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: [email protected]
Cc: Gao, Liming <[email protected]>; Zhu, Yonghong <[email protected]>
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 <[email protected]>
Cc: Yonghong Zhu <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <[email protected]>
---
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
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel