From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v2 6/9] BaseTools: refactor Build Database objects
Date: Mon, 10 Sep 2018 15:18:06 -0700 [thread overview]
Message-ID: <62c9f6520a9540ff8042dbbc550de4821ae35884.1536175711.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1536175710.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1536175710.git.jaben.carsey@intel.com>
1) use namedtuple instead of custom class when apropriate
2) rename collections.OrderedDict to OrderedDict since we import it already
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Workspace/BuildClassObject.py | 32 ++++++--------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 88465c59ea30..e7259b2d3d50 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from collections import OrderedDict, namedtuple
from Common.DataType import *
-import collections
## PcdClassObject
#
@@ -165,17 +165,17 @@ class StructurePcd(PcdClassObject):
self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile
self.PackageDecs = Packages
self.DefaultStoreName = [default_store]
- self.DefaultValues = collections.OrderedDict()
+ self.DefaultValues = OrderedDict()
self.PcdMode = None
- self.SkuOverrideValues = collections.OrderedDict()
+ self.SkuOverrideValues = OrderedDict()
self.FlexibleFieldName = None
self.StructName = None
self.PcdDefineLineNo = 0
self.PkgPath = ""
self.DefaultValueFromDec = ""
self.ValueChain = set()
- self.PcdFieldValueFromComm = collections.OrderedDict()
- self.PcdFieldValueFromFdf = collections.OrderedDict()
+ self.PcdFieldValueFromComm = OrderedDict()
+ self.PcdFieldValueFromFdf = OrderedDict()
def __repr__(self):
return self.TypeName
@@ -189,9 +189,9 @@ class StructurePcd(PcdClassObject):
self.DefaultValueFromDec = DefaultValue
def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):
if SkuName not in self.SkuOverrideValues:
- self.SkuOverrideValues[SkuName] = collections.OrderedDict()
+ self.SkuOverrideValues[SkuName] = OrderedDict()
if DefaultStoreName not in self.SkuOverrideValues[SkuName]:
- self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict()
+ self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict()
if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName]:
del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName]
self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] = [Value.strip(), FileName, LineNo]
@@ -241,21 +241,7 @@ class StructurePcd(PcdClassObject):
self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm
self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf
-## LibraryClassObject
-#
-# This Class defines LibraryClassObject used in BuildDatabase
-#
-# @param object: Inherited from object class
-# @param Name: Input value for LibraryClassName, default is None
-# @param SupModList: Input value for SupModList, default is []
-#
-# @var LibraryClass: To store value for LibraryClass
-# @var SupModList: To store value for SupModList
-#
-class LibraryClassObject(object):
- def __init__(self, Name = None, SupModList = []):
- self.LibraryClass = Name
- self.SupModList = SupModList
+LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModList'], verbose=False)
## ModuleBuildClassObject
#
@@ -323,7 +309,7 @@ class ModuleBuildClassObject(object):
self.Binaries = []
self.Sources = []
- self.LibraryClasses = collections.OrderedDict()
+ self.LibraryClasses = OrderedDict()
self.Libraries = []
self.Protocols = []
self.Ppis = []
--
2.16.2.windows.1
next prev parent reply other threads:[~2018-09-10 22:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-10 22:18 [PATCH v2 0/9] BaseTools: refactor Workspace classes Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 1/9] BaseTools: Refactor PlatformAutoGen Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 2/9] BaseTools: AutoGen refactor WorkspaceAutoGen class Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 3/9] BaseTools: AutoGen - refactor class properties Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 4/9] BaseTools: " Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 5/9] BaseTools: Workspace classes refactor properties Jaben Carsey
2018-09-10 22:18 ` Jaben Carsey [this message]
2018-09-10 22:18 ` [PATCH v2 7/9] BaseTools: Don't save unused workspace data Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 8/9] BaseTools: refactor to not overcreate ModuleAutoGen objects Jaben Carsey
2018-09-10 22:18 ` [PATCH v2 9/9] BaseTools: refactor to cache InfBuildData data Jaben Carsey
2018-09-20 7:01 ` [PATCH v2 0/9] BaseTools: refactor Workspace classes Zhu, Yonghong
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=62c9f6520a9540ff8042dbbc550de4821ae35884.1536175711.git.jaben.carsey@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