From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Two or more type TXT spf records found.) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=bob.c.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 4A7E7210F93C4 for ; Sun, 2 Sep 2018 18:06:08 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2018 18:06:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,322,1531810800"; d="scan'208";a="86619176" Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.110]) by fmsmga001.fm.intel.com with ESMTP; 02 Sep 2018 18:05:59 -0700 From: BobCF To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu , Jaben Carsey , Bob Feng Date: Mon, 3 Sep 2018 09:05:53 +0800 Message-Id: <20180903010553.114896-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [Patch] BaseTools: Involve Dec default value to calculate Maxsize X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2018 01:06:08 -0000 Involve Dec default value to calculate Maxsize for structure PCD Cc: Liming Gao Cc: Yonghong Zhu Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng --- .../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