]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools: use predefined constants instead of local strings
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FdfParser.py
index 662c232c86e427f97a7be79284644547ab8c1e31..bff1d4739355af0d95264c16dd13cb5e4b44ad34 100644 (file)
@@ -52,6 +52,7 @@ from Common.String import NormPath
 import Common.GlobalData as GlobalData\r
 from Common.Expression import *\r
 from Common import GlobalData\r
+from Common.DataType import *\r
 from Common.String import ReplaceMacro\r
 import uuid\r
 from Common.Misc import tdict\r
@@ -511,8 +512,8 @@ class FdfParser:
         if Item == '' or Item == 'RULE':\r
             return\r
 \r
-        if Item == 'DEFINES':\r
-            self.__CurSection = ['COMMON', 'COMMON', 'COMMON']\r
+        if Item == TAB_COMMON_DEFINES.upper():\r
+            self.__CurSection = [TAB_COMMON, TAB_COMMON, TAB_COMMON]\r
         elif Item == 'VTF' and len(ItemList) == 3:\r
             UiName = ItemList[2]\r
             Pos = UiName.find(',')\r
@@ -520,9 +521,9 @@ class FdfParser:
                 UiName = UiName[:Pos]\r
             self.__CurSection = ['VTF', UiName, ItemList[1]]\r
         elif len(ItemList) > 1:\r
-            self.__CurSection = [ItemList[0], ItemList[1], 'COMMON']\r
+            self.__CurSection = [ItemList[0], ItemList[1], TAB_COMMON]\r
         elif len(ItemList) > 0:\r
-            self.__CurSection = [ItemList[0], 'DUMMY', 'COMMON']\r
+            self.__CurSection = [ItemList[0], 'DUMMY', TAB_COMMON]\r
 \r
     ## PreprocessFile() method\r
     #\r
@@ -886,7 +887,7 @@ class FdfParser:
 \r
         if self.__CurSection:\r
             # Defines macro\r
-            ScopeMacro = self.__MacroDict['COMMON', 'COMMON', 'COMMON']\r
+            ScopeMacro = self.__MacroDict[TAB_COMMON, TAB_COMMON, TAB_COMMON]\r
             if ScopeMacro:\r
                 MacroDict.update(ScopeMacro)\r
     \r
@@ -1131,7 +1132,8 @@ class FdfParser:
             self.__UndoToken()\r
             return False\r
 \r
-    def __Verify(self, Name, Value, Scope):\r
+    @staticmethod\r
+    def __Verify(Name, Value, Scope):\r
         if Scope in ['UINT64', 'UINT8']:\r
             ValueNumber = 0\r
             try:\r
@@ -3200,16 +3202,16 @@ class FdfParser:
                     raise Warning("expected value of %s" % Name, self.FileName, self.CurrentLineNumber)\r
                 Value = self.__Token\r
                 if Name == 'IMAGE_HEADER_INIT_VERSION':\r
-                    if self.__Verify(Name, Value, 'UINT8'):\r
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):\r
                         FmpData.Version = Value\r
                 elif Name == 'IMAGE_INDEX':\r
-                    if self.__Verify(Name, Value, 'UINT8'):\r
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):\r
                         FmpData.ImageIndex = Value\r
                 elif Name == 'HARDWARE_INSTANCE':\r
-                    if self.__Verify(Name, Value, 'UINT8'):\r
+                    if FdfParser.__Verify(Name, Value, 'UINT8'):\r
                         FmpData.HardwareInstance = Value\r
                 elif Name == 'MONOTONIC_COUNT':\r
-                    if self.__Verify(Name, Value, 'UINT64'):\r
+                    if FdfParser.__Verify(Name, Value, 'UINT64'):\r
                         FmpData.MonotonicCount = Value\r
                         if FmpData.MonotonicCount.upper().startswith('0X'):\r
                             FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)\r
@@ -3585,7 +3587,7 @@ class FdfParser:
             raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)\r
 \r
         Arch = self.__SkippedChars.rstrip(".")\r
-        if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "AARCH64", "COMMON"):\r
+        if Arch.upper() not in ARCH_LIST_FULL:\r
             raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber)\r
 \r
         ModuleType = self.__GetModuleType()\r