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.151; helo=mga17.intel.com; envelope-from=yunhuax.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 7EACA21D2BF08 for ; Fri, 2 Feb 2018 05:43:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 05:49:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,448,1511856000"; d="scan'208";a="198155902" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga005.jf.intel.com with ESMTP; 02 Feb 2018 05:49:00 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 05:49:00 -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:48:58 +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//9+EoCAAIaVkA== Date: Fri, 2 Feb 2018 13:48:58 +0000 Message-ID: <47C64442C08CCD4089DC43B6B5E46BC4827CAD@shsmsx102.ccr.corp.intel.com> References: <47C64442C08CCD4089DC43B6B5E46BC4822A49@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AAAA82B@shsmsx102.ccr.corp.intel.com> <47C64442C08CCD4089DC43B6B5E46BC4826C92@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AAABACB@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503AAABACB@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:43:23 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable sorry L'' and '' is single quote and not include any character, so we will report= error message Any question, please let me know. Thanks. Best Regards Feng, Yunhua -----Original Message----- From: Yao, Jiewen=20 Sent: Friday, February 2, 2018 9:45 PM To: Feng, YunhuaX ; edk2-devel@lists.01.org Cc: Gao, Liming Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support L'a'= and 'a' Good. I am just confused on the commit message --- when the value is L'' or '', w= ill report error. Would you please clarify what does that mean? Thank you Yao Jiewen > -----Original Message----- > From: Feng, YunhuaX > Sent: Friday, February 2, 2018 9:42 PM > To: Yao, Jiewen ; edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support=20 > L'a' and 'a' >=20 > Yes, you are right. >=20 > 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. >=20 > Best Regards > Feng, Yunhua >=20 > -----Original Message----- > From: Yao, Jiewen > Sent: Friday, February 2, 2018 8:17 PM > To: Feng, YunhuaX ; edk2-devel@lists.01.org > Cc: Gao, Liming ; Yao, Jiewen=20 > > Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support=20 > L'a' and 'a' >=20 > Hello > May I know why we do not support L"String" ? >=20 > My understanding is that L'String' is a string without NULL=20 > terminator, L"String" is a string with NULL terminator, right? >=20 > Thank you > Yao Jiewen >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf=20 > > Of 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*=20 > > support > L'a' > > and 'a' > > > > 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} > > > > when the value is L'' or '', will report error > > > > 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(-) > > > > 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, Dep= th) > > if self.PcdType =3D=3D 'VOID*' and=20 > > (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',=20 > > '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=20 > > 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)) | TmpVa= lue > > 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): > > > > 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, > > + 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 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel