diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-09-11 06:18:05 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-09-20 22:18:06 +0800 |
commit | 71cac3f791c2469468838ded6519b624d32345bb (patch) | |
tree | deb7ce643c1350ff4d75af77a48cb58bc14ebf68 /BaseTools/Source/Python/Workspace/DecBuildData.py | |
parent | 6c204ed4f2a5fc7e471e477dfdb276023f6a7310 (diff) | |
download | edk2-71cac3f791c2469468838ded6519b624d32345bb.tar.gz edk2-71cac3f791c2469468838ded6519b624d32345bb.tar.bz2 edk2-71cac3f791c2469468838ded6519b624d32345bb.zip |
BaseTools: Workspace classes refactor properties
1) use decorators
2) also change some private functions to public when all callers are
external
3) change external callers to use functions instead of directly
accessing private data.
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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/DecBuildData.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/DecBuildData.py | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 45beaebc63..1f74e898f2 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -99,21 +99,22 @@ class DecBuildData(PackageBuildClassObject): self._CommonIncludes = None
self._LibraryClasses = None
self._Pcds = None
- self.__Macros = None
+ self._MacroDict = None
self._PrivateProtocols = None
self._PrivatePpis = None
self._PrivateGuids = None
self._PrivateIncludes = None
## Get current effective macros
- def _GetMacros(self):
- if self.__Macros is None:
- self.__Macros = {}
- self.__Macros.update(GlobalData.gGlobalDefines)
- return self.__Macros
+ @property
+ def _Macros(self):
+ if self._MacroDict is None:
+ self._MacroDict = dict(GlobalData.gGlobalDefines)
+ return self._MacroDict
## Get architecture
- def _GetArch(self):
+ @property
+ def Arch(self):
return self._Arch
## Retrieve all information in [Defines] section
@@ -129,7 +130,8 @@ class DecBuildData(PackageBuildClassObject): self._Header = 'DUMMY'
## Retrieve package name
- def _GetPackageName(self):
+ @property
+ def PackageName(self):
if self._PackageName is None:
if self._Header is None:
self._GetHeaderInfo()
@@ -138,7 +140,8 @@ class DecBuildData(PackageBuildClassObject): return self._PackageName
## Retrieve file guid
- def _GetFileGuid(self):
+ @property
+ def PackageName(self):
if self._Guid is None:
if self._Header is None:
self._GetHeaderInfo()
@@ -147,7 +150,8 @@ class DecBuildData(PackageBuildClassObject): return self._Guid
## Retrieve package version
- def _GetVersion(self):
+ @property
+ def Version(self):
if self._Version is None:
if self._Header is None:
self._GetHeaderInfo()
@@ -156,7 +160,8 @@ class DecBuildData(PackageBuildClassObject): return self._Version
## Retrieve protocol definitions (name/value pairs)
- def _GetProtocol(self):
+ @property
+ def Protocols(self):
if self._Protocols is None:
#
# tdict is a special kind of dict, used for selecting correct
@@ -198,7 +203,8 @@ class DecBuildData(PackageBuildClassObject): return self._Protocols
## Retrieve PPI definitions (name/value pairs)
- def _GetPpi(self):
+ @property
+ def Ppis(self):
if self._Ppis is None:
#
# tdict is a special kind of dict, used for selecting correct
@@ -240,7 +246,8 @@ class DecBuildData(PackageBuildClassObject): return self._Ppis
## Retrieve GUID definitions (name/value pairs)
- def _GetGuid(self):
+ @property
+ def Guids(self):
if self._Guids is None:
#
# tdict is a special kind of dict, used for selecting correct
@@ -282,7 +289,8 @@ class DecBuildData(PackageBuildClassObject): return self._Guids
## Retrieve public include paths declared in this package
- def _GetInclude(self):
+ @property
+ def Includes(self):
if self._Includes is None or self._CommonIncludes is None:
self._CommonIncludes = []
self._Includes = []
@@ -317,7 +325,8 @@ class DecBuildData(PackageBuildClassObject): return self._Includes
## Retrieve library class declarations (not used in build at present)
- def _GetLibraryClass(self):
+ @property
+ def LibraryClasses(self):
if self._LibraryClasses is None:
#
# tdict is a special kind of dict, used for selecting correct
@@ -341,7 +350,8 @@ class DecBuildData(PackageBuildClassObject): return self._LibraryClasses
## Retrieve PCD declarations
- def _GetPcds(self):
+ @property
+ def Pcds(self):
if self._Pcds is None:
self._Pcds = OrderedDict()
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
@@ -351,7 +361,6 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
return self._Pcds
-
def ProcessStructurePcd(self, StructurePcdRawDataSet):
s_pcd_set = OrderedDict()
for s_pcd, LineNo in StructurePcdRawDataSet:
@@ -446,22 +455,9 @@ class DecBuildData(PackageBuildClassObject): EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName, struct_pcd.DefinitionPosition[0], struct_pcd.DefinitionPosition[1] ))
return Pcds
+
@property
def CommonIncludes(self):
if self._CommonIncludes is None:
self.Includes
return self._CommonIncludes
-
-
- _Macros = property(_GetMacros)
- Arch = property(_GetArch)
- PackageName = property(_GetPackageName)
- Guid = property(_GetFileGuid)
- Version = property(_GetVersion)
-
- Protocols = property(_GetProtocol)
- Ppis = property(_GetPpi)
- Guids = property(_GetGuid)
- Includes = property(_GetInclude)
- LibraryClasses = property(_GetLibraryClass)
- Pcds = property(_GetPcds)
|