def GenPcdDeclaration(ContainerFile, PcdInfo, Language, MacroReplaceDict): HelpStr = '' PromptStr = '' TailHelpStr = '' TokenGuidCName, TokenName, Value, DatumType, Token, Type, \ GenericComment, TailComment, Arch = PcdInfo Pcd = PcdObject() Pcd.SetCName(TokenName) Pcd.SetToken(Token) Pcd.SetTokenSpaceGuidCName(TokenGuidCName) Pcd.SetDatumType(DatumType) Pcd.SetDefaultValue(Value) Pcd.SetValidUsage(Type) # # MaxDatumSize is required field for 'VOID*' PCD # if DatumType == TAB_PTR_TYPE_PCD: Pcd.SetMaxDatumSize(ITEM_UNDEFINED) SupArchList = [Arch] Pcd.SetSupArchList(SupArchList) if GenericComment: HelpStr, PcdErrList, PromptStr = ParseDecPcdGenericComment(GenericComment, ContainerFile, TokenGuidCName, TokenName, MacroReplaceDict) if PcdErrList: Pcd.SetPcdErrorsList(PcdErrList) if TailComment: SupModuleList, TailHelpStr = ParseDecPcdTailComment(TailComment, ContainerFile) if SupModuleList: Pcd.SetSupModuleList(SupModuleList) if HelpStr and (not HelpStr.endswith('\n')) and TailHelpStr: HelpStr += '\n' HelpStr += TailHelpStr if HelpStr: HelpTxtObj = TextObject() HelpTxtObj.SetLang(Language) HelpTxtObj.SetString(HelpStr) Pcd.SetHelpTextList([HelpTxtObj]) if PromptStr: TxtObj = TextObject() TxtObj.SetLang(Language) TxtObj.SetString(PromptStr) Pcd.SetPromptList([TxtObj]) return Pcd
def testErrorCase2(self): TestCommentLines = \ '''## BASE INVALID_MODULE_TYPE #hello world''' CommentList = GetSplitValueList(TestCommentLines, "\n") LineNum = 0 TestCommentLinesList = [] for Comment in CommentList: LineNum += 1 TestCommentLinesList.append((Comment, LineNum)) try: ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest') except Logger.FatalError: pass
def testNormalCase5(self): TestCommentLines = \ ''' # 1 = 128MB, 2 = 256MB, 3 = MAX''' CommentList = GetSplitValueList(TestCommentLines, "\n") LineNum = 0 TestCommentLinesList = [] for Comment in CommentList: LineNum += 1 TestCommentLinesList.append((Comment, LineNum)) (SupModeList, HelpStr) = \ ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest') self.failIf(not HelpStr) self.assertEqual(HelpStr, '1 = 128MB, 2 = 256MB, 3 = MAX') self.failIf(SupModeList)
def testNormalCase4(self): TestCommentLines = \ '''## BASE UEFI_APPLICATION''' CommentList = GetSplitValueList(TestCommentLines, "\n") LineNum = 0 TestCommentLinesList = [] for Comment in CommentList: LineNum += 1 TestCommentLinesList.append((Comment, LineNum)) (SupModeList, HelpStr) = \ ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest') self.failIf(HelpStr) self.failIf(not SupModeList) self.assertEqual(SupModeList, ['BASE', 'UEFI_APPLICATION'])