]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools: GenFds - move RegEx compile
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FdfParser.py
index 5dbcb96bbd834b204481096e8407457954f9ddc4..00e03446421d1953725f9f5c6dc0f2cad2cf03c5 100644 (file)
@@ -85,6 +85,7 @@ RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<s
 RegionSizeGuidPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*\|\s*(?P<size>\w+\.\w+)\s*")\r
 RegionOffsetPcdPattern = re.compile("\s*(?P<base>\w+\.\w+)\s*$")\r
 ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")\r
+BaseAddrValuePattern = re.compile('^0[xX][0-9a-fA-F]+')\r
 \r
 AllIncludeFileList = []\r
 \r
@@ -704,7 +705,8 @@ class FdfParser:
         # Preprocess done.\r
         self.Rewind()\r
         \r
-    def __GetIfListCurrentItemStat(self, IfList):\r
+    @staticmethod\r
+    def __GetIfListCurrentItemStat(IfList):\r
         if len(IfList) == 0:\r
             return True\r
         \r
@@ -2210,9 +2212,7 @@ class FdfParser:
         if not self.__GetNextToken():\r
             raise Warning("expected FV base address value", self.FileName, self.CurrentLineNumber)\r
 \r
-        IsValidBaseAddrValue = re.compile('^0[x|X][0-9a-fA-F]+')\r
-\r
-        if not IsValidBaseAddrValue.match(self.__Token.upper()):\r
+        if not BaseAddrValuePattern.match(self.__Token.upper()):\r
             raise Warning("Unknown FV base address value '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)\r
         Obj.FvBaseAddress = self.__Token\r
         return True  \r
@@ -2625,13 +2625,12 @@ class FdfParser:
     #\r
     #   Check whether reloc strip flag can be set for a file type.\r
     #\r
-    #   @param  self        The object pointer\r
     #   @param  FileType    The file type to check with\r
     #   @retval True        This type could have relocation strip flag\r
     #   @retval False       No way to have it\r
     #\r
-\r
-    def __FileCouldHaveRelocFlag (self, FileType):\r
+    @staticmethod\r
+    def __FileCouldHaveRelocFlag (FileType):\r
         if FileType in ('SEC', 'PEI_CORE', 'PEIM', 'PEI_DXE_COMBO'):\r
             return True\r
         else:\r
@@ -2641,13 +2640,12 @@ class FdfParser:
     #\r
     #   Check whether reloc strip flag can be set for a section type.\r
     #\r
-    #   @param  self        The object pointer\r
     #   @param  SectionType The section type to check with\r
     #   @retval True        This type could have relocation strip flag\r
     #   @retval False       No way to have it\r
     #\r
-\r
-    def __SectionCouldHaveRelocFlag (self, SectionType):\r
+    @staticmethod\r
+    def __SectionCouldHaveRelocFlag (SectionType):\r
         if SectionType in ('TE', 'PE32'):\r
             return True\r
         else:\r
@@ -3986,12 +3984,12 @@ class FdfParser:
     #\r
     #   Get whether a section could be optional\r
     #\r
-    #   @param  self        The object pointer\r
     #   @param  SectionType The section type to check\r
     #   @retval True        section could be optional\r
     #   @retval False       section never optional\r
     #\r
-    def __RuleSectionCouldBeOptional(self, SectionType):\r
+    @staticmethod\r
+    def __RuleSectionCouldBeOptional(SectionType):\r
         if SectionType in ("DXE_DEPEX", "UI", "VERSION", "PEI_DEPEX", "RAW", "SMM_DEPEX"):\r
             return True\r
         else:\r
@@ -4001,12 +3999,12 @@ class FdfParser:
     #\r
     #   Get whether a section could have build number information\r
     #\r
-    #   @param  self        The object pointer\r
     #   @param  SectionType The section type to check\r
     #   @retval True        section could have build number information\r
     #   @retval False       section never have build number information\r
     #\r
-    def __RuleSectionCouldHaveBuildNum(self, SectionType):\r
+    @staticmethod\r
+    def __RuleSectionCouldHaveBuildNum(SectionType):\r
         if SectionType in ("VERSION"):\r
             return True\r
         else:\r
@@ -4016,12 +4014,12 @@ class FdfParser:
     #\r
     #   Get whether a section could have string\r
     #\r
-    #   @param  self        The object pointer\r
     #   @param  SectionType The section type to check\r
     #   @retval True        section could have string\r
     #   @retval False       section never have string\r
     #\r
-    def __RuleSectionCouldHaveString(self, SectionType):\r
+    @staticmethod\r
+    def __RuleSectionCouldHaveString(SectionType):\r
         if SectionType in ("UI", "VERSION"):\r
             return True\r
         else:\r