]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools: replace 'UINT8','UINT16','UINT32','UINT64','VOID*' with shared constants.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index bd443fe6261aefc0cf68112569e082e1e04790ba..56b5d399727e4f68af31d654c4115047286267c6 100644 (file)
@@ -762,7 +762,7 @@ class WorkspaceAutoGen(AutoGen):
                         for Module in Pa.ModuleAutoGenList:\r
                             if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):\r
                                 InfFoundFlag = True\r
-                                if not Module.Guid.upper() in _GuidDict.keys():\r
+                                if Module.Guid.upper() not in _GuidDict:\r
                                     _GuidDict[Module.Guid.upper()] = FfsFile\r
                                     break\r
                                 else:\r
@@ -789,7 +789,7 @@ class WorkspaceAutoGen(AutoGen):
                             # BuildObject from one of AutoGenObjectList is enough.\r
                             #\r
                             InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_COMMON, self.BuildTarget, self.ToolChain]\r
-                            if not InfObj.Guid.upper() in _GuidDict.keys():\r
+                            if InfObj.Guid.upper() not in _GuidDict:\r
                                 _GuidDict[InfObj.Guid.upper()] = FfsFile\r
                             else:\r
                                 EdkLogger.error("build",\r
@@ -837,7 +837,7 @@ class WorkspaceAutoGen(AutoGen):
                                                             "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue),\r
                                                             ExtraData=self.FdfFile)\r
 \r
-                                        if not _PcdGuidString.upper() in _GuidDict.keys():\r
+                                        if _PcdGuidString.upper() not in _GuidDict:\r
                                             _GuidDict[_PcdGuidString.upper()] = FfsFile\r
                                             PcdFoundFlag = True\r
                                             break\r
@@ -851,7 +851,7 @@ class WorkspaceAutoGen(AutoGen):
                                                                                                                                            FfsFile.NameGuid.upper()),\r
                                                             ExtraData=self.FdfFile)\r
 \r
-                    if not FfsFile.NameGuid.upper() in _GuidDict.keys():\r
+                    if FfsFile.NameGuid.upper() not in _GuidDict:\r
                         _GuidDict[FfsFile.NameGuid.upper()] = FfsFile\r
                     else:\r
                         #\r
@@ -1394,7 +1394,7 @@ class PlatformAutoGen(AutoGen):
 \r
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:\r
                 # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
-                if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
+                if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']:\r
                     NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
 \r
                 # Check the PCD from Binary INF or Source INF\r
@@ -1402,10 +1402,8 @@ class PlatformAutoGen(AutoGen):
                     PcdFromModule.IsFromBinaryInf = True\r
 \r
                 # Check the PCD from DSC or not \r
-                if (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds.keys():\r
-                    PcdFromModule.IsFromDsc = True\r
-                else:\r
-                    PcdFromModule.IsFromDsc = False\r
+                PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds\r
+\r
                 if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:\r
                     if F.Path not in FdfModuleList:\r
                         # If one of the Source built modules listed in the DSC is not listed \r
@@ -1473,7 +1471,7 @@ class PlatformAutoGen(AutoGen):
                                         ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"\r
                                         % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))\r
                     # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
-                    if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:\r
+                    if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']:\r
                         NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))\r
                     if M.ModuleType in ["PEIM", "PEI_CORE"]:\r
                         PcdFromModule.Phase = "PEI"\r
@@ -1532,22 +1530,22 @@ class PlatformAutoGen(AutoGen):
         VpdFile               = VpdInfoFile.VpdInfoFile()\r
         NeedProcessVpdMapFile = False\r
 \r
-        for pcd in self.Platform.Pcds.keys():\r
-            if pcd not in self._PlatformPcds.keys():\r
+        for pcd in self.Platform.Pcds:\r
+            if pcd not in self._PlatformPcds:\r
                 self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r
 \r
         for item in self._PlatformPcds:\r
             if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
-                self._PlatformPcds[item].DatumType = "VOID*"\r
+                self._PlatformPcds[item].DatumType = TAB_VOID\r
 \r
         if (self.Workspace.ArchList[-1] == self.Arch): \r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
-                Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+                Sku = Pcd.SkuInfoList.values()[0]\r
                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
 \r
                 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
-                    Pcd.DatumType = "VOID*"\r
+                    Pcd.DatumType = TAB_VOID\r
 \r
                     # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
                     # if found HII type PCD then insert to right of UnicodeIndex\r
@@ -1630,7 +1628,7 @@ class PlatformAutoGen(AutoGen):
                 if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
                     if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):\r
                         FoundFlag = False\r
-                        for VpdPcd in VpdFile._VpdArray.keys():\r
+                        for VpdPcd in VpdFile._VpdArray:\r
                             # This PCD has been referenced by module\r
                             if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
                                (VpdPcd.TokenCName == DscPcdEntry.TokenCName):\r
@@ -1699,7 +1697,7 @@ class PlatformAutoGen(AutoGen):
                                 SkuValueMap[PcdValue].append(Sku)\r
                                 if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
                                     NeedProcessVpdMapFile = True \r
-                            if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
+                            if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"):\r
                                 UnicodePcdArray.add(DscPcdEntry)\r
                             elif len(Sku.VariableName) > 0:\r
                                 HiiPcdArray.add(DscPcdEntry)\r
@@ -1742,14 +1740,14 @@ class PlatformAutoGen(AutoGen):
             # Delete the DynamicPcdList At the last time enter into this function\r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
-                Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+                Sku = Pcd.SkuInfoList.values()[0]\r
                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
 \r
                 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
-                    Pcd.DatumType = "VOID*"\r
+                    Pcd.DatumType = TAB_VOID\r
 \r
                 PcdValue = Sku.DefaultValue\r
-                if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
+                if Pcd.DatumType == TAB_VOID and PcdValue.startswith("L"):\r
                     # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
                     UnicodePcdArray.add(Pcd)\r
                 elif len(Sku.VariableName) > 0:\r
@@ -2371,7 +2369,7 @@ class PlatformAutoGen(AutoGen):
             ToPcd.validlists = FromPcd.validlists\r
             ToPcd.expressions = FromPcd.expressions\r
 \r
-        if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
+        if FromPcd is not None and ToPcd.DatumType == TAB_VOID and ToPcd.MaxDatumSize in ['', None]:\r
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
                             % (ToPcd.TokenSpaceGuidCName, TokenCName))\r
             Value = ToPcd.DefaultValue\r
@@ -2447,7 +2445,7 @@ class PlatformAutoGen(AutoGen):
         # use PCD value to calculate the MaxDatumSize when it is not specified\r
         for Name, Guid in Pcds:\r
             Pcd = Pcds[Name, Guid]\r
-            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:\r
+            if Pcd.DatumType == TAB_VOID and Pcd.MaxDatumSize in ['', None]:\r
                 Pcd.MaxSizeUserSet = None\r
                 Value = Pcd.DefaultValue\r
                 if Value in [None, '']:\r
@@ -2482,7 +2480,7 @@ class PlatformAutoGen(AutoGen):
             for LibraryName in M.Libraries:\r
                 Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r
                 if Library is None:\r
-                    for Key in self.Platform.LibraryClasses.data.keys():\r
+                    for Key in self.Platform.LibraryClasses.data:\r
                         if LibraryName.upper() == Key.upper():\r
                             Library = self.Platform.LibraryClasses[Key, ':dummy:']\r
                             break\r
@@ -3105,7 +3103,7 @@ class ModuleAutoGen(AutoGen):
             InfObj = InfSectionParser.InfSectionParser(Filename)\r
             DepexExpresionList = InfObj.GetDepexExpresionList()\r
             for DepexExpresion in DepexExpresionList:\r
-                for key in DepexExpresion.keys():\r
+                for key in DepexExpresion:\r
                     Arch, ModuleType = key\r
                     DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')]\r
                     # the type of build module is USER_DEFINED.\r
@@ -3123,7 +3121,7 @@ class ModuleAutoGen(AutoGen):
         #the type of build module is USER_DEFINED.\r
         if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
             for Depex in DepexList:\r
-                for key in Depex.keys():\r
+                for key in Depex:\r
                     DepexStr += '[Depex.%s.%s]\n' % key\r
                     DepexStr += '\n'.join(['# '+ val for val in Depex[key]])\r
                     DepexStr += '\n\n'\r
@@ -3233,7 +3231,7 @@ class ModuleAutoGen(AutoGen):
             InfObj = InfSectionParser.InfSectionParser(Filename)\r
             TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()\r
             for TianoCoreUserExtent in TianoCoreUserExtenList:\r
-                for Section in TianoCoreUserExtent.keys():\r
+                for Section in TianoCoreUserExtent:\r
                     ItemList = Section.split(TAB_SPLIT)\r
                     Arch = self.Arch\r
                     if len(ItemList) == 4:\r
@@ -4115,13 +4113,13 @@ class ModuleAutoGen(AutoGen):
                     elif BoolValue == 'FALSE':\r
                         Pcd.DefaultValue = '0'\r
 \r
-                if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:\r
+                if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:\r
                     HexFormat = '0x%02x'\r
-                    if Pcd.DatumType == 'UINT16':\r
+                    if Pcd.DatumType == TAB_UINT16:\r
                         HexFormat = '0x%04x'\r
-                    elif Pcd.DatumType == 'UINT32':\r
+                    elif Pcd.DatumType == TAB_UINT32:\r
                         HexFormat = '0x%08x'\r
-                    elif Pcd.DatumType == 'UINT64':\r
+                    elif Pcd.DatumType == TAB_UINT64:\r
                         HexFormat = '0x%016x'\r
                     PcdValue = HexFormat % int(Pcd.DefaultValue, 0)\r
                 else:\r