ECC: fix wrong variable name in c.py
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 28 Jan 2008 07:35:26 +0000 (07:35 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 28 Jan 2008 07:35:26 +0000 (07:35 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@979 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Ecc/c.py

index c61c77a..8b366e1 100644 (file)
@@ -63,8 +63,8 @@ def GetIdentifierList():
             SkipLen = 5\r
         LBPos = su.Content.find('{')\r
         RBPos = su.Content.find('}')\r
-        Name = enum.Content[SkipLen:LBPos].strip()\r
-        Value = enum.Content[LBPos+1:RBPos]\r
+        Name = su.Content[SkipLen:LBPos].strip()\r
+        Value = su.Content[LBPos+1:RBPos]\r
         IdPE = DataClass.IdentifierClass(-1, '', '', Name, Value, Type, -1, -1, su.StartPos[0],su.StartPos[1],su.EndPos[0],su.EndPos[1])\r
         IdList.append(IdPE)\r
         \r
@@ -100,6 +100,8 @@ def GetFunctionList():
         ParamBeginOffset = OffsetSkipped\r
         for p in ParamStr.split(','):\r
             ListP = p.split()\r
+            if len(ListP) == 0:\r
+                continue\r
             ParamName = ListP[-1]\r
             RightSpacePos = p.rfind(ParamName)\r
             ParamModifier = p[0:RightSpacePos]\r
@@ -124,38 +126,49 @@ def GetFunctionList():
         \r
     return FuncObjList\r
 \r
-FileObjList = []\r
-for dirpath, dirnames, filenames in os.walk(sys.argv[1]):\r
-    for d in dirnames:\r
-        if d.startswith('.'):\r
-            dirnames.remove(d)\r
-    for f in filenames:\r
-        FullName = os.path.join(dirpath, f)\r
-        if os.path.splitext(f)[1] in ('.h', '.c'):\r
-            model = f.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H\r
-            collector = CodeFragmentCollector.CodeFragmentCollector(FullName)\r
-            collector.ParseFile()\r
-            collector.PrintFragments()\r
-            BaseName = os.path.basename(f)\r
-            DirName = os.path.dirname(FullName)\r
-            Ext = os.path.splitext(f)[1].lstrip('.')\r
-            ModifiedTime = os.path.getmtime(FullName)\r
-            FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])\r
-            FileObjList.append(FileObj)\r
-            collector.CleanFileProfileBuffer()\r
-\r
-\r
+if __name__ == '__main__':\r
 \r
+    FileObjList = []\r
+    tuple = os.walk(sys.argv[1])\r
 \r
-Db = Database.Database(Database.DATABASE_PATH)\r
-Db.InitDatabase()\r
-Db.QueryTable(Db.TblDataModel)\r
+    ParseErrorFileList = []\r
 \r
-for file in FileObjList:\r
+    for dirpath, dirnames, filenames in tuple:\r
+        for d in dirnames:\r
+            if d.startswith('.'):\r
+                dirnames.remove(d)\r
+        for f in filenames:\r
+            FullName = os.path.join(dirpath, f)\r
+            \r
+            if os.path.splitext(f)[1] in ('.h', '.c'):\r
+                print FullName\r
+                model = f.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H\r
+                collector = CodeFragmentCollector.CodeFragmentCollector(FullName)\r
+                try:\r
+                    collector.ParseFile()\r
+                except:\r
+                    ParseErrorFileList.append(FullName)\r
+                    continue\r
+#                collector.PrintFragments()\r
+                BaseName = os.path.basename(f)\r
+                DirName = os.path.dirname(FullName)\r
+                Ext = os.path.splitext(f)[1].lstrip('.')\r
+                ModifiedTime = os.path.getmtime(FullName)\r
+                FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])\r
+                FileObjList.append(FileObj)\r
+                collector.CleanFileProfileBuffer()   \r
+    print ParseErrorFileList\r
+    \r
     EdkLogger.Initialize()\r
-    EdkLogger.SetLevel(EdkLogger.DEBUG_0)\r
-    Db.InsertOneFile(file)\r
-    Db.UpdateIdentifierBelongsToFunction()\r
-    Db.QueryTable(Db.TblIdentifier)\r
+    EdkLogger.SetLevel(EdkLogger.QUIET)\r
+    Db = Database.Database(Database.DATABASE_PATH)\r
+    Db.InitDatabase()\r
+    Db.QueryTable(Db.TblDataModel)\r
     \r
-print 'Done!'\r
+    for file in FileObjList:    \r
+        Db.InsertOneFile(file)\r
+#        Db.UpdateIdentifierBelongsToFunction()\r
+        Db.QueryTable(Db.TblIdentifier)\r
+    Db.Close()\r
+        \r
+    print 'Done!'\r