From nobody Fri May 3 04:50:02 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 1522194178980208.33334756828958; Tue, 27 Mar 2018 16:42:58 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2AA7821F85E6C; Tue, 27 Mar 2018 16:36:18 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 97CC121E256AC for ; Tue, 27 Mar 2018 16:36:16 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 16:42:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2018 16:42:52 -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.100; helo=mga07.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,368,1517904000"; d="scan'208";a="28995252" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 27 Mar 2018 16:42:44 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 1/4] BaseTools: remove irrelevant code 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" Since PcdValue is a string, no need to test it's type() for string Also remove the block used if it's a list (which is never is) Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Expression.py | 55 ++------------------ 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 4f0f377f3788..b70f7da1233e 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -815,57 +815,12 @@ class ValueExpressionEx(ValueExpression): except BadExpression, Value: if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BO= OLEAN']: PcdValue =3D PcdValue.strip() - if type(PcdValue) =3D=3D type('') and PcdValue.startswith(= '{') and PcdValue.endswith('}'): + if PcdValue.startswith('{') and PcdValue.endswith('}'): PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) - if type(PcdValue) =3D=3D type([]): - TmpValue =3D 0 - Size =3D 0 - ValueType =3D '' - for Item in PcdValue: - Item =3D Item.strip() - if Item.startswith('UINT8'): - ItemSize =3D 1 - ValueType =3D 'UINT8' - elif Item.startswith('UINT16'): - ItemSize =3D 2 - ValueType =3D 'UINT16' - elif Item.startswith('UINT32'): - ItemSize =3D 4 - ValueType =3D 'UINT32' - elif Item.startswith('UINT64'): - ItemSize =3D 8 - ValueType =3D 'UINT64' - elif Item.startswith('"') or Item.startswith("'") = or Item.startswith('L'): - ItemSize =3D 0 - ValueType =3D 'VOID*' - else: - ItemSize =3D 0 - ValueType =3D 'UINT8' - Item =3D ValueExpressionEx(Item, ValueType, self._= Symb)(True) - - if ItemSize =3D=3D 0: - try: - tmpValue =3D int(Item, 16) if Item.upper()= .startswith('0X') else int(Item, 0) - if tmpValue > 255: - raise BadExpression("Byte array numbe= r %s should less than 0xFF." % Item) - except BadExpression, Value: - raise BadExpression(Value) - except ValueError: - pass - ItemValue, ItemSize =3D ParseFieldValue(Item) - else: - ItemValue =3D ParseFieldValue(Item)[0] - - if type(ItemValue) =3D=3D type(''): - ItemValue =3D int(ItemValue, 16) if ItemValue.= startswith('0x') else int(ItemValue) - - TmpValue =3D (ItemValue << (Size * 8)) | TmpValue - Size =3D Size + ItemSize - else: - try: - TmpValue, Size =3D ParseFieldValue(PcdValue) - except BadExpression, Value: - raise BadExpression("Type: %s, Value: %s, %s" % (s= elf.PcdType, PcdValue, Value)) + try: + TmpValue, Size =3D ParseFieldValue(PcdValue) + except BadExpression, Value: + raise BadExpression("Type: %s, Value: %s, %s" % (self.= PcdType, PcdValue, Value)) if type(TmpValue) =3D=3D type(''): try: TmpValue =3D int(TmpValue) --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:50:02 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 1522194181993978.6023300828058; Tue, 27 Mar 2018 16:43:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8F34C21F85E7D; Tue, 27 Mar 2018 16:36:20 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 B067621F85E62 for ; Tue, 27 Mar 2018 16:36:16 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 16:42:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2018 16:42:52 -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.100; helo=mga07.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,368,1517904000"; d="scan'208";a="28995255" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 27 Mar 2018 16:42:45 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 2/4] BaseTools: expression can use single in instead of 3 API calls. 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" change 3 StartsWith() calls to a single 'in' operation. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/Common/Expression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index b70f7da1233e..3f2b43118553 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -948,7 +948,7 @@ class ValueExpressionEx(ValueExpression): Item =3D '0x%x' % TmpValue if type(TmpValu= e) !=3D type('') else TmpValue if ItemSize =3D=3D 0: ItemValue, ItemSize =3D ParseFieldValu= e(Item) - if not (Item.startswith('"') or Item.s= tartswith('L') or Item.startswith('{')) and ItemSize > 1: + if Item[0] not in ['"','L','{'] and It= emSize > 1: raise BadExpression("Byte array n= umber %s should less than 0xFF." % Item) else: ItemValue =3D ParseFieldValue(Item)[0] --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:50:02 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 1522194187778124.94525586177906; Tue, 27 Mar 2018 16:43:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 70F60220C2A68; Tue, 27 Mar 2018 16:36:21 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 D0F2021F85E65 for ; Tue, 27 Mar 2018 16:36:16 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 16:42:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2018 16:42:52 -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.100; helo=mga07.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,368,1517904000"; d="scan'208";a="28995261" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 27 Mar 2018 16:42:46 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 3/4] BaseTools: move regular expression compile out of function call. 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" move to the root of the file and dont recompile. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/Common/Expression.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 3f2b43118553..340c50ebe00f 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -41,6 +41,8 @@ ERR_EMPTY_EXPR =3D 'Empty expression is not allo= wed.' ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY= ), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' =20 __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') +_ReLabel =3D re.compile('LABEL\((\w+)\)') +_ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') =20 ## SplitString # Split string to list according double quote @@ -853,13 +855,11 @@ class ValueExpressionEx(ValueExpression): PcdValueList =3D SplitPcdValueString(PcdValue.stri= p()[1:-1]) LabelDict =3D {} NewPcdValueList =3D [] - ReLabel =3D re.compile('LABEL\((\w+)\)') - ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') LabelOffset =3D 0 for Index, Item in enumerate(PcdValueList): # compute byte offset of every LABEL - LabelList =3D ReLabel.findall(Item) - Item =3D ReLabel.sub('', Item) + LabelList =3D _ReLabel.findall(Item) + Item =3D _ReLabel.sub('', Item) Item =3D Item.strip() if LabelList: for Label in LabelList: @@ -886,11 +886,11 @@ class ValueExpressionEx(ValueExpression): # for LABEL parse Item =3D Item.strip() try: - Item =3D ReLabel.sub('', Item) + Item =3D _ReLabel.sub('', Item) except: pass try: - OffsetList =3D ReOffset.findall(Item) + OffsetList =3D _ReOffset.findall(Item) except: pass for Offset in OffsetList: --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:50:02 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 1522194184916329.0065344896701; Tue, 27 Mar 2018 16:43:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F2FC12205B92F; Tue, 27 Mar 2018 16:36:20 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 BFDF121F85E64 for ; Tue, 27 Mar 2018 16:36:16 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2018 16:42:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2018 16:42:52 -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.100; helo=mga07.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,368,1517904000"; d="scan'208";a="28995264" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 27 Mar 2018 16:42:47 -0700 Message-Id: <76b0832a94769d586d234dfeb59fa94acd12aeb7.1522194073.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 4/4] BaseTools: dont use enumerate when un-needed 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" Since we only use the item from the list and not the numeric value, dont bother with enumerate() Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/Common/Expression.py | 4 ++-- BaseTools/Source/Python/Common/Misc.py | 2 +- BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 340c50ebe00f..f28d770aad94 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -856,7 +856,7 @@ class ValueExpressionEx(ValueExpression): LabelDict =3D {} NewPcdValueList =3D [] LabelOffset =3D 0 - for Index, Item in enumerate(PcdValueList): + for Item in PcdValueList: # compute byte offset of every LABEL LabelList =3D _ReLabel.findall(Item) Item =3D _ReLabel.sub('', Item) @@ -882,7 +882,7 @@ class ValueExpressionEx(ValueExpression): except: LabelOffset =3D LabelOffset + 1 =20 - for Index, Item in enumerate(PcdValueList): + for Item in PcdValueList: # for LABEL parse Item =3D Item.strip() try: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 7d44fdcf8ba7..8f479ace4cb1 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -76,7 +76,7 @@ def GetVariableOffset(mapfilepath, efifilepath, varnames): def _parseForXcode(lines, efifilepath, varnames): status =3D 0 ret =3D [] - for index, line in enumerate(lines): + for line in lines: line =3D line.strip() if status =3D=3D 0 and line =3D=3D "# Symbols:": status =3D 1 diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b= /BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index fdad5a44dc3d..0a701158e2c2 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -65,7 +65,7 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): def _parseForXcode(lines, efifilepath): status =3D 0 pcds =3D [] - for index, line in enumerate(lines): + for line in lines: line =3D line.strip() if status =3D=3D 0 and line =3D=3D "# Symbols:": status =3D 1 --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel