public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Involve Dec default value to calculate Maxsize
@ 2018-08-30  5:27 BobCF
  0 siblings, 0 replies; 3+ messages in thread
From: BobCF @ 2018-08-30  5:27 UTC (permalink / raw)
  To: edk2-devel

Involve Dec default value to calculate Maxsize for structure PCD

Cc: Bob Feng <bob.c.feng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/Workspace/BuildClassObject.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 88465c59ea..32d202de5e 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -91,10 +91,19 @@ class PcdClassObject(object):
                 return max([len(self.PcdValueFromComm)-2+1, MaxSize])
             elif self.PcdValueFromComm.startswith("L\""):
                 return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize])
             else:
                 return max([len(self.PcdValueFromComm), MaxSize])
+        if hasattr(self, "DefaultValueFromDec"):
+            if self.DefaultValueFromDec.startswith("{") and self.DefaultValueFromDec.endswith("}"):
+                return max([len(self.DefaultValueFromDec.split(",")), MaxSize])
+            elif self.DefaultValueFromDec.startswith("\"") or self.DefaultValueFromDec.startswith("\'"):
+                return max([len(self.DefaultValueFromDec)-2+1, MaxSize])
+            elif self.DefaultValueFromDec.startswith("L\""):
+                return max([2*(len(self.DefaultValueFromDec)-3+1), MaxSize])
+            else:
+                return max([len(self.DefaultValueFromDec), MaxSize])
         return MaxSize
 
     ## Get the number of bytes
     def GetPcdSize(self):
         if self.DatumType in TAB_PCD_NUMERIC_TYPES:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Patch] BaseTools: Involve Dec default value to calculate Maxsize
@ 2018-09-03  1:05 BobCF
  2018-09-04 14:50 ` Carsey, Jaben
  0 siblings, 1 reply; 3+ messages in thread
From: BobCF @ 2018-09-03  1:05 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu, Jaben Carsey, Bob Feng

Involve Dec default value to calculate Maxsize for structure PCD

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
---
 .../Source/Python/Workspace/BuildClassObject.py    | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 88465c59ea..b2e5309a90 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -66,35 +66,35 @@ class PcdClassObject(object):
             self.DscDefaultValue = Value
         self.PcdValueFromComm = ""
         self.PcdValueFromFdf = ""
         self.DefinitionPosition = ("","")
 
+    @staticmethod
+    def GetPcdMaxSizeWorker(PcdString, MaxSize):
+        if PcdString.startswith("{") and PcdString.endswith("}"):
+            return  max([len(PcdString.split(",")),MaxSize])
+
+        if PcdString.startswith("\"") or PcdString.startswith("\'"):
+            return  max([len(PcdString)-2+1,MaxSize])
+
+        if PcdString.startswith("L\""):
+            return  max([2*(len(PcdString)-3+1),MaxSize])
+
+        return max([len(PcdString),MaxSize])
+
     ## Get the maximum number of bytes
     def GetPcdMaxSize(self):
         if self.DatumType in TAB_PCD_NUMERIC_TYPES:
             return MAX_SIZE_TYPE[self.DatumType]
 
         MaxSize = int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0
         if self.PcdValueFromFdf:
-            if self.PcdValueFromFdf.startswith("{") and self.PcdValueFromFdf.endswith("}"):
-                MaxSize =  max([len(self.PcdValueFromFdf.split(",")),MaxSize])
-            elif self.PcdValueFromFdf.startswith("\"") or self.PcdValueFromFdf.startswith("\'"):
-                MaxSize =  max([len(self.PcdValueFromFdf)-2+1,MaxSize])
-            elif self.PcdValueFromFdf.startswith("L\""):
-                MaxSize =  max([2*(len(self.PcdValueFromFdf)-3+1),MaxSize])
-            else:
-                MaxSize = max([len(self.PcdValueFromFdf),MaxSize])
-
+            MaxSize = self.GetPcdMaxSizeWorker(self.PcdValueFromFdf,MaxSize)
         if self.PcdValueFromComm:
-            if self.PcdValueFromComm.startswith("{") and self.PcdValueFromComm.endswith("}"):
-                return max([len(self.PcdValueFromComm.split(",")), MaxSize])
-            elif self.PcdValueFromComm.startswith("\"") or self.PcdValueFromComm.startswith("\'"):
-                return max([len(self.PcdValueFromComm)-2+1, MaxSize])
-            elif self.PcdValueFromComm.startswith("L\""):
-                return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize])
-            else:
-                return max([len(self.PcdValueFromComm), MaxSize])
+            MaxSize = self.GetPcdMaxSizeWorker(self.PcdValueFromComm,MaxSize)
+        if hasattr(self, "DefaultValueFromDec"):
+            MaxSize = self.GetPcdMaxSizeWorker(self.DefaultValueFromDec,MaxSize)
         return MaxSize
 
     ## Get the number of bytes
     def GetPcdSize(self):
         if self.DatumType in TAB_PCD_NUMERIC_TYPES:
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch] BaseTools: Involve Dec default value to calculate Maxsize
  2018-09-03  1:05 [Patch] BaseTools: Involve Dec default value to calculate Maxsize BobCF
@ 2018-09-04 14:50 ` Carsey, Jaben
  0 siblings, 0 replies; 3+ messages in thread
From: Carsey, Jaben @ 2018-09-04 14:50 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Sunday, September 02, 2018 6:06 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong
> <yonghong.zhu@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>;
> Feng, Bob C <bob.c.feng@intel.com>
> Subject: [Patch] BaseTools: Involve Dec default value to calculate Maxsize
> Importance: High
> 
> Involve Dec default value to calculate Maxsize for structure PCD
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> ---
>  .../Source/Python/Workspace/BuildClassObject.py    | 34 +++++++++++------
> -----
>  1 file changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
> b/BaseTools/Source/Python/Workspace/BuildClassObject.py
> index 88465c59ea..b2e5309a90 100644
> --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
> +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
> @@ -66,35 +66,35 @@ class PcdClassObject(object):
>              self.DscDefaultValue = Value
>          self.PcdValueFromComm = ""
>          self.PcdValueFromFdf = ""
>          self.DefinitionPosition = ("","")
> 
> +    @staticmethod
> +    def GetPcdMaxSizeWorker(PcdString, MaxSize):
> +        if PcdString.startswith("{") and PcdString.endswith("}"):
> +            return  max([len(PcdString.split(",")),MaxSize])
> +
> +        if PcdString.startswith("\"") or PcdString.startswith("\'"):
> +            return  max([len(PcdString)-2+1,MaxSize])
> +
> +        if PcdString.startswith("L\""):
> +            return  max([2*(len(PcdString)-3+1),MaxSize])
> +
> +        return max([len(PcdString),MaxSize])
> +
>      ## Get the maximum number of bytes
>      def GetPcdMaxSize(self):
>          if self.DatumType in TAB_PCD_NUMERIC_TYPES:
>              return MAX_SIZE_TYPE[self.DatumType]
> 
>          MaxSize = int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0
>          if self.PcdValueFromFdf:
> -            if self.PcdValueFromFdf.startswith("{") and
> self.PcdValueFromFdf.endswith("}"):
> -                MaxSize =  max([len(self.PcdValueFromFdf.split(",")),MaxSize])
> -            elif self.PcdValueFromFdf.startswith("\"") or
> self.PcdValueFromFdf.startswith("\'"):
> -                MaxSize =  max([len(self.PcdValueFromFdf)-2+1,MaxSize])
> -            elif self.PcdValueFromFdf.startswith("L\""):
> -                MaxSize =  max([2*(len(self.PcdValueFromFdf)-3+1),MaxSize])
> -            else:
> -                MaxSize = max([len(self.PcdValueFromFdf),MaxSize])
> -
> +            MaxSize =
> self.GetPcdMaxSizeWorker(self.PcdValueFromFdf,MaxSize)
>          if self.PcdValueFromComm:
> -            if self.PcdValueFromComm.startswith("{") and
> self.PcdValueFromComm.endswith("}"):
> -                return max([len(self.PcdValueFromComm.split(",")), MaxSize])
> -            elif self.PcdValueFromComm.startswith("\"") or
> self.PcdValueFromComm.startswith("\'"):
> -                return max([len(self.PcdValueFromComm)-2+1, MaxSize])
> -            elif self.PcdValueFromComm.startswith("L\""):
> -                return max([2*(len(self.PcdValueFromComm)-3+1), MaxSize])
> -            else:
> -                return max([len(self.PcdValueFromComm), MaxSize])
> +            MaxSize =
> self.GetPcdMaxSizeWorker(self.PcdValueFromComm,MaxSize)
> +        if hasattr(self, "DefaultValueFromDec"):
> +            MaxSize =
> self.GetPcdMaxSizeWorker(self.DefaultValueFromDec,MaxSize)
>          return MaxSize
> 
>      ## Get the number of bytes
>      def GetPcdSize(self):
>          if self.DatumType in TAB_PCD_NUMERIC_TYPES:
> --
> 2.16.2.windows.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-04 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-03  1:05 [Patch] BaseTools: Involve Dec default value to calculate Maxsize BobCF
2018-09-04 14:50 ` Carsey, Jaben
  -- strict thread matches above, loose matches on Subject: below --
2018-08-30  5:27 BobCF

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox