BaseTools: merge towards minimum PCD MAX <something> methods

we have 5 different max val or max byte for PCDs.
refactor and remove 2 methods.
we need 3, as one computes for VOID* PCDs.

Cc: Bob Feng <bob.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Carsey, Jaben
2018-04-12 07:08:08 +08:00
committed by Yonghong Zhu
parent 9eb87141ec
commit 25598f8bdb
5 changed files with 31 additions and 44 deletions

View File

@ -1542,25 +1542,19 @@ class DscBuildData(PlatformBuildClassObject):
@staticmethod
def GetPcdMaxSize(Pcd):
if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:
return MAX_SIZE_TYPE[Pcd.DatumType]
MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0
if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:
if Pcd.PcdValueFromComm:
if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):
MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])
elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):
MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])
elif Pcd.PcdValueFromComm.startswith("L\""):
MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])
else:
MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize])
elif Pcd.DatumType not in ['BOOLEAN','UINT8']:
MaxSize = 1
elif Pcd.DatumType == 'UINT16':
MaxSize = 2
elif Pcd.DatumType == 'UINT32':
MaxSize = 4
elif Pcd.DatumType == 'UINT64':
MaxSize = 8
if Pcd.PcdValueFromComm:
if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):
return max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])
elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):
return max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])
elif Pcd.PcdValueFromComm.startswith("L\""):
return max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])
else:
return max([len(Pcd.PcdValueFromComm),MaxSize])
return MaxSize
def GenerateSizeFunction(self,Pcd):