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>
This commit is contained in:
Carsey, Jaben
2018-09-11 06:18:05 +08:00
committed by Yonghong Zhu
parent 6c204ed4f2
commit 71cac3f791
7 changed files with 228 additions and 235 deletions

View File

@ -213,11 +213,13 @@ class MetaFileParser(object):
self._PostProcessed = True
## Get the parse complete flag
def _GetFinished(self):
@property
def Finished(self):
return self._Finished
## Set the complete flag
def _SetFinished(self, Value):
@Finished.setter
def Finished(self, Value):
self._Finished = Value
## Remove records that do not match given Filter Arch
@ -416,7 +418,9 @@ class MetaFileParser(object):
)
def GetValidExpression(self, TokenSpaceGuid, PcdCName):
return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
def _GetMacros(self):
@property
def _Macros(self):
Macros = {}
Macros.update(self._FileLocalMacros)
Macros.update(self._GetApplicableSectionMacro())
@ -478,9 +482,6 @@ class MetaFileParser(object):
return Macros
_SectionParser = {}
Finished = property(_GetFinished, _SetFinished)
_Macros = property(_GetMacros)
## INF file parser class
#
@ -1252,7 +1253,8 @@ class DscParser(MetaFileParser):
)
## Override parent's method since we'll do all macro replacements in parser
def _GetMacros(self):
@property
def _Macros(self):
Macros = {}
Macros.update(self._FileLocalMacros)
Macros.update(self._GetApplicableSectionMacro())
@ -1673,8 +1675,6 @@ class DscParser(MetaFileParser):
MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHeaderParser,
}
_Macros = property(_GetMacros)
## DEC file parser class
#
# @param FilePath The path of platform description file