BaseTools: Fix PcdArray issue

https://bugzilla.tianocore.org/show_bug.cgi?id=1390

1. support hex number for array index
2. support Non-Dynamic Pcd for array data type
3. support {} and {CODE()} for array data type
4. Change GetStructurePcdMaxSize to be a static function since it need to
be called in another static function. And this function does not depend on
it's class instance.
5. Add unittest for RemoveCComments function and
ArrayIndex regular expression.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Philippe Mathieu-Daud? <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Feng, Bob C
2018-12-15 00:15:21 +08:00
committed by BobCF
parent 778c764050
commit 4c6e6f9f75
4 changed files with 99 additions and 23 deletions

View File

@ -19,7 +19,7 @@ from collections import OrderedDict
from Common.Misc import CopyDict
import copy
StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$')
ArrayIndex = re.compile("\[\s*\d{0,1}\s*\]")
ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]")
## PcdClassObject
#
# This Class is used for PcdObject
@ -84,6 +84,7 @@ class PcdClassObject(object):
maxsize = item.lstrip("[").rstrip("]").strip()
if not maxsize:
maxsize = "-1"
maxsize = str(int(maxsize,16)) if maxsize.startswith(("0x","0X")) else maxsize
self._Capacity.append(maxsize)
if hasattr(self, "SkuOverrideValues"):
for sku in self.SkuOverrideValues: