-\r
- if PcdValue == 'True':\r
- PcdValue = '1'\r
- if PcdValue == 'False':\r
- PcdValue = '0'\r
- if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:\r
- PcdValue = PcdValue.strip()\r
- if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):\r
- PcdValue = PcdValue[1:-1].split(',')\r
- if type(PcdValue) == type([]):\r
- TmpValue = 0\r
- Size = 0\r
- for Item in PcdValue:\r
- if Item.startswith('UINT16'):\r
- ItemSize = 2\r
- elif Item.startswith('UINT32'):\r
- ItemSize = 4\r
- elif Item.startswith('UINT64'):\r
- ItemSize = 8\r
- else:\r
- ItemSize = 0\r
- Item = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)\r
-\r
- if ItemSize == 0:\r
- ItemValue, ItemSize = ParseFieldValue(Item)\r
- else:\r
- ItemValue = ParseFieldValue(Item)[0]\r
-\r
- if type(ItemValue) == type(''):\r
- ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue)\r
-\r
- TmpValue = (ItemValue << (Size * 8)) | TmpValue\r
- Size = Size + ItemSize\r
- else:\r
- TmpValue, Size = ParseFieldValue(PcdValue)\r
- if type(TmpValue) == type(''):\r
- TmpValue = int(TmpValue)\r
- else:\r
- PcdValue = '0x%0{}X'.format(Size) % (TmpValue)\r
- if TmpValue < 0:\r
- raise BadExpression('Type %s PCD Value is negative' % self.PcdType)\r
- if self.PcdType == 'UINT8' and Size > 1:\r
- raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType)\r
- if self.PcdType == 'UINT16' and Size > 2:\r
- raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType)\r
- if self.PcdType == 'UINT32' and Size > 4:\r
- raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType)\r
- if self.PcdType == 'UINT64' and Size > 8:\r
- raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType)\r
- if self.PcdType in ['VOID*']:\r
- try:\r
- TmpValue = long(PcdValue)\r
- TmpList = []\r
- if TmpValue.bit_length() == 0:\r
- PcdValue = '{0x00}'\r
- else:\r
- for I in range((TmpValue.bit_length() + 7) / 8):\r
- TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))\r
- PcdValue = '{' + ', '.join(TmpList) + '}'\r
- except:\r
- if PcdValue.strip().startswith('{'):\r
- PcdValue = PcdValue.strip()[1:-1].strip()\r
+ except BadExpression:\r
+ if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:\r
+ PcdValue = PcdValue.strip()\r
+ if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'):\r
+ PcdValue = PcdValue[1:-1].split(',')\r
+ if type(PcdValue) == type([]):\r
+ TmpValue = 0\r