From d0a0c52c221e5dcf82f24d4346c1cf52109d6dfb Mon Sep 17 00:00:00 2001 From: "Carsey, Jaben" Date: Sat, 28 Apr 2018 06:32:48 +0800 Subject: BaseTools: standardize GUID and pack size currently GUID packing and pack size determination is spread throughout the code. This introduces a shared function and dict and routes all code paths through them. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu --- .../Python/AutoGen/ValidCheckingInfoObject.py | 26 ++++------------------ 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py') diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py index 92c8fe2df9..64d4965e96 100644 --- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py +++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py @@ -35,12 +35,6 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): def dump(self, dest, Phase): - FormatMap = {} - FormatMap[1] = "=B" - FormatMap[2] = "=H" - FormatMap[4] = "=L" - FormatMap[8] = "=Q" - if not os.path.isabs(dest): return if not os.path.exists(dest): @@ -106,19 +100,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): realLength += 4 Guid = var_check_tab.Guid - b = pack('=LHHBBBBBBBB', - Guid[0], - Guid[1], - Guid[2], - Guid[3], - Guid[4], - Guid[5], - Guid[6], - Guid[7], - Guid[8], - Guid[9], - Guid[10], - ) + b = PackByteFormatGUID(Guid) Buffer += b realLength += 16 @@ -156,14 +138,14 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): realLength += 1 for v_data in item.data: if type(v_data) in (int, long): - b = pack(FormatMap[item.StorageWidth], v_data) + b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data) Buffer += b realLength += item.StorageWidth else: - b = pack(FormatMap[item.StorageWidth], v_data[0]) + b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data[0]) Buffer += b realLength += item.StorageWidth - b = pack(FormatMap[item.StorageWidth], v_data[1]) + b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data[1]) Buffer += b realLength += item.StorageWidth -- cgit v1.2.3