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.120; helo=mga04.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 27C122239364B for ; Fri, 2 Feb 2018 05:39:26 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 05:45:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,448,1511856000"; d="scan'208";a="14854135" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga007.fm.intel.com with ESMTP; 02 Feb 2018 05:45:04 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 05:45:03 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Feb 2018 05:45:03 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Fri, 2 Feb 2018 21:45:01 +0800 From: "Yao, Jiewen" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Thread-Index: AdOcBHdjJyb7bj7oSMaYfhDyWzXAYAAGrwOA//+SjAD//3k18A== Date: Fri, 2 Feb 2018 13:45:01 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AAABACB@shsmsx102.ccr.corp.intel.com> References: <47C64442C08CCD4089DC43B6B5E46BC4822A49@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AAAA82B@shsmsx102.ccr.corp.intel.com> <47C64442C08CCD4089DC43B6B5E46BC4826C92@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC4826C92@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 13:39:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 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 > Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support 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 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 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* suppo= rt > 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 (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)) | 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, > > + 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): > > > > if Size > 0: > > PcdValue =3D '{' + ValueStr[:-2] + '}' > > + else: > > + raise BadExpression("Type: %s, Value: %s, > > + 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