def __init__(self, RawData): _DecBase.__init__(self, RawData) self.ItemObject = DecPcdObject(RawData.Filename) # # Used to check duplicate token # Key is token space and token number (integer), value is C name # self.TokenMap = {}
class _DecPcd(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) self.ItemObject = DecPcdObject(RawData.Filename) # # Used to check duplicate token # Key is token space and token number (integer), value is C name # self.TokenMap = {} def _ParseItem(self): Line = self._RawData.CurrentLine TokenList = Line.split(DT.TAB_VALUE_SPLIT) if len(TokenList) < 4: self._LoggerError(ST.ERR_DECPARSE_PCD_SPLIT) # # Token space guid C name # PcdName = GetSplitValueList(TokenList[0], DT.TAB_SPLIT) if len(PcdName) != 2 or PcdName[0] == '' or PcdName[1] == '': self._LoggerError(ST.ERR_DECPARSE_PCD_NAME) Guid = PcdName[0] if not IsValidToken(CVAR_PATTERN, Guid): self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_GUID) # # PCD C name # CName = PcdName[1] if not IsValidToken(CVAR_PATTERN, CName): self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_PCDCNAME) self._CheckReDefine(Guid + DT.TAB_SPLIT + CName) # # Default value, may be C array, string or number # Data = DT.TAB_VALUE_SPLIT.join(TokenList[1:-2]).strip() # # PCD data type # DataType = TokenList[-2].strip() Valid, Cause = IsValidPcdDatum(DataType, Data) if not Valid: self._LoggerError(Cause) PcdType = self._RawData.CurrentScope[0][0] if PcdType == DT.TAB_PCDS_FEATURE_FLAG_NULL.upper() and DataType != 'BOOLEAN': self._LoggerError(ST.ERR_DECPARSE_PCD_FEATUREFLAG) # # Token value is the last element in list. # Token = TokenList[-1].strip() if not IsValidToken(PCD_TOKEN_PATTERN, Token): self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN % Token) elif not Token.startswith('0x') and not Token.startswith('0X'): if long(Token) > 4294967295: self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token) Token = hex(long(Token))[:-1] IntToken = long(Token, 0) if (Guid, IntToken) in self.TokenMap: if self.TokenMap[Guid, IntToken] != CName: self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token)) else: self.TokenMap[Guid, IntToken] = CName Item = DecPcdItemObject(Guid, CName, Data, DataType, Token) self.ItemObject.AddItem(Item, self._RawData.CurrentScope) return Item