public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: BobCF <bob.c.feng@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Yonghong Zhu <yonghong.zhu@intel.com>,
	Jaben Carsey <jaben.carsey@intel.com>,
	Bob Feng <bob.c.feng@intel.com>
Subject: [Patch] BaseTools: Involve Dec default value to calculate Maxsize
Date: Mon,  3 Sep 2018 09:05:53 +0800	[thread overview]
Message-ID: <20180903010553.114896-1-bob.c.feng@intel.com> (raw)

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



             reply	other threads:[~2018-09-03  1:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03  1:05 BobCF [this message]
2018-09-04 14:50 ` [Patch] BaseTools: Involve Dec default value to calculate Maxsize Carsey, Jaben
  -- strict thread matches above, loose matches on Subject: below --
2018-08-30  5:27 BobCF

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180903010553.114896-1-bob.c.feng@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox