From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 718392215BD98 for ; Fri, 2 Feb 2018 04:11:14 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 04:16:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,448,1511856000"; d="scan'208";a="16486619" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 02 Feb 2018 04:16:52 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 04:16:52 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Fri, 2 Feb 2018 20:16:50 +0800 From: "Yao, Jiewen" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Yao, Jiewen" Thread-Topic: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Thread-Index: AdOcBHdjJyb7bj7oSMaYfhDyWzXAYAAGrwOA Date: Fri, 2 Feb 2018 12:16:49 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AAAA82B@shsmsx102.ccr.corp.intel.com> References: <47C64442C08CCD4089DC43B6B5E46BC4822A49@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC4822A49@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzc0MjY0YjUtMmJjMy00MzQ1LTljNzYtMGNiMWFlZTJhYzZhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJhUW9FYnRFQ1FQdU45WFRZRUJDTXl5SDV5MVFHbUFHejdWbkV4eDRpNGtkVkxLSURUSUkzNG1Db2V1VUduSFZvIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2018 12:11:14 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello May I know why we do not support L"String" ? My understanding is that L'String' is a string without NULL terminator, L"S= tring" is a string with NULL terminator, right? Thank you Yao Jiewen > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fe= ng, > YunhuaX > Sent: Friday, February 2, 2018 5:02 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* support= L'a' > and 'a' >=20 > Type VOID* support L'a' and 'a', the value transfer to c style value. > L'a' --> {0x61, 0x00} > L'ab' --> {0x61, 0x00, 0x62, 0x00} > 'a' --> {0x61} > 'ab' --> {0x61, 0x62} >=20 > when the value is L'' or '', will report error >=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yunhua Feng > --- > BaseTools/Source/Python/Common/Expression.py | 19 ++++++++++++++++--- > BaseTools/Source/Python/Common/Misc.py | 4 ++++ > 2 files changed, 20 insertions(+), 3 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Expression.py > b/BaseTools/Source/Python/Common/Expression.py > index b8c48460ff..6a1103df2c 100644 > --- a/BaseTools/Source/Python/Common/Expression.py > +++ b/BaseTools/Source/Python/Common/Expression.py > @@ -740,7 +740,12 @@ class ValueExpressionEx(ValueExpression): > try: > PcdValue =3D ValueExpression.__call__(self, RealValue, Depth= ) > if self.PcdType =3D=3D 'VOID*' and (PcdValue.startswith("'")= or > PcdValue.startswith("L'")): > - raise BadExpression > + PcdValue, Size =3D ParseFieldValue(PcdValue) > + PcdValueList =3D [] > + for I in range(Size): > + PcdValueList.append('0x%02X'%(PcdValue & 0xff)) > + PcdValue =3D PcdValue >> 8 > + PcdValue =3D '{' + ','.join(PcdValueList) + '}' > elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', > 'BOOLEAN'] and (PcdValue.startswith("'") or \ > PcdValue.startswith('"') or PcdValue.startswith("L= '") > or PcdValue.startswith('L"') or PcdValue.startswith('{')): > raise BadExpression > @@ -755,6 +760,8 @@ class ValueExpressionEx(ValueExpression): > TmpValue =3D 0 > Size =3D 0 > for Item in PcdValue: > + if Item.startswith('UINT8'): > + ItemSize =3D 1 > if Item.startswith('UINT16'): > ItemSize =3D 2 > elif Item.startswith('UINT32'): > @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression): > TmpValue =3D (ItemValue << (Size * 8)) | TmpValu= e > Size =3D Size + ItemSize > else: > - TmpValue, Size =3D ParseFieldValue(PcdValue) > + try: > + TmpValue, Size =3D ParseFieldValue(PcdValue) > + except BadExpression: > + raise BadExpression("Type: %s, Value: %s, format > or value error" % (self.PcdType, PcdValue)) > if type(TmpValue) =3D=3D type(''): > TmpValue =3D int(TmpValue) > else: > @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression): > else: > raise BadExpression('%s not > defined before use' % Offset) > ValueType =3D "" > - if Item.startswith('UINT16'): > + if Item.startswith('UINT8'): > ItemSize =3D 1 > ValueType =3D "UINT8" > elif Item.startswith('UINT16'): > @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression): >=20 > if Size > 0: > PcdValue =3D '{' + ValueStr[:-2] + '}' > + else: > + raise BadExpression("Type: %s, Value: %s, forma= t > or value error"%(self.PcdType, PcdValue)) > + > if PcdValue =3D=3D 'True': > PcdValue =3D '1' > if PcdValue =3D=3D 'False': > diff --git a/BaseTools/Source/Python/Common/Misc.py > b/BaseTools/Source/Python/Common/Misc.py > index b34cb4c3be..d80f645d2e 100644 > --- a/BaseTools/Source/Python/Common/Misc.py > +++ b/BaseTools/Source/Python/Common/Misc.py > @@ -1572,6 +1572,8 @@ def ParseFieldValue (Value): > if Value.startswith("L'") and Value.endswith("'"): > # Unicode Character Constant > List =3D list(Value[2:-1]) > + if len(List) =3D=3D 0: > + raise BadExpression('Length %s is %s' % (Value, len(List))) > List.reverse() > Value =3D 0 > for Char in List: > @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value): > if Value.startswith("'") and Value.endswith("'"): > # Character constant > List =3D list(Value[1:-1]) > + if len(List) =3D=3D 0: > + raise BadExpression('Length %s is %s' % (Value, len(List))) > List.reverse() > Value =3D 0 > for Char in List: > -- > 2.12.2.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel