From nobody Fri Nov 1 03:34:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1522789404720277.24778357740126; Tue, 3 Apr 2018 14:03:24 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9F6A6226085B4; Tue, 3 Apr 2018 14:03:14 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1AC67221467CC for ; Tue, 3 Apr 2018 14:03:12 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 14:03:11 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga002.jf.intel.com with ESMTP; 03 Apr 2018 14:03:11 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,402,1517904000"; d="scan'208";a="47710154" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 3 Apr 2018 14:03:01 -0700 Message-Id: <016c7d4269f748607394053380b5b7ebe335257e.1522789210.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 01/10] BaseTools: Use local variable for list of constants. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" instead of listing in multiple places, use a single list. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/GenC.py | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index 4d9ea1b2a8b1..8d76aabd5367 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -41,6 +41,8 @@ gItemTypeStringDatabase =3D { TAB_PCDS_DYNAMIC_EX_HII : '', } =20 +_NumericDataTypesList =3D ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN= '] + ## Dynamic PCD types gDynamicPcd =3D [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNA= MIC_VPD, TAB_PCDS_DYNAMIC_HII] =20 @@ -869,7 +871,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): TokenCNameList.append(TokenCName) =20 def GetPcdSize(Pcd): - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLE= AN']: + if Pcd.DatumType not in _NumericDataTypesList: Value =3D Pcd.DefaultValue if Value in [None, '']: return 1 @@ -975,7 +977,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % = (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -985,7 +987,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1004,7 +1006,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSi= zeName, PcdTokenName)) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) else: @@ -1081,7 +1083,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('U'): Value +=3D 'U' - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'B= OOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize =3D=3D '': EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % = (Pcd.TokenSpaceGuidCName, TokenCName), @@ -1132,7 +1134,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): else: PcdValueName =3D '_PCD_VALUE_' + TokenCName =20 - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'B= OOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: # # For unicode, UINT16 array will be generated, so the alignmen= t of unicode is guaranteed. # @@ -1180,7 +1182,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, Pcd= VariableName)) =20 if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s,= (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName= , Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s= , (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeSta= tusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) else: @@ -1250,7 +1252,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): =20 Type =3D '' Array =3D '' - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLE= AN']: + if Pcd.DatumType not in _NumericDataTypesList: if Pcd.DefaultValue[0]=3D=3D '{': Type =3D '(VOID *)' Array =3D '[]' @@ -1275,7 +1277,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % = (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1285,7 +1287,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1306,7 +1308,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSi= zeName, PcdTokenName)) - if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'B= OOLEAN']: + if DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) else: @@ -1314,7 +1316,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Valu= e))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) if PcdItemType =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PA= TCHABLE_IN_MODULE] + '_' + TokenCName - if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLE= AN']: + if DatumType not in _NumericDataTypesList: ArraySize =3D int(Pcd.MaxDatumSize, 0) if Pcd.DefaultValue[0] =3D=3D 'L': ArraySize =3D ArraySize / 2 @@ -1325,7 +1327,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, P= cdVariableName, Array)) AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeNa= me, Type, TokenCName)) PcdDataSize =3D GetPcdSize(Pcd) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'B= OOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UI= NTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, To= kenCName, TokenCName, TokenCName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (U= INTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusN= ame, TokenCName, TokenCName, TokenCName)) AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pc= d.MaxDatumSize)) @@ -1349,7 +1351,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed= to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) =20 if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD and (key in Info.Con= stPcd or (Info.IsLibrary and not Info._ReferenceModules)): - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType not in _NumericDataTypesList: AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCNam= e, Type, PcdVariableName)) else: AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName,= Pcd.DefaultValue)) --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel