public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhu, Yonghong" <yonghong.zhu@intel.com>
To: "Carsey, Jaben" <jaben.carsey@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Zhu, Yonghong" <yonghong.zhu@intel.com>
Subject: Re: [PATCH v1 1/4] BaseTools: remove irrelevant code
Date: Wed, 28 Mar 2018 02:17:31 +0000	[thread overview]
Message-ID: <B9726D6DCCFB8B4CA276A9169B02216D51FBE92F@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <a2fab6fef128bb0af37bdc49061b24082d004cb5.1522194073.git.jaben.carsey@intel.com>

Hi Jaben,

Current we support flexible PCD value format, example:  UINT64 type PCD can use {0x1, 2, 'A', UINT16(10), "B"} as its value, so the block can't be removed since it maybe a list after SplitPcdValueString function.
https://bugzilla.tianocore.org/show_bug.cgi?id=541 is the feature request for flexible Pcd value format.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Wednesday, March 28, 2018 7:43 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 1/4] BaseTools: remove irrelevant code

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 <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>
---
 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/Source/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', 'BOOLEAN']:
                 PcdValue = PcdValue.strip()
-                if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):
+                if PcdValue.startswith('{') and PcdValue.endswith('}'):
                     PcdValue = SplitPcdValueString(PcdValue[1:-1])
-                if type(PcdValue) == type([]):
-                    TmpValue = 0
-                    Size = 0
-                    ValueType = ''
-                    for Item in PcdValue:
-                        Item = Item.strip()
-                        if Item.startswith('UINT8'):
-                            ItemSize = 1
-                            ValueType = 'UINT8'
-                        elif Item.startswith('UINT16'):
-                            ItemSize = 2
-                            ValueType = 'UINT16'
-                        elif Item.startswith('UINT32'):
-                            ItemSize = 4
-                            ValueType = 'UINT32'
-                        elif Item.startswith('UINT64'):
-                            ItemSize = 8
-                            ValueType = 'UINT64'
-                        elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'):
-                            ItemSize = 0
-                            ValueType = 'VOID*'
-                        else:
-                            ItemSize = 0
-                            ValueType = 'UINT8'
-                        Item = ValueExpressionEx(Item, ValueType, self._Symb)(True)
-
-                        if ItemSize == 0:
-                            try:
-                                tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0)
-                                if tmpValue > 255:
-                                    raise BadExpression("Byte  array number %s should less than 0xFF." % Item)
-                            except BadExpression, Value:
-                                raise BadExpression(Value)
-                            except ValueError:
-                                pass
-                            ItemValue, ItemSize = ParseFieldValue(Item)
-                        else:
-                            ItemValue = ParseFieldValue(Item)[0]
-
-                        if type(ItemValue) == type(''):
-                            ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue)
-
-                        TmpValue = (ItemValue << (Size * 8)) | TmpValue
-                        Size = Size + ItemSize
-                else:
-                    try:
-                        TmpValue, Size = ParseFieldValue(PcdValue)
-                    except BadExpression, Value:
-                        raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))
+                try:
+                    TmpValue, Size = ParseFieldValue(PcdValue)
+                except BadExpression, Value:
+                    raise BadExpression("Type: %s, Value: %s, %s" % 
+ (self.PcdType, PcdValue, Value))
                 if type(TmpValue) == type(''):
                     try:
                         TmpValue = int(TmpValue)
--
2.16.2.windows.1



  reply	other threads:[~2018-03-28  2:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 23:42 [PATCH v1 0/4] BaseTools: remove code without affect Jaben Carsey
2018-03-27 23:42 ` [PATCH v1 1/4] BaseTools: remove irrelevant code Jaben Carsey
2018-03-28  2:17   ` Zhu, Yonghong [this message]
2018-03-28 14:57     ` Carsey, Jaben
2018-03-28 20:22     ` Carsey, Jaben
2018-03-27 23:42 ` [PATCH v1 2/4] BaseTools: expression can use single in instead of 3 API calls Jaben Carsey
2018-03-29  2:55   ` Zhu, Yonghong
2018-03-27 23:42 ` [PATCH v1 3/4] BaseTools: move regular expression compile out of function call Jaben Carsey
2018-03-29  2:55   ` Zhu, Yonghong
2018-03-27 23:42 ` [PATCH v1 4/4] BaseTools: dont use enumerate when un-needed Jaben Carsey
2018-03-29  2:55   ` Zhu, Yonghong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B9726D6DCCFB8B4CA276A9169B02216D51FBE92F@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox