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=yunhuax.feng@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 422F72239364B for ; Fri, 2 Feb 2018 05:35:56 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 05:41:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,448,1511856000"; d="scan'208";a="28295303" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 02 Feb 2018 05:41:33 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 05:41:33 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 05:41:32 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Fri, 2 Feb 2018 21:41:31 +0800 From: "Feng, YunhuaX" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Thread-Index: AQHTnB+0KgG6aDpJiUecnKJs3O2McqORG52g Date: Fri, 2 Feb 2018 13:41:30 +0000 Message-ID: <47C64442C08CCD4089DC43B6B5E46BC4826C92@shsmsx102.ccr.corp.intel.com> References: <47C64442C08CCD4089DC43B6B5E46BC4822A49@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AAAA82B@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AAAA82B@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzc0MjY0YjUtMmJjMy00MzQ1LTljNzYtMGNiMWFlZTJhYzZhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJhUW9FYnRFQ1FQdU45WFRZRUJDTXl5SDV5MVFHbUFHejdWbkV4eDRpNGtkVkxLSURUSUkzNG1Db2V1VUduSFZvIn0= 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 13:35:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes, you are right. L"String" and "String" still support, and we add L'String' and 'String' L"ab" =3D=3D> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00} L'ab' =3D=3D> {0x61, 0x00, 0x62, 0x00}=20 Any question, please let me know. Thanks. Best Regards Feng, Yunhua -----Original Message----- From: Yao, Jiewen=20 Sent: Friday, February 2, 2018 8:17 PM To: Feng, YunhuaX ; edk2-devel@lists.01.org Cc: Gao, Liming ; Yao, Jiewen Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support L'a'= and 'a' 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=20 > Feng, 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("'")= =20 > 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',=20 > 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ > PcdValue.startswith('"') or=20 > PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.starts= with('{')): > 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,=20 > + 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=20 > 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,=20 > + format > 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,=20 > + 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,=20 > + 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