BaseTools: merge towards minimum PCD MAX <something> methods
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / DscBuildData.py
index 1ca8109b4864f11a7294ac7d60eb24a26336eac0..d6b8b761d607db80b04e551341d8dbbe88e4d027 100644 (file)
@@ -1542,25 +1542,19 @@ class DscBuildData(PlatformBuildClassObject):
 \r
     @staticmethod\r
     def GetPcdMaxSize(Pcd):\r
+        if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:\r
+            return MAX_SIZE_TYPE[Pcd.DatumType]\r
+\r
         MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0\r
-        if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:\r
-            if Pcd.PcdValueFromComm:\r
-                if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):\r
-                    MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])\r
-                elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):\r
-                    MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])\r
-                elif Pcd.PcdValueFromComm.startswith("L\""):\r
-                    MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])\r
-                else:\r
-                    MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize])\r
-        elif Pcd.DatumType not in ['BOOLEAN','UINT8']:\r
-            MaxSize = 1\r
-        elif Pcd.DatumType  == 'UINT16':\r
-            MaxSize = 2\r
-        elif Pcd.DatumType  == 'UINT32':\r
-            MaxSize = 4\r
-        elif Pcd.DatumType  == 'UINT64':\r
-            MaxSize = 8\r
+        if Pcd.PcdValueFromComm:\r
+            if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):\r
+                return max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])\r
+            elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):\r
+                return max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])\r
+            elif Pcd.PcdValueFromComm.startswith("L\""):\r
+                return max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])\r
+            else:\r
+                return max([len(Pcd.PcdValueFromComm),MaxSize])\r
         return MaxSize\r
 \r
     def GenerateSizeFunction(self,Pcd):\r