* [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
@ 2018-02-02 9:01 Feng, YunhuaX
2018-02-02 12:16 ` Yao, Jiewen
0 siblings, 1 reply; 6+ messages in thread
From: Feng, YunhuaX @ 2018-02-02 9:01 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Zhu, Yonghong, Gao, Liming
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 <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
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 = ValueExpression.__call__(self, RealValue, Depth)
if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or PcdValue.startswith("L'")):
- raise BadExpression
+ PcdValue, Size = ParseFieldValue(PcdValue)
+ PcdValueList = []
+ for I in range(Size):
+ PcdValueList.append('0x%02X'%(PcdValue & 0xff))
+ PcdValue = PcdValue >> 8
+ PcdValue = '{' + ','.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 = 0
Size = 0
for Item in PcdValue:
+ if Item.startswith('UINT8'):
+ ItemSize = 1
if Item.startswith('UINT16'):
ItemSize = 2
elif Item.startswith('UINT32'):
@@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
TmpValue = (ItemValue << (Size * 8)) | TmpValue
Size = Size + ItemSize
else:
- TmpValue, Size = ParseFieldValue(PcdValue)
+ try:
+ TmpValue, Size = ParseFieldValue(PcdValue)
+ except BadExpression:
+ raise BadExpression("Type: %s, Value: %s, format or value error" % (self.PcdType, PcdValue))
if type(TmpValue) == type(''):
TmpValue = int(TmpValue)
else:
@@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
else:
raise BadExpression('%s not defined before use' % Offset)
ValueType = ""
- if Item.startswith('UINT16'):
+ if Item.startswith('UINT8'):
ItemSize = 1
ValueType = "UINT8"
elif Item.startswith('UINT16'):
@@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
if Size > 0:
PcdValue = '{' + ValueStr[:-2] + '}'
+ else:
+ raise BadExpression("Type: %s, Value: %s, format or value error"%(self.PcdType, PcdValue))
+
if PcdValue == 'True':
PcdValue = '1'
if PcdValue == '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 = list(Value[2:-1])
+ if len(List) == 0:
+ raise BadExpression('Length %s is %s' % (Value, len(List)))
List.reverse()
Value = 0
for Char in List:
@@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
if Value.startswith("'") and Value.endswith("'"):
# Character constant
List = list(Value[1:-1])
+ if len(List) == 0:
+ raise BadExpression('Length %s is %s' % (Value, len(List)))
List.reverse()
Value = 0
for Char in List:
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
2018-02-02 9:01 [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Feng, YunhuaX
@ 2018-02-02 12:16 ` Yao, Jiewen
2018-02-02 13:41 ` Feng, YunhuaX
0 siblings, 1 reply; 6+ messages in thread
From: Yao, Jiewen @ 2018-02-02 12:16 UTC (permalink / raw)
To: Feng, YunhuaX, edk2-devel@lists.01.org; +Cc: Gao, Liming, Yao, Jiewen
Hello
May I know why we do not support L"String" ?
My understanding is that L'String' is a string without NULL terminator, L"String" 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 Feng,
> YunhuaX
> Sent: Friday, February 2, 2018 5:02 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* 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 <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> ---
> 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 = ValueExpression.__call__(self, RealValue, Depth)
> if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or
> PcdValue.startswith("L'")):
> - raise BadExpression
> + PcdValue, Size = ParseFieldValue(PcdValue)
> + PcdValueList = []
> + for I in range(Size):
> + PcdValueList.append('0x%02X'%(PcdValue & 0xff))
> + PcdValue = PcdValue >> 8
> + PcdValue = '{' + ','.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 = 0
> Size = 0
> for Item in PcdValue:
> + if Item.startswith('UINT8'):
> + ItemSize = 1
> if Item.startswith('UINT16'):
> ItemSize = 2
> elif Item.startswith('UINT32'):
> @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
> TmpValue = (ItemValue << (Size * 8)) | TmpValue
> Size = Size + ItemSize
> else:
> - TmpValue, Size = ParseFieldValue(PcdValue)
> + try:
> + TmpValue, Size = ParseFieldValue(PcdValue)
> + except BadExpression:
> + raise BadExpression("Type: %s, Value: %s, format
> or value error" % (self.PcdType, PcdValue))
> if type(TmpValue) == type(''):
> TmpValue = int(TmpValue)
> else:
> @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
> else:
> raise BadExpression('%s not
> defined before use' % Offset)
> ValueType = ""
> - if Item.startswith('UINT16'):
> + if Item.startswith('UINT8'):
> ItemSize = 1
> ValueType = "UINT8"
> elif Item.startswith('UINT16'):
> @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
>
> if Size > 0:
> PcdValue = '{' + ValueStr[:-2] + '}'
> + else:
> + raise BadExpression("Type: %s, Value: %s, format
> or value error"%(self.PcdType, PcdValue))
> +
> if PcdValue == 'True':
> PcdValue = '1'
> if PcdValue == '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 = list(Value[2:-1])
> + if len(List) == 0:
> + raise BadExpression('Length %s is %s' % (Value, len(List)))
> List.reverse()
> Value = 0
> for Char in List:
> @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
> if Value.startswith("'") and Value.endswith("'"):
> # Character constant
> List = list(Value[1:-1])
> + if len(List) == 0:
> + raise BadExpression('Length %s is %s' % (Value, len(List)))
> List.reverse()
> Value = 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
2018-02-02 12:16 ` Yao, Jiewen
@ 2018-02-02 13:41 ` Feng, YunhuaX
2018-02-02 13:45 ` Yao, Jiewen
0 siblings, 1 reply; 6+ messages in thread
From: Feng, YunhuaX @ 2018-02-02 13:41 UTC (permalink / raw)
To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Gao, Liming
Yes, you are right.
L"String" and "String" still support, and we add L'String' and 'String'
L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00}
L'ab' ==> {0x61, 0x00, 0x62, 0x00}
Any question, please let me know. Thanks.
Best Regards
Feng, Yunhua
-----Original Message-----
From: Yao, Jiewen
Sent: Friday, February 2, 2018 8:17 PM
To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
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"String" 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
> Feng, YunhuaX
> Sent: Friday, February 2, 2018 5:02 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* 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 <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> ---
> 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 = ValueExpression.__call__(self, RealValue, Depth)
> if self.PcdType == 'VOID*' and (PcdValue.startswith("'")
> or
> PcdValue.startswith("L'")):
> - raise BadExpression
> + PcdValue, Size = ParseFieldValue(PcdValue)
> + PcdValueList = []
> + for I in range(Size):
> + PcdValueList.append('0x%02X'%(PcdValue & 0xff))
> + PcdValue = PcdValue >> 8
> + PcdValue = '{' + ','.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 = 0
> Size = 0
> for Item in PcdValue:
> + if Item.startswith('UINT8'):
> + ItemSize = 1
> if Item.startswith('UINT16'):
> ItemSize = 2
> elif Item.startswith('UINT32'):
> @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
> TmpValue = (ItemValue << (Size * 8)) | TmpValue
> Size = Size + ItemSize
> else:
> - TmpValue, Size = ParseFieldValue(PcdValue)
> + try:
> + TmpValue, Size = ParseFieldValue(PcdValue)
> + except BadExpression:
> + raise BadExpression("Type: %s, Value: %s,
> + format
> or value error" % (self.PcdType, PcdValue))
> if type(TmpValue) == type(''):
> TmpValue = int(TmpValue)
> else:
> @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
> else:
> raise BadExpression('%s not
> defined before use' % Offset)
> ValueType = ""
> - if Item.startswith('UINT16'):
> + if Item.startswith('UINT8'):
> ItemSize = 1
> ValueType = "UINT8"
> elif Item.startswith('UINT16'):
> @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
>
> if Size > 0:
> PcdValue = '{' + ValueStr[:-2] + '}'
> + else:
> + raise BadExpression("Type: %s, Value: %s,
> + format
> or value error"%(self.PcdType, PcdValue))
> +
> if PcdValue == 'True':
> PcdValue = '1'
> if PcdValue == '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 = list(Value[2:-1])
> + if len(List) == 0:
> + raise BadExpression('Length %s is %s' % (Value,
> + len(List)))
> List.reverse()
> Value = 0
> for Char in List:
> @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
> if Value.startswith("'") and Value.endswith("'"):
> # Character constant
> List = list(Value[1:-1])
> + if len(List) == 0:
> + raise BadExpression('Length %s is %s' % (Value,
> + len(List)))
> List.reverse()
> Value = 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
2018-02-02 13:41 ` Feng, YunhuaX
@ 2018-02-02 13:45 ` Yao, Jiewen
2018-02-02 13:48 ` Feng, YunhuaX
0 siblings, 1 reply; 6+ messages in thread
From: Yao, Jiewen @ 2018-02-02 13:45 UTC (permalink / raw)
To: Feng, YunhuaX, edk2-devel@lists.01.org; +Cc: Gao, Liming
Good.
I am just confused on the commit message --- when the value is L'' or '', will 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 <jiewen.yao@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and
> 'a'
>
> Yes, you are right.
>
> L"String" and "String" still support, and we add L'String' and 'String'
> L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00}
> L'ab' ==> {0x61, 0x00, 0x62, 0x00}
>
> Any question, please let me know. Thanks.
>
> Best Regards
> Feng, Yunhua
>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Friday, February 2, 2018 8:17 PM
> To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> 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"String" 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
> > Feng, YunhuaX
> > Sent: Friday, February 2, 2018 5:02 PM
> > To: edk2-devel@lists.01.org
> > Cc: Gao, Liming <liming.gao@intel.com>
> > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* 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 <liming.gao@intel.com>
> > Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> > ---
> > 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 = ValueExpression.__call__(self, RealValue, Depth)
> > if self.PcdType == 'VOID*' and (PcdValue.startswith("'")
> > or
> > PcdValue.startswith("L'")):
> > - raise BadExpression
> > + PcdValue, Size = ParseFieldValue(PcdValue)
> > + PcdValueList = []
> > + for I in range(Size):
> > + PcdValueList.append('0x%02X'%(PcdValue & 0xff))
> > + PcdValue = PcdValue >> 8
> > + PcdValue = '{' + ','.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 = 0
> > Size = 0
> > for Item in PcdValue:
> > + if Item.startswith('UINT8'):
> > + ItemSize = 1
> > if Item.startswith('UINT16'):
> > ItemSize = 2
> > elif Item.startswith('UINT32'):
> > @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
> > TmpValue = (ItemValue << (Size * 8)) | TmpValue
> > Size = Size + ItemSize
> > else:
> > - TmpValue, Size = ParseFieldValue(PcdValue)
> > + try:
> > + TmpValue, Size = ParseFieldValue(PcdValue)
> > + except BadExpression:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error" % (self.PcdType, PcdValue))
> > if type(TmpValue) == type(''):
> > TmpValue = int(TmpValue)
> > else:
> > @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
> > else:
> > raise BadExpression('%s not
> > defined before use' % Offset)
> > ValueType = ""
> > - if Item.startswith('UINT16'):
> > + if Item.startswith('UINT8'):
> > ItemSize = 1
> > ValueType = "UINT8"
> > elif Item.startswith('UINT16'):
> > @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
> >
> > if Size > 0:
> > PcdValue = '{' + ValueStr[:-2] + '}'
> > + else:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error"%(self.PcdType, PcdValue))
> > +
> > if PcdValue == 'True':
> > PcdValue = '1'
> > if PcdValue == '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 = list(Value[2:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 0
> > for Char in List:
> > @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
> > if Value.startswith("'") and Value.endswith("'"):
> > # Character constant
> > List = list(Value[1:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
2018-02-02 13:45 ` Yao, Jiewen
@ 2018-02-02 13:48 ` Feng, YunhuaX
2018-02-04 3:04 ` Zhu, Yonghong
0 siblings, 1 reply; 6+ messages in thread
From: Feng, YunhuaX @ 2018-02-02 13:48 UTC (permalink / raw)
To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Gao, Liming
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
Sent: Friday, February 2, 2018 9:45 PM
To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>
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 '', will 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 <jiewen.yao@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support
> L'a' and 'a'
>
> Yes, you are right.
>
> L"String" and "String" still support, and we add L'String' and 'String'
> L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00}
> L'ab' ==> {0x61, 0x00, 0x62, 0x00}
>
> Any question, please let me know. Thanks.
>
> Best Regards
> Feng, Yunhua
>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Friday, February 2, 2018 8:17 PM
> To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>
> 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"String" 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 Feng, YunhuaX
> > Sent: Friday, February 2, 2018 5:02 PM
> > To: edk2-devel@lists.01.org
> > Cc: Gao, Liming <liming.gao@intel.com>
> > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID*
> > 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 <liming.gao@intel.com>
> > Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> > ---
> > 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 = ValueExpression.__call__(self, RealValue, Depth)
> > if self.PcdType == 'VOID*' and
> > (PcdValue.startswith("'") or
> > PcdValue.startswith("L'")):
> > - raise BadExpression
> > + PcdValue, Size = ParseFieldValue(PcdValue)
> > + PcdValueList = []
> > + for I in range(Size):
> > + PcdValueList.append('0x%02X'%(PcdValue & 0xff))
> > + PcdValue = PcdValue >> 8
> > + PcdValue = '{' + ','.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 = 0
> > Size = 0
> > for Item in PcdValue:
> > + if Item.startswith('UINT8'):
> > + ItemSize = 1
> > if Item.startswith('UINT16'):
> > ItemSize = 2
> > elif Item.startswith('UINT32'):
> > @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
> > TmpValue = (ItemValue << (Size * 8)) | TmpValue
> > Size = Size + ItemSize
> > else:
> > - TmpValue, Size = ParseFieldValue(PcdValue)
> > + try:
> > + TmpValue, Size = ParseFieldValue(PcdValue)
> > + except BadExpression:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error" % (self.PcdType, PcdValue))
> > if type(TmpValue) == type(''):
> > TmpValue = int(TmpValue)
> > else:
> > @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
> > else:
> > raise BadExpression('%s not
> > defined before use' % Offset)
> > ValueType = ""
> > - if Item.startswith('UINT16'):
> > + if Item.startswith('UINT8'):
> > ItemSize = 1
> > ValueType = "UINT8"
> > elif Item.startswith('UINT16'):
> > @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
> >
> > if Size > 0:
> > PcdValue = '{' + ValueStr[:-2] + '}'
> > + else:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error"%(self.PcdType, PcdValue))
> > +
> > if PcdValue == 'True':
> > PcdValue = '1'
> > if PcdValue == '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 = list(Value[2:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 0
> > for Char in List:
> > @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
> > if Value.startswith("'") and Value.endswith("'"):
> > # Character constant
> > List = list(Value[1:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
2018-02-02 13:48 ` Feng, YunhuaX
@ 2018-02-04 3:04 ` Zhu, Yonghong
0 siblings, 0 replies; 6+ messages in thread
From: Zhu, Yonghong @ 2018-02-04 3:04 UTC (permalink / raw)
To: Feng, YunhuaX, Yao, Jiewen, edk2-devel@lists.01.org
Cc: Gao, Liming, Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Feng, YunhuaX
Sent: Friday, February 02, 2018 9:49 PM
To: Yao, Jiewen <jiewen.yao@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2] [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a'
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
Sent: Friday, February 2, 2018 9:45 PM
To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>
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 '', will 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 <jiewen.yao@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH] BaseTools: Update Expression.py for VOID* support
> L'a' and 'a'
>
> Yes, you are right.
>
> L"String" and "String" still support, and we add L'String' and 'String'
> L"ab" ==> {0x61, 0x00, 0x62, 0x00, 0x00, 0x00}
> L'ab' ==> {0x61, 0x00, 0x62, 0x00}
>
> Any question, please let me know. Thanks.
>
> Best Regards
> Feng, Yunhua
>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Friday, February 2, 2018 8:17 PM
> To: Feng, YunhuaX <yunhuax.feng@intel.com>; edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>
> 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"String" 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 Feng, YunhuaX
> > Sent: Friday, February 2, 2018 5:02 PM
> > To: edk2-devel@lists.01.org
> > Cc: Gao, Liming <liming.gao@intel.com>
> > Subject: [edk2] [PATCH] BaseTools: Update Expression.py for VOID*
> > 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 <liming.gao@intel.com>
> > Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
> > ---
> > 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 = ValueExpression.__call__(self, RealValue, Depth)
> > if self.PcdType == 'VOID*' and
> > (PcdValue.startswith("'") or
> > PcdValue.startswith("L'")):
> > - raise BadExpression
> > + PcdValue, Size = ParseFieldValue(PcdValue)
> > + PcdValueList = []
> > + for I in range(Size):
> > + PcdValueList.append('0x%02X'%(PcdValue & 0xff))
> > + PcdValue = PcdValue >> 8
> > + PcdValue = '{' + ','.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 = 0
> > Size = 0
> > for Item in PcdValue:
> > + if Item.startswith('UINT8'):
> > + ItemSize = 1
> > if Item.startswith('UINT16'):
> > ItemSize = 2
> > elif Item.startswith('UINT32'):
> > @@ -776,7 +783,10 @@ class ValueExpressionEx(ValueExpression):
> > TmpValue = (ItemValue << (Size * 8)) | TmpValue
> > Size = Size + ItemSize
> > else:
> > - TmpValue, Size = ParseFieldValue(PcdValue)
> > + try:
> > + TmpValue, Size = ParseFieldValue(PcdValue)
> > + except BadExpression:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error" % (self.PcdType, PcdValue))
> > if type(TmpValue) == type(''):
> > TmpValue = int(TmpValue)
> > else:
> > @@ -858,7 +868,7 @@ class ValueExpressionEx(ValueExpression):
> > else:
> > raise BadExpression('%s not
> > defined before use' % Offset)
> > ValueType = ""
> > - if Item.startswith('UINT16'):
> > + if Item.startswith('UINT8'):
> > ItemSize = 1
> > ValueType = "UINT8"
> > elif Item.startswith('UINT16'):
> > @@ -887,6 +897,9 @@ class ValueExpressionEx(ValueExpression):
> >
> > if Size > 0:
> > PcdValue = '{' + ValueStr[:-2] + '}'
> > + else:
> > + raise BadExpression("Type: %s, Value: %s,
> > + format
> > or value error"%(self.PcdType, PcdValue))
> > +
> > if PcdValue == 'True':
> > PcdValue = '1'
> > if PcdValue == '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 = list(Value[2:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 0
> > for Char in List:
> > @@ -1580,6 +1582,8 @@ def ParseFieldValue (Value):
> > if Value.startswith("'") and Value.endswith("'"):
> > # Character constant
> > List = list(Value[1:-1])
> > + if len(List) == 0:
> > + raise BadExpression('Length %s is %s' % (Value,
> > + len(List)))
> > List.reverse()
> > Value = 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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-04 2:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-02 9:01 [PATCH] BaseTools: Update Expression.py for VOID* support L'a' and 'a' Feng, YunhuaX
2018-02-02 12:16 ` Yao, Jiewen
2018-02-02 13:41 ` Feng, YunhuaX
2018-02-02 13:45 ` Yao, Jiewen
2018-02-02 13:48 ` Feng, YunhuaX
2018-02-04 3:04 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox