From nobody Thu May 9 12:34:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94950+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94950+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1665432456; cv=none; d=zohomail.com; s=zohoarc; b=GUOgWdD3HL5GAQ/flZjrCaL08ar5SDOBxjiZsZnQ1KLmknno2s71A/8xoXJ9WMRT6m2mfjPfW08Rpzj0YIwkvr/FkPKKeRK3JHwD3PLzu0caF3vDRPn+FQABmOdvzPmRmYd7/LPgIs7Trb0BkSepMV3T0rjcwEKn9/WEMk5OZH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665432456; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qd1fRO0UpISTwxYsOVUXfxvfl+mj2MaRFullc5mPFLg=; b=VO68zsZoM+Qe3HLFudEkzodm6gidgnzjl+QqUBDTUY3a/q45sr3MB0xaVnk/B9hUJTOdBrufM4DiI/vIxTN59aCUoYmbzbLrsX+WGoqCdgJw+1A55H+Sp9qO0PqAxP4S2SMeF6Xw09nS4nwYl9KeMRb7seWKbkSjdBa2VuRDTtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94950+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1665432455425324.5428985964054; Mon, 10 Oct 2022 13:07:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OpjmYY1788612xQZ0Z1uXwwq; Mon, 10 Oct 2022 13:07:33 -0700 X-Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mx.groups.io with SMTP id smtpd.web09.2517.1665432442142677096 for ; Mon, 10 Oct 2022 13:07:23 -0700 X-Received: by mail-pl1-f170.google.com with SMTP id f23so11305918plr.6 for ; Mon, 10 Oct 2022 13:07:22 -0700 (PDT) X-Gm-Message-State: 07DjpoJCf8poW8qfNT8HBhWZx1787277AA= X-Google-Smtp-Source: AMsMyM6C5B+TQ7GFmGDelUq6hnp6BvQOaqsuOQCVfzyhns5beJ8w5zhvE/MnbuojEUQrAIjp+nHPuA== X-Received: by 2002:a17:90b:4c8c:b0:20b:d3f:3c8a with SMTP id my12-20020a17090b4c8c00b0020b0d3f3c8amr22067960pjb.219.1665432435304; Mon, 10 Oct 2022 13:07:15 -0700 (PDT) X-Received: from toolbox.iitism.net ([103.15.228.66]) by smtp.gmail.com with ESMTPSA id l14-20020a170903120e00b0017f74cab9eesm7125298plh.128.2022.10.10.13.06.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 13:07:13 -0700 (PDT) From: "Ayush Singh" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH v1 1/1] Format BaseTools python files using autopep8 Date: Tue, 11 Oct 2022 01:35:50 +0530 Message-Id: <20221010200550.243688-2-ayushdevel1325@gmail.com> In-Reply-To: <20221010200550.243688-1-ayushdevel1325@gmail.com> References: <20221010200550.243688-1-ayushdevel1325@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ayushdevel1325@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1665432453; bh=irx4DJVgs4se4tfkuPKJCPmaWwWempFV/g1iUiCwkWM=; h=Date:From:Reply-To:Subject:To; b=t2RaxVK904Jk+PrOMHIx+Ao8cB4O9ChbbG+9mkpMmzJ2pzjPf1++Cy3pdgD579nFpkP 8/stCXyqAI+/uSjLGKiSOi/awXD/X7nUgG8rfFSBKGMRh1YuXa4wJH+JK2TXdkdLnFNGD XbC/mdRg+Vqx3GlST063QOf4bJ9vrUi1OD4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1665432462500100001 Content-Type: text/plain; charset="utf-8" Format all python files in BaseTools using the following commands: $ find . -name '*.py' -exec autopep8 --in-place '{}' \; This is to make the Python code PEP8 compilant as stated in EDK II Python Development Process Specification Signed-off-by: Ayush Singh --- BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py = | 74 +- BaseTools/Edk2ToolsBuild.py = | 4 +- BaseTools/Plugin/BuildToolsReport/BuildToolsReportGenerator.py = | 15 +- BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py = | 6 +- BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py = | 8 +- BaseTools/Scripts/BinToPcd.py = | 185 +- BaseTools/Scripts/ConvertFceToStructurePcd.py = | 1312 ++-- BaseTools/Scripts/ConvertMasmToNasm.py = | 7 +- BaseTools/Scripts/ConvertUni.py = | 14 +- BaseTools/Scripts/DetectNotUsedItem.py = | 23 +- BaseTools/Scripts/FormatDosFiles.py = | 25 +- BaseTools/Scripts/GetMaintainer.py = | 19 +- BaseTools/Scripts/GetUtcDateTime.py = | 18 +- BaseTools/Scripts/MemoryProfileSymbolGen.py = | 162 +- BaseTools/Scripts/PackageDocumentTools/__init__.py = | 2 +- BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py = | 138 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/__init__.py = | 2 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/__init= __.py | 2 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxyge= n.py | 79 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibin= ary.py | 96 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py= | 92 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/inidoc= view.py | 3 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/messag= e.py | 12 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/__init__.py= | 2 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/__ini= t__.py | 2 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseo= bject.py | 165 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/dec.p= y | 41 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxyg= engen.py | 374 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxyg= engen_spec.py | 372 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/dsc.p= y | 25 +- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/inf.p= y | 59 +- BaseTools/Scripts/PackageDocumentTools/plugins/__init__.py = | 2 +- BaseTools/Scripts/PatchCheck.py = | 90 +- BaseTools/Scripts/RunMakefile.py = | 258 +- BaseTools/Scripts/SetupGit.py = | 23 +- BaseTools/Scripts/SmiHandlerProfileSymbolGen.py = | 165 +- BaseTools/Scripts/UpdateBuildVersions.py = | 64 +- BaseTools/Scripts/efi_debugging.py = | 4 +- BaseTools/Scripts/efi_gdb.py = | 1 + BaseTools/Source/C/Makefiles/NmakeSubdirs.py = | 43 +- BaseTools/Source/C/PyEfiCompressor/setup.py = | 16 +- BaseTools/Source/Python/AmlToC/AmlToC.py = | 29 +- BaseTools/Source/Python/AutoGen/AutoGen.py = | 58 +- BaseTools/Source/Python/AutoGen/AutoGenWorker.py = | 145 +- BaseTools/Source/Python/AutoGen/BuildEngine.py = | 158 +- BaseTools/Source/Python/AutoGen/DataPipe.py = | 152 +- BaseTools/Source/Python/AutoGen/GenC.py = | 944 ++- BaseTools/Source/Python/AutoGen/GenDepex.py = | 211 +- BaseTools/Source/Python/AutoGen/GenMake.py = | 738 +- BaseTools/Source/Python/AutoGen/GenPcdDb.py = | 533 +- BaseTools/Source/Python/AutoGen/GenVar.py = | 182 +- BaseTools/Source/Python/AutoGen/IdfClassObject.py = | 97 +- BaseTools/Source/Python/AutoGen/IncludesAutoGen.py = | 109 +- BaseTools/Source/Python/AutoGen/InfSectionParser.py = | 47 +- BaseTools/Source/Python/AutoGen/ModuleAutoGen.py = | 945 ++- BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py = | 255 +- BaseTools/Source/Python/AutoGen/PlatformAutoGen.py = | 554 +- BaseTools/Source/Python/AutoGen/StrGather.py = | 221 +- BaseTools/Source/Python/AutoGen/UniClassObject.py = | 261 +- BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py = | 23 +- BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py = | 405 +- BaseTools/Source/Python/AutoGen/__init__.py = | 2 +- BaseTools/Source/Python/BPDG/BPDG.py = | 37 +- BaseTools/Source/Python/BPDG/GenVpd.py = | 348 +- BaseTools/Source/Python/BPDG/StringTable.py = | 47 +- BaseTools/Source/Python/BPDG/__init__.py = | 2 +- BaseTools/Source/Python/Capsule/GenerateCapsule.py = | 1329 ++-- BaseTools/Source/Python/Capsule/GenerateWindowsDriver.py = | 119 +- BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py = | 83 +- BaseTools/Source/Python/Common/BuildToolError.py = | 109 +- BaseTools/Source/Python/Common/BuildVersion.py = | 2 +- BaseTools/Source/Python/Common/DataType.py = | 187 +- BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.py = | 84 +- BaseTools/Source/Python/Common/Edk2/Capsule/__init__.py = | 2 +- BaseTools/Source/Python/Common/Edk2/__init__.py = | 2 +- BaseTools/Source/Python/Common/EdkLogger.py = | 112 +- BaseTools/Source/Python/Common/Expression.py = | 243 +- BaseTools/Source/Python/Common/GlobalData.py = | 24 +- BaseTools/Source/Python/Common/LongFilePathOs.py = | 31 +- BaseTools/Source/Python/Common/LongFilePathOsPath.py = | 10 +- BaseTools/Source/Python/Common/LongFilePathSupport.py = | 11 +- BaseTools/Source/Python/Common/Misc.py = | 479 +- BaseTools/Source/Python/Common/MultipleWorkspace.py = | 32 +- BaseTools/Source/Python/Common/Parsing.py = | 332 +- BaseTools/Source/Python/Common/RangeExpression.py = | 89 +- BaseTools/Source/Python/Common/StringUtils.py = | 194 +- BaseTools/Source/Python/Common/TargetTxtClassObject.py = | 73 +- BaseTools/Source/Python/Common/ToolDefClassObject.py = | 89 +- BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.py = | 394 +- BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py = | 117 +- BaseTools/Source/Python/Common/Uefi/Capsule/FmpCapsuleHeader.py = | 286 +- BaseTools/Source/Python/Common/Uefi/Capsule/UefiCapsuleHeader.py = | 110 +- BaseTools/Source/Python/Common/Uefi/Capsule/__init__.py = | 2 +- BaseTools/Source/Python/Common/Uefi/__init__.py = | 2 +- BaseTools/Source/Python/Common/VariableAttributes.py = | 14 +- BaseTools/Source/Python/Common/VpdInfoFile.py = | 96 +- BaseTools/Source/Python/Common/__init__.py = | 2 +- BaseTools/Source/Python/Common/caching.py = | 29 +- BaseTools/Source/Python/CommonDataClass/CommonClass.py = | 29 +- BaseTools/Source/Python/CommonDataClass/DataClass.py = | 88 +- BaseTools/Source/Python/CommonDataClass/Exceptions.py = | 12 +- BaseTools/Source/Python/CommonDataClass/FdfClass.py = | 129 +- BaseTools/Source/Python/CommonDataClass/__init__.py = | 2 +- BaseTools/Source/Python/Ecc/CParser3/CLexer.py = | 1908 ++--- BaseTools/Source/Python/Ecc/CParser3/CParser.py = | 7876 +++++++++----------- BaseTools/Source/Python/Ecc/CParser4/CLexer.py = | 140 +- BaseTools/Source/Python/Ecc/CParser4/CListener.py = | 359 +- BaseTools/Source/Python/Ecc/CParser4/CParser.py = | 2451 +++--- BaseTools/Source/Python/Ecc/Check.py = | 404 +- BaseTools/Source/Python/Ecc/CodeFragment.py = | 68 +- BaseTools/Source/Python/Ecc/CodeFragmentCollector.py = | 151 +- BaseTools/Source/Python/Ecc/Configuration.py = | 245 +- BaseTools/Source/Python/Ecc/Database.py = | 111 +- BaseTools/Source/Python/Ecc/EccGlobalData.py = | 2 +- BaseTools/Source/Python/Ecc/EccMain.py = | 144 +- BaseTools/Source/Python/Ecc/EccToolError.py = | 177 +- BaseTools/Source/Python/Ecc/Exception.py = | 16 +- BaseTools/Source/Python/Ecc/FileProfile.py = | 10 +- BaseTools/Source/Python/Ecc/MetaDataParser.py = | 62 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py = | 43 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py = | 827 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py = | 181 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py = | 2 +- BaseTools/Source/Python/Ecc/ParserWarning.py = | 8 +- BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py = | 39 +- BaseTools/Source/Python/Ecc/Xml/__init__.py = | 2 +- BaseTools/Source/Python/Ecc/__init__.py = | 2 +- BaseTools/Source/Python/Ecc/c.py = | 512 +- BaseTools/Source/Python/Eot/CParser3/CLexer.py = | 1908 ++--- BaseTools/Source/Python/Eot/CParser3/CParser.py = | 7876 +++++++++----------- BaseTools/Source/Python/Eot/CParser4/CLexer.py = | 139 +- BaseTools/Source/Python/Eot/CParser4/CListener.py = | 358 +- BaseTools/Source/Python/Eot/CParser4/CParser.py = | 2451 +++--- BaseTools/Source/Python/Eot/CodeFragment.py = | 78 +- BaseTools/Source/Python/Eot/CodeFragmentCollector.py = | 119 +- BaseTools/Source/Python/Eot/Database.py = | 77 +- BaseTools/Source/Python/Eot/EotGlobalData.py = | 5 +- BaseTools/Source/Python/Eot/EotMain.py = | 544 +- BaseTools/Source/Python/Eot/EotToolError.py = | 7 +- BaseTools/Source/Python/Eot/FileProfile.py = | 10 +- BaseTools/Source/Python/Eot/Identification.py = | 11 +- BaseTools/Source/Python/Eot/InfParserLite.py = | 52 +- BaseTools/Source/Python/Eot/Parser.py = | 244 +- BaseTools/Source/Python/Eot/ParserWarning.py = | 6 +- BaseTools/Source/Python/Eot/Report.py = | 63 +- BaseTools/Source/Python/Eot/__init__.py = | 2 +- BaseTools/Source/Python/Eot/c.py = | 100 +- BaseTools/Source/Python/FMMT/FMMT.py = | 57 +- BaseTools/Source/Python/FMMT/__init__.py = | 4 +- BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py = | 151 +- BaseTools/Source/Python/FMMT/core/BiosTree.py = | 47 +- BaseTools/Source/Python/FMMT/core/BiosTreeNode.py = | 77 +- BaseTools/Source/Python/FMMT/core/FMMTOperation.py = | 40 +- BaseTools/Source/Python/FMMT/core/FMMTParser.py = | 30 +- BaseTools/Source/Python/FMMT/core/FvHandler.py = | 201 +- BaseTools/Source/Python/FMMT/core/GuidTools.py = | 47 +- BaseTools/Source/Python/FMMT/utils/FmmtLogger.py = | 10 +- BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py = | 29 +- BaseTools/Source/Python/FirmwareStorageFormat/Common.py = | 20 +- BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py = | 5 +- BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py = | 31 +- BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py = | 9 +- BaseTools/Source/Python/FirmwareStorageFormat/__init__.py = | 4 +- BaseTools/Source/Python/GenFds/AprioriSection.py = | 48 +- BaseTools/Source/Python/GenFds/Capsule.py = | 103 +- BaseTools/Source/Python/GenFds/CapsuleData.py = | 111 +- BaseTools/Source/Python/GenFds/CompressSection.py = | 42 +- BaseTools/Source/Python/GenFds/DataSection.py = | 63 +- BaseTools/Source/Python/GenFds/DepexSection.py = | 40 +- BaseTools/Source/Python/GenFds/EfiSection.py = | 167 +- BaseTools/Source/Python/GenFds/Fd.py = | 80 +- BaseTools/Source/Python/GenFds/FdfParser.py = | 1680 +++-- BaseTools/Source/Python/GenFds/Ffs.py = | 58 +- BaseTools/Source/Python/GenFds/FfsFileStatement.py = | 67 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py = | 572 +- BaseTools/Source/Python/GenFds/Fv.py = | 240 +- BaseTools/Source/Python/GenFds/FvImageSection.py = | 77 +- BaseTools/Source/Python/GenFds/GenFds.py = | 353 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py = | 355 +- BaseTools/Source/Python/GenFds/GuidSection.py = | 90 +- BaseTools/Source/Python/GenFds/OptRomFileStatement.py = | 16 +- BaseTools/Source/Python/GenFds/OptRomInfStatement.py = | 56 +- BaseTools/Source/Python/GenFds/OptionRom.py = | 46 +- BaseTools/Source/Python/GenFds/Region.py = | 113 +- BaseTools/Source/Python/GenFds/Rule.py = | 8 +- BaseTools/Source/Python/GenFds/RuleComplexFile.py = | 12 +- BaseTools/Source/Python/GenFds/RuleSimpleFile.py = | 10 +- BaseTools/Source/Python/GenFds/Section.py = | 121 +- BaseTools/Source/Python/GenFds/UiSection.py = | 23 +- BaseTools/Source/Python/GenFds/VerSection.py = | 15 +- BaseTools/Source/Python/GenFds/__init__.py = | 2 +- BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py = | 61 +- BaseTools/Source/Python/GenPatchPcdTable/__init__.py = | 2 +- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py = | 49 +- BaseTools/Source/Python/PatchPcdValue/__init__.py = | 2 +- BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py = | 408 +- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py = | 259 +- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py = | 350 +- BaseTools/Source/Python/Split/Split.py = | 17 +- BaseTools/Source/Python/Table/Table.py = | 25 +- BaseTools/Source/Python/Table/TableDataModel.py = | 17 +- BaseTools/Source/Python/Table/TableDec.py = | 15 +- BaseTools/Source/Python/Table/TableDsc.py = | 15 +- BaseTools/Source/Python/Table/TableEotReport.py = | 19 +- BaseTools/Source/Python/Table/TableFdf.py = | 15 +- BaseTools/Source/Python/Table/TableFile.py = | 26 +- BaseTools/Source/Python/Table/TableFunction.py = | 15 +- BaseTools/Source/Python/Table/TableIdentifier.py = | 15 +- BaseTools/Source/Python/Table/TableInf.py = | 15 +- BaseTools/Source/Python/Table/TablePcd.py = | 15 +- BaseTools/Source/Python/Table/TableQuery.py = | 12 +- BaseTools/Source/Python/Table/TableReport.py = | 37 +- BaseTools/Source/Python/Table/__init__.py = | 2 +- BaseTools/Source/Python/TargetTool/TargetTool.py = | 107 +- BaseTools/Source/Python/TargetTool/__init__.py = | 2 +- BaseTools/Source/Python/Trim/Trim.py = | 224 +- BaseTools/Source/Python/UPT/BuildVersion.py = | 2 +- BaseTools/Source/Python/UPT/Core/DependencyRules.py = | 82 +- BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py = | 78 +- BaseTools/Source/Python/UPT/Core/FileHook.py = | 50 +- BaseTools/Source/Python/UPT/Core/IpiDb.py = | 230 +- BaseTools/Source/Python/UPT/Core/PackageFile.py = | 61 +- BaseTools/Source/Python/UPT/Core/__init__.py = | 2 +- BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py = | 149 +- BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py = | 181 +- BaseTools/Source/Python/UPT/GenMetaFile/GenMetaFileMisc.py = | 40 +- BaseTools/Source/Python/UPT/GenMetaFile/GenXmlFile.py = | 2 +- BaseTools/Source/Python/UPT/GenMetaFile/__init__.py = | 2 +- BaseTools/Source/Python/UPT/InstallPkg.py = | 295 +- BaseTools/Source/Python/UPT/InventoryWs.py = | 45 +- BaseTools/Source/Python/UPT/Library/CommentGenerating.py = | 88 +- BaseTools/Source/Python/UPT/Library/CommentParsing.py = | 177 +- BaseTools/Source/Python/UPT/Library/DataType.py = | 379 +- BaseTools/Source/Python/UPT/Library/ExpressionValidate.py = | 147 +- BaseTools/Source/Python/UPT/Library/GlobalData.py = | 2 +- BaseTools/Source/Python/UPT/Library/Misc.py = | 227 +- BaseTools/Source/Python/UPT/Library/ParserValidate.py = | 130 +- BaseTools/Source/Python/UPT/Library/Parsing.py = | 363 +- BaseTools/Source/Python/UPT/Library/StringUtils.py = | 203 +- BaseTools/Source/Python/UPT/Library/UniClassObject.py = | 447 +- BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py = | 37 +- BaseTools/Source/Python/UPT/Library/Xml/__init__.py = | 2 +- BaseTools/Source/Python/UPT/Library/__init__.py = | 2 +- BaseTools/Source/Python/UPT/Logger/Log.py = | 97 +- BaseTools/Source/Python/UPT/Logger/StringTable.py = | 933 +-- BaseTools/Source/Python/UPT/Logger/ToolError.py = | 117 +- BaseTools/Source/Python/UPT/Logger/__init__.py = | 2 +- BaseTools/Source/Python/UPT/MkPkg.py = | 73 +- BaseTools/Source/Python/UPT/Object/POM/CommonObject.py = | 93 +- BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py = | 35 +- BaseTools/Source/Python/UPT/Object/POM/PackageObject.py = | 13 +- BaseTools/Source/Python/UPT/Object/POM/__init__.py = | 2 +- BaseTools/Source/Python/UPT/Object/Parser/DecObject.py = | 186 +- BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py = | 138 +- BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py = | 15 +- BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py = | 46 +- BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py = | 36 +- BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py = | 334 +- BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py = | 21 +- BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py = | 51 +- BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py = | 34 +- BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py = | 35 +- BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py = | 23 +- BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py = | 35 +- BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py = | 116 +- BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py = | 46 +- BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py = | 42 +- BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py = | 66 +- BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py = | 24 +- BaseTools/Source/Python/UPT/Object/Parser/__init__.py = | 2 +- BaseTools/Source/Python/UPT/Object/__init__.py = | 2 +- BaseTools/Source/Python/UPT/Parser/DecParser.py = | 280 +- BaseTools/Source/Python/UPT/Parser/DecParserMisc.py = | 56 +- BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py = | 47 +- BaseTools/Source/Python/UPT/Parser/InfBinarySectionParser.py = | 44 +- BaseTools/Source/Python/UPT/Parser/InfBuildOptionSectionParser.py = | 53 +- BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py = | 45 +- BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py = | 15 +- BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py = | 73 +- BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py = | 38 +- BaseTools/Source/Python/UPT/Parser/InfPackageSectionParser.py = | 34 +- BaseTools/Source/Python/UPT/Parser/InfParser.py = | 164 +- BaseTools/Source/Python/UPT/Parser/InfParserMisc.py = | 122 +- BaseTools/Source/Python/UPT/Parser/InfPcdSectionParser.py = | 45 +- BaseTools/Source/Python/UPT/Parser/InfSectionParser.py = | 94 +- BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py = | 39 +- BaseTools/Source/Python/UPT/Parser/__init__.py = | 2 +- BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py = | 236 +- BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py = | 183 +- BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py = | 35 +- BaseTools/Source/Python/UPT/PomAdapter/__init__.py = | 2 +- BaseTools/Source/Python/UPT/ReplacePkg.py = | 60 +- BaseTools/Source/Python/UPT/RmPkg.py = | 66 +- BaseTools/Source/Python/UPT/TestInstall.py = | 27 +- BaseTools/Source/Python/UPT/UPT.py = | 150 +- BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py = | 86 +- BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py = | 91 +- BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py = | 23 +- BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py = | 118 +- BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py = | 131 +- BaseTools/Source/Python/UPT/Xml/CommonXml.py = | 265 +- BaseTools/Source/Python/UPT/Xml/GuidProtocolPpiXml.py = | 139 +- BaseTools/Source/Python/UPT/Xml/IniToXml.py = | 152 +- BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py = | 143 +- BaseTools/Source/Python/UPT/Xml/PackageSurfaceAreaXml.py = | 87 +- BaseTools/Source/Python/UPT/Xml/PcdXml.py = | 141 +- BaseTools/Source/Python/UPT/Xml/XmlParser.py = | 363 +- BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py = | 22 +- BaseTools/Source/Python/UPT/Xml/__init__.py = | 2 +- BaseTools/Source/Python/Workspace/BuildClassObject.py = | 303 +- BaseTools/Source/Python/Workspace/DecBuildData.py = | 184 +- BaseTools/Source/Python/Workspace/DscBuildData.py = | 2007 +++-- BaseTools/Source/Python/Workspace/InfBuildData.py = | 426 +- BaseTools/Source/Python/Workspace/MetaDataTable.py = | 98 +- BaseTools/Source/Python/Workspace/MetaFileCommentParser.py = | 21 +- BaseTools/Source/Python/Workspace/MetaFileParser.py = | 885 ++- BaseTools/Source/Python/Workspace/MetaFileTable.py = | 217 +- BaseTools/Source/Python/Workspace/WorkspaceCommon.py = | 60 +- BaseTools/Source/Python/Workspace/WorkspaceDatabase.py = | 67 +- BaseTools/Source/Python/Workspace/__init__.py = | 2 +- BaseTools/Source/Python/build/BuildReport.py = | 766 +- BaseTools/Source/Python/build/__init__.py = | 2 +- BaseTools/Source/Python/build/build.py = | 1145 +-- BaseTools/Source/Python/build/buildoptions.py = | 113 +- BaseTools/Source/Python/sitecustomize.py = | 11 +- BaseTools/Source/Python/tests/Split/test_split.py = | 37 +- BaseTools/Tests/CToolsTests.py = | 6 +- BaseTools/Tests/CheckPythonSyntax.py = | 15 +- BaseTools/Tests/CheckUnicodeSourceFiles.py = | 4 +- BaseTools/Tests/PythonTest.py = | 2 +- BaseTools/Tests/PythonToolsTests.py = | 4 +- BaseTools/Tests/RunTests.py = | 7 +- BaseTools/Tests/TestRegularExpression.py = | 7 +- BaseTools/Tests/TestTools.py = | 54 +- BaseTools/Tests/TianoCompress.py = | 15 +- 335 files changed, 35765 insertions(+), 32705 deletions(-) diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py b/BaseTools/= Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py index 3035732d5c81..cd0577e22c0e 100755 --- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py @@ -26,22 +26,27 @@ import pipes # Convert using cygpath command line tool # Currently not used, but just in case we need it in the future # + + def ConvertCygPathToDosViacygpath(CygPath): - p =3D subprocess.Popen("cygpath -m " + pipes.quote(CygPath), shell=3DTru= e, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT, close_fds=3DTrue) - return p.stdout.read().strip() + p =3D subprocess.Popen("cygpath -m " + pipes.quote(CygPath), shell=3DT= rue, + stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STD= OUT, close_fds=3DTrue) + return p.stdout.read().strip() =20 # # # + + def ConvertCygPathToDos(CygPath): - if CygPath.find("/cygdrive/") =3D=3D 0: - # convert /cygdrive/c/Xyz to c:/Xyz - DosPath =3D CygPath[10] + ':' + CygPath[11:] - else: - DosPath =3D CygPath + if CygPath.find("/cygdrive/") =3D=3D 0: + # convert /cygdrive/c/Xyz to c:/Xyz + DosPath =3D CygPath[10] + ':' + CygPath[11:] + else: + DosPath =3D CygPath =20 - # pipes.quote will add the extra \\ for us. - return DosPath.replace('/', '\\') + # pipes.quote will add the extra \\ for us. + return DosPath.replace('/', '\\') =20 =20 # we receive our options as a list, but we will be passing them to the she= ll as a line @@ -50,38 +55,37 @@ def ConvertCygPathToDos(CygPath): # if you don't use the shell you don't get a PATH search. def main(argv): =20 - # use 1st argument as name of tool to call - Command =3D pipes.quote(sys.argv[1]); + # use 1st argument as name of tool to call + Command =3D pipes.quote(sys.argv[1]) =20 - ExceptionList =3D ["/interwork"] + ExceptionList =3D ["/interwork"] =20 - for arg in argv: - if arg.find('/') =3D=3D -1: - # if we don't need to convert just add to the command line - Command =3D Command + ' ' + pipes.quote(arg) - elif arg in ExceptionList: - # if it is in the list, then don't do a cygpath - # assembler stuff after --apcs has the /. - Command =3D Command + ' ' + pipes.quote(arg) - else: - if ((arg[0] =3D=3D '-') and (arg[1] =3D=3D 'I' or arg[1] =3D=3D 'i')= ): - CygPath =3D arg[0] + arg[1] + ConvertCygPathToDos(arg[2:]) - else: - CygPath =3D ConvertCygPathToDos(arg) + for arg in argv: + if arg.find('/') =3D=3D -1: + # if we don't need to convert just add to the command line + Command =3D Command + ' ' + pipes.quote(arg) + elif arg in ExceptionList: + # if it is in the list, then don't do a cygpath + # assembler stuff after --apcs has the /. + Command =3D Command + ' ' + pipes.quote(arg) + else: + if ((arg[0] =3D=3D '-') and (arg[1] =3D=3D 'I' or arg[1] =3D= =3D 'i')): + CygPath =3D arg[0] + arg[1] + ConvertCygPathToDos(arg[2:]) + else: + CygPath =3D ConvertCygPathToDos(arg) =20 - Command =3D Command + ' ' + pipes.quote(CygPath) + Command =3D Command + ' ' + pipes.quote(CygPath) =20 - # call the real tool with the converted paths - return subprocess.call(Command, shell=3DTrue) + # call the real tool with the converted paths + return subprocess.call(Command, shell=3DTrue) =20 =20 if __name__ =3D=3D "__main__": - try: - ret =3D main(sys.argv[2:]) + try: + ret =3D main(sys.argv[2:]) =20 - except: - print("exiting: exception from " + sys.argv[0]) - ret =3D 2 - - sys.exit(ret) + except: + print("exiting: exception from " + sys.argv[0]) + ret =3D 2 =20 + sys.exit(ret) diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py index f862468ce275..f719924c2c0e 100644 --- a/BaseTools/Edk2ToolsBuild.py +++ b/BaseTools/Edk2ToolsBuild.py @@ -143,7 +143,8 @@ class Edk2ToolsBuild(BaseAbstractInvocable): =20 elif self.tool_chain_tag.lower().startswith("gcc"): cpu_count =3D self.GetCpuThreads() - ret =3D RunCmd("make", f"-C . -j {cpu_count}", workingdir=3Ds= hell_env.get_shell_var("EDK_TOOLS_PATH")) + ret =3D RunCmd( + "make", f"-C . -j {cpu_count}", workingdir=3Dshell_env.ge= t_shell_var("EDK_TOOLS_PATH")) if ret !=3D 0: raise Exception("Failed to build.") =20 @@ -168,7 +169,6 @@ class Edk2ToolsBuild(BaseAbstractInvocable): return cpus =20 =20 - def main(): Edk2ToolsBuild().Invoke() =20 diff --git a/BaseTools/Plugin/BuildToolsReport/BuildToolsReportGenerator.py= b/BaseTools/Plugin/BuildToolsReport/BuildToolsReportGenerator.py index 9f86b1c35885..5c826a9e7104 100644 --- a/BaseTools/Plugin/BuildToolsReport/BuildToolsReportGenerator.py +++ b/BaseTools/Plugin/BuildToolsReport/BuildToolsReportGenerator.py @@ -14,16 +14,19 @@ try: try: from edk2toolext.environment import version_aggregator except ImportError: - logging.critical("Loading BuildToolsReportGenerator failed= , please update your Edk2-PyTool-Extensions") + logging.critical( + "Loading BuildToolsReportGenerator failed, please upda= te your Edk2-PyTool-Extensions") return 0 =20 - OutputReport =3D os.path.join(thebuilder.env.GetValue("BUILD_O= UTPUT_BASE"), "BUILD_TOOLS_REPORT") + OutputReport =3D os.path.join(thebuilder.env.GetValue( + "BUILD_OUTPUT_BASE"), "BUILD_TOOLS_REPORT") OutputReport =3D os.path.normpath(OutputReport) if not os.path.isdir(os.path.dirname(OutputReport)): os.makedirs(os.path.dirname(OutputReport)) =20 Report =3D BuildToolsReport() - Report.MakeReport(version_aggregator.GetVersionAggregator().Ge= tAggregatedVersionInformation(), OutputReport=3DOutputReport) + Report.MakeReport(version_aggregator.GetVersionAggregator( + ).GetAggregatedVersionInformation(), OutputReport=3DOutputRepo= rt) =20 def do_pre_build(self, thebuilder): self.do_report(thebuilder) @@ -55,11 +58,13 @@ class BuildToolsReport(object): =20 htmlfile =3D open(OutputReport + ".html", "w") jsonfile =3D open(OutputReport + ".json", "w") - template =3D open(os.path.join(BuildToolsReport.MY_FOLDER, "BuildT= oolsReport_Template.html"), "r") + template =3D open(os.path.join(BuildToolsReport.MY_FOLDER, + "BuildToolsReport_Template.html"), "r") =20 for line in template.readlines(): if "%TO_BE_FILLED_IN_BY_PYTHON_SCRIPT%" in line: - line =3D line.replace("%TO_BE_FILLED_IN_BY_PYTHON_SCRIPT%"= , json.dumps(json_dict)) + line =3D line.replace( + "%TO_BE_FILLED_IN_BY_PYTHON_SCRIPT%", json.dumps(json_= dict)) htmlfile.write(line) =20 jsonfile.write(json.dumps(versions_list, indent=3D4)) diff --git a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py b/Ba= seTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py index f0685d804029..8d5b0e0d3fba 100644 --- a/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py +++ b/BaseTools/Plugin/LinuxGcc5ToolChain/LinuxGcc5ToolChain.py @@ -57,7 +57,8 @@ class LinuxGcc5ToolChain(IUefiBuildPlugin): return 0 =20 # make GCC5_ARM_PREFIX to align with tools_def.txt - prefix =3D os.path.join(install_path, "bin", "arm-none-linux-g= nueabihf-") + prefix =3D os.path.join(install_path, "bin", + "arm-none-linux-gnueabihf-") shell_environment.GetEnvironment().set_shell_var("GCC5_ARM_PRE= FIX", prefix) =20 # now confirm it exists @@ -80,7 +81,8 @@ class LinuxGcc5ToolChain(IUefiBuildPlugin): return 0 =20 # make GCC5_AARCH64_PREFIX to align with tools_def.txt - prefix =3D os.path.join(install_path, "bin", "aarch64-none-lin= ux-gnu-") + prefix =3D os.path.join(install_path, "bin", + "aarch64-none-linux-gnu-") shell_environment.GetEnvironment().set_shell_var("GCC5_AARCH64= _PREFIX", prefix) =20 # now confirm it exists diff --git a/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py b/BaseTo= ols/Plugin/WindowsResourceCompiler/WinRcPath.py index ec2f2d1298f9..f6da2312f4bd 100644 --- a/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py +++ b/BaseTools/Plugin/WindowsResourceCompiler/WinRcPath.py @@ -1,4 +1,4 @@ -## @file WinRcPath.py +# @file WinRcPath.py # Plugin to find Windows SDK Resource Compiler rc.exe ## # This plugin works in conjuncture with the tools_def to support rc.exe @@ -12,18 +12,20 @@ import edk2toollib.windows.locate_tools as locate_tools from edk2toolext.environment import shell_environment from edk2toolext.environment import version_aggregator =20 + class WinRcPath(IUefiBuildPlugin): =20 def do_post_build(self, thebuilder): return 0 =20 def do_pre_build(self, thebuilder): - #get the locate tools module + # get the locate tools module path =3D locate_tools.FindToolInWinSdk("rc.exe") if path is None: thebuilder.logging.warning("Failed to find rc.exe") else: p =3D os.path.abspath(os.path.dirname(path)) shell_environment.GetEnvironment().set_shell_var("WINSDK_PATH_= FOR_RC_EXE", p) - version_aggregator.GetVersionAggregator().ReportVersion("WINSD= K_PATH_FOR_RC_EXE", p, version_aggregator.VersionTypes.INFO) + version_aggregator.GetVersionAggregator().ReportVersion( + "WINSDK_PATH_FOR_RC_EXE", p, version_aggregator.VersionTyp= es.INFO) return 0 diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index 3bc557b8412c..0e82a349d26d 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -1,4 +1,4 @@ -## @file +# @file # Convert a binary file to a VOID* PCD value or DSC file VOID* PCD stateme= nt. # # Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
@@ -18,89 +18,93 @@ import xdrlib # # Globals for help information # -__prog__ =3D 'BinToPcd' -__copyright__ =3D 'Copyright (c) 2016 - 2018, Intel Corporation. All rig= hts reserved.' +__prog__ =3D 'BinToPcd' +__copyright__ =3D 'Copyright (c) 2016 - 2018, Intel Corporation. All right= s reserved.' __description__ =3D 'Convert one or more binary files to a VOID* PCD value= or DSC file VOID* PCD statement.\n' =20 if __name__ =3D=3D '__main__': - def ValidateUnsignedInteger (Argument): + def ValidateUnsignedInteger(Argument): try: - Value =3D int (Argument, 0) + Value =3D int(Argument, 0) except: - Message =3D '{Argument} is not a valid integer value.'.format = (Argument =3D Argument) - raise argparse.ArgumentTypeError (Message) + Message =3D '{Argument} is not a valid integer value.'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) if Value < 0: - Message =3D '{Argument} is a negative value.'.format (Argument= =3D Argument) - raise argparse.ArgumentTypeError (Message) + Message =3D '{Argument} is a negative value.'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) return Value =20 - def ValidatePcdName (Argument): - if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*',= Argument) !=3D ['', '']: - Message =3D '{Argument} is not in the form .'.format (Argument =3D Argument) - raise argparse.ArgumentTypeError (Message) + def ValidatePcdName(Argument): + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', = Argument) !=3D ['', '']: + Message =3D '{Argument} is not in the form .'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) return Argument =20 - def ValidateGuidName (Argument): - if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) !=3D ['', '']: - Message =3D '{Argument} is not a valid GUID C name'.format (Ar= gument =3D Argument) - raise argparse.ArgumentTypeError (Message) + def ValidateGuidName(Argument): + if re.split('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) !=3D ['', '']: + Message =3D '{Argument} is not a valid GUID C name'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) return Argument =20 - def ByteArray (Buffer, Xdr =3D False): + def ByteArray(Buffer, Xdr=3DFalse): if Xdr: # # If Xdr flag is set then encode data using the Variable-Lengt= h Opaque # Data format of RFC 4506 External Data Representation Standar= d (XDR). # - XdrEncoder =3D xdrlib.Packer () + XdrEncoder =3D xdrlib.Packer() for Item in Buffer: - XdrEncoder.pack_bytes (Item) - Buffer =3D bytearray (XdrEncoder.get_buffer ()) + XdrEncoder.pack_bytes(Item) + Buffer =3D bytearray(XdrEncoder.get_buffer()) else: # # If Xdr flag is not set, then concatenate all the data # - Buffer =3D bytearray (b''.join (Buffer)) + Buffer =3D bytearray(b''.join(Buffer)) # # Return a PCD value of the form '{0x01, 0x02, ...}' along with th= e PCD length in bytes # - return '{' + (', '.join (['0x{Byte:02X}'.format (Byte =3D Item) fo= r Item in Buffer])) + '}', len (Buffer) + return '{' + (', '.join(['0x{Byte:02X}'.format(Byte=3DItem) for It= em in Buffer])) + '}', len(Buffer) =20 # # Create command line argument parser object # - parser =3D argparse.ArgumentParser (prog =3D __prog__, - description =3D __description__ + __= copyright__, - conflict_handler =3D 'resolve') - parser.add_argument ("-i", "--input", dest =3D 'InputFile', type =3D a= rgparse.FileType ('rb'), action=3D'append', required =3D True, - help =3D "Input binary filename. Multiple input = files are combined into a single PCD.") - parser.add_argument ("-o", "--output", dest =3D 'OutputFile', type =3D= argparse.FileType ('w'), - help =3D "Output filename for PCD value or PCD st= atement") - parser.add_argument ("-p", "--pcd", dest =3D 'PcdName', type =3D Valid= atePcdName, - help =3D "Name of the PCD in the form .") - parser.add_argument ("-t", "--type", dest =3D 'PcdType', default =3D N= one, choices =3D ['VPD', 'HII'], - help =3D "PCD statement type (HII or VPD). Defau= lt is standard.") - parser.add_argument ("-m", "--max-size", dest =3D 'MaxSize', type =3D = ValidateUnsignedInteger, - help =3D "Maximum size of the PCD. Ignored with = --type HII.") - parser.add_argument ("-f", "--offset", dest =3D 'Offset', type =3D Val= idateUnsignedInteger, - help =3D "VPD offset if --type is VPD. UEFI Vari= able offset if --type is HII. Must be 8-byte aligned.") - parser.add_argument ("-n", "--variable-name", dest =3D 'VariableName', - help =3D "UEFI variable name. Only used with --t= ype HII.") - parser.add_argument ("-g", "--variable-guid", type =3D ValidateGuidNam= e, dest =3D 'VariableGuid', - help =3D "UEFI variable GUID C name. Only used w= ith --type HII.") - parser.add_argument ("-x", "--xdr", dest =3D 'Xdr', action =3D "store_= true", - help =3D "Encode PCD using the Variable-Length Op= aque Data format of RFC 4506 External Data Representation Standard (XDR)") - parser.add_argument ("-v", "--verbose", dest =3D 'Verbose', action =3D= "store_true", - help =3D "Increase output messages") - parser.add_argument ("-q", "--quiet", dest =3D 'Quiet', action =3D "st= ore_true", - help =3D "Reduce output messages") - parser.add_argument ("--debug", dest =3D 'Debug', type =3D int, metava= r =3D '[0-9]', choices =3D range (0, 10), default =3D 0, - help =3D "Set debug level") + parser =3D argparse.ArgumentParser(prog=3D__prog__, + description=3D__description__ + __cop= yright__, + conflict_handler=3D'resolve') + parser.add_argument("-i", "--input", dest=3D'InputFile', type=3Dargpar= se.FileType('rb'), action=3D'append', required=3DTrue, + help=3D"Input binary filename. Multiple input fil= es are combined into a single PCD.") + parser.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dargp= arse.FileType('w'), + help=3D"Output filename for PCD value or PCD state= ment") + parser.add_argument("-p", "--pcd", dest=3D'PcdName', type=3DValidatePc= dName, + help=3D"Name of the PCD in the form .") + parser.add_argument("-t", "--type", dest=3D'PcdType', default=3DNone, = choices=3D['VPD', 'HII'], + help=3D"PCD statement type (HII or VPD). Default = is standard.") + parser.add_argument("-m", "--max-size", dest=3D'MaxSize', type=3DValid= ateUnsignedInteger, + help=3D"Maximum size of the PCD. Ignored with --t= ype HII.") + parser.add_argument("-f", "--offset", dest=3D'Offset', type=3DValidate= UnsignedInteger, + help=3D"VPD offset if --type is VPD. UEFI Variabl= e offset if --type is HII. Must be 8-byte aligned.") + parser.add_argument("-n", "--variable-name", dest=3D'VariableName', + help=3D"UEFI variable name. Only used with --type= HII.") + parser.add_argument("-g", "--variable-guid", type=3DValidateGuidName, = dest=3D'VariableGuid', + help=3D"UEFI variable GUID C name. Only used with= --type HII.") + parser.add_argument("-x", "--xdr", dest=3D'Xdr', action=3D"store_true", + help=3D"Encode PCD using the Variable-Length Opaqu= e Data format of RFC 4506 External Data Representation Standard (XDR)") + parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"sto= re_true", + help=3D"Increase output messages") + parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_t= rue", + help=3D"Reduce output messages") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'= [0-9]', choices=3Drange(0, 10), default=3D0, + help=3D"Set debug level") =20 # # Parse command line arguments # - args =3D parser.parse_args () + args =3D parser.parse_args() =20 # # Read all binary input files @@ -108,17 +112,18 @@ if __name__ =3D=3D '__main__': Buffer =3D [] for File in args.InputFile: try: - Buffer.append (File.read ()) - File.close () + Buffer.append(File.read()) + File.close() except: - print ('BinToPcd: error: can not read binary input file {File}= '.format (File =3D File)) - sys.exit (1) + print( + 'BinToPcd: error: can not read binary input file {File}'.f= ormat(File=3DFile)) + sys.exit(1) =20 # # Convert PCD to an encoded string of hex values and determine the siz= e of # the encoded PCD in bytes. # - PcdValue, PcdSize =3D ByteArray (Buffer, args.Xdr) + PcdValue, PcdSize =3D ByteArray(Buffer, args.Xdr) =20 # # Convert binary buffer to a DSC file PCD statement @@ -129,7 +134,7 @@ if __name__ =3D=3D '__main__': # Pcd =3D PcdValue if args.Verbose: - print ('BinToPcd: Convert binary file to PCD Value') + print('BinToPcd: Convert binary file to PCD Value') elif args.PcdType is None: # # If --type is neither VPD nor HII, then use PCD statement syntax = that is @@ -141,19 +146,21 @@ if __name__ =3D=3D '__main__': # If --max-size is not provided, then do not generate the synt= ax that # includes the maximum size. # - Pcd =3D ' {Name}|{Value}'.format (Name =3D args.PcdName, Valu= e =3D PcdValue) + Pcd =3D ' {Name}|{Value}'.format(Name=3Dargs.PcdName, Value= =3DPcdValue) elif args.MaxSize < PcdSize: - print ('BinToPcd: error: argument --max-size is smaller than i= nput file.') - sys.exit (1) + print('BinToPcd: error: argument --max-size is smaller than in= put file.') + sys.exit(1) else: - Pcd =3D ' {Name}|{Value}|VOID*|{Size}'.format (Name =3D args.= PcdName, Value =3D PcdValue, Size =3D args.MaxSize) + Pcd =3D ' {Name}|{Value}|VOID*|{Size}'.format( + Name=3Dargs.PcdName, Value=3DPcdValue, Size=3Dargs.MaxSize) =20 if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections:') - print (' [PcdsFixedAtBuild]') - print (' [PcdsPatchableInModule]') - print (' [PcdsDynamicDefault]') - print (' [PcdsDynamicExDefault]') + print( + 'BinToPcd: Convert binary file to PCD statement compatible= with PCD sections:') + print(' [PcdsFixedAtBuild]') + print(' [PcdsPatchableInModule]') + print(' [PcdsDynamicDefault]') + print(' [PcdsDynamicExDefault]') elif args.PcdType =3D=3D 'VPD': if args.MaxSize is None: # @@ -162,33 +169,37 @@ if __name__ =3D=3D '__main__': # args.MaxSize =3D PcdSize if args.MaxSize < PcdSize: - print ('BinToPcd: error: argument --max-size is smaller than i= nput file.') - sys.exit (1) + print('BinToPcd: error: argument --max-size is smaller than in= put file.') + sys.exit(1) if args.Offset is None: # # if --offset is not provided, then set offset field to '*' so= build # tools will compute offset of PCD in VPD region. # - Pcd =3D ' {Name}|*|{Size}|{Value}'.format (Name =3D args.PcdN= ame, Size =3D args.MaxSize, Value =3D PcdValue) + Pcd =3D ' {Name}|*|{Size}|{Value}'.format( + Name=3Dargs.PcdName, Size=3Dargs.MaxSize, Value=3DPcdValue) else: # # --offset value must be 8-byte aligned # if (args.Offset % 8) !=3D 0: - print ('BinToPcd: error: argument --offset must be 8-byte = aligned.') - sys.exit (1) + print('BinToPcd: error: argument --offset must be 8-byte a= ligned.') + sys.exit(1) # # Use the --offset value provided. # - Pcd =3D ' {Name}|{Offset}|{Size}|{Value}'.format (Name =3D ar= gs.PcdName, Offset =3D args.Offset, Size =3D args.MaxSize, Value =3D PcdVal= ue) + Pcd =3D ' {Name}|{Offset}|{Size}|{Value}'.format( + Name=3Dargs.PcdName, Offset=3Dargs.Offset, Size=3Dargs.Max= Size, Value=3DPcdValue) if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections') - print (' [PcdsDynamicVpd]') - print (' [PcdsDynamicExVpd]') + print( + 'BinToPcd: Convert binary file to PCD statement compatible= with PCD sections') + print(' [PcdsDynamicVpd]') + print(' [PcdsDynamicExVpd]') elif args.PcdType =3D=3D 'HII': if args.VariableGuid is None or args.VariableName is None: - print ('BinToPcd: error: arguments --variable-guid and --varia= ble-name are required for --type HII.') - sys.exit (1) + print( + 'BinToPcd: error: arguments --variable-guid and --variable= -name are required for --type HII.') + sys.exit(1) if args.Offset is None: # # Use UEFI Variable offset of 0 if --offset is not provided @@ -198,23 +209,25 @@ if __name__ =3D=3D '__main__': # --offset value must be 8-byte aligned # if (args.Offset % 8) !=3D 0: - print ('BinToPcd: error: argument --offset must be 8-byte alig= ned.') - sys.exit (1) - Pcd =3D ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format = (Name =3D args.PcdName, VarName =3D args.VariableName, VarGuid =3D args.Var= iableGuid, Offset =3D args.Offset, Value =3D PcdValue) + print('BinToPcd: error: argument --offset must be 8-byte align= ed.') + sys.exit(1) + Pcd =3D ' {Name}|L"{VarName}"|{VarGuid}|{Offset}|{Value}'.format( + Name=3Dargs.PcdName, VarName=3Dargs.VariableName, VarGuid=3Dar= gs.VariableGuid, Offset=3Dargs.Offset, Value=3DPcdValue) if args.Verbose: - print ('BinToPcd: Convert binary file to PCD statement compati= ble with PCD sections') - print (' [PcdsDynamicHii]') - print (' [PcdsDynamicExHii]') + print( + 'BinToPcd: Convert binary file to PCD statement compatible= with PCD sections') + print(' [PcdsDynamicHii]') + print(' [PcdsDynamicExHii]') =20 # # Write PCD value or PCD statement to the output file # try: - args.OutputFile.write (Pcd) - args.OutputFile.close () + args.OutputFile.write(Pcd) + args.OutputFile.close() except: # # If output file is not specified or it can not be written, then w= rite the # PCD value or PCD statement to the console # - print (Pcd) + print(Pcd) diff --git a/BaseTools/Scripts/ConvertFceToStructurePcd.py b/BaseTools/Scri= pts/ConvertFceToStructurePcd.py index 9e7fe58768b1..066ddccbc245 100644 --- a/BaseTools/Scripts/ConvertFceToStructurePcd.py +++ b/BaseTools/Scripts/ConvertFceToStructurePcd.py @@ -1,5 +1,5 @@ #!/usr/bin/python -## @file +# @file # Firmware Configuration Editor (FCE) from https://firmware.intel.com/deve= lop # can parse BIOS image and generate Firmware Configuration file. # This script bases on Firmware Configuration file, and generate the struc= ture @@ -21,13 +21,13 @@ import argparse # # Globals for help information # -__prog__ =3D 'ConvertFceToStructurePcd' -__version__ =3D '%s Version %s' % (__prog__, '0.1 ') -__copyright__ =3D 'Copyright (c) 2018, Intel Corporation. All rights res= erved.' +__prog__ =3D 'ConvertFceToStructurePcd' +__version__ =3D '%s Version %s' % (__prog__, '0.1 ') +__copyright__ =3D 'Copyright (c) 2018, Intel Corporation. All rights reser= ved.' __description__ =3D 'Generate Structure PCD in DEC/DSC/INF based on Firmwa= re Configuration.\n' =20 =20 -dscstatement=3D'''[Defines] +dscstatement =3D '''[Defines] VPD_TOOL_GUID =3D 8C3D856A-9BE6-468E-850A-24F7A8D38E08 =20 [SkuIds] @@ -50,693 +50,747 @@ decstatement =3D '''[Guids] infstatement =3D '''[Pcd] ''' =20 -SECTION=3D'PcdsDynamicHii' -PCD_NAME=3D'gStructPcdTokenSpaceGuid.Pcd' +SECTION =3D 'PcdsDynamicHii' +PCD_NAME =3D 'gStructPcdTokenSpaceGuid.Pcd' Max_Pcd_Len =3D 100 =20 -WARNING=3D[] -ERRORMSG=3D[] +WARNING =3D [] +ERRORMSG =3D [] + =20 class parser_lst(object): =20 - def __init__(self,filelist): - self._ignore=3D['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64'] - self.file=3Dfilelist - self.text=3Dself.megre_lst()[0] - self.content=3Dself.megre_lst()[1] + def __init__(self, filelist): + self._ignore =3D ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64'] + self.file =3D filelist + self.text =3D self.megre_lst()[0] + self.content =3D self.megre_lst()[1] =20 - def megre_lst(self): - alltext=3D'' - content=3D{} - for file in self.file: - with open(file,'r') as f: - read =3Df.read() - alltext +=3D read - content[file]=3Dread - return alltext,content + def megre_lst(self): + alltext =3D '' + content =3D {} + for file in self.file: + with open(file, 'r') as f: + read =3D f.read() + alltext +=3D read + content[file] =3D read + return alltext, content =20 - def struct_lst(self):#{struct:lst file} - structs_file=3D{} - name_format =3D re.compile(r'(?') - name_format =3D re.compile(r'(?') + name_format =3D re.compile(r'(? each or each > "\x7E": - if bytes(each, 'utf-16') =3D=3D b'\xff\xfe\xae\x00': - each =3D '(R)' - else: - each =3D "" - comment +=3D each - line=3Dvalue_re.sub('',line) #delete \\... in "Q...." line - list1=3Dline.split(' ') - value=3Dself.value_parser(list1) - offset =3D offset_re.findall(x.replace(' ','')) - name =3D name_re.findall(x.replace(' ','')) - guid =3D guid_re.findall(x.replace(' ','')) - attribute =3Dattribute_re.findall(x.replace(' ','')) - if offset and name and guid and value and attribute: - if attribute[0] in ['0x3','0x7']: - offset =3D int(offset[0], 16) - #help =3D help_re.findall(x) - text_without_comment =3D offset, name[0], guid[0], value, attr= ibute[0] - if text_without_comment in part_without_comment: - # check if exists same Pcd with different comments, add di= fferent comments in one line with "|". - dupl_index =3D part_without_comment.index(text_without_com= ment) - part[dupl_index] =3D list(part[dupl_index]) - if comment not in part[dupl_index][-1]: - part[dupl_index][-1] +=3D " | " + comment - part[dupl_index] =3D tuple(part[dupl_index]) + def section_parser(self, section): + offset_re =3D re.compile(r'offset=3D(\w+)') + name_re =3D re.compile(r'name=3D(\S+)') + guid_re =3D re.compile(r'guid=3D(\S+)') + # help_re =3D re.compile(r'help =3D (.*)') + attribute_re =3D re.compile(r'attribute=3D(\w+)') + value_re =3D re.compile(r'(//.*)') + part =3D [] + part_without_comment =3D [] + for x in section[1:]: + line =3D x.split('\n')[0] + # the string \\... in "Q...." line + comment_list =3D value_re.findall(line) + comment_list[0] =3D comment_list[0].replace('//', '') + comment_ori =3D comment_list[0].strip() + comment =3D "" + for each in comment_ori: + if each !=3D " " and "\x21" > each or each > "\x7E": + if bytes(each, 'utf-16') =3D=3D b'\xff\xfe\xae\x00': + each =3D '(R)' + else: + each =3D "" + comment +=3D each + line =3D value_re.sub('', line) # delete \\... in "Q...." line + list1 =3D line.split(' ') + value =3D self.value_parser(list1) + offset =3D offset_re.findall(x.replace(' ', '')) + name =3D name_re.findall(x.replace(' ', '')) + guid =3D guid_re.findall(x.replace(' ', '')) + attribute =3D attribute_re.findall(x.replace(' ', '')) + if offset and name and guid and value and attribute: + if attribute[0] in ['0x3', '0x7']: + offset =3D int(offset[0], 16) + #help =3D help_re.findall(x) + text_without_comment =3D offset, name[0], guid[0], val= ue, attribute[0] + if text_without_comment in part_without_comment: + # check if exists same Pcd with different comments= , add different comments in one line with "|". + dupl_index =3D part_without_comment.index( + text_without_comment) + part[dupl_index] =3D list(part[dupl_index]) + if comment not in part[dupl_index][-1]: + part[dupl_index][-1] +=3D " | " + comment + part[dupl_index] =3D tuple(part[dupl_index]) + else: + text =3D offset, name[0], guid[0], value, attribut= e[0], comment + part_without_comment.append(text_without_comment) + part.append(text) + return(part) + + def value_parser(self, list1): + list1 =3D [t for t in list1 if t !=3D ''] # remove '' form list + first_num =3D int(list1[0], 16) + if list1[first_num + 1] =3D=3D 'STRING': # parser STRING + if list1[-1] =3D=3D '""': + value =3D "{0x0, 0x0}" else: - text =3D offset, name[0], guid[0], value, attribute[0], co= mment - part_without_comment.append(text_without_comment) - part.append(text) - return(part) - - def value_parser(self, list1): - list1 =3D [t for t in list1 if t !=3D ''] # remove '' form list - first_num =3D int(list1[0], 16) - if list1[first_num + 1] =3D=3D 'STRING': # parser STRING - if list1[-1] =3D=3D '""': - value =3D "{0x0, 0x0}" - else: - value =3D 'L%s' % list1[-1] - elif list1[first_num + 1] =3D=3D 'ORDERED_LIST': # parser ORDERED_LIST - value_total =3D int(list1[first_num + 2]) - list2 =3D list1[-value_total:] - tmp =3D [] - line =3D '' - for i in list2: - if len(i) % 2 =3D=3D 0 and len(i) !=3D 2: - for m in range(0, len(i) // 2): - tmp.append('0x%02x' % (int('0x%s' % i, 16) >> m * 8 & 0xff)) + value =3D 'L%s' % list1[-1] + elif list1[first_num + 1] =3D=3D 'ORDERED_LIST': # parser ORDERED= _LIST + value_total =3D int(list1[first_num + 2]) + list2 =3D list1[-value_total:] + tmp =3D [] + line =3D '' + for i in list2: + if len(i) % 2 =3D=3D 0 and len(i) !=3D 2: + for m in range(0, len(i) // 2): + tmp.append('0x%02x' % + (int('0x%s' % i, 16) >> m * 8 & 0xff)) + else: + tmp.append('0x%s' % i) + for i in tmp: + line +=3D '%s,' % i + value =3D '{%s}' % line[:-1] else: - tmp.append('0x%s' % i) - for i in tmp: - line +=3D '%s,' % i - value =3D '{%s}' % line[:-1] - else: - value =3D "0x%01x" % int(list1[-1], 16) - return value + value =3D "0x%01x" % int(list1[-1], 16) + return value =20 =20 -#parser Guid file, get guid name form guid value +# parser Guid file, get guid name form guid value class GUID(object): =20 - def __init__(self,path): - self.path =3D path - self.guidfile =3D self.gfile() - self.guiddict =3D self.guid_dict() + def __init__(self, path): + self.path =3D path + self.guidfile =3D self.gfile() + self.guiddict =3D self.guid_dict() =20 - def gfile(self): - for root, dir, file in os.walk(self.path, topdown=3DTrue, followlinks= =3DFalse): - if 'FV' in dir: - gfile =3D os.path.join(root,'Fv','Guid.xref') - if os.path.isfile(gfile): - return gfile + def gfile(self): + for root, dir, file in os.walk(self.path, topdown=3DTrue, followli= nks=3DFalse): + if 'FV' in dir: + gfile =3D os.path.join(root, 'Fv', 'Guid.xref') + if os.path.isfile(gfile): + return gfile + else: + print("ERROR: Guid.xref file not found") + ERRORMSG.append("ERROR: Guid.xref file not found") + exit() + + def guid_dict(self): + guiddict =3D {} + with open(self.guidfile, 'r') as file: + lines =3D file.readlines() + guidinfo =3D lines + for line in guidinfo: + list =3D line.strip().split(' ') + if list: + if len(list) > 1: + guiddict[list[0].upper()] =3D list[1] + elif list[0] !=3D '' and len(list) =3D=3D 1: + print("Error: line %s can't be parser in %s" % + (line.strip(), self.guidfile)) + ERRORMSG.append("Error: line %s can't be parser in %s"= % ( + line.strip(), self.guidfile)) + else: + print("ERROR: No data in %s" % self.guidfile) + ERRORMSG.append("ERROR: No data in %s" % self.guidfile) + return guiddict + + def guid_parser(self, guid): + if guid.upper() in self.guiddict: + return self.guiddict[guid.upper()] else: - print("ERROR: Guid.xref file not found") - ERRORMSG.append("ERROR: Guid.xref file not found") - exit() + print("ERROR: GUID %s not found in file %s" % + (guid, self.guidfile)) + ERRORMSG.append("ERROR: GUID %s not found in file %s" % + (guid, self.guidfile)) + return guid =20 - def guid_dict(self): - guiddict=3D{} - with open(self.guidfile,'r') as file: - lines =3D file.readlines() - guidinfo=3Dlines - for line in guidinfo: - list=3Dline.strip().split(' ') - if list: - if len(list)>1: - guiddict[list[0].upper()]=3Dlist[1] - elif list[0] !=3D ''and len(list)=3D=3D1: - print("Error: line %s can't be parser in %s"%(line.strip(),self.= guidfile)) - ERRORMSG.append("Error: line %s can't be parser in %s"%(line.str= ip(),self.guidfile)) - else: - print("ERROR: No data in %s" %self.guidfile) - ERRORMSG.append("ERROR: No data in %s" %self.guidfile) - return guiddict - - def guid_parser(self,guid): - if guid.upper() in self.guiddict: - return self.guiddict[guid.upper()] - else: - print("ERROR: GUID %s not found in file %s"%(guid, self.guidfile)) - ERRORMSG.append("ERROR: GUID %s not found in file %s"%(guid, self.gu= idfile)) - return guid =20 class PATH(object): =20 - def __init__(self,path): - self.path=3Dpath - self.rootdir=3Dself.get_root_dir() - self.usefuldir=3Dset() - self.lstinf =3D {} - for path in self.rootdir: - for o_root, o_dir, o_file in os.walk(os.path.join(path, "OUTPUT"), t= opdown=3DTrue, followlinks=3DFalse): - for INF in o_file: - if os.path.splitext(INF)[1] =3D=3D '.inf': - for l_root, l_dir, l_file in os.walk(os.path.join(path, "DEBUG= "), topdown=3DTrue, - followlinks=3DFalse): - for LST in l_file: - if os.path.splitext(LST)[1] =3D=3D '.lst': - self.lstinf[os.path.join(l_root, LST)] =3D os.path.join(= o_root, INF) - self.usefuldir.add(path) + def __init__(self, path): + self.path =3D path + self.rootdir =3D self.get_root_dir() + self.usefuldir =3D set() + self.lstinf =3D {} + for path in self.rootdir: + for o_root, o_dir, o_file in os.walk(os.path.join(path, "OUTPU= T"), topdown=3DTrue, followlinks=3DFalse): + for INF in o_file: + if os.path.splitext(INF)[1] =3D=3D '.inf': + for l_root, l_dir, l_file in os.walk(os.path.join(= path, "DEBUG"), topdown=3DTrue, + followlinks= =3DFalse): + for LST in l_file: + if os.path.splitext(LST)[1] =3D=3D '.lst': + self.lstinf[os.path.join(l_root, LST)]= =3D os.path.join( + o_root, INF) + self.usefuldir.add(path) =20 - def get_root_dir(self): - rootdir=3D[] - for root,dir,file in os.walk(self.path,topdown=3DTrue,followlinks=3DFa= lse): - if "OUTPUT" in root: - updir=3Droot.split("OUTPUT",1)[0] - rootdir.append(updir) - rootdir=3Dlist(set(rootdir)) - return rootdir + def get_root_dir(self): + rootdir =3D [] + for root, dir, file in os.walk(self.path, topdown=3DTrue, followli= nks=3DFalse): + if "OUTPUT" in root: + updir =3D root.split("OUTPUT", 1)[0] + rootdir.append(updir) + rootdir =3D list(set(rootdir)) + return rootdir =20 - def lst_inf(self): - return self.lstinf + def lst_inf(self): + return self.lstinf =20 - def package(self): - package=3D{} - package_re=3Dre.compile(r'Packages\.\w+]\n(.*)',re.S) - for i in list(self.lstinf.values()): - with open(i,'r') as inf: - read=3Dinf.read() - section=3Dread.split('[') - for j in section: - p=3Dpackage_re.findall(j) - if p: - package[i]=3Dp[0].rstrip() - return package + def package(self): + package =3D {} + package_re =3D re.compile(r'Packages\.\w+]\n(.*)', re.S) + for i in list(self.lstinf.values()): + with open(i, 'r') as inf: + read =3D inf.read() + section =3D read.split('[') + for j in section: + p =3D package_re.findall(j) + if p: + package[i] =3D p[0].rstrip() + return package =20 - def header(self,struct): - header=3D{} - head_re =3D re.compile('typedef.*} %s;[\n]+(.*)(?:typedef|formset)'%st= ruct,re.M|re.S) - head_re2 =3D re.compile(r'#line[\s\d]+"(\S+h)"') - for i in list(self.lstinf.keys()): - with open(i,'r') as lst: - read =3D lst.read() - h =3D head_re.findall(read) - if h: - head=3Dhead_re2.findall(h[0]) - if head: - format =3D head[0].replace('\\\\','/').replace('\\','/') - name =3Dformat.split('/')[-1] - head =3D self.headerfileset.get(name) - if head: - head =3D head.replace('\\','/') - header[struct] =3D head - return header - @property - def headerfileset(self): - headerset =3D dict() - for root,dirs,files in os.walk(self.path): - for file in files: - if os.path.basename(file) =3D=3D 'deps.txt': - with open(os.path.join(root,file),"r") as fr: - for line in fr.readlines(): - headerset[os.path.basename(line).strip()] =3D line.strip() - return headerset + def header(self, struct): + header =3D {} + head_re =3D re.compile( + 'typedef.*} %s;[\n]+(.*)(?:typedef|formset)' % struct, re.M | = re.S) + head_re2 =3D re.compile(r'#line[\s\d]+"(\S+h)"') + for i in list(self.lstinf.keys()): + with open(i, 'r') as lst: + read =3D lst.read() + h =3D head_re.findall(read) + if h: + head =3D head_re2.findall(h[0]) + if head: + format =3D head[0].replace('\\\\', '/').replace('\\', = '/') + name =3D format.split('/')[-1] + head =3D self.headerfileset.get(name) + if head: + head =3D head.replace('\\', '/') + header[struct] =3D head + return header + + @property + def headerfileset(self): + headerset =3D dict() + for root, dirs, files in os.walk(self.path): + for file in files: + if os.path.basename(file) =3D=3D 'deps.txt': + with open(os.path.join(root, file), "r") as fr: + for line in fr.readlines(): + headerset[os.path.basename( + line).strip()] =3D line.strip() + return headerset + + def makefile(self, filename): + re_format =3D re.compile(r'DEBUG_DIR.*(?:\S+Pkg)\\(.*\\%s)' % file= name) + for i in self.usefuldir: + with open(os.path.join(i, 'Makefile'), 'r') as make: + read =3D make.read() + dir =3D re_format.findall(read) + if dir: + return dir[0] + return None =20 - def makefile(self,filename): - re_format =3D re.compile(r'DEBUG_DIR.*(?:\S+Pkg)\\(.*\\%s)'%filename) - for i in self.usefuldir: - with open(os.path.join(i,'Makefile'),'r') as make: - read =3D make.read() - dir =3D re_format.findall(read) - if dir: - return dir[0] - return None =20 class mainprocess(object): =20 - def __init__(self,InputPath,Config,OutputPath): - self.init =3D 0xFCD00000 - self.inputpath =3D os.path.abspath(InputPath) - self.outputpath =3D os.path.abspath(OutputPath) - self.LST =3D PATH(self.inputpath) - self.lst_dict =3D self.LST.lst_inf() - self.Config =3D Config - self.attribute_dict =3D {'0x3': 'NV, BS', '0x7': 'NV, BS, RT'} - self.guid =3D GUID(self.inputpath) - self.header=3D{} + def __init__(self, InputPath, Config, OutputPath): + self.init =3D 0xFCD00000 + self.inputpath =3D os.path.abspath(InputPath) + self.outputpath =3D os.path.abspath(OutputPath) + self.LST =3D PATH(self.inputpath) + self.lst_dict =3D self.LST.lst_inf() + self.Config =3D Config + self.attribute_dict =3D {'0x3': 'NV, BS', '0x7': 'NV, BS, RT'} + self.guid =3D GUID(self.inputpath) + self.header =3D {} =20 - def main(self): - conf=3DConfig(self.Config) - config_dict=3Dconf.config_parser() #get {'0_0':[offset,name,guid,value= ,attribute]...,'1_0':....} - lst=3Dparser_lst(list(self.lst_dict.keys())) - efi_dict=3Dlst.efivarstore_parser() #get {name:struct} form lst file - keys=3Dsorted(config_dict.keys()) - all_struct=3Dlst.struct() - stru_lst=3Dlst.struct_lst() - title_list=3D[] - info_list=3D[] - header_list=3D[] - inf_list =3D[] - for i in stru_lst: - tmp =3D self.LST.header(i) - self.header.update(tmp) - for id_key in keys: - tmp_id=3D[id_key] #['0_0',[(struct,[name...]),(struct,[name...])]] - tmp_info=3D{} #{name:struct} - for section in config_dict[id_key]: - c_offset,c_name,c_guid,c_value,c_attribute,c_comment =3D section - if c_name in efi_dict: - struct =3D efi_dict[c_name] - title=3D'%s%s|L"%s"|%s|0x00||%s\n'%(PCD_NAME,c_name,c_name,self.= guid.guid_parser(c_guid),self.attribute_dict[c_attribute]) - if struct in all_struct: - lstfile =3D stru_lst[struct] - struct_dict=3Dall_struct[struct] - try: - title2 =3D '%s%s|{0}|%s|0xFCD00000{\n \n %s\n = \n%s\n}\n' % (PCD_NAME, c_name, struct, self.header[struct], self= .LST.package()[self.lst_dict[lstfile]]) - except KeyError: - WARNING.append("Warning: No for struct %s"%str= uct) - title2 =3D '%s%s|{0}|%s|0xFCD00000{\n \n %s\n = \n%s\n}\n' % (PCD_NAME, c_name, struct, '', self.LST.package()[se= lf.lst_dict[lstfile]]) - header_list.append(title2) - elif struct not in lst._ignore: - struct_dict =3D{} - print("ERROR: Struct %s can't found in lst file" %struct) - ERRORMSG.append("ERROR: Struct %s can't found in lst file" %st= ruct) - if c_offset in struct_dict: - offset_name=3Dstruct_dict[c_offset] - info =3D "%s%s.%s|%s\n"%(PCD_NAME,c_name,offset_name,c_value) - blank_length =3D Max_Pcd_Len - len(info) - if blank_length <=3D 0: - info_comment =3D "%s%s.%s|%s%s# %s\n"%(PCD_NAME,c_name,off= set_name,c_value," ",c_comment) - else: - info_comment =3D "%s%s.%s|%s%s# %s\n"%(PCD_NAME,c_name,off= set_name,c_value,blank_length*" ",c_comment) - inf =3D "%s%s\n"%(PCD_NAME,c_name) - inf_list.append(inf) - tmp_info[info_comment]=3Dtitle - else: - print("ERROR: Can't find offset %s with struct name %s"%(c_off= set,struct)) - ERRORMSG.append("ERROR: Can't find offset %s with name %s"%(c_= offset,struct)) + def main(self): + conf =3D Config(self.Config) + # get {'0_0':[offset,name,guid,value,attribute]...,'1_0':....} + config_dict =3D conf.config_parser() + lst =3D parser_lst(list(self.lst_dict.keys())) + efi_dict =3D lst.efivarstore_parser() # get {name:struct} form ls= t file + keys =3D sorted(config_dict.keys()) + all_struct =3D lst.struct() + stru_lst =3D lst.struct_lst() + title_list =3D [] + info_list =3D [] + header_list =3D [] + inf_list =3D [] + for i in stru_lst: + tmp =3D self.LST.header(i) + self.header.update(tmp) + for id_key in keys: + # ['0_0',[(struct,[name...]),(struct,[name...])]] + tmp_id =3D [id_key] + tmp_info =3D {} # {name:struct} + for section in config_dict[id_key]: + c_offset, c_name, c_guid, c_value, c_attribute, c_comment = =3D section + if c_name in efi_dict: + struct =3D efi_dict[c_name] + title =3D '%s%s|L"%s"|%s|0x00||%s\n' % (PCD_NAME, c_na= me, c_name, self.guid.guid_parser( + c_guid), self.attribute_dict[c_attribute]) + if struct in all_struct: + lstfile =3D stru_lst[struct] + struct_dict =3D all_struct[struct] + try: + title2 =3D '%s%s|{0}|%s|0xFCD00000{\n \n %s\n \n%s\n}\n' % ( + PCD_NAME, c_name, struct, self.header[stru= ct], self.LST.package()[self.lst_dict[lstfile]]) + except KeyError: + WARNING.append( + "Warning: No for struct %s" = % struct) + title2 =3D '%s%s|{0}|%s|0xFCD00000{\n \n %s\n \n%s\n}\n' % ( + PCD_NAME, c_name, struct, '', self.LST.pac= kage()[self.lst_dict[lstfile]]) + header_list.append(title2) + elif struct not in lst._ignore: + struct_dict =3D {} + print("ERROR: Struct %s can't found in lst file" %= struct) + ERRORMSG.append( + "ERROR: Struct %s can't found in lst file" % s= truct) + if c_offset in struct_dict: + offset_name =3D struct_dict[c_offset] + info =3D "%s%s.%s|%s\n" % ( + PCD_NAME, c_name, offset_name, c_value) + blank_length =3D Max_Pcd_Len - len(info) + if blank_length <=3D 0: + info_comment =3D "%s%s.%s|%s%s# %s\n" % ( + PCD_NAME, c_name, offset_name, c_value, " = ", c_comment) + else: + info_comment =3D "%s%s.%s|%s%s# %s\n" % ( + PCD_NAME, c_name, offset_name, c_value, bl= ank_length*" ", c_comment) + inf =3D "%s%s\n" % (PCD_NAME, c_name) + inf_list.append(inf) + tmp_info[info_comment] =3D title + else: + print("ERROR: Can't find offset %s with struct nam= e %s" % ( + c_offset, struct)) + ERRORMSG.append( + "ERROR: Can't find offset %s with name %s" % (= c_offset, struct)) + else: + print("ERROR: Can't find name %s in lst file" % (c_nam= e)) + ERRORMSG.append( + "ERROR: Can't find name %s in lst file" % (c_name)) + tmp_id.append(list(self.reverse_dict(tmp_info).items())) + id, tmp_title_list, tmp_info_list =3D self.read_list(tmp_id) + title_list +=3D tmp_title_list + info_list.append(tmp_info_list) + inf_list =3D self.del_repeat(inf_list) + header_list =3D self.plus(self.del_repeat(header_list)) + title_all =3D list(set(title_list)) + info_list =3D self.remove_bracket(self.del_repeat(info_list)) + for i in range(len(info_list)-1, -1, -1): + if len(info_list[i]) =3D=3D 0: + info_list.remove(info_list[i]) + for i in (inf_list, title_all, header_list): + i.sort() + return keys, title_all, info_list, header_list, inf_list + + def correct_sort(self, PcdString): + # sort the Pcd list with two rules: + # First sort through Pcd name; + # Second if the Pcd exists several elements, sort them through ind= ex value. + if ("]|") in PcdString: + Pcdname =3D PcdString.split("[")[0] + Pcdindex =3D int(PcdString.split("[")[1].split("]")[0]) else: - print("ERROR: Can't find name %s in lst file"%(c_name)) - ERRORMSG.append("ERROR: Can't find name %s in lst file"%(c_name)) - tmp_id.append(list(self.reverse_dict(tmp_info).items())) - id,tmp_title_list,tmp_info_list =3D self.read_list(tmp_id) - title_list +=3Dtmp_title_list - info_list.append(tmp_info_list) - inf_list =3D self.del_repeat(inf_list) - header_list =3D self.plus(self.del_repeat(header_list)) - title_all=3Dlist(set(title_list)) - info_list =3D self.remove_bracket(self.del_repeat(info_list)) - for i in range(len(info_list)-1,-1,-1): - if len(info_list[i]) =3D=3D 0: - info_list.remove(info_list[i]) - for i in (inf_list, title_all, header_list): - i.sort() - return keys,title_all,info_list,header_list,inf_list + Pcdname =3D PcdString.split("|")[0] + Pcdindex =3D 0 + return Pcdname, Pcdindex =20 - def correct_sort(self, PcdString): - # sort the Pcd list with two rules: - # First sort through Pcd name; - # Second if the Pcd exists several elements, sort them through index v= alue. - if ("]|") in PcdString: - Pcdname =3D PcdString.split("[")[0] - Pcdindex =3D int(PcdString.split("[")[1].split("]")[0]) - else: - Pcdname =3D PcdString.split("|")[0] - Pcdindex =3D 0 - return Pcdname, Pcdindex + def remove_bracket(self, List): + for i in List: + for j in i: + tmp =3D j.split("|") + if (('L"' in j) and ("[" in j)) or (tmp[1].split("#")[0].s= trip() =3D=3D '{0x0, 0x0}'): + tmp[0] =3D tmp[0][:tmp[0].index('[')] + List[List.index(i)][i.index(j)] =3D "|".join(tmp) + else: + List[List.index(i)][i.index(j)] =3D j + for i in List: + if type(i) =3D=3D type([0, 0]): + i.sort(key=3Dlambda x: (self.correct_sort( + x)[0], self.correct_sort(x)[1])) + return List =20 - def remove_bracket(self,List): - for i in List: - for j in i: - tmp =3D j.split("|") - if (('L"' in j) and ("[" in j)) or (tmp[1].split("#")[0].strip() = =3D=3D '{0x0, 0x0}'): - tmp[0] =3D tmp[0][:tmp[0].index('[')] - List[List.index(i)][i.index(j)] =3D "|".join(tmp) - else: - List[List.index(i)][i.index(j)] =3D j - for i in List: - if type(i) =3D=3D type([0,0]): - i.sort(key =3D lambda x:(self.correct_sort(x)[0], self.correct_sor= t(x)[1])) - return List + def write_all(self): + title_flag =3D 1 + info_flag =3D 1 + if not os.path.isdir(self.outputpath): + os.makedirs(self.outputpath) + decwrite =3D write2file(os.path.join( + self.outputpath, 'StructurePcd.dec')) + dscwrite =3D write2file(os.path.join( + self.outputpath, 'StructurePcd.dsc')) + infwrite =3D write2file(os.path.join( + self.outputpath, 'StructurePcd.inf')) + conf =3D Config(self.Config) + ids, title, info, header, inf =3D self.main() + decwrite.add2file(decstatement) + decwrite.add2file(header) + infwrite.add2file(infstatement) + infwrite.add2file(inf) + dscwrite.add2file(dscstatement) + for id in ids: + dscwrite.add2file(conf.eval_id(id)) + if title_flag: + dscwrite.add2file(title) + title_flag =3D 0 + if len(info) =3D=3D 1: + dscwrite.add2file(info) + elif len(info) =3D=3D 2: + if info_flag: + dscwrite.add2file(info[0]) + info_flag =3D 0 + else: + dscwrite.add2file(info[1]) =20 - def write_all(self): - title_flag=3D1 - info_flag=3D1 - if not os.path.isdir(self.outputpath): - os.makedirs(self.outputpath) - decwrite =3D write2file(os.path.join(self.outputpath,'StructurePcd.dec= ')) - dscwrite =3D write2file(os.path.join(self.outputpath,'StructurePcd.dsc= ')) - infwrite =3D write2file(os.path.join(self.outputpath, 'StructurePcd.in= f')) - conf =3D Config(self.Config) - ids,title,info,header,inf=3Dself.main() - decwrite.add2file(decstatement) - decwrite.add2file(header) - infwrite.add2file(infstatement) - infwrite.add2file(inf) - dscwrite.add2file(dscstatement) - for id in ids: - dscwrite.add2file(conf.eval_id(id)) - if title_flag: - dscwrite.add2file(title) - title_flag=3D0 - if len(info) =3D=3D 1: - dscwrite.add2file(info) - elif len(info) =3D=3D 2: - if info_flag: - dscwrite.add2file(info[0]) - info_flag =3D0 + def del_repeat(self, List): + if len(List) =3D=3D 1 or len(List) =3D=3D 0: + return List else: - dscwrite.add2file(info[1]) - - def del_repeat(self,List): - if len(List) =3D=3D 1 or len(List) =3D=3D 0: - return List - else: - if type(List[0]) !=3D type('xxx'): - alist=3D[] - for i in range(len(List)): - if i =3D=3D 0: - alist.append(List[0]) - else: - plist =3D [] - for j in range(i): - plist +=3D List[j] - alist.append(self.__del(list(set(plist)), List[i])) - return alist - else: - return list(set(List)) + if type(List[0]) !=3D type('xxx'): + alist =3D [] + for i in range(len(List)): + if i =3D=3D 0: + alist.append(List[0]) + else: + plist =3D [] + for j in range(i): + plist +=3D List[j] + alist.append(self.__del(list(set(plist)), List[i])) + return alist + else: + return list(set(List)) =20 + def __del(self, list1, list2): + return list(set(list2).difference(set(list1))) =20 - def __del(self,list1,list2): - return list(set(list2).difference(set(list1))) + def reverse_dict(self, dict): + data =3D {} + for i in list(dict.items()): + if i[1] not in list(data.keys()): + data[i[1]] =3D [i[0]] + else: + data[i[1]].append(i[0]) + return data =20 - def reverse_dict(self,dict): - data=3D{} - for i in list(dict.items()): - if i[1] not in list(data.keys()): - data[i[1]]=3D[i[0]] - else: - data[i[1]].append(i[0]) - return data + def read_list(self, list): + title_list =3D [] + info_list =3D [] + for i in list[1]: + title_list.append(i[0]) + for j in i[1]: + info_list.append(j) + return list[0], title_list, info_list =20 - def read_list(self,list): - title_list=3D[] - info_list=3D[] - for i in list[1]: - title_list.append(i[0]) - for j in i[1]: - info_list.append(j) - return list[0],title_list,info_list + def plus(self, list): + nums =3D [] + for i in list: + if type(i) !=3D type([0]): + self.init +=3D 1 + num =3D "0x%01x" % self.init + j =3D i.replace('0xFCD00000', num.upper()) + nums.append(j) + return nums =20 - def plus(self,list): - nums=3D[] - for i in list: - if type(i) !=3D type([0]): - self.init +=3D 1 - num =3D "0x%01x" % self.init - j=3Di.replace('0xFCD00000',num.upper()) - nums.append(j) - return nums =20 class write2file(object): =20 - def __init__(self,Output): - self.output=3DOutput - self.text=3D'' - if os.path.exists(self.output): - os.remove(self.output) + def __init__(self, Output): + self.output =3D Output + self.text =3D '' + if os.path.exists(self.output): + os.remove(self.output) =20 - def add2file(self,content): - self.text =3D '' - with open(self.output,'a+') as file: - file.write(self.__gen(content)) + def add2file(self, content): + self.text =3D '' + with open(self.output, 'a+') as file: + file.write(self.__gen(content)) =20 - def __gen(self,content): - if type(content) =3D=3D type(''): - return content - elif type(content) =3D=3D type([0,0])or type(content) =3D=3D type((0,0= )): - return self.__readlist(content) - elif type(content) =3D=3D type({0:0}): - return self.__readdict(content) + def __gen(self, content): + if type(content) =3D=3D type(''): + return content + elif type(content) =3D=3D type([0, 0]) or type(content) =3D=3D typ= e((0, 0)): + return self.__readlist(content) + elif type(content) =3D=3D type({0: 0}): + return self.__readdict(content) =20 - def __readlist(self,list): - for i in list: - if type(i) =3D=3D type([0,0])or type(i) =3D=3D type((0,0)): - self.__readlist(i) - elif type(i) =3D=3D type('') : - self.text +=3Di - return self.text + def __readlist(self, list): + for i in list: + if type(i) =3D=3D type([0, 0]) or type(i) =3D=3D type((0, 0)): + self.__readlist(i) + elif type(i) =3D=3D type(''): + self.text +=3D i + return self.text + + def __readdict(self, dict): + content =3D list(dict.items()) + return self.__readlist(content) =20 - def __readdict(self,dict): - content=3Dlist(dict.items()) - return self.__readlist(content) =20 def stamp(): - return datetime.datetime.now() + return datetime.datetime.now() =20 -def dtime(start,end,id=3DNone): - if id: - pass - print("%s time:%s" % (id,str(end - start))) - else: - print("Total time:%s" %str(end-start)[:-7]) + +def dtime(start, end, id=3DNone): + if id: + pass + print("%s time:%s" % (id, str(end - start))) + else: + print("Total time:%s" % str(end-start)[:-7]) =20 =20 def main(): - start =3D stamp() - parser =3D argparse.ArgumentParser(prog =3D __prog__, - description =3D __description__ + __cop= yright__, - conflict_handler =3D 'resolve') - parser.add_argument('-v', '--version', action =3D 'version',version =3D = __version__, help=3D"show program's version number and exit") - parser.add_argument('-p', '--path', metavar=3D'PATH', dest=3D'path', hel= p=3D"platform build output directory") - parser.add_argument('-c', '--config',metavar=3D'FILENAME', dest=3D'confi= g', help=3D"firmware configuration file") - parser.add_argument('-o', '--outputdir', metavar=3D'PATH', dest=3D'outpu= t', help=3D"output directoy") - options =3D parser.parse_args() - if options.config: - if options.path: - if options.output: - run =3D mainprocess(options.path, options.config, options.output) - print("Running...") - run.write_all() - if WARNING: - warning =3D list(set(WARNING)) - for j in warning: - print(j) - if ERRORMSG: - ERROR =3D list(set(ERRORMSG)) - with open("ERROR.log", 'w+') as error: - for i in ERROR: - error.write(i + '\n') - print("Some error find, error log in ERROR.log") - print('Finished, Output files in directory %s'%os.path.abspath(opt= ions.output)) - else: - print('Error command, no output path, use -h for help') + start =3D stamp() + parser =3D argparse.ArgumentParser(prog=3D__prog__, + description=3D__description__ + __cop= yright__, + conflict_handler=3D'resolve') + parser.add_argument('-v', '--version', action=3D'version', + version=3D__version__, help=3D"show program's vers= ion number and exit") + parser.add_argument('-p', '--path', metavar=3D'PATH', + dest=3D'path', help=3D"platform build output direc= tory") + parser.add_argument('-c', '--config', metavar=3D'FILENAME', + dest=3D'config', help=3D"firmware configuration fi= le") + parser.add_argument('-o', '--outputdir', metavar=3D'PATH', + dest=3D'output', help=3D"output directoy") + options =3D parser.parse_args() + if options.config: + if options.path: + if options.output: + run =3D mainprocess(options.path, options.config, options.= output) + print("Running...") + run.write_all() + if WARNING: + warning =3D list(set(WARNING)) + for j in warning: + print(j) + if ERRORMSG: + ERROR =3D list(set(ERRORMSG)) + with open("ERROR.log", 'w+') as error: + for i in ERROR: + error.write(i + '\n') + print("Some error find, error log in ERROR.log") + print('Finished, Output files in directory %s' % + os.path.abspath(options.output)) + else: + print('Error command, no output path, use -h for help') + else: + print('Error command, no build path input, use -h for help') else: - print('Error command, no build path input, use -h for help') - else: - print('Error command, no output file, use -h for help') - end =3D stamp() - dtime(start, end) + print('Error command, no output file, use -h for help') + end =3D stamp() + dtime(start, end) + =20 if __name__ =3D=3D '__main__': - main() + main() diff --git a/BaseTools/Scripts/ConvertMasmToNasm.py b/BaseTools/Scripts/Con= vertMasmToNasm.py index 0ef5a8badb94..c4439dd5c5bc 100755 --- a/BaseTools/Scripts/ConvertMasmToNasm.py +++ b/BaseTools/Scripts/ConvertMasmToNasm.py @@ -834,7 +834,8 @@ class ConvertInfFile(CommonUtils): reldst =3D self.RootRelative(dst) print('Unabled to convert', reldst) if unsupportedArchCount > 0 and not self.args.quiet: - print('Skipped', unsupportedArchCount, 'files based on archite= cture') + print('Skipped', unsupportedArchCount, + 'files based on architecture') =20 def UpdateInfAsmFile(self, dst, IgnoreMissingAsm=3DFalse): infPath =3D os.path.split(os.path.realpath(self.inf))[0] @@ -961,7 +962,8 @@ class ConvertInfFiles(CommonUtils): reldst =3D self.RootRelative(dst) print('Unabled to convert', reldst) if unsupportedArchCount > 0 and not self.args.quiet: - print('Skipped', unsupportedArchCount, 'files based on archite= cture') + print('Skipped', unsupportedArchCount, + 'files based on architecture') =20 =20 class ConvertDirectories(CommonUtils): @@ -1002,4 +1004,5 @@ class ConvertAsmApp(CommonUtils): elif not self.dirmode: ConvertAsmFile(src, dst, self) =20 + ConvertAsmApp() diff --git a/BaseTools/Scripts/ConvertUni.py b/BaseTools/Scripts/ConvertUni= .py index d87550b63132..c4980f1e1a6f 100755 --- a/BaseTools/Scripts/ConvertUni.py +++ b/BaseTools/Scripts/ConvertUni.py @@ -1,4 +1,4 @@ -## @file +# @file # Check a patch for various format issues # # Copyright (c) 2015, Intel Corporation. All rights reserved.
@@ -7,14 +7,14 @@ # =20 from __future__ import print_function +import sys +import os +import codecs +import argparse =20 VersionNumber =3D '0.1' __copyright__ =3D "Copyright (c) 2015, Intel Corporation All rights reser= ved." =20 -import argparse -import codecs -import os -import sys =20 class ConvertOneArg: """Converts utf-16 to utf-8 for one command line argument. @@ -82,7 +82,8 @@ class ConvertOneArg: f.write(new_content) f.close() =20 - print(source + ": converted, size", len(file_content), '=3D>', len= (new_content)) + print(source + ": converted, size", + len(file_content), '=3D>', len(new_content)) return True =20 =20 @@ -121,5 +122,6 @@ class ConvertUniApp: self.args =3D parser.parse_args() self.utf8 =3D not self.args.utf_16 =20 + if __name__ =3D=3D "__main__": sys.exit(ConvertUniApp().retval) diff --git a/BaseTools/Scripts/DetectNotUsedItem.py b/BaseTools/Scripts/Det= ectNotUsedItem.py index 61481fb9187c..807627d5e9fe 100644 --- a/BaseTools/Scripts/DetectNotUsedItem.py +++ b/BaseTools/Scripts/DetectNotUsedItem.py @@ -1,4 +1,4 @@ -## @file +# @file # Detect unreferenced PCD and GUID/Protocols/PPIs. # # Copyright (c) 2019, Intel Corporation. All rights reserved. @@ -73,7 +73,8 @@ class PROCESS(object): Comment_Line.append(Index) if NotComment: if content !=3D "\n" and content !=3D "\r\n": - ItemName[Index] =3D content.split('=3D')[0].sp= lit('|')[0].split('#')[0].strip() + ItemName[Index] =3D content.split('=3D')[0].sp= lit('|')[ + 0].split('#')[0].strip() Comments[Index] =3D Comment_Line Comment_Line =3D [] return ItemName, Comments @@ -103,7 +104,8 @@ class PROCESS(object): InfDscFdfContent =3D self.ParserDscFdfInfFile() for LineNum in list(DecItem.keys()): DecItemName =3D DecItem[LineNum] - Match_reg =3D re.compile("(? @@ -25,6 +25,7 @@ EXPRESSIONS =3D { 'webpage': re.compile(r'^W:\s*(?P.*?)\r*$') } =20 + def printsection(section): """Prints out the dictionary describing a Maintainers.txt section.""" print('=3D=3D=3D') @@ -33,6 +34,7 @@ def printsection(section): for item in section[key]: print(' %s' % item) =20 + def pattern_to_regex(pattern): """Takes a string containing regular UNIX path wildcards and returns a string suitable for matching with regex.""" @@ -49,6 +51,7 @@ def pattern_to_regex(pattern): =20 return pattern =20 + def path_in_section(path, section): """Returns True of False indicating whether the path is covered by the current section.""" @@ -72,6 +75,7 @@ def path_in_section(path, section): =20 return False =20 + def get_section_maintainers(path, section): """Returns a list with email addresses to any M: and R: entries matching the provided path in the provided section.""" @@ -82,7 +86,8 @@ def get_section_maintainers(path, section): if path_in_section(path, section): for status in section['status']: if status not in nowarn_status: - print('WARNING: Maintained status for "%s" is \'%s\'!' % (= path, status)) + print('WARNING: Maintained status for "%s" is \'%s\'!' % + (path, status)) for address in section['maintainer'], section['reviewer']: # Convert to list if necessary if isinstance(address, list): @@ -98,6 +103,7 @@ def get_section_maintainers(path, section): =20 return maintainers, lists =20 + def get_maintainers(path, sections, level=3D0): """For 'path', iterates over all sections, returning maintainers for matching ones.""" @@ -115,7 +121,8 @@ def get_maintainers(path, sections, level=3D0): # REPO.working_dir/ print('"%s": no maintainers found, looking for default' % path) if level =3D=3D 0: - maintainers =3D get_maintainers('', sections, level= =3Dlevel + 1) + maintainers =3D get_maintainers( + '', sections, level=3Dlevel + 1) else: print("No maintainers set for project.") if not maintainers: @@ -123,6 +130,7 @@ def get_maintainers(path, sections, level=3D0): =20 return maintainers + lists =20 + def parse_maintainers_line(line): """Parse one line of Maintainers.txt, returning any match group and it= s key.""" for key, expression in EXPRESSIONS.items(): @@ -131,6 +139,7 @@ def parse_maintainers_line(line): return key, match.group(key) return None, None =20 + def parse_maintainers_file(filename): """Parse the Maintainers.txt from top-level of repo and return a list containing dictionaries of all sections.""" @@ -153,11 +162,13 @@ def parse_maintainers_file(filename): =20 return sectionlist =20 + def get_modified_files(repo, args): """Returns a list of the files modified by the commit specified in 'ar= gs'.""" commit =3D repo.commit(args.commit) return commit.stats.files =20 + if __name__ =3D=3D '__main__': PARSER =3D argparse.ArgumentParser( description=3D'Retrieves information on who to cc for review on a = given commit') @@ -178,7 +189,7 @@ if __name__ =3D=3D '__main__': SECTIONS =3D parse_maintainers_file(CONFIG_FILE) =20 if ARGS.lookup: - FILES =3D [ARGS.lookup.replace('\\','/')] + FILES =3D [ARGS.lookup.replace('\\', '/')] else: FILES =3D get_modified_files(REPO, ARGS) =20 diff --git a/BaseTools/Scripts/GetUtcDateTime.py b/BaseTools/Scripts/GetUtc= DateTime.py index 3cfb6ac2ae77..8327854835c5 100644 --- a/BaseTools/Scripts/GetUtcDateTime.py +++ b/BaseTools/Scripts/GetUtcDateTime.py @@ -1,4 +1,4 @@ -## @file +# @file # Get current UTC date and time information and output as ascii code. # # Copyright (c) 2019, Intel Corporation. All rights reserved.
@@ -6,10 +6,11 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -VersionNumber =3D '0.1' -import sys -import datetime import argparse +import datetime +import sys +VersionNumber =3D '0.1' + =20 def Main(): PARSER =3D argparse.ArgumentParser( @@ -26,19 +27,20 @@ def Main(): =20 ARGS =3D PARSER.parse_args() if len(sys.argv) =3D=3D 1: - print ("ERROR: At least one argument is required!\n") + print("ERROR: At least one argument is required!\n") PARSER.print_help() =20 today =3D datetime.datetime.utcnow() if ARGS.year: ReversedNumber =3D str(today.year)[::-1] - print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNu= mber)) + print(''.join(hex(ord(HexString))[2:] for HexString in ReversedNum= ber)) if ARGS.date: ReversedNumber =3D str(today.strftime("%m%d"))[::-1] - print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNu= mber)) + print(''.join(hex(ord(HexString))[2:] for HexString in ReversedNum= ber)) if ARGS.time: ReversedNumber =3D str(today.strftime("%H%M"))[::-1] - print (''.join(hex(ord(HexString))[2:] for HexString in ReversedNu= mber)) + print(''.join(hex(ord(HexString))[2:] for HexString in ReversedNum= ber)) + =20 if __name__ =3D=3D '__main__': Main() diff --git a/BaseTools/Scripts/MemoryProfileSymbolGen.py b/BaseTools/Script= s/MemoryProfileSymbolGen.py index 69df2fb99b30..0a2ee3f20311 100644 --- a/BaseTools/Scripts/MemoryProfileSymbolGen.py +++ b/BaseTools/Scripts/MemoryProfileSymbolGen.py @@ -17,6 +17,7 @@ from optparse import OptionParser versionNumber =3D "1.1" __copyright__ =3D "Copyright (c) 2016 - 2018, Intel Corporation. All right= s reserved." =20 + class Symbols: def __init__(self): self.listLineAddress =3D [] @@ -26,36 +27,36 @@ class Symbols: # Cache for line self.sourceName =3D "" =20 - - def getSymbol (self, rva): + def getSymbol(self, rva): index =3D 0 - lineName =3D 0 + lineName =3D 0 sourceName =3D "??" - while index + 1 < self.lineCount : - if self.listLineAddress[index][0] <=3D rva and self.listLineAd= dress[index + 1][0] > rva : + while index + 1 < self.lineCount: + if self.listLineAddress[index][0] <=3D rva and self.listLineAd= dress[index + 1][0] > rva: offset =3D rva - self.listLineAddress[index][0] functionName =3D self.listLineAddress[index][1] lineName =3D self.listLineAddress[index][2] sourceName =3D self.listLineAddress[index][3] - if lineName =3D=3D 0 : - return " (" + self.listLineAddress[index][1] + "() - " += ")" - else : - return " (" + self.listLineAddress[index][1] + "() - " += sourceName + ":" + str(lineName) + ")" + if lineName =3D=3D 0: + return " (" + self.listLineAddress[index][1] + "() - "= + ")" + else: + return " (" + self.listLineAddress[index][1] + "() - "= + sourceName + ":" + str(lineName) + ")" index +=3D 1 =20 return " (unknown)" =20 def parse_debug_file(self, driverName, pdbName): - if cmp (pdbName, "") =3D=3D 0 : + if cmp(pdbName, "") =3D=3D 0: return - self.pdbName =3D pdbName; + self.pdbName =3D pdbName =20 try: nmCommand =3D "nm" nmLineOption =3D "-l" print("parsing (debug) - " + pdbName) - os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOp= tion, pdbName)) - except : + os.system('%s %s %s > nmDump.line.log' % + (nmCommand, nmLineOption, pdbName)) + except: print('ERROR: nm command not available. Please verify PATH') return =20 @@ -70,36 +71,38 @@ class Symbols: patchLineFileMatchString =3D "([0-9a-fA-F]*)\s+[T|D|t|d]\s+(\w+)\s= *((?:[a-zA-Z]:)?[\w+\-./_a-zA-Z0-9\\\\]*):?([0-9]*)" =20 for reportLine in reportLines: - #print "check - " + reportLine + # print "check - " + reportLine match =3D re.match(patchLineFileMatchString, reportLine) if match is not None: - #print "match - " + reportLine[:-1] - #print "0 - " + match.group(0) - #print "1 - " + match.group(1) - #print "2 - " + match.group(2) - #print "3 - " + match.group(3) - #print "4 - " + match.group(4) + # print "match - " + reportLine[:-1] + # print "0 - " + match.group(0) + # print "1 - " + match.group(1) + # print "2 - " + match.group(2) + # print "3 - " + match.group(3) + # print "4 - " + match.group(4) =20 - rva =3D int (match.group(1), 16) + rva =3D int(match.group(1), 16) functionName =3D match.group(2) sourceName =3D match.group(3) - if cmp (match.group(4), "") !=3D 0 : - lineName =3D int (match.group(4)) - else : + if cmp(match.group(4), "") !=3D 0: + lineName =3D int(match.group(4)) + else: lineName =3D 0 - self.listLineAddress.append ([rva, functionName, lineName,= sourceName]) + self.listLineAddress.append( + [rva, functionName, lineName, sourceName]) =20 - self.lineCount =3D len (self.listLineAddress) + self.lineCount =3D len(self.listLineAddress) =20 - self.listLineAddress =3D sorted(self.listLineAddress, key=3Dlambda= symbolAddress:symbolAddress[0]) + self.listLineAddress =3D sorted( + self.listLineAddress, key=3Dlambda symbolAddress: symbolAddres= s[0]) =20 - #for key in self.listLineAddress : - #print "rva - " + "%x"%(key[0]) + ", func - " + key[1] + ", li= ne - " + str(key[2]) + ", source - " + key[3] + # for key in self.listLineAddress : + # print "rva - " + "%x"%(key[0]) + ", func - " + key[1] + ", line = - " + str(key[2]) + ", source - " + key[3] =20 def parse_pdb_file(self, driverName, pdbName): - if cmp (pdbName, "") =3D=3D 0 : + if cmp(pdbName, "") =3D=3D 0: return - self.pdbName =3D pdbName; + self.pdbName =3D pdbName =20 try: #DIA2DumpCommand =3D "\"C:\\Program Files (x86)\Microsoft Visu= al Studio 14.0\\DIA SDK\\Samples\\DIA2Dump\\x64\\Debug\\Dia2Dump.exe\"" @@ -108,8 +111,9 @@ class Symbols: DIA2LinesOption =3D "-l" print("parsing (pdb) - " + pdbName) #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpComman= d, DIA2SymbolOption, pdbName)) - os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, = DIA2LinesOption, pdbName)) - except : + os.system('%s %s %s > DIA2Dump.line.log' % + (DIA2DumpCommand, DIA2LinesOption, pdbName)) + except: print('ERROR: DIA2Dump command not available. Please verify P= ATH') return =20 @@ -129,108 +133,120 @@ class Symbols: patchLineFileMatchStringFunc =3D "\*\*\s+(\w+)\s*" =20 for reportLine in reportLines: - #print "check line - " + reportLine + # print "check line - " + reportLine match =3D re.match(patchLineFileMatchString, reportLine) if match is not None: - #print "match - " + reportLine[:-1] - #print "0 - " + match.group(0) - #print "1 - " + match.group(1) - #print "2 - " + match.group(2) - if cmp (match.group(3), "") !=3D 0 : + # print "match - " + reportLine[:-1] + # print "0 - " + match.group(0) + # print "1 - " + match.group(1) + # print "2 - " + match.group(2) + if cmp(match.group(3), "") !=3D 0: self.sourceName =3D match.group(3) sourceName =3D self.sourceName functionName =3D self.functionName =20 - rva =3D int (match.group(2), 16) - lineName =3D int (match.group(1)) - self.listLineAddress.append ([rva, functionName, lineName,= sourceName]) - else : + rva =3D int(match.group(2), 16) + lineName =3D int(match.group(1)) + self.listLineAddress.append( + [rva, functionName, lineName, sourceName]) + else: match =3D re.match(patchLineFileMatchStringFunc, reportLin= e) if match is not None: self.functionName =3D match.group(1) =20 - self.lineCount =3D len (self.listLineAddress) - self.listLineAddress =3D sorted(self.listLineAddress, key=3Dlambda= symbolAddress:symbolAddress[0]) + self.lineCount =3D len(self.listLineAddress) + self.listLineAddress =3D sorted( + self.listLineAddress, key=3Dlambda symbolAddress: symbolAddres= s[0]) + + # for key in self.listLineAddress : + # print "rva - " + "%x"%(key[0]) + ", func - " + key[1] + ", line = - " + str(key[2]) + ", source - " + key[3] =20 - #for key in self.listLineAddress : - #print "rva - " + "%x"%(key[0]) + ", func - " + key[1] + ", li= ne - " + str(key[2]) + ", source - " + key[3] =20 class SymbolsFile: def __init__(self): self.symbolsTable =3D {} =20 + symbolsFile =3D "" =20 driverName =3D "" rvaName =3D "" symbolName =3D "" =20 + def getSymbolName(driverName, rva): global symbolsFile =20 - #print "driverName - " + driverName + # print "driverName - " + driverName =20 - try : + try: symbolList =3D symbolsFile.symbolsTable[driverName] if symbolList is not None: - return symbolList.getSymbol (rva) + return symbolList.getSymbol(rva) else: return " (???)" except Exception: return " (???)" =20 + def processLine(newline): global driverName global rvaName =20 driverPrefixLen =3D len("Driver - ") # get driver name - if cmp(newline[0:driverPrefixLen], "Driver - ") =3D=3D 0 : + if cmp(newline[0:driverPrefixLen], "Driver - ") =3D=3D 0: driverlineList =3D newline.split(" ") driverName =3D driverlineList[2] - #print "Checking : ", driverName + # print "Checking : ", driverName =20 # EDKII application output pdbMatchString =3D "Driver - \w* \(Usage - 0x[0-9a-fA-F]+\) \(Pdb = - ([:\-.\w\\\\/]*)\)\s*" pdbName =3D "" match =3D re.match(pdbMatchString, newline) if match is not None: - #print "match - " + newline - #print "0 - " + match.group(0) - #print "1 - " + match.group(1) + # print "match - " + newline + # print "0 - " + match.group(0) + # print "1 - " + match.group(1) pdbName =3D match.group(1) - #print "PDB - " + pdbName + # print "PDB - " + pdbName =20 symbolsFile.symbolsTable[driverName] =3D Symbols() =20 - if cmp (pdbName[-3:], "pdb") =3D=3D 0 : - symbolsFile.symbolsTable[driverName].parse_pdb_file (driverNam= e, pdbName) - else : - symbolsFile.symbolsTable[driverName].parse_debug_file (driverN= ame, pdbName) + if cmp(pdbName[-3:], "pdb") =3D=3D 0: + symbolsFile.symbolsTable[driverName].parse_pdb_file( + driverName, pdbName) + else: + symbolsFile.symbolsTable[driverName].parse_debug_file( + driverName, pdbName) =20 - elif cmp(newline, "") =3D=3D 0 : + elif cmp(newline, "") =3D=3D 0: driverName =3D "" =20 # check entry line - if newline.find ("<=3D=3D") !=3D -1 : + if newline.find("<=3D=3D") !=3D -1: entry_list =3D newline.split(" ") rvaName =3D entry_list[4] - #print "rva : ", rvaName - symbolName =3D getSymbolName (driverName, int(rvaName, 16)) - else : + # print "rva : ", rvaName + symbolName =3D getSymbolName(driverName, int(rvaName, 16)) + else: rvaName =3D "" symbolName =3D "" =20 - if cmp(rvaName, "") =3D=3D 0 : + if cmp(rvaName, "") =3D=3D 0: return newline - else : + else: return newline + symbolName =20 + def myOptionParser(): usage =3D "%prog [--version] [-h] [--help] [-i inputfile [-o outputfil= e]]" - Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, ve= rsion=3D"%prog " + str(versionNumber)) - Parser.add_option("-i", "--inputfile", dest=3D"inputfilename", type=3D= "string", help=3D"The input memory profile info file output from MemoryProf= ileInfo application in MdeModulePkg") - Parser.add_option("-o", "--outputfile", dest=3D"outputfilename", type= =3D"string", help=3D"The output memory profile info file with symbol, Memor= yProfileInfoSymbol.txt will be used if it is not specified") + Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, + version=3D"%prog " + str(versionNumber)) + Parser.add_option("-i", "--inputfile", dest=3D"inputfilename", type=3D= "string", + help=3D"The input memory profile info file output fr= om MemoryProfileInfo application in MdeModulePkg") + Parser.add_option("-o", "--outputfile", dest=3D"outputfilename", type= =3D"string", + help=3D"The output memory profile info file with sym= bol, MemoryProfileInfoSymbol.txt will be used if it is not specified") =20 (Options, args) =3D Parser.parse_args() if Options.inputfilename is None: @@ -239,6 +255,7 @@ def myOptionParser(): Options.outputfilename =3D "MemoryProfileInfoSymbol.txt" return Options =20 + def main(): global symbolsFile global Options @@ -246,12 +263,12 @@ def main(): =20 symbolsFile =3D SymbolsFile() =20 - try : + try: file =3D open(Options.inputfilename) except Exception: print("fail to open " + Options.inputfilename) return 1 - try : + try: newfile =3D open(Options.outputfilename, "w") except Exception: print("fail to open " + Options.outputfilename) @@ -272,5 +289,6 @@ def main(): file.close() newfile.close() =20 + if __name__ =3D=3D '__main__': sys.exit(main()) diff --git a/BaseTools/Scripts/PackageDocumentTools/__init__.py b/BaseTools= /Scripts/PackageDocumentTools/__init__.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/__init__.py +++ b/BaseTools/Scripts/PackageDocumentTools/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/Bas= eTools/Scripts/PackageDocumentTools/packagedoc_cli.py index eb3164a553fa..3e7b6742c155 100644 --- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py +++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py @@ -1,4 +1,4 @@ -## @file +# @file # This module provide command line entry for generating package document! # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
@@ -7,23 +7,29 @@ # =20 from __future__ import print_function -import os, sys, logging, traceback, subprocess +import os +import sys +import logging +import traceback +import subprocess from optparse import OptionParser =20 from plugins.EdkPlugins.edk2.model import baseobject from plugins.EdkPlugins.edk2.model import doxygengen =20 -gArchMarcoDict =3D {'ALL' : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE= _CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER', +gArchMarcoDict =3D {'ALL': 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_I= PF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER', 'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS', - 'IA32_GNU' : 'MDE_CPU_IA32 __GNUC__', - 'X64_MSFT' : 'MDE_CPU_X64 _MSC_EXTENSIONS ASM_PFX=3D OP= TIONAL=3D ', - 'X64_GNU' : 'MDE_CPU_X64 __GNUC__ ASM_PFX=3D OPTIONAL= =3D ', - 'IPF_MSFT' : 'MDE_CPU_IPF _MSC_EXTENSIONS ASM_PFX=3D OP= TIONAL=3D ', - 'IPF_GNU' : 'MDE_CPU_IPF __GNUC__ ASM_PFX=3D OPTIONAL= =3D ', + 'IA32_GNU': 'MDE_CPU_IA32 __GNUC__', + 'X64_MSFT': 'MDE_CPU_X64 _MSC_EXTENSIONS ASM_PFX=3D OPT= IONAL=3D ', + 'X64_GNU': 'MDE_CPU_X64 __GNUC__ ASM_PFX=3D OPTIONAL=3D= ', + 'IPF_MSFT': 'MDE_CPU_IPF _MSC_EXTENSIONS ASM_PFX=3D OPT= IONAL=3D ', + 'IPF_GNU': 'MDE_CPU_IPF __GNUC__ ASM_PFX=3D OPTIONAL=3D= ', 'EBC_INTEL': 'MDE_CPU_EBC __INTEL_COMPILER ASM_PFX=3D O= PTIONAL=3D '} =20 + def parseCmdArgs(): - parser =3D OptionParser(version=3D"Package Document Generation Tools -= Version 0.1") + parser =3D OptionParser( + version=3D"Package Document Generation Tools - Version 0.1") parser.add_option('-w', '--workspace', action=3D'store', type=3D'strin= g', dest=3D'WorkspacePath', help=3D'Specify workspace absolute path. For example= : c:\\tianocore') parser.add_option('-p', '--decfile', action=3D'store', dest=3D'Package= Path', @@ -47,22 +53,27 @@ def parseCmdArgs(): if options.WorkspacePath is None: errors.append('- Please specify workspace path via option -w!') elif not os.path.exists(options.WorkspacePath): - errors.append("- Invalid workspace path %s! The workspace path sho= uld be exist in absolute path!" % options.WorkspacePath) + errors.append( + "- Invalid workspace path %s! The workspace path should be exi= st in absolute path!" % options.WorkspacePath) =20 if options.PackagePath is None: errors.append('- Please specify package DEC file path via option -= p!') elif not os.path.exists(options.PackagePath): - errors.append("- Invalid package's DEC file path %s! The DEC path = should be exist in absolute path!" % options.PackagePath) + errors.append( + "- Invalid package's DEC file path %s! The DEC path should be = exist in absolute path!" % options.PackagePath) =20 default =3D "C:\\Program Files\\doxygen\\bin\\doxygen.exe" if options.DoxygenPath is None: if os.path.exists(default): - print("Warning: Assume doxygen tool is installed at %s. If not= , please specify via -x" % default) + print( + "Warning: Assume doxygen tool is installed at %s. If not, = please specify via -x" % default) options.DoxygenPath =3D default else: - errors.append('- Please specify the path of doxygen tool insta= llation via option -x! or install it in default path %s' % default) + errors.append( + '- Please specify the path of doxygen tool installation vi= a option -x! or install it in default path %s' % default) elif not os.path.exists(options.DoxygenPath): - errors.append("- Invalid doxygen tool path %s! The doxygen tool pa= th should be exist in absolute path!" % options.DoxygenPath) + errors.append( + "- Invalid doxygen tool path %s! The doxygen tool path should = be exist in absolute path!" % options.DoxygenPath) =20 if options.OutputPath is not None: if not os.path.exists(options.OutputPath): @@ -70,20 +81,24 @@ def parseCmdArgs(): try: os.makedirs(options.OutputPath) except: - errors.append('- Fail to create the output directory %s' %= options.OutputPath) + errors.append( + '- Fail to create the output directory %s' % options.O= utputPath) else: if options.PackagePath is not None and os.path.exists(options.Pack= agePath): dirpath =3D os.path.dirname(options.PackagePath) - default =3D os.path.join (dirpath, "Document") - print('Warning: Assume document output at %s. If not, please s= pecify via option -o' % default) + default =3D os.path.join(dirpath, "Document") + print( + 'Warning: Assume document output at %s. If not, please spe= cify via option -o' % default) options.OutputPath =3D default if not os.path.exists(default): try: os.makedirs(default) except: - errors.append('- Fail to create default output directo= ry %s! Please specify document output diretory via option -o' % default) + errors.append( + '- Fail to create default output directory %s! Ple= ase specify document output diretory via option -o' % default) else: - errors.append('- Please specify document output path via optio= n -o!') + errors.append( + '- Please specify document output path via option -o!') =20 if options.Arch is None: options.Arch =3D 'ALL' @@ -104,29 +119,35 @@ def parseCmdArgs(): print('Warning: Assume the installation path of Microsoft = HTML Workshop is %s. If not, specify via option -c.' % default) options.HtmlWorkshopPath =3D default else: - errors.append('- Please specify the installation path of M= icrosoft HTML Workshop via option -c!') + errors.append( + '- Please specify the installation path of Microsoft H= TML Workshop via option -c!') elif not os.path.exists(options.HtmlWorkshopPath): - errors.append('- The installation path of Microsoft HTML Works= hop %s does not exists. ' % options.HtmlWorkshopPath) + errors.append( + '- The installation path of Microsoft HTML Workshop %s doe= s not exists. ' % options.HtmlWorkshopPath) =20 if len(errors) !=3D 0: print('\n') - parser.error('Fail to start due to following reasons: \n%s' %'\n'.= join(errors)) + parser.error('Fail to start due to following reasons: \n%s' % + '\n'.join(errors)) return (options.WorkspacePath, options.PackagePath, options.DoxygenPat= h, options.OutputPath, options.Arch, options.DocumentMode, options.IncludeOnly, optio= ns.HtmlWorkshopPath) =20 + def createPackageObject(wsPath, pkgPath): try: pkgObj =3D baseobject.Package(None, wsPath) pkgObj.Load(pkgPath) except: - logging.getLogger().error ('Fail to create package object!') + logging.getLogger().error('Fail to create package object!') return None =20 return pkgObj =20 + def callbackLogMessage(msg, level): print(msg.strip()) =20 + def callbackCreateDoxygenProcess(doxPath, configPath): if sys.platform =3D=3D 'win32': cmd =3D '"%s" %s' % (doxPath, configPath) @@ -146,7 +167,8 @@ def DocumentFixup(outPath, arch): if dir.lower() in ['.svn', '_svn', 'cvs']: dirs.remove(dir) for file in files: - if not file.lower().endswith('.html'): continue + if not file.lower().endswith('.html'): + continue fullpath =3D os.path.join(outPath, root, file) try: f =3D open(fullpath, 'r') @@ -169,6 +191,7 @@ def DocumentFixup(outPath, arch): =20 print(' >>> Finish all document fixing up! \n') =20 + def FixPageBaseLib(path, text): print(' >>> Fixup BaseLib file page at file %s \n' % path) lines =3D text.split('\n') @@ -184,13 +207,13 @@ def FixPageBaseLib(path, text): lines[index] =3D '#define BASE_LIBRARY_J= UMP_BUFFER_ALIGNMENT   9 [EBC, x64] ' if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT  &n= bsp;4') !=3D -1: lines[index] =3D lines[index].replace('BASE_LIBRARY_JUMP_BUFFE= R_ALIGNMENT   4', - 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&n= bsp;  4 [IA32]') + 'BASE_LIBRARY_JUMP_BUFFER_= ALIGNMENT   4 [IA32]') if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT  &n= bsp;0x10') !=3D -1: lines[index] =3D lines[index].replace('BASE_LIBRARY_JUMP_BUFFE= R_ALIGNMENT   0x10', - 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&n= bsp;  0x10 [IPF]') + 'BASE_LIBRARY_JUMP_BUFFER_= ALIGNMENT   0x10 [IPF]') if line.find('BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT  &n= bsp;8') !=3D -1: lines[index] =3D lines[index].replace('BASE_LIBRARY_JUMP_BUFFE= R_ALIGNMENT   8', - 'BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT&n= bsp;  8 [x64, EBC]') + 'BASE_LIBRARY_JUMP_BUFFER_= ALIGNMENT   8 [x64, EBC]') if line.find('>BASE_LIBRARY_JUMP_BUFFER') !=3D -1: if lastBaseJumpIndex !=3D -1: del lines[lastBaseJumpIndex] @@ -208,15 +231,18 @@ def FixPageBaseLib(path, text): return print(" <<< Finish to fixup file %s\n" % path) =20 + def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text): print(' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at f= ile %s \n' % path) lines =3D text.split('\n') for index in range(len(lines) - 1, -1, -1): line =3D lines[index].strip() if line.find('struct {') !=3D -1 and lines[index - 2].find('>= Uint64') !=3D -1: - lines.insert(index, '

Data Fields= For X64

') + lines.insert( + index, '

Data Fields For X64<= /h2>') if line.find('struct {') !=3D -1 and lines[index - 1].find('D= ata Fields') !=3D -1: - lines.insert(index, '

Data Fields= For IA32

') + lines.insert( + index, '

Data Fields For IA32=

') try: f =3D open(path, 'w') f.write('\n'.join(lines)) @@ -226,6 +252,7 @@ def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text): return print(" <<< Finish to fixup file %s\n" % path) =20 + def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text): print(' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at f= ile %s \n' % path) lines =3D text.split('\n') @@ -237,23 +264,27 @@ def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text): bInDetail =3D False if line.startswith('EBC context buffer used by') and lines[index -= 1].startswith('x64 context buffer'): lines[index] =3D "IA32/IPF/X64/" + line - bNeedRemove =3D True + bNeedRemove =3D True if line.startswith("x64 context buffer") or line.startswith('IPF c= ontext buffer used by') or \ line.startswith('IA32 context buffer used by'): if bNeedRemove: lines.remove(line) if line.find('>R0') !=3D -1 and not bInDetail: if lines[index - 1] !=3D '

Data F= ields For EBC

': - lines.insert(index, '

Data Fi= elds For EBC

') + lines.insert( + index, '

Data Fields For = EBC

') if line.find('>Rbx') !=3D -1 and not bInDetail: if lines[index - 1] !=3D '

Data F= ields For X64

': - lines.insert(index, '

Data Fi= elds For X64

') + lines.insert( + index, '

Data Fields For = X64

') if line.find('>F2') !=3D -1 and not bInDetail: if lines[index - 1] !=3D '

Data F= ields For IPF

': - lines.insert(index, '

Data Fi= elds For IPF

') + lines.insert( + index, '

Data Fields For = IPF

') if line.find('>Ebx') !=3D -1 and not bInDetail: if lines[index - 1] !=3D '

Data F= ields For IA32

': - lines.insert(index, '

Data Fi= elds For IA32

') + lines.insert( + index, '

Data Fields For = IA32

') try: f =3D open(path, 'w') f.write('\n'.join(lines)) @@ -263,17 +294,18 @@ def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text): return print(" <<< Finish to fixup file %s\n" % path) =20 + def FixPageUefiDriverEntryPoint(path, text): print(' >>> Fixup file reference MdePkg/Include/Library/UefiDriverE= ntryPoint.h at file %s \n' % path) lines =3D text.split('\n') bInModuleEntry =3D False - bInEfiMain =3D False - ModuleEntryDlCount =3D 0 + bInEfiMain =3D False + ModuleEntryDlCount =3D 0 ModuleEntryDelStart =3D 0 - ModuleEntryDelEnd =3D 0 - EfiMainDlCount =3D 0 - EfiMainDelStart =3D 0 - EfiMainDelEnd =3D 0 + ModuleEntryDelEnd =3D 0 + EfiMainDlCount =3D 0 + EfiMainDelStart =3D 0 + EfiMainDelEnd =3D 0 =20 for index in range(len(lines)): line =3D lines[index].strip() @@ -320,13 +352,13 @@ def FixPageUefiApplicationEntryPoint(path, text): print(' >>> Fixup file reference MdePkg/Include/Library/UefiApplica= tionEntryPoint.h at file %s \n' % path) lines =3D text.split('\n') bInModuleEntry =3D False - bInEfiMain =3D False - ModuleEntryDlCount =3D 0 + bInEfiMain =3D False + ModuleEntryDlCount =3D 0 ModuleEntryDelStart =3D 0 - ModuleEntryDelEnd =3D 0 - EfiMainDlCount =3D 0 - EfiMainDelStart =3D 0 - EfiMainDelEnd =3D 0 + ModuleEntryDelEnd =3D 0 + EfiMainDlCount =3D 0 + EfiMainDelStart =3D 0 + EfiMainDelEnd =3D 0 =20 for index in range(len(lines)): line =3D lines[index].strip() @@ -368,12 +400,14 @@ def FixPageUefiApplicationEntryPoint(path, text): return print(" <<< Finish to fixup file %s\n" % path) =20 + if __name__ =3D=3D '__main__': wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath =3D= parseCmdArgs() =20 # configure logging system logfilepath =3D os.path.join(outpath, 'log.txt') - logging.basicConfig(format=3D'%(levelname)-8s %(message)s', level=3Dlo= gging.DEBUG) + logging.basicConfig( + format=3D'%(levelname)-8s %(message)s', level=3Dlogging.DEBUG) =20 # create package model object firstly pkgObj =3D createPackageObject(wspath, pkgpath) @@ -381,13 +415,13 @@ if __name__ =3D=3D '__main__': sys.exit(-1) =20 # create doxygen action model - arch =3D None + arch =3D None tooltag =3D None if archtag.lower() !=3D 'all': arch =3D archtag.split('_')[0] tooltag =3D archtag.split('_')[1] else: - arch =3D 'all' + arch =3D 'all' tooltag =3D 'all' =20 # preprocess package and call doxygen @@ -419,6 +453,8 @@ if __name__ =3D=3D '__main__': else: cmd =3D '%s %s' % (hwpath, indexpath) subprocess.call(cmd) - print('\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.chm')) + print('\nFinish to generate package document! Please open %s for r= eview' % + os.path.join(outpath, 'html', 'index.chm')) else: - print('\nFinish to generate package document! Please open %s for r= eview' % os.path.join(outpath, 'html', 'index.html')) + print('\nFinish to generate package document! Please open %s for r= eview' % + os.path.join(outpath, 'html', 'index.html')) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/__in= it__.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/__init_= _.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/__init__.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/__init__.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugi= ns/basemodel/__init__.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/_= _init__.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/_= _init__.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/doxygen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugin= s/basemodel/doxygen.py index a8f87751a0fa..9081234a9088 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/d= oxygen.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/d= oxygen.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
# @@ -11,10 +11,11 @@ import os =20 from .message import * =20 + class BaseDoxygeItem: def __init__(self, name, tag=3D''): self.mName =3D name - self.mTag =3D tag + self.mTag =3D tag self.mDescription =3D '' self.mText =3D [] =20 @@ -27,6 +28,7 @@ class BaseDoxygeItem: def Generate(self): """This interface need to be override""" =20 + class Section(BaseDoxygeItem): def Generate(self): """This interface need to be override""" @@ -38,13 +40,14 @@ class Section(BaseDoxygeItem): self.mText.append(self.mDescription) return self.mText =20 + class Page(BaseDoxygeItem): def __init__(self, name, tag=3DNone, isSort=3DTrue): BaseDoxygeItem.__init__(self, name, tag) - self.mSubPages =3D [] - self.mIsMainPage =3D False - self.mSections =3D [] - self.mIsSort =3D isSort + self.mSubPages =3D [] + self.mIsMainPage =3D False + self.mSections =3D [] + self.mIsSort =3D isSort =20 def GetSubpageCount(self): return len(self.mSubPages) @@ -88,7 +91,8 @@ class Page(BaseDoxygeItem): if self.mIsSort: self.mSubPages.sort(key=3Dlambda x: x.mName.lower()) for page in self.mSubPages: - self.mText.insert(endIndex, '
  • \subpage %s \"%s\"
  • '= % (page.mTag, page.mName)) + self.mText.insert( + endIndex, '
  • \subpage %s \"%s\"
  • ' % (page.mTag,= page.mName)) endIndex +=3D 1 self.mText +=3D page.Generate() self.mText.insert(endIndex, '') @@ -96,10 +100,11 @@ class Page(BaseDoxygeItem): self.mText.insert(endIndex, ' **/') return self.mText =20 + class DoxygenFile(Page): def __init__(self, name, file): Page.__init__(self, name) - self.mFilename =3D file + self.mFilename =3D file self.mIsMainPage =3D True =20 def GetFilename(self): @@ -112,11 +117,12 @@ class DoxygenFile(Page): f.write('\n'.join(str)) f.close() except IOError as e: - ErrorMsg ('Fail to write file %s' % self.mFilename) + ErrorMsg('Fail to write file %s' % self.mFilename) return False =20 return True =20 + doxygenConfigTemplate =3D """ DOXYFILE_ENCODING =3D UTF-8 PROJECT_NAME =3D %(ProjectName)s @@ -326,19 +332,21 @@ DOT_CLEANUP =3D YES SEARCHENGINE =3D NO =20 """ + + class DoxygenConfigFile: def __init__(self): - self.mProjectName =3D '' - self.mOutputDir =3D '' - self.mFileList =3D [] - self.mIncludeList =3D [] - self.mStripPath =3D '' - self.mExamplePath =3D '' - self.mPattern =3D ['*.c', '*.h', - '*.asm', '*.s', '.nasm', '*.html', '*.dox'] - self.mMode =3D 'HTML' - self.mWarningFile =3D '' - self.mPreDefined =3D [] + self.mProjectName =3D '' + self.mOutputDir =3D '' + self.mFileList =3D [] + self.mIncludeList =3D [] + self.mStripPath =3D '' + self.mExamplePath =3D '' + self.mPattern =3D ['*.c', '*.h', + '*.asm', '*.s', '.nasm', '*.html', '*.dox'] + self.mMode =3D 'HTML' + self.mWarningFile =3D '' + self.mPreDefined =3D [] self.mProjectVersion =3D 0.1 =20 def SetChmMode(self): @@ -399,7 +407,7 @@ class DoxygenConfigFile: self.mPreDefined.append(macro) =20 def Generate(self, path): - files =3D ' \\\n'.join(self.mFileList) + files =3D ' \\\n'.join(self.mFileList) includes =3D ' \\\n'.join(self.mIncludeList) patterns =3D ' \\\n'.join(self.mPattern) if self.mMode.lower() =3D=3D 'html': @@ -409,32 +417,33 @@ class DoxygenConfigFile: sHtmlHelp =3D 'YES' sTreeView =3D 'NO' =20 - text =3D doxygenConfigTemplate % {'ProjectName':self.mProjectName, - 'OutputDir':self.mOutputDir, - 'StripPath':self.mStripPath, - 'ExamplePath':self.mExamplePath, - 'FileList':files, - 'Pattern':patterns, - 'WhetherGenerateHtmlHelp':sHtmlHel= p, - 'WhetherGenerateTreeView':sTreeVie= w, - 'IncludePath':includes, - 'WarningFile':self.mWarningFile, - 'PreDefined':' '.join(self.mPreDef= ined), - 'ProjectVersion':self.mProjectVers= ion} + text =3D doxygenConfigTemplate % {'ProjectName': self.mProjectName, + 'OutputDir': self.mOutputDir, + 'StripPath': self.mStripPath, + 'ExamplePath': self.mExamplePath, + 'FileList': files, + 'Pattern': patterns, + 'WhetherGenerateHtmlHelp': sHtmlHe= lp, + 'WhetherGenerateTreeView': sTreeVi= ew, + 'IncludePath': includes, + 'WarningFile': self.mWarningFile, + 'PreDefined': ' '.join(self.mPreDe= fined), + 'ProjectVersion': self.mProjectVer= sion} try: f =3D open(path, 'w') f.write(text) f.close() except IOError as e: - ErrorMsg ('Fail to generate doxygen config file %s' % path) + ErrorMsg('Fail to generate doxygen config file %s' % path) return False =20 return True =20 + ######################################################################## # TEST CODE ######################################################################## -if __name__=3D=3D '__main__': +if __name__ =3D=3D '__main__': df =3D DoxygenFile('Platform Document', 'm:\tree') df.AddPage(Page('Module', 'module')) p =3D df.AddPage(Page('Library', 'library')) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlug= ins/basemodel/efibinary.py index 1bc4938bfcdf..c0d7518317e3 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/e= fibinary.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/e= fibinary.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -13,9 +13,11 @@ import os import logging import core.pe as pe =20 + def GetLogger(): return logging.getLogger('EFI Binary File') =20 + class EFIBinaryError(Exception): def __init__(self, message): Exception.__init__(self) @@ -24,6 +26,7 @@ class EFIBinaryError(Exception): def GetMessage(self): return self._message =20 + class EfiFd(object): EFI_FV_HEADER_SIZE =3D 0x48 =20 @@ -43,28 +46,29 @@ class EfiFd(object): def GetFvs(self): return self._fvs =20 + class EfiFv(object): FILE_SYSTEM_GUID =3D uuid.UUID('{8c8ce578-8a3d-4f1c-9935-896185c32dd3}= ') =20 def __init__(self, parent=3DNone): - self._size =3D 0 - self._filename =3D None - self._fvheader =3D None + self._size =3D 0 + self._filename =3D None + self._fvheader =3D None self._blockentries =3D [] - self._ffs =3D [] + self._ffs =3D [] =20 # following field is for FV in FD - self._parent =3D parent - self._offset =3D 0 - self._raw =3D array.array('B') + self._parent =3D parent + self._offset =3D 0 + self._raw =3D array.array('B') =20 def Load(self, fd): - self._offset =3D fd.tell() + self._offset =3D fd.tell() self._filename =3D fd.name =20 # get file header self._fvheader =3D EfiFirmwareVolumeHeader.Read(fd) - #self._fvheader.Dump() + # self._fvheader.Dump() =20 self._size =3D self._fvheader.GetFvLength() =20 @@ -80,10 +84,10 @@ class EfiFv(object): self._blockentries.append(blockentry) blockentry =3D BlockMapEntry.Read(fd) =20 - if self._fvheader.GetSize() + (len(self._blockentries)) * 8 !=3D \ self._fvheader.GetHeaderLength(): - raise EFIBinaryError("Volume Header length not consistent with= block map!") + raise EFIBinaryError( + "Volume Header length not consistent with block map!") =20 index =3D align(fd.tell(), 8) count =3D 0 @@ -120,10 +124,11 @@ class EfiFv(object): def GetRawData(self): return self._raw.tolist() =20 + class BinaryItem(object): def __init__(self, parent=3DNone): self._size =3D 0 - self._arr =3D array.array('B') + self._arr =3D array.array('B') self._parent =3D parent =20 @classmethod @@ -144,6 +149,7 @@ class BinaryItem(object): def GetParent(self): return self._parent =20 + class EfiFirmwareVolumeHeader(BinaryItem): def GetSize(self): return 56 @@ -267,6 +273,7 @@ class EfiFirmwareVolumeHeader(BinaryItem): def GetRawData(self): return self._arr.tolist() =20 + class BlockMapEntry(BinaryItem): def GetSize(self): return 8 @@ -285,15 +292,16 @@ class BlockMapEntry(BinaryItem): def __str__(self): return '[BlockEntry] Number =3D 0x%X, length=3D0x%X' % (self.GetNu= mberBlocks(), self.GetLength()) =20 + class EfiFfs(object): - FFS_HEADER_SIZE =3D 24 + FFS_HEADER_SIZE =3D 24 =20 def __init__(self, parent=3DNone): self._header =3D None =20 # following field is for FFS in FV file. - self._parent =3D parent - self._offset =3D 0 + self._parent =3D parent + self._offset =3D 0 self._sections =3D [] =20 def Load(self, fd): @@ -335,8 +343,8 @@ class EfiFfs(object): return self._header.GetNameGuid() =20 def DumpContent(self): - list =3D self._content.tolist() - line =3D [] + list =3D self._content.tolist() + line =3D [] count =3D 0 for item in list: if count < 32: @@ -358,13 +366,14 @@ class EfiFfs(object): def GetSections(self): return self._sections =20 + class EfiFfsHeader(BinaryItem): - ffs_state_map =3D {0x01:'EFI_FILE_HEADER_CONSTRUCTION', - 0x02:'EFI_FILE_HEADER_VALID', - 0x04:'EFI_FILE_DATA_VALID', - 0x08:'EFI_FILE_MARKED_FOR_UPDATE', - 0x10:'EFI_FILE_DELETED', - 0x20:'EFI_FILE_HEADER_INVALID'} + ffs_state_map =3D {0x01: 'EFI_FILE_HEADER_CONSTRUCTION', + 0x02: 'EFI_FILE_HEADER_VALID', + 0x04: 'EFI_FILE_DATA_VALID', + 0x08: 'EFI_FILE_MARKED_FOR_UPDATE', + 0x10: 'EFI_FILE_DELETED', + 0x20: 'EFI_FILE_HEADER_INVALID'} =20 def GetSize(self): return 24 @@ -377,7 +386,6 @@ class EfiFfsHeader(BinaryItem): list =3D self._arr.tolist() return int(list[18]) =20 - def GetTypeString(self): value =3D self.GetType() if value =3D=3D 0x01: @@ -454,7 +462,7 @@ class EfiSection(object): EFI_SECTION_HEADER_SIZE =3D 4 =20 def __init__(self, parent=3DNone): - self._size =3D 0 + self._size =3D 0 self._parent =3D parent self._offset =3D 0 self._contents =3D array.array('B') @@ -465,8 +473,8 @@ class EfiSection(object): self._header =3D EfiSectionHeader.Read(fd, self) =20 if self._header.GetTypeString() =3D=3D "EFI_SECTION_PE32": - pefile =3D pe.PEFile(self) - pefile.Load(fd, self.GetContentSize()) + pefile =3D pe.PEFile(self) + pefile.Load(fd, self.GetContentSize()) =20 fd.seek(self._offset) self._contents.fromfile(fd, self.GetContentSize()) @@ -491,6 +499,7 @@ class EfiSection(object): def GetSectionOffset(self): return self._offset + self.EFI_SECTION_HEADER_SIZE =20 + class EfiSectionHeader(BinaryItem): section_type_map =3D {0x01: 'EFI_SECTION_COMPRESSION', 0x02: 'EFI_SECTION_GUID_DEFINED', @@ -505,6 +514,7 @@ class EfiSectionHeader(BinaryItem): 0x18: 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', 0x19: 'EFI_SECTION_RAW', 0x1B: 'EFI_SECTION_PEI_DEPEX'} + def GetSize(self): return 4 =20 @@ -527,8 +537,10 @@ class EfiSectionHeader(BinaryItem): print('type =3D 0x%X' % self.GetType()) =20 =20 +rMapEntry =3D re.compile( + '^(\w+)[ \(\w\)]* \(BaseAddress=3D([0-9a-fA-F]+), EntryPoint=3D([0-9a-= fA-F]+), GUID=3D([0-9a-fA-F\-]+)') + =20 -rMapEntry =3D re.compile('^(\w+)[ \(\w\)]* \(BaseAddress=3D([0-9a-fA-F]+),= EntryPoint=3D([0-9a-fA-F]+), GUID=3D([0-9a-fA-F\-]+)') class EfiFvMapFile(object): def __init__(self): self._mapentries =3D {} @@ -549,12 +561,13 @@ class EfiFvMapFile(object): # new entry ret =3D rMapEntry.match(line) if ret is not None: - name =3D ret.groups()[0] + name =3D ret.groups()[0] baseaddr =3D int(ret.groups()[1], 16) - entry =3D int(ret.groups()[2], 16) - guidstr =3D '{' + ret.groups()[3] + '}' - guid =3D uuid.UUID(guidstr) - self._mapentries[guid] =3D EfiFvMapFileEntry(name, bas= eaddr, entry, guid) + entry =3D int(ret.groups()[2], 16) + guidstr =3D '{' + ret.groups()[3] + '}' + guid =3D uuid.UUID(guidstr) + self._mapentries[guid] =3D EfiFvMapFileEntry( + name, baseaddr, entry, guid) return True =20 def GetEntry(self, guid): @@ -562,12 +575,13 @@ class EfiFvMapFile(object): return self._mapentries[guid] return None =20 + class EfiFvMapFileEntry(object): def __init__(self, name, baseaddr, entry, guid): - self._name =3D name + self._name =3D name self._baseaddr =3D baseaddr - self._entry =3D entry - self._guid =3D guid + self._entry =3D entry + self._guid =3D guid =20 def GetName(self): return self._name @@ -578,6 +592,7 @@ class EfiFvMapFileEntry(object): def GetEntryPoint(self): return self._entry =20 + def list2guid(list): val1 =3D list2int(list[0:4]) val2 =3D list2int(list[4:6]) @@ -586,20 +601,25 @@ def list2guid(list): for item in list[8:16]: val4 =3D (val4 << 8) | int(item) =20 - val =3D val1 << 12 * 8 | val2 << 10 * 8 | val3 << 8 * 8 | val4 + val =3D val1 << 12 * 8 | val2 << 10 * 8 | val3 << 8 * 8 | val4 guid =3D uuid.UUID(int=3Dval) return guid =20 + def list2int(list): val =3D 0 for index in range(len(list) - 1, -1, -1): val =3D (val << 8) | int(list[index]) return val =20 + def align(value, alignment): return (value + ((alignment - value) & (alignment - 1))) =20 + gInvalidGuid =3D uuid.UUID(int=3D0xffffffffffffffffffffffffffffffff) + + def isValidGuid(guid): if guid =3D=3D gInvalidGuid: return False diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/ba= semodel/ini.py index 7facb9aa24c7..c51195d58336 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/i= ni.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/i= ni.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -12,16 +12,19 @@ import os =20 section_re =3D re.compile(r'^\[([\w., "]+)\]') =20 + class BaseINIFile(object): _objs =3D {} + def __new__(cls, *args, **kwargs): """Maintain only a single instance of this object @return: instance of this class =20 """ - if len(args) =3D=3D 0: return object.__new__(cls) + if len(args) =3D=3D 0: + return object.__new__(cls) filename =3D args[0] - parent =3D None + parent =3D None if len(args) > 1: parent =3D args[1] =20 @@ -35,19 +38,21 @@ class BaseINIFile(object): return cls._objs[key] =20 def __init__(self, filename=3DNone, parent=3DNone): - self._lines =3D [] + self._lines =3D [] self._sections =3D {} self._filename =3D filename - self._globals =3D [] + self._globals =3D [] self._isModify =3D True =20 def AddParent(self, parent): - if parent is None: return + if parent is None: + return if not hasattr(self, "_parents"): self._parents =3D [] =20 if parent in self._parents: - ErrorMsg("Duplicate parent is found for INI file %s" % self._f= ilename) + ErrorMsg("Duplicate parent is found for INI file %s" % + self._filename) return self._parents.append(parent) =20 @@ -58,7 +63,8 @@ class BaseINIFile(object): return self._isModify =20 def Modify(self, modify=3DTrue, obj=3DNone): - if modify =3D=3D self._isModify: return + if modify =3D=3D self._isModify: + return self._isModify =3D modify if modify: for parent in self._parents: @@ -73,7 +79,7 @@ class BaseINIFile(object): =20 try: handle =3D open(filename, 'r') - self._lines =3D handle.readlines() + self._lines =3D handle.readlines() handle.close() except: raise EdkException("Fail to open file %s" % filename) @@ -102,22 +108,25 @@ class BaseINIFile(object): return arr =20 def Parse(self): - if not self._isModify: return True - if not self._ReadLines(self._filename): return False + if not self._isModify: + return True + if not self._ReadLines(self._filename): + return False =20 - sObjs =3D [] + sObjs =3D [] inGlobal =3D True # process line for index in range(len(self._lines)): templine =3D self._lines[index].strip() # skip comments - if len(templine) =3D=3D 0: continue + if len(templine) =3D=3D 0: + continue if re.match("^\[=3D*\]", templine) or re.match("^#", templine)= or \ re.match("\*+/", templine): continue =20 m =3D section_re.match(templine) - if m is not None: # found a section + if m is not None: # found a section inGlobal =3D False # Finish the latest section first if len(sObjs) !=3D 0: @@ -132,7 +141,8 @@ class BaseINIFile(object): sname_arr =3D m.groups()[0].split(',') sObjs =3D [] for name in sname_arr: - sObj =3D self.GetSectionInstance(self, name, (len(snam= e_arr) > 1)) + sObj =3D self.GetSectionInstance( + self, name, (len(sname_arr) > 1)) sObj._start =3D index sObjs.append(sObj) if name.lower() not in self._sections: @@ -164,14 +174,16 @@ class BaseINIFile(object): assert parent in self._parents, "when destory ini object, can = not found parent reference!" self._parents.remove(parent) =20 - if len(self._parents) !=3D 0: return + if len(self._parents) !=3D 0: + return =20 for sects in self._sections.values(): for sect in sects: sect.Destroy() =20 # dereference from _objs array - assert self.GetFilename() in self._objs.keys(), "When destroy ini = object, can not find obj reference!" + assert self.GetFilename() in self._objs.keys( + ), "When destroy ini object, can not find obj reference!" assert self in self._objs.values(), "When destroy ini object, can = not find obj reference!" del self._objs[self.GetFilename()] =20 @@ -208,12 +220,13 @@ class BaseINIFile(object): =20 def AddNewSection(self, sectName): if sectName.lower() in self._sections.keys(): - ErrorMsg('Section %s can not be created for conflict with exis= ting section') + ErrorMsg( + 'Section %s can not be created for conflict with existing = section') return None =20 sectionObj =3D self.GetSectionInstance(self, sectName) sectionObj._start =3D len(self._lines) - sectionObj._end =3D len(self._lines) + 1 + sectionObj._end =3D len(self._lines) + 1 self._lines.append('[%s]\n' % sectName) self._lines.append('\n\n') self._sections[sectName.lower()] =3D sectionObj @@ -228,19 +241,19 @@ class BaseINIFile(object): def __str__(self): return ''.join(self._lines) =20 - ## Get file header's comment from basic INI file. + # Get file header's comment from basic INI file. # The file comments has two style: # 1) #/** @file # 2) ## @file # def GetFileHeader(self): desc =3D [] - lineArr =3D self._lines + lineArr =3D self._lines inHeader =3D False for num in range(len(self._lines)): line =3D lineArr[num].strip() if not inHeader and (line.startswith("#/**") or line.startswit= h("##")) and \ - line.find("@file") !=3D -1: + line.find("@file") !=3D -1: inHeader =3D True continue if inHeader and (line.startswith("#**/") or line.startswith('#= #')): @@ -254,14 +267,15 @@ class BaseINIFile(object): desc.append(line[prefixIndex + 1:]) return '
    \n'.join(desc) =20 + class BaseINISection(object): def __init__(self, parent, name, isCombined=3DFalse): - self._parent =3D parent - self._name =3D name + self._parent =3D parent + self._name =3D name self._isCombined =3D isCombined - self._start =3D 0 - self._end =3D 0 - self._objs =3D [] + self._start =3D 0 + self._end =3D 0 + self._objs =3D [] =20 def __del__(self): for obj in self._objs: @@ -354,7 +368,7 @@ class BaseINISection(object): =20 def GetComment(self): comments =3D [] - start =3D self._start - 1 + start =3D self._start - 1 bFound =3D False =20 while (start > 0): @@ -376,18 +390,21 @@ class BaseINISection(object): end =3D start + 1 while (end < self._start): line =3D self.GetLine(end).strip() - if len(line) =3D=3D 0: break - if not line.startswith('#'): break + if len(line) =3D=3D 0: + break + if not line.startswith('#'): + break index =3D line.rfind('#') if (index + 1) < len(line): comments.append(line[index + 1:]) end +=3D 1 return comments =20 + class BaseINIGlobalObject(object): def __init__(self, parent): self._start =3D 0 - self._end =3D 0 + self._end =3D 0 =20 def Parse(self): return True @@ -398,10 +415,11 @@ class BaseINIGlobalObject(object): def __del__(self): pass =20 + class BaseINISectionObject(object): def __init__(self, parent): - self._start =3D 0 - self._end =3D 0 + self._start =3D 0 + self._end =3D 0 self._parent =3D parent =20 def __del__(self): @@ -444,7 +462,7 @@ class BaseINISectionObject(object): =20 def GetComment(self): comments =3D [] - start =3D self.GetStartLinenumber() - 1 + start =3D self.GetStartLinenumber() - 1 bFound =3D False =20 while (start > 0): @@ -466,8 +484,10 @@ class BaseINISectionObject(object): end =3D start + 1 while (end <=3D self.GetStartLinenumber() - 1): line =3D self.GetParent().GetLine(end).strip() - if len(line) =3D=3D 0: break - if not line.startswith('#'): break + if len(line) =3D=3D 0: + break + if not line.startswith('#'): + break index =3D line.rfind('#') if (index + 1) < len(line): comments.append(line[index + 1:]) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/inidocview.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlu= gins/basemodel/inidocview.py index 849d0fc91a53..43e053fc0c60 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/i= nidocview.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/i= nidocview.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -7,6 +7,7 @@ =20 import core.editor =20 + class INIDoc(core.editor.EditorDocument): def __init__(self): core.editor.EditorDocument.__init__(self) diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/message.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugin= s/basemodel/message.py index 882538a1711b..636aa4d40378 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/m= essage.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/m= essage.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -9,23 +9,28 @@ def GetEdkLogger(): import logging return logging.getLogger('edk') =20 + class EdkException(Exception): def __init__(self, message, fName=3DNone, fNo=3DNone): self._message =3D message ErrorMsg(message, fName, fNo) =20 def GetMessage(self): - return '[EDK Failure]: %s' %self._message + return '[EDK Failure]: %s' % self._message + =20 def ErrorMsg(mess, fName=3DNone, fNo=3DNone): GetEdkLogger().error(NormalMessage('#ERR#', mess, fName, fNo)) =20 + def LogMsg(mess, fName=3DNone, fNo=3DNone): GetEdkLogger().info(NormalMessage('@LOG@', mess, fName, fNo)) =20 + def WarnMsg(mess, fName=3DNone, fNo=3DNone): GetEdkLogger().warning(NormalMessage('!WAR!', mess, fName, fNo)) =20 + def NormalMessage(type, mess, fName=3DNone, fNo=3DNone): strMsg =3D type =20 @@ -41,6 +46,3 @@ def NormalMessage(type, mess, fName=3DNone, fNo=3DNone): strMsg +=3D mess =20 return strMsg - - - diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /__init__.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/ed= k2/__init__.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/__init= __.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/__init= __.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/__init__.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlug= ins/edk2/model/__init__.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= __init__.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= __init__.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/baseobject.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPl= ugins/edk2/model/baseobject.py index ee00529f464b..307dac9949af 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= baseobject.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= baseobject.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -11,6 +11,7 @@ from plugins.EdkPlugins.edk2.model import dec import os from plugins.EdkPlugins.basemodel.message import * =20 + class SurfaceObject(object): _objs =3D {} =20 @@ -27,10 +28,10 @@ class SurfaceObject(object): return obj =20 def __init__(self, parent, workspace): - self._parent =3D parent - self._fileObj =3D None + self._parent =3D parent + self._fileObj =3D None self._workspace =3D workspace - self._isModify =3D False + self._isModify =3D False self._modifiedObjs =3D [] =20 def __del__(self): @@ -68,7 +69,8 @@ class SurfaceObject(object): =20 def Load(self, relativePath): # if has been loaded, directly return - if self._fileObj is not None: return True + if self._fileObj is not None: + return True =20 relativePath =3D os.path.normpath(relativePath) fullPath =3D os.path.join(self._workspace, relativePath) @@ -133,11 +135,12 @@ class SurfaceObject(object): continue return arr =20 + class Platform(SurfaceObject): def __init__(self, parent, workspace): SurfaceObject.__init__(self, parent, workspace) - self._modules =3D [] - self._packages =3D [] + self._modules =3D [] + self._packages =3D [] =20 def Destroy(self): for module in self._modules: @@ -201,7 +204,8 @@ class Platform(SurfaceObject): =20 return obj.GetInstance() =20 - ErrorMsg("Fail to get library class %s [%s][%s] from platform %s" = % (classname, arch, type, self.GetFilename())) + ErrorMsg("Fail to get library class %s [%s][%s] from platform %s" = % ( + classname, arch, type, self.GetFilename())) return None =20 def GetPackage(self, path): @@ -224,7 +228,8 @@ class Platform(SurfaceObject): # do not care force paramter for platform object isFileChanged =3D self.GetFileObj().IsModified() ret =3D SurfaceObject.Reload(self, False) - if not ret: return False + if not ret: + return False if isFileChanged: # destroy all modules and reload them again for obj in self._modules: @@ -285,8 +290,10 @@ class Platform(SurfaceObject): for oldSect in sects: newSect =3D newDsc.AddNewSection(oldSect.GetName()) for oldComObj in oldSect.GetObjects(): - module =3D self.GetModuleObject(oldComObj.GetFilename(), o= ldSect.GetArch()) - if module is None: continue + module =3D self.GetModuleObject( + oldComObj.GetFilename(), oldSect.GetArch()) + if module is None: + continue =20 newComObj =3D dsc.DSCComponentObject(newSect) newComObj.SetFilename(oldComObj.GetFilename()) @@ -295,13 +302,14 @@ class Platform(SurfaceObject): libdict =3D module.GetLibraries() for libclass in libdict.keys(): if libdict[libclass] is not None: - newComObj.AddOverideLib(libclass, libdict[libclass= ].GetRelativeFilename().replace('\\', '/')) + newComObj.AddOverideLib( + libclass, libdict[libclass].GetRelativeFilenam= e().replace('\\', '/')) =20 # add all pcds for override section pcddict =3D module.GetPcds() for pcd in pcddict.values(): - buildPcd =3D pcd.GetBuildObj() - buildType =3D buildPcd.GetPcdType() + buildPcd =3D pcd.GetBuildObj() + buildType =3D buildPcd.GetPcdType() buildValue =3D None if buildType.lower() =3D=3D 'pcdsdynamichii' or \ buildType.lower() =3D=3D 'pcdsdynamicvpd' or \ @@ -315,20 +323,21 @@ class Platform(SurfaceObject): newSect.AddObject(newComObj) return newDsc =20 + class Module(SurfaceObject): def __init__(self, parent, workspace): SurfaceObject.__init__(self, parent, workspace) - self._arch =3D 'common' - self._parent =3D parent + self._arch =3D 'common' + self._parent =3D parent self._overidePcds =3D {} self._overideLibs =3D {} - self._libs =3D {} - self._pcds =3D {} - self._ppis =3D [] - self._protocols =3D [] - self._depexs =3D [] - self._guids =3D [] - self._packages =3D [] + self._libs =3D {} + self._pcds =3D {} + self._ppis =3D [] + self._protocols =3D [] + self._depexs =3D [] + self._guids =3D [] + self._packages =3D [] =20 def Destroy(self): for lib in self._libs.values(): @@ -397,7 +406,8 @@ class Module(SurfaceObject): def GetPcds(self): pcds =3D self._pcds.copy() for lib in self._libs.values(): - if lib is None: continue + if lib is None: + continue for name in lib._pcds.keys(): pcds[name] =3D lib._pcds[name] return pcds @@ -406,7 +416,8 @@ class Module(SurfaceObject): ppis =3D [] ppis +=3D self._ppis for lib in self._libs.values(): - if lib is None: continue + if lib is None: + continue ppis +=3D lib._ppis return ppis =20 @@ -414,7 +425,8 @@ class Module(SurfaceObject): pros =3D [] pros =3D self._protocols for lib in self._libs.values(): - if lib is None: continue + if lib is None: + continue pros +=3D lib._protocols return pros =20 @@ -422,7 +434,8 @@ class Module(SurfaceObject): guids =3D [] guids +=3D self._guids for lib in self._libs.values(): - if lib is None: continue + if lib is None: + continue guids +=3D lib._guids return guids =20 @@ -430,7 +443,8 @@ class Module(SurfaceObject): deps =3D [] deps +=3D self._depexs for lib in self._libs.values(): - if lib is None: continue + if lib is None: + continue deps +=3D lib._depexs return deps =20 @@ -449,13 +463,15 @@ class Module(SurfaceObject): if issubclass(parent.__class__, Platform): path =3D parent.GetLibraryPath(classname, arch, type) if path is None: - ErrorMsg('Fail to get library instance for %s' % class= name, self.GetFilename()) + ErrorMsg('Fail to get library instance for %s' % + classname, self.GetFilename()) return None self._libs[classname] =3D Library(self, self.GetWorkspace(= )) if not self._libs[classname].Load(path, self.GetArch()): self._libs[classname] =3D None else: - self._libs[classname] =3D parent.GetLibraryInstance(classn= ame, arch, type) + self._libs[classname] =3D parent.GetLibraryInstance( + classname, arch, type) return self._libs[classname] =20 def GetSourceObjs(self): @@ -479,14 +495,14 @@ class Module(SurfaceObject): =20 def _SearchSurfaceItems(self): # get surface item from self's inf - pcds =3D [] - ppis =3D [] - pros =3D [] - deps =3D [] + pcds =3D [] + ppis =3D [] + pros =3D [] + deps =3D [] guids =3D [] if self.GetFileObj() is not None: pcds =3D self.FilterObjsByArch(self.GetFileObj().GetSectionObj= ectsByName('pcd'), - self.GetArch()) + self.GetArch()) for pcd in pcds: if pcd.GetPcdName() not in self._pcds.keys(): pcdItem =3D PcdItem(pcd.GetPcdName(), self, pcd) @@ -518,7 +534,7 @@ class Module(SurfaceObject): self._depexs.append(item) =20 guids +=3D self.FilterObjsByArch(self.GetFileObj().GetSectionO= bjectsByName('guids'), - self.GetArch()) + self.GetArch()) for guid in guids: item =3D GuidItem(guid.GetName(), self, guid) if item not in self._guids: @@ -542,7 +558,8 @@ class Module(SurfaceObject): =20 def GetLibraryClassHeaderFilePath(self): lcname =3D self.GetFileObj().GetProduceLibraryClass() - if lcname is None: return None + if lcname is None: + return None =20 pkgs =3D self.GetPackages() for package in pkgs: @@ -556,7 +573,8 @@ class Module(SurfaceObject): callback(self, "Starting reload...") =20 ret =3D SurfaceObject.Reload(self, force) - if not ret: return False + if not ret: + return False =20 if not force and not self.IsModified(): return True @@ -612,6 +630,7 @@ class Module(SurfaceObject): self._isModify =3D modify self.GetParent().Modify(modify, self) =20 + class Library(Module): def __init__(self, parent, workspace): Module.__init__(self, parent, workspace) @@ -637,13 +656,14 @@ class Library(Module): self._pcds.clear() SurfaceObject.Destroy(self) =20 + class Package(SurfaceObject): def __init__(self, parent, workspace): SurfaceObject.__init__(self, parent, workspace) - self._pcds =3D {} - self._guids =3D {} + self._pcds =3D {} + self._guids =3D {} self._protocols =3D {} - self._ppis =3D {} + self._ppis =3D {} =20 def GetPcds(self): return self._pcds @@ -679,19 +699,22 @@ class Package(SurfaceObject): =20 def Load(self, relativePath): ret =3D SurfaceObject.Load(self, relativePath) - if not ret: return False + if not ret: + return False pcds =3D self.GetFileObj().GetSectionObjectsByName('pcds') for pcd in pcds: if pcd.GetPcdName() in self._pcds.keys(): if self._pcds[pcd.GetPcdName()] is not None: self._pcds[pcd.GetPcdName()].AddDecObj(pcd) else: - self._pcds[pcd.GetPcdName()] =3D PcdItem(pcd.GetPcdName(),= self, pcd) + self._pcds[pcd.GetPcdName()] =3D PcdItem( + pcd.GetPcdName(), self, pcd) =20 guids =3D self.GetFileObj().GetSectionObjectsByName('guids') for guid in guids: if guid.GetName() not in self._guids.keys(): - self._guids[guid.GetName()] =3D GuidItem(guid.GetName(), s= elf, guid) + self._guids[guid.GetName()] =3D GuidItem( + guid.GetName(), self, guid) else: WarnMsg("Duplicate definition for %s" % guid.GetName()) =20 @@ -705,7 +728,8 @@ class Package(SurfaceObject): protocols =3D self.GetFileObj().GetSectionObjectsByName('protocols= ') for protocol in protocols: if protocol.GetName() not in self._protocols.keys(): - self._protocols[protocol.GetName()] =3D ProtocolItem(proto= col.GetName(), self, protocol) + self._protocols[protocol.GetName()] =3D ProtocolItem( + protocol.GetName(), self, protocol) else: WarnMsg("Duplicate definition for %s" % protocol.GetName()) =20 @@ -720,7 +744,8 @@ class Package(SurfaceObject): def GetPcdDefineObjs(self, name=3DNone): arr =3D [] objs =3D self.GetFileObj().GetSectionObjectsByName('pcds') - if name is None: return objs + if name is None: + return objs =20 for obj in objs: if obj.GetPcdName().lower() =3D=3D name.lower(): @@ -748,6 +773,7 @@ class Package(SurfaceObject): return obj.GetHeaderFile() return None =20 + class DepexItem(object): def __init__(self, parent, infObj): self._parent =3D parent @@ -759,19 +785,21 @@ class DepexItem(object): def GetInfObject(self): return self._infObj =20 + class ModulePcd(object): _type_mapping =3D {'FeaturePcd': 'PcdsFeatureFlag', 'FixedPcd': 'PcdsFixedAtBuild', 'PatchPcd': 'PcdsPatchableInModule'} =20 def __init__(self, parent, name, infObj, pcdItem): - assert issubclass(parent.__class__, Module), "Module's PCD's paren= t must be module!" + assert issubclass(parent.__class__, + Module), "Module's PCD's parent must be module!" assert pcdItem is not None, 'Pcd %s does not in some package!' % n= ame =20 - self._name =3D name - self._parent =3D parent - self._pcdItem =3D pcdItem - self._infObj =3D infObj + self._name =3D name + self._parent =3D parent + self._pcdItem =3D pcdItem + self._infObj =3D infObj =20 def GetName(self): return self._name @@ -787,7 +815,8 @@ class ModulePcd(object): self._infObj =3D None =20 def GetBuildObj(self): - platformInfos =3D self._parent.GetPlatform().GetPcdBuildObjs(self.= _name, self.GetArch()) + platformInfos =3D self._parent.GetPlatform( + ).GetPcdBuildObjs(self._name, self.GetArch()) modulePcdType =3D self._infObj.GetPcdType() =20 # if platform do not gives pcd's value, get default value from pac= kage @@ -802,12 +831,12 @@ class ModulePcd(object): =20 if self._type_mapping[modulePcdType] =3D=3D obj.GetPcd= Type(): return obj - ErrorMsg ('Module PCD type %s does not in valied range [%s= ] in package!' % \ - (modulePcdType)) + ErrorMsg('Module PCD type %s does not in valied range [%s]= in package!' % + (modulePcdType)) else: if modulePcdType.lower() =3D=3D 'pcd': if len(platformInfos) > 1: - WarnMsg("Find more than one value for PCD %s in platfo= rm %s" % \ + WarnMsg("Find more than one value for PCD %s in platfo= rm %s" % (self._name, self._parent.GetPlatform().GetFil= ename())) return platformInfos[0] else: @@ -819,7 +848,7 @@ class ModulePcd(object): if self._type_mapping[modulePcdType] =3D=3D obj.GetPcd= Type(): return obj =20 - ErrorMsg('Can not find value for pcd %s in pcd type %s' % \ + ErrorMsg('Can not find value for pcd %s in pcd type %s' % (self._name, modulePcdType)) return None =20 @@ -832,8 +861,8 @@ class SurfaceItem(object): @return: instance of this class =20 """ - name =3D args[0] - parent =3D args[1] + name =3D args[0] + parent =3D args[1] fileObj =3D args[2] if issubclass(parent.__class__, Package): if name in cls._objs.keys(): @@ -845,19 +874,18 @@ class SurfaceItem(object): return obj elif issubclass(parent.__class__, Module): if name not in cls._objs.keys(): - ErrorMsg("%s item does not defined in any package! It is u= sed by module %s" % \ + ErrorMsg("%s item does not defined in any package! It is u= sed by module %s" % (name, parent.GetFilename())) return None return cls._objs[name] =20 return None =20 - def __init__(self, name, parent, fileObj): if issubclass(parent.__class__, Package): - self._name =3D name - self._parent =3D parent - self._decObj =3D [fileObj] + self._name =3D name + self._parent =3D parent + self._decObj =3D [fileObj] self._refMods =3D {} else: self.RefModule(parent, fileObj) @@ -879,7 +907,8 @@ class SurfaceItem(object): =20 def DeRef(self, mObj): if mObj not in self._refMods.keys(): - WarnMsg("%s is not referenced by module %s" % (self._name, mOb= j.GetFilename())) + WarnMsg("%s is not referenced by module %s" % + (self._name, mObj.GetFilename())) return del self._refMods[mObj] =20 @@ -897,16 +926,17 @@ class SurfaceItem(object): def GetDecObjects(self): return self._decObj =20 + class PcdItem(SurfaceItem): def AddDecObj(self, fileObj): for decObj in self._decObj: if decObj.GetFilename() !=3D fileObj.GetFilename(): - ErrorMsg("Pcd %s defined in more than one packages : %s an= d %s" % \ + ErrorMsg("Pcd %s defined in more than one packages : %s an= d %s" % (self._name, decObj.GetFilename(), fileObj.GetFil= ename())) return if decObj.GetPcdType() =3D=3D fileObj.GetPcdType() and \ decObj.GetArch().lower() =3D=3D fileObj.GetArch(): - ErrorMsg("Pcd %s is duplicated defined in pcd type %s in p= ackage %s" % \ + ErrorMsg("Pcd %s is duplicated defined in pcd type %s in p= ackage %s" % (self._name, decObj.GetPcdType(), decObj.GetFilen= ame())) return self._decObj.append(fileObj) @@ -918,11 +948,14 @@ class PcdItem(SurfaceItem): types +=3D obj.GetPcdType() return types =20 + class GuidItem(SurfaceItem): pass =20 + class PpiItem(SurfaceItem): pass =20 + class ProtocolItem(SurfaceItem): pass diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/dec.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/e= dk2/model/dec.py index c25ab322efd9..879c63c12f23 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= dec.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= dec.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
    # @@ -6,9 +6,11 @@ # =20 from plugins.EdkPlugins.basemodel import ini -import re, os +import re +import os from plugins.EdkPlugins.basemodel.message import * =20 + class DECFile(ini.BaseINIFile): =20 def GetSectionInstance(self, parent, name, isCombined=3DFalse): @@ -39,6 +41,7 @@ class DECFile(ini.BaseINIFile): =20 return arr =20 + class DECSection(ini.BaseINISection): def GetSectionINIObject(self, parent): type =3D self.GetType() @@ -79,10 +82,12 @@ class DECSection(ini.BaseINISection): =20 return True =20 + class DECSectionObject(ini.BaseINISectionObject): def GetArch(self): return self.GetParent().GetArch() =20 + class DECDefineSectionObject(DECSectionObject): def __init__(self, parent): DECSectionObject.__init__(self, parent) @@ -90,20 +95,21 @@ class DECDefineSectionObject(DECSectionObject): self._value =3D None =20 def Parse(self): - assert (self._start =3D=3D self._end), 'The object in define secti= on must be in single line' + assert (self._start =3D=3D + self._end), 'The object in define section must be in singl= e line' =20 line =3D self.GetLineByOffset(self._start).strip() =20 line =3D line.split('#')[0] - arr =3D line.split('=3D') + arr =3D line.split('=3D') if len(arr) !=3D 2: ErrorMsg('Invalid define section object', - self.GetFilename(), - self.GetParent().GetName() - ) + self.GetFilename(), + self.GetParent().GetName() + ) return False =20 - self._key =3D arr[0].strip() + self._key =3D arr[0].strip() self._value =3D arr[1].strip() =20 return True @@ -114,6 +120,7 @@ class DECDefineSectionObject(DECSectionObject): def GetValue(self): return self._value =20 + class DECGuidObject(DECSectionObject): _objs =3D {} =20 @@ -149,8 +156,10 @@ class DECGuidObject(DECSectionObject): def GetObjectDict(): return DECGuidObject._objs =20 + class DECPpiObject(DECSectionObject): _objs =3D {} + def __init__(self, parent): DECSectionObject.__init__(self, parent) self._name =3D None @@ -183,6 +192,7 @@ class DECPpiObject(DECSectionObject): def GetObjectDict(): return DECPpiObject._objs =20 + class DECProtocolObject(DECSectionObject): _objs =3D {} =20 @@ -214,11 +224,11 @@ class DECProtocolObject(DECSectionObject): if len(objdict[self._name]) =3D=3D 0: del objdict[self._name] =20 - @staticmethod def GetObjectDict(): return DECProtocolObject._objs =20 + class DECLibraryClassObject(DECSectionObject): _objs =3D {} =20 @@ -256,6 +266,7 @@ class DECLibraryClassObject(DECSectionObject): def GetObjectDict(): return DECLibraryClassObject._objs =20 + class DECIncludeObject(DECSectionObject): def __init__(self, parent): DECSectionObject.__init__(self, parent) @@ -263,19 +274,21 @@ class DECIncludeObject(DECSectionObject): def GetPath(self): return self.GetLineByOffset(self._start).split('#')[0].strip() =20 + class DECPcdObject(DECSectionObject): _objs =3D {} =20 def __init__(self, parent): DECSectionObject.__init__(self, parent) - self.mPcdName =3D None - self.mPcdDefaultValue =3D None - self.mPcdDataType =3D None - self.mPcdToken =3D None + self.mPcdName =3D None + self.mPcdDefaultValue =3D None + self.mPcdDataType =3D None + self.mPcdToken =3D None =20 def Parse(self): line =3D self.GetLineByOffset(self._start).strip().split('#')[0] - (self.mPcdName, self.mPcdDefaultValue, self.mPcdDataType, self.mPc= dToken) =3D line.split('|') + (self.mPcdName, self.mPcdDefaultValue, + self.mPcdDataType, self.mPcdToken) =3D line.split('|') objdict =3D DECPcdObject._objs if self.mPcdName not in objdict.keys(): objdict[self.mPcdName] =3D [self] diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/doxygengen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPl= ugins/edk2/model/doxygengen.py index 89833043c6b1..9d7d03b5749c 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen.py @@ -1,4 +1,4 @@ -## @file +# @file # # This file produce action class to generate doxygen document for edk2 cod= ebase. # The action classes are shared by GUI and command line tools. @@ -24,22 +24,24 @@ from plugins.EdkPlugins.basemodel.message import * =20 _ignore_dir =3D ['.svn', '_svn', 'cvs'] _inf_key_description_mapping_table =3D { - 'INF_VERSION':'Version of INF file specification', - #'BASE_NAME':'Module Name', - 'FILE_GUID':'Module Guid', - 'MODULE_TYPE': 'Module Type', - 'VERSION_STRING': 'Module Version', - 'LIBRARY_CLASS': 'Produced Library Class', - 'EFI_SPECIFICATION_VERSION': 'UEFI Specification Version', - 'PI_SPECIFICATION_VERSION': 'PI Specification Version', - 'ENTRY_POINT': 'Module Entry Point Function', - 'CONSTRUCTOR': 'Library Constructor Function' + 'INF_VERSION': 'Version of INF file specification', + # 'BASE_NAME':'Module Name', + 'FILE_GUID': 'Module Guid', + 'MODULE_TYPE': 'Module Type', + 'VERSION_STRING': 'Module Version', + 'LIBRARY_CLASS': 'Produced Library Class', + 'EFI_SPECIFICATION_VERSION': 'UEFI Specification Version', + 'PI_SPECIFICATION_VERSION': 'PI Specification Version', + 'ENTRY_POINT': 'Module Entry Point Function', + 'CONSTRUCTOR': 'Library Constructor Function' } =20 _dec_key_description_mapping_table =3D { - 'DEC_SPECIFICATION': 'Version of DEC file specification', - 'PACKAGE_GUID': 'Package Guid' + 'DEC_SPECIFICATION': 'Version of DEC file specification', + 'PACKAGE_GUID': 'Package Guid' } + + class DoxygenAction: """This is base class for all doxygen action. """ @@ -50,17 +52,17 @@ class DoxygenAction: @param outputPath the obosolution output path. @param log log function for output message """ - self._doxPath =3D doxPath - self._chmPath =3D chmPath - self._outputPath =3D outputPath - self._projname =3D projname - self._configFile =3D None # doxygen config file is use= d by doxygen exe file + self._doxPath =3D doxPath + self._chmPath =3D chmPath + self._outputPath =3D outputPath + self._projname =3D projname + self._configFile =3D None # doxygen config file is used b= y doxygen exe file self._indexPageFile =3D None # doxygen page file for inde= x page. - self._log =3D log - self._mode =3D mode - self._verbose =3D verbose + self._log =3D log + self._mode =3D mode + self._verbose =3D verbose self._doxygenCallback =3D None - self._chmCallback =3D None + self._chmCallback =3D None =20 def Log(self, message, level=3D'info'): if self._log is not None: @@ -71,13 +73,15 @@ class DoxygenAction: =20 def Generate(self): """Generate interface called by outer directly""" - self.Log(">>>>>> Start generate doxygen document for %s... Zzz....= \n" % self._projname) + self.Log( + ">>>>>> Start generate doxygen document for %s... Zzz....\n" %= self._projname) =20 # create doxygen config file at first self._configFile =3D doxygen.DoxygenConfigFile() self._configFile.SetOutputDir(self._outputPath) =20 - self._configFile.SetWarningFilePath(os.path.join(self._outputPath,= 'warning.txt')) + self._configFile.SetWarningFilePath( + os.path.join(self._outputPath, 'warning.txt')) if self._mode.lower() =3D=3D 'html': self._configFile.SetHtmlMode() else: @@ -92,15 +96,18 @@ class DoxygenAction: self.Log("Fail to generate index page!\n", 'error') return False else: - self.Log("Success to create doxygen index page file %s \n" % i= ndexPagePath) + self.Log("Success to create doxygen index page file %s \n" % + indexPagePath) =20 # Add index page doxygen file to file list. self._configFile.AddFile(indexPagePath) =20 # save config file to output path - configFilePath =3D os.path.join(self._outputPath, self._projname += '.doxygen_config') + configFilePath =3D os.path.join( + self._outputPath, self._projname + '.doxygen_config') self._configFile.Generate(configFilePath) - self.Log(" <<<<<< Success Save doxygen config file to %s...\n" = % configFilePath) + self.Log(" <<<<<< Success Save doxygen config file to %s...\n" % + configFilePath) =20 # launch doxygen tool to generate document if self._doxygenCallback is not None: @@ -128,17 +135,20 @@ class DoxygenAction: def RegisterCallbackCHMProcess(self, callback): self._chmCallback =3D callback =20 + class PlatformDocumentAction(DoxygenAction): """Generate platform doxygen document, will be implement at future.""" =20 + class PackageDocumentAction(DoxygenAction): """Generate package reference document""" =20 def __init__(self, doxPath, chmPath, outputPath, pObj, mode=3D'html', = log=3DNone, arch=3DNone, tooltag=3DNone, - onlyInclude=3DFalse, verbose=3DFalse): - DoxygenAction.__init__(self, doxPath, chmPath, outputPath, pObj.Ge= tName(), mode, log, verbose) - self._pObj =3D pObj - self._arch =3D arch + onlyInclude=3DFalse, verbose=3DFalse): + DoxygenAction.__init__(self, doxPath, chmPath, + outputPath, pObj.GetName(), mode, log, verb= ose) + self._pObj =3D pObj + self._arch =3D arch self._tooltag =3D tooltag self._onlyIncludeDocument =3D onlyInclude =20 @@ -166,7 +176,8 @@ class PackageDocumentAction(DoxygenAction): namestr +=3D '[%s]' % self._tooltag self._configFile.SetProjectName(namestr) self._configFile.SetStripPath(self._pObj.GetWorkspace()) - self._configFile.SetProjectVersion(self._pObj.GetFileObj().GetVers= ion()) + self._configFile.SetProjectVersion( + self._pObj.GetFileObj().GetVersion()) self._configFile.AddPattern('*.decdoxygen') =20 if self._tooltag.lower() =3D=3D 'msft': @@ -186,28 +197,32 @@ class PackageDocumentAction(DoxygenAction): =20 def GenerateIndexPage(self): """Generate doxygen index page. Inherited class should implement i= t.""" - fObj =3D self._pObj.GetFileObj() - pdObj =3D doxygen.DoxygenFile('%s Package Document' % self._pObj.= GetName(), - '%s.decdoxygen' % self._pObj.GetFilen= ame()) + fObj =3D self._pObj.GetFileObj() + pdObj =3D doxygen.DoxygenFile('%s Package Document' % self._pObj.G= etName(), + '%s.decdoxygen' % self._pObj.GetFilena= me()) self._configFile.AddFile(pdObj.GetFilename()) pdObj.AddDescription(fObj.GetFileHeader()) =20 defSection =3D fObj.GetSectionByName('defines')[0] - baseSection =3D doxygen.Section('PackageBasicInformation', 'Packag= e Basic Information') + baseSection =3D doxygen.Section( + 'PackageBasicInformation', 'Package Basic Information') descr =3D '' for obj in defSection.GetObjects(): if obj.GetKey() in _dec_key_description_mapping_table.keys(): descr +=3D '' - descr +=3D '' % _dec_key_description_map= ping_table[obj.GetKey()] + descr +=3D '' % _dec_key_description_map= ping_table[obj.GetKey( + )] descr +=3D '' % obj.GetValue() descr +=3D '' descr +=3D '
    %s%s%s

    ' baseSection.AddDescription(descr) pdObj.AddSection(baseSection) =20 - knownIssueSection =3D doxygen.Section('Known_Issue_section', 'Know= n Issue') + knownIssueSection =3D doxygen.Section( + 'Known_Issue_section', 'Known Issue') knownIssueSection.AddDescription('
      ') - knownIssueSection.AddDescription('
    • OPTIONAL macro for function= parameter can not be dealed with doxygen, so it disapear in this document!=
    • ') + knownIssueSection.AddDescription( + '
    • OPTIONAL macro for function parameter can not be dealed = with doxygen, so it disapear in this document!
    • ') knownIssueSection.AddDescription('
    ') pdObj.AddSection(knownIssueSection) =20 @@ -215,7 +230,8 @@ class PackageDocumentAction(DoxygenAction): pages =3D self.GenerateIncludesSubPage(self._pObj, self._configFil= e) if len(pages) !=3D 0: pdObj.AddPages(pages) - pages =3D self.GenerateLibraryClassesSubPage(self._pObj, self._con= figFile) + pages =3D self.GenerateLibraryClassesSubPage( + self._pObj, self._configFile) if len(pages) !=3D 0: pdObj.AddPages(pages) pages =3D self.GeneratePcdSubPages(self._pObj, self._configFile) @@ -231,7 +247,8 @@ class PackageDocumentAction(DoxygenAction): if len(pages) !=3D 0: pdObj.AddPages(pages) if not self._onlyIncludeDocument: - pdObj.AddPages(self.GenerateModulePages(self._pObj, self._conf= igFile)) + pdObj.AddPages(self.GenerateModulePages( + self._pObj, self._configFile)) =20 pdObj.Save() return pdObj.GetFilename() @@ -244,16 +261,20 @@ class PackageDocumentAction(DoxygenAction): configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Protoco= l')) configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Ppi')) configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Guid')) - configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Industr= yStandard')) + configFile.AddIncludePath(os.path.join( + pkpath, 'Include', 'IndustryStandard')) =20 rootArray =3D [] - pageRoot =3D doxygen.Page("Public Includes", "%s_public_includes" = % pObj.GetName()) + pageRoot =3D doxygen.Page( + "Public Includes", "%s_public_includes" % pObj.GetName()) objs =3D pObj.GetFileObj().GetSectionObjectsByName('includes') - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] =20 for obj in objs: # Add path to include path - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath(), = obj.GetPath()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetPath()) configFile.AddIncludePath(path) =20 # only list common folder's include file @@ -261,27 +282,35 @@ class PackageDocumentAction(DoxygenAction): continue =20 bNeedAddIncludePage =3D False - topPage =3D doxygen.Page(self._ConvertPathToDoxygen(path, pObj= ), 'public_include_top') + topPage =3D doxygen.Page(self._ConvertPathToDoxygen( + path, pObj), 'public_include_top') =20 topPage.AddDescription('
      \n') for file in os.listdir(path): - if file.lower() in _ignore_dir: continue + if file.lower() in _ignore_dir: + continue fullpath =3D os.path.join(path, file) if os.path.isfile(fullpath): - self.ProcessSourceFileForInclude(fullpath, pObj, confi= gFile) - topPage.AddDescription('
    • \link %s\endlink
    • \n'= % self._ConvertPathToDoxygen(fullpath, pObj)) + self.ProcessSourceFileForInclude( + fullpath, pObj, configFile) + topPage.AddDescription( + '
    • \link %s\endlink
    • \n' % self._ConvertPat= hToDoxygen(fullpath, pObj)) else: if file.lower() in ['library', 'protocol', 'guid', 'pp= i', 'ia32', 'x64', 'ipf', 'ebc', 'arm', 'pi', 'uefi', 'aarch64']: continue bNeedAddSubPage =3D False - subpage =3D doxygen.Page(self._ConvertPathToDoxygen(fu= llpath, pObj), 'public_include_%s' % file) + subpage =3D doxygen.Page(self._ConvertPathToDoxygen( + fullpath, pObj), 'public_include_%s' % file) subpage.AddDescription('
        \n') for subfile in os.listdir(fullpath): - if subfile.lower() in _ignore_dir: continue + if subfile.lower() in _ignore_dir: + continue bNeedAddSubPage =3D True subfullpath =3D os.path.join(fullpath, subfile) - self.ProcessSourceFileForInclude(subfullpath, pObj= , configFile) - subpage.AddDescription('
      • \link %s \endlink \n' % self._ConvertPathToDoxygen(subfullpath, pObj)) + self.ProcessSourceFileForInclude( + subfullpath, pObj, configFile) + subpage.AddDescription( + '
      • \link %s \endlink
      • \n' % self._Conve= rtPathToDoxygen(subfullpath, pObj)) subpage.AddDescription('
      \n') if bNeedAddSubPage: bNeedAddIncludePage =3D True @@ -304,9 +333,11 @@ class PackageDocumentAction(DoxygenAction): @param fObj DEC file object. """ rootArray =3D [] - pageRoot =3D doxygen.Page("Library Class", "%s_libraryclass" % pOb= j.GetName()) + pageRoot =3D doxygen.Page( + "Library Class", "%s_libraryclass" % pObj.GetName()) objs =3D pObj.GetFileObj().GetSectionObjectsByName('libraryclass',= self._arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] =20 if self._arch is not None: for obj in objs: @@ -314,17 +345,21 @@ class PackageDocumentAction(DoxygenAction): "lc_%s" % obj.GetClassName()) comments =3D obj.GetComment() if len(comments) !=3D 0: - classPage.AddDescription('
      \n'.join(comments) + '\n') + classPage.AddDescription( + '
      \n'.join(comments) + '
      \n') pageRoot.AddPage(classPage) - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath= (), obj.GetHeaderFile()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) path =3D path[len(pObj.GetWorkspace()) + 1:] if len(comments) =3D=3D 0: - classPage.AddDescription('\copydoc %s

      ' % obj.GetHea= derFile()) + classPage.AddDescription( + '\copydoc %s

      ' % obj.GetHeaderFile()) section =3D doxygen.Section('ref', 'Refer to Header File') section.AddDescription('\link %s\n' % obj.GetHeaderFile()) section.AddDescription(' \endlink

      \n') classPage.AddSection(section) - fullPath =3D os.path.join(pObj.GetFileObj().GetPackageRoot= Path(), obj.GetHeaderFile()) + fullPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e) else: archPageDict =3D {} @@ -338,17 +373,21 @@ class PackageDocumentAction(DoxygenAction): "lc_%s" % obj.GetClassName()) comments =3D obj.GetComment() if len(comments) !=3D 0: - classPage.AddDescription('
      \n'.join(comments) + '\n') + classPage.AddDescription( + '
      \n'.join(comments) + '
      \n') subArchRoot.AddPage(classPage) - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath= (), obj.GetHeaderFile()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) path =3D path[len(pObj.GetWorkspace()) + 1:] if len(comments) =3D=3D 0: - classPage.AddDescription('\copydoc %s

      ' % obj.GetHea= derFile()) + classPage.AddDescription( + '\copydoc %s

      ' % obj.GetHeaderFile()) section =3D doxygen.Section('ref', 'Refer to Header File') section.AddDescription('\link %s\n' % obj.GetHeaderFile()) section.AddDescription(' \endlink

      \n') classPage.AddSection(section) - fullPath =3D os.path.join(pObj.GetFileObj().GetPackageRoot= Path(), obj.GetHeaderFile()) + fullPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) =20 self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e) rootArray.append(pageRoot) @@ -388,10 +427,12 @@ class PackageDocumentAction(DoxygenAction): continue index =3D lines[no].lower().find('include') #mo =3D IncludePattern.finditer(lines[no].lower()) - mo =3D re.match(r"^#\s*include\s+[<\"]([\\/\w.]+)[>\"]$", line= s[no].strip().lower()) + mo =3D re.match( + r"^#\s*include\s+[<\"]([\\/\w.]+)[>\"]$", lines[no].strip(= ).lower()) if not mo: continue - mo =3D re.match(r"^[#\w\s]+[<\"]([\\/\w.]+)[>\"]$", lines[no].= strip()) + mo =3D re.match(r"^[#\w\s]+[<\"]([\\/\w.]+)[>\"]$", + lines[no].strip()) filePath =3D mo.groups()[0] =20 if filePath is None or len(filePath) =3D=3D 0: @@ -402,49 +443,60 @@ class PackageDocumentAction(DoxygenAction): =20 if os.path.exists(os.path.join(os.path.dirname(path), filePath= )): # Find the file in current directory - fullPath =3D os.path.join(os.path.dirname(path), filePath)= .replace('\\', '/') + fullPath =3D os.path.join(os.path.dirname( + path), filePath).replace('\\', '/') else: # find in depedent package's include path incObjs =3D pObj.GetFileObj().GetSectionObjectsByName('inc= ludes') for incObj in incObjs: - incPath =3D os.path.join(pObj.GetFileObj().GetPackageR= ootPath(), incObj.GetPath()).strip() + incPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), incObj.Get= Path()).strip() incPath =3D os.path.realpath(os.path.join(incPath, fil= ePath)) if os.path.exists(incPath): fullPath =3D incPath break if infObj is not None: pkgInfObjs =3D infObj.GetSectionObjectsByName('package= s') - for obj in pkgInfObjs: - decObj =3D dec.DECFile(os.path.join(pObj.GetWorksp= ace(), obj.GetPath())) + for obj in pkgInfObjs: + decObj =3D dec.DECFile(os.path.join( + pObj.GetWorkspace(), obj.GetPath())) if not decObj: - ErrorMsg ('Fail to create pacakge object for %= s' % obj.GetPackageName()) + ErrorMsg('Fail to create pacakge object for %s= ' % + obj.GetPackageName()) continue if not decObj.Parse(): - ErrorMsg ('Fail to load package object for %s'= % obj.GetPackageName()) + ErrorMsg('Fail to load package object for %s' % + obj.GetPackageName()) continue incObjs =3D decObj.GetSectionObjectsByName('includ= es') for incObj in incObjs: - incPath =3D os.path.join(decObj.GetPackageRoot= Path(), incObj.GetPath()).replace('\\', '/') + incPath =3D os.path.join( + decObj.GetPackageRootPath(), incObj.GetPat= h()).replace('\\', '/') if os.path.exists(os.path.join(incPath, filePa= th)): - fullPath =3D os.path.join(os.path.join(inc= Path, filePath)) + fullPath =3D os.path.join( + os.path.join(incPath, filePath)) break if fullPath is not None: break =20 if fullPath is None and self.IsVerbose(): - self.Log('Can not resolve header file %s for file %s in pa= ckage %s\n' % (filePath, path, pObj.GetFileObj().GetFilename()), 'error') + self.Log('Can not resolve header file %s for file %s in pa= ckage %s\n' % ( + filePath, path, pObj.GetFileObj().GetFilename()), 'err= or') return else: fullPath =3D fullPath.replace('\\', '/') if self.IsVerbose(): - self.Log('Preprocessing: Add include file %s for file = %s\n' % (fullPath, path)) + self.Log('Preprocessing: Add include file %s for file = %s\n' % ( + fullPath, path)) #LogMsg ('Preprocessing: Add include file %s for file %s' = % (fullPath, path)) - self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e, infObj) + self.ProcessSourceFileForInclude( + fullPath, pObj, configFile, infObj) =20 def AddAllIncludeFiles(self, pObj, configFile): objs =3D pObj.GetFileObj().GetSectionObjectsByName('includes') for obj in objs: - incPath =3D os.path.join(pObj.GetFileObj().GetPackageRootPath(= ), obj.GetPath()) + incPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetPath()) for root, dirs, files in os.walk(incPath): for dir in dirs: if dir.lower() in _ignore_dir: @@ -469,15 +521,17 @@ class PackageDocumentAction(DoxygenAction): typeArchRootPageDict =3D {} for obj in objs: if obj.GetPcdType() not in typeRootPageDict.keys(): - typeRootPageDict[obj.GetPcdType()] =3D doxygen.Page(obj.Ge= tPcdType(), 'pcd_%s_root_page' % obj.GetPcdType()) + typeRootPageDict[obj.GetPcdType()] =3D doxygen.Page( + obj.GetPcdType(), 'pcd_%s_root_page' % obj.GetPcdType(= )) pcdRootPage.AddPage(typeRootPageDict[obj.GetPcdType()]) typeRoot =3D typeRootPageDict[obj.GetPcdType()] if self._arch is not None: pcdPage =3D doxygen.Page('%s' % obj.GetPcdName(), - 'pcd_%s_%s_%s' % (obj.GetPcdType()= , obj.GetArch(), obj.GetPcdName().split('.')[1])) - pcdPage.AddDescription('
      \n'.join(obj.GetComment()) + '=
      \n') + 'pcd_%s_%s_%s' % (obj.GetPcdType(),= obj.GetArch(), obj.GetPcdName().split('.')[1])) + pcdPage.AddDescription( + '
      \n'.join(obj.GetComment()) + '
      \n') section =3D doxygen.Section('PCDinformation', 'PCD Informa= tion') - desc =3D '' + desc =3D '
      ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -486,8 +540,10 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' desc +=3D '' - desc +=3D '' % obj.GetPcdNam= e().split('.')[1] - desc +=3D '' % obj.GetPcdNam= e().split('.')[0] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 1] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 0] desc +=3D '' % obj.GetPcdTok= en() desc +=3D '' % obj.GetPcdDat= aType() desc +=3D '' % obj.GetPcdVal= ue() @@ -499,15 +555,17 @@ class PackageDocumentAction(DoxygenAction): else: keystr =3D obj.GetPcdType() + obj.GetArch() if keystr not in typeArchRootPageDict.keys(): - typeArchRootPage =3D doxygen.Page(obj.GetArch(), 'pcd_= %s_%s_root_page' % (obj.GetPcdType(), obj.GetArch())) + typeArchRootPage =3D doxygen.Page( + obj.GetArch(), 'pcd_%s_%s_root_page' % (obj.GetPcd= Type(), obj.GetArch())) typeArchRootPageDict[keystr] =3D typeArchRootPage typeRoot.AddPage(typeArchRootPage) typeArchRoot =3D typeArchRootPageDict[keystr] pcdPage =3D doxygen.Page('%s' % obj.GetPcdName(), - 'pcd_%s_%s_%s' % (obj.GetPcdType()= , obj.GetArch(), obj.GetPcdName().split('.')[1])) - pcdPage.AddDescription('
      \n'.join(obj.GetComment()) + '=
      \n') + 'pcd_%s_%s_%s' % (obj.GetPcdType(),= obj.GetArch(), obj.GetPcdName().split('.')[1])) + pcdPage.AddDescription( + '
      \n'.join(obj.GetComment()) + '
      \n') section =3D doxygen.Section('PCDinformation', 'PCD Informa= tion') - desc =3D '
      Name
      Token Space
      Default Value
      %s
      %s
      %s
      %s
      %s
      %s
      %s
      ' + desc =3D '
      ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -516,8 +574,10 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' desc +=3D '' - desc +=3D '' % obj.GetPcdNam= e().split('.')[1] - desc +=3D '' % obj.GetPcdNam= e().split('.')[0] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 1] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 0] desc +=3D '' % obj.GetPcdTok= en() desc +=3D '' % obj.GetPcdDat= aType() desc +=3D '' % obj.GetPcdVal= ue() @@ -535,7 +595,7 @@ class PackageDocumentAction(DoxygenAction): if len(comments) !=3D 0: guidPage.AddDescription('
      '.join(obj.GetComment()) + '
      ') section =3D doxygen.Section('BasicGuidInfo', 'GUID Information') - desc =3D '
      Name
      Token Space
      Default Value
      %s
      %s
      %s
      %s
      %s
      %s
      %s
      ' + desc =3D '
      ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -567,19 +627,23 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('GUID', 'guid_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('guids', self._= arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GenerateGuidSubPage(pObj, obj, conf= igFile)) + pageRoot.AddPage( + self._GenerateGuidSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'guid_arc= h_root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'guid_arch_root_%s' % obj.GetArch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GenerateGuidSubPage(pObj, obj, = configFile)) + guidArchRoot.AddPage( + self._GenerateGuidSubPage(pObj, obj, configFile)) return [pageRoot] =20 def _GeneratePpiSubPage(self, pObj, obj, configFile): @@ -588,7 +652,7 @@ class PackageDocumentAction(DoxygenAction): if len(comments) !=3D 0: guidPage.AddDescription('
      '.join(obj.GetComment()) + '
      ') section =3D doxygen.Section('BasicPpiInfo', 'PPI Information') - desc =3D '
      GUID\'s Guid Name
      GUID\'s Guid
      ' + desc =3D '
      ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -620,28 +684,33 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('PPI', 'ppi_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('ppis', self._a= rch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GeneratePpiSubPage(pObj, obj, confi= gFile)) + pageRoot.AddPage( + self._GeneratePpiSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'ppi_arch= _root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'ppi_arch_root_%s' % obj.GetArch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GeneratePpiSubPage(pObj, obj, c= onfigFile)) + guidArchRoot.AddPage( + self._GeneratePpiSubPage(pObj, obj, configFile)) return [pageRoot] =20 def _GenerateProtocolSubPage(self, pObj, obj, configFile): - guidPage =3D doxygen.Page(obj.GetName(), 'protocol_page_%s' % obj.= GetName()) + guidPage =3D doxygen.Page( + obj.GetName(), 'protocol_page_%s' % obj.GetName()) comments =3D obj.GetComment() if len(comments) !=3D 0: guidPage.AddDescription('
      '.join(obj.GetComment()) + '
      ') section =3D doxygen.Section('BasicProtocolInfo', 'PROTOCOL Informa= tion') - desc =3D '
      PPI\'s Guid Name
      PPI\'s Guid
      ' + desc =3D '
      ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -674,19 +743,23 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('PROTOCOL', 'protocol_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('protocols', se= lf._arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GenerateProtocolSubPage(pObj, obj, = configFile)) + pageRoot.AddPage( + self._GenerateProtocolSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'protocol= _arch_root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'protocol_arch_root_%s' % obj.GetAr= ch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GenerateProtocolSubPage(pObj, o= bj, configFile)) + guidArchRoot.AddPage( + self._GenerateProtocolSubPage(pObj, obj, configFile)) return [pageRoot] =20 def FindHeaderFileForGuid(self, pObj, name, configFile): @@ -699,8 +772,8 @@ class PackageDocumentAction(DoxygenAction): =20 @return full path of header file and None if not found. """ - startPath =3D pObj.GetFileObj().GetPackageRootPath() - incPath =3D os.path.join(startPath, 'Include').replace('\\', '/= ') + startPath =3D pObj.GetFileObj().GetPackageRootPath() + incPath =3D os.path.join(startPath, 'Include').replace('\\', '/') # if /include exist, then search header under it. if os.path.exists(incPath): startPath =3D incPath @@ -760,7 +833,7 @@ class PackageDocumentAction(DoxygenAction): modObjs =3D [] for infpath in infList: infObj =3D inf.INFFile(infpath) - #infObj =3D INFFileObject.INFFile (pObj.GetWorkspacePath(), + # infObj =3D INFFileObject.INFFile (pObj.GetWorkspacePath(), # inf) if not infObj: self.Log('Fail create INF object for %s' % inf) @@ -777,13 +850,15 @@ class PackageDocumentAction(DoxygenAction): libRootPage =3D doxygen.Page('Libraries', 'lib_root_page') rootPages.append(libRootPage) for libInf in libObjs: - libRootPage.AddPage(self.GenerateModulePage(pObj, libInf, = configFile, True)) + libRootPage.AddPage(self.GenerateModulePage( + pObj, libInf, configFile, True)) =20 if len(modObjs) !=3D 0: modRootPage =3D doxygen.Page('Modules', 'module_root_page') rootPages.append(modRootPage) for modInf in modObjs: - modRootPage.AddPage(self.GenerateModulePage(pObj, modInf, = configFile, False)) + modRootPage.AddPage(self.GenerateModulePage( + pObj, modInf, configFile, False)) =20 return rootPages =20 @@ -798,13 +873,15 @@ class PackageDocumentAction(DoxygenAction): """ workspace =3D pObj.GetWorkspace() refDecObjs =3D [] - for obj in infObj.GetSectionObjectsByName('packages'): + for obj in infObj.GetSectionObjectsByName('packages'): decObj =3D dec.DECFile(os.path.join(workspace, obj.GetPath())) if not decObj: - ErrorMsg ('Fail to create pacakge object for %s' % obj.Get= PackageName()) + ErrorMsg('Fail to create pacakge object for %s' % + obj.GetPackageName()) continue if not decObj.Parse(): - ErrorMsg ('Fail to load package object for %s' % obj.GetPa= ckageName()) + ErrorMsg('Fail to load package object for %s' % + obj.GetPackageName()) continue refDecObjs.append(decObj) =20 @@ -812,12 +889,14 @@ class PackageDocumentAction(DoxygenAction): 'module_%s' % infObj.GetBaseName()) modPage.AddDescription(infObj.GetFileHeader()) =20 - basicInfSection =3D doxygen.Section('BasicModuleInformation', 'Bas= ic Module Information') + basicInfSection =3D doxygen.Section( + 'BasicModuleInformation', 'Basic Module Information') desc =3D "
      PROTOCOL\'s Guid Name
      PROTOCOL\'s Guid
      " for obj in infObj.GetSectionObjectsByName('defines'): key =3D obj.GetKey() value =3D obj.GetValue() - if key not in _inf_key_description_mapping_table.keys(): conti= nue + if key not in _inf_key_description_mapping_table.keys(): + continue if key =3D=3D 'LIBRARY_CLASS' and value.find('|') !=3D -1: clsname, types =3D value.split('|') desc +=3D '' @@ -841,7 +920,7 @@ class PackageDocumentAction(DoxygenAction): modPage.AddSection(basicInfSection) =20 # Add protocol section - data =3D [] + data =3D [] for obj in infObj.GetSectionObjectsByName('pcd', self._arch): data.append(obj.GetPcdName().strip()) if len(data) !=3D 0: @@ -852,7 +931,8 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' % item.split('.')[1] desc +=3D '' % item.split('.')[0] - pkgbasename =3D self.SearchPcdPackage(item, workspace, ref= DecObjs) + pkgbasename =3D self.SearchPcdPackage( + item, workspace, refDecObjs) desc +=3D '' % pkgbasename desc +=3D '' desc +=3D "
      %s%s%s
      " @@ -861,8 +941,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add protocol section #sects =3D infObj.GetSectionByString('protocol') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('protocol', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -872,7 +952,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchProtocolPackage(item, workspace= , refDecObjs) + pkgbasename =3D self.SearchProtocolPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -881,8 +962,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add ppi section #sects =3D infObj.GetSectionByString('ppi') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('ppi', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -892,7 +973,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchPpiPackage(item, workspace, ref= DecObjs) + pkgbasename =3D self.SearchPpiPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -901,8 +983,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add guid section #sects =3D infObj.GetSectionByString('guid') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('guid', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -912,7 +994,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchGuidPackage(item, workspace, re= fDecObjs) + pkgbasename =3D self.SearchGuidPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -928,12 +1011,13 @@ class PackageDocumentAction(DoxygenAction): desc +=3D 'Produce' try: pkgname, hPath =3D self.SearchLibraryClassHeaderFile(infOb= j.GetProduceLibraryClass(), - workspace, - refDecObjs) + workspa= ce, + refDecO= bjs) except: - self.Log ('fail to get package header file for lib class %= s' % infObj.GetProduceLibraryClass()) + self.Log('fail to get package header file for lib class %s= ' % + infObj.GetProduceLibraryClass()) pkgname =3D 'NULL' - hPath =3D 'NULL' + hPath =3D 'NULL' desc +=3D '%s' % pkgname if hPath !=3D "NULL": desc +=3D '\link %s \endlink' % hPath @@ -949,9 +1033,10 @@ class PackageDocumentAction(DoxygenAction): if retarr is not None: pkgname, hPath =3D retarr else: - self.Log('Fail find the library class %s definition from m= odule %s dependent package!' % (lcObj.GetClass(), infObj.GetFilename()), 'e= rror') + self.Log('Fail find the library class %s definition from m= odule %s dependent package!' % ( + lcObj.GetClass(), infObj.GetFilename()), 'error') pkgname =3D 'NULL' - hPath =3D 'NULL' + hPath =3D 'NULL' desc +=3D 'Consume' desc +=3D '%s' % pkgname desc +=3D '\link %s \endlink' % hPath @@ -964,22 +1049,25 @@ class PackageDocumentAction(DoxygenAction): section.AddDescription('

        \n') for obj in infObj.GetSourceObjects(self._arch, self._tooltag): sPath =3D infObj.GetModuleRootPath() - sPath =3D os.path.join(sPath, obj.GetSourcePath()).replace('\\= ', '/').strip() + sPath =3D os.path.join(sPath, obj.GetSourcePath() + ).replace('\\', '/').strip() if sPath.lower().endswith('.uni') or sPath.lower().endswith('.= s') or sPath.lower().endswith('.asm') or sPath.lower().endswith('.nasm'): newPath =3D self.TranslateUniFile(sPath) configFile.AddFile(newPath) newPath =3D newPath[len(pObj.GetWorkspace()) + 1:] - section.AddDescription('
      • \link %s \endlink
      • ' % n= ewPath) + section.AddDescription( + '
      • \link %s \endlink
      • ' % newPath) else: - self.ProcessSourceFileForInclude(sPath, pObj, configFile, = infObj) + self.ProcessSourceFileForInclude( + sPath, pObj, configFile, infObj) sPath =3D sPath[len(pObj.GetWorkspace()) + 1:] section.AddDescription('
      • \link %s \endlink
      • ' % sPa= th) section.AddDescription('
      \n') modPage.AddSection(section) =20 #sects =3D infObj.GetSectionByString('depex') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('depex'): data.append(str(obj)) if len(data) !=3D 0: @@ -1029,35 +1117,35 @@ class PackageDocumentAction(DoxygenAction): return newpath =20 def SearchPcdPackage(self, pcdname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for pcd in decObj.GetSectionObjectsByName('pcd'): if pcdname =3D=3D pcd.GetPcdName(): return decObj.GetBaseName() return None =20 def SearchProtocolPackage(self, protname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for proto in decObj.GetSectionObjectsByName('protocol'): if protname =3D=3D proto.GetName(): return decObj.GetBaseName() return None =20 def SearchPpiPackage(self, ppiname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for ppi in decObj.GetSectionObjectsByName('ppi'): if ppiname =3D=3D ppi.GetName(): return decObj.GetBaseName() return None =20 def SearchGuidPackage(self, guidname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for guid in decObj.GetSectionObjectsByName('guid'): if guidname =3D=3D guid.GetName(): return decObj.GetBaseName() return None =20 def SearchLibraryClassHeaderFile(self, className, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for cls in decObj.GetSectionObjectsByName('libraryclasses'): if cls.GetClassName().strip() =3D=3D className: path =3D cls.GetHeaderFile().strip() @@ -1072,9 +1160,11 @@ class PackageDocumentAction(DoxygenAction): path =3D path[len(pRootPath) + 1:] return path.replace('\\', '/') =20 + def IsCHeaderFile(path): return CheckPathPostfix(path, 'h') =20 + def CheckPathPostfix(path, str): index =3D path.rfind('.') if index =3D=3D -1: diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/doxygengen_spec.py b/BaseTools/Scripts/PackageDocumentTools/plugins/= EdkPlugins/edk2/model/doxygengen_spec.py index e37938c466a2..56e1a637c0ff 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen_spec.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen_spec.py @@ -1,4 +1,4 @@ -## @file +# @file # # This file produce action class to generate doxygen document for edk2 cod= ebase. # The action classes are shared by GUI and command line tools. @@ -21,22 +21,24 @@ from plugins.EdkPlugins.basemodel.message import * =20 _ignore_dir =3D ['.svn', '_svn', 'cvs'] _inf_key_description_mapping_table =3D { - 'INF_VERSION':'Version of INF file specification', - #'BASE_NAME':'Module Name', - 'FILE_GUID':'Module Guid', - 'MODULE_TYPE': 'Module Type', - 'VERSION_STRING': 'Module Version', - 'LIBRARY_CLASS': 'Produced Library Class', - 'EFI_SPECIFICATION_VERSION': 'UEFI Specification Version', - 'PI_SPECIFICATION_VERSION': 'PI Specification Version', - 'ENTRY_POINT': 'Module Entry Point Function', - 'CONSTRUCTOR': 'Library Constructor Function' + 'INF_VERSION': 'Version of INF file specification', + # 'BASE_NAME':'Module Name', + 'FILE_GUID': 'Module Guid', + 'MODULE_TYPE': 'Module Type', + 'VERSION_STRING': 'Module Version', + 'LIBRARY_CLASS': 'Produced Library Class', + 'EFI_SPECIFICATION_VERSION': 'UEFI Specification Version', + 'PI_SPECIFICATION_VERSION': 'PI Specification Version', + 'ENTRY_POINT': 'Module Entry Point Function', + 'CONSTRUCTOR': 'Library Constructor Function' } =20 _dec_key_description_mapping_table =3D { - 'DEC_SPECIFICATION': 'Version of DEC file specification', - 'PACKAGE_GUID': 'Package Guid' + 'DEC_SPECIFICATION': 'Version of DEC file specification', + 'PACKAGE_GUID': 'Package Guid' } + + class DoxygenAction: """This is base class for all doxygen action. """ @@ -47,17 +49,17 @@ class DoxygenAction: @param outputPath the obosolution output path. @param log log function for output message """ - self._doxPath =3D doxPath - self._chmPath =3D chmPath - self._outputPath =3D outputPath - self._projname =3D projname - self._configFile =3D None # doxygen config file is use= d by doxygen exe file + self._doxPath =3D doxPath + self._chmPath =3D chmPath + self._outputPath =3D outputPath + self._projname =3D projname + self._configFile =3D None # doxygen config file is used b= y doxygen exe file self._indexPageFile =3D None # doxygen page file for inde= x page. - self._log =3D log - self._mode =3D mode - self._verbose =3D verbose + self._log =3D log + self._mode =3D mode + self._verbose =3D verbose self._doxygenCallback =3D None - self._chmCallback =3D None + self._chmCallback =3D None =20 def Log(self, message, level=3D'info'): if self._log is not None: @@ -68,13 +70,15 @@ class DoxygenAction: =20 def Generate(self): """Generate interface called by outer directly""" - self.Log(">>>>>> Start generate doxygen document for %s... Zzz....= \n" % self._projname) + self.Log( + ">>>>>> Start generate doxygen document for %s... Zzz....\n" %= self._projname) =20 # create doxygen config file at first self._configFile =3D doxygen.DoxygenConfigFile() self._configFile.SetOutputDir(self._outputPath) =20 - self._configFile.SetWarningFilePath(os.path.join(self._outputPath,= 'warning.txt')) + self._configFile.SetWarningFilePath( + os.path.join(self._outputPath, 'warning.txt')) if self._mode.lower() =3D=3D 'html': self._configFile.SetHtmlMode() else: @@ -89,15 +93,18 @@ class DoxygenAction: self.Log("Fail to generate index page!\n", 'error') return False else: - self.Log("Success to create doxygen index page file %s \n" % i= ndexPagePath) + self.Log("Success to create doxygen index page file %s \n" % + indexPagePath) =20 # Add index page doxygen file to file list. self._configFile.AddFile(indexPagePath) =20 # save config file to output path - configFilePath =3D os.path.join(self._outputPath, self._projname += '.doxygen_config') + configFilePath =3D os.path.join( + self._outputPath, self._projname + '.doxygen_config') self._configFile.Generate(configFilePath) - self.Log(" <<<<<< Success Save doxygen config file to %s...\n" = % configFilePath) + self.Log(" <<<<<< Success Save doxygen config file to %s...\n" % + configFilePath) =20 # launch doxygen tool to generate document if self._doxygenCallback is not None: @@ -125,17 +132,20 @@ class DoxygenAction: def RegisterCallbackCHMProcess(self, callback): self._chmCallback =3D callback =20 + class PlatformDocumentAction(DoxygenAction): """Generate platform doxygen document, will be implement at future.""" =20 + class PackageDocumentAction(DoxygenAction): """Generate package reference document""" =20 def __init__(self, doxPath, chmPath, outputPath, pObj, mode=3D'html', = log=3DNone, arch=3DNone, tooltag=3DNone, macros=3D[], onlyInclude=3DFalse, verbose=3DFalse): - DoxygenAction.__init__(self, doxPath, chmPath, outputPath, pObj.Ge= tName(), mode, log, verbose) - self._pObj =3D pObj - self._arch =3D arch + DoxygenAction.__init__(self, doxPath, chmPath, + outputPath, pObj.GetName(), mode, log, verb= ose) + self._pObj =3D pObj + self._arch =3D arch self._tooltag =3D tooltag self._macros =3D macros self._onlyIncludeDocument =3D onlyInclude @@ -167,7 +177,8 @@ class PackageDocumentAction(DoxygenAction): namestr +=3D '[%s]' % self._tooltag self._configFile.SetProjectName(namestr) self._configFile.SetStripPath(self._pObj.GetWorkspace()) - self._configFile.SetProjectVersion(self._pObj.GetFileObj().GetVers= ion()) + self._configFile.SetProjectVersion( + self._pObj.GetFileObj().GetVersion()) self._configFile.AddPattern('*.decdoxygen') =20 if self._tooltag.lower() =3D=3D 'msft': @@ -187,28 +198,32 @@ class PackageDocumentAction(DoxygenAction): =20 def GenerateIndexPage(self): """Generate doxygen index page. Inherited class should implement i= t.""" - fObj =3D self._pObj.GetFileObj() - pdObj =3D doxygen.DoxygenFile('%s Package Document' % self._pObj.= GetName(), - '%s.decdoxygen' % self._pObj.GetFilen= ame()) + fObj =3D self._pObj.GetFileObj() + pdObj =3D doxygen.DoxygenFile('%s Package Document' % self._pObj.G= etName(), + '%s.decdoxygen' % self._pObj.GetFilena= me()) self._configFile.AddFile(pdObj.GetFilename()) pdObj.AddDescription(fObj.GetFileHeader()) =20 defSection =3D fObj.GetSectionByName('defines')[0] - baseSection =3D doxygen.Section('PackageBasicInformation', 'Packag= e Basic Information') + baseSection =3D doxygen.Section( + 'PackageBasicInformation', 'Package Basic Information') descr =3D '' for obj in defSection.GetObjects(): if obj.GetKey() in _dec_key_description_mapping_table.keys(): descr +=3D '' - descr +=3D '' % _dec_key_description_map= ping_table[obj.GetKey()] + descr +=3D '' % _dec_key_description_map= ping_table[obj.GetKey( + )] descr +=3D '' % obj.GetValue() descr +=3D '' descr +=3D '
      %s%s%s

      ' baseSection.AddDescription(descr) pdObj.AddSection(baseSection) =20 - knownIssueSection =3D doxygen.Section('Known_Issue_section', 'Know= n Issue') + knownIssueSection =3D doxygen.Section( + 'Known_Issue_section', 'Known Issue') knownIssueSection.AddDescription('
        ') - knownIssueSection.AddDescription('
      • OPTIONAL macro for function= parameter can not be dealed with doxygen, so it disapear in this document!=
      • ') + knownIssueSection.AddDescription( + '
      • OPTIONAL macro for function parameter can not be dealed = with doxygen, so it disapear in this document!
      • ') knownIssueSection.AddDescription('
      ') pdObj.AddSection(knownIssueSection) =20 @@ -216,7 +231,8 @@ class PackageDocumentAction(DoxygenAction): pages =3D self.GenerateIncludesSubPage(self._pObj, self._configFil= e) if len(pages) !=3D 0: pdObj.AddPages(pages) - pages =3D self.GenerateLibraryClassesSubPage(self._pObj, self._con= figFile) + pages =3D self.GenerateLibraryClassesSubPage( + self._pObj, self._configFile) if len(pages) !=3D 0: pdObj.AddPages(pages) pages =3D self.GeneratePcdSubPages(self._pObj, self._configFile) @@ -232,7 +248,8 @@ class PackageDocumentAction(DoxygenAction): if len(pages) !=3D 0: pdObj.AddPages(pages) if not self._onlyIncludeDocument: - pdObj.AddPages(self.GenerateModulePages(self._pObj, self._conf= igFile)) + pdObj.AddPages(self.GenerateModulePages( + self._pObj, self._configFile)) =20 pdObj.Save() return pdObj.GetFilename() @@ -245,16 +262,20 @@ class PackageDocumentAction(DoxygenAction): configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Protoco= l')) configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Ppi')) configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Guid')) - configFile.AddIncludePath(os.path.join(pkpath, 'Include', 'Industr= yStandard')) + configFile.AddIncludePath(os.path.join( + pkpath, 'Include', 'IndustryStandard')) =20 rootArray =3D [] - pageRoot =3D doxygen.Page("Public Includes", "%s_public_includes" = % pObj.GetName()) + pageRoot =3D doxygen.Page( + "Public Includes", "%s_public_includes" % pObj.GetName()) objs =3D pObj.GetFileObj().GetSectionObjectsByName('includes') - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] =20 for obj in objs: # Add path to include path - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath(), = obj.GetPath()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetPath()) configFile.AddIncludePath(path) =20 # only list common folder's include file @@ -262,27 +283,35 @@ class PackageDocumentAction(DoxygenAction): continue =20 bNeedAddIncludePage =3D False - topPage =3D doxygen.Page(self._ConvertPathToDoxygen(path, pObj= ), 'public_include_top') + topPage =3D doxygen.Page(self._ConvertPathToDoxygen( + path, pObj), 'public_include_top') =20 topPage.AddDescription('
        \n') for file in os.listdir(path): - if file.lower() in _ignore_dir: continue + if file.lower() in _ignore_dir: + continue fullpath =3D os.path.join(path, file) if os.path.isfile(fullpath): - self.ProcessSourceFileForInclude(fullpath, pObj, confi= gFile) - topPage.AddDescription('
      • \link %s\endlink
      • \n'= % self._ConvertPathToDoxygen(fullpath, pObj)) + self.ProcessSourceFileForInclude( + fullpath, pObj, configFile) + topPage.AddDescription( + '
      • \link %s\endlink
      • \n' % self._ConvertPat= hToDoxygen(fullpath, pObj)) else: if file.lower() in ['library', 'protocol', 'guid', 'pp= i', 'ia32', 'x64', 'ipf', 'ebc', 'arm', 'pi', 'uefi', 'aarch64']: continue bNeedAddSubPage =3D False - subpage =3D doxygen.Page(self._ConvertPathToDoxygen(fu= llpath, pObj), 'public_include_%s' % file) + subpage =3D doxygen.Page(self._ConvertPathToDoxygen( + fullpath, pObj), 'public_include_%s' % file) subpage.AddDescription('
          \n') for subfile in os.listdir(fullpath): - if subfile.lower() in _ignore_dir: continue + if subfile.lower() in _ignore_dir: + continue bNeedAddSubPage =3D True subfullpath =3D os.path.join(fullpath, subfile) - self.ProcessSourceFileForInclude(subfullpath, pObj= , configFile) - subpage.AddDescription('
        • \link %s \endlink \n' % self._ConvertPathToDoxygen(subfullpath, pObj)) + self.ProcessSourceFileForInclude( + subfullpath, pObj, configFile) + subpage.AddDescription( + '
        • \link %s \endlink
        • \n' % self._Conve= rtPathToDoxygen(subfullpath, pObj)) subpage.AddDescription('
        \n') if bNeedAddSubPage: bNeedAddIncludePage =3D True @@ -305,9 +334,11 @@ class PackageDocumentAction(DoxygenAction): @param fObj DEC file object. """ rootArray =3D [] - pageRoot =3D doxygen.Page("Library Class", "%s_libraryclass" % pOb= j.GetName()) + pageRoot =3D doxygen.Page( + "Library Class", "%s_libraryclass" % pObj.GetName()) objs =3D pObj.GetFileObj().GetSectionObjectsByName('libraryclass',= self._arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] =20 if self._arch is not None: for obj in objs: @@ -315,17 +346,21 @@ class PackageDocumentAction(DoxygenAction): "lc_%s" % obj.GetClassName()) comments =3D obj.GetComment() if len(comments) !=3D 0: - classPage.AddDescription('
        \n'.join(comments) + '\n') + classPage.AddDescription( + '
        \n'.join(comments) + '
        \n') pageRoot.AddPage(classPage) - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath= (), obj.GetHeaderFile()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) path =3D path[len(pObj.GetWorkspace()) + 1:] if len(comments) =3D=3D 0: - classPage.AddDescription('\copydoc %s

        ' % obj.GetHea= derFile()) + classPage.AddDescription( + '\copydoc %s

        ' % obj.GetHeaderFile()) section =3D doxygen.Section('ref', 'Refer to Header File') section.AddDescription('\link %s\n' % obj.GetHeaderFile()) section.AddDescription(' \endlink

        \n') classPage.AddSection(section) - fullPath =3D os.path.join(pObj.GetFileObj().GetPackageRoot= Path(), obj.GetHeaderFile()) + fullPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e) else: archPageDict =3D {} @@ -339,17 +374,21 @@ class PackageDocumentAction(DoxygenAction): "lc_%s" % obj.GetClassName()) comments =3D obj.GetComment() if len(comments) !=3D 0: - classPage.AddDescription('
        \n'.join(comments) + '\n') + classPage.AddDescription( + '
        \n'.join(comments) + '
        \n') subArchRoot.AddPage(classPage) - path =3D os.path.join(pObj.GetFileObj().GetPackageRootPath= (), obj.GetHeaderFile()) + path =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) path =3D path[len(pObj.GetWorkspace()) + 1:] if len(comments) =3D=3D 0: - classPage.AddDescription('\copydoc %s

        ' % obj.GetHea= derFile()) + classPage.AddDescription( + '\copydoc %s

        ' % obj.GetHeaderFile()) section =3D doxygen.Section('ref', 'Refer to Header File') section.AddDescription('\link %s\n' % obj.GetHeaderFile()) section.AddDescription(' \endlink

        \n') classPage.AddSection(section) - fullPath =3D os.path.join(pObj.GetFileObj().GetPackageRoot= Path(), obj.GetHeaderFile()) + fullPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetHeaderF= ile()) =20 self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e) rootArray.append(pageRoot) @@ -389,10 +428,12 @@ class PackageDocumentAction(DoxygenAction): continue index =3D lines[no].lower().find('include') #mo =3D IncludePattern.finditer(lines[no].lower()) - mo =3D re.match(r"^#\s*include\s+[<\"]([\\/\w.]+)[>\"]$", line= s[no].strip().lower()) + mo =3D re.match( + r"^#\s*include\s+[<\"]([\\/\w.]+)[>\"]$", lines[no].strip(= ).lower()) if not mo: continue - mo =3D re.match(r"^[#\w\s]+[<\"]([\\/\w.]+)[>\"]$", lines[no].= strip()) + mo =3D re.match(r"^[#\w\s]+[<\"]([\\/\w.]+)[>\"]$", + lines[no].strip()) filePath =3D mo.groups()[0] =20 if filePath is None or len(filePath) =3D=3D 0: @@ -403,49 +444,60 @@ class PackageDocumentAction(DoxygenAction): =20 if os.path.exists(os.path.join(os.path.dirname(path), filePath= )): # Find the file in current directory - fullPath =3D os.path.join(os.path.dirname(path), filePath)= .replace('\\', '/') + fullPath =3D os.path.join(os.path.dirname( + path), filePath).replace('\\', '/') else: # find in depedent package's include path incObjs =3D pObj.GetFileObj().GetSectionObjectsByName('inc= ludes') for incObj in incObjs: - incPath =3D os.path.join(pObj.GetFileObj().GetPackageR= ootPath(), incObj.GetPath()).strip() + incPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), incObj.Get= Path()).strip() incPath =3D os.path.realpath(os.path.join(incPath, fil= ePath)) if os.path.exists(incPath): fullPath =3D incPath break if infObj is not None: pkgInfObjs =3D infObj.GetSectionObjectsByName('package= s') - for obj in pkgInfObjs: - decObj =3D dec.DECFile(os.path.join(pObj.GetWorksp= ace(), obj.GetPath())) + for obj in pkgInfObjs: + decObj =3D dec.DECFile(os.path.join( + pObj.GetWorkspace(), obj.GetPath())) if not decObj: - ErrorMsg ('Fail to create pacakge object for %= s' % obj.GetPackageName()) + ErrorMsg('Fail to create pacakge object for %s= ' % + obj.GetPackageName()) continue if not decObj.Parse(): - ErrorMsg ('Fail to load package object for %s'= % obj.GetPackageName()) + ErrorMsg('Fail to load package object for %s' % + obj.GetPackageName()) continue incObjs =3D decObj.GetSectionObjectsByName('includ= es') for incObj in incObjs: - incPath =3D os.path.join(decObj.GetPackageRoot= Path(), incObj.GetPath()).replace('\\', '/') + incPath =3D os.path.join( + decObj.GetPackageRootPath(), incObj.GetPat= h()).replace('\\', '/') if os.path.exists(os.path.join(incPath, filePa= th)): - fullPath =3D os.path.join(os.path.join(inc= Path, filePath)) + fullPath =3D os.path.join( + os.path.join(incPath, filePath)) break if fullPath is not None: break =20 if fullPath is None and self.IsVerbose(): - self.Log('Can not resolve header file %s for file %s in pa= ckage %s\n' % (filePath, path, pObj.GetFileObj().GetFilename()), 'error') + self.Log('Can not resolve header file %s for file %s in pa= ckage %s\n' % ( + filePath, path, pObj.GetFileObj().GetFilename()), 'err= or') return else: fullPath =3D fullPath.replace('\\', '/') if self.IsVerbose(): - self.Log('Preprocessing: Add include file %s for file = %s\n' % (fullPath, path)) + self.Log('Preprocessing: Add include file %s for file = %s\n' % ( + fullPath, path)) #LogMsg ('Preprocessing: Add include file %s for file %s' = % (fullPath, path)) - self.ProcessSourceFileForInclude(fullPath, pObj, configFil= e, infObj) + self.ProcessSourceFileForInclude( + fullPath, pObj, configFile, infObj) =20 def AddAllIncludeFiles(self, pObj, configFile): objs =3D pObj.GetFileObj().GetSectionObjectsByName('includes') for obj in objs: - incPath =3D os.path.join(pObj.GetFileObj().GetPackageRootPath(= ), obj.GetPath()) + incPath =3D os.path.join( + pObj.GetFileObj().GetPackageRootPath(), obj.GetPath()) for root, dirs, files in os.walk(incPath): for dir in dirs: if dir.lower() in _ignore_dir: @@ -470,15 +522,17 @@ class PackageDocumentAction(DoxygenAction): typeArchRootPageDict =3D {} for obj in objs: if obj.GetPcdType() not in typeRootPageDict.keys(): - typeRootPageDict[obj.GetPcdType()] =3D doxygen.Page(obj.Ge= tPcdType(), 'pcd_%s_root_page' % obj.GetPcdType()) + typeRootPageDict[obj.GetPcdType()] =3D doxygen.Page( + obj.GetPcdType(), 'pcd_%s_root_page' % obj.GetPcdType(= )) pcdRootPage.AddPage(typeRootPageDict[obj.GetPcdType()]) typeRoot =3D typeRootPageDict[obj.GetPcdType()] if self._arch is not None: pcdPage =3D doxygen.Page('%s' % obj.GetPcdName(), - 'pcd_%s_%s_%s' % (obj.GetPcdType()= , obj.GetArch(), obj.GetPcdName().split('.')[1])) - pcdPage.AddDescription('
        \n'.join(obj.GetComment()) + '=
        \n') + 'pcd_%s_%s_%s' % (obj.GetPcdType(),= obj.GetArch(), obj.GetPcdName().split('.')[1])) + pcdPage.AddDescription( + '
        \n'.join(obj.GetComment()) + '
        \n') section =3D doxygen.Section('PCDinformation', 'PCD Informa= tion') - desc =3D '' + desc =3D '
        ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -487,8 +541,10 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' desc +=3D '' - desc +=3D '' % obj.GetPcdNam= e().split('.')[1] - desc +=3D '' % obj.GetPcdNam= e().split('.')[0] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 1] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 0] desc +=3D '' % obj.GetPcdTok= en() desc +=3D '' % obj.GetPcdDat= aType() desc +=3D '' % obj.GetPcdVal= ue() @@ -500,15 +556,17 @@ class PackageDocumentAction(DoxygenAction): else: keystr =3D obj.GetPcdType() + obj.GetArch() if keystr not in typeArchRootPageDict.keys(): - typeArchRootPage =3D doxygen.Page(obj.GetArch(), 'pcd_= %s_%s_root_page' % (obj.GetPcdType(), obj.GetArch())) + typeArchRootPage =3D doxygen.Page( + obj.GetArch(), 'pcd_%s_%s_root_page' % (obj.GetPcd= Type(), obj.GetArch())) typeArchRootPageDict[keystr] =3D typeArchRootPage typeRoot.AddPage(typeArchRootPage) typeArchRoot =3D typeArchRootPageDict[keystr] pcdPage =3D doxygen.Page('%s' % obj.GetPcdName(), - 'pcd_%s_%s_%s' % (obj.GetPcdType()= , obj.GetArch(), obj.GetPcdName().split('.')[1])) - pcdPage.AddDescription('
        \n'.join(obj.GetComment()) + '=
        \n') + 'pcd_%s_%s_%s' % (obj.GetPcdType(),= obj.GetArch(), obj.GetPcdName().split('.')[1])) + pcdPage.AddDescription( + '
        \n'.join(obj.GetComment()) + '
        \n') section =3D doxygen.Section('PCDinformation', 'PCD Informa= tion') - desc =3D '
        Name
        Token Space
        Default Value
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        ' + desc =3D '
        ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -517,8 +575,10 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' desc +=3D '' - desc +=3D '' % obj.GetPcdNam= e().split('.')[1] - desc +=3D '' % obj.GetPcdNam= e().split('.')[0] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 1] + desc +=3D '' % obj.GetPcdNam= e().split('.')[ + 0] desc +=3D '' % obj.GetPcdTok= en() desc +=3D '' % obj.GetPcdDat= aType() desc +=3D '' % obj.GetPcdVal= ue() @@ -536,7 +596,7 @@ class PackageDocumentAction(DoxygenAction): if len(comments) !=3D 0: guidPage.AddDescription('
        '.join(obj.GetComment()) + '
        ') section =3D doxygen.Section('BasicGuidInfo', 'GUID Information') - desc =3D '
        Name
        Token Space
        Default Value
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        ' + desc =3D '
        ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -568,19 +628,23 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('GUID', 'guid_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('guids', self._= arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GenerateGuidSubPage(pObj, obj, conf= igFile)) + pageRoot.AddPage( + self._GenerateGuidSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'guid_arc= h_root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'guid_arch_root_%s' % obj.GetArch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GenerateGuidSubPage(pObj, obj, = configFile)) + guidArchRoot.AddPage( + self._GenerateGuidSubPage(pObj, obj, configFile)) return [pageRoot] =20 def _GeneratePpiSubPage(self, pObj, obj, configFile): @@ -589,7 +653,7 @@ class PackageDocumentAction(DoxygenAction): if len(comments) !=3D 0: guidPage.AddDescription('
        '.join(obj.GetComment()) + '
        ') section =3D doxygen.Section('BasicPpiInfo', 'PPI Information') - desc =3D '
        GUID\'s Guid Name
        GUID\'s Guid
        ' + desc =3D '
        ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -621,28 +685,33 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('PPI', 'ppi_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('ppis', self._a= rch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GeneratePpiSubPage(pObj, obj, confi= gFile)) + pageRoot.AddPage( + self._GeneratePpiSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'ppi_arch= _root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'ppi_arch_root_%s' % obj.GetArch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GeneratePpiSubPage(pObj, obj, c= onfigFile)) + guidArchRoot.AddPage( + self._GeneratePpiSubPage(pObj, obj, configFile)) return [pageRoot] =20 def _GenerateProtocolSubPage(self, pObj, obj, configFile): - guidPage =3D doxygen.Page(obj.GetName(), 'protocol_page_%s' % obj.= GetName()) + guidPage =3D doxygen.Page( + obj.GetName(), 'protocol_page_%s' % obj.GetName()) comments =3D obj.GetComment() if len(comments) !=3D 0: guidPage.AddDescription('
        '.join(obj.GetComment()) + '
        ') section =3D doxygen.Section('BasicProtocolInfo', 'PROTOCOL Informa= tion') - desc =3D '
        PPI\'s Guid Name
        PPI\'s Guid
        ' + desc =3D '
        ' desc +=3D '' desc +=3D '' desc +=3D '' @@ -675,19 +744,23 @@ class PackageDocumentAction(DoxygenAction): """ pageRoot =3D doxygen.Page('PROTOCOL', 'protocol_root_page') objs =3D pObj.GetFileObj().GetSectionObjectsByName('protocols', se= lf._arch) - if len(objs) =3D=3D 0: return [] + if len(objs) =3D=3D 0: + return [] if self._arch is not None: for obj in objs: - pageRoot.AddPage(self._GenerateProtocolSubPage(pObj, obj, = configFile)) + pageRoot.AddPage( + self._GenerateProtocolSubPage(pObj, obj, configFile)) else: guidArchRootPageDict =3D {} for obj in objs: if obj.GetArch() not in guidArchRootPageDict.keys(): - guidArchRoot =3D doxygen.Page(obj.GetArch(), 'protocol= _arch_root_%s' % obj.GetArch()) + guidArchRoot =3D doxygen.Page( + obj.GetArch(), 'protocol_arch_root_%s' % obj.GetAr= ch()) pageRoot.AddPage(guidArchRoot) guidArchRootPageDict[obj.GetArch()] =3D guidArchRoot guidArchRoot =3D guidArchRootPageDict[obj.GetArch()] - guidArchRoot.AddPage(self._GenerateProtocolSubPage(pObj, o= bj, configFile)) + guidArchRoot.AddPage( + self._GenerateProtocolSubPage(pObj, obj, configFile)) return [pageRoot] =20 def FindHeaderFileForGuid(self, pObj, name, configFile): @@ -700,8 +773,8 @@ class PackageDocumentAction(DoxygenAction): =20 @return full path of header file and None if not found. """ - startPath =3D pObj.GetFileObj().GetPackageRootPath() - incPath =3D os.path.join(startPath, 'Include').replace('\\', '/= ') + startPath =3D pObj.GetFileObj().GetPackageRootPath() + incPath =3D os.path.join(startPath, 'Include').replace('\\', '/') # if /include exist, then search header under it. if os.path.exists(incPath): startPath =3D incPath @@ -761,7 +834,7 @@ class PackageDocumentAction(DoxygenAction): modObjs =3D [] for infpath in infList: infObj =3D inf.INFFile(infpath) - #infObj =3D INFFileObject.INFFile (pObj.GetWorkspacePath(), + # infObj =3D INFFileObject.INFFile (pObj.GetWorkspacePath(), # inf) if not infObj: self.Log('Fail create INF object for %s' % inf) @@ -778,13 +851,15 @@ class PackageDocumentAction(DoxygenAction): libRootPage =3D doxygen.Page('Libraries', 'lib_root_page') rootPages.append(libRootPage) for libInf in libObjs: - libRootPage.AddPage(self.GenerateModulePage(pObj, libInf, = configFile, True)) + libRootPage.AddPage(self.GenerateModulePage( + pObj, libInf, configFile, True)) =20 if len(modObjs) !=3D 0: modRootPage =3D doxygen.Page('Modules', 'module_root_page') rootPages.append(modRootPage) for modInf in modObjs: - modRootPage.AddPage(self.GenerateModulePage(pObj, modInf, = configFile, False)) + modRootPage.AddPage(self.GenerateModulePage( + pObj, modInf, configFile, False)) =20 return rootPages =20 @@ -799,13 +874,15 @@ class PackageDocumentAction(DoxygenAction): """ workspace =3D pObj.GetWorkspace() refDecObjs =3D [] - for obj in infObj.GetSectionObjectsByName('packages'): + for obj in infObj.GetSectionObjectsByName('packages'): decObj =3D dec.DECFile(os.path.join(workspace, obj.GetPath())) if not decObj: - ErrorMsg ('Fail to create pacakge object for %s' % obj.Get= PackageName()) + ErrorMsg('Fail to create pacakge object for %s' % + obj.GetPackageName()) continue if not decObj.Parse(): - ErrorMsg ('Fail to load package object for %s' % obj.GetPa= ckageName()) + ErrorMsg('Fail to load package object for %s' % + obj.GetPackageName()) continue refDecObjs.append(decObj) =20 @@ -813,12 +890,14 @@ class PackageDocumentAction(DoxygenAction): 'module_%s' % infObj.GetBaseName()) modPage.AddDescription(infObj.GetFileHeader()) =20 - basicInfSection =3D doxygen.Section('BasicModuleInformation', 'Bas= ic Module Information') + basicInfSection =3D doxygen.Section( + 'BasicModuleInformation', 'Basic Module Information') desc =3D "
        PROTOCOL\'s Guid Name
        PROTOCOL\'s Guid
        " for obj in infObj.GetSectionObjectsByName('defines'): key =3D obj.GetKey() value =3D obj.GetValue() - if key not in _inf_key_description_mapping_table.keys(): conti= nue + if key not in _inf_key_description_mapping_table.keys(): + continue if key =3D=3D 'LIBRARY_CLASS' and value.find('|') !=3D -1: clsname, types =3D value.split('|') desc +=3D '' @@ -842,7 +921,7 @@ class PackageDocumentAction(DoxygenAction): modPage.AddSection(basicInfSection) =20 # Add protocol section - data =3D [] + data =3D [] for obj in infObj.GetSectionObjectsByName('pcd', self._arch): data.append(obj.GetPcdName().strip()) if len(data) !=3D 0: @@ -853,7 +932,8 @@ class PackageDocumentAction(DoxygenAction): desc +=3D '' desc +=3D '' % item.split('.')[1] desc +=3D '' % item.split('.')[0] - pkgbasename =3D self.SearchPcdPackage(item, workspace, ref= DecObjs) + pkgbasename =3D self.SearchPcdPackage( + item, workspace, refDecObjs) desc +=3D '' % pkgbasename desc +=3D '' desc +=3D "
        %s%s%s
        " @@ -862,8 +942,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add protocol section #sects =3D infObj.GetSectionByString('protocol') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('protocol', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -873,7 +953,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchProtocolPackage(item, workspace= , refDecObjs) + pkgbasename =3D self.SearchProtocolPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -882,8 +963,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add ppi section #sects =3D infObj.GetSectionByString('ppi') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('ppi', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -893,7 +974,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchPpiPackage(item, workspace, ref= DecObjs) + pkgbasename =3D self.SearchPpiPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -902,8 +984,8 @@ class PackageDocumentAction(DoxygenAction): =20 # Add guid section #sects =3D infObj.GetSectionByString('guid') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('guid', self._arch): data.append(obj.GetName().strip()) if len(data) !=3D 0: @@ -913,7 +995,8 @@ class PackageDocumentAction(DoxygenAction): for item in data: desc +=3D '' desc +=3D '%s' % item - pkgbasename =3D self.SearchGuidPackage(item, workspace, re= fDecObjs) + pkgbasename =3D self.SearchGuidPackage( + item, workspace, refDecObjs) desc +=3D '%s' % pkgbasename desc +=3D '' desc +=3D "" @@ -929,12 +1012,13 @@ class PackageDocumentAction(DoxygenAction): desc +=3D 'Produce' try: pkgname, hPath =3D self.SearchLibraryClassHeaderFile(infOb= j.GetProduceLibraryClass(), - workspace, - refDecObjs) + workspa= ce, + refDecO= bjs) except: - self.Log ('fail to get package header file for lib class %= s' % infObj.GetProduceLibraryClass()) + self.Log('fail to get package header file for lib class %s= ' % + infObj.GetProduceLibraryClass()) pkgname =3D 'NULL' - hPath =3D 'NULL' + hPath =3D 'NULL' desc +=3D '%s' % pkgname if hPath !=3D "NULL": #desc +=3D '\link %s \endlink' % hPath @@ -951,9 +1035,10 @@ class PackageDocumentAction(DoxygenAction): if retarr is not None: pkgname, hPath =3D retarr else: - self.Log('Fail find the library class %s definition from m= odule %s dependent package!' % (lcObj.GetClass(), infObj.GetFilename()), 'e= rror') + self.Log('Fail find the library class %s definition from m= odule %s dependent package!' % ( + lcObj.GetClass(), infObj.GetFilename()), 'error') pkgname =3D 'NULL' - hPath =3D 'NULL' + hPath =3D 'NULL' desc +=3D 'Consume' desc +=3D '%s' % pkgname desc +=3D '%s' % hPath @@ -966,22 +1051,25 @@ class PackageDocumentAction(DoxygenAction): section.AddDescription('

          \n') for obj in infObj.GetSourceObjects(self._arch, self._tooltag): sPath =3D infObj.GetModuleRootPath() - sPath =3D os.path.join(sPath, obj.GetSourcePath()).replace('\\= ', '/').strip() + sPath =3D os.path.join(sPath, obj.GetSourcePath() + ).replace('\\', '/').strip() if sPath.lower().endswith('.uni') or sPath.lower().endswith('.= s') or sPath.lower().endswith('.asm') or sPath.lower().endswith('.nasm'): newPath =3D self.TranslateUniFile(sPath) configFile.AddFile(newPath) newPath =3D newPath[len(pObj.GetWorkspace()) + 1:] - section.AddDescription('
        • \link %s \endlink
        • ' % n= ewPath) + section.AddDescription( + '
        • \link %s \endlink
        • ' % newPath) else: - self.ProcessSourceFileForInclude(sPath, pObj, configFile, = infObj) + self.ProcessSourceFileForInclude( + sPath, pObj, configFile, infObj) sPath =3D sPath[len(pObj.GetWorkspace()) + 1:] section.AddDescription('
        • \link %s \endlink
        • ' % sPa= th) section.AddDescription('
        \n') modPage.AddSection(section) =20 #sects =3D infObj.GetSectionByString('depex') - data =3D [] - #for sect in sects: + data =3D [] + # for sect in sects: for obj in infObj.GetSectionObjectsByName('depex'): data.append(str(obj)) if len(data) !=3D 0: @@ -1031,35 +1119,35 @@ class PackageDocumentAction(DoxygenAction): return newpath =20 def SearchPcdPackage(self, pcdname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for pcd in decObj.GetSectionObjectsByName('pcd'): if pcdname =3D=3D pcd.GetPcdName(): return decObj.GetBaseName() return None =20 def SearchProtocolPackage(self, protname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for proto in decObj.GetSectionObjectsByName('protocol'): if protname =3D=3D proto.GetName(): return decObj.GetBaseName() return None =20 def SearchPpiPackage(self, ppiname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for ppi in decObj.GetSectionObjectsByName('ppi'): if ppiname =3D=3D ppi.GetName(): return decObj.GetBaseName() return None =20 def SearchGuidPackage(self, guidname, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for guid in decObj.GetSectionObjectsByName('guid'): if guidname =3D=3D guid.GetName(): return decObj.GetBaseName() return None =20 def SearchLibraryClassHeaderFile(self, className, workspace, decObjs): - for decObj in decObjs: + for decObj in decObjs: for cls in decObj.GetSectionObjectsByName('libraryclasses'): if cls.GetClassName().strip() =3D=3D className: path =3D cls.GetHeaderFile().strip() @@ -1074,9 +1162,11 @@ class PackageDocumentAction(DoxygenAction): path =3D path[len(pRootPath) + 1:] return path.replace('\\', '/') =20 + def IsCHeaderFile(path): return CheckPathPostfix(path, 'h') =20 + def CheckPathPostfix(path, str): index =3D path.rfind('.') if index =3D=3D -1: diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/dsc.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/e= dk2/model/dsc.py index a2d23a7732f4..566531035307 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= dsc.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= dsc.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        # @@ -6,9 +6,11 @@ # =20 from plugins.EdkPlugins.basemodel import ini -import re, os +import re +import os from plugins.EdkPlugins.basemodel.message import * =20 + class DSCFile(ini.BaseINIFile): def GetSectionInstance(self, parent, name, isCombined=3DFalse): return DSCSection(parent, name, isCombined) @@ -16,6 +18,7 @@ class DSCFile(ini.BaseINIFile): def GetComponents(self): return self.GetSectionObjectsByName('Components') =20 + class DSCSection(ini.BaseINISection): def GetSectionINIObject(self, parent): type =3D self.GetType() @@ -53,10 +56,12 @@ class DSCSection(ini.BaseINISection): return 'common' return arr[2] =20 + class DSCSectionObject(ini.BaseINISectionObject): def GetArch(self): return self.GetParent().GetArch() =20 + class DSCPcdObject(DSCSectionObject): =20 def __init__(self, parent): @@ -65,8 +70,8 @@ class DSCPcdObject(DSCSectionObject): =20 def Parse(self): line =3D self.GetLineByOffset(self._start).strip().split('#')[0] - self._name =3D line.split('|')[0] - self._value =3D line.split('|')[1] + self._name =3D line.split('|')[0] + self._value =3D line.split('|')[1] return True =20 def GetPcdName(self): @@ -78,6 +83,7 @@ class DSCPcdObject(DSCSectionObject): def GetPcdValue(self): return self._value =20 + class DSCLibraryClassObject(DSCSectionObject): def __init__(self, parent): ini.BaseINISectionObject.__init__(self, parent) @@ -96,13 +102,14 @@ class DSCLibraryClassObject(DSCSectionObject): def GetModuleType(self): return self.GetParent().GetModuleType() =20 + class DSCComponentObject(DSCSectionObject): =20 def __init__(self, parent): ini.BaseINISectionObject.__init__(self, parent) - self._OveridePcds =3D {} + self._OveridePcds =3D {} self._OverideLibraries =3D {} - self._Filename =3D '' + self._Filename =3D '' =20 def __del__(self): self._OverideLibraries.clear() @@ -140,7 +147,7 @@ class DSCComponentObject(DSCSectionObject): # The end line is '}' and could be ignored # curr =3D self._start + 1 - end =3D self._end - 1 + end =3D self._end - 1 OverideName =3D '' while (curr <=3D end): line =3D self.GetLineByOffset(curr).strip() @@ -176,7 +183,8 @@ class DSCComponentObject(DSCSectionObject): if hasLib: lines.append(' \n') for libKey in self._OverideLibraries.keys(): - lines.append(' %s|%s\n' % (libKey, self._OverideLibra= ries[libKey])) + lines.append(' %s|%s\n' % + (libKey, self._OverideLibraries[libKey])) =20 if hasPcd: for key in self._OveridePcds.keys(): @@ -192,4 +200,3 @@ class DSCComponentObject(DSCSectionObject): lines.append(' }\n') =20 return lines - diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/inf.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/e= dk2/model/inf.py index 430e71af2d89..259e8a409fac 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= inf.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= inf.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        # @@ -6,9 +6,11 @@ # =20 from plugins.EdkPlugins.basemodel import ini -import re, os +import re +import os from plugins.EdkPlugins.basemodel.message import * =20 + class INFFile(ini.BaseINIFile): _libobjs =3D {} =20 @@ -17,7 +19,8 @@ class INFFile(ini.BaseINIFile): =20 def GetProduceLibraryClass(self): obj =3D self.GetDefine("LIBRARY_CLASS") - if obj is None: return None + if obj is None: + return None =20 return obj.split('|')[0].strip() =20 @@ -116,10 +119,12 @@ class INFSection(ini.BaseINISection): =20 return True =20 + class INFSectionObject(ini.BaseINISectionObject): def GetArch(self): return self.GetParent().GetArch() =20 + class INFDefineSectionObject(INFSectionObject): def __init__(self, parent): INFSectionObject.__init__(self, parent) @@ -127,20 +132,21 @@ class INFDefineSectionObject(INFSectionObject): self._value =3D None =20 def Parse(self): - assert (self._start =3D=3D self._end), 'The object in define secti= on must be in single line' + assert (self._start =3D=3D + self._end), 'The object in define section must be in singl= e line' =20 line =3D self.GetLineByOffset(self._start).strip() =20 line =3D line.split('#')[0] - arr =3D line.split('=3D') + arr =3D line.split('=3D') if len(arr) !=3D 2: ErrorMsg('Invalid define section object', - self.GetFilename(), - self._start - ) + self.GetFilename(), + self._start + ) return False =20 - self._key =3D arr[0].strip() + self._key =3D arr[0].strip() self._value =3D arr[1].strip() =20 return True @@ -151,8 +157,10 @@ class INFDefineSectionObject(INFSectionObject): def GetValue(self): return self._value =20 + class INFLibraryClassObject(INFSectionObject): _objs =3D {} + def __init__(self, parent): INFSectionObject.__init__(self, parent) self._classname =3D None @@ -161,7 +169,8 @@ class INFLibraryClassObject(INFSectionObject): return self._classname =20 def Parse(self): - self._classname =3D self.GetLineByOffset(self._start).split('#')[0= ].strip() + self._classname =3D self.GetLineByOffset( + self._start).split('#')[0].strip() objdict =3D INFLibraryClassObject._objs if self._classname in objdict: objdict[self._classname].append(self) @@ -182,21 +191,24 @@ class INFLibraryClassObject(INFSectionObject): def GetObjectDict(): return INFLibraryClassObject._objs =20 + class INFDependentPackageObject(INFSectionObject): def GetPath(self): return self.GetLineByOffset(self._start).split('#')[0].strip() =20 + class INFSourceObject(INFSectionObject): _objs =3D {} + def __init__(self, parent): INFSectionObject.__init__(self, parent) =20 - self.mSourcename =3D None - self.mToolCode =3D None - self.mFamily =3D None - self.mTagName =3D None - self.mFeaturePcd =3D None - self.mFilename =3D None + self.mSourcename =3D None + self.mToolCode =3D None + self.mFamily =3D None + self.mTagName =3D None + self.mFeaturePcd =3D None + self.mFilename =3D None =20 def GetSourcePath(self): return self.mSourcename @@ -273,15 +285,16 @@ class INFSourceObject(INFSectionObject): def GetObjectDict(): return INFSourceObject._objs =20 + class INFPcdObject(INFSectionObject): _objs =3D {} =20 def __init__(self, parent): INFSectionObject.__init__(self, parent) =20 - self.mPcdType =3D None + self.mPcdType =3D None self.mDefaultValue =3D None - self.mPcdName =3D None + self.mPcdName =3D None =20 @staticmethod def GetObjectDict(): @@ -291,7 +304,7 @@ class INFPcdObject(INFSectionObject): line =3D self.GetLineByOffset(self._start).strip().split('#')[0] =20 arr =3D line.split('|') - self.mPcdName =3D arr[0].strip() + self.mPcdName =3D arr[0].strip() =20 if len(arr) >=3D 2: self.mDefaultValue =3D arr[1].strip() @@ -319,17 +332,17 @@ class INFPcdObject(INFSectionObject): if len(objdict[self.GetName()]) =3D=3D 0: del objdict[self.GetName()] =20 + class INFGuidObject(INFSectionObject): def __init__(self, parent): INFSectionObject.__init__(self, parent) self._name =3D None =20 def Parse(self): - line =3D self.GetLineByOffset(self._start).strip().split('#')[0].s= plit("|")[0] - self._name =3D line.strip() + line =3D self.GetLineByOffset(self._start).strip().split('#')[ + 0].split("|")[0] + self._name =3D line.strip() return True =20 def GetName(self): return self._name - - diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/__init__.py b/B= aseTools/Scripts/PackageDocumentTools/plugins/__init__.py index 57dfebde5916..dd93c30888c4 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/__init__.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        # diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 63e6223f8ebc..551bc3d26fdf 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -1,4 +1,4 @@ -## @file +# @file # Check a patch for various format issues # # Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
        @@ -9,23 +9,23 @@ # =20 from __future__ import print_function +import email.header +import sys +import subprocess +import re +import os +import argparse +import email =20 VersionNumber =3D '0.1' __copyright__ =3D "Copyright (c) 2015 - 2016, Intel Corporation All right= s reserved." =20 -import email -import argparse -import os -import re -import subprocess -import sys - -import email.header =20 class Verbose: SILENT, ONELINE, NORMAL =3D range(3) level =3D NORMAL =20 + class EmailAddressCheck: """Checks an email address.""" =20 @@ -55,7 +55,7 @@ class EmailAddressCheck: count +=3D 1 =20 email_re1 =3D re.compile(r'(?:\s*)(.*?)(\s*)<(.+)>\s*$', - re.MULTILINE|re.IGNORECASE) + re.MULTILINE | re.IGNORECASE) =20 def check_email_address(self, email): email =3D email.strip() @@ -86,13 +86,14 @@ class EmailAddressCheck: self.error("Email rewritten by lists DMARC / DKIM / SPF: " + email) =20 + class CommitMessageCheck: """Checks the contents of a git commit message.""" =20 def __init__(self, subject, message, author_email): self.ok =3D True =20 - if subject is None and message is None: + if subject is None and message is None: self.error('Commit message is missing!') return =20 @@ -104,7 +105,7 @@ class CommitMessageCheck: self.subject =3D subject self.msg =3D message =20 - print (subject) + print(subject) =20 self.check_contributed_under() if not MergifyMerge: @@ -143,7 +144,7 @@ class CommitMessageCheck: # requires ':' to be present. Matches if there is white space before # the tag or between the tag and the ':'. contributed_under_re =3D \ - re.compile(r'^\s*contributed-under\s*:', re.MULTILINE|re.IGNORECAS= E) + re.compile(r'^\s*contributed-under\s*:', re.MULTILINE | re.IGNOREC= ASE) =20 def check_contributed_under(self): match =3D self.contributed_under_re.search(self.msg) @@ -160,7 +161,7 @@ class CommitMessageCheck: re_str =3D (r'^(?P' + sub_re + r')(\s*):(\s*)(?P\S.*?)(?:\s*)$') try: - return re.compile(re_str, re.MULTILINE|re.IGNORECASE) + return re.compile(re_str, re.MULTILINE | re.IGNORECASE) except Exception: print("Tried to compile re:", re_str) raise @@ -184,7 +185,7 @@ class CommitMessageCheck: =20 bad_case_sigs =3D filter(lambda m: m[0] !=3D sig, sigs) for s in bad_case_sigs: - self.error("'" +s[0] + "' should be '" + sig + "'") + self.error("'" + s[0] + "' should be '" + sig + "'") =20 for s in sigs: if s[1] !=3D '': @@ -198,7 +199,7 @@ class CommitMessageCheck: return sigs =20 def check_signed_off_by(self): - sob=3D'Signed-off-by' + sob =3D 'Signed-off-by' if self.msg.find(sob) < 0: self.error('Missing Signed-off-by! (Note: this must be ' + 'added by the code contributor!)') @@ -217,7 +218,7 @@ class CommitMessageCheck: 'Suggested', 'Acked', 'Cc' - ) + ) =20 def check_misc_signatures(self): for sig in self.sig_types: @@ -251,7 +252,7 @@ class CommitMessageCheck: self.error( 'First line of commit message (subject line) is too lo= ng (%d >=3D 93).' % (len(lines[0].rstrip())) - ) + ) else: # # If CVE-xxxx-xxxxx is not present in subject line, then limit @@ -261,7 +262,7 @@ class CommitMessageCheck: self.error( 'First line of commit message (subject line) is too lo= ng (%d >=3D 76).' % (len(lines[0].rstrip())) - ) + ) =20 if count >=3D 1 and len(lines[0].strip()) =3D=3D 0: self.error('First line of commit message (subject line) ' + @@ -281,14 +282,14 @@ class CommitMessageCheck: not lines[i].startswith('Reported-by:') and not lines[i].startswith('Suggested-by:') and not lines[i].startswith('Signed-off-by:') and - not lines[i].startswith('Cc:')): + not lines[i].startswith('Cc:')): # # Print a warning if body line is longer than 75 characters # print( 'WARNING - Line %d of commit message is too long (%d >= =3D 76).' % (i + 1, len(lines[i])) - ) + ) print(lines[i]) =20 last_sig_line =3D None @@ -307,8 +308,10 @@ class CommitMessageCheck: break last_sig_line =3D line.strip() =20 + (START, PRE_PATCH, PATCH) =3D range(3) =20 + class GitDiffCheck: """Checks the contents of a git diff.""" =20 @@ -347,8 +350,8 @@ class GitDiffCheck: if line.startswith('@@ '): self.state =3D PRE_PATCH elif len(line) >=3D 1 and line[0] not in ' -+' and \ - not line.startswith('\r\n') and \ - not line.startswith(r'\ No newline ') and not self.binary: + not line.startswith('\r\n') and \ + not line.startswith(r'\ No newline ') and not self.bin= ary: for line in self.lines[self.line_num + 1:]: if line.startswith('diff --git'): self.format_error('diff found after end of patch') @@ -364,10 +367,10 @@ class GitDiffCheck: self.force_crlf =3D True self.force_notabs =3D True if self.filename.endswith('.sh') or \ - self.filename.startswith('BaseTools/BinWrappers/PosixL= ike/') or \ - self.filename.startswith('BaseTools/BinPipWrappers/Pos= ixLike/') or \ - self.filename.startswith('BaseTools/Bin/CYGWIN_NT-5.1-= i686/') or \ - self.filename =3D=3D 'BaseTools/BuildEnv': + self.filename.startswith('BaseTools/BinWrappers/Po= sixLike/') or \ + self.filename.startswith('BaseTools/BinPipWrappers= /PosixLike/') or \ + self.filename.startswith('BaseTools/Bin/CYGWIN_NT-= 5.1-i686/') or \ + self.filename =3D=3D 'BaseTools/BuildEnv': # # Do not enforce CR/LF line endings for linux shell sc= ripts. # Some linux shell scripts don't end with the ".sh" ex= tension, @@ -391,7 +394,7 @@ class GitDiffCheck: self.state =3D PATCH self.binary =3D False elif line.startswith('GIT binary patch') or \ - line.startswith('Binary files'): + line.startswith('Binary files'): self.state =3D PATCH self.binary =3D True if self.is_newfile: @@ -437,7 +440,7 @@ class GitDiffCheck: 'copy from ', 'copy to ', 'rename ', - ) + ) =20 line_endings =3D ('\r\n', '\n\r', '\n', '\r') =20 @@ -448,7 +451,7 @@ class GitDiffCheck: re.VERBOSE) =20 def added_line_error(self, msg, line): - lines =3D [ msg ] + lines =3D [msg] if self.filename is not None: lines.append('File: ' + self.filename) lines.append('Line: ' + line) @@ -514,6 +517,7 @@ class GitDiffCheck: print(prefix, line) count +=3D 1 =20 + class CheckOnePatch: """Checks the contents of a git email formatted patch. =20 @@ -528,7 +532,8 @@ class CheckOnePatch: email_check =3D EmailAddressCheck(self.author_email, 'Author') email_ok =3D email_check.ok =20 - msg_check =3D CommitMessageCheck(self.commit_subject, self.commit_= msg, self.author_email) + msg_check =3D CommitMessageCheck( + self.commit_subject, self.commit_msg, self.author_email) msg_ok =3D msg_check.ok =20 diff_ok =3D True @@ -550,7 +555,6 @@ class CheckOnePatch: result =3D 'bad ' + ' and '.join(result) print(name, result) =20 - git_diff_re =3D re.compile(r''' ^ diff \s+ --git \s+ a/.+ \s+ b/.+ $ ''', @@ -629,10 +633,12 @@ class CheckOnePatch: =20 self.commit_subject =3D subject.replace('\r\n', '') self.commit_subject =3D self.commit_subject.replace('\n', '') - self.commit_subject =3D self.subject_prefix_re.sub('', self.commit= _subject, 1) + self.commit_subject =3D self.subject_prefix_re.sub( + '', self.commit_subject, 1) =20 self.author_email =3D pmail['from'] =20 + class CheckGitCommits: """Reads patches from git based on the specified git revision range. =20 @@ -642,7 +648,7 @@ class CheckGitCommits: def __init__(self, rev_spec, max_count): commits =3D self.read_commit_list_from_git(rev_spec, max_count) if len(commits) =3D=3D 1 and Verbose.level > Verbose.ONELINE: - commits =3D [ rev_spec ] + commits =3D [rev_spec] self.ok =3D True blank_line =3D False for commit in commits: @@ -661,7 +667,7 @@ class CheckGitCommits: =20 def read_commit_list_from_git(self, rev_spec, max_count): # Run git to get the commit patch - cmd =3D [ 'rev-list', '--abbrev-commit', '--no-walk' ] + cmd =3D ['rev-list', '--abbrev-commit', '--no-walk'] if max_count is not None: cmd.append('--max-count=3D' + str(max_count)) cmd.append(rev_spec) @@ -679,13 +685,14 @@ class CheckGitCommits: '--no-use-mailmap', commit) =20 def run_git(self, *args): - cmd =3D [ 'git' ] + cmd =3D ['git'] cmd +=3D args p =3D subprocess.Popen(cmd, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT) + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT) Result =3D p.communicate() - return Result[0].decode('utf-8', 'ignore') if Result[0] and Result= [0].find(b"fatal")!=3D0 else None + return Result[0].decode('utf-8', 'ignore') if Result[0] and Result= [0].find(b"fatal") !=3D 0 else None + =20 class CheckOnePatchFile: """Performs a patch check for a single file. @@ -705,6 +712,7 @@ class CheckOnePatchFile: print('Checking patch file:', patch_filename) self.ok =3D CheckOnePatch(patch_filename, patch).ok =20 + class CheckOneArg: """Performs a patch check for a single command line argument. =20 @@ -720,6 +728,7 @@ class CheckOneArg: checker =3D CheckGitCommits(param, max_count) self.ok =3D checker.ok =20 + class PatchCheckApp: """Checks patches based on the command line arguments.""" =20 @@ -728,7 +737,7 @@ class PatchCheckApp: patches =3D self.args.patches =20 if len(patches) =3D=3D 0: - patches =3D [ 'HEAD' ] + patches =3D ['HEAD'] =20 self.ok =3D True self.count =3D None @@ -772,5 +781,6 @@ class PatchCheckApp: if self.args.silent: Verbose.level =3D Verbose.SILENT =20 + if __name__ =3D=3D "__main__": sys.exit(PatchCheckApp().retval) diff --git a/BaseTools/Scripts/RunMakefile.py b/BaseTools/Scripts/RunMakefi= le.py index 0e0a0114f9c7..a65cd0717495 100644 --- a/BaseTools/Scripts/RunMakefile.py +++ b/BaseTools/Scripts/RunMakefile.py @@ -1,4 +1,4 @@ -## @file +# @file # Run a makefile as part of a PREBUILD or POSTBUILD action. # # Copyright (c) 2017, Intel Corporation. All rights reserved.
        @@ -17,9 +17,9 @@ import subprocess # # Globals for help information # -__prog__ =3D 'RunMakefile' -__version__ =3D '%s Version %s' % (__prog__, '1.0') -__copyright__ =3D 'Copyright (c) 2017, Intel Corporation. All rights res= erved.' +__prog__ =3D 'RunMakefile' +__version__ =3D '%s Version %s' % (__prog__, '1.0') +__copyright__ =3D 'Copyright (c) 2017, Intel Corporation. All rights reser= ved.' __description__ =3D 'Run a makefile as part of a PREBUILD or POSTBUILD act= ion.\n' =20 # @@ -27,146 +27,152 @@ __description__ =3D 'Run a makefile as part of a PREB= UILD or POSTBUILD action.\n' # gArgs =3D None =20 + def Log(Message): - if not gArgs.Verbose: - return - sys.stdout.write (__prog__ + ': ' + Message + '\n') + if not gArgs.Verbose: + return + sys.stdout.write(__prog__ + ': ' + Message + '\n') + =20 def Error(Message, ExitValue=3D1): - sys.stderr.write (__prog__ + ': ERROR: ' + Message + '\n') - sys.exit (ExitValue) + sys.stderr.write(__prog__ + ': ERROR: ' + Message + '\n') + sys.exit(ExitValue) + =20 def RelativePath(target): - return os.path.relpath (target, gWorkspace) + return os.path.relpath(target, gWorkspace) + =20 def NormalizePath(target): - if isinstance(target, tuple): - return os.path.normpath (os.path.join (*target)) - else: - return os.path.normpath (target) + if isinstance(target, tuple): + return os.path.normpath(os.path.join(*target)) + else: + return os.path.normpath(target) + =20 if __name__ =3D=3D '__main__': - # - # Create command line argument parser object - # - parser =3D argparse.ArgumentParser ( - prog =3D __prog__, - version =3D __version__, - description =3D __description__ + __copyright__, - conflict_handler =3D 'resolve' - ) - parser.add_argument ( - '-a', '--arch', dest =3D 'Arch', nargs =3D '+', action =3D 'app= end', - required =3D True, - help =3D '''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 = or EBC, + # + # Create command line argument parser object + # + parser =3D argparse.ArgumentParser( + prog=3D__prog__, + version=3D__version__, + description=3D__description__ + __copyright__, + conflict_handler=3D'resolve' + ) + parser.add_argument( + '-a', '--arch', dest=3D'Arch', nargs=3D'+', action=3D'append', + required=3DTrue, + help=3D'''ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EB= C, which overrides target.txt's TARGET_ARCH definition. = To specify more archs, please repeat this option.''' - ) - parser.add_argument ( - '-t', '--tagname', dest =3D 'ToolChain', required =3D True, - help =3D '''Using the Tool Chain Tagname to build the platform, + ) + parser.add_argument( + '-t', '--tagname', dest=3D'ToolChain', required=3DTrue, + help=3D'''Using the Tool Chain Tagname to build the platform, overriding target.txt's TOOL_CHAIN_TAG definition.''' - ) - parser.add_argument ( - '-p', '--platform', dest =3D 'PlatformFile', required =3D True, - help =3D '''Build the platform specified by the DSC file name a= rgument, + ) + parser.add_argument( + '-p', '--platform', dest=3D'PlatformFile', required=3DTrue, + help=3D'''Build the platform specified by the DSC file name argume= nt, overriding target.txt's ACTIVE_PLATFORM definition.''' - ) - parser.add_argument ( - '-b', '--buildtarget', dest =3D 'BuildTarget', required =3D Tru= e, - help =3D '''Using the TARGET to build the platform, overriding + ) + parser.add_argument( + '-b', '--buildtarget', dest=3D'BuildTarget', required=3DTrue, + help=3D'''Using the TARGET to build the platform, overriding target.txt's TARGET definition.''' - ) - parser.add_argument ( - '--conf=3D', dest =3D 'ConfDirectory', required =3D True, - help =3D '''Specify the customized Conf directory.''' - ) - parser.add_argument ( - '-D', '--define', dest =3D 'Define', nargs=3D'*', action =3D 'a= ppend', - help =3D '''Macro: "Name [=3D Value]".''' - ) - parser.add_argument ( - '--makefile', dest =3D 'Makefile', required =3D True, - help =3D '''Makefile to run passing in arguments as makefile de= fines.''' - ) - parser.add_argument ( - '-v', '--verbose', dest =3D 'Verbose', action =3D 'store_true', - help =3D '''Turn on verbose output with informational messages = printed''' - ) + ) + parser.add_argument( + '--conf=3D', dest=3D'ConfDirectory', required=3DTrue, + help=3D'''Specify the customized Conf directory.''' + ) + parser.add_argument( + '-D', '--define', dest=3D'Define', nargs=3D'*', action=3D'append', + help=3D'''Macro: "Name [=3D Value]".''' + ) + parser.add_argument( + '--makefile', dest=3D'Makefile', required=3DTrue, + help=3D'''Makefile to run passing in arguments as makefile defines= .''' + ) + parser.add_argument( + '-v', '--verbose', dest=3D'Verbose', action=3D'store_true', + help=3D'''Turn on verbose output with informational messages print= ed''' + ) =20 - # - # Parse command line arguments - # - gArgs, remaining =3D parser.parse_known_args() - gArgs.BuildType =3D 'all' - for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall', = 'modules', 'libraries', 'run']: - if BuildType in remaining: - gArgs.BuildType =3D BuildType - remaining.remove(BuildType) - break - gArgs.Remaining =3D ' '.join(remaining) + # + # Parse command line arguments + # + gArgs, remaining =3D parser.parse_known_args() + gArgs.BuildType =3D 'all' + for BuildType in ['all', 'fds', 'genc', 'genmake', 'clean', 'cleanall'= , 'modules', 'libraries', 'run']: + if BuildType in remaining: + gArgs.BuildType =3D BuildType + remaining.remove(BuildType) + break + gArgs.Remaining =3D ' '.join(remaining) =20 - # - # Start - # - Log ('Start') + # + # Start + # + Log('Start') =20 - # - # Find makefile in WORKSPACE or PACKAGES_PATH - # - PathList =3D [''] - try: - PathList.append(os.environ['WORKSPACE']) - except: - Error ('WORKSPACE environment variable not set') - try: - PathList +=3D os.environ['PACKAGES_PATH'].split(os.pathsep) - except: - pass - for Path in PathList: - Makefile =3D NormalizePath((Path, gArgs.Makefile)) - if os.path.exists (Makefile): - break - if not os.path.exists(Makefile): - Error ('makefile %s not found' % (gArgs.Makefile)) + # + # Find makefile in WORKSPACE or PACKAGES_PATH + # + PathList =3D [''] + try: + PathList.append(os.environ['WORKSPACE']) + except: + Error('WORKSPACE environment variable not set') + try: + PathList +=3D os.environ['PACKAGES_PATH'].split(os.pathsep) + except: + pass + for Path in PathList: + Makefile =3D NormalizePath((Path, gArgs.Makefile)) + if os.path.exists(Makefile): + break + if not os.path.exists(Makefile): + Error('makefile %s not found' % (gArgs.Makefile)) =20 - # - # Build command line arguments converting build arguments to makefile de= fines - # - CommandLine =3D [Makefile] - CommandLine.append('TARGET_ARCH=3D"%s"' % (' '.join([Item[0] for Item in= gArgs.Arch]))) - CommandLine.append('TOOL_CHAIN_TAG=3D"%s"' % (gArgs.ToolChain)) - CommandLine.append('TARGET=3D"%s"' % (gArgs.BuildTarget)) - CommandLine.append('ACTIVE_PLATFORM=3D"%s"' % (gArgs.PlatformFile)) - CommandLine.append('CONF_DIRECTORY=3D"%s"' % (gArgs.ConfDirectory)) - if gArgs.Define: - for Item in gArgs.Define: - if '=3D' not in Item[0]: - continue - Item =3D Item[0].split('=3D', 1) - CommandLine.append('%s=3D"%s"' % (Item[0], Item[1])) - CommandLine.append('EXTRA_FLAGS=3D"%s"' % (gArgs.Remaining)) - CommandLine.append(gArgs.BuildType) - if sys.platform =3D=3D "win32": - CommandLine =3D 'nmake /f %s' % (' '.join(CommandLine)) - else: - CommandLine =3D 'make -f %s' % (' '.join(CommandLine)) + # + # Build command line arguments converting build arguments to makefile = defines + # + CommandLine =3D [Makefile] + CommandLine.append('TARGET_ARCH=3D"%s"' % + (' '.join([Item[0] for Item in gArgs.Arch]))) + CommandLine.append('TOOL_CHAIN_TAG=3D"%s"' % (gArgs.ToolChain)) + CommandLine.append('TARGET=3D"%s"' % (gArgs.BuildTarget)) + CommandLine.append('ACTIVE_PLATFORM=3D"%s"' % (gArgs.PlatformFile)) + CommandLine.append('CONF_DIRECTORY=3D"%s"' % (gArgs.ConfDirectory)) + if gArgs.Define: + for Item in gArgs.Define: + if '=3D' not in Item[0]: + continue + Item =3D Item[0].split('=3D', 1) + CommandLine.append('%s=3D"%s"' % (Item[0], Item[1])) + CommandLine.append('EXTRA_FLAGS=3D"%s"' % (gArgs.Remaining)) + CommandLine.append(gArgs.BuildType) + if sys.platform =3D=3D "win32": + CommandLine =3D 'nmake /f %s' % (' '.join(CommandLine)) + else: + CommandLine =3D 'make -f %s' % (' '.join(CommandLine)) =20 - # - # Run the makefile - # - try: - Process =3D subprocess.Popen(CommandLine, shell=3DTrue) - except: - Error ('make command not available. Please verify PATH') - Process.communicate() + # + # Run the makefile + # + try: + Process =3D subprocess.Popen(CommandLine, shell=3DTrue) + except: + Error('make command not available. Please verify PATH') + Process.communicate() =20 - # - # Done - # - Log ('Done') + # + # Done + # + Log('Done') =20 - # - # Return status from running the makefile - # - sys.exit(Process.returncode) + # + # Return status from running the makefile + # + sys.exit(Process.returncode) diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py index 91814199bfb9..a1bcd185bf0f 100644 --- a/BaseTools/Scripts/SetupGit.py +++ b/BaseTools/Scripts/SetupGit.py @@ -1,4 +1,4 @@ -## @file +# @file # Set up the git configuration for contributing to TianoCore projects # # Copyright (c) 2019, Linaro Ltd. All rights reserved.
        @@ -50,7 +50,7 @@ UPSTREAMS =3D [ {'name': 'edk2-test', 'repo': 'https://github.com/tianocore/edk2-test.git', 'list': 'devel@edk2.groups.io', 'prefix': 'edk2-test'} - ] +] =20 # The minimum version required for all of the below options to work MIN_GIT_VERSION =3D (1, 9, 0) @@ -78,11 +78,12 @@ OPTIONS =3D [ {'section': 'format', 'option': 'numbered', 'value': Tru= e}, {'section': 'format', 'option': 'signoff', 'value': Fal= se}, {'section': 'log', 'option': 'mailmap', 'value': Tru= e}, - {'section': 'notes', 'option': 'rewriteRef', 'value': 're= fs/notes/commits'}, + {'section': 'notes', 'option': 'rewriteRef', + 'value': 'refs/notes/commits'}, {'section': 'sendemail', 'option': 'chainreplyto', 'value': Fal= se}, {'section': 'sendemail', 'option': 'thread', 'value': Tru= e}, {'section': 'sendemail', 'option': 'transferEncoding', 'value': '8b= it'}, - ] +] =20 =20 def locate_repo(): @@ -97,7 +98,7 @@ def locate_repo(): =20 def fuzzy_match_repo_url(one, other): """Compares two repository URLs, ignoring protocol and optional traili= ng '.git'.""" - oneresult =3D re.match(r'.*://(?P.*?)(\.git)*$', one) + oneresult =3D re.match(r'.*://(?P.*?)(\.git)*$', one) otherresult =3D re.match(r'.*://(?P.*?)(\.git)*$', other) =20 if oneresult and otherresult: @@ -204,13 +205,17 @@ if __name__ =3D=3D '__main__': entry['option']= , value)) else: if ARGS.force: - write_config_value(REPO, entry['section'], entry['opti= on'], entry['value']) + write_config_value( + REPO, entry['section'], entry['option'], entry['va= lue']) else: print("Not overwriting existing %s.%s value:" % (entry= ['section'], entry= ['option'])) print(" '%s' !=3D '%s'" % (value, entry['value'])) - print(" add '-f' to command line to force overwriting= existing settings") + print( + " add '-f' to command line to force overwriting e= xisting settings") else: - print("%s.%s =3D> '%s'" % (entry['section'], entry['option'], = entry['value'])) + print("%s.%s =3D> '%s'" % + (entry['section'], entry['option'], entry['value'])) if not ARGS.check: - write_config_value(REPO, entry['section'], entry['option']= , entry['value']) + write_config_value( + REPO, entry['section'], entry['option'], entry['value'= ]) diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py b/BaseTools/Sc= ripts/SmiHandlerProfileSymbolGen.py index 1e2e7fd1049b..4caea88c68e2 100644 --- a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py +++ b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py @@ -20,6 +20,7 @@ import xml.dom.minidom versionNumber =3D "1.1" __copyright__ =3D "Copyright (c) 2016, Intel Corporation. All rights reser= ved." =20 + class Symbols: def __init__(self): self.listLineAddress =3D [] @@ -29,36 +30,36 @@ class Symbols: # Cache for line self.sourceName =3D "" =20 - - def getSymbol (self, rva): + def getSymbol(self, rva): index =3D 0 - lineName =3D 0 + lineName =3D 0 sourceName =3D "??" - while index + 1 < self.lineCount : - if self.listLineAddress[index][0] <=3D rva and self.listLineAd= dress[index + 1][0] > rva : + while index + 1 < self.lineCount: + if self.listLineAddress[index][0] <=3D rva and self.listLineAd= dress[index + 1][0] > rva: offset =3D rva - self.listLineAddress[index][0] functionName =3D self.listLineAddress[index][1] lineName =3D self.listLineAddress[index][2] sourceName =3D self.listLineAddress[index][3] - if lineName =3D=3D 0 : - return [functionName] - else : - return [functionName, sourceName, lineName] + if lineName =3D=3D 0: + return [functionName] + else: + return [functionName, sourceName, lineName] index +=3D 1 =20 return [] =20 def parse_debug_file(self, driverName, pdbName): - if cmp (pdbName, "") =3D=3D 0 : + if cmp(pdbName, "") =3D=3D 0: return - self.pdbName =3D pdbName; + self.pdbName =3D pdbName =20 try: nmCommand =3D "nm" nmLineOption =3D "-l" print("parsing (debug) - " + pdbName) - os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOp= tion, pdbName)) - except : + os.system('%s %s %s > nmDump.line.log' % + (nmCommand, nmLineOption, pdbName)) + except: print('ERROR: nm command not available. Please verify PATH') return =20 @@ -75,23 +76,25 @@ class Symbols: for reportLine in reportLines: match =3D re.match(patchLineFileMatchString, reportLine) if match is not None: - rva =3D int (match.group(1), 16) + rva =3D int(match.group(1), 16) functionName =3D match.group(2) sourceName =3D match.group(3) - if cmp (match.group(4), "") !=3D 0 : - lineName =3D int (match.group(4)) - else : + if cmp(match.group(4), "") !=3D 0: + lineName =3D int(match.group(4)) + else: lineName =3D 0 - self.listLineAddress.append ([rva, functionName, lineName,= sourceName]) + self.listLineAddress.append( + [rva, functionName, lineName, sourceName]) =20 - self.lineCount =3D len (self.listLineAddress) + self.lineCount =3D len(self.listLineAddress) =20 - self.listLineAddress =3D sorted(self.listLineAddress, key=3Dlambda= symbolAddress:symbolAddress[0]) + self.listLineAddress =3D sorted( + self.listLineAddress, key=3Dlambda symbolAddress: symbolAddres= s[0]) =20 def parse_pdb_file(self, driverName, pdbName): - if cmp (pdbName, "") =3D=3D 0 : + if cmp(pdbName, "") =3D=3D 0: return - self.pdbName =3D pdbName; + self.pdbName =3D pdbName =20 try: #DIA2DumpCommand =3D "\"C:\\Program Files (x86)\Microsoft Visu= al Studio 14.0\\DIA SDK\\Samples\\DIA2Dump\\x64\\Debug\\Dia2Dump.exe\"" @@ -100,8 +103,9 @@ class Symbols: DIA2LinesOption =3D "-l" print("parsing (pdb) - " + pdbName) #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpComman= d, DIA2SymbolOption, pdbName)) - os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, = DIA2LinesOption, pdbName)) - except : + os.system('%s %s %s > DIA2Dump.line.log' % + (DIA2DumpCommand, DIA2LinesOption, pdbName)) + except: print('ERROR: DIA2Dump command not available. Please verify P= ATH') return =20 @@ -123,50 +127,60 @@ class Symbols: for reportLine in reportLines: match =3D re.match(patchLineFileMatchString, reportLine) if match is not None: - if cmp (match.group(3), "") !=3D 0 : + if cmp(match.group(3), "") !=3D 0: self.sourceName =3D match.group(3) sourceName =3D self.sourceName functionName =3D self.functionName =20 - rva =3D int (match.group(2), 16) - lineName =3D int (match.group(1)) - self.listLineAddress.append ([rva, functionName, lineName,= sourceName]) - else : + rva =3D int(match.group(2), 16) + lineName =3D int(match.group(1)) + self.listLineAddress.append( + [rva, functionName, lineName, sourceName]) + else: match =3D re.match(patchLineFileMatchStringFunc, reportLin= e) if match is not None: self.functionName =3D match.group(1) =20 - self.lineCount =3D len (self.listLineAddress) - self.listLineAddress =3D sorted(self.listLineAddress, key=3Dlambda= symbolAddress:symbolAddress[0]) + self.lineCount =3D len(self.listLineAddress) + self.listLineAddress =3D sorted( + self.listLineAddress, key=3Dlambda symbolAddress: symbolAddres= s[0]) + =20 class SymbolsFile: def __init__(self): self.symbolsTable =3D {} =20 + symbolsFile =3D "" =20 driverName =3D "" rvaName =3D "" symbolName =3D "" =20 + def getSymbolName(driverName, rva): global symbolsFile =20 - try : + try: symbolList =3D symbolsFile.symbolsTable[driverName] if symbolList is not None: - return symbolList.getSymbol (rva) + return symbolList.getSymbol(rva) else: return [] except Exception: return [] =20 + def myOptionParser(): usage =3D "%prog [--version] [-h] [--help] [-i inputfile [-o outputfil= e] [-g guidreffile]]" - Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, ve= rsion=3D"%prog " + str(versionNumber)) - Parser.add_option("-i", "--inputfile", dest=3D"inputfilename", type=3D= "string", help=3D"The input memory profile info file output from MemoryProf= ileInfo application in MdeModulePkg") - Parser.add_option("-o", "--outputfile", dest=3D"outputfilename", type= =3D"string", help=3D"The output memory profile info file with symbol, Memor= yProfileInfoSymbol.txt will be used if it is not specified") - Parser.add_option("-g", "--guidref", dest=3D"guidreffilename", type=3D= "string", help=3D"The input guid ref file output from build") + Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, + version=3D"%prog " + str(versionNumber)) + Parser.add_option("-i", "--inputfile", dest=3D"inputfilename", type=3D= "string", + help=3D"The input memory profile info file output fr= om MemoryProfileInfo application in MdeModulePkg") + Parser.add_option("-o", "--outputfile", dest=3D"outputfilename", type= =3D"string", + help=3D"The output memory profile info file with sym= bol, MemoryProfileInfoSymbol.txt will be used if it is not specified") + Parser.add_option("-g", "--guidref", dest=3D"guidreffilename", + type=3D"string", help=3D"The input guid ref file out= put from build") =20 (Options, args) =3D Parser.parse_args() if Options.inputfilename is None: @@ -175,22 +189,24 @@ def myOptionParser(): Options.outputfilename =3D "SmiHandlerProfileInfoSymbol.xml" return Options =20 + dictGuid =3D { - '00000000-0000-0000-0000-000000000000':'gZeroGuid', - '2A571201-4966-47F6-8B86-F31E41F32F10':'gEfiEventLegacyBootGuid', - '27ABF055-B1B8-4C26-8048-748F37BAA2DF':'gEfiEventExitBootServicesGuid', - '7CE88FB3-4BD7-4679-87A8-A8D8DEE50D2B':'gEfiEventReadyToBootGuid', - '02CE967A-DD7E-4FFC-9EE7-810CF0470880':'gEfiEndOfDxeEventGroupGuid', - '60FF8964-E906-41D0-AFED-F241E974E08E':'gEfiDxeSmmReadyToLockProtocolGui= d', - '18A3C6DC-5EEA-48C8-A1C1-B53389F98999':'gEfiSmmSwDispatch2ProtocolGuid', - '456D2859-A84B-4E47-A2EE-3276D886997D':'gEfiSmmSxDispatch2ProtocolGuid', - '4CEC368E-8E8E-4D71-8BE1-958C45FC8A53':'gEfiSmmPeriodicTimerDispatch2Pro= tocolGuid', - 'EE9B8D90-C5A6-40A2-BDE2-52558D33CCA1':'gEfiSmmUsbDispatch2ProtocolGuid', - '25566B03-B577-4CBF-958C-ED663EA24380':'gEfiSmmGpiDispatch2ProtocolGuid', - '7300C4A1-43F2-4017-A51B-C81A7F40585B':'gEfiSmmStandbyButtonDispatch2Pro= tocolGuid', - '1B1183FA-1823-46A7-8872-9C578755409D':'gEfiSmmPowerButtonDispatch2Proto= colGuid', - '58DC368D-7BFA-4E77-ABBC-0E29418DF930':'gEfiSmmIoTrapDispatch2ProtocolGu= id', - } + '00000000-0000-0000-0000-000000000000': 'gZeroGuid', + '2A571201-4966-47F6-8B86-F31E41F32F10': 'gEfiEventLegacyBootGuid', + '27ABF055-B1B8-4C26-8048-748F37BAA2DF': 'gEfiEventExitBootServicesGuid= ', + '7CE88FB3-4BD7-4679-87A8-A8D8DEE50D2B': 'gEfiEventReadyToBootGuid', + '02CE967A-DD7E-4FFC-9EE7-810CF0470880': 'gEfiEndOfDxeEventGroupGuid', + '60FF8964-E906-41D0-AFED-F241E974E08E': 'gEfiDxeSmmReadyToLockProtocol= Guid', + '18A3C6DC-5EEA-48C8-A1C1-B53389F98999': 'gEfiSmmSwDispatch2ProtocolGui= d', + '456D2859-A84B-4E47-A2EE-3276D886997D': 'gEfiSmmSxDispatch2ProtocolGui= d', + '4CEC368E-8E8E-4D71-8BE1-958C45FC8A53': 'gEfiSmmPeriodicTimerDispatch2= ProtocolGuid', + 'EE9B8D90-C5A6-40A2-BDE2-52558D33CCA1': 'gEfiSmmUsbDispatch2ProtocolGu= id', + '25566B03-B577-4CBF-958C-ED663EA24380': 'gEfiSmmGpiDispatch2ProtocolGu= id', + '7300C4A1-43F2-4017-A51B-C81A7F40585B': 'gEfiSmmStandbyButtonDispatch2= ProtocolGuid', + '1B1183FA-1823-46A7-8872-9C578755409D': 'gEfiSmmPowerButtonDispatch2Pr= otocolGuid', + '58DC368D-7BFA-4E77-ABBC-0E29418DF930': 'gEfiSmmIoTrapDispatch2Protoco= lGuid', +} + =20 def genGuidString(guidreffile): guidLines =3D guidreffile.readlines() @@ -199,27 +215,32 @@ def genGuidString(guidreffile): if len(guidLineList) =3D=3D 2: guid =3D guidLineList[0] guidName =3D guidLineList[1] - if guid not in dictGuid : + if guid not in dictGuid: dictGuid[guid] =3D guidName =20 + def createSym(symbolName): SymbolNode =3D xml.dom.minidom.Document().createElement("Symbol") SymbolFunction =3D xml.dom.minidom.Document().createElement("Function") - SymbolFunctionData =3D xml.dom.minidom.Document().createTextNode(symbo= lName[0]) + SymbolFunctionData =3D xml.dom.minidom.Document( + ).createTextNode(symbolName[0]) SymbolFunction.appendChild(SymbolFunctionData) SymbolNode.appendChild(SymbolFunction) if (len(symbolName)) >=3D 2: SymbolSourceFile =3D xml.dom.minidom.Document().createElement("Sou= rceFile") - SymbolSourceFileData =3D xml.dom.minidom.Document().createTextNode= (symbolName[1]) + SymbolSourceFileData =3D xml.dom.minidom.Document( + ).createTextNode(symbolName[1]) SymbolSourceFile.appendChild(SymbolSourceFileData) SymbolNode.appendChild(SymbolSourceFile) if (len(symbolName)) >=3D 3: SymbolLineNumber =3D xml.dom.minidom.Document().createElement(= "LineNumber") - SymbolLineNumberData =3D xml.dom.minidom.Document().createText= Node(str(symbolName[2])) + SymbolLineNumberData =3D xml.dom.minidom.Document( + ).createTextNode(str(symbolName[2])) SymbolLineNumber.appendChild(SymbolLineNumberData) SymbolNode.appendChild(SymbolLineNumber) return SymbolNode =20 + def main(): global symbolsFile global Options @@ -227,14 +248,14 @@ def main(): =20 symbolsFile =3D SymbolsFile() =20 - try : + try: DOMTree =3D xml.dom.minidom.parse(Options.inputfilename) except Exception: print("fail to open input " + Options.inputfilename) return 1 =20 if Options.guidreffilename is not None: - try : + try: guidreffile =3D open(Options.guidreffilename) except Exception: print("fail to open guidref" + Options.guidreffilename) @@ -244,8 +265,10 @@ def main(): =20 SmiHandlerProfile =3D DOMTree.documentElement =20 - SmiHandlerDatabase =3D SmiHandlerProfile.getElementsByTagName("SmiHand= lerDatabase") - SmiHandlerCategory =3D SmiHandlerDatabase[0].getElementsByTagName("Smi= HandlerCategory") + SmiHandlerDatabase =3D SmiHandlerProfile.getElementsByTagName( + "SmiHandlerDatabase") + SmiHandlerCategory =3D SmiHandlerDatabase[0].getElementsByTagName( + "SmiHandlerCategory") for smiHandlerCategory in SmiHandlerCategory: SmiEntry =3D smiHandlerCategory.getElementsByTagName("SmiEntry") for smiEntry in SmiEntry: @@ -265,10 +288,12 @@ def main(): =20 symbolsFile.symbolsTable[driverName] =3D Symbols() =20 - if cmp (pdbName[-3:], "pdb") =3D=3D 0 : - symbolsFile.symbolsTable[driverName].parse_pdb_fil= e (driverName, pdbName) - else : - symbolsFile.symbolsTable[driverName].parse_debug_f= ile (driverName, pdbName) + if cmp(pdbName[-3:], "pdb") =3D=3D 0: + symbolsFile.symbolsTable[driverName].parse_pdb_fil= e( + driverName, pdbName) + else: + symbolsFile.symbolsTable[driverName].parse_debug_f= ile( + driverName, pdbName) =20 Handler =3D smiHandler.getElementsByTagName("Handler") RVA =3D Handler[0].getElementsByTagName("RVA") @@ -276,7 +301,8 @@ def main(): =20 if (len(RVA)) >=3D 1: rvaName =3D RVA[0].childNodes[0].data - symbolName =3D getSymbolName (driverName, int(rvaN= ame, 16)) + symbolName =3D getSymbolName( + driverName, int(rvaName, 16)) =20 if (len(symbolName)) >=3D 1: SymbolNode =3D createSym(symbolName) @@ -288,20 +314,23 @@ def main(): =20 if (len(RVA)) >=3D 1: rvaName =3D RVA[0].childNodes[0].data - symbolName =3D getSymbolName (driverName, int(rvaN= ame, 16)) + symbolName =3D getSymbolName( + driverName, int(rvaName, 16)) =20 if (len(symbolName)) >=3D 1: SymbolNode =3D createSym(symbolName) Caller[0].appendChild(SymbolNode) =20 - try : + try: newfile =3D open(Options.outputfilename, "w") except Exception: print("fail to open output" + Options.outputfilename) return 1 =20 - newfile.write(DOMTree.toprettyxml(indent =3D "\t", newl =3D "\n", enco= ding =3D "utf-8")) + newfile.write(DOMTree.toprettyxml( + indent=3D"\t", newl=3D"\n", encoding=3D"utf-8")) newfile.close() =20 + if __name__ =3D=3D '__main__': sys.exit(main()) diff --git a/BaseTools/Scripts/UpdateBuildVersions.py b/BaseTools/Scripts/U= pdateBuildVersions.py index 0f019f25cf50..d5174d040b44 100755 --- a/BaseTools/Scripts/UpdateBuildVersions.py +++ b/BaseTools/Scripts/UpdateBuildVersions.py @@ -1,4 +1,4 @@ -## @file +# @file # Update build revisions of the tools when performing a developer build # # This script will modife the C/Include/Common/BuildVersion.h file and the= two @@ -27,7 +27,8 @@ SYS_ENV_ERR =3D "ERROR : %s system environment variable m= ust be set prior to runni =20 __execname__ =3D "UpdateBuildVersions.py" SVN_REVISION =3D "$LastChangedRevision: 3 $" -SVN_REVISION =3D SVN_REVISION.replace("$LastChangedRevision:", "").replace= ("$", "").strip() +SVN_REVISION =3D SVN_REVISION.replace( + "$LastChangedRevision:", "").replace("$", "").strip() __copyright__ =3D "Copyright (c) 2014, Intel Corporation. All rights reser= ved." VERSION_NUMBER =3D "0.7.0" __version__ =3D "Version %s.%s" % (VERSION_NUMBER, SVN_REVISION) @@ -74,13 +75,16 @@ def ShellCommandResults(CmdLine, Opt): =20 returnValue =3D 0 try: - subprocess.check_call(args=3Dshlex.split(CmdLine), stderr=3Dsubpro= cess.STDOUT, stdout=3Dfile_list) + subprocess.check_call(args=3Dshlex.split(CmdLine), + stderr=3Dsubprocess.STDOUT, stdout=3Dfile_li= st) except subprocess.CalledProcessError as err_val: file_list.close() if not Opt.silent: - sys.stderr.write("ERROR : %d : %s\n" % (err_val.returncode, er= r_val.__str__())) + sys.stderr.write("ERROR : %d : %s\n" % + (err_val.returncode, err_val.__str__())) if os.path.exists(filename): - sys.stderr.write(" : Partial results may be in this f= ile: %s\n" % filename) + sys.stderr.write( + " : Partial results may be in this file: %s\n" % = filename) sys.stderr.flush() returnValue =3D err_val.returncode =20 @@ -91,7 +95,8 @@ def ShellCommandResults(CmdLine, Opt): sys.stderr.write("I/O ERROR : %s : %s\n" % (str(errno), strerr= or)) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLin= e) if os.path.exists(filename): - sys.stderr.write(" : Partial results may be in this f= ile: %s\n" % filename) + sys.stderr.write( + " : Partial results may be in this file: %s\n" % = filename) sys.stderr.flush() returnValue =3D errno =20 @@ -102,16 +107,19 @@ def ShellCommandResults(CmdLine, Opt): sys.stderr.write("OS ERROR : %s : %s\n" % (str(errno), strerro= r)) sys.stderr.write("ERROR : this command failed : %s\n" % CmdLin= e) if os.path.exists(filename): - sys.stderr.write(" : Partial results may be in this f= ile: %s\n" % filename) + sys.stderr.write( + " : Partial results may be in this file: %s\n" % = filename) sys.stderr.flush() returnValue =3D errno =20 except KeyboardInterrupt: file_list.close() if not Opt.silent: - sys.stderr.write("ERROR : Command terminated by user : %s\n" %= CmdLine) + sys.stderr.write( + "ERROR : Command terminated by user : %s\n" % CmdLine) if os.path.exists(filename): - sys.stderr.write(" : Partial results may be in this f= ile: %s\n" % filename) + sys.stderr.write( + " : Partial results may be in this file: %s\n" % = filename) sys.stderr.flush() returnValue =3D 1 =20 @@ -136,14 +144,15 @@ def ShellCommandResults(CmdLine, Opt): def UpdateBuildVersionPython(Rev, UserModified, opts): """ This routine will update the BuildVersion.h files in the C source = tree """ for SubDir in ["Common", "UPT"]: - PyPath =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "= Python", SubDir) + PyPath =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir) BuildVersionPy =3D os.path.join(PyPath, "BuildVersion.py") fd_ =3D open(os.path.normpath(BuildVersionPy), 'r') contents =3D fd_.readlines() fd_.close() if opts.HAVE_SVN is False: BuildVersionOrig =3D os.path.join(PyPath, "orig_BuildVersion.p= y") - fd_ =3D open (BuildVersionOrig, 'w') + fd_ =3D open(BuildVersionOrig, 'w') for line in contents: fd_.write(line) fd_.flush() @@ -166,7 +175,8 @@ def UpdateBuildVersionPython(Rev, UserModified, opts): =20 def UpdateBuildVersionH(Rev, UserModified, opts): """ This routine will update the BuildVersion.h files in the C source = tree """ - CPath =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "C", "= Include", "Common") + CPath =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common") BuildVersionH =3D os.path.join(CPath, "BuildVersion.h") fd_ =3D open(os.path.normpath(BuildVersionH), 'r') contents =3D fd_.readlines() @@ -185,7 +195,7 @@ def UpdateBuildVersionH(Rev, UserModified, opts): new_line =3D "#define __BUILD_VERSION \"Developer Build based = on Revision: %s\"" % Rev if UserModified: new_line =3D "#define __BUILD_VERSION \"Developer Build ba= sed on Revision: %s with Modified Sources\"" % \ - Rev + Rev new_content.append(new_line) continue new_content.append(line) @@ -222,7 +232,8 @@ def RevertCmd(Filename, Opt): =20 except KeyboardInterrupt: if not Opt.silent: - sys.stderr.write("ERROR : Command terminated by user : %s\n" %= CmdLine) + sys.stderr.write( + "ERROR : Command terminated by user : %s\n" % CmdLine) sys.stderr.flush() =20 if Opt.verbose: @@ -236,7 +247,8 @@ def GetSvnRevision(opts): Modified =3D False =20 if opts.HAVE_SVN is False: - sys.stderr.write("WARNING: the svn command-line tool is not availa= ble.\n") + sys.stderr.write( + "WARNING: the svn command-line tool is not available.\n") return (Revision, Modified) =20 SrcPath =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source") @@ -323,7 +335,8 @@ def CheckOriginals(Opts): Returns 0 if this succeeds, or 1 if the copy function fails. It will a= lso return 0 if the orig_BuildVersion.* file does not exist. """ - CPath =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "C", "= Include", "Common") + CPath =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common") BuildVersionH =3D os.path.join(CPath, "BuildVersion.h") OrigBuildVersionH =3D os.path.join(CPath, "orig_BuildVersion.h") if not os.path.exists(OrigBuildVersionH): @@ -331,7 +344,8 @@ def CheckOriginals(Opts): if CopyOrig(OrigBuildVersionH, BuildVersionH, Opts): return 1 for SubDir in ["Common", "UPT"]: - PyPath =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source", "= Python", SubDir) + PyPath =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir) BuildVersionPy =3D os.path.join(PyPath, "BuildVersion.h") OrigBuildVersionPy =3D os.path.join(PyPath, "orig_BuildVersion.h") if not os.path.exists(OrigBuildVersionPy): @@ -351,12 +365,15 @@ def RevertBuildVersionFiles(opts): return 1 return 0 # SVN is available - BuildVersionH =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "Source"= , "C", "Include", "Common", "BuildVersion.h") + BuildVersionH =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "C", "Include", "Common",= "BuildVersion.h") RevertCmd(BuildVersionH, opts) for SubDir in ["Common", "UPT"]: - BuildVersionPy =3D os.path.join(os.environ['BASE_TOOLS_PATH'], "So= urce", "Python", SubDir, "BuildVersion.py") + BuildVersionPy =3D os.path.join( + os.environ['BASE_TOOLS_PATH'], "Source", "Python", SubDir, "Bu= ildVersion.py") RevertCmd(BuildVersionPy, opts) =20 + def UpdateRevisionFiles(): """ Main routine that will update the BuildVersion.py and BuildVersion= .h files.""" options =3D ParseOptions() @@ -368,10 +385,10 @@ def UpdateRevisionFiles(): sys.stderr.write(SYS_ENV_ERR % 'BASE_TOOLS_PATH') return 1 if not os.path.exists(os.environ['BASE_TOOLS_PATH']): - sys.stderr.write("Unable to locate the %s directory." % os.environ= ['BASE_TOOLS_PATH']) + sys.stderr.write("Unable to locate the %s directory." % + os.environ['BASE_TOOLS_PATH']) return 1 =20 - options.HAVE_SVN =3D CheckSvn(options) if options.TEST_SVN: return (not options.HAVE_SVN) @@ -384,7 +401,8 @@ def UpdateRevisionFiles(): RevertBuildVersionFiles(options) Revision, Modified =3D GetSvnRevision(options) if options.verbose: - sys.stdout.write("Revision: %s is Modified: %s\n" % (Revision,= Modified)) + sys.stdout.write("Revision: %s is Modified: %s\n" % + (Revision, Modified)) sys.stdout.flush() UpdateBuildVersionH(Revision, Modified, options) UpdateBuildVersionPython(Revision, Modified, options) @@ -394,5 +412,3 @@ def UpdateRevisionFiles(): =20 if __name__ =3D=3D "__main__": sys.exit(UpdateRevisionFiles()) - - diff --git a/BaseTools/Scripts/efi_debugging.py b/BaseTools/Scripts/efi_deb= ugging.py index 9848cd5968c7..8ea0184097e8 100755 --- a/BaseTools/Scripts/efi_debugging.py +++ b/BaseTools/Scripts/efi_debugging.py @@ -1668,11 +1668,11 @@ class EfiDevicePath: node, extra =3D self._ctype_read_ex(type_str, ptr, hdr.Len= gth) if 'VENDOR_DEVICE_PATH' in type(node).__name__: guid_type =3D self.guid_override_dict.get( - GuidNames.to_uuid(node.Guid), None) + GuidNames.to_uuid(node.Guid), None) if guid_type: # use the ctype associated with the GUID node, extra =3D self._ctype_read_ex( - guid_type, ptr, hdr.Length) + guid_type, ptr, hdr.Length) =20 instance.append((type(node).__name__, hdr.Type, hdr.SubType, hdr.Length, node, extra)) diff --git a/BaseTools/Scripts/efi_gdb.py b/BaseTools/Scripts/efi_gdb.py index f3e7fd9d0c28..7cf62067a051 100755 --- a/BaseTools/Scripts/efi_gdb.py +++ b/BaseTools/Scripts/efi_gdb.py @@ -852,6 +852,7 @@ class LoadEmulatorEfiSymbols(gdb.Breakpoint): Note: make sure SecGdbScriptBreak is not optimized away! Also turn off the dlopen() flow like on macOS. ''' + def stop(self): symbols =3D EfiSymbols() # Emulator adds SizeOfHeaders so we need file alignment to search diff --git a/BaseTools/Source/C/Makefiles/NmakeSubdirs.py b/BaseTools/Sourc= e/C/Makefiles/NmakeSubdirs.py index 1f4a45004f4b..717cb700ac4f 100644 --- a/BaseTools/Source/C/Makefiles/NmakeSubdirs.py +++ b/BaseTools/Source/C/Makefiles/NmakeSubdirs.py @@ -20,13 +20,15 @@ import subprocess import multiprocessing import copy import sys -__prog__ =3D 'NmakeSubdirs' -__version__ =3D '%s Version %s' % (__prog__, '0.10 ') -__copyright__ =3D 'Copyright (c) 2018, Intel Corporation. All rights res= erved.' +__prog__ =3D 'NmakeSubdirs' +__version__ =3D '%s Version %s' % (__prog__, '0.10 ') +__copyright__ =3D 'Copyright (c) 2018, Intel Corporation. All rights reser= ved.' __description__ =3D 'Replace for NmakeSubdirs.bat in windows ,support para= llel build for nmake.\n' =20 cpu_count =3D multiprocessing.cpu_count() output_lock =3D threading.Lock() + + def RunCommand(WorkDir=3DNone, *Args, **kwargs): if WorkDir is None: WorkDir =3D os.curdir @@ -34,17 +36,21 @@ def RunCommand(WorkDir=3DNone, *Args, **kwargs): kwargs["stderr"] =3D subprocess.STDOUT if "stdout" not in kwargs: kwargs["stdout"] =3D subprocess.PIPE - p =3D subprocess.Popen(Args, cwd=3DWorkDir, stderr=3Dkwargs["stderr"],= stdout=3Dkwargs["stdout"]) + p =3D subprocess.Popen( + Args, cwd=3DWorkDir, stderr=3Dkwargs["stderr"], stdout=3Dkwargs["s= tdout"]) stdout, stderr =3D p.communicate() message =3D "" if stdout is not None: - message =3D stdout.decode(errors=3D'ignore') #for compatibility in= python 2 and 3 + # for compatibility in python 2 and 3 + message =3D stdout.decode(errors=3D'ignore') =20 if p.returncode !=3D 0: - raise RuntimeError("Error while execute command \'{0}\' in direcot= ry {1}\n{2}".format(" ".join(Args), WorkDir, message)) + raise RuntimeError("Error while execute command \'{0}\' in direcot= ry {1}\n{2}".format( + " ".join(Args), WorkDir, message)) =20 output_lock.acquire(True) - print("execute command \"{0}\" in directory {1}".format(" ".join(Args)= , WorkDir)) + print("execute command \"{0}\" in directory {1}".format( + " ".join(Args), WorkDir)) try: print(message) except: @@ -53,6 +59,7 @@ def RunCommand(WorkDir=3DNone, *Args, **kwargs): =20 return p.returncode, stdout =20 + class TaskUnit(object): def __init__(self, func, args, kwargs): self.func =3D func @@ -71,6 +78,7 @@ class TaskUnit(object): =20 return "{0}({1})".format(self.func.__name__, ",".join(para)) =20 + class ThreadControl(object): =20 def __init__(self, maxthread): @@ -123,7 +131,8 @@ class ThreadControl(object): try: task.run() except RuntimeError as e: - if self.error: break + if self.error: + break self.errorLock.acquire(True) self.error =3D True self.errorMsg =3D str(e) @@ -135,6 +144,7 @@ class ThreadControl(object): self.running.remove(threading.currentThread()) self.runningLock.release() =20 + def Run(): curdir =3D os.path.abspath(os.curdir) if len(args.subdirs) =3D=3D 1: @@ -142,25 +152,30 @@ def Run(): if args.jobs =3D=3D 1: try: for dir in args.subdirs: - RunCommand(os.path.join(curdir, dir), "nmake", args.target= , stdout=3Dsys.stdout, stderr=3Dsubprocess.STDOUT) + RunCommand(os.path.join(curdir, dir), "nmake", args.target, + stdout=3Dsys.stdout, stderr=3Dsubprocess.STDOUT) except RuntimeError: exit(1) else: controller =3D ThreadControl(args.jobs) for dir in args.subdirs: - controller.addTask(RunCommand, os.path.join(curdir, dir), "nma= ke", args.target) + controller.addTask(RunCommand, os.path.join( + curdir, dir), "nmake", args.target) controller.startSchedule() controller.waitComplete() if controller.error: exit(1) =20 + if __name__ =3D=3D "__main__": - parser =3D argparse.ArgumentParser(prog=3D__prog__, description=3D__de= scription__ + __copyright__, conflict_handler=3D'resolve') + parser =3D argparse.ArgumentParser( + prog=3D__prog__, description=3D__description__ + __copyright__, co= nflict_handler=3D'resolve') =20 parser.add_argument("target", help=3D"the target for nmake") - parser.add_argument("subdirs", nargs=3D"+", help=3D"the relative dir p= ath of makefile") - parser.add_argument("--jobs", type=3Dint, dest=3D"jobs", default=3Dcpu= _count, help=3D"thread number") + parser.add_argument("subdirs", nargs=3D"+", + help=3D"the relative dir path of makefile") + parser.add_argument("--jobs", type=3Dint, dest=3D"jobs", + default=3Dcpu_count, help=3D"thread number") parser.add_argument('--version', action=3D'version', version=3D__versi= on__) args =3D parser.parse_args() Run() - diff --git a/BaseTools/Source/C/PyEfiCompressor/setup.py b/BaseTools/Source= /C/PyEfiCompressor/setup.py index 3daf178b5401..506bace9cb7e 100644 --- a/BaseTools/Source/C/PyEfiCompressor/setup.py +++ b/BaseTools/Source/C/PyEfiCompressor/setup.py @@ -1,4 +1,4 @@ -## @file +# @file # package and install PyEfiCompressor extension # # Copyright (c) 2008, Intel Corporation. All rights reserved.
        @@ -23,15 +23,15 @@ setup( Extension( 'EfiCompressor', sources=3D[ - os.path.join(BaseToolsDir, 'Source', 'C', 'Common', 'Decom= press.c'), + os.path.join(BaseToolsDir, 'Source', 'C', + 'Common', 'Decompress.c'), 'EfiCompressor.c' - ], + ], include_dirs=3D[ os.path.join(BaseToolsDir, 'Source', 'C', 'Include'), os.path.join(BaseToolsDir, 'Source', 'C', 'Include', 'Ia32= '), os.path.join(BaseToolsDir, 'Source', 'C', 'Common') - ], - ) - ], - ) - + ], + ) + ], +) diff --git a/BaseTools/Source/Python/AmlToC/AmlToC.py b/BaseTools/Source/Py= thon/AmlToC/AmlToC.py index 346de7159de7..80f18c04b049 100644 --- a/BaseTools/Source/Python/AmlToC/AmlToC.py +++ b/BaseTools/Source/Python/AmlToC/AmlToC.py @@ -1,4 +1,4 @@ -## @file +# @file # # Convert an AML file to a .c file containing the AML bytecode stored in a # C array. @@ -24,10 +24,12 @@ Tables\Dsdt.c will contain a C array named "dsdt_aml_co= de" that contains the AML bytecode. """ =20 -## Parse the command line arguments. +# Parse the command line arguments. # # @retval A argparse.NameSpace instance, containing parsed values. # + + def ParseArgs(): # Initialize the parser. Parser =3D argparse.ArgumentParser(description=3D__description__) @@ -50,7 +52,8 @@ def ParseArgs(): with open(Args.InputFile, "rb") as fIn: Signature =3D str(fIn.read(4)) if ("DSDT" not in Signature) and ("SSDT" not in Signature): - EdkLogger.info("Invalid file type. File does not have a va= lid DSDT or SSDT signature: {}".format(Args.InputFile)) + EdkLogger.info( + "Invalid file type. File does not have a valid DSDT or= SSDT signature: {}".format(Args.InputFile)) return None =20 # Get the basename of the input file. @@ -70,7 +73,7 @@ def ParseArgs(): =20 return Args =20 -## Convert an AML file to a .c file containing the AML bytecode stored +# Convert an AML file to a .c file containing the AML bytecode stored # in a C array. # # @param InputFile Path to the input AML file. @@ -78,11 +81,13 @@ def ParseArgs(): # @param BaseName Base name of the input file. # This is also the name of the generated .c file. # + + def AmlToC(InputFile, OutputFile, BaseName): =20 ArrayName =3D BaseName.lower() + "_aml_code" FileHeader =3D\ -""" + """ // This file has been generated from: // -Python script: {} // -Input AML file: {} @@ -91,7 +96,8 @@ def AmlToC(InputFile, OutputFile, BaseName): =20 with open(InputFile, "rb") as fIn, open(OutputFile, "w") as fOut: # Write header. - fOut.write(FileHeader.format(os.path.abspath(InputFile), os.path.a= bspath(__file__))) + fOut.write(FileHeader.format(os.path.abspath( + InputFile), os.path.abspath(__file__))) =20 # Write the array and its content. fOut.write("unsigned char {}[] =3D {{\n ".format(ArrayName)) @@ -105,7 +111,7 @@ def AmlToC(InputFile, OutputFile, BaseName): byte =3D fIn.read(1) fOut.write("\n};\n") =20 -## Main method +# Main method # # This method: # 1- Initialize an EdkLogger instance. @@ -116,6 +122,8 @@ def AmlToC(InputFile, OutputFile, BaseName): # @retval 0 Success. # @retval 1 Error. # + + def Main(): # Initialize an EdkLogger instance. EdkLogger.Initialize() @@ -128,15 +136,18 @@ def Main(): =20 # Convert an AML file to a .c file containing the AML bytecode sto= red # in a C array. - AmlToC(CommandArguments.InputFile, CommandArguments.OutputFile, Co= mmandArguments.BaseName) + AmlToC(CommandArguments.InputFile, + CommandArguments.OutputFile, CommandArguments.BaseName) except Exception as e: print(e) return 1 =20 return 0 =20 + if __name__ =3D=3D '__main__': r =3D Main() # 0-127 is a safe return range, and 1 is a standard default error - if r < 0 or r > 127: r =3D 1 + if r < 0 or r > 127: + r =3D 1 sys.exit(r) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index d9ee699d8f30..2181cf521215 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1,4 +1,4 @@ -## @file +# @file # Generate AutoGen.h, AutoGen.c and *.depex files # # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
        @@ -8,20 +8,23 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # from __future__ import print_function from __future__ import absolute_import from Common.DataType import TAB_STAR -## Base class for AutoGen +# Base class for AutoGen # # This class just implements the cache mechanism of AutoGen objects. # + + class AutoGen(object): # database to maintain the objects in each child class - __ObjectCache =3D {} # (BuildTarget, ToolChain, ARCH, platform file= ): AutoGen object + # (BuildTarget, ToolChain, ARCH, platform file): AutoGen object + __ObjectCache =3D {} =20 - ## Factory method + # Factory method # # @param Class class object of real AutoGen class # (WorkspaceAutoGen, ModuleAutoGen or Platfo= rmAutoGen) @@ -44,17 +47,17 @@ class AutoGen(object): RetVal =3D cls.__ObjectCache[Key] =3D super(AutoGen, cls).__new__(= cls) return RetVal =20 - - ## hash() operator + # hash() operator # # The file path of platform file will be used to represent hash value= of this object # # @retval int Hash value of the file path of platform file # + def __hash__(self): return hash(self.MetaFile) =20 - ## str() operator + # str() operator # # The file path of platform file will be used to represent this object # @@ -63,7 +66,7 @@ class AutoGen(object): def __str__(self): return str(self.MetaFile) =20 - ## "=3D=3D" operator + # "=3D=3D" operator def __eq__(self, Other): return Other and self.MetaFile =3D=3D Other =20 @@ -71,31 +74,34 @@ class AutoGen(object): def Cache(cls): return cls.__ObjectCache =20 + # # The priority list while override build option # -PrioList =3D {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_AT= TRIBUTE (Highest) - "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTR= IBUTE - "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTR= IBUTE - "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTR= IBUTE - "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTR= IBUTE - "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTR= IBUTE - "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTR= IBUTE - "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTR= IBUTE - "0x00101" : 5, # ******_*********_ARCH_***********_ATTR= IBUTE - "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTR= IBUTE - "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTR= IBUTE - "0x10001" : 2, # TARGET_*********_****_***********_ATTR= IBUTE - "0x00001" : 1} # ******_*********_****_***********_ATTR= IBUTE (Lowest) -## Calculate the priority value of the build option +PrioList =3D {"0x11111": 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUT= E (Highest) + "0x01111": 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE + "0x10111": 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE + "0x00111": 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE + "0x11011": 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE + "0x01011": 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE + "0x10011": 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE + "0x00011": 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE + "0x11101": 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE + "0x01101": 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE + "0x10101": 6, # TARGET_*********_ARCH_***********_ATTRIBUTE + "0x00101": 5, # ******_*********_ARCH_***********_ATTRIBUTE + "0x11001": 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE + "0x01001": 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE + "0x10001": 2, # TARGET_*********_****_***********_ATTRIBUTE + "0x00001": 1} # ******_*********_****_***********_ATTRIBUTE (= Lowest) +# Calculate the priority value of the build option # # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_= COMMANDTYPE_ATTRIBUTE # # @retval Value Priority value based on the priority list. # + + def CalculatePriorityValue(Key): Target, ToolChain, Arch, CommandType, Attr =3D Key.split('_') PriorityValue =3D 0x11111 diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py b/BaseTools/S= ource/Python/AutoGen/AutoGenWorker.py index 0ba2339bed64..3b90571d505f 100755 --- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py +++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py @@ -1,4 +1,4 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019, Intel Corporation. All rights reserved.
        @@ -9,7 +9,7 @@ import multiprocessing as mp import threading from Common.Misc import PathClass from AutoGen.ModuleAutoGen import ModuleAutoGen -from AutoGen.ModuleAutoGenHelper import WorkSpaceInfo,AutoGenInfo +from AutoGen.ModuleAutoGenHelper import WorkSpaceInfo, AutoGenInfo import Common.GlobalData as GlobalData import Common.EdkLogger as EdkLogger import os @@ -26,6 +26,7 @@ from AutoGen.DataPipe import MemoryDataPipe import logging import time =20 + def clearQ(q): try: while True: @@ -33,16 +34,19 @@ def clearQ(q): except Empty: pass =20 + class LogAgent(threading.Thread): - def __init__(self,log_q,log_level,log_file=3DNone): - super(LogAgent,self).__init__() + def __init__(self, log_q, log_level, log_file=3DNone): + super(LogAgent, self).__init__() self.log_q =3D log_q self.log_level =3D log_level self.log_file =3D log_file + def InitLogger(self): # For DEBUG level (All DEBUG_0~9 are applicable) self._DebugLogger_agent =3D logging.getLogger("tool_debug_agent") - _DebugFormatter =3D logging.Formatter("[%(asctime)s.%(msecs)d]: %(= message)s", datefmt=3D"%H:%M:%S") + _DebugFormatter =3D logging.Formatter( + "[%(asctime)s.%(msecs)d]: %(message)s", datefmt=3D"%H:%M:%S") self._DebugLogger_agent.setLevel(self.log_level) _DebugChannel =3D logging.StreamHandler(sys.stdout) _DebugChannel.setFormatter(_DebugFormatter) @@ -71,7 +75,7 @@ class LogAgent(threading.Thread): _Ch.setFormatter(_DebugFormatter) self._DebugLogger_agent.addHandler(_Ch) =20 - _Ch=3D logging.FileHandler(self.log_file) + _Ch =3D logging.FileHandler(self.log_file) _Ch.setFormatter(_InfoFormatter) self._InfoLogger_agent.addHandler(_Ch) =20 @@ -86,23 +90,30 @@ class LogAgent(threading.Thread): if log_message is None: break if log_message.name =3D=3D "tool_error": - self._ErrorLogger_agent.log(log_message.levelno,log_messag= e.getMessage()) + self._ErrorLogger_agent.log( + log_message.levelno, log_message.getMessage()) elif log_message.name =3D=3D "tool_info": - self._InfoLogger_agent.log(log_message.levelno,log_message= .getMessage()) + self._InfoLogger_agent.log( + log_message.levelno, log_message.getMessage()) elif log_message.name =3D=3D "tool_debug": - self._DebugLogger_agent.log(log_message.levelno,log_messag= e.getMessage()) + self._DebugLogger_agent.log( + log_message.levelno, log_message.getMessage()) else: - self._InfoLogger_agent.log(log_message.levelno,log_message= .getMessage()) + self._InfoLogger_agent.log( + log_message.levelno, log_message.getMessage()) =20 def kill(self): self.log_q.put(None) + + class AutoGenManager(threading.Thread): - def __init__(self,autogen_workers, feedback_q,error_event): - super(AutoGenManager,self).__init__() + def __init__(self, autogen_workers, feedback_q, error_event): + super(AutoGenManager, self).__init__() self.autogen_workers =3D autogen_workers self.feedback_q =3D feedback_q self.Status =3D True self.error_event =3D error_event + def run(self): try: fin_num =3D 0 @@ -113,10 +124,12 @@ class AutoGenManager(threading.Thread): if badnews =3D=3D "Done": fin_num +=3D 1 elif badnews =3D=3D "QueueEmpty": - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (= os.getpid(), badnews)) + EdkLogger.debug(EdkLogger.DEBUG_9, + "Worker %s: %s" % (os.getpid(), badnew= s)) self.TerminateWorkers() else: - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (= os.getpid(), badnews)) + EdkLogger.debug(EdkLogger.DEBUG_9, + "Worker %s: %s" % (os.getpid(), badnew= s)) self.Status =3D False self.TerminateWorkers() if fin_num =3D=3D len(self.autogen_workers): @@ -143,20 +156,23 @@ class AutoGenManager(threading.Thread): cache_num +=3D 1 else: GlobalData.gModuleAllCacheStatus.add(item) - if cache_num =3D=3D len(self.autogen_workers): + if cache_num =3D=3D len(self.autogen_workers): break except: - print ("cache_q error") + print("cache_q error") =20 def TerminateWorkers(self): self.error_event.set() + def kill(self): self.feedback_q.put(None) + + class AutoGenWorkerInProcess(mp.Process): - def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_loc= k,cache_q,log_q,error_event): + def __init__(self, module_queue, data_pipe_file_path, feedback_q, file= _lock, cache_q, log_q, error_event): mp.Process.__init__(self) self.module_queue =3D module_queue - self.data_pipe_file_path =3Ddata_pipe_file_path + self.data_pipe_file_path =3D data_pipe_file_path self.data_pipe =3D None self.feedback_q =3D feedback_q self.PlatformMetaFileSet =3D {} @@ -164,12 +180,14 @@ class AutoGenWorkerInProcess(mp.Process): self.cache_q =3D cache_q self.log_q =3D log_q self.error_event =3D error_event - def GetPlatformMetaFile(self,filepath,root): + + def GetPlatformMetaFile(self, filepath, root): try: - return self.PlatformMetaFileSet[(filepath,root)] + return self.PlatformMetaFileSet[(filepath, root)] except: - self.PlatformMetaFileSet[(filepath,root)] =3D filepath - return self.PlatformMetaFileSet[(filepath,root)] + self.PlatformMetaFileSet[(filepath, root)] =3D filepath + return self.PlatformMetaFileSet[(filepath, root)] + def run(self): try: taskname =3D "Init" @@ -178,7 +196,8 @@ class AutoGenWorkerInProcess(mp.Process): self.data_pipe =3D MemoryDataPipe() self.data_pipe.load(self.data_pipe_file_path) except: - self.feedback_q.put(taskname + ":" + "load data pipe %= s failed." % self.data_pipe_file_path) + self.feedback_q.put( + taskname + ":" + "load data pipe %s failed." % sel= f.data_pipe_file_path) EdkLogger.LogClientInitialize(self.log_q) loglevel =3D self.data_pipe.Get("LogLevel") if not loglevel: @@ -193,12 +212,13 @@ class AutoGenWorkerInProcess(mp.Process): PackagesPath =3D os.getenv("PACKAGES_PATH") mws.setWs(workspacedir, PackagesPath) self.Wa =3D WorkSpaceInfo( - workspacedir,active_p,target,toolchain,archlist - ) + workspacedir, active_p, target, toolchain, archlist + ) self.Wa._SrcTimeStamp =3D self.data_pipe.Get("Workspace_timest= amp") GlobalData.gGlobalDefines =3D self.data_pipe.Get("G_defines") GlobalData.gCommandLineDefines =3D self.data_pipe.Get("CL_defi= nes") - GlobalData.gCommandMaxLength =3D self.data_pipe.Get('gCommandM= axLength') + GlobalData.gCommandMaxLength =3D self.data_pipe.Get( + 'gCommandMaxLength') os.environ._data =3D self.data_pipe.Get("Env_Var") GlobalData.gWorkspace =3D workspacedir GlobalData.gDisableIncludePathCheck =3D False @@ -208,23 +228,26 @@ class AutoGenWorkerInProcess(mp.Process): GlobalData.gUseHashCache =3D self.data_pipe.Get("UseHashCache") GlobalData.gBinCacheSource =3D self.data_pipe.Get("BinCacheSou= rce") GlobalData.gBinCacheDest =3D self.data_pipe.Get("BinCacheDest") - GlobalData.gPlatformHashFile =3D self.data_pipe.Get("PlatformH= ashFile") + GlobalData.gPlatformHashFile =3D self.data_pipe.Get( + "PlatformHashFile") GlobalData.gModulePreMakeCacheStatus =3D dict() GlobalData.gModuleMakeCacheStatus =3D dict() GlobalData.gHashChainStatus =3D dict() GlobalData.gCMakeHashFile =3D dict() GlobalData.gModuleHashFile =3D dict() GlobalData.gFileHashDict =3D dict() - GlobalData.gEnableGenfdsMultiThread =3D self.data_pipe.Get("En= ableGenfdsMultiThread") - GlobalData.gPlatformFinalPcds =3D self.data_pipe.Get("gPlatfor= mFinalPcds") + GlobalData.gEnableGenfdsMultiThread =3D self.data_pipe.Get( + "EnableGenfdsMultiThread") + GlobalData.gPlatformFinalPcds =3D self.data_pipe.Get( + "gPlatformFinalPcds") GlobalData.file_lock =3D self.file_lock CommandTarget =3D self.data_pipe.Get("CommandTarget") pcd_from_build_option =3D [] for pcd_tuple in self.data_pipe.Get("BuildOptPcd"): - pcd_id =3D ".".join((pcd_tuple[0],pcd_tuple[1])) + pcd_id =3D ".".join((pcd_tuple[0], pcd_tuple[1])) if pcd_tuple[2].strip(): - pcd_id =3D ".".join((pcd_id,pcd_tuple[2])) - pcd_from_build_option.append("=3D".join((pcd_id,pcd_tuple[= 3]))) + pcd_id =3D ".".join((pcd_id, pcd_tuple[2])) + pcd_from_build_option.append("=3D".join((pcd_id, pcd_tuple= [3]))) GlobalData.BuildOptionPcd =3D pcd_from_build_option module_count =3D 0 FfsCmd =3D self.data_pipe.Get("FfsCommand") @@ -232,36 +255,40 @@ class AutoGenWorkerInProcess(mp.Process): FfsCmd =3D {} GlobalData.FfsCmd =3D FfsCmd PlatformMetaFile =3D self.GetPlatformMetaFile(self.data_pipe.G= et("P_Info").get("ActivePlatform"), - self.data_pipe.Get("P_Info").= get("WorkspaceDir")) + self.data_pipe.Get= ("P_Info").get("WorkspaceDir")) while True: if self.error_event.is_set(): break module_count +=3D 1 try: - module_file,module_root,module_path,module_basename,mo= dule_originalpath,module_arch,IsLib =3D self.module_queue.get_nowait() + module_file, module_root, module_path, module_basename= , module_originalpath, module_arch, IsLib =3D self.module_queue.get_nowait() except Empty: - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (= os.getpid(), "Fake Empty.")) + EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % ( + os.getpid(), "Fake Empty.")) time.sleep(0.01) continue if module_file is None: - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (= os.getpid(), "Worker get the last item in the queue.")) + EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % ( + os.getpid(), "Worker get the last item in the queu= e.")) self.feedback_q.put("QueueEmpty") time.sleep(0.01) continue =20 - modulefullpath =3D os.path.join(module_root,module_file) - taskname =3D " : ".join((modulefullpath,module_arch)) - module_metafile =3D PathClass(module_file,module_root) + modulefullpath =3D os.path.join(module_root, module_file) + taskname =3D " : ".join((modulefullpath, module_arch)) + module_metafile =3D PathClass(module_file, module_root) if module_path: module_metafile.Path =3D module_path if module_basename: module_metafile.BaseName =3D module_basename if module_originalpath: - module_metafile.OriginalPath =3D PathClass(module_orig= inalpath,module_root) + module_metafile.OriginalPath =3D PathClass( + module_originalpath, module_root) arch =3D module_arch target =3D self.data_pipe.Get("P_Info").get("Target") toolchain =3D self.data_pipe.Get("P_Info").get("ToolChain") - Ma =3D ModuleAutoGen(self.Wa,module_metafile,target,toolch= ain,arch,PlatformMetaFile,self.data_pipe) + Ma =3D ModuleAutoGen(self.Wa, module_metafile, target, + toolchain, arch, PlatformMetaFile, self= .data_pipe) Ma.IsLibrary =3D IsLib # SourceFileList calling sequence impact the makefile stri= ng sequence. # Create cached SourceFileList here to unify its calling s= equence for both @@ -275,13 +302,16 @@ class AutoGenWorkerInProcess(mp.Process): self.feedback_q.put(taskname) =20 if CacheResult: - self.cache_q.put((Ma.MetaFile.Path, Ma.Arch, "PreM= akeCache", True)) + self.cache_q.put( + (Ma.MetaFile.Path, Ma.Arch, "PreMakeCache", Tr= ue)) continue else: - self.cache_q.put((Ma.MetaFile.Path, Ma.Arch, "PreM= akeCache", False)) + self.cache_q.put( + (Ma.MetaFile.Path, Ma.Arch, "PreMakeCache", Fa= lse)) =20 Ma.CreateCodeFile(False) - Ma.CreateMakeFile(False,GenFfsList=3DFfsCmd.get((Ma.MetaFi= le.Path, Ma.Arch),[])) + Ma.CreateMakeFile(False, GenFfsList=3DFfsCmd.get( + (Ma.MetaFile.Path, Ma.Arch), [])) Ma.CreateAsBuiltInf() if GlobalData.gBinCacheSource and CommandTarget in [None, = "", "all"]: try: @@ -291,22 +321,28 @@ class AutoGenWorkerInProcess(mp.Process): self.feedback_q.put(taskname) =20 if CacheResult: - self.cache_q.put((Ma.MetaFile.Path, Ma.Arch, "Make= Cache", True)) + self.cache_q.put( + (Ma.MetaFile.Path, Ma.Arch, "MakeCache", True)) continue else: - self.cache_q.put((Ma.MetaFile.Path, Ma.Arch, "Make= Cache", False)) + self.cache_q.put( + (Ma.MetaFile.Path, Ma.Arch, "MakeCache", False= )) =20 except Exception as e: - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (os.getpi= d(), str(e))) + EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % + (os.getpid(), str(e))) self.feedback_q.put(taskname) finally: - EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % (os.getpi= d(), "Done")) + EdkLogger.debug(EdkLogger.DEBUG_9, "Worker %s: %s" % + (os.getpid(), "Done")) self.feedback_q.put("Done") self.cache_q.put("CacheDone") =20 def printStatus(self): - print("Processs ID: %d Run %d modules in AutoGen " % (os.getpid(),= len(AutoGen.Cache()))) - print("Processs ID: %d Run %d modules in AutoGenInfo " % (os.getpi= d(),len(AutoGenInfo.GetCache()))) + print("Processs ID: %d Run %d modules in AutoGen " % + (os.getpid(), len(AutoGen.Cache()))) + print("Processs ID: %d Run %d modules in AutoGenInfo " % + (os.getpid(), len(AutoGenInfo.GetCache()))) groupobj =3D {} for buildobj in BuildDB.BuildObject.GetCache().values(): if str(buildobj).lower().endswith("dec"): @@ -326,6 +362,9 @@ class AutoGenWorkerInProcess(mp.Process): except: groupobj['inf'] =3D [str(buildobj)] =20 - print("Processs ID: %d Run %d pkg in WDB " % (os.getpid(),len(grou= pobj.get("dec",[])))) - print("Processs ID: %d Run %d pla in WDB " % (os.getpid(),len(grou= pobj.get("dsc",[])))) - print("Processs ID: %d Run %d inf in WDB " % (os.getpid(),len(grou= pobj.get("inf",[])))) + print("Processs ID: %d Run %d pkg in WDB " % + (os.getpid(), len(groupobj.get("dec", [])))) + print("Processs ID: %d Run %d pla in WDB " % + (os.getpid(), len(groupobj.get("dsc", [])))) + print("Processs ID: %d Run %d inf in WDB " % + (os.getpid(), len(groupobj.get("inf", [])))) diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/Python/AutoGen/BuildEngine.py index 752a1a1f6a86..7f810dce97de 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -1,4 +1,4 @@ -## @file +# @file # The engine for building files # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -9,6 +9,7 @@ # Import Modules # from __future__ import print_function +import Common.EdkLogger as EdkLogger import Common.LongFilePathOs as os import re import copy @@ -24,26 +25,29 @@ from Common.TargetTxtClassObject import TargetTxtDict gDefaultBuildRuleFile =3D 'build_rule.txt' AutoGenReqBuildRuleVerNum =3D '0.1' =20 -import Common.EdkLogger as EdkLogger =20 -## Convert file type to file list macro name +# Convert file type to file list macro name # # @param FileType The name of file type # # @retval string The name of macro # + def FileListMacro(FileType): return "%sS" % FileType.replace("-", "_").upper() =20 -## Convert file type to list file macro name +# Convert file type to list file macro name # # @param FileType The name of file type # # @retval string The name of macro # + + def ListFileMacro(FileType): return "%s_LIST" % FileListMacro(FileType) =20 + class TargetDescBlock(object): def __init__(self, Inputs, Outputs, Commands, Dependencies): self.InitWorker(Inputs, Outputs, Commands, Dependencies) @@ -77,17 +81,19 @@ class TargetDescBlock(object): def IsMultipleInput(self): return len(self.Inputs) > 1 =20 -## Class for one build rule +# Class for one build rule # # This represents a build rule which can give out corresponding command li= st for # building the given source file(s). The result can be used for generating= the # target for makefile. # + + class FileBuildRule: INC_LIST_MACRO =3D "INC_LIST" INC_MACRO =3D "INC" =20 - ## constructor + # constructor # # @param Input The dictionary representing input file(s) for = a rule # @param Output The list representing output file(s) for a rule @@ -165,28 +171,30 @@ class FileBuildRule: # All build targets generated by this rule for a module self.BuildTargets =3D {} =20 - ## str() function support + # str() function support # # @retval string # def __str__(self): SourceString =3D "" - SourceString +=3D " %s %s %s" % (self.SourceFileType, " ".join(sel= f.SourceFileExtList), self.ExtraSourceFileList) + SourceString +=3D " %s %s %s" % (self.SourceFileType, " ".join( + self.SourceFileExtList), self.ExtraSourceFileList) DestString =3D ", ".join([str(i) for i in self.DestFileList]) CommandString =3D "\n\t".join(self.CommandList) return "%s : %s\n\t%s" % (DestString, SourceString, CommandString) =20 - def Instantiate(self, Macros =3D None): + def Instantiate(self, Macros=3DNone): if Macros is None: Macros =3D {} NewRuleObject =3D copy.copy(self) NewRuleObject.BuildTargets =3D {} NewRuleObject.DestFileList =3D [] for File in self.DestFileList: - NewRuleObject.DestFileList.append(PathClass(NormPath(File, Mac= ros))) + NewRuleObject.DestFileList.append( + PathClass(NormPath(File, Macros))) return NewRuleObject =20 - ## Apply the rule to given source file(s) + # Apply the rule to given source file(s) # # @param SourceFile One file or a list of files to be built # @param RelativeToDir The relative path of the source file @@ -233,24 +241,26 @@ class FileBuildRule: =20 BuildRulePlaceholderDict =3D { # source file - "src" : SrcFile, - "s_path" : SrcPath, - "s_dir" : SrcFileDir, - "s_name" : SrcFileName, - "s_base" : SrcFileBase, - "s_ext" : SrcFileExt, + "src": SrcFile, + "s_path": SrcPath, + "s_dir": SrcFileDir, + "s_name": SrcFileName, + "s_base": SrcFileBase, + "s_ext": SrcFileExt, # destination file - "dst" : DestFile, - "d_path" : DestPath, - "d_name" : DestFileName, - "d_base" : DestFileBase, - "d_ext" : DestFileExt, + "dst": DestFile, + "d_path": DestPath, + "d_name": DestFileName, + "d_base": DestFileBase, + "d_ext": DestFileExt, } =20 DstFile =3D [] for File in self.DestFileList: - File =3D string.Template(str(File)).safe_substitute(BuildRuleP= laceholderDict) - File =3D string.Template(str(File)).safe_substitute(BuildRuleP= laceholderDict) + File =3D string.Template(str(File)).safe_substitute( + BuildRulePlaceholderDict) + File =3D string.Template(str(File)).safe_substitute( + BuildRulePlaceholderDict) DstFile.append(PathClass(File, IsBinary=3DTrue)) =20 if DstFile[0] in self.BuildTargets: @@ -262,14 +272,17 @@ class FileBuildRule: # # Command line should be regenerated since some ma= cros are different # - CommandList =3D self._BuildCommand(BuildRulePlaceh= olderDict) - TargetDesc.InitWorker([SourceFile], DstFile, Comma= ndList, self.ExtraSourceFileList) + CommandList =3D self._BuildCommand( + BuildRulePlaceholderDict) + TargetDesc.InitWorker( + [SourceFile], DstFile, CommandList, self.Extra= SourceFileList) break else: TargetDesc.AddInput(SourceFile) else: CommandList =3D self._BuildCommand(BuildRulePlaceholderDict) - TargetDesc =3D TargetDescBlock([SourceFile], DstFile, CommandL= ist, self.ExtraSourceFileList) + TargetDesc =3D TargetDescBlock( + [SourceFile], DstFile, CommandList, self.ExtraSourceFileLi= st) TargetDesc.ListFileMacro =3D self.ListFileMacro TargetDesc.FileListMacro =3D self.FileListMacro TargetDesc.IncListFileMacro =3D self.IncListFileMacro @@ -282,16 +295,20 @@ class FileBuildRule: def _BuildCommand(self, Macros): CommandList =3D [] for CommandString in self.CommandList: - CommandString =3D string.Template(CommandString).safe_substitu= te(Macros) - CommandString =3D string.Template(CommandString).safe_substitu= te(Macros) + CommandString =3D string.Template( + CommandString).safe_substitute(Macros) + CommandString =3D string.Template( + CommandString).safe_substitute(Macros) CommandList.append(CommandString) return CommandList =20 -## Class for build rules +# Class for build rules # # BuildRule class parses rules defined in a file or passed by caller, and = converts # the rule into FileBuildRule object. # + + class BuildRule: _SectionHeader =3D "SECTIONHEADER" _Section =3D "SECTION" @@ -310,7 +327,7 @@ class BuildRule: _BinaryFileRule =3D FileBuildRule(TAB_DEFAULT_BINARY_FILE, [], [os.pat= h.join("$(OUTPUT_DIR)", "${s_name}")], ["$(CP) ${src} ${dst}"], []) =20 - ## Constructor + # Constructor # # @param File The file containing build rules in a w= ell defined format # @param Content The string list of build rules in a we= ll defined format @@ -328,42 +345,48 @@ class BuildRule: elif Content is not None: self.RuleContent =3D Content else: - EdkLogger.error("build", PARAMETER_MISSING, ExtraData=3D"No ru= le file or string given") + EdkLogger.error("build", PARAMETER_MISSING, + ExtraData=3D"No rule file or string given") =20 self.SupportedToolChainFamilyList =3D SupportedFamily - self.RuleDatabase =3D tdict(True, 4) # {FileExt, ModuleType, Arch= , Family : FileBuildRule object} + # {FileExt, ModuleType, Arch, Family : FileBuildRule object} + self.RuleDatabase =3D tdict(True, 4) self.Ext2FileType =3D {} # {ext : file-type} self.FileTypeList =3D set() =20 self._LineIndex =3D LineIndex self._State =3D "" - self._RuleInfo =3D tdict(True, 2) # {toolchain family : {"Inpu= tFile": {}, "OutputFile" : [], "Command" : []}} + # {toolchain family : {"InputFile": {}, "OutputFile" : [], "Comman= d" : []}} + self._RuleInfo =3D tdict(True, 2) self._FileType =3D '' self._BuildTypeList =3D set() self._ArchList =3D set() self._FamilyList =3D [] self._TotalToolChainFamilySet =3D set() - self._RuleObjectList =3D [] # FileBuildRule object list + self._RuleObjectList =3D [] # FileBuildRule object list self._FileVersion =3D "" =20 self.Parse() =20 # some intrinsic rules - self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, TAB_COMMON, TAB_COMMON,= TAB_COMMON] =3D self._BinaryFileRule + self.RuleDatabase[TAB_DEFAULT_BINARY_FILE, TAB_COMMON, + TAB_COMMON, TAB_COMMON] =3D self._BinaryFileRule self.FileTypeList.add(TAB_DEFAULT_BINARY_FILE) =20 - ## Parse the build rule strings + # Parse the build rule strings def Parse(self): self._State =3D self._Section for Index in range(self._LineIndex, len(self.RuleContent)): # Clean up the line and replace path separator with native one - Line =3D self.RuleContent[Index].strip().replace(self._PATH_SE= P, os.path.sep) + Line =3D self.RuleContent[Index].strip().replace( + self._PATH_SEP, os.path.sep) self.RuleContent[Index] =3D Line =20 # find the build_rule_version if Line and Line[0] =3D=3D "#" and Line.find(TAB_BUILD_RULE_VE= RSION) !=3D -1: if Line.find("=3D") !=3D -1 and Line.find("=3D") < (len(Li= ne) - 1) and (Line[(Line.find("=3D") + 1):]).split(): - self._FileVersion =3D (Line[(Line.find("=3D") + 1):]).= split()[0] + self._FileVersion =3D ( + Line[(Line.find("=3D") + 1):]).split()[0] # skip empty or comment line if Line =3D=3D "" or Line[0] =3D=3D "#": continue @@ -383,14 +406,14 @@ class BuildRule: # merge last section information into rule database self.EndOfSection() =20 - ## Parse definitions under a section + # Parse definitions under a section # # @param LineIndex The line index of build rule text # def ParseSection(self, LineIndex): pass =20 - ## Parse definitions under a subsection + # Parse definitions under a subsection # # @param LineIndex The line index of build rule text # @@ -398,14 +421,14 @@ class BuildRule: # currently nothing here pass =20 - ## Placeholder for not supported sections + # Placeholder for not supported sections # # @param LineIndex The line index of build rule text # def SkipSection(self, LineIndex): pass =20 - ## Merge section information just got into rule database + # Merge section information just got into rule database def EndOfSection(self): Database =3D self.RuleDatabase # if there's specific toolchain family, 'COMMON' doesn't make sens= e any more @@ -417,14 +440,16 @@ class BuildRule: Command =3D self._RuleInfo[Family, self._Command] ExtraDependency =3D self._RuleInfo[Family, self._ExtraDependen= cy] =20 - BuildRule =3D FileBuildRule(self._FileType, Input, Output, Com= mand, ExtraDependency) + BuildRule =3D FileBuildRule( + self._FileType, Input, Output, Command, ExtraDependency) for BuildType in self._BuildTypeList: for Arch in self._ArchList: - Database[self._FileType, BuildType, Arch, Family] =3D = BuildRule + Database[self._FileType, BuildType, + Arch, Family] =3D BuildRule for FileExt in BuildRule.SourceFileExtList: self.Ext2FileType[FileExt] =3D self._FileType =20 - ## Parse section header + # Parse section header # # @param LineIndex The line index of build rule text # @@ -439,7 +464,8 @@ class BuildRule: for RuleName in RuleNameList: Arch =3D TAB_COMMON BuildType =3D TAB_COMMON - TokenList =3D [Token.strip().upper() for Token in RuleName.spl= it('.')] + TokenList =3D [Token.strip().upper() + for Token in RuleName.split('.')] # old format: Build.File-Type if TokenList[0] =3D=3D "BUILD": if len(TokenList) =3D=3D 1: @@ -486,7 +512,7 @@ class BuildRule: self._State =3D self._Section self.FileTypeList.add(FileType) =20 - ## Parse sub-section header + # Parse sub-section header # # @param LineIndex The line index of build rule text # @@ -529,8 +555,10 @@ class BuildRule: # # @param LineIndex The line index of build rule text # + def ParseInputFileSubSection(self, LineIndex): - FileList =3D [File.strip() for File in self.RuleContent[LineIndex]= .split(",")] + FileList =3D [File.strip() + for File in self.RuleContent[LineIndex].split(",")] for ToolChainFamily in self._FamilyList: if self._RuleInfo[ToolChainFamily, self._State] is None: self._RuleInfo[ToolChainFamily, self._State] =3D [] @@ -546,9 +574,10 @@ class BuildRule: for ToolChainFamily in self._FamilyList: if self._RuleInfo[ToolChainFamily, self._State] is None: self._RuleInfo[ToolChainFamily, self._State] =3D [] - self._RuleInfo[ToolChainFamily, self._State].append(self.RuleC= ontent[LineIndex]) + self._RuleInfo[ToolChainFamily, self._State].append( + self.RuleContent[LineIndex]) =20 - ## Get a build rule via [] operator + # Get a build rule via [] operator # # @param FileExt The extension of a file # @param ToolChainFamily The tool chain family name @@ -577,17 +606,18 @@ class BuildRule: return self.RuleDatabase[Key] =20 _StateHandler =3D { - _SectionHeader : ParseSectionHeader, - _Section : ParseSection, - _SubSectionHeader : ParseSubSectionHeader, - _SubSection : ParseSubSection, - _InputFile : ParseInputFileSubSection, - _OutputFile : ParseCommonSubSection, - _ExtraDependency : ParseCommonSubSection, - _Command : ParseCommonSubSection, - _UnknownSection : SkipSection, + _SectionHeader: ParseSectionHeader, + _Section: ParseSection, + _SubSectionHeader: ParseSubSectionHeader, + _SubSection: ParseSubSection, + _InputFile: ParseInputFileSubSection, + _OutputFile: ParseCommonSubSection, + _ExtraDependency: ParseCommonSubSection, + _Command: ParseCommonSubSection, + _UnknownSection: SkipSection, } =20 + class ToolBuildRule(): =20 def __new__(cls, *args, **kw): @@ -618,13 +648,14 @@ class ToolBuildRule(): if RetVal._FileVersion =3D=3D "": RetVal._FileVersion =3D AutoGenReqBuildRuleVerNum else: - if RetVal._FileVersion < AutoGenReqBuildRuleVerNum : + if RetVal._FileVersion < AutoGenReqBuildRuleVerNum: # If Build Rule's version is less than the version number = required by the tools, halting the build. EdkLogger.error("build", AUTOGEN_ERROR, - ExtraData=3D"The version number [%s] of bu= ild_rule.txt is less than the version number required by the AutoGen.(the m= inimum required version number is [%s])"\ - % (RetVal._FileVersion, AutoGenReqBuildRu= leVerNum)) + ExtraData=3D"The version number [%s] of bu= ild_rule.txt is less than the version number required by the AutoGen.(the m= inimum required version number is [%s])" + % (RetVal._FileVersion, AutoGenReqBuildRul= eVerNum)) self._ToolBuildRule =3D RetVal =20 + # This acts like the main() function for the script, unless it is 'import'= ed into another # script. if __name__ =3D=3D '__main__': @@ -647,4 +678,3 @@ if __name__ =3D=3D '__main__': print(str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])) print() print(str(Br[".s", SUP_MODULE_SEC][1])) - diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source= /Python/AutoGen/DataPipe.py index 848c7a82963e..5ae948f5b5ab 100755 --- a/BaseTools/Source/Python/AutoGen/DataPipe.py +++ b/BaseTools/Source/Python/AutoGen/DataPipe.py @@ -1,4 +1,4 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019, Intel Corporation. All rights reserved.
        @@ -13,10 +13,11 @@ import pickle from pickle import HIGHEST_PROTOCOL from Common import EdkLogger =20 + class PCD_DATA(): - def __init__(self,TokenCName,TokenSpaceGuidCName,Type,DatumType,SkuInf= oList,DefaultValue, - MaxDatumSize,UserDefinedDefaultStoresFlag,validateranges, - validlists,expressions,CustomAttribute,TokenValue): + def __init__(self, TokenCName, TokenSpaceGuidCName, Type, DatumType, S= kuInfoList, DefaultValue, + MaxDatumSize, UserDefinedDefaultStoresFlag, validaterange= s, + validlists, expressions, CustomAttribute, TokenValue): self.TokenCName =3D TokenCName self.TokenSpaceGuidCName =3D TokenSpaceGuidCName self.Type =3D Type @@ -31,143 +32,156 @@ class PCD_DATA(): self.CustomAttribute =3D CustomAttribute self.TokenValue =3D TokenValue =20 + class DataPipe(object): def __init__(self, BuildDir=3DNone): self.data_container =3D {} self.BuildDir =3D BuildDir self.dump_file =3D "" =20 + class MemoryDataPipe(DataPipe): =20 - def Get(self,key): + def Get(self, key): return self.data_container.get(key) =20 - def dump(self,file_path): + def dump(self, file_path): self.dump_file =3D file_path - with open(file_path,'wb') as fd: - pickle.dump(self.data_container,fd,pickle.HIGHEST_PROTOCOL) + with open(file_path, 'wb') as fd: + pickle.dump(self.data_container, fd, pickle.HIGHEST_PROTOCOL) =20 - def load(self,file_path): - with open(file_path,'rb') as fd: + def load(self, file_path): + with open(file_path, 'rb') as fd: self.data_container =3D pickle.load(fd) =20 @property def DataContainer(self): return self.data_container + @DataContainer.setter - def DataContainer(self,data): + def DataContainer(self, data): self.data_container.update(data) =20 - def FillData(self,PlatformInfo): - #Platform Pcds + def FillData(self, PlatformInfo): + # Platform Pcds self.DataContainer =3D { - "PLA_PCD" : [PCD_DATA( - pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type, - pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue, - pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validate= ranges, - pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.To= kenValue) - for pcd in PlatformInfo.Platform.Pcds.values()] - } + "PLA_PCD": [PCD_DATA( + pcd.TokenCName, pcd.TokenSpaceGuidCName, pcd.Type, + pcd.DatumType, pcd.SkuInfoList, pcd.DefaultValue, + pcd.MaxDatumSize, pcd.UserDefinedDefaultStoresFlag, pcd.va= lidateranges, + pcd.validlists, pcd.expressions, pcd.CustomAttribute, pcd.= TokenValue) + for pcd in PlatformInfo.Platform.Pcds.values()] + } =20 - #Platform Module Pcds + # Platform Module Pcds ModulePcds =3D {} for m in PlatformInfo.Platform.Modules: module =3D PlatformInfo.Platform.Modules[m] - m_pcds =3D module.Pcds + m_pcds =3D module.Pcds if m_pcds: ModulePcds[module.Guid] =3D [PCD_DATA( - pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type, - pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue, - pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validate= ranges, - pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.To= kenValue) - for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()] + pcd.TokenCName, pcd.TokenSpaceGuidCName, pcd.Type, + pcd.DatumType, pcd.SkuInfoList, pcd.DefaultValue, + pcd.MaxDatumSize, pcd.UserDefinedDefaultStoresFlag, pc= d.validateranges, + pcd.validlists, pcd.expressions, pcd.CustomAttribute, = pcd.TokenValue) + for pcd in PlatformInfo.Platform.Modules[m].Pcds.value= s()] =20 + self.DataContainer =3D {"MOL_PCDS": ModulePcds} =20 - self.DataContainer =3D {"MOL_PCDS":ModulePcds} - - #Module's Library Instance + # Module's Library Instance ModuleLibs =3D {} libModules =3D {} for m in PlatformInfo.Platform.Modules: - module_obj =3D BuildDB.BuildObject[m,PlatformInfo.Arch,Platfor= mInfo.BuildTarget,PlatformInfo.ToolChain] - Libs =3D GetModuleLibInstances(module_obj, PlatformInfo.Platfo= rm, BuildDB.BuildObject, PlatformInfo.Arch,PlatformInfo.BuildTarget,Platfor= mInfo.ToolChain,PlatformInfo.MetaFile,EdkLogger) + module_obj =3D BuildDB.BuildObject[m, PlatformInfo.Arch, + PlatformInfo.BuildTarget, Pla= tformInfo.ToolChain] + Libs =3D GetModuleLibInstances(module_obj, PlatformInfo.Platfo= rm, BuildDB.BuildObject, PlatformInfo.Arch, + PlatformInfo.BuildTarget, Platfor= mInfo.ToolChain, PlatformInfo.MetaFile, EdkLogger) for lib in Libs: try: - libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Ar= ch,lib.MetaFile.Path)].append((m.File,m.Root,module_obj.Arch,m.Path)) + libModules[(lib.MetaFile.File, lib.MetaFile.Root, lib.= Arch, lib.MetaFile.Path)].append( + (m.File, m.Root, module_obj.Arch, m.Path)) except: - libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Ar= ch,lib.MetaFile.Path)] =3D [(m.File,m.Root,module_obj.Arch,m.Path)] - ModuleLibs[(m.File,m.Root,module_obj.Arch,m.Path)] =3D [(l.Met= aFile.File,l.MetaFile.Root,l.Arch,l.MetaFile.Path) for l in Libs] - self.DataContainer =3D {"DEPS":ModuleLibs} - self.DataContainer =3D {"REFS":libModules} + libModules[(lib.MetaFile.File, lib.MetaFile.Root, lib.= Arch, lib.MetaFile.Path)] =3D [ + (m.File, m.Root, module_obj.Arch, m.Path)] + ModuleLibs[(m.File, m.Root, module_obj.Arch, m.Path)] =3D [ + (l.MetaFile.File, l.MetaFile.Root, l.Arch, l.MetaFile.Path= ) for l in Libs] + self.DataContainer =3D {"DEPS": ModuleLibs} + self.DataContainer =3D {"REFS": libModules} =20 - #Platform BuildOptions + # Platform BuildOptions =20 - platform_build_opt =3D PlatformInfo.EdkIIBuildOption + platform_build_opt =3D PlatformInfo.EdkIIBuildOption =20 ToolDefinition =3D PlatformInfo.ToolDefinition module_build_opt =3D {} for m in PlatformInfo.Platform.Modules: - ModuleTypeOptions, PlatformModuleOptions =3D PlatformInfo.GetG= lobalBuildOptions(BuildDB.BuildObject[m,PlatformInfo.Arch,PlatformInfo.Buil= dTarget,PlatformInfo.ToolChain]) + ModuleTypeOptions, PlatformModuleOptions =3D PlatformInfo.GetG= lobalBuildOptions( + BuildDB.BuildObject[m, PlatformInfo.Arch, PlatformInfo.Bui= ldTarget, PlatformInfo.ToolChain]) if ModuleTypeOptions or PlatformModuleOptions: - module_build_opt.update({(m.File,m.Root): {"ModuleTypeOpti= ons":ModuleTypeOptions, "PlatformModuleOptions":PlatformModuleOptions}}) + module_build_opt.update({(m.File, m.Root): { + "ModuleTypeOptions": ModuleTypeOpt= ions, "PlatformModuleOptions": PlatformModuleOptions}}) =20 - self.DataContainer =3D {"PLA_BO":platform_build_opt, - "TOOLDEF":ToolDefinition, - "MOL_BO":module_build_opt + self.DataContainer =3D {"PLA_BO": platform_build_opt, + "TOOLDEF": ToolDefinition, + "MOL_BO": module_build_opt } =20 - - - #Platform Info + # Platform Info PInfo =3D { - "WorkspaceDir":PlatformInfo.Workspace.WorkspaceDir, - "Target":PlatformInfo.BuildTarget, - "ToolChain":PlatformInfo.Workspace.ToolChain, - "BuildRuleFile":PlatformInfo.BuildRule, + "WorkspaceDir": PlatformInfo.Workspace.WorkspaceDir, + "Target": PlatformInfo.BuildTarget, + "ToolChain": PlatformInfo.Workspace.ToolChain, + "BuildRuleFile": PlatformInfo.BuildRule, "Arch": PlatformInfo.Arch, - "ArchList":PlatformInfo.Workspace.ArchList, - "ActivePlatform":PlatformInfo.MetaFile - } - self.DataContainer =3D {'P_Info':PInfo} + "ArchList": PlatformInfo.Workspace.ArchList, + "ActivePlatform": PlatformInfo.MetaFile + } + self.DataContainer =3D {'P_Info': PInfo} =20 - self.DataContainer =3D {'M_Name':PlatformInfo.UniqueBaseName} + self.DataContainer =3D {'M_Name': PlatformInfo.UniqueBaseName} =20 self.DataContainer =3D {"ToolChainFamily": PlatformInfo.ToolChainF= amily} =20 self.DataContainer =3D {"BuildRuleFamily": PlatformInfo.BuildRuleF= amily} =20 - self.DataContainer =3D {"MixedPcd":GlobalData.MixedPcd} + self.DataContainer =3D {"MixedPcd": GlobalData.MixedPcd} =20 - self.DataContainer =3D {"BuildOptPcd":GlobalData.BuildOptionPcd} + self.DataContainer =3D {"BuildOptPcd": GlobalData.BuildOptionPcd} =20 self.DataContainer =3D {"BuildCommand": PlatformInfo.BuildCommand} =20 - self.DataContainer =3D {"AsBuildModuleList": PlatformInfo._AsBuild= ModuleList} + self.DataContainer =3D { + "AsBuildModuleList": PlatformInfo._AsBuildModuleList} =20 self.DataContainer =3D {"G_defines": GlobalData.gGlobalDefines} =20 self.DataContainer =3D {"CL_defines": GlobalData.gCommandLineDefin= es} =20 - self.DataContainer =3D {"gCommandMaxLength": GlobalData.gCommandMa= xLength} + self.DataContainer =3D { + "gCommandMaxLength": GlobalData.gCommandMaxLength} =20 - self.DataContainer =3D {"Env_Var": {k:v for k, v in os.environ.ite= ms()}} + self.DataContainer =3D {"Env_Var": {k: v for k, v in os.environ.it= ems()}} =20 - self.DataContainer =3D {"PackageList": [(dec.MetaFile,dec.Arch) fo= r dec in PlatformInfo.PackageList]} + self.DataContainer =3D {"PackageList": [ + (dec.MetaFile, dec.Arch) for dec in PlatformInfo.PackageList]} =20 self.DataContainer =3D {"GuidDict": PlatformInfo.Platform._GuidDic= t} =20 - self.DataContainer =3D {"DatabasePath":GlobalData.gDatabasePath} + self.DataContainer =3D {"DatabasePath": GlobalData.gDatabasePath} =20 - self.DataContainer =3D {"FdfParser": True if GlobalData.gFdfParser= else False} + self.DataContainer =3D { + "FdfParser": True if GlobalData.gFdfParser else False} =20 self.DataContainer =3D {"LogLevel": EdkLogger.GetLevel()} =20 - self.DataContainer =3D {"UseHashCache":GlobalData.gUseHashCache} + self.DataContainer =3D {"UseHashCache": GlobalData.gUseHashCache} =20 - self.DataContainer =3D {"BinCacheSource":GlobalData.gBinCacheSourc= e} + self.DataContainer =3D {"BinCacheSource": GlobalData.gBinCacheSour= ce} =20 - self.DataContainer =3D {"BinCacheDest":GlobalData.gBinCacheDest} + self.DataContainer =3D {"BinCacheDest": GlobalData.gBinCacheDest} =20 - self.DataContainer =3D {"EnableGenfdsMultiThread":GlobalData.gEnab= leGenfdsMultiThread} + self.DataContainer =3D { + "EnableGenfdsMultiThread": GlobalData.gEnableGenfdsMultiThread} =20 - self.DataContainer =3D {"gPlatformFinalPcds":GlobalData.gPlatformF= inalPcds} + self.DataContainer =3D { + "gPlatformFinalPcds": GlobalData.gPlatformFinalPcds} diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index a2053d548521..fe02f160fd01 100755 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1,11 +1,11 @@ -## @file +# @file # Routines for generating AutoGen.h and AutoGen.c # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # from __future__ import absolute_import import string @@ -21,28 +21,31 @@ from .StrGather import * from .GenPcdDb import CreatePcdDatabaseCode from .IdfClassObject import * =20 -## PCD type string -gItemTypeStringDatabase =3D { - TAB_PCDS_FEATURE_FLAG : TAB_PCDS_FIXED_AT_BUILD, - TAB_PCDS_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD, +# PCD type string +gItemTypeStringDatabase =3D { + TAB_PCDS_FEATURE_FLAG: TAB_PCDS_FIXED_AT_BUILD, + TAB_PCDS_FIXED_AT_BUILD: TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE: 'BinaryPatch', - TAB_PCDS_DYNAMIC : '', - TAB_PCDS_DYNAMIC_DEFAULT : '', - TAB_PCDS_DYNAMIC_VPD : '', - TAB_PCDS_DYNAMIC_HII : '', - TAB_PCDS_DYNAMIC_EX : '', - TAB_PCDS_DYNAMIC_EX_DEFAULT : '', - TAB_PCDS_DYNAMIC_EX_VPD : '', - TAB_PCDS_DYNAMIC_EX_HII : '', + TAB_PCDS_DYNAMIC: '', + TAB_PCDS_DYNAMIC_DEFAULT: '', + TAB_PCDS_DYNAMIC_VPD: '', + TAB_PCDS_DYNAMIC_HII: '', + TAB_PCDS_DYNAMIC_EX: '', + TAB_PCDS_DYNAMIC_EX_DEFAULT: '', + TAB_PCDS_DYNAMIC_EX_VPD: '', + TAB_PCDS_DYNAMIC_EX_HII: '', } =20 =20 -## Datum size -gDatumSizeStringDatabase =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32= ',TAB_UINT64:'64','BOOLEAN':'BOOLEAN',TAB_VOID:'8'} -gDatumSizeStringDatabaseH =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'3= 2',TAB_UINT64:'64','BOOLEAN':'BOOL',TAB_VOID:'PTR'} -gDatumSizeStringDatabaseLib =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:= '32',TAB_UINT64:'64','BOOLEAN':'Bool',TAB_VOID:'Ptr'} +# Datum size +gDatumSizeStringDatabase =3D {TAB_UINT8: '8', TAB_UINT16: '16', + TAB_UINT32: '32', TAB_UINT64: '64', 'BOOLEAN':= 'BOOLEAN', TAB_VOID: '8'} +gDatumSizeStringDatabaseH =3D {TAB_UINT8: '8', TAB_UINT16: '16', + TAB_UINT32: '32', TAB_UINT64: '64', 'BOOLEAN'= : 'BOOL', TAB_VOID: 'PTR'} +gDatumSizeStringDatabaseLib =3D {TAB_UINT8: '8', TAB_UINT16: '16', + TAB_UINT32: '32', TAB_UINT64: '64', 'BOOLEA= N': 'Bool', TAB_VOID: 'Ptr'} =20 -## AutoGen File Header Templates +# AutoGen File Header Templates gAutoGenHeaderString =3D TemplateString("""\ /** DO NOT EDIT @@ -75,7 +78,7 @@ gAutoGenHEpilogueString =3D """ #endif """ =20 -## PEI Core Entry Point Templates +# PEI Core Entry Point Templates gPeiCoreEntryPointPrototype =3D TemplateString(""" ${BEGIN} VOID @@ -105,7 +108,7 @@ ${END} """) =20 =20 -## DXE Core Entry Point Templates +# DXE Core Entry Point Templates gDxeCoreEntryPointPrototype =3D TemplateString(""" ${BEGIN} VOID @@ -130,7 +133,7 @@ ProcessModuleEntryPointList ( ${END} """) =20 -## PEIM Entry Point Templates +# PEIM Entry Point Templates gPeimEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -143,7 +146,7 @@ ${END} """) =20 gPeimEntryPointString =3D [ -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision =3D ${PiSpecVers= ion}; =20 EFI_STATUS @@ -157,7 +160,7 @@ ProcessModuleEntryPointList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision =3D ${PiSpecVers= ion}; ${BEGIN} EFI_STATUS @@ -172,7 +175,7 @@ ProcessModuleEntryPointList ( } ${END} """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision =3D ${PiSpecVers= ion}; =20 EFI_STATUS @@ -198,7 +201,7 @@ ${END} """) ] =20 -## SMM_CORE Entry Point Templates +# SMM_CORE Entry Point Templates gSmmCoreEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -227,7 +230,7 @@ ProcessModuleEntryPointList ( ${END} """) =20 -## MM_CORE_STANDALONE Entry Point Templates +# MM_CORE_STANDALONE Entry Point Templates gMmCoreStandaloneEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -253,7 +256,7 @@ ProcessModuleEntryPointList ( ${END} """) =20 -## MM_STANDALONE Entry Point Templates +# MM_STANDALONE Entry Point Templates gMmStandaloneEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -266,7 +269,7 @@ ${END} """) =20 gMmStandaloneEntryPointString =3D [ -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision =3D ${PiSpecVersio= n}; =20 EFI_STATUS @@ -280,7 +283,7 @@ ProcessModuleEntryPointList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision =3D ${PiSpecVersio= n}; ${BEGIN} EFI_STATUS @@ -295,7 +298,7 @@ ProcessModuleEntryPointList ( } ${END} """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gMmRevision =3D ${PiSpecVersio= n}; =20 EFI_STATUS @@ -321,7 +324,7 @@ ${END} """) ] =20 -## DXE SMM Entry Point Templates +# DXE SMM Entry Point Templates gDxeSmmEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -334,7 +337,7 @@ ${END} """) =20 gDxeSmmEntryPointString =3D [ -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; const UINT32 _gDxeRevision =3D ${PiSpecVersion}; =20 @@ -349,7 +352,7 @@ ProcessModuleEntryPointList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; const UINT32 _gDxeRevision =3D ${PiSpecVersion}; =20 @@ -390,7 +393,7 @@ ${END} """) ] =20 -## UEFI Driver Entry Point Templates +# UEFI Driver Entry Point Templates gUefiDriverEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -403,7 +406,7 @@ ${END} """) =20 gUefiDriverEntryPointString =3D [ -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; const UINT32 _gDxeRevision =3D ${PiSpecVersion}; =20 @@ -417,7 +420,7 @@ ProcessModuleEntryPointList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; const UINT32 _gDxeRevision =3D ${PiSpecVersion}; =20 @@ -445,7 +448,7 @@ ExitDriver ( gBS->Exit (gImageHandle, Status, 0, NULL); } """), -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; const UINT32 _gDxeRevision =3D ${PiSpecVersion}; =20 @@ -485,7 +488,7 @@ ExitDriver ( ] =20 =20 -## UEFI Application Entry Point Templates +# UEFI Application Entry Point Templates gUefiApplicationEntryPointPrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -498,7 +501,7 @@ ${END} """) =20 gUefiApplicationEntryPointString =3D [ -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; =20 EFI_STATUS @@ -511,7 +514,7 @@ ProcessModuleEntryPointList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; =20 ${BEGIN} @@ -538,7 +541,7 @@ ExitDriver ( gBS->Exit (gImageHandle, Status, 0, NULL); } """), -TemplateString(""" + TemplateString(""" const UINT32 _gUefiDriverRevision =3D ${UefiSpecVersion}; =20 EFI_STATUS @@ -576,7 +579,7 @@ ExitDriver ( """) ] =20 -## UEFI Unload Image Templates +# UEFI Unload Image Templates gUefiUnloadImagePrototype =3D TemplateString(""" ${BEGIN} EFI_STATUS @@ -588,7 +591,7 @@ ${END} """) =20 gUefiUnloadImageString =3D [ -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount =3D ${C= ount}; =20 EFI_STATUS @@ -600,7 +603,7 @@ ProcessModuleUnloadList ( return EFI_SUCCESS; } """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount =3D ${C= ount}; =20 ${BEGIN} @@ -614,7 +617,7 @@ ProcessModuleUnloadList ( } ${END} """), -TemplateString(""" + TemplateString(""" GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount =3D ${C= ount}; =20 EFI_STATUS @@ -639,7 +642,7 @@ ${END} ] =20 gLibraryStructorPrototype =3D { -SUP_MODULE_BASE : TemplateString("""${BEGIN} + SUP_MODULE_BASE: TemplateString("""${BEGIN} RETURN_STATUS EFIAPI ${Function} ( @@ -647,7 +650,7 @@ ${Function} ( );${END} """), =20 -'PEI' : TemplateString("""${BEGIN} + 'PEI': TemplateString("""${BEGIN} EFI_STATUS EFIAPI ${Function} ( @@ -656,7 +659,7 @@ ${Function} ( );${END} """), =20 -'DXE' : TemplateString("""${BEGIN} + 'DXE': TemplateString("""${BEGIN} EFI_STATUS EFIAPI ${Function} ( @@ -665,7 +668,7 @@ ${Function} ( );${END} """), =20 -'MM' : TemplateString("""${BEGIN} + 'MM': TemplateString("""${BEGIN} EFI_STATUS EFIAPI ${Function} ( @@ -676,30 +679,30 @@ ${Function} ( } =20 gLibraryStructorCall =3D { -SUP_MODULE_BASE : TemplateString("""${BEGIN} + SUP_MODULE_BASE: TemplateString("""${BEGIN} Status =3D ${Function} (); ASSERT_RETURN_ERROR (Status);${END} """), =20 -'PEI' : TemplateString("""${BEGIN} + 'PEI': TemplateString("""${BEGIN} Status =3D ${Function} (FileHandle, PeiServices); ASSERT_EFI_ERROR (Status);${END} """), =20 -'DXE' : TemplateString("""${BEGIN} + 'DXE': TemplateString("""${BEGIN} Status =3D ${Function} (ImageHandle, SystemTable); ASSERT_EFI_ERROR (Status);${END} """), =20 -'MM' : TemplateString("""${BEGIN} + 'MM': TemplateString("""${BEGIN} Status =3D ${Function} (ImageHandle, MmSystemTable); ASSERT_EFI_ERROR (Status);${END} """), } =20 -## Library Constructor and Destructor Templates +# Library Constructor and Destructor Templates gLibraryString =3D { -SUP_MODULE_BASE : TemplateString(""" + SUP_MODULE_BASE: TemplateString(""" ${BEGIN}${FunctionPrototype}${END} =20 VOID @@ -713,7 +716,7 @@ ${FunctionCall}${END} } """), =20 -'PEI' : TemplateString(""" + 'PEI': TemplateString(""" ${BEGIN}${FunctionPrototype}${END} =20 VOID @@ -728,7 +731,7 @@ ${FunctionCall}${END} } """), =20 -'DXE' : TemplateString(""" + 'DXE': TemplateString(""" ${BEGIN}${FunctionPrototype}${END} =20 VOID @@ -743,7 +746,7 @@ ${FunctionCall}${END} } """), =20 -'MM' : TemplateString(""" + 'MM': TemplateString(""" ${BEGIN}${FunctionPrototype}${END} =20 VOID @@ -762,34 +765,36 @@ ${FunctionCall}${END} gBasicHeaderFile =3D "Base.h" =20 gModuleTypeHeaderFile =3D { - SUP_MODULE_BASE : [gBasicHeaderFile, "Library/DebugLib.= h"], - SUP_MODULE_SEC : ["PiPei.h", "Library/DebugLib.h"], - SUP_MODULE_PEI_CORE : ["PiPei.h", "Library/DebugLib.h", "Li= brary/PeiCoreEntryPoint.h"], - SUP_MODULE_PEIM : ["PiPei.h", "Library/DebugLib.h", "Li= brary/PeimEntryPoint.h"], - SUP_MODULE_DXE_CORE : ["PiDxe.h", "Library/DebugLib.h", "Li= brary/DxeCoreEntryPoint.h"], - SUP_MODULE_DXE_DRIVER : ["PiDxe.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriver= EntryPoint.h"], - SUP_MODULE_DXE_SMM_DRIVER : ["PiDxe.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriver= EntryPoint.h"], + SUP_MODULE_BASE: [gBasicHeaderFile, "Library/DebugLib.h"], + SUP_MODULE_SEC: ["PiPei.h", "Library/DebugLib.h"], + SUP_MODULE_PEI_CORE: ["PiPei.h", "Library/DebugLib.h", "Library/PeiC= oreEntryPoint.h"], + SUP_MODULE_PEIM: ["PiPei.h", "Library/DebugLib.h", "Library/PeimEntr= yPoint.h"], + SUP_MODULE_DXE_CORE: ["PiDxe.h", "Library/DebugLib.h", "Library/DxeC= oreEntryPoint.h"], + SUP_MODULE_DXE_DRIVER: ["PiDxe.h", "Library/BaseLib.h", "Library/Deb= ugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoi= nt.h"], + SUP_MODULE_DXE_SMM_DRIVER: ["PiDxe.h", "Library/BaseLib.h", "Library= /DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntr= yPoint.h"], SUP_MODULE_DXE_RUNTIME_DRIVER: ["PiDxe.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriver= EntryPoint.h"], - SUP_MODULE_DXE_SAL_DRIVER : ["PiDxe.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriver= EntryPoint.h"], - SUP_MODULE_UEFI_DRIVER : ["Uefi.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriver= EntryPoint.h"], - SUP_MODULE_UEFI_APPLICATION : ["Uefi.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplic= ationEntryPoint.h"], - SUP_MODULE_SMM_CORE : ["PiDxe.h", "Library/BaseLib.h", "Lib= rary/DebugLib.h", "Library/UefiDriverEntryPoint.h"], - SUP_MODULE_MM_STANDALONE : ["PiMm.h", "Library/BaseLib.h", "Libr= ary/DebugLib.h", "Library/StandaloneMmDriverEntryPoint.h"], - SUP_MODULE_MM_CORE_STANDALONE : ["PiMm.h", "Library/BaseLib.h", "Libr= ary/DebugLib.h", "Library/StandaloneMmCoreEntryPoint.h"], - SUP_MODULE_USER_DEFINED : [gBasicHeaderFile, "Library/DebugLib.= h"], - SUP_MODULE_HOST_APPLICATION : [gBasicHeaderFile, "Library/DebugLib.= h"] + SUP_MODULE_DXE_SAL_DRIVER: ["PiDxe.h", "Library/BaseLib.h", "Library= /DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntr= yPoint.h"], + SUP_MODULE_UEFI_DRIVER: ["Uefi.h", "Library/BaseLib.h", "Library/De= bugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPo= int.h"], + SUP_MODULE_UEFI_APPLICATION: ["Uefi.h", "Library/BaseLib.h", "Libra= ry/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicat= ionEntryPoint.h"], + SUP_MODULE_SMM_CORE: ["PiDxe.h", "Library/BaseLib.h", "Library/Debug= Lib.h", "Library/UefiDriverEntryPoint.h"], + SUP_MODULE_MM_STANDALONE: ["PiMm.h", "Library/BaseLib.h", "Library/D= ebugLib.h", "Library/StandaloneMmDriverEntryPoint.h"], + SUP_MODULE_MM_CORE_STANDALONE: ["PiMm.h", "Library/BaseLib.h", "Libra= ry/DebugLib.h", "Library/StandaloneMmCoreEntryPoint.h"], + SUP_MODULE_USER_DEFINED: [gBasicHeaderFile, "Library/DebugLib.h"], + SUP_MODULE_HOST_APPLICATION: [gBasicHeaderFile, "Library/DebugLib.h"] } =20 -## Autogen internal worker macro to define DynamicEx PCD name includes bot= h the TokenSpaceGuidName +# Autogen internal worker macro to define DynamicEx PCD name includes both= the TokenSpaceGuidName # the TokenName and Guid comparison to avoid define name collisions. # # @param Info The ModuleAutoGen object # @param AutoGenH The TemplateString object for header file # # + + def DynExPcdTokenNumberMapping(Info, AutoGenH): ExTokenCNameList =3D [] - PcdExList =3D [] + PcdExList =3D [] # Even it is the Library, the PCD is saved in the ModulePcdList PcdList =3D Info.ModulePcdList for Pcd in PcdList: @@ -817,7 +822,8 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): if Pcd.TokenCName =3D=3D TokenCName: Index =3D Index + 1 if Index =3D=3D 1: - AutoGenH.Append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) = (' % (RealTokenCName)) + AutoGenH.Append( + '\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (RealT= okenCName)) AutoGenH.Append('\\\n (GuidPtr =3D=3D &%s) ? _PCD_TOK= EN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenS= paceGuidCName, RealTokenCName)) else: @@ -842,7 +848,8 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName =3D= =3D TokenCName: Index =3D Index + 1 if Index =3D=3D 1: - AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) = (' % (RealTokenCName)) + AutoGenH.Append( + '\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (RealTo= kenCName)) AutoGenH.Append('\\\n (GuidPtr =3D=3D NULL) ? 0:') AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _P= CD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenS= paceGuidCName, RealTokenCName)) @@ -859,15 +866,18 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): % (RealTokenCName, RealTokenCName, Rea= lTokenCName, RealTokenCName)) TokenCNameList.add(TokenCName) =20 -## Create code for module PCDs +# Create code for module PCDs # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # @param Pcd The PCD object # + + def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): - TokenSpaceGuidValue =3D Pcd.TokenSpaceGuidValue #Info.GuidList[Pcd.T= okenSpaceGuidCName] + # Info.GuidList[Pcd.TokenSpaceGuidCName] + TokenSpaceGuidValue =3D Pcd.TokenSpaceGuidValue PcdTokenNumber =3D Info.PlatformInfo.PcdTokenNumber # # Write PCDs @@ -878,7 +888,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): TokenCName =3D PcdItem[0] break PcdTokenName =3D '_PCD_TOKEN_' + TokenCName - PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' + PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName + '_SIZE' PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName PatchPcdMaxSizeVariable =3D '_gPcd_BinaryPatch_MaxSize_' + TokenCName FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName @@ -909,23 +919,33 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): TokenNumber =3D 0 else: EdkLogger.error("build", AUTOGEN_ERROR, - "No generated token number for %s.%s\n" % = (Pcd.TokenSpaceGuidCName, TokenCName), + "No generated token number for %s.%s\n" % ( + Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) else: - TokenNumber =3D PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceG= uidCName] + TokenNumber =3D PcdTokenNumber[Pcd.TokenCName, + Pcd.TokenSpaceGuidCName] AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber= )) =20 - EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + TokenCName += "." + Pcd.TokenSpaceGuidCName) + EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + + TokenCName + "." + Pcd.TokenSpaceGuidCName) if Pcd.Type not in gItemTypeStringDatabase: EdkLogger.error("build", AUTOGEN_ERROR, - "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, = Pcd.TokenSpaceGuidCName, TokenCName), + "Unknown PCD type [%s] of PCD %s.%s" % ( + Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) =20 DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_= VOID] - GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName - SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName - SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + T= okenCName + GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_GET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_SET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_SET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName =3D '_PCD_GET_MODE_SIZE' + '_' + TokenCName =20 if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: @@ -944,26 +964,41 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): # If only PcdToken and PcdGet/Set used in all Pcds with different = CName, it should succeed to build. # If PcdToken and PcdGet/Set used in the Pcds with different Guids= but same CName, it should failed to build. if PcdExCNameTest > 1: - AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGe= t/Set are not allowed in the case that more than one DynamicEx Pcds are dif= ferent Guids but same CName.\n') - AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) - AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % = (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append( + '// Disabled the macros, as PcdToken and PcdGet/Set are no= t allowed in the case that more than one DynamicEx Pcds are different Guids= but same CName.\n') + AutoGenH.Append('// #define %s %s\n' % + (PcdTokenName, PcdExTokenName)) + AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % + (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuid= CName, PcdTokenName)) + AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % + (GetModeSizeName, Pcd.TokenSpaceGuidCName, Pcd= TokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % + (SetModeName, DatumSizeLib, Pcd.TokenSpace= GuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % + (SetModeStatusName, DatumSizeLib, Pcd.Toke= nSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, = %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdT= okenName)) - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s,= %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNam= e, PcdTokenName)) + AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, = %s, (Value))\n' % + (SetModeName, DatumSizeLib, Pcd.TokenSpace= GuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s,= %s, (Value))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) - AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s %s\n' % + (PcdTokenName, PcdExTokenName)) + AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % ( + GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTok= enName)) + AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % ( + GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, Pc= dTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s,= (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdToke= nName)) - AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s= , (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, = PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s,= (Value))\n' % ( + SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, Pc= dTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s= , (Value))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) elif Pcd.Type in PCD_DYNAMIC_TYPE_SET: PcdCNameTest =3D 0 for PcdModule in Info.LibraryPcdList + Info.ModulePcdList: @@ -973,18 +1008,26 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pc= d): if PcdCNameTest > 1: break if PcdCNameTest > 1: - EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic= Pcds [%s] are different Guids but same CName. They need to be changed to D= ynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData=3D"[%s= ]" % str(Info.MetaFile.Path)) + EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic= Pcds [%s] are different Guids but same CName. They need to be changed to D= ynamicEx type to avoid the confliction.\n" % ( + TokenCName), ExtraData=3D"[%s]" % str(Info.MetaFile.Path)) else: - AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSi= zeName, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % + (GetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % + (GetModeSizeName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeStatusName, DatumSizeLib, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value= ))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Valu= e))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value= ))\n' % ( + SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Valu= e))\n' % ( + SetModeStatusName, DatumSizeLib, PcdTokenName)) else: - PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] += '_' + TokenCName + PcdVariableName =3D '_gPcd_' + \ + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName Const =3D 'const' if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: Const =3D '' @@ -1007,18 +1050,21 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, P= cd): Value =3D Value[:-1] if Value.startswith('0') and not Value.lower().startswith(= '0x') and len(Value) > 1 and Value.lstrip('0'): Value =3D Value.lstrip('0') - ValueNumber =3D int (Value, 0) + ValueNumber =3D int(Value, 0) except: EdkLogger.error("build", AUTOGEN_ERROR, - "PCD value is not valid dec or hex number = for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName= , TokenCName), + "PCD value is not valid dec or hex number = for datum type [%s] of PCD %s.%s" % ( + Pcd.DatumType, Pcd.TokenSpaceGuidCName= , TokenCName), ExtraData=3D"[%s]" % str(Info)) if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, - "PCD can't be set to negative value for da= tum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Toke= nCName), + "PCD can't be set to negative value for da= tum type [%s] of PCD %s.%s" % ( + Pcd.DatumType, Pcd.TokenSpaceGuidCName= , TokenCName), ExtraData=3D"[%s]" % str(Info)) elif ValueNumber > MAX_VAL_TYPE[Pcd.DatumType]: EdkLogger.error("build", AUTOGEN_ERROR, - "Too large PCD value for datum type [%s] o= f PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), + "Too large PCD value for datum type [%s] o= f PCD %s.%s" % ( + Pcd.DatumType, Pcd.TokenSpaceGuidCName= , TokenCName), ExtraData=3D"[%s]" % str(Info)) if Pcd.DatumType =3D=3D TAB_UINT64 and not Value.endswith('ULL= '): Value +=3D 'ULL' @@ -1028,7 +1074,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if not Pcd.MaxDatumSize: EdkLogger.error("build", AUTOGEN_ERROR, - "Unknown [MaxDatumSize] of PCD [%s.%s]" % = (Pcd.TokenSpaceGuidCName, TokenCName), + "Unknown [MaxDatumSize] of PCD [%s.%s]" % ( + Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) =20 ArraySize =3D int(Pcd.MaxDatumSize, 0) @@ -1038,23 +1085,26 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, P= cd): else: if Value[0] =3D=3D 'L': Unicode =3D True - Value =3D Value.lstrip('L') #.strip('"') + Value =3D Value.lstrip('L') # .strip('"') Value =3D eval(Value) # translate escape character ValueSize =3D len(Value) + 1 NewValue =3D '{' for Index in range(0, len(Value)): if Unicode: - NewValue =3D NewValue + str(ord(Value[Index]) % 0x= 10000) + ', ' + NewValue =3D NewValue + \ + str(ord(Value[Index]) % 0x10000) + ', ' else: - NewValue =3D NewValue + str(ord(Value[Index]) % 0x= 100) + ', ' + NewValue =3D NewValue + \ + str(ord(Value[Index]) % 0x100) + ', ' if Unicode: ArraySize =3D ArraySize // 2 Value =3D NewValue + '0 }' if ArraySize < ValueSize: if Pcd.MaxSizeUserSet: EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* type PCD '%s.%s= ' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Token= CName), - ExtraData=3D"[%s]" % str(Info)) + "The maximum size of VOID* type PCD '%= s.%s' is less than its actual size occupied." % ( + Pcd.TokenSpaceGuidCName, TokenCNam= e), + ExtraData=3D"[%s]" % str(Info)) else: ArraySize =3D Pcd.GetPcdSize() if Unicode: @@ -1076,76 +1126,108 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, = Pcd): # # For unicode, UINT16 array will be generated, so the alignmen= t of unicode is guaranteed. # - AutoGenH.Append('#define %s %s%s\n' %(PcdValueName, Type, Pcd= VariableName)) + AutoGenH.Append('#define %s %s%s\n' % + (PcdValueName, Type, PcdVariableName)) if Unicode: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %= s%s =3D %s;\n' % (Const, PcdVariableName, Array, Value)) - AutoGenH.Append('extern %s UINT16 %s%s;\n' %(Const, PcdVar= iableName, Array)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %= s%s =3D %s;\n' % ( + Const, PcdVariableName, Array, Value)) + AutoGenH.Append('extern %s UINT16 %s%s;\n' % + (Const, PcdVariableName, Array)) else: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s= %s =3D %s;\n' % (Const, PcdVariableName, Array, Value)) - AutoGenH.Append('extern %s UINT8 %s%s;\n' %(Const, PcdVari= ableName, Array)) - AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdV= ariableName)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s= %s =3D %s;\n' % ( + Const, PcdVariableName, Array, Value)) + AutoGenH.Append('extern %s UINT8 %s%s;\n' % + (Const, PcdVariableName, Array)) + AutoGenH.Append('#define %s %s%s\n' % + (GetModeName, Type, PcdVariableName)) =20 PcdDataSize =3D Pcd.GetPcdSize() if Pcd.Type =3D=3D TAB_PCDS_FIXED_AT_BUILD: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, = PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, Fi= xPcdSizeTokenName)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN= %s =3D %s;\n' % (FixedPcdSizeVariableName, PcdDataSize)) + AutoGenH.Append('#define %s %s\n' % + (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.Append('#define %s %s \n' % + (GetModeSizeName, FixPcdSizeTokenName)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN= %s =3D %s;\n' % ( + FixedPcdSizeVariableName, PcdDataSize)) if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName= , Pcd.MaxDatumSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, Pa= tchPcdSizeVariableName)) - AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariab= leName) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = =3D %s;\n' % (PatchPcdSizeVariableName, PcdDataSize)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN= %s =3D %s;\n' % (PatchPcdMaxSizeVariable, Pcd.MaxDatumSize)) + AutoGenH.Append('#define %s %s\n' % + (PatchPcdSizeTokenName, Pcd.MaxDatumSize)) + AutoGenH.Append('#define %s %s \n' % + (GetModeSizeName, PatchPcdSizeVariableName= )) + AutoGenH.Append('extern UINTN %s; \n' % + PatchPcdSizeVariableName) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = =3D %s;\n' % ( + PatchPcdSizeVariableName, PcdDataSize)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN= %s =3D %s;\n' % ( + PatchPcdMaxSizeVariable, Pcd.MaxDatumSize)) elif Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: - AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) - AutoGenC.Append('volatile %s %s %s =3D %s;\n' %(Const, Pcd.Dat= umType, PcdVariableName, PcdValueName)) - AutoGenH.Append('extern volatile %s %s %s%s;\n' % (Const, Pc= d.DatumType, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, Pcd= VariableName)) + AutoGenH.Append('#define %s %s\n' % (PcdValueName, Value)) + AutoGenC.Append('volatile %s %s %s =3D %s;\n' % ( + Const, Pcd.DatumType, PcdVariableName, PcdValueName)) + AutoGenH.Append('extern volatile %s %s %s%s;\n' % + (Const, Pcd.DatumType, PcdVariableName, Array)) + AutoGenH.Append('#define %s %s%s\n' % + (GetModeName, Type, PcdVariableName)) =20 PcdDataSize =3D Pcd.GetPcdSize() - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pc= dDataSize)) + AutoGenH.Append('#define %s %s\n' % + (PatchPcdSizeTokenName, PcdDataSize)) =20 - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, PatchP= cdSizeVariableName)) + AutoGenH.Append('#define %s %s \n' % + (GetModeSizeName, PatchPcdSizeVariableName)) AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableNa= me) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s =3D %s= ;\n' % (PatchPcdSizeVariableName, PcdDataSize)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s =3D %s= ;\n' % ( + PatchPcdSizeVariableName, PcdDataSize)) else: PcdDataSize =3D Pcd.GetPcdSize() - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdD= ataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, FixPcd= SizeTokenName)) + AutoGenH.Append('#define %s %s\n' % + (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.Append('#define %s %s \n' % + (GetModeSizeName, FixPcdSizeTokenName)) =20 - AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s =3D %s= ;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) - AutoGenH.Append('extern %s %s %s%s;\n' % (Const, Pcd.DatumTy= pe, PcdVariableName, Array)) - AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, Pcd= VariableName)) + AutoGenH.Append('#define %s %s\n' % (PcdValueName, Value)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s =3D %s= ;\n' % ( + Const, Pcd.DatumType, PcdVariableName, PcdValueName)) + AutoGenH.Append('extern %s %s %s%s;\n' % + (Const, Pcd.DatumType, PcdVariableName, Array)) + AutoGenH.Append('#define %s %s%s\n' % + (GetModeName, Type, PcdVariableName)) =20 if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s,= (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName= , Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s= , (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeSta= tusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s,= (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % + (SetModeName, Pcd.TokenCName, Pcd.TokenCNa= me, Pcd.TokenCName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatc= hPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s= , (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % + (SetModeStatusName, Pcd.TokenCName, Pcd.To= kenCName, Pcd.TokenCName)) else: - AutoGenH.Append('#define %s(Value) (%s =3D (Value))\n' % = (SetModeName, PcdVariableName)) - AutoGenH.Append('#define %s(Value) ((%s =3D (Value)), RET= URN_SUCCESS) \n' % (SetModeStatusName, PcdVariableName)) + AutoGenH.Append('#define %s(Value) (%s =3D (Value))\n' % + (SetModeName, PcdVariableName)) + AutoGenH.Append('#define %s(Value) ((%s =3D (Value)), RET= URN_SUCCESS) \n' % ( + SetModeStatusName, PcdVariableName)) else: - AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not all= owed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) + AutoGenH.Append( + '//#define %s ASSERT(FALSE) // It is not allowed to set = value for a FIXED_AT_BUILD PCD\n' % SetModeName) =20 -## Create code for library module PCDs +# Create code for library module PCDs # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # @param Pcd The PCD object # + + def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenNumber =3D Info.PlatformInfo.PcdTokenNumber TokenSpaceGuidCName =3D Pcd.TokenSpaceGuidCName - TokenCName =3D Pcd.TokenCName + TokenCName =3D Pcd.TokenCName for PcdItem in GlobalData.MixedPcd: if (TokenCName, TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdIte= m]: TokenCName =3D PcdItem[0] break PcdTokenName =3D '_PCD_TOKEN_' + TokenCName FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName - PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' + PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName + '_SIZE' PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName PatchPcdMaxSizeVariable =3D '_gPcd_BinaryPatch_MaxSize_' + TokenCName FixedPcdSizeVariableName =3D '_gPcd_FixedAtBuild_Size_' + TokenCName @@ -1173,28 +1255,37 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): TokenNumber =3D 0 else: EdkLogger.error("build", AUTOGEN_ERROR, - "No generated token number for %s.%s\n" % = (Pcd.TokenSpaceGuidCName, TokenCName), + "No generated token number for %s.%s\n" % ( + Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) else: - TokenNumber =3D PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceG= uidCName] + TokenNumber =3D PcdTokenNumber[Pcd.TokenCName, + Pcd.TokenSpaceGuidCName] =20 if Pcd.Type not in gItemTypeStringDatabase: EdkLogger.error("build", AUTOGEN_ERROR, - "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, = Pcd.TokenSpaceGuidCName, TokenCName), + "Unknown PCD type [%s] of PCD %s.%s" % ( + Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData=3D"[%s]" % str(Info)) =20 - DatumType =3D Pcd.DatumType + DatumType =3D Pcd.DatumType DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_= VOID] - GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName - SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName - SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + T= okenCName + GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_GET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_SET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + \ + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PC= D_SET_MODE_' + \ + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName =3D '_PCD_GET_MODE_SIZE' + '_' + TokenCName =20 Type =3D '' Array =3D '' if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - if Pcd.DefaultValue[0]=3D=3D '{': + if Pcd.DefaultValue[0] =3D=3D '{': Type =3D '(VOID *)' Array =3D '[]' PcdItemType =3D Pcd.Type @@ -1217,28 +1308,44 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): # If only PcdGet/Set used in all Pcds with different CName, it sho= uld succeed to build. # If PcdGet/Set used in the Pcds with different Guids but same CNa= me, it should failed to build. if PcdExCNameTest > 1: - AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGe= t/Set are not allowed in the case that more than one DynamicEx Pcds are dif= ferent Guids but same CName.\n') - AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) - AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % = (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append( + '// Disabled the macros, as PcdToken and PcdGet/Set are no= t allowed in the case that more than one DynamicEx Pcds are different Guids= but same CName.\n') + AutoGenH.Append('// #define %s %s\n' % + (PcdTokenName, PcdExTokenName)) + AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % + (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuid= CName, PcdTokenName)) + AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % + (GetModeSizeName, Pcd.TokenSpaceGuidCName, Pcd= TokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % + (SetModeName, DatumSizeLib, Pcd.TokenSpace= GuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % + (SetModeStatusName, DatumSizeLib, Pcd.Toke= nSpaceGuidCName, PcdTokenName)) else: - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, = %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdT= okenName)) - AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s,= %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNam= e, PcdTokenName)) + AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, = %s, (Value))\n' % + (SetModeName, DatumSizeLib, Pcd.TokenSpace= GuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s(Value) LibPcdSetEx%sS(&%s,= %s, (Value))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) - AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s %s\n' % + (PcdTokenName, PcdExTokenName)) + AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % ( + GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTok= enName)) + AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % ( + GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, Pc= dTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s,= (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdToke= nName)) - AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s= , (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, = PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s,= (Value))\n' % ( + SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, Pc= dTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s= , (Value))\n' % ( + SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCNa= me, PcdTokenName)) else: - AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, Toke= nNumber)) + AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % + (TokenCName, TokenNumber)) if PcdItemType in PCD_DYNAMIC_TYPE_SET: PcdList =3D [] PcdCNameList =3D [] @@ -1248,51 +1355,75 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): if PcdModule.Type in PCD_DYNAMIC_TYPE_SET: PcdCNameList.append(PcdModule.TokenCName) if PcdCNameList.count(Pcd.TokenCName) > 1: - EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic= Pcds [%s] are different Guids but same CName.They need to be changed to Dy= namicEx type to avoid the confliction.\n" % (TokenCName), ExtraData=3D"[%s]= " % str(Info.MetaFile.Path)) + EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic= Pcds [%s] are different Guids but same CName.They need to be changed to Dy= namicEx type to avoid the confliction.\n" % ( + TokenCName), ExtraData=3D"[%s]" % str(Info.MetaFile.Path)) else: - AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSi= zeName, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % + (GetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % + (GetModeSizeName, PcdTokenName)) if DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % ( + SetModeStatusName, DatumSizeLib, PcdTokenName)) else: - AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value= ))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) - AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Valu= e))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value= ))\n' % ( + SetModeName, DatumSizeLib, PcdTokenName)) + AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Valu= e))\n' % ( + SetModeStatusName, DatumSizeLib, PcdTokenName)) if PcdItemType =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: - PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PA= TCHABLE_IN_MODULE] + '_' + TokenCName + PcdVariableName =3D '_gPcd_' + \ + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + \ + '_' + TokenCName if DatumType not in TAB_PCD_NUMERIC_TYPES: if DatumType =3D=3D TAB_VOID and Array =3D=3D '[]': DatumType =3D [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] = =3D=3D 'L'] else: DatumType =3D TAB_UINT8 - AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumT= ype, TokenCName, Array)) + AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' % + (DatumType, TokenCName, Array)) else: - AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, P= cdVariableName, Array)) - AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeNa= me, Type, TokenCName)) + AutoGenH.Append('extern volatile %s %s%s;\n' % + (DatumType, PcdVariableName, Array)) + AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' % + (GetModeName, Type, TokenCName)) PcdDataSize =3D Pcd.GetPcdSize() if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffe= r))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSiz= eVariable)) - AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buff= er))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPc= dMaxSizeVariable)) - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pa= tchPcdMaxSizeVariable)) - AutoGenH.Append('extern const UINTN %s; \n' % PatchPcdMaxSizeV= ariable) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffe= r))\n' % + (SetModeName, TokenCName, PatchPcdSizeVariable= Name, PatchPcdMaxSizeVariable)) + AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buff= er))\n' % + (SetModeStatusName, TokenCName, PatchPcdSizeVa= riableName, PatchPcdMaxSizeVariable)) + AutoGenH.Append('#define %s %s\n' % + (PatchPcdSizeTokenName, PatchPcdMaxSizeVariabl= e)) + AutoGenH.Append('extern const UINTN %s; \n' % + PatchPcdMaxSizeVariable) else: - AutoGenH.Append('#define %s(Value) (%s =3D (Value))\n' % (Set= ModeName, PcdVariableName)) - AutoGenH.Append('#define %s(Value) ((%s =3D (Value)), RETURN_= SUCCESS)\n' % (SetModeStatusName, PcdVariableName)) - AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pc= dDataSize)) + AutoGenH.Append('#define %s(Value) (%s =3D (Value))\n' % + (SetModeName, PcdVariableName)) + AutoGenH.Append('#define %s(Value) ((%s =3D (Value)), RETURN_= SUCCESS)\n' % ( + SetModeStatusName, PcdVariableName)) + AutoGenH.Append('#define %s %s\n' % + (PatchPcdSizeTokenName, PcdDataSize)) =20 - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, PatchPcdSize= VariableName)) + AutoGenH.Append('#define %s %s\n' % + (GetModeSizeName, PatchPcdSizeVariableName)) AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) =20 if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD or PcdItemType =3D=3D TA= B_PCDS_FEATURE_FLAG: key =3D ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) - PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] += '_' + TokenCName + PcdVariableName =3D '_gPcd_' + \ + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName if DatumType =3D=3D TAB_VOID and Array =3D=3D '[]': DatumType =3D [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] =3D= =3D 'L'] if DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: DatumType =3D TAB_UINT8 - AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(Dat= umType, TokenCName, Array)) - AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeN= ame, Type, TokenCName)) - AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed= to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) + AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' % + (DatumType, TokenCName, Array)) + AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' % + (GetModeName, Type, TokenCName)) + AutoGenH.Append( + '//#define %s ASSERT(FALSE) // It is not allowed to set valu= e for a FIXED_AT_BUILD PCD\n' % SetModeName) =20 ConstFixedPcd =3D False if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD and (key in Info.Con= stPcd or (Info.IsLibrary and not Info.ReferenceModules)): @@ -1300,29 +1431,40 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): if key in Info.ConstPcd: Pcd.DefaultValue =3D Info.ConstPcd[key] if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCNam= e, Type, PcdVariableName)) + AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' % + (TokenCName, Type, PcdVariableName)) else: - AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName,= Pcd.DefaultValue)) + AutoGenH.Append('#define _PCD_VALUE_%s %s\n' % + (TokenCName, Pcd.DefaultValue)) PcdDataSize =3D Pcd.GetPcdSize() if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD: if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if ConstFixedPcd: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenNa= me, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, = FixPcdSizeTokenName)) + AutoGenH.Append('#define %s %s\n' % + (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.Append('#define %s %s\n' % + (GetModeSizeName, FixPcdSizeTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, = FixedPcdSizeVariableName)) - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenNa= me, FixedPcdSizeVariableName)) - AutoGenH.Append('extern const UINTN %s; \n' % FixedPcd= SizeVariableName) + AutoGenH.Append('#define %s %s\n' % + (GetModeSizeName, FixedPcdSizeVariable= Name)) + AutoGenH.Append('#define %s %s\n' % ( + FixPcdSizeTokenName, FixedPcdSizeVariableName)) + AutoGenH.Append('extern const UINTN %s; \n' % + FixedPcdSizeVariableName) else: - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, = PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, FixP= cdSizeTokenName)) + AutoGenH.Append('#define %s %s\n' % + (FixPcdSizeTokenName, PcdDataSize)) + AutoGenH.Append('#define %s %s\n' % + (GetModeSizeName, FixPcdSizeTokenName)) =20 -## Create code for library constructor +# Create code for library constructor # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): # # Library Constructors @@ -1336,21 +1478,29 @@ def CreateLibraryConstructorCode(Info, AutoGenC, Au= toGenH): for Lib in DependentLibraryList: if len(Lib.ConstructorList) <=3D 0: continue - Dict =3D {'Function':Lib.ConstructorList} + Dict =3D {'Function': Lib.ConstructorList} if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]: - ConstructorPrototypeString.Append(gLibraryStructorPrototype[SU= P_MODULE_BASE].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall[SUP_MODUL= E_BASE].Replace(Dict)) + ConstructorPrototypeString.Append( + gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict)) + ConstructorCallingString.Append( + gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict)) if Info.ModuleType not in [SUP_MODULE_BASE, SUP_MODULE_USER_DEFINE= D, SUP_MODULE_HOST_APPLICATION]: if Lib.ModuleType in SUP_MODULE_SET_PEI: - ConstructorPrototypeString.Append(gLibraryStructorPrototyp= e['PEI'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['PEI'= ].Replace(Dict)) + ConstructorPrototypeString.Append( + gLibraryStructorPrototype['PEI'].Replace(Dict)) + ConstructorCallingString.Append( + gLibraryStructorCall['PEI'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DR= IVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_= UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: - ConstructorPrototypeString.Append(gLibraryStructorPrototyp= e['DXE'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['DXE'= ].Replace(Dict)) + ConstructorPrototypeString.Append( + gLibraryStructorPrototype['DXE'].Replace(Dict)) + ConstructorCallingString.Append( + gLibraryStructorCall['DXE'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_M= M_CORE_STANDALONE]: - ConstructorPrototypeString.Append(gLibraryStructorPrototyp= e['MM'].Replace(Dict)) - ConstructorCallingString.Append(gLibraryStructorCall['MM']= .Replace(Dict)) + ConstructorPrototypeString.Append( + gLibraryStructorPrototype['MM'].Replace(Dict)) + ConstructorCallingString.Append( + gLibraryStructorCall['MM'].Replace(Dict)) =20 if str(ConstructorPrototypeString) =3D=3D '': ConstructorPrototypeList =3D [] @@ -1362,9 +1512,9 @@ def CreateLibraryConstructorCode(Info, AutoGenC, Auto= GenH): ConstructorCallingList =3D [str(ConstructorCallingString)] =20 Dict =3D { - 'Type' : 'Constructor', - 'FunctionPrototype' : ConstructorPrototypeList, - 'FunctionCall' : ConstructorCallingList + 'Type': 'Constructor', + 'FunctionPrototype': ConstructorPrototypeList, + 'FunctionCall': ConstructorCallingList } if Info.IsLibrary: AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict) @@ -1379,12 +1529,14 @@ def CreateLibraryConstructorCode(Info, AutoGenC, Au= toGenH): elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_C= ORE_STANDALONE]: AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) =20 -## Create code for library destructor +# Create code for library destructor # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): # # Library Destructors @@ -1399,21 +1551,29 @@ def CreateLibraryDestructorCode(Info, AutoGenC, Aut= oGenH): Lib =3D DependentLibraryList[Index] if len(Lib.DestructorList) <=3D 0: continue - Dict =3D {'Function':Lib.DestructorList} + Dict =3D {'Function': Lib.DestructorList} if Lib.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC]: - DestructorPrototypeString.Append(gLibraryStructorPrototype[SUP= _MODULE_BASE].Replace(Dict)) - DestructorCallingString.Append(gLibraryStructorCall[SUP_MODULE= _BASE].Replace(Dict)) + DestructorPrototypeString.Append( + gLibraryStructorPrototype[SUP_MODULE_BASE].Replace(Dict)) + DestructorCallingString.Append( + gLibraryStructorCall[SUP_MODULE_BASE].Replace(Dict)) if Info.ModuleType not in [SUP_MODULE_BASE, SUP_MODULE_USER_DEFINE= D, SUP_MODULE_HOST_APPLICATION]: if Lib.ModuleType in SUP_MODULE_SET_PEI: - DestructorPrototypeString.Append(gLibraryStructorPrototype= ['PEI'].Replace(Dict)) - DestructorCallingString.Append(gLibraryStructorCall['PEI']= .Replace(Dict)) + DestructorPrototypeString.Append( + gLibraryStructorPrototype['PEI'].Replace(Dict)) + DestructorCallingString.Append( + gLibraryStructorCall['PEI'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DR= IVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_= UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: - DestructorPrototypeString.Append(gLibraryStructorPrototype= ['DXE'].Replace(Dict)) - DestructorCallingString.Append(gLibraryStructorCall['DXE']= .Replace(Dict)) + DestructorPrototypeString.Append( + gLibraryStructorPrototype['DXE'].Replace(Dict)) + DestructorCallingString.Append( + gLibraryStructorCall['DXE'].Replace(Dict)) elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_M= M_CORE_STANDALONE]: - DestructorPrototypeString.Append(gLibraryStructorPrototype= ['MM'].Replace(Dict)) - DestructorCallingString.Append(gLibraryStructorCall['MM'].= Replace(Dict)) + DestructorPrototypeString.Append( + gLibraryStructorPrototype['MM'].Replace(Dict)) + DestructorCallingString.Append( + gLibraryStructorCall['MM'].Replace(Dict)) =20 if str(DestructorPrototypeString) =3D=3D '': DestructorPrototypeList =3D [] @@ -1425,9 +1585,9 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoG= enH): DestructorCallingList =3D [str(DestructorCallingString)] =20 Dict =3D { - 'Type' : 'Destructor', - 'FunctionPrototype' : DestructorPrototypeList, - 'FunctionCall' : DestructorCallingList + 'Type': 'Destructor', + 'FunctionPrototype': DestructorPrototypeList, + 'FunctionCall': DestructorCallingList } if Info.IsLibrary: AutoGenH.Append("${BEGIN}${FunctionPrototype}${END}", Dict) @@ -1443,7 +1603,7 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoG= enH): AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) =20 =20 -## Create code for ModuleEntryPoint +# Create code for ModuleEntryPoint # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code @@ -1465,8 +1625,8 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGe= nH): else: UefiSpecVersion =3D '0x00000000' Dict =3D { - 'Function' : Info.Module.ModuleEntryPointList, - 'PiSpecVersion' : PiSpecVersion + 'U', + 'Function': Info.Module.ModuleEntryPointList, + 'PiSpecVersion': PiSpecVersion + 'U', 'UefiSpecVersion': UefiSpecVersion + 'U' } =20 @@ -1474,12 +1634,12 @@ def CreateModuleEntryPointCode(Info, AutoGenC, Auto= GenH): if Info.SourceFileList: if NumEntryPoints !=3D 1: EdkLogger.error( - "build", - AUTOGEN_ERROR, - '%s must have exactly one entry point' % Info.ModuleType, - File=3Dstr(Info), - ExtraData=3D ", ".join(Info.Module.ModuleEntryPointList) - ) + "build", + AUTOGEN_ERROR, + '%s must have exactly one entry point' % Info.ModuleTy= pe, + File=3Dstr(Info), + ExtraData=3D", ".join(Info.Module.ModuleEntryPointList) + ) if Info.ModuleType =3D=3D SUP_MODULE_PEI_CORE: AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict)) @@ -1494,13 +1654,15 @@ def CreateModuleEntryPointCode(Info, AutoGenC, Auto= GenH): AutoGenH.Append(gMmCoreStandaloneEntryPointPrototype.Replace(Dict)) elif Info.ModuleType =3D=3D SUP_MODULE_PEIM: if NumEntryPoints < 2: - AutoGenC.Append(gPeimEntryPointString[NumEntryPoints].Replace(= Dict)) + AutoGenC.Append( + gPeimEntryPointString[NumEntryPoints].Replace(Dict)) else: AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict)) AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict)) elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE= _DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: if NumEntryPoints < 2: - AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Re= place(Dict)) + AutoGenC.Append( + gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) else: AutoGenC.Append(gUefiDriverEntryPointString[2].Replace(Dict)) AutoGenH.Append(gUefiDriverEntryPointPrototype.Replace(Dict)) @@ -1512,23 +1674,27 @@ def CreateModuleEntryPointCode(Info, AutoGenC, Auto= GenH): AutoGenH.Append(gDxeSmmEntryPointPrototype.Replace(Dict)) elif Info.ModuleType =3D=3D SUP_MODULE_MM_STANDALONE: if NumEntryPoints < 2: - AutoGenC.Append(gMmStandaloneEntryPointString[NumEntryPoints].= Replace(Dict)) + AutoGenC.Append( + gMmStandaloneEntryPointString[NumEntryPoints].Replace(Dict= )) else: AutoGenC.Append(gMmStandaloneEntryPointString[2].Replace(Dict)) AutoGenH.Append(gMmStandaloneEntryPointPrototype.Replace(Dict)) elif Info.ModuleType =3D=3D SUP_MODULE_UEFI_APPLICATION: if NumEntryPoints < 2: - AutoGenC.Append(gUefiApplicationEntryPointString[NumEntryPoint= s].Replace(Dict)) + AutoGenC.Append( + gUefiApplicationEntryPointString[NumEntryPoints].Replace(D= ict)) else: AutoGenC.Append(gUefiApplicationEntryPointString[2].Replace(Di= ct)) AutoGenH.Append(gUefiApplicationEntryPointPrototype.Replace(Dict)) =20 -## Create code for ModuleUnloadImage +# Create code for ModuleUnloadImage # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_= MODULE_HOST_APPLICATION, SUP_MODULE_BASE, SUP_MODULE_SEC]: return @@ -1536,19 +1702,22 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, Aut= oGenH): # Unload Image Handlers # NumUnloadImage =3D len(Info.Module.ModuleUnloadImageList) - Dict =3D {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.Mo= duleUnloadImageList} + Dict =3D {'Count': str(NumUnloadImage) + 'U', + 'Function': Info.Module.ModuleUnloadImageList} if NumUnloadImage < 2: AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dic= t)) else: AutoGenC.Append(gUefiUnloadImageString[2].Replace(Dict)) AutoGenH.Append(gUefiUnloadImagePrototype.Replace(Dict)) =20 -## Create code for GUID +# Create code for GUID # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_HOST_APPLIC= ATION, SUP_MODULE_BASE]: GuidType =3D TAB_GUID @@ -1564,15 +1733,18 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGe= nH): # for Key in Info.GuidList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % (GuidType, Key, Info.GuidList[Key])) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % ( + GuidType, Key, Info.GuidList[Key])) AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) =20 -## Create code for protocol +# Create code for protocol # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_HOST_APPLIC= ATION, SUP_MODULE_BASE]: GuidType =3D TAB_GUID @@ -1588,15 +1760,18 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, Au= toGenH): # for Key in Info.ProtocolList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % (GuidType, Key, Info.ProtocolList[Key])) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % ( + GuidType, Key, Info.ProtocolList[Key])) AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) =20 -## Create code for PPI +# Create code for PPI # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_HOST_APPLIC= ATION, SUP_MODULE_BASE]: GuidType =3D TAB_GUID @@ -1612,15 +1787,18 @@ def CreatePpiDefinitionCode(Info, AutoGenC, AutoGen= H): # for Key in Info.PpiList: if not Info.IsLibrary: - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % (GuidType, Key, Info.PpiList[Key])) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s =3D %s;\n= ' % ( + GuidType, Key, Info.PpiList[Key])) AutoGenH.Append('extern %s %s;\n' % (GuidType, Key)) =20 -## Create code for PCD +# Create code for PCD # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreatePcdCode(Info, AutoGenC, AutoGenH): =20 # Collect Token Space GUIDs used by DynamicEc PCDs @@ -1634,7 +1812,8 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n") # Add extern declarations to AutoGen.h if one or more Token Space GUID= s were found if TokenSpaceList: - AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in = this module\n\n") + AutoGenH.Append( + "\n// Definition of PCD Token Space GUIDs used in this module\= n\n") if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_HOST_AP= PLICATION, SUP_MODULE_BASE]: GuidType =3D TAB_GUID else: @@ -1647,24 +1826,26 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): AutoGenH.Append("\n// PCD definitions\n") for Pcd in Info.ModulePcdList: CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd) - DynExPcdTokenNumberMapping (Info, AutoGenH) + DynExPcdTokenNumberMapping(Info, AutoGenH) else: AutoGenC.Append("\n// Definition of SkuId Array\n") - AutoGenC.Append("GLOBAL_REMOVE_IF_UNREFERENCED UINT64 _gPcd_SkuId_= Array[] =3D %s;\n" % SkuMgr.DumpSkuIdArrary()) + AutoGenC.Append( + "GLOBAL_REMOVE_IF_UNREFERENCED UINT64 _gPcd_SkuId_Array[] =3D = %s;\n" % SkuMgr.DumpSkuIdArrary()) if Info.ModulePcdList: AutoGenH.Append("\n// Definition of PCDs used in this module\n= ") AutoGenC.Append("\n// Definition of PCDs used in this module\n= ") for Pcd in Info.ModulePcdList: CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd) - DynExPcdTokenNumberMapping (Info, AutoGenH) + DynExPcdTokenNumberMapping(Info, AutoGenH) if Info.LibraryPcdList: - AutoGenH.Append("\n// Definition of PCDs used in libraries is = in AutoGen.c\n") + AutoGenH.Append( + "\n// Definition of PCDs used in libraries is in AutoGen.c= \n") AutoGenC.Append("\n// Definition of PCDs used in libraries\n") for Pcd in Info.LibraryPcdList: CreateModulePcdCode(Info, AutoGenC, AutoGenC, Pcd) CreatePcdDatabaseCode(Info, AutoGenC, AutoGenH) =20 -## Create code for unicode string definition +# Create code for unicode string definition # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code @@ -1672,6 +1853,8 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): # @param UniGenCFlag UniString is generated into AutoGen C file= when it is set to True # @param UniGenBinBuffer Buffer to store uni string package data # + + def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenB= inBuffer): WorkingDir =3D os.getcwd() os.chdir(Info.WorkspaceDir) @@ -1698,12 +1881,13 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGen= H, UniGenCFlag, UniGenBinBuff else: ShellMode =3D False =20 - #RFC4646 is only for EDKII modules and ISO639-2 for EDK modules + # RFC4646 is only for EDKII modules and ISO639-2 for EDK modules if EDK2Module: FilterInfo =3D [EDK2Module] + [Info.PlatformInfo.Platform.RFCLangu= ages] else: FilterInfo =3D [EDK2Module] + [Info.PlatformInfo.Platform.ISOLangu= ages] - Header, Code =3D GetStringFiles(Info.UnicodeFileList, SrcList, IncList= , Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellM= ode, UniGenCFlag, UniGenBinBuffer, FilterInfo) + Header, Code =3D GetStringFiles(Info.UnicodeFileList, SrcList, IncList= , Info.IncludePathList, [ + '.uni', '.inf'], Info.Name, CompatibleMo= de, ShellMode, UniGenCFlag, UniGenBinBuffer, FilterInfo) if CompatibleMode or UniGenCFlag: AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") AutoGenC.Append(Code) @@ -1714,9 +1898,10 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH= , UniGenCFlag, UniGenBinBuff AutoGenH.Append("\n#define STRING_ARRAY_NAME %sStrings\n" % Info.N= ame) os.chdir(WorkingDir) =20 + def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffe= r): if len(Info.IdfFileList) > 0: - ImageFiles =3D IdfFileClassObject(sorted (Info.IdfFileList)) + ImageFiles =3D IdfFileClassObject(sorted(Info.IdfFileList)) if ImageFiles.ImageFilesDict: Index =3D 1 PaletteIndex =3D 1 @@ -1739,32 +1924,41 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfG= enCFlag, IdfGenBinBuffer): for sourcefile in Info.SourceFileList: if FileObj.FileName =3D=3D sourcefile.File: if not sourcefile.Ext.upper() in ['.PNG', = '.BMP', '.JPG']: - EdkLogger.error("build", AUTOGEN_ERROR= , "The %s's postfix must be one of .bmp, .jpg, .png" % (FileObj.FileName), = ExtraData=3D"[%s]" % str(Info)) + EdkLogger.error("build", AUTOGEN_ERROR= , "The %s's postfix must be one of .bmp, .jpg, .png" % ( + FileObj.FileName), ExtraData=3D"[%= s]" % str(Info)) FileObj.File =3D sourcefile break else: - EdkLogger.error("build", AUTOGEN_ERROR, "The %= s in %s is not defined in the driver's [Sources] section" % (FileObj.FileNa= me, Idf), ExtraData=3D"[%s]" % str(Info)) + EdkLogger.error("build", AUTOGEN_ERROR, "The %= s in %s is not defined in the driver's [Sources] section" % ( + FileObj.FileName, Idf), ExtraData=3D"[%s]"= % str(Info)) =20 for FileObj in ImageFiles.ImageFilesDict[Idf]: ID =3D FileObj.ImageID File =3D FileObj.File try: - SearchImageID (FileObj, FileList) + SearchImageID(FileObj, FileList) if FileObj.Referenced: if (ValueStartPtr - len(DEFINE_STR + ID)) = <=3D 0: - Line =3D DEFINE_STR + ' ' + ID + ' ' += DecToHexStr(Index, 4) + '\n' + Line =3D DEFINE_STR + ' ' + ID + ' ' += \ + DecToHexStr(Index, 4) + '\n' else: - Line =3D DEFINE_STR + ' ' + ID + ' ' *= (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n' + Line =3D DEFINE_STR + ' ' + ID + ' ' *= \ + (ValueStartPtr - len(DEFINE_STR + = ID) + ) + DecToHexStr(Index, 4) + '\n' =20 if File not in FileDict: FileDict[File] =3D Index else: - DuplicateBlock =3D pack('B', EFI_HII_I= IBT_DUPLICATE) + DuplicateBlock =3D pack( + 'B', EFI_HII_IIBT_DUPLICATE) DuplicateBlock +=3D pack('H', FileDict= [File]) ImageBuffer +=3D DuplicateBlock - BufferStr =3D WriteLine(BufferStr, '//= %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4))) - TempBufferList =3D AscToHexList(Duplic= ateBlock) - BufferStr =3D WriteLine(BufferStr, Cre= ateArrayItem(TempBufferList, 16) + '\n') + BufferStr =3D WriteLine( + BufferStr, '// %s: %s: %s' % (DecT= oHexStr(Index, 4), ID, DecToHexStr(Index, 4))) + TempBufferList =3D AscToHexList( + DuplicateBlock) + BufferStr =3D WriteLine( + BufferStr, CreateArrayItem(TempBuf= ferList, 16) + '\n') StringH.Append(Line) Index +=3D 1 continue @@ -1773,50 +1967,65 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfG= enCFlag, IdfGenBinBuffer): Buffer =3D TmpFile.read() TmpFile.close() if File.Ext.upper() =3D=3D '.PNG': - TempBuffer =3D pack('B', EFI_HII_IIBT_= IMAGE_PNG) + TempBuffer =3D pack( + 'B', EFI_HII_IIBT_IMAGE_PNG) TempBuffer +=3D pack('I', len(Buffer)) TempBuffer +=3D Buffer elif File.Ext.upper() =3D=3D '.JPG': - ImageType, =3D struct.unpack('4s', Buf= fer[6:10]) + ImageType, =3D struct.unpack( + '4s', Buffer[6:10]) if ImageType !=3D b'JFIF': - EdkLogger.error("build", FILE_TYPE= _MISMATCH, "The file %s is not a standard JPG file." % File.Path) - TempBuffer =3D pack('B', EFI_HII_IIBT_= IMAGE_JPEG) + EdkLogger.error( + "build", FILE_TYPE_MISMATCH, "= The file %s is not a standard JPG file." % File.Path) + TempBuffer =3D pack( + 'B', EFI_HII_IIBT_IMAGE_JPEG) TempBuffer +=3D pack('I', len(Buffer)) TempBuffer +=3D Buffer elif File.Ext.upper() =3D=3D '.BMP': - TempBuffer, TempPalette =3D BmpImageDe= coder(File, Buffer, PaletteIndex, FileObj.TransParent) + TempBuffer, TempPalette =3D BmpImageDe= coder( + File, Buffer, PaletteIndex, FileOb= j.TransParent) if len(TempPalette) > 1: PaletteIndex +=3D 1 - NewPalette =3D pack('H', len(TempP= alette)) + NewPalette =3D pack( + 'H', len(TempPalette)) NewPalette +=3D TempPalette PaletteBuffer +=3D NewPalette - PaletteStr =3D WriteLine(PaletteSt= r, '// %s: %s: %s' % (DecToHexStr(PaletteIndex - 1, 4), ID, DecToHexStr(Pal= etteIndex - 1, 4))) - TempPaletteList =3D AscToHexList(N= ewPalette) - PaletteStr =3D WriteLine(PaletteSt= r, CreateArrayItem(TempPaletteList, 16) + '\n') + PaletteStr =3D WriteLine(PaletteSt= r, '// %s: %s: %s' % ( + DecToHexStr(PaletteIndex - 1, = 4), ID, DecToHexStr(PaletteIndex - 1, 4))) + TempPaletteList =3D AscToHexList( + NewPalette) + PaletteStr =3D WriteLine( + PaletteStr, CreateArrayItem(Te= mpPaletteList, 16) + '\n') ImageBuffer +=3D TempBuffer - BufferStr =3D WriteLine(BufferStr, '// %s:= %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4))) + BufferStr =3D WriteLine( + BufferStr, '// %s: %s: %s' % (DecToHex= Str(Index, 4), ID, DecToHexStr(Index, 4))) TempBufferList =3D AscToHexList(TempBuffer) - BufferStr =3D WriteLine(BufferStr, CreateA= rrayItem(TempBufferList, 16) + '\n') + BufferStr =3D WriteLine( + BufferStr, CreateArrayItem(TempBufferL= ist, 16) + '\n') =20 StringH.Append(Line) Index +=3D 1 except IOError: - EdkLogger.error("build", FILE_NOT_FOUND, Extra= Data=3DFile.Path) + EdkLogger.error( + "build", FILE_NOT_FOUND, ExtraData=3DFile.= Path) =20 BufferStr =3D WriteLine(BufferStr, '// End of the Image Info') - BufferStr =3D WriteLine(BufferStr, CreateArrayItem(DecToHexLis= t(EFI_HII_IIBT_END, 2)) + '\n') + BufferStr =3D WriteLine(BufferStr, CreateArrayItem( + DecToHexList(EFI_HII_IIBT_END, 2)) + '\n') ImageEnd =3D pack('B', EFI_HII_IIBT_END) ImageBuffer +=3D ImageEnd =20 if len(ImageBuffer) > 1: ImageInfoOffset =3D 12 if len(PaletteBuffer) > 1: - PaletteInfoOffset =3D 12 + len(ImageBuffer) - 1 # -1 is fo= r the first empty pad byte of ImageBuffer + # -1 is for the first empty pad byte of ImageBuffer + PaletteInfoOffset =3D 12 + len(ImageBuffer) - 1 =20 IMAGE_PACKAGE_HDR =3D pack('=3DII', ImageInfoOffset, PaletteIn= foOffset) # PACKAGE_HEADER_Length =3D PACKAGE_HEADER + ImageInfoOffset += PaletteInfoOffset + ImageBuffer Length + PaletteCount + PaletteBuffer Leng= th if len(PaletteBuffer) > 1: - PACKAGE_HEADER_Length =3D 4 + 4 + 4 + len(ImageBuffer) - 1= + 2 + len(PaletteBuffer) - 1 + PACKAGE_HEADER_Length =3D 4 + 4 + 4 + \ + len(ImageBuffer) - 1 + 2 + len(PaletteBuffer) - 1 else: PACKAGE_HEADER_Length =3D 4 + 4 + 4 + len(ImageBuffer) - 1 if PaletteIndex > 1: @@ -1824,12 +2033,14 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfG= enCFlag, IdfGenBinBuffer): # EFI_HII_PACKAGE_HEADER length max value is 0xFFFFFF Hex_Length =3D '%06X' % PACKAGE_HEADER_Length if PACKAGE_HEADER_Length > 0xFFFFFF: - EdkLogger.error("build", AUTOGEN_ERROR, "The Length of EFI= _HII_PACKAGE_HEADER exceed its maximum value", ExtraData=3D"[%s]" % str(Inf= o)) - PACKAGE_HEADER =3D pack('=3DHBB', int('0x' + Hex_Length[2:], 1= 6), int('0x' + Hex_Length[0:2], 16), EFI_HII_PACKAGE_IMAGES) + EdkLogger.error( + "build", AUTOGEN_ERROR, "The Length of EFI_HII_PACKAGE= _HEADER exceed its maximum value", ExtraData=3D"[%s]" % str(Info)) + PACKAGE_HEADER =3D pack('=3DHBB', int( + '0x' + Hex_Length[2:], 16), int('0x' + Hex_Length[0:2], 16= ), EFI_HII_PACKAGE_IMAGES) =20 IdfGenBinBuffer.write(PACKAGE_HEADER) IdfGenBinBuffer.write(IMAGE_PACKAGE_HDR) - if len(ImageBuffer) > 1 : + if len(ImageBuffer) > 1: IdfGenBinBuffer.write(ImageBuffer[1:]) if PaletteIndex > 1: IdfGenBinBuffer.write(PALETTE_INFO_HEADER) @@ -1839,27 +2050,34 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfG= enCFlag, IdfGenBinBuffer): if IdfGenCFlag: TotalLength =3D EFI_HII_ARRAY_SIZE_LENGTH + PACKAGE_HEADER= _Length AutoGenC.Append("\n//\n//Image Pack Definition\n//\n") - AllStr =3D WriteLine('', CHAR_ARRAY_DEFIN + ' ' + Info.Mod= ule.BaseName + 'Images' + '[] =3D {\n') + AllStr =3D WriteLine('', CHAR_ARRAY_DEFIN + ' ' + + Info.Module.BaseName + 'Images' + '[] = =3D {\n') AllStr =3D WriteLine(AllStr, '// STRGATHER_OUTPUT_HEADER') - AllStr =3D WriteLine(AllStr, CreateArrayItem(DecToHexList(= TotalLength)) + '\n') + AllStr =3D WriteLine(AllStr, CreateArrayItem( + DecToHexList(TotalLength)) + '\n') AllStr =3D WriteLine(AllStr, '// Image PACKAGE HEADER\n') IMAGE_PACKAGE_HDR_List =3D AscToHexList(PACKAGE_HEADER) IMAGE_PACKAGE_HDR_List +=3D AscToHexList(IMAGE_PACKAGE_HDR) - AllStr =3D WriteLine(AllStr, CreateArrayItem(IMAGE_PACKAGE= _HDR_List, 16) + '\n') + AllStr =3D WriteLine(AllStr, CreateArrayItem( + IMAGE_PACKAGE_HDR_List, 16) + '\n') AllStr =3D WriteLine(AllStr, '// Image DATA\n') if BufferStr: AllStr =3D WriteLine(AllStr, BufferStr) if PaletteStr: AllStr =3D WriteLine(AllStr, '// Palette Header\n') - PALETTE_INFO_HEADER_List =3D AscToHexList(PALETTE_INFO= _HEADER) - AllStr =3D WriteLine(AllStr, CreateArrayItem(PALETTE_I= NFO_HEADER_List, 16) + '\n') + PALETTE_INFO_HEADER_List =3D AscToHexList( + PALETTE_INFO_HEADER) + AllStr =3D WriteLine(AllStr, CreateArrayItem( + PALETTE_INFO_HEADER_List, 16) + '\n') AllStr =3D WriteLine(AllStr, '// Palette Data\n') AllStr =3D WriteLine(AllStr, PaletteStr) AllStr =3D WriteLine(AllStr, '};') AutoGenC.Append(AllStr) AutoGenC.Append("\n") - StringH.Append('\nextern unsigned char ' + Info.Module.Bas= eName + 'Images[];\n') - StringH.Append("\n#define IMAGE_ARRAY_NAME %sImages\n" % I= nfo.Module.BaseName) + StringH.Append('\nextern unsigned char ' + + Info.Module.BaseName + 'Images[];\n') + StringH.Append( + "\n#define IMAGE_ARRAY_NAME %sImages\n" % Info.Module.= BaseName) =20 # typedef struct _EFI_HII_IMAGE_PACKAGE_HDR { # EFI_HII_PACKAGE_HEADER Header; # Standard package header, wh= ere Header.Type =3D EFI_HII_PACKAGE_IMAGES @@ -1878,24 +2096,31 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfG= enCFlag, IdfGenBinBuffer): # UINT8 BlockBody[]; # } EFI_HII_IMAGE_BLOCK; =20 + def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent): ImageType, =3D struct.unpack('2s', Buffer[0:2]) - if ImageType!=3D b'BM': # BMP file type is 'BM' - EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a= standard BMP file." % File.Path) - BMP_IMAGE_HEADER =3D collections.namedtuple('BMP_IMAGE_HEADER', ['bfSi= ze', 'bfReserved1', 'bfReserved2', 'bfOffBits', 'biSize', 'biWidth', 'biHei= ght', 'biPlanes', 'biBitCount', 'biCompression', 'biSizeImage', 'biXPelsPer= Meter', 'biYPelsPerMeter', 'biClrUsed', 'biClrImportant']) + if ImageType !=3D b'BM': # BMP file type is 'BM' + EdkLogger.error("build", FILE_TYPE_MISMATCH, + "The file %s is not a standard BMP file." % File.P= ath) + BMP_IMAGE_HEADER =3D collections.namedtuple('BMP_IMAGE_HEADER', ['bfSi= ze', 'bfReserved1', 'bfReserved2', 'bfOffBits', 'biSize', 'biWidth', + 'biHeight', 'biPlanes', 'biB= itCount', 'biCompression', 'biSizeImage', 'biXPelsPerMeter', 'biYPelsPerMet= er', 'biClrUsed', 'biClrImportant']) BMP_IMAGE_HEADER_STRUCT =3D struct.Struct('IHHIIIIHHIIIIII') - BmpHeader =3D BMP_IMAGE_HEADER._make(BMP_IMAGE_HEADER_STRUCT.unpack_fr= om(Buffer[2:])) + BmpHeader =3D BMP_IMAGE_HEADER._make( + BMP_IMAGE_HEADER_STRUCT.unpack_from(Buffer[2:])) # # Doesn't support compress. # if BmpHeader.biCompression !=3D 0: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "The compress BMP f= ile %s is not support." % File.Path) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "The compress BMP file %s is not support." % File.= Path) =20 # The Width and Height is UINT16 type in Image Package if BmpHeader.biWidth > 0xFFFF: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "The BMP file %s Wi= dth is exceed 0xFFFF." % File.Path) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "The BMP file %s Width is exceed 0xFFFF." % File.P= ath) if BmpHeader.biHeight > 0xFFFF: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "The BMP file %s He= ight is exceed 0xFFFF." % File.Path) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "The BMP file %s Height is exceed 0xFFFF." % File.= Path) =20 PaletteBuffer =3D pack('x') if BmpHeader.biBitCount =3D=3D 1: @@ -1906,7 +2131,8 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Trans= Parent): ImageBuffer +=3D pack('B', PaletteIndex) Width =3D (BmpHeader.biWidth + 7)//8 if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2: - PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : Bm= pHeader.bfOffBits] + PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + + 2: BmpHeader.bfOffBits] elif BmpHeader.biBitCount =3D=3D 4: if TransParent: ImageBuffer =3D pack('B', EFI_HII_IIBT_IMAGE_4BIT_TRANS) @@ -1915,7 +2141,8 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Trans= Parent): ImageBuffer +=3D pack('B', PaletteIndex) Width =3D (BmpHeader.biWidth + 1)//2 if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2: - PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : Bm= pHeader.bfOffBits] + PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + + 2: BmpHeader.bfOffBits] elif BmpHeader.biBitCount =3D=3D 8: if TransParent: ImageBuffer =3D pack('B', EFI_HII_IIBT_IMAGE_8BIT_TRANS) @@ -1924,7 +2151,8 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Trans= Parent): ImageBuffer +=3D pack('B', PaletteIndex) Width =3D BmpHeader.biWidth if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2: - PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : Bm= pHeader.bfOffBits] + PaletteBuffer =3D Buffer[BMP_IMAGE_HEADER_STRUCT.size + + 2: BmpHeader.bfOffBits] elif BmpHeader.biBitCount =3D=3D 24: if TransParent: ImageBuffer =3D pack('B', EFI_HII_IIBT_IMAGE_24BIT_TRANS) @@ -1932,7 +2160,8 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Trans= Parent): ImageBuffer =3D pack('B', EFI_HII_IIBT_IMAGE_24BIT) Width =3D BmpHeader.biWidth * 3 else: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "Only support the 1= bit, 4 bit, 8bit, 24 bit BMP files.", ExtraData=3D"[%s]" % str(File.Path)) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "Only support the 1 bit, 4 bit, 8bit, 24 bit BMP f= iles.", ExtraData=3D"[%s]" % str(File.Path)) =20 ImageBuffer +=3D pack('H', BmpHeader.biWidth) ImageBuffer +=3D pack('H', BmpHeader.biHeight) @@ -1943,7 +2172,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Trans= Parent): Start =3D End + (Width % 4) - 4 - Width else: Start =3D End - Width - ImageBuffer +=3D Buffer[Start + 1 : Start + Width + 1] + ImageBuffer +=3D Buffer[Start + 1: Start + Width + 1] End =3D Start =20 # handle the Palette info, BMP use 4 bytes for R, G, B and Reserved i= nfo while EFI_HII_RGB_PIXEL only have the R, G, B info @@ -1956,22 +2185,26 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, Tra= nsParent): PaletteBuffer =3D PaletteTemp[1:] return ImageBuffer, PaletteBuffer =20 -## Create common code +# Create common code # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateHeaderCode(Info, AutoGenC, AutoGenH): # file header - AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'})) + AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName': 'AutoGen.h'}= )) # header file Prologue - AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Gu= id':Info.Guid.replace('-', '_')})) + AutoGenH.Append(gAutoGenHPrologueString.Replace( + {'File': 'AUTOGENH', 'Guid': Info.Guid.replace('-', '_')})) AutoGenH.Append(gAutoGenHCppPrologueString) =20 # header files includes if Info.ModuleType in gModuleTypeHeaderFile: - AutoGenH.Append("#include <%s>\n" % gModuleTypeHeaderFile[Info.Mod= uleType][0]) + AutoGenH.Append("#include <%s>\n" % + gModuleTypeHeaderFile[Info.ModuleType][0]) # # if either PcdLib in [LibraryClasses] sections or there exist Pcd sec= tion, add PcdLib.h # As if modules only uses FixedPcd, then PcdLib is not needed in [Libr= aryClasses] section. @@ -1986,13 +2219,15 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary: return =20 - AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n %s\n" % GuidStringTo= GuidStructureString(Info.Guid)) - AutoGenH.Append("#define EDKII_DSC_PLATFORM_GUID \\\n %s\n" % GuidStr= ingToGuidStructureString(Info.PlatformInfo.Guid)) + AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n %s\n" % + GuidStringToGuidStructureString(Info.Guid)) + AutoGenH.Append("#define EDKII_DSC_PLATFORM_GUID \\\n %s\n" % + GuidStringToGuidStructureString(Info.PlatformInfo.Guid= )) =20 if Info.IsLibrary: return # C file header - AutoGenC.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.c'})) + AutoGenC.Append(gAutoGenHeaderString.Replace({'FileName': 'AutoGen.c'}= )) # C file header files includes if Info.ModuleType in gModuleTypeHeaderFile: for Inc in gModuleTypeHeaderFile[Info.ModuleType]: @@ -2003,20 +2238,25 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): # # Publish the CallerId Guid # - AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid= =3D %s;\n' % GuidStringToGuidStructureString(Info.Guid)) - AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEdkiiDscPlatfor= mGuid =3D %s;\n' % GuidStringToGuidStructureString(Info.PlatformInfo.Guid)) - AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gEfiCallerBase= Name =3D "%s";\n' % Info.Name) + AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid= =3D %s;\n' % + GuidStringToGuidStructureString(Info.Guid)) + AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEdkiiDscPlatfor= mGuid =3D %s;\n' % + GuidStringToGuidStructureString(Info.PlatformInfo.Guid= )) + AutoGenC.Append( + '\nGLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *gEfiCallerBaseName =3D "%s= ";\n' % Info.Name) =20 -## Create common code for header file +# Create common code for header file # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # + + def CreateFooterCode(Info, AutoGenC, AutoGenH): AutoGenH.Append(gAutoGenHEpilogueString) =20 -## Create code for a module +# Create code for a module # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code @@ -2028,6 +2268,8 @@ def CreateFooterCode(Info, AutoGenC, AutoGenH): # @param IdfGenCFlag IdfString is generated into AutoGen C file= when it is set to True # @param IdfGenBinBuffer Buffer to store Idf string package data # + + def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBu= ffer, StringIdf, IdfGenCFlag, IdfGenBinBuffer): CreateHeaderCode(Info, AutoGenC, AutoGenH) =20 @@ -2042,25 +2284,34 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, U= niGenCFlag, UniGenBinBuffer, =20 if Info.UnicodeFileList: FileName =3D "%sStrDefs.h" % Info.Name - StringH.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) - StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', = 'Guid':Info.Guid.replace('-', '_')})) - CreateUnicodeStringCode(Info, AutoGenC, StringH, UniGenCFlag, UniG= enBinBuffer) + StringH.Append(gAutoGenHeaderString.Replace({'FileName': FileName}= )) + StringH.Append(gAutoGenHPrologueString.Replace( + {'File': 'STRDEFS', 'Guid': Info.Guid.replace('-', '_')})) + CreateUnicodeStringCode(Info, AutoGenC, StringH, + UniGenCFlag, UniGenBinBuffer) =20 GuidMacros =3D [] for Guid in Info.Module.Guids: if Guid in Info.Module.GetGuidsUsedByPcd(): continue - GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[G= uid])) + GuidMacros.append('#define %s %s' % + (Guid, Info.Module.Guids[Guid])) for Guid, Value in list(Info.Module.Protocols.items()) + list(Info= .Module.Ppis.items()): GuidMacros.append('#define %s %s' % (Guid, Value)) # supports FixedAtBuild and FeaturePcd usage in VFR file if Info.VfrFileList and Info.ModulePcdList: - GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenNam= e)', '_PCD_VALUE_##TokenName')) - GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)'= , '_PCD_VALUE_##TokenName')) - GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)= ', '_PCD_VALUE_##TokenName')) - GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)= ', '_PCD_VALUE_##TokenName')) - GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)= ', '_PCD_VALUE_##TokenName')) - GuidMacros.append('#define %s %s' % ('FeaturePcdGet(TokenName)= ', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FixedPcdGet16(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FixedPcdGet32(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FixedPcdGet64(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ( + 'FeaturePcdGet(TokenName)', '_PCD_VALUE_##TokenName')) for Pcd in Info.ModulePcdList: if Pcd.Type in [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_FEATURE_= FLAG]: TokenCName =3D Pcd.TokenCName @@ -2075,29 +2326,33 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, U= niGenCFlag, UniGenBinBuffer, if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in Gl= obalData.MixedPcd[PcdItem]: TokenCName =3D PcdItem[0] break - GuidMacros.append('#define %s %s' % ('_PCD_VALUE_'+Tok= enCName, Value)) + GuidMacros.append('#define %s %s' % + ('_PCD_VALUE_'+TokenCName, Value)) =20 if Info.IdfFileList: GuidMacros.append('#include "%sImgDefs.h"' % Info.Name) =20 if GuidMacros: - StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join= (GuidMacros)) + StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % + '\n'.join(GuidMacros)) =20 StringH.Append("\n#endif\n") AutoGenH.Append('#include "%s"\n' % FileName) =20 if Info.IdfFileList: FileName =3D "%sImgDefs.h" % Info.Name - StringIdf.Append(gAutoGenHeaderString.Replace({'FileName':FileName= })) - StringIdf.Append(gAutoGenHPrologueString.Replace({'File':'IMAGEDEF= S', 'Guid':Info.Guid.replace('-', '_')})) - CreateIdfFileCode(Info, AutoGenC, StringIdf, IdfGenCFlag, IdfGenBi= nBuffer) + StringIdf.Append(gAutoGenHeaderString.Replace({'FileName': FileNam= e})) + StringIdf.Append(gAutoGenHPrologueString.Replace( + {'File': 'IMAGEDEFS', 'Guid': Info.Guid.replace('-', '_')})) + CreateIdfFileCode(Info, AutoGenC, StringIdf, + IdfGenCFlag, IdfGenBinBuffer) =20 StringIdf.Append("\n#endif\n") AutoGenH.Append('#include "%s"\n' % FileName) =20 CreateFooterCode(Info, AutoGenC, AutoGenH) =20 -## Create the code file +# Create the code file # # @param FilePath The path of code file # @param Content The content of code file @@ -2106,6 +2361,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, Uni= GenCFlag, UniGenBinBuffer, # @retval True If file content is changed or file doesn't exi= st # @retval False If the file exists and the content is not chan= ged # + + def Generate(FilePath, Content, IsBinaryFile): return SaveFileOnChange(FilePath, Content, IsBinaryFile) - diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source= /Python/AutoGen/GenDepex.py index f2f2e9d65b5f..31be6e897cb9 100644 --- a/BaseTools/Source/Python/AutoGen/GenDepex.py +++ b/BaseTools/Source/Python/AutoGen/GenDepex.py @@ -1,10 +1,10 @@ -## @file +# @file # This file is used to generate DEPEX file for module's dependency express= ion # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent =20 -## Import Modules +# Import Modules # import sys import Common.LongFilePathOs as os @@ -22,113 +22,120 @@ from Common import EdkLogger as EdkLogger from Common.BuildVersion import gBUILD_VERSION from Common.DataType import * =20 -## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END" +# Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END" gStartClosePattern =3D re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*"= , re.S) =20 -## Mapping between module type and EFI phase +# Mapping between module type and EFI phase gType2Phase =3D { - SUP_MODULE_BASE : None, - SUP_MODULE_SEC : "PEI", - SUP_MODULE_PEI_CORE : "PEI", - SUP_MODULE_PEIM : "PEI", - SUP_MODULE_DXE_CORE : "DXE", - SUP_MODULE_DXE_DRIVER : "DXE", - SUP_MODULE_DXE_SMM_DRIVER : "DXE", + SUP_MODULE_BASE: None, + SUP_MODULE_SEC: "PEI", + SUP_MODULE_PEI_CORE: "PEI", + SUP_MODULE_PEIM: "PEI", + SUP_MODULE_DXE_CORE: "DXE", + SUP_MODULE_DXE_DRIVER: "DXE", + SUP_MODULE_DXE_SMM_DRIVER: "DXE", SUP_MODULE_DXE_RUNTIME_DRIVER: "DXE", - SUP_MODULE_DXE_SAL_DRIVER : "DXE", - SUP_MODULE_UEFI_DRIVER : "DXE", - SUP_MODULE_UEFI_APPLICATION : "DXE", - SUP_MODULE_SMM_CORE : "DXE", - SUP_MODULE_MM_STANDALONE : "MM", - SUP_MODULE_MM_CORE_STANDALONE : "MM", + SUP_MODULE_DXE_SAL_DRIVER: "DXE", + SUP_MODULE_UEFI_DRIVER: "DXE", + SUP_MODULE_UEFI_APPLICATION: "DXE", + SUP_MODULE_SMM_CORE: "DXE", + SUP_MODULE_MM_STANDALONE: "MM", + SUP_MODULE_MM_CORE_STANDALONE: "MM", } =20 -## Convert dependency expression string into EFI internal representation +# Convert dependency expression string into EFI internal representation # # DependencyExpression class is used to parse dependency expression stri= ng and # convert it into its binary form. # + + class DependencyExpression: =20 ArchProtocols =3D { - '665e3ff6-46cc-11d4-9a38-0090273fc14d', # 'g= EfiBdsArchProtocolGuid' - '26baccb1-6f42-11d4-bce7-0080c73c8881', # 'g= EfiCpuArchProtocolGuid' - '26baccb2-6f42-11d4-bce7-0080c73c8881', # 'g= EfiMetronomeArchProtocolGuid' - '1da97072-bddc-4b30-99f1-72a0b56fff2a', # 'g= EfiMonotonicCounterArchProtocolGuid' - '27cfac87-46cc-11d4-9a38-0090273fc14d', # 'g= EfiRealTimeClockArchProtocolGuid' - '27cfac88-46cc-11d4-9a38-0090273fc14d', # 'g= EfiResetArchProtocolGuid' - 'b7dfb4e1-052f-449f-87be-9818fc91b733', # 'g= EfiRuntimeArchProtocolGuid' - 'a46423e3-4617-49f1-b9ff-d1bfa9115839', # 'g= EfiSecurityArchProtocolGuid' - '26baccb3-6f42-11d4-bce7-0080c73c8881', # 'g= EfiTimerArchProtocolGuid' - '6441f818-6362-4e44-b570-7dba31dd2453', # 'g= EfiVariableWriteArchProtocolGuid' - '1e5668e2-8481-11d4-bcf1-0080c73c8881', # 'g= EfiVariableArchProtocolGuid' - '665e3ff5-46cc-11d4-9a38-0090273fc14d' # 'g= EfiWatchdogTimerArchProtocolGuid' - } + '665e3ff6-46cc-11d4-9a38-0090273fc14d', # 'gEfiBdsArchProtocolGui= d' + '26baccb1-6f42-11d4-bce7-0080c73c8881', # 'gEfiCpuArchProtocolGui= d' + '26baccb2-6f42-11d4-bce7-0080c73c8881', # 'gEfiMetronomeArchProto= colGuid' + # 'gEfiMonotonicCounterArchProtocolGuid' + '1da97072-bddc-4b30-99f1-72a0b56fff2a', + '27cfac87-46cc-11d4-9a38-0090273fc14d', # 'gEfiRealTimeClockArchP= rotocolGuid' + '27cfac88-46cc-11d4-9a38-0090273fc14d', # 'gEfiResetArchProtocolG= uid' + 'b7dfb4e1-052f-449f-87be-9818fc91b733', # 'gEfiRuntimeArchProtoco= lGuid' + 'a46423e3-4617-49f1-b9ff-d1bfa9115839', # 'gEfiSecurityArchProtoc= olGuid' + '26baccb3-6f42-11d4-bce7-0080c73c8881', # 'gEfiTimerArchProtocolG= uid' + '6441f818-6362-4e44-b570-7dba31dd2453', # 'gEfiVariableWriteArchP= rotocolGuid' + '1e5668e2-8481-11d4-bcf1-0080c73c8881', # 'gEfiVariableArchProtoc= olGuid' + '665e3ff5-46cc-11d4-9a38-0090273fc14d' # 'gEfiWatchdogTimerArchPr= otocolGuid' + } =20 OpcodePriority =3D { - DEPEX_OPCODE_AND : 1, - DEPEX_OPCODE_OR : 1, - DEPEX_OPCODE_NOT : 2, + DEPEX_OPCODE_AND: 1, + DEPEX_OPCODE_OR: 1, + DEPEX_OPCODE_NOT: 2, } =20 Opcode =3D { - "PEI" : { - DEPEX_OPCODE_PUSH : 0x02, - DEPEX_OPCODE_AND : 0x03, - DEPEX_OPCODE_OR : 0x04, - DEPEX_OPCODE_NOT : 0x05, - DEPEX_OPCODE_TRUE : 0x06, - DEPEX_OPCODE_FALSE : 0x07, - DEPEX_OPCODE_END : 0x08 + "PEI": { + DEPEX_OPCODE_PUSH: 0x02, + DEPEX_OPCODE_AND: 0x03, + DEPEX_OPCODE_OR: 0x04, + DEPEX_OPCODE_NOT: 0x05, + DEPEX_OPCODE_TRUE: 0x06, + DEPEX_OPCODE_FALSE: 0x07, + DEPEX_OPCODE_END: 0x08 }, =20 - "DXE" : { + "DXE": { DEPEX_OPCODE_BEFORE: 0x00, - DEPEX_OPCODE_AFTER : 0x01, - DEPEX_OPCODE_PUSH : 0x02, - DEPEX_OPCODE_AND : 0x03, - DEPEX_OPCODE_OR : 0x04, - DEPEX_OPCODE_NOT : 0x05, - DEPEX_OPCODE_TRUE : 0x06, - DEPEX_OPCODE_FALSE : 0x07, - DEPEX_OPCODE_END : 0x08, - DEPEX_OPCODE_SOR : 0x09 + DEPEX_OPCODE_AFTER: 0x01, + DEPEX_OPCODE_PUSH: 0x02, + DEPEX_OPCODE_AND: 0x03, + DEPEX_OPCODE_OR: 0x04, + DEPEX_OPCODE_NOT: 0x05, + DEPEX_OPCODE_TRUE: 0x06, + DEPEX_OPCODE_FALSE: 0x07, + DEPEX_OPCODE_END: 0x08, + DEPEX_OPCODE_SOR: 0x09 }, =20 - "MM" : { + "MM": { DEPEX_OPCODE_BEFORE: 0x00, - DEPEX_OPCODE_AFTER : 0x01, - DEPEX_OPCODE_PUSH : 0x02, - DEPEX_OPCODE_AND : 0x03, - DEPEX_OPCODE_OR : 0x04, - DEPEX_OPCODE_NOT : 0x05, - DEPEX_OPCODE_TRUE : 0x06, - DEPEX_OPCODE_FALSE : 0x07, - DEPEX_OPCODE_END : 0x08, - DEPEX_OPCODE_SOR : 0x09 + DEPEX_OPCODE_AFTER: 0x01, + DEPEX_OPCODE_PUSH: 0x02, + DEPEX_OPCODE_AND: 0x03, + DEPEX_OPCODE_OR: 0x04, + DEPEX_OPCODE_NOT: 0x05, + DEPEX_OPCODE_TRUE: 0x06, + DEPEX_OPCODE_FALSE: 0x07, + DEPEX_OPCODE_END: 0x08, + DEPEX_OPCODE_SOR: 0x09 } } =20 # all supported op codes and operands - SupportedOpcode =3D [DEPEX_OPCODE_BEFORE, DEPEX_OPCODE_AFTER, DEPEX_OP= CODE_PUSH, DEPEX_OPCODE_AND, DEPEX_OPCODE_OR, DEPEX_OPCODE_NOT, DEPEX_OPCOD= E_END, DEPEX_OPCODE_SOR] + SupportedOpcode =3D [DEPEX_OPCODE_BEFORE, DEPEX_OPCODE_AFTER, DEPEX_OP= CODE_PUSH, + DEPEX_OPCODE_AND, DEPEX_OPCODE_OR, DEPEX_OPCODE_NOT= , DEPEX_OPCODE_END, DEPEX_OPCODE_SOR] SupportedOperand =3D [DEPEX_OPCODE_TRUE, DEPEX_OPCODE_FALSE] =20 - OpcodeWithSingleOperand =3D [DEPEX_OPCODE_NOT, DEPEX_OPCODE_BEFORE, DE= PEX_OPCODE_AFTER] + OpcodeWithSingleOperand =3D [DEPEX_OPCODE_NOT, + DEPEX_OPCODE_BEFORE, DEPEX_OPCODE_AFTER] OpcodeWithTwoOperand =3D [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR] =20 # op code that should not be the last one - NonEndingOpcode =3D [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR, DEPEX_OPCODE_N= OT, DEPEX_OPCODE_SOR] + NonEndingOpcode =3D [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR, + DEPEX_OPCODE_NOT, DEPEX_OPCODE_SOR] # op code must not present at the same time ExclusiveOpcode =3D [DEPEX_OPCODE_BEFORE, DEPEX_OPCODE_AFTER] # op code that should be the first one if it presents - AboveAllOpcode =3D [DEPEX_OPCODE_SOR, DEPEX_OPCODE_BEFORE, DEPEX_OPCOD= E_AFTER] + AboveAllOpcode =3D [DEPEX_OPCODE_SOR, + DEPEX_OPCODE_BEFORE, DEPEX_OPCODE_AFTER] =20 # # open and close brace must be taken as individual tokens # TokenPattern =3D re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)") =20 - ## Constructor + # Constructor # # @param Expression The list or string of dependency expression # @param ModuleType The type of the module using the dependency ex= pression @@ -152,7 +159,8 @@ class DependencyExpression: EdkLogger.debug(EdkLogger.DEBUG_8, repr(self)) if Optimize: self.Optimize() - EdkLogger.debug(EdkLogger.DEBUG_8, "\n Optimized: " + repr(= self)) + EdkLogger.debug(EdkLogger.DEBUG_8, + "\n Optimized: " + repr(self)) =20 def __str__(self): return " ".join(self.TokenList) @@ -166,11 +174,11 @@ class DependencyExpression: WellForm +=3D ' ' + Token return WellForm =20 - ## Split the expression string into token list + # Split the expression string into token list def GetExpressionTokenList(self): self.TokenList =3D self.TokenPattern.findall(self.ExpressionString) =20 - ## Convert token list into postfix notation + # Convert token list into postfix notation def GetPostfixNotation(self): Stack =3D [] LastToken =3D '' @@ -198,8 +206,8 @@ class DependencyExpression: EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid= dependency expression: missing operator before NOT", ExtraData=3D"Near %s" % LastToken) elif LastToken in self.SupportedOpcode + ['(', '', None]: - EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid= dependency expression: missing operand before " + Token, - ExtraData=3D"Near %s" % LastToken) + EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dep= endency expression: missing operand before " + Token, + ExtraData=3D"Near %s" % LastToken) =20 while len(Stack) > 0: if Stack[-1] =3D=3D "(" or self.OpcodePriority[Token] = >=3D self.OpcodePriority[Stack[-1]]: @@ -223,7 +231,8 @@ class DependencyExpression: self.OpcodeList.append(Token) else: EdkLogger.error("GenDepex", PARSER_ERROR, - "Opcode=3D%s doesn't supported in %s s= tage " % (Token, self.Phase), + "Opcode=3D%s doesn't supported in %s s= tage " % ( + Token, self.Phase), ExtraData=3Dstr(self)) self.PostfixNotation.append(Token) LastToken =3D Token @@ -237,7 +246,7 @@ class DependencyExpression: if self.PostfixNotation[-1] !=3D DEPEX_OPCODE_END: self.PostfixNotation.append(DEPEX_OPCODE_END) =20 - ## Validate the dependency expression + # Validate the dependency expression def ValidateOpcode(self): for Op in self.AboveAllOpcode: if Op in self.PostfixNotation: @@ -265,14 +274,14 @@ class DependencyExpression: EdkLogger.error("GenDepex", PARSER_ERROR, "Extra expressions a= fter END", ExtraData=3Dstr(self)) =20 - ## Simply optimize the dependency expression by removing duplicated op= erands + # Simply optimize the dependency expression by removing duplicated ope= rands def Optimize(self): OpcodeSet =3D set(self.OpcodeList) # if there are isn't one in the set, return if len(OpcodeSet) !=3D 1: - return + return Op =3D OpcodeSet.pop() - #if Op isn't either OR or AND, return + # if Op isn't either OR or AND, return if Op not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]: return NewOperand =3D [] @@ -319,25 +328,29 @@ class DependencyExpression: self.PostfixNotation =3D [] self.GetPostfixNotation() =20 - - ## Convert a GUID value in C structure format into its binary form + # Convert a GUID value in C structure format into its binary form # # @param Guid The GUID value in C structure format # # @retval array The byte array representing the GUID value # + def GetGuidValue(self, Guid): - GuidValueString =3D Guid.replace("{", "").replace("}", "").replace= (" ", "") + GuidValueString =3D Guid.replace( + "{", "").replace("}", "").replace(" ", "") GuidValueList =3D GuidValueString.split(",") if len(GuidValueList) !=3D 11 and len(GuidValueList) =3D=3D 16: - GuidValueString =3D GuidStringToGuidStructureString(GuidStruct= ureByteArrayToGuidString(Guid)) - GuidValueString =3D GuidValueString.replace("{", "").replace("= }", "").replace(" ", "") + GuidValueString =3D GuidStringToGuidStructureString( + GuidStructureByteArrayToGuidString(Guid)) + GuidValueString =3D GuidValueString.replace( + "{", "").replace("}", "").replace(" ", "") GuidValueList =3D GuidValueString.split(",") if len(GuidValueList) !=3D 11: - EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID value = string or opcode: %s" % Guid) + EdkLogger.error("GenDepex", PARSER_ERROR, + "Invalid GUID value string or opcode: %s" % Gu= id) return pack("1I2H8B", *(int(value, 16) for value in GuidValueList)) =20 - ## Save the binary form of dependency expression in file + # Save the binary form of dependency expression in file # # @param File The path of file. If None is given, put the data o= n console # @@ -354,7 +367,8 @@ class DependencyExpression: Buffer.write(pack("B", self.Opcode[self.Phase][Item])) elif Item in self.SupportedOpcode: EdkLogger.error("GenDepex", FORMAT_INVALID, - "Opcode [%s] is not expected in %s phase" = % (Item, self.Phase), + "Opcode [%s] is not expected in %s phase" = % ( + Item, self.Phase), ExtraData=3Dself.ExpressionString) else: Buffer.write(self.GetGuidValue(Item)) @@ -370,19 +384,23 @@ class DependencyExpression: Buffer.close() return FileChangeFlag =20 + versionNumber =3D ("0.04" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + versionNumber __copyright__ =3D "Copyright (c) 2007-2018, Intel Corporation All rights = reserved." __usage__ =3D "%prog [options] [dependency_expression_file]" =20 -## Parse command line options +# Parse command line options # # @retval OptionParser # + + def GetOptions(): from optparse import OptionParser =20 - Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, usage=3D__usage__) + Parser =3D OptionParser(description=3D__copyright__, + version=3D__version__, usage=3D__usage__) =20 Parser.add_option("-o", "--output", dest=3D"OutputFile", default=3DNon= e, metavar=3D"FILE", help=3D"Specify the name of depex file to be generat= ed") @@ -394,14 +412,15 @@ def GetOptions(): help=3D"Do some simple optimization on the expressio= n.") Parser.add_option("-v", "--verbose", dest=3D"verbose", default=3DFalse= , action=3D"store_true", help=3D"build with verbose information") - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", hel= p=3D"Enable debug messages at specified level.") + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + help=3D"Enable debug messages at specified level.") Parser.add_option("-q", "--quiet", dest=3D"quiet", default=3DFalse, ac= tion=3D"store_true", help=3D"build with little information") =20 return Parser.parse_args() =20 =20 -## Entrance method +# Entrance method # # @retval 0 Tool was successful # @retval 1 Tool failed @@ -422,12 +441,14 @@ def Main(): =20 try: if Option.ModuleType is None or Option.ModuleType not in gType2Pha= se: - EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is no= t specified or supported") + EdkLogger.error("GenDepex", OPTION_MISSING, + "Module type is not specified or supported") =20 DxsFile =3D '' if len(Input) > 0 and Option.Expression =3D=3D "": DxsFile =3D Input[0] - DxsString =3D open(DxsFile, 'r').read().replace("\n", " ").rep= lace("\r", " ") + DxsString =3D open(DxsFile, 'r').read().replace( + "\n", " ").replace("\r", " ") DxsString =3D gStartClosePattern.sub("\\1", DxsString) elif Option.Expression !=3D "": if Option.Expression[0] =3D=3D '"': @@ -435,9 +456,11 @@ def Main(): else: DxsString =3D Option.Expression else: - EdkLogger.error("GenDepex", OPTION_MISSING, "No expression str= ing or file given") + EdkLogger.error("GenDepex", OPTION_MISSING, + "No expression string or file given") =20 - Dpx =3D DependencyExpression(DxsString, Option.ModuleType, Option.= Optimize) + Dpx =3D DependencyExpression( + DxsString, Option.ModuleType, Option.Optimize) if Option.OutputFile is not None: FileChangeFlag =3D Dpx.Generate(Option.OutputFile) if not FileChangeFlag and DxsFile: @@ -459,6 +482,6 @@ def Main(): =20 return 0 =20 + if __name__ =3D=3D '__main__': sys.exit(Main()) - diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index daec9c6d54b2..acbc3056d918 100755 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1,4 +1,4 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
        @@ -6,7 +6,7 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # from __future__ import absolute_import import Common.LongFilePathOs as os @@ -24,33 +24,34 @@ import Common.GlobalData as GlobalData from collections import OrderedDict from Common.DataType import TAB_COMPILER_MSFT =20 -## Regular expression for finding header file inclusions -gIncludePattern =3D re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?= :\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)= ?)", re.MULTILINE | re.UNICODE | re.IGNORECASE) +# Regular expression for finding header file inclusions +gIncludePattern =3D re.compile( + r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(= ?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNIC= ODE | re.IGNORECASE) =20 -## Regular expression for matching macro used in header file inclusion +# Regular expression for matching macro used in header file inclusion gMacroPattern =3D re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICOD= E) =20 gIsFileMap =3D {} =20 -## pattern for include style in Edk.x code +# pattern for include style in Edk.x code gProtocolDefinition =3D "Protocol/%(HeaderKey)s/%(HeaderKey)s.h" gGuidDefinition =3D "Guid/%(HeaderKey)s/%(HeaderKey)s.h" gArchProtocolDefinition =3D "ArchProtocol/%(HeaderKey)s/%(HeaderKey)s.h" gPpiDefinition =3D "Ppi/%(HeaderKey)s/%(HeaderKey)s.h" gIncludeMacroConversion =3D { - "EFI_PROTOCOL_DEFINITION" : gProtocolDefinition, - "EFI_GUID_DEFINITION" : gGuidDefinition, - "EFI_ARCH_PROTOCOL_DEFINITION" : gArchProtocolDefinition, - "EFI_PROTOCOL_PRODUCER" : gProtocolDefinition, - "EFI_PROTOCOL_CONSUMER" : gProtocolDefinition, - "EFI_PROTOCOL_DEPENDENCY" : gProtocolDefinition, - "EFI_ARCH_PROTOCOL_PRODUCER" : gArchProtocolDefinition, - "EFI_ARCH_PROTOCOL_CONSUMER" : gArchProtocolDefinition, - "EFI_ARCH_PROTOCOL_DEPENDENCY" : gArchProtocolDefinition, - "EFI_PPI_DEFINITION" : gPpiDefinition, - "EFI_PPI_PRODUCER" : gPpiDefinition, - "EFI_PPI_CONSUMER" : gPpiDefinition, - "EFI_PPI_DEPENDENCY" : gPpiDefinition, + "EFI_PROTOCOL_DEFINITION": gProtocolDefinition, + "EFI_GUID_DEFINITION": gGuidDefinition, + "EFI_ARCH_PROTOCOL_DEFINITION": gArchProtocolDefinition, + "EFI_PROTOCOL_PRODUCER": gProtocolDefinition, + "EFI_PROTOCOL_CONSUMER": gProtocolDefinition, + "EFI_PROTOCOL_DEPENDENCY": gProtocolDefinition, + "EFI_ARCH_PROTOCOL_PRODUCER": gArchProtocolDefinition, + "EFI_ARCH_PROTOCOL_CONSUMER": gArchProtocolDefinition, + "EFI_ARCH_PROTOCOL_DEPENDENCY": gArchProtocolDefinition, + "EFI_PPI_DEFINITION": gPpiDefinition, + "EFI_PPI_PRODUCER": gPpiDefinition, + "EFI_PPI_CONSUMER": gPpiDefinition, + "EFI_PPI_DEPENDENCY": gPpiDefinition, } =20 NMAKE_FILETYPE =3D "nmake" @@ -58,21 +59,23 @@ GMAKE_FILETYPE =3D "gmake" WIN32_PLATFORM =3D "win32" POSIX_PLATFORM =3D "posix" =20 -## BuildFile class +# BuildFile class # # This base class encapsules build file and its generation. It uses templ= ate to generate # the content of build file. The content of build file will be got from A= utoGen objects. # + + class BuildFile(object): - ## template used to generate the build file (i.e. makefile if using ma= ke) + # template used to generate the build file (i.e. makefile if using mak= e) _TEMPLATE_ =3D TemplateString('') =20 _DEFAULT_FILE_NAME_ =3D "Makefile" =20 - ## default file name for each type of build file + # default file name for each type of build file _FILE_NAME_ =3D { - NMAKE_FILETYPE : "Makefile", - GMAKE_FILETYPE : "GNUmakefile" + NMAKE_FILETYPE: "Makefile", + GMAKE_FILETYPE: "GNUmakefile" } =20 # Get Makefile name. @@ -82,7 +85,7 @@ class BuildFile(object): else: return self._FILE_NAME_[self._FileType] =20 - ## Fixed header string for makefile + # Fixed header string for makefile _MAKEFILE_HEADER =3D '''# # DO NOT EDIT # This file is auto-generated by build utility @@ -97,13 +100,13 @@ class BuildFile(object): # ''' =20 - ## Header string for each type of build file + # Header string for each type of build file _FILE_HEADER_ =3D { - NMAKE_FILETYPE : _MAKEFILE_HEADER % _FILE_NAME_[NMAKE_FILETYPE], - GMAKE_FILETYPE : _MAKEFILE_HEADER % _FILE_NAME_[GMAKE_FILETYPE] + NMAKE_FILETYPE: _MAKEFILE_HEADER % _FILE_NAME_[NMAKE_FILETYPE], + GMAKE_FILETYPE: _MAKEFILE_HEADER % _FILE_NAME_[GMAKE_FILETYPE] } =20 - ## shell commands which can be used in build file in the form of macro + # shell commands which can be used in build file in the form of macro # $(CP) copy file command # $(MV) move file command # $(RM) remove file command @@ -111,64 +114,65 @@ class BuildFile(object): # $(RD) remove dir command # _SHELL_CMD_ =3D { - WIN32_PLATFORM : { - "CP" : "copy /y", - "MV" : "move /y", - "RM" : "del /f /q", - "MD" : "mkdir", - "RD" : "rmdir /s /q", + WIN32_PLATFORM: { + "CP": "copy /y", + "MV": "move /y", + "RM": "del /f /q", + "MD": "mkdir", + "RD": "rmdir /s /q", }, =20 - POSIX_PLATFORM : { - "CP" : "cp -p -f", - "MV" : "mv -f", - "RM" : "rm -f", - "MD" : "mkdir -p", - "RD" : "rm -r -f", + POSIX_PLATFORM: { + "CP": "cp -p -f", + "MV": "mv -f", + "RM": "rm -f", + "MD": "mkdir -p", + "RD": "rm -r -f", } } =20 - ## directory separator + # directory separator _SEP_ =3D { - WIN32_PLATFORM : "\\", - POSIX_PLATFORM : "/" + WIN32_PLATFORM: "\\", + POSIX_PLATFORM: "/" } =20 - ## directory creation template + # directory creation template _MD_TEMPLATE_ =3D { - WIN32_PLATFORM : 'if not exist %(dir)s $(MD) %(dir)s', - POSIX_PLATFORM : "$(MD) %(dir)s" + WIN32_PLATFORM: 'if not exist %(dir)s $(MD) %(dir)s', + POSIX_PLATFORM: "$(MD) %(dir)s" } =20 - ## directory removal template + # directory removal template _RD_TEMPLATE_ =3D { - WIN32_PLATFORM : 'if exist %(dir)s $(RD) %(dir)s', - POSIX_PLATFORM : "$(RD) %(dir)s" + WIN32_PLATFORM: 'if exist %(dir)s $(RD) %(dir)s', + POSIX_PLATFORM: "$(RD) %(dir)s" } - ## cp if exist + # cp if exist _CP_TEMPLATE_ =3D { - WIN32_PLATFORM : 'if exist %(Src)s $(CP) %(Src)s %(Dst)s', - POSIX_PLATFORM : "test -f %(Src)s && $(CP) %(Src)s %(Dst)s" + WIN32_PLATFORM: 'if exist %(Src)s $(CP) %(Src)s %(Dst)s', + POSIX_PLATFORM: "test -f %(Src)s && $(CP) %(Src)s %(Dst)s" } =20 _CD_TEMPLATE_ =3D { - WIN32_PLATFORM : 'if exist %(dir)s cd %(dir)s', - POSIX_PLATFORM : "test -e %(dir)s && cd %(dir)s" + WIN32_PLATFORM: 'if exist %(dir)s cd %(dir)s', + POSIX_PLATFORM: "test -e %(dir)s && cd %(dir)s" } =20 _MAKE_TEMPLATE_ =3D { - WIN32_PLATFORM : 'if exist %(file)s "$(MAKE)" $(MAKE_FLAGS) -f %= (file)s', - POSIX_PLATFORM : 'test -e %(file)s && "$(MAKE)" $(MAKE_FLAGS) -f= %(file)s' + WIN32_PLATFORM: 'if exist %(file)s "$(MAKE)" $(MAKE_FLAGS) -f %(= file)s', + POSIX_PLATFORM: 'test -e %(file)s && "$(MAKE)" $(MAKE_FLAGS) -f = %(file)s' } =20 _INCLUDE_CMD_ =3D { - NMAKE_FILETYPE : '!INCLUDE', - GMAKE_FILETYPE : "include" + NMAKE_FILETYPE: '!INCLUDE', + GMAKE_FILETYPE: "include" } =20 - _INC_FLAG_ =3D {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I"= , "NASM" : "-I"} + _INC_FLAG_ =3D {TAB_COMPILER_MSFT: "/I", + "GCC": "-I", "INTEL": "-I", "NASM": "-I"} =20 - ## Constructor of BuildFile + # Constructor of BuildFile # # @param AutoGenObject Object of AutoGen class # @@ -188,7 +192,7 @@ class BuildFile(object): else: self._Platform =3D POSIX_PLATFORM =20 - ## Create build file. + # Create build file. # # Only nmake and gmake are supported. # @@ -199,33 +203,33 @@ class BuildFile(object): FileContent =3D self._TEMPLATE_.Replace(self._TemplateDict) FileName =3D self.getMakefileName() if not os.path.exists(os.path.join(self._AutoGenObject.MakeFileDir= , "deps.txt")): - with open(os.path.join(self._AutoGenObject.MakeFileDir, "deps.= txt"),"w+") as fd: + with open(os.path.join(self._AutoGenObject.MakeFileDir, "deps.= txt"), "w+") as fd: fd.write("") if not os.path.exists(os.path.join(self._AutoGenObject.MakeFileDir= , "dependency")): - with open(os.path.join(self._AutoGenObject.MakeFileDir, "depen= dency"),"w+") as fd: + with open(os.path.join(self._AutoGenObject.MakeFileDir, "depen= dency"), "w+") as fd: fd.write("") if not os.path.exists(os.path.join(self._AutoGenObject.MakeFileDir= , "deps_target")): - with open(os.path.join(self._AutoGenObject.MakeFileDir, "deps_= target"),"w+") as fd: + with open(os.path.join(self._AutoGenObject.MakeFileDir, "deps_= target"), "w+") as fd: fd.write("") return SaveFileOnChange(os.path.join(self._AutoGenObject.MakeFileD= ir, FileName), FileContent, False) =20 - ## Return a list of directory creation command string + # Return a list of directory creation command string # # @param DirList The list of directory to be created # # @retval list The directory creation command list # def GetCreateDirectoryCommand(self, DirList): - return [self._MD_TEMPLATE_[self._Platform] % {'dir':Dir} for Dir i= n DirList] + return [self._MD_TEMPLATE_[self._Platform] % {'dir': Dir} for Dir = in DirList] =20 - ## Return a list of directory removal command string + # Return a list of directory removal command string # # @param DirList The list of directory to be removed # # @retval list The directory removal command list # def GetRemoveDirectoryCommand(self, DirList): - return [self._RD_TEMPLATE_[self._Platform] % {'dir':Dir} for Dir i= n DirList] + return [self._RD_TEMPLATE_[self._Platform] % {'dir': Dir} for Dir = in DirList] =20 def PlaceMacro(self, Path, MacroDefinitions=3DNone): if Path.startswith("$("): @@ -244,13 +248,15 @@ class BuildFile(object): break return Path =20 -## ModuleMakefile class +# ModuleMakefile class # # This class encapsules makefie and its generation for module. It uses te= mplate to generate # the content of makefile. The content of makefile will be got from Modul= eAutoGen object. # + + class ModuleMakefile(BuildFile): - ## template used to generate the makefile for module + # template used to generate the makefile for module _TEMPLATE_ =3D TemplateString('''\ ${makefile_header} =20 @@ -432,10 +438,12 @@ cleanlib: \t${BEGIN}-@${library_build_command} cleanall \t${END}@cd $(MODULE_BUILD_DIR)\n\n''') =20 - _FILE_MACRO_TEMPLATE =3D TemplateString("${macro_name} =3D ${BEGIN} \\= \n ${source_file}${END}\n") - _BUILD_TARGET_TEMPLATE =3D TemplateString("${BEGIN}${target} : ${deps}= \n${END}\t${cmd}\n") + _FILE_MACRO_TEMPLATE =3D TemplateString( + "${macro_name} =3D ${BEGIN} \\\n ${source_file}${END}\n") + _BUILD_TARGET_TEMPLATE =3D TemplateString( + "${BEGIN}${target} : ${deps}\n${END}\t${cmd}\n") =20 - ## Constructor of ModuleMakefile + # Constructor of ModuleMakefile # # @param ModuleAutoGen Object of ModuleAutoGen class # @@ -460,14 +468,14 @@ cleanlib: self.LibraryBuildDirectoryList =3D [] self.SystemLibraryList =3D [] self.Macros =3D OrderedDict() - self.Macros["OUTPUT_DIR" ] =3D self._AutoGenObject.Macros["OU= TPUT_DIR"] - self.Macros["DEBUG_DIR" ] =3D self._AutoGenObject.Macros["DE= BUG_DIR"] + self.Macros["OUTPUT_DIR"] =3D self._AutoGenObject.Macros["OUTPUT_D= IR"] + self.Macros["DEBUG_DIR"] =3D self._AutoGenObject.Macros["DEBUG_DIR= "] self.Macros["MODULE_BUILD_DIR"] =3D self._AutoGenObject.Macros["MO= DULE_BUILD_DIR"] - self.Macros["BIN_DIR" ] =3D self._AutoGenObject.Macros["BI= N_DIR"] - self.Macros["BUILD_DIR" ] =3D self._AutoGenObject.Macros["BU= ILD_DIR"] - self.Macros["WORKSPACE" ] =3D self._AutoGenObject.Macros["WO= RKSPACE"] - self.Macros["FFS_OUTPUT_DIR" ] =3D self._AutoGenObject.Macros["FF= S_OUTPUT_DIR"] - self.GenFfsList =3D ModuleAutoGen.GenFfsList + self.Macros["BIN_DIR"] =3D self._AutoGenObject.Macros["BIN_DIR"] + self.Macros["BUILD_DIR"] =3D self._AutoGenObject.Macros["BUILD_DIR= "] + self.Macros["WORKSPACE"] =3D self._AutoGenObject.Macros["WORKSPACE= "] + self.Macros["FFS_OUTPUT_DIR"] =3D self._AutoGenObject.Macros["FFS_= OUTPUT_DIR"] + self.GenFfsList =3D ModuleAutoGen.GenFfsList self.MacroList =3D ['FFS_OUTPUT_DIR', 'MODULE_GUID', 'OUTPUT_DIR'] self.FfsOutputFileList =3D [] self.DependencyHeaderFileSet =3D set() @@ -534,7 +542,8 @@ cleanlib: continue # Remove duplicated include path, if any if Attr =3D=3D "FLAGS": - Value =3D RemoveDupOption(Value, IncPrefix, MyAgo.= IncludePathList) + Value =3D RemoveDupOption( + Value, IncPrefix, MyAgo.IncludePathList) if Tool =3D=3D "OPTROM" and PCI_COMPRESS_Flag: ValueList =3D Value.split() if ValueList: @@ -554,7 +563,8 @@ cleanlib: if RespDict: RespFileListContent =3D '' for Resp in RespDict: - RespFile =3D os.path.join(MyAgo.OutputDir, str(Resp).lower= () + '.txt') + RespFile =3D os.path.join( + MyAgo.OutputDir, str(Resp).lower() + '.txt') StrList =3D RespDict[Resp].split(' ') UnexpandMacro =3D [] NewStr =3D [] @@ -566,7 +576,8 @@ cleanlib: UnexpandMacroStr =3D ' '.join(UnexpandMacro) NewRespStr =3D ' '.join(NewStr) SaveFileOnChange(RespFile, NewRespStr, False) - ToolsDef.append("%s =3D %s" % (Resp, UnexpandMacroStr + ' = @' + RespFile)) + ToolsDef.append("%s =3D %s" % + (Resp, UnexpandMacroStr + ' @' + RespFile)) RespFileListContent +=3D '@' + RespFile + TAB_LINE_BREAK RespFileListContent +=3D NewRespStr + TAB_LINE_BREAK SaveFileOnChange(RespFileList, RespFileListContent, False) @@ -584,36 +595,39 @@ cleanlib: self.ParserGenerateFfsCmd() =20 # Generate macros used to represent input files - FileMacroList =3D [] # macro name =3D file list + FileMacroList =3D [] # macro name =3D file list for FileListMacro in self.FileListMacros: FileMacro =3D self._FILE_MACRO_TEMPLATE.Replace( - { - "macro_name" : Fi= leListMacro, - "source_file" : se= lf.FileListMacros[FileListMacro] - } - ) + { + "macro_name": FileListMacro, + "source_file": self.FileListMacros[FileListMacro] + } + ) FileMacroList.append(FileMacro) =20 # INC_LIST is special FileMacro =3D "" IncludePathList =3D [] - for P in MyAgo.IncludePathList: + for P in MyAgo.IncludePathList: IncludePathList.append(IncPrefix + self.PlaceMacro(P, self.Mac= ros)) if FileBuildRule.INC_LIST_MACRO in self.ListFileMacros: - self.ListFileMacros[FileBuildRule.INC_LIST_MACRO].append(I= ncPrefix + P) + self.ListFileMacros[FileBuildRule.INC_LIST_MACRO].append( + IncPrefix + P) FileMacro +=3D self._FILE_MACRO_TEMPLATE.Replace( - { - "macro_name" : "INC", - "source_file" : Includ= ePathList - } - ) + { + "macro_name": "INC", + "source_file": IncludePathList + } + ) FileMacroList.append(FileMacro) # Add support when compiling .nasm source files IncludePathList =3D [] - asmsource =3D [item for item in MyAgo.SourceFileList if item.File.= upper().endswith((".NASM",".ASM",".NASMB","S"))] + asmsource =3D [item for item in MyAgo.SourceFileList if item.File.= upper( + ).endswith((".NASM", ".ASM", ".NASMB", "S"))] if asmsource: - for P in MyAgo.IncludePathList: - IncludePath =3D self._INC_FLAG_['NASM'] + self.PlaceMacro(= P, self.Macros) + for P in MyAgo.IncludePathList: + IncludePath =3D self._INC_FLAG_[ + 'NASM'] + self.PlaceMacro(P, self.Macros) if IncludePath.endswith(os.sep): IncludePath =3D IncludePath.rstrip(os.sep) # When compiling .nasm files, need to add a literal backsl= ash at each path. @@ -624,29 +638,33 @@ cleanlib: else: IncludePath =3D os.path.join(IncludePath, '') IncludePathList.append(IncludePath) - FileMacroList.append(self._FILE_MACRO_TEMPLATE.Replace({"macro= _name": "NASM_INC", "source_file": IncludePathList})) + FileMacroList.append(self._FILE_MACRO_TEMPLATE.Replace( + {"macro_name": "NASM_INC", "source_file": IncludePathList}= )) =20 # Generate macros used to represent files containing list of input= files for ListFileMacro in self.ListFileMacros: - ListFileName =3D os.path.join(MyAgo.OutputDir, "%s.lst" % List= FileMacro.lower()[:len(ListFileMacro) - 5]) + ListFileName =3D os.path.join(MyAgo.OutputDir, "%s.lst" % List= FileMacro.lower()[ + :len(ListFileMacro) - 5]) FileMacroList.append("%s =3D %s" % (ListFileMacro, ListFileNam= e)) SaveFileOnChange( ListFileName, "\n".join(self.ListFileMacros[ListFileMacro]), False - ) + ) =20 # Generate objlist used to create .obj file for Type in self.ObjTargetDict: NewLine =3D ' '.join(list(self.ObjTargetDict[Type])) - FileMacroList.append("OBJLIST_%s =3D %s" % (list(self.ObjTarge= tDict.keys()).index(Type), NewLine)) + FileMacroList.append("OBJLIST_%s =3D %s" % ( + list(self.ObjTargetDict.keys()).index(Type), NewLine)) =20 BcTargetList =3D [] =20 MakefileName =3D self.getMakefileName() LibraryMakeCommandList =3D [] for D in self.LibraryBuildDirectoryList: - Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file":os.= path.join(D, MakefileName)} + Command =3D self._MAKE_TEMPLATE_[self._Platform] % { + "file": os.path.join(D, MakefileName)} LibraryMakeCommandList.append(Command) =20 package_rel_dir =3D MyAgo.SourceDir @@ -663,66 +681,67 @@ cleanlib: package_rel_dir =3D package_rel_dir[index + 1:] =20 MakefileTemplateDict =3D { - "makefile_header" : self._FILE_HEADER_[self._FileTyp= e], - "makefile_path" : os.path.join("$(MODULE_BUILD_DIR= )", MakefileName), - "makefile_name" : MakefileName, - "platform_name" : self.PlatformInfo.Name, - "platform_guid" : self.PlatformInfo.Guid, - "platform_version" : self.PlatformInfo.Version, + "makefile_header": self._FILE_HEADER_[self._FileType], + "makefile_path": os.path.join("$(MODULE_BUILD_DIR)", MakefileN= ame), + "makefile_name": MakefileName, + "platform_name": self.PlatformInfo.Name, + "platform_guid": self.PlatformInfo.Guid, + "platform_version": self.PlatformInfo.Version, "platform_relative_directory": self.PlatformInfo.SourceDir, - "platform_output_directory" : self.PlatformInfo.OutputDir, - "ffs_output_directory" : MyAgo.Macros["FFS_OUTPUT_DIR"], - "platform_dir" : MyAgo.Macros["PLATFORM_DIR"], + "platform_output_directory": self.PlatformInfo.OutputDir, + "ffs_output_directory": MyAgo.Macros["FFS_OUTPUT_DIR"], + "platform_dir": MyAgo.Macros["PLATFORM_DIR"], =20 - "module_name" : MyAgo.Name, - "module_guid" : MyAgo.Guid, - "module_name_guid" : MyAgo.UniqueBaseName, - "module_version" : MyAgo.Version, - "module_type" : MyAgo.ModuleType, - "module_file" : MyAgo.MetaFile.Name, - "module_file_base_name" : MyAgo.MetaFile.BaseName, - "module_relative_directory" : MyAgo.SourceDir, - "module_dir" : mws.join (self.Macros["WORKSPACE= "], MyAgo.SourceDir), + "module_name": MyAgo.Name, + "module_guid": MyAgo.Guid, + "module_name_guid": MyAgo.UniqueBaseName, + "module_version": MyAgo.Version, + "module_type": MyAgo.ModuleType, + "module_file": MyAgo.MetaFile.Name, + "module_file_base_name": MyAgo.MetaFile.BaseName, + "module_relative_directory": MyAgo.SourceDir, + "module_dir": mws.join(self.Macros["WORKSPACE"], MyAgo.SourceD= ir), "package_relative_directory": package_rel_dir, - "module_extra_defines" : ["%s =3D %s" % (k, v) for k, v i= n MyAgo.Module.Defines.items()], + "module_extra_defines": ["%s =3D %s" % (k, v) for k, v in MyAg= o.Module.Defines.items()], =20 - "architecture" : MyAgo.Arch, - "toolchain_tag" : MyAgo.ToolChain, - "build_target" : MyAgo.BuildTarget, + "architecture": MyAgo.Arch, + "toolchain_tag": MyAgo.ToolChain, + "build_target": MyAgo.BuildTarget, =20 - "platform_build_directory" : self.PlatformInfo.BuildDir, - "module_build_directory" : MyAgo.BuildDir, - "module_output_directory" : MyAgo.OutputDir, - "module_debug_directory" : MyAgo.DebugDir, + "platform_build_directory": self.PlatformInfo.BuildDir, + "module_build_directory": MyAgo.BuildDir, + "module_output_directory": MyAgo.OutputDir, + "module_debug_directory": MyAgo.DebugDir, =20 - "separator" : Separator, - "module_tool_definitions" : ToolsDef, + "separator": Separator, + "module_tool_definitions": ToolsDef, =20 - "shell_command_code" : list(self._SHELL_CMD_[self._Plat= form].keys()), - "shell_command" : list(self._SHELL_CMD_[self._Plat= form].values()), + "shell_command_code": list(self._SHELL_CMD_[self._Platform].ke= ys()), + "shell_command": list(self._SHELL_CMD_[self._Platform].values(= )), =20 - "module_entry_point" : ModuleEntryPoint, - "image_entry_point" : ImageEntryPoint, - "arch_entry_point" : ArchEntryPoint, - "remaining_build_target" : self.ResultFileList, - "common_dependency_file" : self.CommonFileDependency, - "create_directory_command" : self.GetCreateDirectoryCommand(s= elf.IntermediateDirectoryList), - "clean_command" : self.GetRemoveDirectoryCommand([= "$(OUTPUT_DIR)"]), - "cleanall_command" : self.GetRemoveDirectoryCommand([= "$(DEBUG_DIR)", "$(OUTPUT_DIR)"]), - "dependent_library_build_directory" : self.LibraryBuildDirecto= ryList, - "library_build_command" : LibraryMakeCommandList, - "file_macro" : FileMacroList, - "file_build_target" : self.BuildTargetList, + "module_entry_point": ModuleEntryPoint, + "image_entry_point": ImageEntryPoint, + "arch_entry_point": ArchEntryPoint, + "remaining_build_target": self.ResultFileList, + "common_dependency_file": self.CommonFileDependency, + "create_directory_command": self.GetCreateDirectoryCommand(sel= f.IntermediateDirectoryList), + "clean_command": self.GetRemoveDirectoryCommand(["$(OUTPUT_DIR= )"]), + "cleanall_command": self.GetRemoveDirectoryCommand(["$(DEBUG_D= IR)", "$(OUTPUT_DIR)"]), + "dependent_library_build_directory": self.LibraryBuildDirector= yList, + "library_build_command": LibraryMakeCommandList, + "file_macro": FileMacroList, + "file_build_target": self.BuildTargetList, "backward_compatible_target": BcTargetList, - "INCLUDETAG" : "\n".join([self._INCLUDE_CMD_= [self._FileType] + " " + os.path.join("$(MODULE_BUILD_DIR)","dependency"), - self._INCLUD= E_CMD_[self._FileType] + " " + os.path.join("$(MODULE_BUILD_DIR)","deps_tar= get") - ]) + "INCLUDETAG": "\n".join([self._INCLUDE_CMD_[self._FileType] + = " " + os.path.join("$(MODULE_BUILD_DIR)", "dependency"), + self._INCLUDE_CMD_[ + self._FileType] + " " + os.path.j= oin("$(MODULE_BUILD_DIR)", "deps_target") + ]) } =20 return MakefileTemplateDict =20 def ParserGenerateFfsCmd(self): - #Add Ffs cmd to self.BuildTargetList + # Add Ffs cmd to self.BuildTargetList OutputFile =3D '' DepsFileList =3D [] =20 @@ -734,9 +753,10 @@ cleanlib: Dst =3D self.ReplaceMacro(Dst) if Dst not in self.ResultFileList: self.ResultFileList.append(Dst) - if '%s :' %(Dst) not in self.BuildTargetList: - self.BuildTargetList.append("%s : %s" %(Dst,Src)) - self.BuildTargetList.append('\t' + self._CP_TEMPLA= TE_[self._Platform] %{'Src': Src, 'Dst': Dst}) + if '%s :' % (Dst) not in self.BuildTargetList: + self.BuildTargetList.append("%s : %s" % (Dst, Src)) + self.BuildTargetList.append( + '\t' + self._CP_TEMPLATE_[self._Platform] % {'= Src': Src, 'Dst': Dst}) =20 FfsCmdList =3D Cmd[0] for index, Str in enumerate(FfsCmdList): @@ -753,14 +773,16 @@ cleanlib: OutputFile =3D self.ReplaceMacro(OutputFile) self.ResultFileList.append(OutputFile) DepsFileString =3D self.ReplaceMacro(DepsFileString) - self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileS= tring)) + self.BuildTargetList.append( + '%s : %s' % (OutputFile, DepsFileString)) CmdString =3D ' '.join(FfsCmdList).strip() CmdString =3D self.ReplaceMacro(CmdString) self.BuildTargetList.append('\t%s' % CmdString) =20 self.ParseSecCmd(DepsFileList, Cmd[1]) - for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileLi= st : - self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro= (SecOutputFile), self.ReplaceMacro(SecDepsFile))) + for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileLi= st: + self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro( + SecOutputFile), self.ReplaceMacro(SecDepsFile))) self.BuildTargetList.append('\t%s' % self.ReplaceMacro(Sec= Cmd)) self.FfsOutputFileList =3D [] =20 @@ -778,10 +800,13 @@ cleanlib: SecDepsFileList.append(SecCmdList[index + = 1]) index =3D index + 1 if CmdName =3D=3D 'Trim': - SecDepsFileList.append(os.path.join('$(DEBUG_D= IR)', os.path.basename(OutputFile).replace('offset', 'efi'))) + SecDepsFileList.append(os.path.join( + '$(DEBUG_DIR)', os.path.basename(OutputFil= e).replace('offset', 'efi'))) if OutputFile.endswith('.ui') or OutputFile.endswi= th('.ver'): - SecDepsFileList.append(os.path.join('$(MODULE_= DIR)', '$(MODULE_FILE)')) - self.FfsOutputFileList.append((OutputFile, ' '.joi= n(SecDepsFileList), SecCmdStr)) + SecDepsFileList.append(os.path.join( + '$(MODULE_DIR)', '$(MODULE_FILE)')) + self.FfsOutputFileList.append( + (OutputFile, ' '.join(SecDepsFileList), SecCmd= Str)) if len(SecDepsFileList) > 0: self.ParseSecCmd(SecDepsFileList, CmdTuple) break @@ -798,14 +823,14 @@ cleanlib: =20 def CommandExceedLimit(self): FlagDict =3D { - 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : Fal= se}, - 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : Fal= se}, - 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : Fal= se}, - 'ASLPP' : { 'Macro' : '$(ASLPP_FLAGS)', 'Value' : Fal= se}, - 'VFRPP' : { 'Macro' : '$(VFRPP_FLAGS)', 'Value' : Fal= se}, - 'ASM' : { 'Macro' : '$(ASM_FLAGS)', 'Value' : Fal= se}, - 'ASLCC' : { 'Macro' : '$(ASLCC_FLAGS)', 'Value' : Fal= se}, - } + 'CC': {'Macro': '$(CC_FLAGS)', 'Value': False}, + 'PP': {'Macro': '$(PP_FLAGS)', 'Value': False}, + 'APP': {'Macro': '$(APP_FLAGS)', 'Value': False}, + 'ASLPP': {'Macro': '$(ASLPP_FLAGS)', 'Value': False}, + 'VFRPP': {'Macro': '$(VFRPP_FLAGS)', 'Value': False}, + 'ASM': {'Macro': '$(ASM_FLAGS)', 'Value': False}, + 'ASLCC': {'Macro': '$(ASLCC_FLAGS)', 'Value': False}, + } =20 RespDict =3D {} FileTypeList =3D [] @@ -830,44 +855,53 @@ cleanlib: SingleCommandList =3D SingleCommand.split() if len(SingleCommandList) > 0: for Flag in FlagDict: - if '$('+ Flag +')' in SingleCommandList[0]: + if '$(' + Flag + ')' in SingleCommandList[= 0]: Tool =3D Flag break if Tool: if 'PATH' not in self._AutoGenObject.BuildOpti= on[Tool]: - EdkLogger.error("build", AUTOGEN_ERROR, "%= s_PATH doesn't exist in %s ToolChain and %s Arch." %(Tool, self._AutoGenObj= ect.ToolChain, self._AutoGenObject.Arch), ExtraData=3D"[%s]" % str(self._Au= toGenObject)) - SingleCommandLength +=3D len(self._AutoGenObje= ct.BuildOption[Tool]['PATH']) + EdkLogger.error("build", AUTOGEN_ERROR, "%= s_PATH doesn't exist in %s ToolChain and %s Arch." % ( + Tool, self._AutoGenObject.ToolChain, s= elf._AutoGenObject.Arch), ExtraData=3D"[%s]" % str(self._AutoGenObject)) + SingleCommandLength +=3D len( + self._AutoGenObject.BuildOption[Tool]['PAT= H']) for item in SingleCommandList[1:]: if FlagDict[Tool]['Macro'] in item: if 'FLAGS' not in self._AutoGenObject.= BuildOption[Tool]: - EdkLogger.error("build", AUTOGEN_E= RROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." %(Tool, self._A= utoGenObject.ToolChain, self._AutoGenObject.Arch), ExtraData=3D"[%s]" % str= (self._AutoGenObject)) + EdkLogger.error("build", AUTOGEN_E= RROR, "%s_FLAGS doesn't exist in %s ToolChain and %s Arch." % ( + Tool, self._AutoGenObject.Tool= Chain, self._AutoGenObject.Arch), ExtraData=3D"[%s]" % str(self._AutoGenObj= ect)) Str =3D self._AutoGenObject.BuildOptio= n[Tool]['FLAGS'] for Option in self._AutoGenObject.Buil= dOption: for Attr in self._AutoGenObject.Bu= ildOption[Option]: if Str.find(Option + '_' + Att= r) !=3D -1: - Str =3D Str.replace('$(' += Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) + Str =3D Str.replace( + '$(' + Option + '_' + = Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) while(Str.find('$(') !=3D -1): for macro in self._AutoGenObject.M= acros: - MacroName =3D '$('+ macro + ')' + MacroName =3D '$(' + macro + '= )' if (Str.find(MacroName) !=3D -= 1): - Str =3D Str.replace(MacroN= ame, self._AutoGenObject.Macros[macro]) + Str =3D Str.replace( + MacroName, self._AutoG= enObject.Macros[macro]) break else: break SingleCommandLength +=3D len(Str) elif '$(INC)' in item: - SingleCommandLength +=3D self._AutoGen= Object.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject.Include= PathList) + SingleCommandLength +=3D self._AutoGen= Object.IncludePathLength + \ + len(IncPrefix) * \ + len(self._AutoGenObject.IncludePat= hList) elif item.find('$(') !=3D -1: Str =3D item for Option in self._AutoGenObject.Buil= dOption: for Attr in self._AutoGenObject.Bu= ildOption[Option]: if Str.find(Option + '_' + Att= r) !=3D -1: - Str =3D Str.replace('$(' += Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) + Str =3D Str.replace( + '$(' + Option + '_' + = Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) while(Str.find('$(') !=3D -1): for macro in self._AutoGenObject.M= acros: - MacroName =3D '$('+ macro + ')' + MacroName =3D '$(' + macro + '= )' if (Str.find(MacroName) !=3D -= 1): - Str =3D Str.replace(MacroN= ame, self._AutoGenObject.Macros[macro]) + Str =3D Str.replace( + MacroName, self._AutoG= enObject.Macros[macro]) break else: break @@ -880,19 +914,22 @@ cleanlib: for Flag in FlagDict: if FlagDict[Flag]['Value']: Key =3D Flag + '_RESP' - RespMacro =3D FlagDict[Flag]['Macro'].replace('FLA= GS', 'RESP') + RespMacro =3D FlagDict[Flag]['Macro'].replace( + 'FLAGS', 'RESP') Value =3D self._AutoGenObject.BuildOption[Flag]['F= LAGS'] for inc in self._AutoGenObject.IncludePathList: Value +=3D ' ' + IncPrefix + inc for Option in self._AutoGenObject.BuildOption: for Attr in self._AutoGenObject.BuildOption[Op= tion]: if Value.find(Option + '_' + Attr) !=3D -1: - Value =3D Value.replace('$(' + Option = + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr]) + Value =3D Value.replace( + '$(' + Option + '_' + Attr + ')', = self._AutoGenObject.BuildOption[Option][Attr]) while (Value.find('$(') !=3D -1): for macro in self._AutoGenObject.Macros: - MacroName =3D '$('+ macro + ')' + MacroName =3D '$(' + macro + ')' if (Value.find(MacroName) !=3D -1): - Value =3D Value.replace(MacroName, sel= f._AutoGenObject.Macros[macro]) + Value =3D Value.replace( + MacroName, self._AutoGenObject.Mac= ros[macro]) break else: break @@ -904,7 +941,8 @@ cleanlib: for Target in BuildTargets: for i, SingleCommand in enumerate(BuildTargets= [Target].Commands): if FlagDict[Flag]['Macro'] in SingleComman= d: - BuildTargets[Target].Commands[i] =3D S= ingleCommand.replace('$(INC)', '').replace(FlagDict[Flag]['Macro'], RespMac= ro) + BuildTargets[Target].Commands[i] =3D S= ingleCommand.replace( + '$(INC)', '').replace(FlagDict[Fla= g]['Macro'], RespMacro) return RespDict =20 def ProcessBuildTargetList(self, RespFile, ToolsDef): @@ -926,7 +964,8 @@ cleanlib: if Item in SourceFileList: SourceFileList.remove(Item) =20 - FileDependencyDict =3D {item:ForceIncludedFile for item in SourceF= ileList} + FileDependencyDict =3D { + item: ForceIncludedFile for item in SourceFileList} =20 for Dependency in FileDependencyDict.values(): self.DependencyHeaderFileSet.update(set(Dependency)) @@ -985,11 +1024,12 @@ cleanlib: continue if GlobalData.gUseHashCache: GlobalData.gModuleBuildTracking[self._AutoGenObject] =3D '= FAIL_METAFILE' - EdkLogger.warn("build","Module MetaFile [Sources] is missing l= ocal header!", - ExtraData =3D "Local Header: " + aFile + " not fou= nd in " + self._AutoGenObject.MetaFile.Path - ) + EdkLogger.warn("build", "Module MetaFile [Sources] is missing = local header!", + ExtraData=3D"Local Header: " + aFile + + " not found in " + self._AutoGenObject.MetaFile= .Path + ) =20 - for File,Dependency in FileDependencyDict.items(): + for File, Dependency in FileDependencyDict.items(): if not Dependency: continue =20 @@ -1024,7 +1064,8 @@ cleanlib: for Dep in T.Dependencies: Deps.append(self.PlaceMacro(str(Dep), self.Macros)) if Dep !=3D '$(MAKE_FILE)': - CCodeDeps.append(self.PlaceMacro(str(Dep), self.Ma= cros)) + CCodeDeps.append( + self.PlaceMacro(str(Dep), self.Macros)) # Add inclusion-dependencies if len(T.Inputs) =3D=3D 1 and T.Inputs[0] in FileDependenc= yDict: for F in FileDependencyDict[T.Inputs[0]]: @@ -1035,7 +1076,8 @@ cleanlib: # In order to use file list macro as dependency if T.GenListFile: # gnu tools need forward slash path separator, eve= n on Windows - self.ListFileMacros[T.ListFileMacro].append(str(F)= .replace ('\\', '/')) + self.ListFileMacros[T.ListFileMacro].append( + str(F).replace('\\', '/')) self.FileListMacros[T.FileListMacro].append(NewFil= e) elif T.GenFileListMacro: self.FileListMacros[T.FileListMacro].append(NewFil= e) @@ -1054,25 +1096,32 @@ cleanlib: = CmdCppDict, DependencyDict, RespFile, = ToolsDef, resp_file_number) resp_file_number +=3D 1 - TargetDict =3D {"target": self.PlaceMacro(T.Target.Pat= h, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": CCodeDeps} - CmdLine =3D self._BUILD_TARGET_TEMPLATE.Replace(Target= Dict).rstrip().replace('\t$(OBJLIST', '$(OBJLIST') + TargetDict =3D {"target": self.PlaceMacro( + T.Target.Path, self.Macros), "cmd": "\n\t".join(T.= Commands), "deps": CCodeDeps} + CmdLine =3D self._BUILD_TARGET_TEMPLATE.Replace( + TargetDict).rstrip().replace('\t$(OBJLIST', '$(OBJ= LIST') if T.Commands: - CmdLine =3D '%s%s' %(CmdLine, TAB_LINE_BREAK) + CmdLine =3D '%s%s' % (CmdLine, TAB_LINE_BREAK) if CCodeDeps or CmdLine: self.BuildTargetList.append(CmdLine) else: - TargetDict =3D {"target": self.PlaceMacro(T.Target.Pat= h, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": Deps} - self.BuildTargetList.append(self._BUILD_TARGET_TEMPLAT= E.Replace(TargetDict)) + TargetDict =3D {"target": self.PlaceMacro( + T.Target.Path, self.Macros), "cmd": "\n\t".join(T.= Commands), "deps": Deps} + self.BuildTargetList.append( + self._BUILD_TARGET_TEMPLATE.Replace(TargetDict)) =20 # Add a Makefile rule for targets generating multiple = files. # The main output is a prerequisite for the other outp= ut files. for i in T.Outputs[1:]: - AnnexeTargetDict =3D {"target": self.PlaceMacro(i.= Path, self.Macros), "cmd": "", "deps": self.PlaceMacro(T.Target.Path, self.= Macros)} - self.BuildTargetList.append(self._BUILD_TARGET_TEM= PLATE.Replace(AnnexeTargetDict)) + AnnexeTargetDict =3D {"target": self.PlaceMacro( + i.Path, self.Macros), "cmd": "", "deps": self.= PlaceMacro(T.Target.Path, self.Macros)} + self.BuildTargetList.append( + self._BUILD_TARGET_TEMPLATE.Replace(AnnexeTarg= etDict)) =20 def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDi= ct, DependencyDict, RespFile, ToolsDef, - resp_file_number): - SaveFilePath =3D os.path.join(RespFile, "cc_resp_%s.txt" % resp_fi= le_number) + resp_file_number): + SaveFilePath =3D os.path.join( + RespFile, "cc_resp_%s.txt" % resp_file_number) if not CmdSumDict: for item in self._AutoGenObject.Targets[Type]: CmdSumDict[item.Target.SubDir] =3D item.Target.BaseName @@ -1097,39 +1146,47 @@ cleanlib: if len(SingleCommandList) > 0 and self.CheckCCCmd(SingleCo= mmandList): for Temp in SingleCommandList: if Temp.startswith('/Fo'): - CmdSign =3D '%s%s' % (Temp.rsplit(TAB_SLASH, 1= )[0], TAB_SLASH) + CmdSign =3D '%s%s' % (Temp.rsplit( + TAB_SLASH, 1)[0], TAB_SLASH) break else: continue if CmdSign not in list(CmdTargetDict.keys()): cmd =3D Item.replace(Temp, CmdSign) if SingleCommandList[-1] in cmd: - CmdTargetDict[CmdSign] =3D [cmd.replace(Single= CommandList[-1], "").rstrip(), SingleCommandList[-1]] + CmdTargetDict[CmdSign] =3D [cmd.replace( + SingleCommandList[-1], "").rstrip(), Singl= eCommandList[-1]] else: # CmdTargetDict[CmdSign] =3D "%s %s" % (CmdTargetD= ict[CmdSign], SingleCommandList[-1]) CmdTargetDict[CmdSign].append(SingleCommandList[-1= ]) Index =3D CommandList.index(Item) CommandList.pop(Index) - BaseName =3D SingleCommandList[-1].rsplit('.',1)[0] + BaseName =3D SingleCommandList[-1].rsplit('.', 1)[0] if BaseName.endswith("%s%s" % (TAB_SLASH, CmdSumDict[C= mdSign[3:].rsplit(TAB_SLASH, 1)[0]])): Cpplist =3D CmdCppDict[T.Target.SubDir] - Cpplist.insert(0, '$(OBJLIST_%d): ' % list(self.Ob= jTargetDict.keys()).index(T.Target.SubDir)) + Cpplist.insert(0, '$(OBJLIST_%d): ' % list( + self.ObjTargetDict.keys()).index(T.Target.SubD= ir)) source_files =3D CmdTargetDict[CmdSign][1:] source_files.insert(0, " ") - if len(source_files)>2: - SaveFileOnChange(SaveFilePath, " ".join(source= _files), False) + if len(source_files) > 2: + SaveFileOnChange( + SaveFilePath, " ".join(source_files), Fals= e) T.Commands[Index] =3D '%s\n\t%s $(cc_resp_%s)'= % ( - ' \\\n\t'.join(Cpplist), CmdTargetDict[CmdSign= ][0], resp_file_number) - ToolsDef.append("cc_resp_%s =3D @%s" % (resp_f= ile_number, SaveFilePath)) + ' \\\n\t'.join(Cpplist), CmdTargetDict[Cmd= Sign][0], resp_file_number) + ToolsDef.append("cc_resp_%s =3D @%s" % + (resp_file_number, SaveFilePat= h)) =20 - elif len(source_files)<=3D2 and len(" ".join(CmdTa= rgetDict[CmdSign][:2]))>GlobalData.gCommandMaxLength: - SaveFileOnChange(SaveFilePath, " ".join(source= _files), False) + elif len(source_files) <=3D 2 and len(" ".join(Cmd= TargetDict[CmdSign][:2])) > GlobalData.gCommandMaxLength: + SaveFileOnChange( + SaveFilePath, " ".join(source_files), Fals= e) T.Commands[Index] =3D '%s\n\t%s $(cc_resp_%s)'= % ( ' \\\n\t'.join(Cpplist), CmdTargetDict[Cmd= Sign][0], resp_file_number) - ToolsDef.append("cc_resp_%s =3D @%s" % (resp_f= ile_number, SaveFilePath)) + ToolsDef.append("cc_resp_%s =3D @%s" % + (resp_file_number, SaveFilePat= h)) =20 else: - T.Commands[Index] =3D '%s\n\t%s' % (' \\\n\t'.= join(Cpplist), " ".join(CmdTargetDict[CmdSign])) + T.Commands[Index] =3D '%s\n\t%s' % (' \\\n\t'.= join( + Cpplist), " ".join(CmdTargetDict[CmdSign])) else: T.Commands.pop(Index) return T, CmdSumDict, CmdTargetDict, CmdCppDict @@ -1139,13 +1196,15 @@ cleanlib: if '$(CC)' in cmd: return True return False - ## For creating makefile targets for dependent libraries + # For creating makefile targets for dependent libraries + def ProcessDependentLibrary(self): for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList: if not LibraryAutoGen.IsBinaryModule: - self.LibraryBuildDirectoryList.append(self.PlaceMacro(Libr= aryAutoGen.BuildDir, self.Macros)) + self.LibraryBuildDirectoryList.append( + self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros)) =20 - ## Return a list containing source file's dependencies + # Return a list containing source file's dependencies # # @param FileList The list of source files # @param ForceInculeList The list of files which will be includ= ed forcely @@ -1156,17 +1215,18 @@ cleanlib: def GetFileDependency(self, FileList, ForceInculeList, SearchPathList): Dependency =3D {} for F in FileList: - Dependency[F] =3D GetDependencyList(self._AutoGenObject, self.= FileCache, F, ForceInculeList, SearchPathList) + Dependency[F] =3D GetDependencyList( + self._AutoGenObject, self.FileCache, F, ForceInculeList, S= earchPathList) return Dependency =20 =20 -## CustomMakefile class +# CustomMakefile class # # This class encapsules makefie and its generation for module. It uses te= mplate to generate # the content of makefile. The content of makefile will be got from Modul= eAutoGen object. # class CustomMakefile(BuildFile): - ## template used to generate the makefile for module with custom makef= ile + # template used to generate the makefile for module with custom makefi= le _TEMPLATE_ =3D TemplateString('''\ ${makefile_header} =20 @@ -1258,7 +1318,7 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\ =20 ''') =20 - ## Constructor of CustomMakefile + # Constructor of CustomMakefile # # @param ModuleAutoGen Object of ModuleAutoGen class # @@ -1277,9 +1337,9 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\ EdkLogger.error('build', OPTION_NOT_SUPPORTED, "No custom make= file for %s" % self._FileType, ExtraData=3D"[%s]" % str(MyAgo)) MakefilePath =3D mws.join( - MyAgo.WorkspaceDir, - MyAgo.CustomMakefile[self._FileType] - ) + MyAgo.WorkspaceDir, + MyAgo.CustomMakefile[self._FileType] + ) try: CustomMakefile =3D open(MakefilePath, 'r').read() except: @@ -1296,61 +1356,65 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\ if Attr =3D=3D "FAMILY": continue elif Attr =3D=3D "PATH": - ToolsDef.append("%s =3D %s" % (Tool, MyAgo.BuildOption= [Tool][Attr])) + ToolsDef.append("%s =3D %s" % + (Tool, MyAgo.BuildOption[Tool][Attr])) else: - ToolsDef.append("%s_%s =3D %s" % (Tool, Attr, MyAgo.Bu= ildOption[Tool][Attr])) + ToolsDef.append("%s_%s =3D %s" % + (Tool, Attr, MyAgo.BuildOption[Tool][A= ttr])) ToolsDef.append("") =20 MakefileName =3D self.getMakefileName() MakefileTemplateDict =3D { - "makefile_header" : self._FILE_HEADER_[self._FileTyp= e], - "makefile_path" : os.path.join("$(MODULE_BUILD_DIR= )", MakefileName), - "platform_name" : self.PlatformInfo.Name, - "platform_guid" : self.PlatformInfo.Guid, - "platform_version" : self.PlatformInfo.Version, + "makefile_header": self._FILE_HEADER_[self._FileType], + "makefile_path": os.path.join("$(MODULE_BUILD_DIR)", MakefileN= ame), + "platform_name": self.PlatformInfo.Name, + "platform_guid": self.PlatformInfo.Guid, + "platform_version": self.PlatformInfo.Version, "platform_relative_directory": self.PlatformInfo.SourceDir, - "platform_output_directory" : self.PlatformInfo.OutputDir, - "platform_dir" : MyAgo.Macros["PLATFORM_DIR"], + "platform_output_directory": self.PlatformInfo.OutputDir, + "platform_dir": MyAgo.Macros["PLATFORM_DIR"], =20 - "module_name" : MyAgo.Name, - "module_guid" : MyAgo.Guid, - "module_name_guid" : MyAgo.UniqueBaseName, - "module_version" : MyAgo.Version, - "module_type" : MyAgo.ModuleType, - "module_file" : MyAgo.MetaFile, - "module_file_base_name" : MyAgo.MetaFile.BaseName, - "module_relative_directory" : MyAgo.SourceDir, - "module_dir" : mws.join (MyAgo.WorkspaceDir, My= Ago.SourceDir), + "module_name": MyAgo.Name, + "module_guid": MyAgo.Guid, + "module_name_guid": MyAgo.UniqueBaseName, + "module_version": MyAgo.Version, + "module_type": MyAgo.ModuleType, + "module_file": MyAgo.MetaFile, + "module_file_base_name": MyAgo.MetaFile.BaseName, + "module_relative_directory": MyAgo.SourceDir, + "module_dir": mws.join(MyAgo.WorkspaceDir, MyAgo.SourceDir), =20 - "architecture" : MyAgo.Arch, - "toolchain_tag" : MyAgo.ToolChain, - "build_target" : MyAgo.BuildTarget, + "architecture": MyAgo.Arch, + "toolchain_tag": MyAgo.ToolChain, + "build_target": MyAgo.BuildTarget, =20 - "platform_build_directory" : self.PlatformInfo.BuildDir, - "module_build_directory" : MyAgo.BuildDir, - "module_output_directory" : MyAgo.OutputDir, - "module_debug_directory" : MyAgo.DebugDir, + "platform_build_directory": self.PlatformInfo.BuildDir, + "module_build_directory": MyAgo.BuildDir, + "module_output_directory": MyAgo.OutputDir, + "module_debug_directory": MyAgo.DebugDir, =20 - "separator" : Separator, - "module_tool_definitions" : ToolsDef, + "separator": Separator, + "module_tool_definitions": ToolsDef, =20 - "shell_command_code" : list(self._SHELL_CMD_[self._Plat= form].keys()), - "shell_command" : list(self._SHELL_CMD_[self._Plat= form].values()), + "shell_command_code": list(self._SHELL_CMD_[self._Platform].ke= ys()), + "shell_command": list(self._SHELL_CMD_[self._Platform].values(= )), =20 - "create_directory_command" : self.GetCreateDirectoryCommand(s= elf.IntermediateDirectoryList), - "custom_makefile_content" : CustomMakefile + "create_directory_command": self.GetCreateDirectoryCommand(sel= f.IntermediateDirectoryList), + "custom_makefile_content": CustomMakefile } =20 return MakefileTemplateDict =20 -## PlatformMakefile class +# PlatformMakefile class # # This class encapsules makefie and its generation for platform. It uses # template to generate the content of makefile. The content of makefile wi= ll be # got from PlatformAutoGen object. # + + class PlatformMakefile(BuildFile): - ## template used to generate the makefile for platform + # template used to generate the makefile for platform _TEMPLATE_ =3D TemplateString('''\ ${makefile_header} =20 @@ -1445,7 +1509,7 @@ cleanlib: \t${END}@cd $(BUILD_DIR)\n ''') =20 - ## Constructor of PlatformMakefile + # Constructor of PlatformMakefile # # @param ModuleAutoGen Object of PlatformAutoGen class # @@ -1477,9 +1541,9 @@ cleanlib: LibraryMakefileList =3D [] LibraryMakeCommandList =3D [] for D in self.LibraryBuildDirectoryList: - D =3D self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir}) + D =3D self.PlaceMacro(D, {"BUILD_DIR": MyAgo.BuildDir}) Makefile =3D os.path.join(D, MakefileName) - Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file":Mak= efile} + Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file": Ma= kefile} LibraryMakefileList.append(Makefile) LibraryMakeCommandList.append(Command) self.LibraryMakeCommandList =3D LibraryMakeCommandList @@ -1487,44 +1551,44 @@ cleanlib: ModuleMakefileList =3D [] ModuleMakeCommandList =3D [] for D in self.ModuleBuildDirectoryList: - D =3D self.PlaceMacro(D, {"BUILD_DIR":MyAgo.BuildDir}) + D =3D self.PlaceMacro(D, {"BUILD_DIR": MyAgo.BuildDir}) Makefile =3D os.path.join(D, MakefileName) - Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file":Mak= efile} + Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file": Ma= kefile} ModuleMakefileList.append(Makefile) ModuleMakeCommandList.append(Command) =20 MakefileTemplateDict =3D { - "makefile_header" : self._FILE_HEADER_[self._FileTyp= e], - "makefile_path" : os.path.join("$(BUILD_DIR)", Mak= efileName), - "make_path" : MyAgo.ToolDefinition["MAKE"]["PA= TH"], - "makefile_name" : MakefileName, - "platform_name" : MyAgo.Name, - "platform_guid" : MyAgo.Guid, - "platform_version" : MyAgo.Version, - "platform_file" : MyAgo.MetaFile, + "makefile_header": self._FILE_HEADER_[self._FileType], + "makefile_path": os.path.join("$(BUILD_DIR)", MakefileName), + "make_path": MyAgo.ToolDefinition["MAKE"]["PATH"], + "makefile_name": MakefileName, + "platform_name": MyAgo.Name, + "platform_guid": MyAgo.Guid, + "platform_version": MyAgo.Version, + "platform_file": MyAgo.MetaFile, "platform_relative_directory": MyAgo.SourceDir, - "platform_output_directory" : MyAgo.OutputDir, - "platform_build_directory" : MyAgo.BuildDir, - "platform_dir" : MyAgo.Macros["PLATFORM_DIR"], + "platform_output_directory": MyAgo.OutputDir, + "platform_build_directory": MyAgo.BuildDir, + "platform_dir": MyAgo.Macros["PLATFORM_DIR"], =20 - "toolchain_tag" : MyAgo.ToolChain, - "build_target" : MyAgo.BuildTarget, - "shell_command_code" : list(self._SHELL_CMD_[self._Plat= form].keys()), - "shell_command" : list(self._SHELL_CMD_[self._Plat= form].values()), - "build_architecture_list" : MyAgo.Arch, - "architecture" : MyAgo.Arch, - "separator" : Separator, - "create_directory_command" : self.GetCreateDirectoryCommand(s= elf.IntermediateDirectoryList), - "cleanall_command" : self.GetRemoveDirectoryCommand(s= elf.IntermediateDirectoryList), - "library_makefile_list" : LibraryMakefileList, - "module_makefile_list" : ModuleMakefileList, - "library_build_command" : LibraryMakeCommandList, - "module_build_command" : ModuleMakeCommandList, + "toolchain_tag": MyAgo.ToolChain, + "build_target": MyAgo.BuildTarget, + "shell_command_code": list(self._SHELL_CMD_[self._Platform].ke= ys()), + "shell_command": list(self._SHELL_CMD_[self._Platform].values(= )), + "build_architecture_list": MyAgo.Arch, + "architecture": MyAgo.Arch, + "separator": Separator, + "create_directory_command": self.GetCreateDirectoryCommand(sel= f.IntermediateDirectoryList), + "cleanall_command": self.GetRemoveDirectoryCommand(self.Interm= ediateDirectoryList), + "library_makefile_list": LibraryMakefileList, + "module_makefile_list": ModuleMakefileList, + "library_build_command": LibraryMakeCommandList, + "module_build_command": ModuleMakeCommandList, } =20 return MakefileTemplateDict =20 - ## Get the root directory list for intermediate files of all modules b= uild + # Get the root directory list for intermediate files of all modules bu= ild # # @retval list The list of directory # @@ -1532,10 +1596,11 @@ cleanlib: DirList =3D [] for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList: if not ModuleAutoGen.IsBinaryModule: - DirList.append(os.path.join(self._AutoGenObject.BuildDir, = ModuleAutoGen.BuildDir)) + DirList.append(os.path.join( + self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir)) return DirList =20 - ## Get the root directory list for intermediate files of all libraries= build + # Get the root directory list for intermediate files of all libraries = build # # @retval list The list of directory # @@ -1543,20 +1608,23 @@ cleanlib: DirList =3D [] for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList: if not LibraryAutoGen.IsBinaryModule: - DirList.append(os.path.join(self._AutoGenObject.BuildDir, = LibraryAutoGen.BuildDir)) + DirList.append(os.path.join( + self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir)) return DirList =20 -## TopLevelMakefile class +# TopLevelMakefile class # # This class encapsules makefie and its generation for entrance makefile.= It # uses template to generate the content of makefile. The content of makefi= le # will be got from WorkspaceAutoGen object. # + + class TopLevelMakefile(BuildFile): - ## template used to generate toplevel makefile + # template used to generate toplevel makefile _TEMPLATE_ =3D TemplateString('''${BEGIN}\tGenFds -f ${fdf_file} --con= f=3D${conf_directory} -o ${platform_build_directory} -t ${toolchain_tag} -b= ${build_target} -p ${active_platform} -a ${build_architecture_list} ${extr= a_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C= ${cap} ${END}${BEGIN} -D ${macro} ${END}''') =20 - ## Constructor of TopLevelMakefile + # Constructor of TopLevelMakefile # # @param Workspace Object of WorkspaceAutoGen class # @@ -1578,7 +1646,8 @@ class TopLevelMakefile(BuildFile): ExtraData=3D"[%s]" % str(MyAgo)) =20 for Arch in MyAgo.ArchList: - self.IntermediateDirectoryList.append(Separator.join(["$(BUILD= _DIR)", Arch])) + self.IntermediateDirectoryList.append( + Separator.join(["$(BUILD_DIR)", Arch])) self.IntermediateDirectoryList.append("$(FV_DIR)") =20 # TRICK: for not generating GenFds call in makefile if no FDF file @@ -1591,7 +1660,8 @@ class TopLevelMakefile(BuildFile): MacroDict.update(GlobalData.gCommandLineDefines) for MacroName in MacroDict: if MacroDict[MacroName] !=3D "": - MacroList.append('"%s=3D%s"' % (MacroName, MacroDict[M= acroName].replace('\\', '\\\\'))) + MacroList.append('"%s=3D%s"' % ( + MacroName, MacroDict[MacroName].replace('\\', '\\\= \'))) else: MacroList.append('"%s"' % MacroName) else: @@ -1620,48 +1690,50 @@ class TopLevelMakefile(BuildFile): else: pcdname =3D '.'.join(pcd[0:2]) if pcd[3].startswith('{'): - ExtraOption +=3D " --pcd " + pcdname + '=3D' + 'H' + '"' += pcd[3] + '"' + ExtraOption +=3D " --pcd " + pcdname + \ + '=3D' + 'H' + '"' + pcd[3] + '"' else: ExtraOption +=3D " --pcd " + pcdname + '=3D' + pcd[3] =20 MakefileName =3D self.getMakefileName() SubBuildCommandList =3D [] for A in MyAgo.ArchList: - Command =3D self._MAKE_TEMPLATE_[self._Platform] % {"file":os.= path.join("$(BUILD_DIR)", A, MakefileName)} + Command =3D self._MAKE_TEMPLATE_[self._Platform] % { + "file": os.path.join("$(BUILD_DIR)", A, MakefileName)} SubBuildCommandList.append(Command) =20 MakefileTemplateDict =3D { - "makefile_header" : self._FILE_HEADER_[self._FileTyp= e], - "makefile_path" : os.path.join("$(BUILD_DIR)", Mak= efileName), - "make_path" : MyAgo.ToolDefinition["MAKE"]["PA= TH"], - "platform_name" : MyAgo.Name, - "platform_guid" : MyAgo.Guid, - "platform_version" : MyAgo.Version, - "platform_build_directory" : MyAgo.BuildDir, - "conf_directory" : GlobalData.gConfDirectory, + "makefile_header": self._FILE_HEADER_[self._FileType], + "makefile_path": os.path.join("$(BUILD_DIR)", MakefileName), + "make_path": MyAgo.ToolDefinition["MAKE"]["PATH"], + "platform_name": MyAgo.Name, + "platform_guid": MyAgo.Guid, + "platform_version": MyAgo.Version, + "platform_build_directory": MyAgo.BuildDir, + "conf_directory": GlobalData.gConfDirectory, =20 - "toolchain_tag" : MyAgo.ToolChain, - "build_target" : MyAgo.BuildTarget, - "shell_command_code" : list(self._SHELL_CMD_[self._Plat= form].keys()), - "shell_command" : list(self._SHELL_CMD_[self._Plat= form].values()), - 'arch' : list(MyAgo.ArchList), - "build_architecture_list" : ','.join(MyAgo.ArchList), - "separator" : Separator, - "create_directory_command" : self.GetCreateDirectoryCommand(s= elf.IntermediateDirectoryList), - "cleanall_command" : self.GetRemoveDirectoryCommand(s= elf.IntermediateDirectoryList), - "sub_build_command" : SubBuildCommandList, - "fdf_file" : FdfFileList, - "active_platform" : str(MyAgo), - "fd" : MyAgo.FdTargetList, - "fv" : MyAgo.FvTargetList, - "cap" : MyAgo.CapTargetList, - "extra_options" : ExtraOption, - "macro" : MacroList, + "toolchain_tag": MyAgo.ToolChain, + "build_target": MyAgo.BuildTarget, + "shell_command_code": list(self._SHELL_CMD_[self._Platform].ke= ys()), + "shell_command": list(self._SHELL_CMD_[self._Platform].values(= )), + 'arch': list(MyAgo.ArchList), + "build_architecture_list": ','.join(MyAgo.ArchList), + "separator": Separator, + "create_directory_command": self.GetCreateDirectoryCommand(sel= f.IntermediateDirectoryList), + "cleanall_command": self.GetRemoveDirectoryCommand(self.Interm= ediateDirectoryList), + "sub_build_command": SubBuildCommandList, + "fdf_file": FdfFileList, + "active_platform": str(MyAgo), + "fd": MyAgo.FdTargetList, + "fv": MyAgo.FvTargetList, + "cap": MyAgo.CapTargetList, + "extra_options": ExtraOption, + "macro": MacroList, } =20 return MakefileTemplateDict =20 - ## Get the root directory list for intermediate files of all modules b= uild + # Get the root directory list for intermediate files of all modules bu= ild # # @retval list The list of directory # @@ -1669,10 +1741,11 @@ class TopLevelMakefile(BuildFile): DirList =3D [] for ModuleAutoGen in self._AutoGenObject.ModuleAutoGenList: if not ModuleAutoGen.IsBinaryModule: - DirList.append(os.path.join(self._AutoGenObject.BuildDir, = ModuleAutoGen.BuildDir)) + DirList.append(os.path.join( + self._AutoGenObject.BuildDir, ModuleAutoGen.BuildDir)) return DirList =20 - ## Get the root directory list for intermediate files of all libraries= build + # Get the root directory list for intermediate files of all libraries = build # # @retval list The list of directory # @@ -1680,10 +1753,11 @@ class TopLevelMakefile(BuildFile): DirList =3D [] for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList: if not LibraryAutoGen.IsBinaryModule: - DirList.append(os.path.join(self._AutoGenObject.BuildDir, = LibraryAutoGen.BuildDir)) + DirList.append(os.path.join( + self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir)) return DirList =20 -## Find dependencies for one source file +# Find dependencies for one source file # # By searching recursively "#include" directive in file, find out all the # files needed by given source file. The dependencies will be only search= ed @@ -1695,8 +1769,11 @@ class TopLevelMakefile(BuildFile): # # @retval list The list of files the given source file de= pends on # + + def GetDependencyList(AutoGenObject, FileCache, File, ForceList, SearchPat= hList): - EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s= " % File) + EdkLogger.debug(EdkLogger.DEBUG_1, + "Try to get dependency files for %s" % File) FileStack =3D [File] + ForceList DependencySet =3D set() =20 @@ -1725,7 +1802,8 @@ def GetDependencyList(AutoGenObject, FileCache, File,= ForceList, SearchPathList) FileContent =3D Fd.read() Fd.close() except BaseException as X: - EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DF.= Path + "\n\t" + str(X)) + EdkLogger.error("build", FILE_OPEN_FAILURE, + ExtraData=3DF.Path + "\n\t" + str(X)) if len(FileContent) =3D=3D 0: continue try: @@ -1746,7 +1824,8 @@ def GetDependencyList(AutoGenObject, FileCache, File,= ForceList, SearchPathList) HeaderType =3D HeaderList[0][0] HeaderKey =3D HeaderList[0][1] if HeaderType in gIncludeMacroConversion: - Inc =3D gIncludeMacroConversion[HeaderType] % {"He= aderKey" : HeaderKey} + Inc =3D gIncludeMacroConversion[HeaderType] % { + "HeaderKey": HeaderKey} else: # not known macro used in #include, always build t= he file by # returning a empty dependency @@ -1776,7 +1855,7 @@ def GetDependencyList(AutoGenObject, FileCache, File,= ForceList, SearchPathList) FileStack.append(FilePath) break else: - EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was = not found "\ + EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was = not found " "in any given path:\n\t%s" % (Inc, F, "\n\= t".join(SearchPathList))) =20 FileCache[F] =3D FullPathDependList @@ -1789,6 +1868,7 @@ def GetDependencyList(AutoGenObject, FileCache, File,= ForceList, SearchPathList) =20 return DependencyList =20 + # This acts like the main() function for the script, unless it is 'import'= ed into another script. if __name__ =3D=3D '__main__': pass diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source= /Python/AutoGen/GenPcdDb.py index ad5dae0e5a2f..8bf76e6a7058 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -1,4 +1,4 @@ -## @file +# @file # Routines for generating Pcd Database # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
        @@ -94,10 +94,10 @@ ${END} #endif """) =20 -## Mapping between PCD driver type and EFI phase +# Mapping between PCD driver type and EFI phase gPcdPhaseMap =3D { - "PEI_PCD_DRIVER" : "PEI", - "DXE_PCD_DRIVER" : "DXE" + "PEI_PCD_DRIVER": "PEI", + "DXE_PCD_DRIVER": "DXE" } =20 gPcdDatabaseAutoGenH =3D TemplateString(""" @@ -233,7 +233,7 @@ ${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit =3D { #endif """) =20 -## DbItemList +# DbItemList # # The class holds the Pcd database items. ItemSize if not zero should mat= ch the item datum type in the C structure. # When the structure is changed, remember to check the ItemSize and the r= elated PackStr in PackData() @@ -241,6 +241,8 @@ ${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit =3D { # the DataList corresponds to the data that need to be written to databas= e. If DataList is not present, then RawDataList # will be written to the database. # + + class DbItemList: def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): self.ItemSize =3D ItemSize @@ -269,13 +271,14 @@ class DbItemList: self.ListSize =3D 0 return self.ListSize if self.ItemSize =3D=3D 0: - self.ListSize =3D self.GetInterOffset(len(self.RawDataList) - = 1) + len(self.RawDataList[len(self.RawDataList)-1]) + self.ListSize =3D self.GetInterOffset( + len(self.RawDataList) - 1) + len(self.RawDataList[len(self= .RawDataList)-1]) else: self.ListSize =3D self.ItemSize * len(self.RawDataList) return self.ListSize =20 def PackData(self): - ## PackGuid + # PackGuid # # Pack the GUID value in C structure format into data array # @@ -305,10 +308,12 @@ class DbItemList: =20 return Buffer =20 -## DbExMapTblItemList +# DbExMapTblItemList # # The class holds the ExMap table # + + class DbExMapTblItemList (DbItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbItemList.__init__(self, ItemSize, DataList, RawDataList) @@ -323,11 +328,13 @@ class DbExMapTblItemList (DbItemList): GetIntegerValue(Datas[2])) return Buffer =20 -## DbComItemList +# DbComItemList # # The DbComItemList is a special kind of DbItemList in case that the size = of the List can not be computed by the # ItemSize multiply the ItemCount. # + + class DbComItemList (DbItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbItemList.__init__(self, ItemSize, DataList, RawDataList) @@ -356,7 +363,8 @@ class DbComItemList (DbItemList): if len(self.RawDataList) =3D=3D 0: self.ListSize =3D 0 else: - self.ListSize =3D self.GetInterOffset(len(self.RawDataList= ) - 1) + len(self.RawDataList[len(self.RawDataList)-1]) * self.ItemSize + self.ListSize =3D self.GetInterOffset(len( + self.RawDataList) - 1) + len(self.RawDataList[len(self= .RawDataList)-1]) * self.ItemSize =20 return self.ListSize =20 @@ -374,10 +382,12 @@ class DbComItemList (DbItemList): =20 return Buffer =20 -## DbVariableTableItemList +# DbVariableTableItemList # # The class holds the Variable header value table # + + class DbVariableTableItemList (DbComItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbComItemList.__init__(self, ItemSize, DataList, RawDataList) @@ -397,8 +407,9 @@ class DbVariableTableItemList (DbComItemList): GetIntegerValue(0)) return Buffer =20 + class DbStringHeadTableItemList(DbItemList): - def __init__(self,ItemSize,DataList=3DNone,RawDataList=3DNone): + def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbItemList.__init__(self, ItemSize, DataList, RawDataList) =20 def GetInterOffset(self, Index): @@ -426,7 +437,8 @@ class DbStringHeadTableItemList(DbItemList): self.ListSize =3D 0 return self.ListSize if self.ItemSize =3D=3D 0: - self.ListSize =3D self.GetInterOffset(len(self.RawDataList) - = 1) + len(self.RawDataList[len(self.RawDataList)-1]) + self.ListSize =3D self.GetInterOffset( + len(self.RawDataList) - 1) + len(self.RawDataList[len(self= .RawDataList)-1]) else: for Datas in self.RawDataList: if type(Datas) in (list, tuple): @@ -435,10 +447,12 @@ class DbStringHeadTableItemList(DbItemList): self.ListSize +=3D self.ItemSize return self.ListSize =20 -## DbSkuHeadTableItemList +# DbSkuHeadTableItemList # # The class holds the Sku header value table # + + class DbSkuHeadTableItemList (DbItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbItemList.__init__(self, ItemSize, DataList, RawDataList) @@ -452,10 +466,12 @@ class DbSkuHeadTableItemList (DbItemList): GetIntegerValue(Data[1])) return Buffer =20 -## DbSizeTableItemList +# DbSizeTableItemList # # The class holds the size table # + + class DbSizeTableItemList (DbItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone): DbItemList.__init__(self, ItemSize, DataList, RawDataList) @@ -465,6 +481,7 @@ class DbSizeTableItemList (DbItemList): for Data in self.RawDataList: length +=3D (1 + len(Data[1])) return length * self.ItemSize + def PackData(self): PackStr =3D "=3DH" Buffer =3D bytearray() @@ -473,13 +490,15 @@ class DbSizeTableItemList (DbItemList): GetIntegerValue(Data[0])) for subData in Data[1]: Buffer +=3D pack(PackStr, - GetIntegerValue(subData)) + GetIntegerValue(subData)) return Buffer =20 -## DbStringItemList +# DbStringItemList # # The class holds the string table # + + class DbStringItemList (DbComItemList): def __init__(self, ItemSize, DataList=3DNone, RawDataList=3DNone, LenL= ist=3DNone): if DataList is None: @@ -504,6 +523,7 @@ class DbStringItemList (DbComItemList): DataList.append(ActualDatas) self.LenList =3D LenList DbComItemList.__init__(self, ItemSize, DataList, RawDataList) + def GetInterOffset(self, Index): Offset =3D 0 =20 @@ -520,7 +540,8 @@ class DbStringItemList (DbComItemList): if len(self.LenList) =3D=3D 0: self.ListSize =3D 0 else: - self.ListSize =3D self.GetInterOffset(len(self.LenList) - 1) += self.LenList[len(self.LenList)-1] + self.ListSize =3D self.GetInterOffset( + len(self.LenList) - 1) + self.LenList[len(self.LenList)-1] =20 return self.ListSize =20 @@ -529,8 +550,7 @@ class DbStringItemList (DbComItemList): return DbComItemList.PackData(self) =20 =20 - -## Find the index in two list where the item matches the key separately +# Find the index in two list where the item matches the key separately # # @param Key1 The key used to search the List1 # @param List1 The list that Key1 will be searched @@ -551,7 +571,7 @@ def GetMatchedIndex(Key1, List1, Key2, List2): return -1 =20 =20 -## convert StringArray like {0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x0= 0, 0x34, 0x00, 0x00, 0x00} +# convert StringArray like {0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x00= , 0x34, 0x00, 0x00, 0x00} # to List like [0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x00, 0x34, 0x00= , 0x00, 0x00] # # @param StringArray A string array like {0x36, 0x00, 0x34, 0x00, 0= x21, 0x00, 0x36, 0x00, 0x34, 0x00, 0x00, 0x00} @@ -564,7 +584,7 @@ def StringArrayToList(StringArray): return eval(StringArray) =20 =20 -## Convert TokenType String like "PCD_DATUM_TYPE_UINT32 | PCD_TYPE_HII" t= o TokenType value +# Convert TokenType String like "PCD_DATUM_TYPE_UINT32 | PCD_TYPE_HII" to= TokenType value # # @param TokenType A TokenType string like "PCD_DATUM_TYPE_UINT32 = | PCD_TYPE_HII" # @@ -576,7 +596,7 @@ def GetTokenTypeValue(TokenType): "PCD_TYPE_DATA": (0x0 << 28), "PCD_TYPE_HII": (0x8 << 28), "PCD_TYPE_VPD": (0x4 << 28), -# "PCD_TYPE_SKU_ENABLED":(0x2 << 28), + # "PCD_TYPE_SKU_ENABLED":(0x2 << 28), "PCD_TYPE_STRING": (0x1 << 28), =20 "PCD_DATUM_TYPE_SHIFT": 24, @@ -588,106 +608,112 @@ def GetTokenTypeValue(TokenType): =20 "PCD_DATUM_TYPE_SHIFT2": 20, "PCD_DATUM_TYPE_UINT8_BOOLEAN": (0x1 << 20 | 0x1 << 24), - } + } return eval(TokenType, TokenTypeDict) =20 -## construct the external Pcd database using data from Dict +# construct the external Pcd database using data from Dict # # @param Dict A dictionary contains Pcd related tables # # @retval Buffer A byte stream of the Pcd database # + + def BuildExDataBase(Dict): # init Db items InitValueUint64 =3D Dict['INIT_DB_VALUE_UINT64'] - DbInitValueUint64 =3D DbComItemList(8, RawDataList =3D InitValueUint64) + DbInitValueUint64 =3D DbComItemList(8, RawDataList=3DInitValueUint64) VardefValueUint64 =3D Dict['VARDEF_DB_VALUE_UINT64'] - DbVardefValueUint64 =3D DbItemList(8, RawDataList =3D VardefValueUint6= 4) + DbVardefValueUint64 =3D DbItemList(8, RawDataList=3DVardefValueUint64) InitValueUint32 =3D Dict['INIT_DB_VALUE_UINT32'] - DbInitValueUint32 =3D DbComItemList(4, RawDataList =3D InitValueUint32) + DbInitValueUint32 =3D DbComItemList(4, RawDataList=3DInitValueUint32) VardefValueUint32 =3D Dict['VARDEF_DB_VALUE_UINT32'] - DbVardefValueUint32 =3D DbItemList(4, RawDataList =3D VardefValueUint3= 2) + DbVardefValueUint32 =3D DbItemList(4, RawDataList=3DVardefValueUint32) VpdHeadValue =3D Dict['VPD_DB_VALUE'] - DbVpdHeadValue =3D DbComItemList(4, RawDataList =3D VpdHeadValue) - ExMapTable =3D list(zip(Dict['EXMAPPING_TABLE_EXTOKEN'], Dict['EXMAPPI= NG_TABLE_LOCAL_TOKEN'], Dict['EXMAPPING_TABLE_GUID_INDEX'])) - DbExMapTable =3D DbExMapTblItemList(8, RawDataList =3D ExMapTable) + DbVpdHeadValue =3D DbComItemList(4, RawDataList=3DVpdHeadValue) + ExMapTable =3D list(zip(Dict['EXMAPPING_TABLE_EXTOKEN'], + Dict['EXMAPPING_TABLE_LOCAL_TOKEN'], Dict['EXMAPPING= _TABLE_GUID_INDEX'])) + DbExMapTable =3D DbExMapTblItemList(8, RawDataList=3DExMapTable) LocalTokenNumberTable =3D Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] - DbLocalTokenNumberTable =3D DbItemList(4, RawDataList =3D LocalTokenNu= mberTable) + DbLocalTokenNumberTable =3D DbItemList(4, RawDataList=3DLocalTokenNumb= erTable) GuidTable =3D Dict['GUID_STRUCTURE'] - DbGuidTable =3D DbItemList(16, RawDataList =3D GuidTable) + DbGuidTable =3D DbItemList(16, RawDataList=3DGuidTable) StringHeadValue =3D Dict['STRING_DB_VALUE'] # DbItemList to DbStringHeadTableItemList - DbStringHeadValue =3D DbStringHeadTableItemList(4, RawDataList =3D Str= ingHeadValue) + DbStringHeadValue =3D DbStringHeadTableItemList( + 4, RawDataList=3DStringHeadValue) VariableTable =3D Dict['VARIABLE_DB_VALUE'] - DbVariableTable =3D DbVariableTableItemList(20, RawDataList =3D Variab= leTable) + DbVariableTable =3D DbVariableTableItemList(20, RawDataList=3DVariable= Table) NumberOfSkuEnabledPcd =3D GetIntegerValue(Dict['SKU_HEAD_SIZE']) =20 - Dict['STRING_TABLE_DB_VALUE'] =3D [StringArrayToList(x) for x in Dict[= 'STRING_TABLE_VALUE']] + Dict['STRING_TABLE_DB_VALUE'] =3D [ + StringArrayToList(x) for x in Dict['STRING_TABLE_VALUE']] =20 StringTableValue =3D Dict['STRING_TABLE_DB_VALUE'] # when calcute the offset, should use StringTableLen instead of String= TableValue, as string maximum len may be different with actual len StringTableLen =3D Dict['STRING_TABLE_LENGTH'] - DbStringTableLen =3D DbStringItemList(0, RawDataList =3D StringTableVa= lue, LenList =3D StringTableLen) - + DbStringTableLen =3D DbStringItemList( + 0, RawDataList=3DStringTableValue, LenList=3DStringTableLen) =20 PcdTokenTable =3D Dict['PCD_TOKENSPACE'] PcdTokenLen =3D Dict['PCD_TOKENSPACE_LENGTH'] PcdTokenTableValue =3D [StringArrayToList(x) for x in Dict['PCD_TOKENS= PACE']] - DbPcdTokenTable =3D DbStringItemList(0, RawDataList =3D PcdTokenTableV= alue, LenList =3D PcdTokenLen) + DbPcdTokenTable =3D DbStringItemList( + 0, RawDataList=3DPcdTokenTableValue, LenList=3DPcdTokenLen) =20 PcdCNameTable =3D Dict['PCD_CNAME'] PcdCNameLen =3D Dict['PCD_CNAME_LENGTH'] PcdCNameTableValue =3D [StringArrayToList(x) for x in Dict['PCD_CNAME'= ]] - DbPcdCNameTable =3D DbStringItemList(0, RawDataList =3D PcdCNameTableV= alue, LenList =3D PcdCNameLen) + DbPcdCNameTable =3D DbStringItemList( + 0, RawDataList=3DPcdCNameTableValue, LenList=3DPcdCNameLen) =20 PcdNameOffsetTable =3D Dict['PCD_NAME_OFFSET'] - DbPcdNameOffsetTable =3D DbItemList(4, RawDataList =3D PcdNameOffsetTa= ble) + DbPcdNameOffsetTable =3D DbItemList(4, RawDataList=3DPcdNameOffsetTabl= e) =20 - SizeTableValue =3D list(zip(Dict['SIZE_TABLE_MAXIMUM_LENGTH'], Dict['S= IZE_TABLE_CURRENT_LENGTH'])) - DbSizeTableValue =3D DbSizeTableItemList(2, RawDataList =3D SizeTableV= alue) + SizeTableValue =3D list( + zip(Dict['SIZE_TABLE_MAXIMUM_LENGTH'], Dict['SIZE_TABLE_CURRENT_LE= NGTH'])) + DbSizeTableValue =3D DbSizeTableItemList(2, RawDataList=3DSizeTableVal= ue) InitValueUint16 =3D Dict['INIT_DB_VALUE_UINT16'] - DbInitValueUint16 =3D DbComItemList(2, RawDataList =3D InitValueUint16) + DbInitValueUint16 =3D DbComItemList(2, RawDataList=3DInitValueUint16) VardefValueUint16 =3D Dict['VARDEF_DB_VALUE_UINT16'] - DbVardefValueUint16 =3D DbItemList(2, RawDataList =3D VardefValueUint1= 6) + DbVardefValueUint16 =3D DbItemList(2, RawDataList=3DVardefValueUint16) InitValueUint8 =3D Dict['INIT_DB_VALUE_UINT8'] - DbInitValueUint8 =3D DbComItemList(1, RawDataList =3D InitValueUint8) + DbInitValueUint8 =3D DbComItemList(1, RawDataList=3DInitValueUint8) VardefValueUint8 =3D Dict['VARDEF_DB_VALUE_UINT8'] - DbVardefValueUint8 =3D DbItemList(1, RawDataList =3D VardefValueUint8) + DbVardefValueUint8 =3D DbItemList(1, RawDataList=3DVardefValueUint8) InitValueBoolean =3D Dict['INIT_DB_VALUE_BOOLEAN'] - DbInitValueBoolean =3D DbComItemList(1, RawDataList =3D InitValueBoole= an) + DbInitValueBoolean =3D DbComItemList(1, RawDataList=3DInitValueBoolean) VardefValueBoolean =3D Dict['VARDEF_DB_VALUE_BOOLEAN'] - DbVardefValueBoolean =3D DbItemList(1, RawDataList =3D VardefValueBool= ean) + DbVardefValueBoolean =3D DbItemList(1, RawDataList=3DVardefValueBoolea= n) SkuidValue =3D Dict['SKUID_VALUE'] - DbSkuidValue =3D DbItemList(8, RawDataList =3D SkuidValue) - - + DbSkuidValue =3D DbItemList(8, RawDataList=3DSkuidValue) =20 # Unit Db Items UnInitValueUint64 =3D Dict['UNINIT_GUID_DECL_UINT64'] - DbUnInitValueUint64 =3D DbItemList(8, RawDataList =3D UnInitValueUint6= 4) + DbUnInitValueUint64 =3D DbItemList(8, RawDataList=3DUnInitValueUint64) UnInitValueUint32 =3D Dict['UNINIT_GUID_DECL_UINT32'] - DbUnInitValueUint32 =3D DbItemList(4, RawDataList =3D UnInitValueUint3= 2) + DbUnInitValueUint32 =3D DbItemList(4, RawDataList=3DUnInitValueUint32) UnInitValueUint16 =3D Dict['UNINIT_GUID_DECL_UINT16'] - DbUnInitValueUint16 =3D DbItemList(2, RawDataList =3D UnInitValueUint1= 6) + DbUnInitValueUint16 =3D DbItemList(2, RawDataList=3DUnInitValueUint16) UnInitValueUint8 =3D Dict['UNINIT_GUID_DECL_UINT8'] - DbUnInitValueUint8 =3D DbItemList(1, RawDataList =3D UnInitValueUint8) + DbUnInitValueUint8 =3D DbItemList(1, RawDataList=3DUnInitValueUint8) UnInitValueBoolean =3D Dict['UNINIT_GUID_DECL_BOOLEAN'] - DbUnInitValueBoolean =3D DbItemList(1, RawDataList =3D UnInitValueBool= ean) + DbUnInitValueBoolean =3D DbItemList(1, RawDataList=3DUnInitValueBoolea= n) PcdTokenNumberMap =3D Dict['PCD_ORDER_TOKEN_NUMBER_MAP'] =20 DbNameTotle =3D ["SkuidValue", "InitValueUint64", "VardefValueUint64"= , "InitValueUint32", "VardefValueUint32", "VpdHeadValue", "ExMapTable", - "LocalTokenNumberTable", "GuidTable", "StringHeadValue", "= PcdNameOffsetTable", "VariableTable", "StringTableLen", "PcdTokenTable", "P= cdCNameTable", - "SizeTableValue", "InitValueUint16", "VardefValueUint16", "= InitValueUint8", "VardefValueUint8", "InitValueBoolean", - "VardefValueBoolean", "UnInitValueUint64", "UnInitValueUint= 32", "UnInitValueUint16", "UnInitValueUint8", "UnInitValueBoolean"] + "LocalTokenNumberTable", "GuidTable", "StringHeadValue"= , "PcdNameOffsetTable", "VariableTable", "StringTableLen", "PcdTokenTable"= , "PcdCNameTable", + "SizeTableValue", "InitValueUint16", "VardefValueUint16= ", "InitValueUint8", "VardefValueUint8", "InitValueBoolean", + "VardefValueBoolean", "UnInitValueUint64", "UnInitValue= Uint32", "UnInitValueUint16", "UnInitValueUint8", "UnInitValueBoolean"] =20 DbTotal =3D [SkuidValue, InitValueUint64, VardefValueUint64, InitValu= eUint32, VardefValueUint32, VpdHeadValue, ExMapTable, LocalTokenNumberTable, GuidTable, StringHeadValue, PcdName= OffsetTable, VariableTable, StringTableLen, PcdTokenTable, PcdCNameTable, SizeTableValue, InitValueUint16, VardefValueUint16, InitVal= ueUint8, VardefValueUint8, InitValueBoolean, VardefValueBoolean, UnInitValueUint64, UnInitValueUint32, U= nInitValueUint16, UnInitValueUint8, UnInitValueBoolean] DbItemTotal =3D [DbSkuidValue, DbInitValueUint64, DbVardefValueUint64= , DbInitValueUint32, DbVardefValueUint32, DbVpdHeadValue, DbExMapTable, - DbLocalTokenNumberTable, DbGuidTable, DbStringHeadValue, D= bPcdNameOffsetTable, DbVariableTable, DbStringTableLen, DbPcdTokenTable, Db= PcdCNameTable, - DbSizeTableValue, DbInitValueUint16, DbVardefValueUint16, D= bInitValueUint8, DbVardefValueUint8, DbInitValueBoolean, - DbVardefValueBoolean, DbUnInitValueUint64, DbUnInitValueUin= t32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean] + DbLocalTokenNumberTable, DbGuidTable, DbStringHeadValue= , DbPcdNameOffsetTable, DbVariableTable, DbStringTableLen, DbPcdTokenTable= , DbPcdCNameTable, + DbSizeTableValue, DbInitValueUint16, DbVardefValueUint1= 6, DbInitValueUint8, DbVardefValueUint8, DbInitValueBoolean, + DbVardefValueBoolean, DbUnInitValueUint64, DbUnInitValu= eUint32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean] =20 # VardefValueBoolean is the last table in the init table items InitTableNum =3D DbNameTotle.index("VardefValueBoolean") + 1 @@ -701,7 +727,6 @@ def BuildExDataBase(Dict): break SkuIdTableOffset +=3D DbItemTotal[DbIndex].GetListSize() =20 - # Get offset of SkuValue table in the database =20 # Fix up the LocalTokenNumberTable, SkuHeader table @@ -721,22 +746,22 @@ def BuildExDataBase(Dict): =20 TokenTypeValue =3D Dict['TOKEN_TYPE'][LocalTokenNumberTableIndex] TokenTypeValue =3D GetTokenTypeValue(TokenTypeValue) - LocalTokenNumberTable[LocalTokenNumberTableIndex] =3D DbOffset|int= (TokenTypeValue) + LocalTokenNumberTable[LocalTokenNumberTableIndex] =3D DbOffset | i= nt( + TokenTypeValue) # if PCD_TYPE_SKU_ENABLED, then we need to fix up the SkuTable =20 - - - # resolve variable table offset for VariableEntries in VariableTable: skuindex =3D 0 for VariableEntryPerSku in VariableEntries: - (VariableHeadGuidIndex, VariableHeadStringIndex, SKUVariableOf= fset, VariableOffset, VariableRefTable, VariableAttribute) =3D VariableEntr= yPerSku[:] + (VariableHeadGuidIndex, VariableHeadStringIndex, SKUVariableOf= fset, + VariableOffset, VariableRefTable, VariableAttribute) =3D Vari= ableEntryPerSku[:] DbIndex =3D 0 DbOffset =3D FixedHeaderLen for DbIndex in range(len(DbTotal)): if DbTotal[DbIndex] is VariableRefTable: - DbOffset +=3D DbItemTotal[DbIndex].GetInterOffset(Vari= ableOffset) + DbOffset +=3D DbItemTotal[DbIndex].GetInterOffset( + VariableOffset) break DbOffset +=3D DbItemTotal[DbIndex].GetListSize() if DbIndex + 1 =3D=3D InitTableNum: @@ -749,8 +774,10 @@ def BuildExDataBase(Dict): skuindex +=3D 1 if DbIndex >=3D InitTableNum: assert(False) - VarAttr, VarProp =3D VariableAttributes.GetVarAttributes(Varia= bleAttribute) - VariableEntryPerSku[:] =3D (VariableHeadStringIndex, DbOffset,= VariableHeadGuidIndex, SKUVariableOffset, VarAttr, VarProp) + VarAttr, VarProp =3D VariableAttributes.GetVarAttributes( + VariableAttribute) + VariableEntryPerSku[:] =3D (VariableHeadStringIndex, DbOffset, + VariableHeadGuidIndex, SKUVariableOf= fset, VarAttr, VarProp) =20 # calculate various table offset now DbTotalLength =3D FixedHeaderLen @@ -770,17 +797,16 @@ def BuildExDataBase(Dict): elif DbItemTotal[DbIndex] is DbPcdNameOffsetTable: DbPcdNameOffset =3D DbTotalLength =20 - DbTotalLength +=3D DbItemTotal[DbIndex].GetListSize() if not Dict['PCD_INFO_FLAG']: - DbPcdNameOffset =3D 0 + DbPcdNameOffset =3D 0 LocalTokenCount =3D GetIntegerValue(Dict['LOCAL_TOKEN_NUMBER']) ExTokenCount =3D GetIntegerValue(Dict['EX_TOKEN_NUMBER']) GuidTableCount =3D GetIntegerValue(Dict['GUID_TABLE_SIZE']) SystemSkuId =3D GetIntegerValue(Dict['SYSTEM_SKU_ID_VALUE']) Pad =3D 0xDA =20 - UninitDataBaseSize =3D 0 + UninitDataBaseSize =3D 0 for Item in (DbUnInitValueUint64, DbUnInitValueUint32, DbUnInitValueUi= nt16, DbUnInitValueUint8, DbUnInitValueBoolean): UninitDataBaseSize +=3D Item.GetListSize() =20 @@ -846,7 +872,7 @@ def BuildExDataBase(Dict): =20 Index =3D 0 for Item in DbItemTotal: - Index +=3D1 + Index +=3D 1 packdata =3D Item.PackData() for i in range(len(packdata)): Buffer +=3D packdata[i:i + 1] @@ -858,20 +884,23 @@ def BuildExDataBase(Dict): break return Buffer =20 -## Create code for PCD database +# Create code for PCD database # # @param Info The ModuleAutoGen object # @param AutoGenC The TemplateString object for C code # @param AutoGenH The TemplateString object for header file # -def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): + + +def CreatePcdDatabaseCode(Info, AutoGenC, AutoGenH): if Info.PcdIsDriver =3D=3D "": return if Info.PcdIsDriver not in gPcdPhaseMap: EdkLogger.error("build", AUTOGEN_ERROR, "Not supported PcdIsDriver= type:%s" % Info.PcdIsDriver, ExtraData=3D"[%s]" % str(Info)) =20 - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer =3D NewCreatePcdDa= tabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI') + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer =3D NewCreatePcdDa= tabasePhaseSpecificAutoGen( + Info.PlatformInfo, 'PEI') AutoGenH.Append(AdditionalAutoGenH.String) =20 Phase =3D gPcdPhaseMap[Info.PcdIsDriver] @@ -879,26 +908,32 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH): AutoGenC.Append(AdditionalAutoGenC.String) =20 if Phase =3D=3D 'DXE': - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer =3D NewCreateP= cdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase) + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer =3D NewCreateP= cdDatabasePhaseSpecificAutoGen( + Info.PlatformInfo, Phase) AutoGenH.Append(AdditionalAutoGenH.String) AutoGenC.Append(AdditionalAutoGenC.String) =20 if Info.IsBinaryModule: - DbFileName =3D os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIR= ECTORY, Phase + "PcdDataBase.raw") + DbFileName =3D os.path.join( + Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdData= Base.raw") else: DbFileName =3D os.path.join(Info.OutputDir, Phase + "PcdDataBase.r= aw") DbFile =3D BytesIO() DbFile.write(PcdDbBuffer) Changed =3D SaveFileOnChange(DbFileName, DbFile.getvalue(), True) + + def CreatePcdDataBase(PcdDBData): delta =3D {} for skuname, skuid in PcdDBData: if len(PcdDBData[(skuname, skuid)][1]) !=3D len(PcdDBData[(TAB_DEF= AULT, "0")][1]): - EdkLogger.error("build", AUTOGEN_ERROR, "The size of each sku = in one pcd are not same") + EdkLogger.error("build", AUTOGEN_ERROR, + "The size of each sku in one pcd are not same") for skuname, skuid in PcdDBData: if skuname =3D=3D TAB_DEFAULT: continue - delta[(skuname, skuid)] =3D [(index, data, hex(data)) for index, d= ata in enumerate(PcdDBData[(skuname, skuid)][1]) if PcdDBData[(skuname, sku= id)][1][index] !=3D PcdDBData[(TAB_DEFAULT, "0")][1][index]] + delta[(skuname, skuid)] =3D [(index, data, hex(data)) for index, d= ata in enumerate(PcdDBData[( + skuname, skuid)][1]) if PcdDBData[(skuname, skuid)][1][index] = !=3D PcdDBData[(TAB_DEFAULT, "0")][1][index]] databasebuff =3D PcdDBData[(TAB_DEFAULT, "0")][0] =20 for skuname, skuid in delta: @@ -922,25 +957,30 @@ def CreatePcdDataBase(PcdDBData): =20 return newbuffer =20 + def CreateVarCheckBin(VarCheckTab): return VarCheckTab[(TAB_DEFAULT, "0")] =20 + def CreateAutoGen(PcdDriverAutoGenData): autogenC =3D TemplateString() for skuname, skuid in PcdDriverAutoGenData: autogenC.Append("//SKUID: %s" % skuname) autogenC.Append(PcdDriverAutoGenData[(skuname, skuid)][1].String) return (PcdDriverAutoGenData[(skuname, skuid)][0], autogenC) + + def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform, Phase): def prune_sku(pcd, skuname): new_pcd =3D copy.deepcopy(pcd) - new_pcd.SkuInfoList =3D {skuname:pcd.SkuInfoList[skuname]} + new_pcd.SkuInfoList =3D {skuname: pcd.SkuInfoList[skuname]} new_pcd.isinit =3D 'INIT' if new_pcd.DatumType in TAB_PCD_NUMERIC_TYPES: for skuobj in pcd.SkuInfoList.values(): if skuobj.DefaultValue: - defaultvalue =3D int(skuobj.DefaultValue, 16) if skuob= j.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue, 10) - if defaultvalue !=3D 0: + defaultvalue =3D int(skuobj.DefaultValue, 16) if skuob= j.DefaultValue.upper( + ).startswith("0X") else int(skuobj.DefaultValue, 10) + if defaultvalue !=3D 0: new_pcd.isinit =3D "INIT" break elif skuobj.VariableName: @@ -950,64 +990,72 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform= , Phase): new_pcd.isinit =3D "UNINIT" return new_pcd DynamicPcds =3D Platform.DynamicPcdList - DynamicPcdSet_Sku =3D {(SkuName, skuobj.SkuId):[] for pcd in DynamicPc= ds for (SkuName, skuobj) in pcd.SkuInfoList.items() } + DynamicPcdSet_Sku =3D {(SkuName, skuobj.SkuId): [] for pcd in DynamicP= cds for ( + SkuName, skuobj) in pcd.SkuInfoList.items()} for skuname, skuid in DynamicPcdSet_Sku: - DynamicPcdSet_Sku[(skuname, skuid)] =3D [prune_sku(pcd, skuname) f= or pcd in DynamicPcds] + DynamicPcdSet_Sku[(skuname, skuid)] =3D [ + prune_sku(pcd, skuname) for pcd in DynamicPcds] PcdDBData =3D {} PcdDriverAutoGenData =3D {} VarCheckTableData =3D {} if DynamicPcdSet_Sku: for skuname, skuid in DynamicPcdSet_Sku: - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckT= ab =3D CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdSet_Sku[(= skuname, skuid)], Phase) + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckT= ab =3D CreatePcdDatabasePhaseSpecificAutoGen( + Platform, DynamicPcdSet_Sku[(skuname, skuid)], Phase) final_data =3D () for item in range(len(PcdDbBuffer)): final_data +=3D unpack("B", PcdDbBuffer[item:item+1]) PcdDBData[(skuname, skuid)] =3D (PcdDbBuffer, final_data) - PcdDriverAutoGenData[(skuname, skuid)] =3D (AdditionalAutoGenH= , AdditionalAutoGenC) + PcdDriverAutoGenData[(skuname, skuid)] =3D ( + AdditionalAutoGenH, AdditionalAutoGenC) VarCheckTableData[(skuname, skuid)] =3D VarCheckTab if Platform.Platform.VarCheckFlag: dest =3D os.path.join(Platform.BuildDir, TAB_FV_DIRECTORY) VarCheckTable =3D CreateVarCheckBin(VarCheckTableData) VarCheckTable.dump(dest, Phase) - AdditionalAutoGenH, AdditionalAutoGenC =3D CreateAutoGen(PcdDrive= rAutoGenData) + AdditionalAutoGenH, AdditionalAutoGenC =3D CreateAutoGen( + PcdDriverAutoGenData) else: - AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckTab = =3D CreatePcdDatabasePhaseSpecificAutoGen (Platform, {}, Phase) + AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckTab = =3D CreatePcdDatabasePhaseSpecificAutoGen( + Platform, {}, Phase) final_data =3D () for item in range(len(PcdDbBuffer)): final_data +=3D unpack("B", PcdDbBuffer[item:item + 1]) PcdDBData[(TAB_DEFAULT, "0")] =3D (PcdDbBuffer, final_data) =20 return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDB= Data) -## Create PCD database in DXE or PEI phase +# Create PCD database in DXE or PEI phase # # @param Platform The platform object # @retval tuple Two TemplateString objects for C code and head= er file, # respectively # -def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase= ): + + +def CreatePcdDatabasePhaseSpecificAutoGen(Platform, DynamicPcdList, Phase): AutoGenC =3D TemplateString() AutoGenH =3D TemplateString() =20 Dict =3D { - 'PHASE' : Phase, - 'SERVICE_DRIVER_VERSION' : DATABASE_VERSION, - 'GUID_TABLE_SIZE' : '1U', - 'STRING_TABLE_SIZE' : '1U', - 'SKUID_TABLE_SIZE' : '1U', - 'LOCAL_TOKEN_NUMBER_TABLE_SIZE' : '0U', - 'LOCAL_TOKEN_NUMBER' : '0U', - 'EXMAPPING_TABLE_SIZE' : '1U', - 'EX_TOKEN_NUMBER' : '0U', - 'SIZE_TABLE_SIZE' : '2U', - 'SKU_HEAD_SIZE' : '1U', - 'GUID_TABLE_EMPTY' : 'TRUE', - 'STRING_TABLE_EMPTY' : 'TRUE', - 'SKUID_TABLE_EMPTY' : 'TRUE', - 'DATABASE_EMPTY' : 'TRUE', - 'EXMAP_TABLE_EMPTY' : 'TRUE', - 'PCD_DATABASE_UNINIT_EMPTY' : ' UINT8 dummy; /* PCD_DATABASE= _UNINIT is empty */', - 'SYSTEM_SKU_ID' : ' SKU_ID SystemSkuI= d;', - 'SYSTEM_SKU_ID_VALUE' : '0U' + 'PHASE': Phase, + 'SERVICE_DRIVER_VERSION': DATABASE_VERSION, + 'GUID_TABLE_SIZE': '1U', + 'STRING_TABLE_SIZE': '1U', + 'SKUID_TABLE_SIZE': '1U', + 'LOCAL_TOKEN_NUMBER_TABLE_SIZE': '0U', + 'LOCAL_TOKEN_NUMBER': '0U', + 'EXMAPPING_TABLE_SIZE': '1U', + 'EX_TOKEN_NUMBER': '0U', + 'SIZE_TABLE_SIZE': '2U', + 'SKU_HEAD_SIZE': '1U', + 'GUID_TABLE_EMPTY': 'TRUE', + 'STRING_TABLE_EMPTY': 'TRUE', + 'SKUID_TABLE_EMPTY': 'TRUE', + 'DATABASE_EMPTY': 'TRUE', + 'EXMAP_TABLE_EMPTY': 'TRUE', + 'PCD_DATABASE_UNINIT_EMPTY': ' UINT8 dummy; /* PCD_DATABASE_UNIN= IT is empty */', + 'SYSTEM_SKU_ID': ' SKU_ID SystemSkuId;', + 'SYSTEM_SKU_ID_VALUE': '0U' } =20 SkuObj =3D Platform.Platform.SkuIdMgr @@ -1017,20 +1065,20 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): =20 for DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Dict['VARDEF_CNAME_' + DatumType] =3D [] - Dict['VARDEF_GUID_' + DatumType] =3D [] + Dict['VARDEF_GUID_' + DatumType] =3D [] Dict['VARDEF_SKUID_' + DatumType] =3D [] Dict['VARDEF_VALUE_' + DatumType] =3D [] Dict['VARDEF_DB_VALUE_' + DatumType] =3D [] for Init in ['INIT', 'UNINIT']: - Dict[Init+'_CNAME_DECL_' + DatumType] =3D [] - Dict[Init+'_GUID_DECL_' + DatumType] =3D [] + Dict[Init+'_CNAME_DECL_' + DatumType] =3D [] + Dict[Init+'_GUID_DECL_' + DatumType] =3D [] Dict[Init+'_NUMSKUS_DECL_' + DatumType] =3D [] - Dict[Init+'_VALUE_' + DatumType] =3D [] + Dict[Init+'_VALUE_' + DatumType] =3D [] Dict[Init+'_DB_VALUE_'+DatumType] =3D [] =20 for Type in ['STRING_HEAD', 'VPD_HEAD', 'VARIABLE_HEAD']: - Dict[Type + '_CNAME_DECL'] =3D [] - Dict[Type + '_GUID_DECL'] =3D [] + Dict[Type + '_CNAME_DECL'] =3D [] + Dict[Type + '_GUID_DECL'] =3D [] Dict[Type + '_NUMSKUS_DECL'] =3D [] Dict[Type + '_VALUE'] =3D [] =20 @@ -1039,23 +1087,23 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): Dict['VARIABLE_DB_VALUE'] =3D [] =20 Dict['STRING_TABLE_INDEX'] =3D [] - Dict['STRING_TABLE_LENGTH'] =3D [] + Dict['STRING_TABLE_LENGTH'] =3D [] Dict['STRING_TABLE_CNAME'] =3D [] - Dict['STRING_TABLE_GUID'] =3D [] + Dict['STRING_TABLE_GUID'] =3D [] Dict['STRING_TABLE_VALUE'] =3D [] Dict['STRING_TABLE_DB_VALUE'] =3D [] =20 Dict['SIZE_TABLE_CNAME'] =3D [] - Dict['SIZE_TABLE_GUID'] =3D [] - Dict['SIZE_TABLE_CURRENT_LENGTH'] =3D [] - Dict['SIZE_TABLE_MAXIMUM_LENGTH'] =3D [] + Dict['SIZE_TABLE_GUID'] =3D [] + Dict['SIZE_TABLE_CURRENT_LENGTH'] =3D [] + Dict['SIZE_TABLE_MAXIMUM_LENGTH'] =3D [] =20 Dict['EXMAPPING_TABLE_EXTOKEN'] =3D [] Dict['EXMAPPING_TABLE_LOCAL_TOKEN'] =3D [] Dict['EXMAPPING_TABLE_GUID_INDEX'] =3D [] =20 Dict['GUID_STRUCTURE'] =3D [] - Dict['SKUID_VALUE'] =3D [0] # init Dict length + Dict['SKUID_VALUE'] =3D [0] # init Dict length Dict['VARDEF_HEADER'] =3D [] =20 Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] =3D [] @@ -1084,7 +1132,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): GuidList =3D [] VarCheckTab =3D VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER() i =3D 0 - ReorderedDynPcdList =3D GetOrderedDynamicPcdList(DynamicPcdList, Platf= orm.PcdTokenNumber) + ReorderedDynPcdList =3D GetOrderedDynamicPcdList( + DynamicPcdList, Platform.PcdTokenNumber) for item in ReorderedDynPcdList: if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_U= INT64, TAB_VOID, "BOOLEAN"]: item.DatumType =3D TAB_VOID @@ -1098,7 +1147,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.Mix= edPcd[PcdItem]: CName =3D PcdItem[0] =20 - EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName= , TokenSpaceGuidCName, Pcd.Phase, Phase)) + EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % + (CName, TokenSpaceGuidCName, Pcd.Phase, Phase)) =20 if Pcd.Phase =3D=3D 'PEI': NumberOfPeiLocalTokens +=3D 1 @@ -1111,7 +1161,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): # TODO: need GetGuidValue() definition # TokenSpaceGuidStructure =3D Pcd.TokenSpaceGuidValue - TokenSpaceGuid =3D GuidStructureStringToGuidValueName(TokenSpaceGu= idStructure) + TokenSpaceGuid =3D GuidStructureStringToGuidValueName( + TokenSpaceGuidStructure) if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if TokenSpaceGuid not in GuidList: GuidList.append(TokenSpaceGuid) @@ -1149,17 +1200,20 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): if SkuId is None or SkuId =3D=3D '': continue =20 - SkuIdIndex +=3D 1 =20 if len(Sku.VariableName) > 0: VariableGuidStructure =3D Sku.VariableGuidValue - VariableGuid =3D GuidStructureStringToGuidValueName(Variab= leGuidStructure) + VariableGuid =3D GuidStructureStringToGuidValueName( + VariableGuidStructure) if Platform.Platform.VarCheckFlag: - var_check_obj =3D VAR_CHECK_PCD_VARIABLE_TAB(VariableG= uidStructure, StringToArray(Sku.VariableName)) + var_check_obj =3D VAR_CHECK_PCD_VARIABLE_TAB( + VariableGuidStructure, StringToArray(Sku.VariableN= ame)) try: - var_check_obj.push_back(GetValidationObject(Pcd, S= ku.VariableOffset)) - VarAttr, _ =3D VariableAttributes.GetVarAttributes= (Sku.VariableAttribute) + var_check_obj.push_back( + GetValidationObject(Pcd, Sku.VariableOffset)) + VarAttr, _ =3D VariableAttributes.GetVarAttributes( + Sku.VariableAttribute) var_check_obj.SetAttributes(VarAttr) var_check_obj.UpdateSize() VarCheckTab.push_back(var_check_obj) @@ -1171,11 +1225,12 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): ValidInfo =3D Pcd.validlists[0] if ValidInfo: EdkLogger.error("build", PCD_VALIDATION_INFO_E= RROR, - "The PCD '%s.%s' Validatio= n information defined in DEC file has incorrect format." % (Pcd.TokenSpaceG= uidCName, Pcd.TokenCName), - ExtraData =3D "[%s]" % str= (ValidInfo)) + "The PCD '%s.%s' Validation in= formation defined in DEC file has incorrect format." % ( + Pcd.TokenSpaceGuidCName, P= cd.TokenCName), + ExtraData=3D"[%s]" % str(Valid= Info)) else: EdkLogger.error("build", PCD_VALIDATION_INFO_E= RROR, - "The PCD '%s.%s' Validatio= n information defined in DEC file has incorrect format." % (Pcd.TokenSpaceG= uidCName, Pcd.TokenCName)) + "The PCD '%s.%s' Validation in= formation defined in DEC file has incorrect format." % (Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName)) Pcd.TokenTypeList.append('PCD_TYPE_HII') Pcd.InitString =3D 'INIT' # Store all variable names of one HII PCD under different = SKU to stringTable @@ -1184,9 +1239,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform,= DynamicPcdList, Phase): VariableNameStructure =3D StringToArray(Sku.VariableName) =20 # Make pointer of VaraibleName(HII PCD) 2 bytes aligned - VariableNameStructureBytes =3D VariableNameStructure.lstri= p("{").rstrip("}").split(",") + VariableNameStructureBytes =3D VariableNameStructure.lstri= p( + "{").rstrip("}").split(",") if len(VariableNameStructureBytes) % 2: - VariableNameStructure =3D "{%s,0x00}" % ",".join(Varia= bleNameStructureBytes) + VariableNameStructure =3D "{%s,0x00}" % ",".join( + VariableNameStructureBytes) =20 if VariableNameStructure not in Dict['STRING_TABLE_VALUE']: Dict['STRING_TABLE_CNAME'].append(CName) @@ -1194,16 +1251,19 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): if StringTableIndex =3D=3D 0: Dict['STRING_TABLE_INDEX'].append('') else: - Dict['STRING_TABLE_INDEX'].append('_%d' % StringTa= bleIndex) - VarNameSize =3D len(VariableNameStructure.replace(',',= ' ').split()) - Dict['STRING_TABLE_LENGTH'].append(VarNameSize ) + Dict['STRING_TABLE_INDEX'].append( + '_%d' % StringTableIndex) + VarNameSize =3D len( + VariableNameStructure.replace(',', ' ').split()) + Dict['STRING_TABLE_LENGTH'].append(VarNameSize) Dict['STRING_TABLE_VALUE'].append(VariableNameStructur= e) StringHeadOffsetList.append(str(StringTableSize) + 'U') VarStringDbOffsetList =3D [] VarStringDbOffsetList.append(StringTableSize) Dict['STRING_DB_VALUE'].append(VarStringDbOffsetList) StringTableIndex +=3D 1 - StringTableSize +=3D len(VariableNameStructure.replace= (',', ' ').split()) + StringTableSize +=3D len( + VariableNameStructure.replace(',', ' ').split()) VariableHeadStringIndex =3D 0 for Index in range(Dict['STRING_TABLE_VALUE'].index(Variab= leNameStructure)): VariableHeadStringIndex +=3D Dict['STRING_TABLE_LENGTH= '][Index] @@ -1220,32 +1280,38 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): if "PCD_TYPE_STRING" in Pcd.TokenTypeList: VariableHeadValueList.append('%dU, offsetof(%s_PCD_DAT= ABASE, Init.%s_%s), %dU, %sU' % (VariableHeadStringIndex,= Phase, CName, TokenSpaceGuid, - VariableHeadGuidIndex, Sk= u.VariableOffset)) + VariableHeadGuidIndex, S= ku.VariableOffset)) else: VariableHeadValueList.append('%dU, offsetof(%s_PCD_DAT= ABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' % (VariableHeadStringIndex,= Phase, CName, TokenSpaceGuid, SkuIdIndex, - VariableHeadGuidIndex, Sk= u.VariableOffset)) + VariableHeadGuidIndex, S= ku.VariableOffset)) Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName) Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid) Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex) - if "PCD_TYPE_STRING" in Pcd.TokenTypeList: - Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d= ]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex)) + if "PCD_TYPE_STRING" in Pcd.TokenTypeList: + Dict['VARDEF_VALUE_' + Pcd.DatumType].append( + "%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, Sku= IdIndex)) else: # # ULL (for UINT64) or U(other integer type) should be = append to avoid # warning under linux building environment. # - Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiD= efaultValue) + Dict['VARDEF_DB_VALUE_' + + Pcd.DatumType].append(Sku.HiiDefaultValue) =20 if Pcd.DatumType =3D=3D TAB_UINT64: - Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.Hii= DefaultValue + "ULL") + Dict['VARDEF_VALUE_' + + Pcd.DatumType].append(Sku.HiiDefaultValue + "= ULL") elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UIN= T8): - Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.Hii= DefaultValue + "U") + Dict['VARDEF_VALUE_' + + Pcd.DatumType].append(Sku.HiiDefaultValue + "= U") elif Pcd.DatumType =3D=3D "BOOLEAN": if eval(Sku.HiiDefaultValue) in [1, 0]: - Dict['VARDEF_VALUE_'+Pcd.DatumType].append(str= (eval(Sku.HiiDefaultValue)) + "U") + Dict['VARDEF_VALUE_'+Pcd.DatumType].append( + str(eval(Sku.HiiDefaultValue)) + "U") else: - Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.Hii= DefaultValue) + Dict['VARDEF_VALUE_' + + Pcd.DatumType].append(Sku.HiiDefaultValue) =20 # construct the VariableHeader value if "PCD_TYPE_STRING" in Pcd.TokenTypeList: @@ -1260,9 +1326,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform,= DynamicPcdList, Phase): (VariableHeadGuidIndex, V= ariableHeadStringIndex, Sku.VariableOffset, Phase, CName, TokenSpace= Guid, SkuIdIndex)) # the Pcd default value was filled before - VariableOffset =3D len(Dict['VARDEF_DB_VALUE_' + Pcd.D= atumType]) - 1 + VariableOffset =3D len( + Dict['VARDEF_DB_VALUE_' + Pcd.DatumType]) - 1 VariableRefTable =3D Dict['VARDEF_DB_VALUE_' + Pcd.Dat= umType] - VariableDbValueList.append([VariableHeadGuidIndex, Variabl= eHeadStringIndex, Sku.VariableOffset, VariableOffset, VariableRefTable, Sku= .VariableAttribute]) + VariableDbValueList.append([VariableHeadGuidIndex, Variabl= eHeadStringIndex, + Sku.VariableOffset, VariableOff= set, VariableRefTable, Sku.VariableAttribute]) =20 elif Sku.VpdOffset !=3D '': Pcd.TokenTypeList.append('PCD_TYPE_VPD') @@ -1289,19 +1357,27 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): if StringTableIndex =3D=3D 0: Dict['STRING_TABLE_INDEX'].append('') else: - Dict['STRING_TABLE_INDEX'].append('_%d' % StringTa= bleIndex) + Dict['STRING_TABLE_INDEX'].append( + '_%d' % StringTableIndex) if Sku.DefaultValue[0] =3D=3D 'L': - DefaultValueBinStructure =3D StringToArray(Sku.Def= aultValue) - Size =3D len(DefaultValueBinStructure.replace(',',= ' ').split()) - Dict['STRING_TABLE_VALUE'].append(DefaultValueBinS= tructure) + DefaultValueBinStructure =3D StringToArray( + Sku.DefaultValue) + Size =3D len(DefaultValueBinStructure.replace( + ',', ' ').split()) + Dict['STRING_TABLE_VALUE'].append( + DefaultValueBinStructure) elif Sku.DefaultValue[0] =3D=3D '"': - DefaultValueBinStructure =3D StringToArray(Sku.Def= aultValue) + DefaultValueBinStructure =3D StringToArray( + Sku.DefaultValue) Size =3D len(Sku.DefaultValue) - 2 + 1 - Dict['STRING_TABLE_VALUE'].append(DefaultValueBinS= tructure) + Dict['STRING_TABLE_VALUE'].append( + DefaultValueBinStructure) elif Sku.DefaultValue[0] =3D=3D '{': - DefaultValueBinStructure =3D StringToArray(Sku.Def= aultValue) + DefaultValueBinStructure =3D StringToArray( + Sku.DefaultValue) Size =3D len(Sku.DefaultValue.split(",")) - Dict['STRING_TABLE_VALUE'].append(DefaultValueBinS= tructure) + Dict['STRING_TABLE_VALUE'].append( + DefaultValueBinStructure) =20 StringHeadOffsetList.append(str(StringTableSize) + 'U') StringDbOffsetList.append(StringTableSize) @@ -1310,8 +1386,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): if MaxDatumSize < Size: if Pcd.MaxSizeUserSet: EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* typ= e PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuid= CName, Pcd.TokenCName), - ExtraData=3D"[%s]" % str(Platf= orm)) + "The maximum size of VOID*= type PCD '%s.%s' is less than its actual size occupied." % ( + Pcd.TokenSpaceGuidCNam= e, Pcd.TokenCName), + ExtraData=3D"[%s]" % str(P= latform)) else: MaxDatumSize =3D Size else: @@ -1351,16 +1428,16 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): if Pcd.DatumType =3D=3D TAB_VOID: Dict['SIZE_TABLE_CNAME'].append(CName) Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid) - Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize)= + 'U') + Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append( + str(Pcd.MaxDatumSize) + 'U') Dict['SIZE_TABLE_CURRENT_LENGTH'].append(VoidStarTypeCurrSize) =20 - - if 'PCD_TYPE_HII' in Pcd.TokenTypeList: Dict['VARIABLE_HEAD_CNAME_DECL'].append(CName) Dict['VARIABLE_HEAD_GUID_DECL'].append(TokenSpaceGuid) Dict['VARIABLE_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList)) - Dict['VARIABLE_HEAD_VALUE'].append('{ %s }\n' % ' },\n { '.= join(VariableHeadValueList)) + Dict['VARIABLE_HEAD_VALUE'].append( + '{ %s }\n' % ' },\n { '.join(VariableHeadValueList)) Dict['VARDEF_HEADER'].append('_Variable_Header') Dict['VARIABLE_DB_VALUE'].append(VariableDbValueList) else: @@ -1369,7 +1446,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): Dict['VPD_HEAD_CNAME_DECL'].append(CName) Dict['VPD_HEAD_GUID_DECL'].append(TokenSpaceGuid) Dict['VPD_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList)) - Dict['VPD_HEAD_VALUE'].append('{ %s }' % ' }, { '.join(VpdHead= OffsetList)) + Dict['VPD_HEAD_VALUE'].append( + '{ %s }' % ' }, { '.join(VpdHeadOffsetList)) Dict['VPD_DB_VALUE'].append(VpdDbOffsetList) if 'PCD_TYPE_STRING' in Pcd.TokenTypeList: Dict['STRING_HEAD_CNAME_DECL'].append(CName) @@ -1377,28 +1455,34 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): Dict['STRING_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList)) Dict['STRING_HEAD_VALUE'].append(', '.join(StringHeadOffsetLis= t)) Dict['STRING_DB_VALUE'].append(StringDbOffsetList) - PCD_STRING_INDEX_MAP[len(Dict['STRING_HEAD_CNAME_DECL']) -1 ] = =3D len(Dict['STRING_DB_VALUE']) -1 + PCD_STRING_INDEX_MAP[len( + Dict['STRING_HEAD_CNAME_DECL']) - 1] =3D len(Dict['STRING_= DB_VALUE']) - 1 if 'PCD_TYPE_DATA' in Pcd.TokenTypeList: Dict[Pcd.InitString+'_CNAME_DECL_'+Pcd.DatumType].append(CName) - Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType].append(TokenS= paceGuid) - Dict[Pcd.InitString+'_NUMSKUS_DECL_'+Pcd.DatumType].append(len= (Pcd.SkuInfoList)) + Dict[Pcd.InitString+'_GUID_DECL_' + + Pcd.DatumType].append(TokenSpaceGuid) + Dict[Pcd.InitString+'_NUMSKUS_DECL_' + + Pcd.DatumType].append(len(Pcd.SkuInfoList)) if Pcd.InitString =3D=3D 'UNINIT': Dict['PCD_DATABASE_UNINIT_EMPTY'] =3D '' else: - Dict[Pcd.InitString+'_VALUE_'+Pcd.DatumType].append(', '.j= oin(ValueList)) - Dict[Pcd.InitString+'_DB_VALUE_'+Pcd.DatumType].append(DbV= alueList) + Dict[Pcd.InitString+'_VALUE_' + + Pcd.DatumType].append(', '.join(ValueList)) + Dict[Pcd.InitString+'_DB_VALUE_' + + Pcd.DatumType].append(DbValueList) =20 if Phase =3D=3D 'PEI': NumberOfLocalTokens =3D NumberOfPeiLocalTokens if Phase =3D=3D 'DXE': NumberOfLocalTokens =3D NumberOfDxeLocalTokens =20 - Dict['TOKEN_INIT'] =3D ['' for x in range(NumberOfLocalTokens)] - Dict['TOKEN_CNAME'] =3D ['' for x in range(NumberOfLocalTokens)] - Dict['TOKEN_GUID'] =3D ['' for x in range(NumberOfLocalTokens)] - Dict['TOKEN_TYPE'] =3D ['' for x in range(NumberOfLocalTokens)] - Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] =3D ['' for x in range(NumberOfLoc= alTokens)] - Dict['PCD_CNAME'] =3D ['' for x in range(NumberOfLocalTokens)] + Dict['TOKEN_INIT'] =3D ['' for x in range(NumberOfLocalTokens)] + Dict['TOKEN_CNAME'] =3D ['' for x in range(NumberOfLocalTokens)] + Dict['TOKEN_GUID'] =3D ['' for x in range(NumberOfLocalTokens)] + Dict['TOKEN_TYPE'] =3D ['' for x in range(NumberOfLocalTokens)] + Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] =3D [ + '' for x in range(NumberOfLocalTokens)] + Dict['PCD_CNAME'] =3D ['' for x in range(NumberOfLocalTokens)] Dict['PCD_TOKENSPACE_MAP'] =3D ['' for x in range(NumberOfLocalTokens)] Dict['PCD_CNAME_LENGTH'] =3D [0 for x in range(NumberOfLocalTokens)] SkuEnablePcdIndex =3D 0 @@ -1408,8 +1492,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform,= DynamicPcdList, Phase): if Pcd.Phase !=3D Phase: continue =20 - TokenSpaceGuid =3D GuidStructureStringToGuidValueName(Pcd.TokenSpa= ceGuidValue) #(Platform.PackageList, TokenSpaceGuidCName)) - GeneratedTokenNumber =3D Platform.PcdTokenNumber[CName, TokenSpace= GuidCName] - 1 + # (Platform.PackageList, TokenSpaceGuidCName)) + TokenSpaceGuid =3D GuidStructureStringToGuidValueName( + Pcd.TokenSpaceGuidValue) + GeneratedTokenNumber =3D Platform.PcdTokenNumber[CName, + TokenSpaceGuidCName= ] - 1 if Phase =3D=3D 'DXE': GeneratedTokenNumber -=3D NumberOfPeiLocalTokens =20 @@ -1421,9 +1508,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform,= DynamicPcdList, Phase): if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.Mix= edPcd[PcdItem]: CName =3D PcdItem[0] =20 - EdkLogger.debug(EdkLogger.DEBUG_1, "PCD =3D %s.%s" % (CName, Token= SpaceGuidCName)) + EdkLogger.debug(EdkLogger.DEBUG_1, "PCD =3D %s.%s" % + (CName, TokenSpaceGuidCName)) EdkLogger.debug(EdkLogger.DEBUG_1, "phase =3D %s" % Phase) - EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber =3D %s" %= str(GeneratedTokenNumber)) + EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber =3D %s" % + str(GeneratedTokenNumber)) =20 # # following four Dict items hold the information for LocalTokenNum= berTable @@ -1434,47 +1523,56 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): =20 Dict['TOKEN_CNAME'][GeneratedTokenNumber] =3D CName Dict['TOKEN_GUID'][GeneratedTokenNumber] =3D TokenSpaceGuid - Dict['TOKEN_TYPE'][GeneratedTokenNumber] =3D ' | '.join(Pcd.TokenT= ypeList) + Dict['TOKEN_TYPE'][GeneratedTokenNumber] =3D ' | '.join( + Pcd.TokenTypeList) =20 if Platform.Platform.PcdInfoFlag: - TokenSpaceGuidCNameArray =3D StringToArray('"' + TokenSpaceGui= dCName + '"' ) + TokenSpaceGuidCNameArray =3D StringToArray( + '"' + TokenSpaceGuidCName + '"') if TokenSpaceGuidCNameArray not in Dict['PCD_TOKENSPACE']: Dict['PCD_TOKENSPACE'].append(TokenSpaceGuidCNameArray) - Dict['PCD_TOKENSPACE_LENGTH'].append( len(TokenSpaceGuidCN= ameArray.split(",")) ) - Dict['PCD_TOKENSPACE_MAP'][GeneratedTokenNumber] =3D Dict['PCD= _TOKENSPACE'].index(TokenSpaceGuidCNameArray) - CNameBinArray =3D StringToArray('"' + CName + '"' ) + Dict['PCD_TOKENSPACE_LENGTH'].append( + len(TokenSpaceGuidCNameArray.split(","))) + Dict['PCD_TOKENSPACE_MAP'][GeneratedTokenNumber] =3D Dict['PCD= _TOKENSPACE'].index( + TokenSpaceGuidCNameArray) + CNameBinArray =3D StringToArray('"' + CName + '"') Dict['PCD_CNAME'][GeneratedTokenNumber] =3D CNameBinArray =20 - Dict['PCD_CNAME_LENGTH'][GeneratedTokenNumber] =3D len(CNameBi= nArray.split(",")) - + Dict['PCD_CNAME_LENGTH'][GeneratedTokenNumber] =3D len( + CNameBinArray.split(",")) =20 Pcd.TokenTypeList =3D list(set(Pcd.TokenTypeList)) =20 # search the Offset and Table, used by LocalTokenNumberTableOffset if 'PCD_TYPE_HII' in Pcd.TokenTypeList: # Find index by CName, TokenSpaceGuid - Offset =3D GetMatchedIndex(CName, Dict['VARIABLE_HEAD_CNAME_DE= CL'], TokenSpaceGuid, Dict['VARIABLE_HEAD_GUID_DECL']) + Offset =3D GetMatchedIndex( + CName, Dict['VARIABLE_HEAD_CNAME_DECL'], TokenSpaceGuid, D= ict['VARIABLE_HEAD_GUID_DECL']) assert(Offset !=3D -1) Table =3D Dict['VARIABLE_DB_VALUE'] if 'PCD_TYPE_VPD' in Pcd.TokenTypeList: - Offset =3D GetMatchedIndex(CName, Dict['VPD_HEAD_CNAME_DECL'],= TokenSpaceGuid, Dict['VPD_HEAD_GUID_DECL']) + Offset =3D GetMatchedIndex( + CName, Dict['VPD_HEAD_CNAME_DECL'], TokenSpaceGuid, Dict['= VPD_HEAD_GUID_DECL']) assert(Offset !=3D -1) Table =3D Dict['VPD_DB_VALUE'] if 'PCD_TYPE_STRING' in Pcd.TokenTypeList and 'PCD_TYPE_HII' not i= n Pcd.TokenTypeList: # Find index by CName, TokenSpaceGuid - Offset =3D GetMatchedIndex(CName, Dict['STRING_HEAD_CNAME_DECL= '], TokenSpaceGuid, Dict['STRING_HEAD_GUID_DECL']) + Offset =3D GetMatchedIndex( + CName, Dict['STRING_HEAD_CNAME_DECL'], TokenSpaceGuid, Dic= t['STRING_HEAD_GUID_DECL']) Offset =3D PCD_STRING_INDEX_MAP[Offset] assert(Offset !=3D -1) Table =3D Dict['STRING_DB_VALUE'] if 'PCD_TYPE_DATA' in Pcd.TokenTypeList: # need to store whether it is in init table or not - Offset =3D GetMatchedIndex(CName, Dict[Pcd.InitString+'_CNAME_= DECL_'+Pcd.DatumType], TokenSpaceGuid, Dict[Pcd.InitString+'_GUID_DECL_'+Pc= d.DatumType]) + Offset =3D GetMatchedIndex(CName, Dict[Pcd.InitString+'_CNAME_= DECL_'+Pcd.DatumType], + TokenSpaceGuid, Dict[Pcd.InitString+'= _GUID_DECL_'+Pcd.DatumType]) assert(Offset !=3D -1) if Pcd.InitString =3D=3D 'UNINIT': - Table =3D Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType] + Table =3D Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType] else: Table =3D Dict[Pcd.InitString+'_DB_VALUE_'+Pcd.DatumType] - Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'][GeneratedTokenNumber] =3D (Off= set, Table) + Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'][GeneratedTokenNumber] =3D ( + Offset, Table) =20 # # Update VARDEF_HEADER @@ -1484,7 +1582,6 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): else: Dict['VARDEF_HEADER'][GeneratedTokenNumber] =3D '' =20 - if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: =20 if Phase =3D=3D 'DXE': @@ -1499,10 +1596,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): # to the EXMAPPING_TABLE. # =20 - Dict['EXMAPPING_TABLE_EXTOKEN'].append(str(Pcd.TokenValue) + '= U') - Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(str(GeneratedTokenN= umber + 1) + 'U') - Dict['EXMAPPING_TABLE_GUID_INDEX'].append(str(GuidList.index(T= okenSpaceGuid)) + 'U') + Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append( + str(GeneratedTokenNumber + 1) + 'U') + Dict['EXMAPPING_TABLE_GUID_INDEX'].append( + str(GuidList.index(TokenSpaceGuid)) + 'U') =20 if Platform.Platform.PcdInfoFlag: for index in range(len(Dict['PCD_TOKENSPACE_MAP'])): @@ -1515,7 +1613,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): StringTableIndex +=3D 1 for index in range(len(Dict['PCD_CNAME'])): Dict['PCD_CNAME_OFFSET'].append(StringTableSize) - Dict['PCD_NAME_OFFSET'].append(Dict['PCD_TOKENSPACE_OFFSET'][i= ndex]) + Dict['PCD_NAME_OFFSET'].append( + Dict['PCD_TOKENSPACE_OFFSET'][index]) Dict['PCD_NAME_OFFSET'].append(StringTableSize) StringTableSize +=3D Dict['PCD_CNAME_LENGTH'][index] StringTableIndex +=3D 1 @@ -1523,7 +1622,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): Dict['GUID_TABLE_EMPTY'] =3D 'FALSE' Dict['GUID_TABLE_SIZE'] =3D str(len(GuidList)) + 'U' else: - Dict['GUID_STRUCTURE'] =3D [GuidStringToGuidStructureString('00000= 000-0000-0000-0000-000000000000')] + Dict['GUID_STRUCTURE'] =3D [GuidStringToGuidStructureString( + '00000000-0000-0000-0000-000000000000')] =20 if StringTableIndex =3D=3D 0: Dict['STRING_TABLE_INDEX'].append('') @@ -1542,14 +1642,14 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append('0U') =20 if NumberOfLocalTokens !=3D 0: - Dict['DATABASE_EMPTY'] =3D 'FALSE' + Dict['DATABASE_EMPTY'] =3D 'FALSE' Dict['LOCAL_TOKEN_NUMBER_TABLE_SIZE'] =3D NumberOfLocalTokens - Dict['LOCAL_TOKEN_NUMBER'] =3D NumberOfLocalTokens + Dict['LOCAL_TOKEN_NUMBER'] =3D NumberOfLocalTokens =20 if NumberOfExTokens !=3D 0: - Dict['EXMAP_TABLE_EMPTY'] =3D 'FALSE' + Dict['EXMAP_TABLE_EMPTY'] =3D 'FALSE' Dict['EXMAPPING_TABLE_SIZE'] =3D str(NumberOfExTokens) + 'U' - Dict['EX_TOKEN_NUMBER'] =3D str(NumberOfExTokens) + 'U' + Dict['EX_TOKEN_NUMBER'] =3D str(NumberOfExTokens) + 'U' else: Dict['EXMAPPING_TABLE_EXTOKEN'].append('0U') Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append('0U') @@ -1587,11 +1687,15 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): for Count in range(len(Dict['TOKEN_CNAME'])): for Count1 in range(len(Dict['SIZE_TABLE_CNAME'])): if Dict['TOKEN_CNAME'][Count] =3D=3D Dict['SIZE_TABLE_= CNAME'][Count1] and \ - Dict['TOKEN_GUID'][Count] =3D=3D Dict['SIZE_TABLE_= GUID'][Count1]: - SizeCNameTempList.append(Dict['SIZE_TABLE_CNAME'][= Count1]) - SizeGuidTempList.append(Dict['SIZE_TABLE_GUID'][Co= unt1]) - SizeCurLenTempList.append(Dict['SIZE_TABLE_CURRENT= _LENGTH'][Count1]) - SizeMaxLenTempList.append(Dict['SIZE_TABLE_MAXIMUM= _LENGTH'][Count1]) + Dict['TOKEN_GUID'][Count] =3D=3D Dict['SIZE_TA= BLE_GUID'][Count1]: + SizeCNameTempList.append( + Dict['SIZE_TABLE_CNAME'][Count1]) + SizeGuidTempList.append( + Dict['SIZE_TABLE_GUID'][Count1]) + SizeCurLenTempList.append( + Dict['SIZE_TABLE_CURRENT_LENGTH'][Count1]) + SizeMaxLenTempList.append( + Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count1]) =20 for Count in range(len(Dict['SIZE_TABLE_CNAME'])): Dict['SIZE_TABLE_CNAME'][Count] =3D SizeCNameTempList[Coun= t] @@ -1606,10 +1710,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform= , DynamicPcdList, Phase): Buffer =3D BuildExDataBase(Dict) return AutoGenH, AutoGenC, Buffer, VarCheckTab =20 + def GetOrderedDynamicPcdList(DynamicPcdList, PcdTokenNumberList): ReorderedDyPcdList =3D [None for i in range(len(DynamicPcdList))] for Pcd in DynamicPcdList: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in PcdTokenNumberList: - ReorderedDyPcdList[PcdTokenNumberList[Pcd.TokenCName, Pcd.Toke= nSpaceGuidCName]-1] =3D Pcd + ReorderedDyPcdList[PcdTokenNumberList[Pcd.TokenCName, + Pcd.TokenSpaceGuidCName]= -1] =3D Pcd return ReorderedDyPcdList - diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/P= ython/AutoGen/GenVar.py index f2ad54ba630e..8b7ff2f66196 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -17,11 +17,13 @@ import collections import Common.DataType as DataType import Common.GlobalData as GlobalData =20 -var_info =3D collections.namedtuple("uefi_var", "pcdindex,pcdname,defaults= toragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default= _value, default_value, data_type,PcdDscLine,StructurePcd") +var_info =3D collections.namedtuple( + "uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var= _guid, var_offset,var_attribute,pcd_default_value, default_value, data_type= ,PcdDscLine,StructurePcd") NvStorageHeaderSize =3D 28 VariableHeaderSize =3D 32 AuthenticatedVariableHeaderSize =3D 60 =20 + class VariableMgr(object): def __init__(self, DefaultStoreMap, SkuIdMap): self.VarInfo =3D [] @@ -46,9 +48,11 @@ class VariableMgr(object): if not self.NVHeaderBuff: return "" self.NVHeaderBuff =3D self.NVHeaderBuff[:8] + pack("=3DQ", maxsize) - default_var_bin =3D VariableMgr.format_data(self.NVHeaderBuff + se= lf.VarDefaultBuff + self.VarDeltaBuff) + default_var_bin =3D VariableMgr.format_data( + self.NVHeaderBuff + self.VarDefaultBuff + self.VarDeltaBuff) value_str =3D "{" - default_var_bin_strip =3D [ data.strip("""'""") for data in defaul= t_var_bin] + default_var_bin_strip =3D [data.strip( + """'""") for data in default_var_bin] value_str +=3D ",".join(default_var_bin_strip) value_str +=3D "}" return value_str @@ -57,13 +61,17 @@ class VariableMgr(object): indexedvarinfo =3D collections.OrderedDict() for item in self.VarInfo: if (item.skuname, item.defaultstoragename, item.var_name, item= .var_guid) not in indexedvarinfo: - indexedvarinfo[(item.skuname, item.defaultstoragename, ite= m.var_name, item.var_guid) ] =3D [] - indexedvarinfo[(item.skuname, item.defaultstoragename, item.va= r_name, item.var_guid)].append(item) + indexedvarinfo[(item.skuname, item.defaultstoragename, + item.var_name, item.var_guid)] =3D [] + indexedvarinfo[(item.skuname, item.defaultstoragename, + item.var_name, item.var_guid)].append(item) for key in indexedvarinfo: sku_var_info_offset_list =3D indexedvarinfo[key] - sku_var_info_offset_list.sort(key=3Dlambda x:x.PcdDscLine) - FirstOffset =3D int(sku_var_info_offset_list[0].var_offset, 16= ) if sku_var_info_offset_list[0].var_offset.upper().startswith("0X") else i= nt(sku_var_info_offset_list[0].var_offset) - fisrtvalue_list =3D sku_var_info_offset_list[0].default_value.= strip("{").strip("}").split(",") + sku_var_info_offset_list.sort(key=3Dlambda x: x.PcdDscLine) + FirstOffset =3D int(sku_var_info_offset_list[0].var_offset, 16= ) if sku_var_info_offset_list[0].var_offset.upper( + ).startswith("0X") else int(sku_var_info_offset_list[0].var_of= fset) + fisrtvalue_list =3D sku_var_info_offset_list[0].default_value.= strip( + "{").strip("}").split(",") firstdata_type =3D sku_var_info_offset_list[0].data_type if firstdata_type in DataType.TAB_PCD_NUMERIC_TYPES: fisrtdata_flag =3D DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYP= E[firstdata_type]] @@ -71,12 +79,15 @@ class VariableMgr(object): fisrtvalue_list =3D [] pack_data =3D pack(fisrtdata_flag, int(fisrtdata, 0)) for data_byte in range(len(pack_data)): - fisrtvalue_list.append(hex(unpack("B", pack_data[data_= byte:data_byte + 1])[0])) + fisrtvalue_list.append( + hex(unpack("B", pack_data[data_byte:data_byte + 1]= )[0])) newvalue_list =3D ["0x00"] * FirstOffset + fisrtvalue_list =20 for var_item in sku_var_info_offset_list[1:]: - CurOffset =3D int(var_item.var_offset, 16) if var_item.var= _offset.upper().startswith("0X") else int(var_item.var_offset) - CurvalueList =3D var_item.default_value.strip("{").strip("= }").split(",") + CurOffset =3D int(var_item.var_offset, 16) if var_item.var= _offset.upper( + ).startswith("0X") else int(var_item.var_offset) + CurvalueList =3D var_item.default_value.strip( + "{").strip("}").split(",") Curdata_type =3D var_item.data_type if Curdata_type in DataType.TAB_PCD_NUMERIC_TYPES: data_flag =3D DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE= [Curdata_type]] @@ -84,15 +95,20 @@ class VariableMgr(object): CurvalueList =3D [] pack_data =3D pack(data_flag, int(data, 0)) for data_byte in range(len(pack_data)): - CurvalueList.append(hex(unpack("B", pack_data[data= _byte:data_byte + 1])[0])) + CurvalueList.append( + hex(unpack("B", pack_data[data_byte:data_byte = + 1])[0])) if CurOffset > len(newvalue_list): - newvalue_list =3D newvalue_list + ["0x00"] * (CurOffse= t - len(newvalue_list)) + CurvalueList + newvalue_list =3D newvalue_list + \ + ["0x00"] * (CurOffset - len(newvalue_list) + ) + CurvalueList else: - newvalue_list[CurOffset : CurOffset + len(CurvalueList= )] =3D CurvalueList + newvalue_list[CurOffset: CurOffset + + len(CurvalueList)] =3D CurvalueList =20 - newvaluestr =3D "{" + ",".join(newvalue_list) +"}" + newvaluestr =3D "{" + ",".join(newvalue_list) + "}" n =3D sku_var_info_offset_list[0] - indexedvarinfo[key] =3D [var_info(n.pcdindex, n.pcdname, n.de= faultstoragename, n.skuname, n.var_name, n.var_guid, "0x00", n.var_attribut= e, newvaluestr, newvaluestr, DataType.TAB_VOID,n.PcdDscLine,n.StructurePcd)] + indexedvarinfo[key] =3D [var_info(n.pcdindex, n.pcdname, n.def= aultstoragename, n.skuname, n.var_name, n.var_guid, + "0x00", n.var_attribute, newva= luestr, newvaluestr, DataType.TAB_VOID, n.PcdDscLine, n.StructurePcd)] self.VarInfo =3D [item[0] for item in list(indexedvarinfo.values()= )] =20 def process_variable_data(self): @@ -103,7 +119,8 @@ class VariableMgr(object): for item in self.VarInfo: if item.pcdindex not in indexedvarinfo: indexedvarinfo[item.pcdindex] =3D dict() - indexedvarinfo[item.pcdindex][(item.skuname, item.defaultstora= gename)] =3D item + indexedvarinfo[item.pcdindex][( + item.skuname, item.defaultstoragename)] =3D item =20 for index in indexedvarinfo: sku_var_info =3D indexedvarinfo[index] @@ -111,40 +128,52 @@ class VariableMgr(object): default_data_buffer =3D "" others_data_buffer =3D "" tail =3D None - default_sku_default =3D indexedvarinfo[index].get((DataType.TA= B_DEFAULT, DataType.TAB_DEFAULT_STORES_DEFAULT)) + default_sku_default =3D indexedvarinfo[index].get( + (DataType.TAB_DEFAULT, DataType.TAB_DEFAULT_STORES_DEFAULT= )) =20 if default_sku_default.data_type not in DataType.TAB_PCD_NUMER= IC_TYPES: - var_max_len =3D max(len(var_item.default_value.split(","))= for var_item in sku_var_info.values()) + var_max_len =3D max(len(var_item.default_value.split(",")) + for var_item in sku_var_info.values()) if len(default_sku_default.default_value.split(",")) < var= _max_len: - tail =3D ",".join("0x00" for i in range(var_max_len-le= n(default_sku_default.default_value.split(",")))) + tail =3D ",".join("0x00" for i in range( + var_max_len-len(default_sku_default.default_value.= split(",")))) =20 - default_data_buffer =3D VariableMgr.PACK_VARIABLES_DATA(defaul= t_sku_default.default_value, default_sku_default.data_type, tail) + default_data_buffer =3D VariableMgr.PACK_VARIABLES_DATA( + default_sku_default.default_value, default_sku_default.dat= a_type, tail) =20 default_data_array =3D () for item in range(len(default_data_buffer)): - default_data_array +=3D unpack("B", default_data_buffer[it= em:item + 1]) + default_data_array +=3D unpack("B", + default_data_buffer[item:item= + 1]) =20 - var_data[(DataType.TAB_DEFAULT, DataType.TAB_DEFAULT_STORES_DE= FAULT)][index] =3D (default_data_buffer, sku_var_info[(DataType.TAB_DEFAULT= , DataType.TAB_DEFAULT_STORES_DEFAULT)]) + var_data[(DataType.TAB_DEFAULT, DataType.TAB_DEFAULT_STORES_DE= FAULT)][index] =3D ( + default_data_buffer, sku_var_info[(DataType.TAB_DEFAULT, D= ataType.TAB_DEFAULT_STORES_DEFAULT)]) =20 for (skuid, defaultstoragename) in indexedvarinfo[index]: tail =3D None if (skuid, defaultstoragename) =3D=3D (DataType.TAB_DEFAUL= T, DataType.TAB_DEFAULT_STORES_DEFAULT): continue - other_sku_other =3D indexedvarinfo[index][(skuid, defaults= toragename)] + other_sku_other =3D indexedvarinfo[index][( + skuid, defaultstoragename)] =20 if default_sku_default.data_type not in DataType.TAB_PCD_N= UMERIC_TYPES: if len(other_sku_other.default_value.split(",")) < var= _max_len: - tail =3D ",".join("0x00" for i in range(var_max_le= n-len(other_sku_other.default_value.split(",")))) + tail =3D ",".join("0x00" for i in range( + var_max_len-len(other_sku_other.default_value.= split(",")))) =20 - others_data_buffer =3D VariableMgr.PACK_VARIABLES_DATA(oth= er_sku_other.default_value, other_sku_other.data_type, tail) + others_data_buffer =3D VariableMgr.PACK_VARIABLES_DATA( + other_sku_other.default_value, other_sku_other.data_ty= pe, tail) =20 others_data_array =3D () for item in range(len(others_data_buffer)): - others_data_array +=3D unpack("B", others_data_buffer[= item:item + 1]) + others_data_array +=3D unpack("B", + others_data_buffer[item:it= em + 1]) =20 - data_delta =3D VariableMgr.calculate_delta(default_data_ar= ray, others_data_array) + data_delta =3D VariableMgr.calculate_delta( + default_data_array, others_data_array) =20 - var_data[(skuid, defaultstoragename)][index] =3D (data_del= ta, sku_var_info[(skuid, defaultstoragename)]) + var_data[(skuid, defaultstoragename)][index] =3D ( + data_delta, sku_var_info[(skuid, defaultstoragename)]) return var_data =20 def new_process_varinfo(self): @@ -155,41 +184,51 @@ class VariableMgr(object): if not var_data: return [] =20 - pcds_default_data =3D var_data.get((DataType.TAB_DEFAULT, DataType= .TAB_DEFAULT_STORES_DEFAULT), {}) + pcds_default_data =3D var_data.get( + (DataType.TAB_DEFAULT, DataType.TAB_DEFAULT_STORES_DEFAULT), {= }) NvStoreDataBuffer =3D bytearray() var_data_offset =3D collections.OrderedDict() offset =3D NvStorageHeaderSize for default_data, default_info in pcds_default_data.values(): - var_name_buffer =3D VariableMgr.PACK_VARIABLE_NAME(default_inf= o.var_name) + var_name_buffer =3D VariableMgr.PACK_VARIABLE_NAME( + default_info.var_name) =20 vendorguid =3D default_info.var_guid.split('-') =20 if default_info.var_attribute: - var_attr_value, _ =3D VariableAttributes.GetVarAttributes(= default_info.var_attribute) + var_attr_value, _ =3D VariableAttributes.GetVarAttributes( + default_info.var_attribute) else: var_attr_value =3D 0x07 =20 DataBuffer =3D VariableMgr.AlignData(var_name_buffer + default= _data) =20 data_size =3D len(DataBuffer) - if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTH= ENTICATED_VARIABLE_STORE,"FALSE").upper() =3D=3D "TRUE": - offset +=3D AuthenticatedVariableHeaderSize + len(default_= info.var_name.split(",")) + if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTH= ENTICATED_VARIABLE_STORE, "FALSE").upper() =3D=3D "TRUE": + offset +=3D AuthenticatedVariableHeaderSize + \ + len(default_info.var_name.split(",")) else: - offset +=3D VariableHeaderSize + len(default_info.var_name= .split(",")) + offset +=3D VariableHeaderSize + \ + len(default_info.var_name.split(",")) var_data_offset[default_info.pcdindex] =3D offset offset +=3D data_size - len(default_info.var_name.split(",")) - if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTH= ENTICATED_VARIABLE_STORE,"FALSE").upper() =3D=3D "TRUE": - var_header_buffer =3D VariableMgr.PACK_AUTHENTICATED_VARIA= BLE_HEADER(var_attr_value, len(default_info.var_name.split(",")), len (defa= ult_data), vendorguid) + if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTH= ENTICATED_VARIABLE_STORE, "FALSE").upper() =3D=3D "TRUE": + var_header_buffer =3D VariableMgr.PACK_AUTHENTICATED_VARIA= BLE_HEADER( + var_attr_value, len(default_info.var_name.split(",")),= len(default_data), vendorguid) else: - var_header_buffer =3D VariableMgr.PACK_VARIABLE_HEADER(var= _attr_value, len(default_info.var_name.split(",")), len (default_data), ven= dorguid) + var_header_buffer =3D VariableMgr.PACK_VARIABLE_HEADER(var= _attr_value, len( + default_info.var_name.split(",")), len(default_data), = vendorguid) NvStoreDataBuffer +=3D (var_header_buffer + DataBuffer) =20 - if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTI= CATED_VARIABLE_STORE,"FALSE").upper() =3D=3D "TRUE": - variable_storage_header_buffer =3D VariableMgr.PACK_AUTHENTICA= TED_VARIABLE_STORE_HEADER(len(NvStoreDataBuffer) + 28) + if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTI= CATED_VARIABLE_STORE, "FALSE").upper() =3D=3D "TRUE": + variable_storage_header_buffer =3D VariableMgr.PACK_AUTHENTICA= TED_VARIABLE_STORE_HEADER( + len(NvStoreDataBuffer) + 28) else: - variable_storage_header_buffer =3D VariableMgr.PACK_VARIABLE_S= TORE_HEADER(len(NvStoreDataBuffer) + 28) + variable_storage_header_buffer =3D VariableMgr.PACK_VARIABLE_S= TORE_HEADER( + len(NvStoreDataBuffer) + 28) =20 - nv_default_part =3D VariableMgr.AlignData(VariableMgr.PACK_DEFAULT= _DATA(0, 0, VariableMgr.unpack_data(variable_storage_header_buffer+NvStoreD= ataBuffer)), 8) + nv_default_part =3D VariableMgr.AlignData(VariableMgr.PACK_DEFAULT= _DATA( + 0, 0, VariableMgr.unpack_data(variable_storage_header_buffer+N= vStoreDataBuffer)), 8) =20 data_delta_structure_buffer =3D bytearray() for skuname, defaultstore in var_data: @@ -200,24 +239,26 @@ class VariableMgr(object): for pcdindex in pcds_sku_data: offset =3D var_data_offset[pcdindex] delta_data, _ =3D pcds_sku_data[pcdindex] - delta_data =3D [(item[0] + offset, item[1]) for item in de= lta_data] + delta_data =3D [(item[0] + offset, item[1]) + for item in delta_data] delta_data_set.extend(delta_data) =20 - data_delta_structure_buffer +=3D VariableMgr.AlignData(self.PA= CK_DELTA_DATA(skuname, defaultstore, delta_data_set), 8) + data_delta_structure_buffer +=3D VariableMgr.AlignData( + self.PACK_DELTA_DATA(skuname, defaultstore, delta_data_set= ), 8) =20 size =3D len(nv_default_part + data_delta_structure_buffer) + 16 maxsize =3D self.VpdRegionSize if self.VpdRegionSize else size - NV_Store_Default_Header =3D VariableMgr.PACK_NV_STORE_DEFAULT_HEAD= ER(size, maxsize) + NV_Store_Default_Header =3D VariableMgr.PACK_NV_STORE_DEFAULT_HEAD= ER( + size, maxsize) =20 - self.NVHeaderBuff =3D NV_Store_Default_Header - self.VarDefaultBuff =3Dnv_default_part - self.VarDeltaBuff =3D data_delta_structure_buffer + self.NVHeaderBuff =3D NV_Store_Default_Header + self.VarDefaultBuff =3D nv_default_part + self.VarDeltaBuff =3D data_delta_structure_buffer return VariableMgr.format_data(NV_Store_Default_Header + nv_defaul= t_part + data_delta_structure_buffer) =20 - @staticmethod def format_data(data): - return [hex(item) for item in VariableMgr.unpack_data(data)] + return [hex(item) for item in VariableMgr.unpack_data(data)] =20 @staticmethod def unpack_data(data): @@ -229,7 +270,8 @@ class VariableMgr(object): @staticmethod def calculate_delta(default, theother): if len(default) - len(theother) !=3D 0: - EdkLogger.error("build", FORMAT_INVALID, 'The variable data le= ngth is not the same for the same PCD.') + EdkLogger.error("build", FORMAT_INVALID, + 'The variable data length is not the same for = the same PCD.') data_delta =3D [] for i in range(len(default)): if default[i] !=3D theother[i]: @@ -241,7 +283,8 @@ class VariableMgr(object): default_var_bin =3D self.new_process_varinfo() if default_var_bin: value_str =3D "{" - default_var_bin_strip =3D [ data.strip("""'""") for data in de= fault_var_bin] + default_var_bin_strip =3D [data.strip( + """'""") for data in default_var_bin] value_str +=3D ",".join(default_var_bin_strip) value_str +=3D "}" return value_str @@ -291,7 +334,7 @@ class VariableMgr(object): @staticmethod def PACK_VARIABLE_HEADER(attribute, namesize, datasize, vendorguid): =20 - Buffer =3D pack('=3DH', 0x55AA) # pack StartID + Buffer =3D pack('=3DH', 0x55AA) # pack StartID Buffer +=3D pack('=3DB', 0x3F) # pack State Buffer +=3D pack('=3DB', 0) # pack reserved =20 @@ -313,18 +356,18 @@ class VariableMgr(object): Buffer +=3D pack('=3DL', attribute) =20 Buffer +=3D pack('=3DQ', 0) # pack MonotonicCount - Buffer +=3D pack('=3DHBBBBBBLhBB', # pack TimeStamp - 0, # UINT16 Year - 0, # UINT8 Month - 0, # UINT8 Day - 0, # UINT8 Hour - 0, # UINT8 Minute - 0, # UINT8 Second - 0, # UINT8 Pad1 - 0, # UINT32 Nanosecond - 0, # INT16 TimeZone - 0, # UINT8 Daylight - 0) # UINT8 Pad2 + Buffer +=3D pack('=3DHBBBBBBLhBB', # pack TimeStamp + 0, # UINT16 Year + 0, # UINT8 Month + 0, # UINT8 Day + 0, # UINT8 Hour + 0, # UINT8 Minute + 0, # UINT8 Second + 0, # UINT8 Pad1 + 0, # UINT32 Nanosecond + 0, # INT16 TimeZone + 0, # UINT8 Daylight + 0) # UINT8 Pad2 Buffer +=3D pack('=3DL', 0) # pack PubKeyIndex =20 Buffer +=3D pack('=3DL', namesize) @@ -335,7 +378,7 @@ class VariableMgr(object): return Buffer =20 @staticmethod - def PACK_VARIABLES_DATA(var_value,data_type, tail =3D None): + def PACK_VARIABLES_DATA(var_value, data_type, tail=3DNone): Buffer =3D bytearray() data_len =3D 0 if data_type =3D=3D DataType.TAB_VOID: @@ -347,9 +390,10 @@ class VariableMgr(object): Buffer +=3D pack("=3DB", int(value_char, 16)) data_len +=3D len(tail.split(",")) elif data_type =3D=3D "BOOLEAN": - Buffer +=3D pack("=3DB", True) if var_value.upper() in ["TRUE"= ,"1"] else pack("=3DB", False) + Buffer +=3D pack("=3DB", True) if var_value.upper() in [ + "TRUE", "1"] else pack("=3DB", False) data_len +=3D 1 - elif data_type =3D=3D DataType.TAB_UINT8: + elif data_type =3D=3D DataType.TAB_UINT8: Buffer +=3D pack("=3DB", GetIntegerValue(var_value)) data_len +=3D 1 elif data_type =3D=3D DataType.TAB_UINT16: @@ -404,7 +448,7 @@ class VariableMgr(object): return Buffer =20 @staticmethod - def AlignData(data, align =3D 4): + def AlignData(data, align=3D4): mybuffer =3D data if (len(data) % align) > 0: for i in range(align - (len(data) % align)): diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/= Source/Python/AutoGen/IdfClassObject.py index a6b8123c2539..1526a9f01de4 100644 --- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py +++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to collect all defined strings in Image Definition fil= es # # Copyright (c) 2016, Intel Corporation. All rights reserved.
        @@ -18,53 +18,56 @@ import os from Common.GlobalData import gIdentifierPattern from .UniClassObject import StripComments =20 -IMAGE_TOKEN =3D re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE= | re.UNICODE) +IMAGE_TOKEN =3D re.compile( + 'IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) =20 # # Value of different image information block types # -EFI_HII_IIBT_END =3D 0x00 -EFI_HII_IIBT_IMAGE_1BIT =3D 0x10 -EFI_HII_IIBT_IMAGE_1BIT_TRANS =3D 0x11 -EFI_HII_IIBT_IMAGE_4BIT =3D 0x12 -EFI_HII_IIBT_IMAGE_4BIT_TRANS =3D 0x13 -EFI_HII_IIBT_IMAGE_8BIT =3D 0x14 -EFI_HII_IIBT_IMAGE_8BIT_TRANS =3D 0x15 -EFI_HII_IIBT_IMAGE_24BIT =3D 0x16 +EFI_HII_IIBT_END =3D 0x00 +EFI_HII_IIBT_IMAGE_1BIT =3D 0x10 +EFI_HII_IIBT_IMAGE_1BIT_TRANS =3D 0x11 +EFI_HII_IIBT_IMAGE_4BIT =3D 0x12 +EFI_HII_IIBT_IMAGE_4BIT_TRANS =3D 0x13 +EFI_HII_IIBT_IMAGE_8BIT =3D 0x14 +EFI_HII_IIBT_IMAGE_8BIT_TRANS =3D 0x15 +EFI_HII_IIBT_IMAGE_24BIT =3D 0x16 EFI_HII_IIBT_IMAGE_24BIT_TRANS =3D 0x17 -EFI_HII_IIBT_IMAGE_JPEG =3D 0x18 -EFI_HII_IIBT_IMAGE_PNG =3D 0x19 -EFI_HII_IIBT_DUPLICATE =3D 0x20 -EFI_HII_IIBT_SKIP2 =3D 0x21 -EFI_HII_IIBT_SKIP1 =3D 0x22 -EFI_HII_IIBT_EXT1 =3D 0x30 -EFI_HII_IIBT_EXT2 =3D 0x31 -EFI_HII_IIBT_EXT4 =3D 0x32 +EFI_HII_IIBT_IMAGE_JPEG =3D 0x18 +EFI_HII_IIBT_IMAGE_PNG =3D 0x19 +EFI_HII_IIBT_DUPLICATE =3D 0x20 +EFI_HII_IIBT_SKIP2 =3D 0x21 +EFI_HII_IIBT_SKIP1 =3D 0x22 +EFI_HII_IIBT_EXT1 =3D 0x30 +EFI_HII_IIBT_EXT2 =3D 0x31 +EFI_HII_IIBT_EXT4 =3D 0x32 =20 # # Value of HII package type # -EFI_HII_PACKAGE_TYPE_ALL =3D 0x00 -EFI_HII_PACKAGE_TYPE_GUID =3D 0x01 -EFI_HII_PACKAGE_FORMS =3D 0x02 -EFI_HII_PACKAGE_STRINGS =3D 0x04 -EFI_HII_PACKAGE_FONTS =3D 0x05 -EFI_HII_PACKAGE_IMAGES =3D 0x06 -EFI_HII_PACKAGE_SIMPLE_FONTS =3D 0x07 -EFI_HII_PACKAGE_DEVICE_PATH =3D 0x08 -EFI_HII_PACKAGE_KEYBOARD_LAYOUT =3D 0x09 -EFI_HII_PACKAGE_ANIMATIONS =3D 0x0A -EFI_HII_PACKAGE_END =3D 0xDF -EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN =3D 0xE0 -EFI_HII_PACKAGE_TYPE_SYSTEM_END =3D 0xFF +EFI_HII_PACKAGE_TYPE_ALL =3D 0x00 +EFI_HII_PACKAGE_TYPE_GUID =3D 0x01 +EFI_HII_PACKAGE_FORMS =3D 0x02 +EFI_HII_PACKAGE_STRINGS =3D 0x04 +EFI_HII_PACKAGE_FONTS =3D 0x05 +EFI_HII_PACKAGE_IMAGES =3D 0x06 +EFI_HII_PACKAGE_SIMPLE_FONTS =3D 0x07 +EFI_HII_PACKAGE_DEVICE_PATH =3D 0x08 +EFI_HII_PACKAGE_KEYBOARD_LAYOUT =3D 0x09 +EFI_HII_PACKAGE_ANIMATIONS =3D 0x0A +EFI_HII_PACKAGE_END =3D 0xDF +EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN =3D 0xE0 +EFI_HII_PACKAGE_TYPE_SYSTEM_END =3D 0xFF + =20 class IdfFileClassObject(object): - def __init__(self, FileList =3D []): + def __init__(self, FileList=3D[]): self.ImageFilesDict =3D {} self.ImageIDList =3D [] for File in FileList: if File is None: - EdkLogger.error("Image Definition File Parser", PARSER_ERR= OR, 'No Image definition file is given.') + EdkLogger.error("Image Definition File Parser", + PARSER_ERROR, 'No Image definition file is= given.') =20 try: IdfFile =3D open(LongFilePath(File.Path), mode=3D'r') @@ -82,30 +85,38 @@ class IdfFileClassObject(object): =20 LineNo =3D GetLineNo(FileIn, Line, False) if not Line.startswith('#image '): - EdkLogger.error("Image Definition File Parser", PARSER= _ERROR, 'The %s in Line %s of File %s is invalid.' % (Line, LineNo, File.Pa= th)) + EdkLogger.error("Image Definition File Parser", PARSER= _ERROR, + 'The %s in Line %s of File %s is inval= id.' % (Line, LineNo, File.Path)) =20 if Line.find('#image ') >=3D 0: LineDetails =3D Line.split() Len =3D len(LineDetails) if Len !=3D 3 and Len !=3D 4: - EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, 'The format is not match #image IMAGE_ID [TRANSPARENT] ImageFil= eName in Line %s of File %s.' % (LineNo, File.Path)) + EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, + 'The format is not match #image IM= AGE_ID [TRANSPARENT] ImageFileName in Line %s of File %s.' % (LineNo, File.= Path)) if Len =3D=3D 4 and LineDetails[2] !=3D 'TRANSPARENT': - EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, 'Please use the keyword "TRANSPARENT" to describe the transpare= ncy setting in Line %s of File %s.' % (LineNo, File.Path)) + EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, + 'Please use the keyword "TRANSPARE= NT" to describe the transparency setting in Line %s of File %s.' % (LineNo,= File.Path)) MatchString =3D gIdentifierPattern.match(LineDetails[1= ]) if MatchString is None: - EdkLogger.error('Image Definition File Parser', F= ORMAT_INVALID, 'The Image token name %s defined in Idf file %s contains the= invalid character.' % (LineDetails[1], File.Path)) + EdkLogger.error('Image Definition File Parser', F= ORMAT_INVALID, + 'The Image token name %s defined i= n Idf file %s contains the invalid character.' % (LineDetails[1], File.Path= )) if LineDetails[1] not in self.ImageIDList: self.ImageIDList.append(LineDetails[1]) else: - EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, 'The %s in Line %s of File %s is already defined.' % (LineDetai= ls[1], LineNo, File.Path)) + EdkLogger.error("Image Definition File Parser", PA= RSER_ERROR, 'The %s in Line %s of File %s is already defined.' % ( + LineDetails[1], LineNo, File.Path)) if Len =3D=3D 4: - ImageFile =3D ImageFileObject(LineDetails[Len-1], = LineDetails[1], True) + ImageFile =3D ImageFileObject( + LineDetails[Len-1], LineDetails[1], True) else: - ImageFile =3D ImageFileObject(LineDetails[Len-1], = LineDetails[1], False) + ImageFile =3D ImageFileObject( + LineDetails[Len-1], LineDetails[1], False) ImageFileList.append(ImageFile) if ImageFileList: self.ImageFilesDict[File] =3D ImageFileList =20 + def SearchImageID(ImageFileObject, FileList): if FileList =3D=3D []: return ImageFileObject @@ -116,11 +127,13 @@ def SearchImageID(ImageFileObject, FileList): for Line in Lines: ImageIdList =3D IMAGE_TOKEN.findall(Line) for ID in ImageIdList: - EdkLogger.debug(EdkLogger.DEBUG_5, "Found ImageID iden= tifier: " + ID) + EdkLogger.debug(EdkLogger.DEBUG_5, + "Found ImageID identifier: " + ID) ImageFileObject.SetImageIDReferenced(ID) =20 + class ImageFileObject(object): - def __init__(self, FileName, ImageID, TransParent =3D False): + def __init__(self, FileName, ImageID, TransParent=3DFalse): self.FileName =3D FileName self.File =3D '' self.ImageID =3D ImageID diff --git a/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py b/BaseTools= /Source/Python/AutoGen/IncludesAutoGen.py index 5ec26eb98b42..7d3dbae33512 100644 --- a/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py @@ -1,4 +1,4 @@ -## @file +# @file # Build cache intermediate result and state # # Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
        @@ -16,6 +16,7 @@ gIsFileMap =3D {} =20 DEP_FILE_TAIL =3D "# Updated \n" =20 + class IncludesAutoGen(): """ This class is to manage the dependent files witch are used in Make= file to support incremental build. 1. C files: @@ -34,6 +35,7 @@ class IncludesAutoGen(): 2. ASM PP use c preprocessor to find out all included files wi= th #include format and generate a deps file 3. build tool updates the .deps file """ + def __init__(self, makefile_folder, ModuleAuto): self.d_folder =3D makefile_folder self.makefile_folder =3D makefile_folder @@ -42,14 +44,16 @@ class IncludesAutoGen(): self.workspace =3D ModuleAuto.WorkspaceDir =20 def CreateModuleDeps(self): - SaveFileOnChange(os.path.join(self.makefile_folder,"deps.txt"),"\n= ".join(self.DepsCollection),False) + SaveFileOnChange(os.path.join(self.makefile_folder, + "deps.txt"), "\n".join(self.DepsCollection), Fals= e) =20 def CreateDepsInclude(self): - deps_file =3D {'deps_file':self.deps_files} + deps_file =3D {'deps_file': self.deps_files} =20 MakePath =3D self.module_autogen.BuildOption.get('MAKE', {}).get('= PATH') if not MakePath: - EdkLogger.error("build", PARAMETER_MISSING, Message=3D"No Make= path available.") + EdkLogger.error("build", PARAMETER_MISSING, + Message=3D"No Make path available.") elif "nmake" in MakePath: _INCLUDE_DEPS_TEMPLATE =3D TemplateString(''' ${BEGIN} @@ -69,10 +73,12 @@ ${END} deps_include_str =3D _INCLUDE_DEPS_TEMPLATE.Replace(deps_file) except Exception as e: print(e) - SaveFileOnChange(os.path.join(self.makefile_folder,"dependency"),d= eps_include_str,False) + SaveFileOnChange(os.path.join(self.makefile_folder, + "dependency"), deps_include_str, False) =20 def CreateDepsTarget(self): - SaveFileOnChange(os.path.join(self.makefile_folder,"deps_target"),= "\n".join([item +":" for item in self.DepsCollection]),False) + SaveFileOnChange(os.path.join(self.makefile_folder, "deps_target")= , "\n".join( + [item + ":" for item in self.DepsCollection]), False) =20 @cached_property def deps_files(self): @@ -93,14 +99,14 @@ ${END} targetname =3D [item[0].Name for item in self.TargetFileList.value= s()] for abspath in self.deps_files: try: - with open(abspath,"r") as fd: + with open(abspath, "r") as fd: lines =3D fd.readlines() =20 firstlineitems =3D lines[0].split(": ") dependency_file =3D firstlineitems[1].strip(" \\\n") dependency_file =3D dependency_file.strip('''"''') if dependency_file: - if os.path.normpath(dependency_file +".deps") =3D=3D a= bspath: + if os.path.normpath(dependency_file + ".deps") =3D=3D = abspath: continue filename =3D os.path.basename(dependency_file).strip() if filename not in targetname: @@ -113,14 +119,15 @@ ${END} dependency_file =3D dependency_file.strip('''"''') if dependency_file =3D=3D '': continue - if os.path.normpath(dependency_file +".deps") =3D=3D a= bspath: + if os.path.normpath(dependency_file + ".deps") =3D=3D = abspath: continue filename =3D os.path.basename(dependency_file).strip() if filename in targetname: continue includes.add(dependency_file.strip()) except Exception as e: - EdkLogger.error("build",FILE_NOT_FOUND, "%s doesn't exist"= % abspath, ExtraData=3Dstr(e), RaiseError=3DFalse) + EdkLogger.error("build", FILE_NOT_FOUND, "%s doesn't exist= " % + abspath, ExtraData=3Dstr(e), RaiseError=3D= False) continue rt =3D sorted(list(set([item.strip(' " \\\n') for item in includes= ]))) return rt @@ -128,49 +135,60 @@ ${END} @cached_property def SourceFileList(self): """ Get a map of module's source files name to module's source fil= es path """ - source =3D {os.path.basename(item.File):item.Path for item in self= .module_autogen.SourceFileList} + source =3D {os.path.basename( + item.File): item.Path for item in self.module_autogen.SourceFi= leList} middle_file =3D {} for afile in source: if afile.upper().endswith(".VFR"): - middle_file.update({afile.split(".")[0]+".c":os.path.join(= self.module_autogen.DebugDir,afile.split(".")[0]+".c")}) - if afile.upper().endswith((".S","ASM")): - middle_file.update({afile.split(".")[0]+".i":os.path.join(= self.module_autogen.OutputDir,afile.split(".")[0]+".i")}) + middle_file.update({afile.split(".")[ + 0]+".c": os.path.join(self.module_autog= en.DebugDir, afile.split(".")[0]+".c")}) + if afile.upper().endswith((".S", "ASM")): + middle_file.update({afile.split(".")[ + 0]+".i": os.path.join(self.module_autog= en.OutputDir, afile.split(".")[0]+".i")}) if afile.upper().endswith(".ASL"): - middle_file.update({afile.split(".")[0]+".i":os.path.join(= self.module_autogen.OutputDir,afile.split(".")[0]+".i")}) - source.update({"AutoGen.c":os.path.join(self.module_autogen.Output= Dir,"AutoGen.c")}) + middle_file.update({afile.split(".")[ + 0]+".i": os.path.join(self.module_autog= en.OutputDir, afile.split(".")[0]+".i")}) + source.update({"AutoGen.c": os.path.join( + self.module_autogen.OutputDir, "AutoGen.c")}) source.update(middle_file) return source =20 @cached_property def HasNamesakeSourceFile(self): - source_base_name =3D set([os.path.basename(item.File) for item in = self.module_autogen.SourceFileList]) + source_base_name =3D set([os.path.basename(item.File) + for item in self.module_autogen.SourceFileL= ist]) rt =3D len(source_base_name) !=3D len(self.module_autogen.SourceFi= leList) return rt + @cached_property def CcPPCommandPathSet(self): rt =3D set() - rt.add(self.module_autogen.BuildOption.get('CC',{}).get('PATH')) - rt.add(self.module_autogen.BuildOption.get('ASLCC',{}).get('PATH')) - rt.add(self.module_autogen.BuildOption.get('ASLPP',{}).get('PATH')) - rt.add(self.module_autogen.BuildOption.get('VFRPP',{}).get('PATH')) - rt.add(self.module_autogen.BuildOption.get('PP',{}).get('PATH')) - rt.add(self.module_autogen.BuildOption.get('APP',{}).get('PATH')) + rt.add(self.module_autogen.BuildOption.get('CC', {}).get('PATH')) + rt.add(self.module_autogen.BuildOption.get('ASLCC', {}).get('PATH'= )) + rt.add(self.module_autogen.BuildOption.get('ASLPP', {}).get('PATH'= )) + rt.add(self.module_autogen.BuildOption.get('VFRPP', {}).get('PATH'= )) + rt.add(self.module_autogen.BuildOption.get('PP', {}).get('PATH')) + rt.add(self.module_autogen.BuildOption.get('APP', {}).get('PATH')) rt.discard(None) return rt + @cached_property def TargetFileList(self): """ Get a map of module's target name to a tuple of module's targe= ts path and whose input file path """ targets =3D {} - targets["AutoGen.obj"] =3D (PathClass(os.path.join(self.module_aut= ogen.OutputDir,"AutoGen.obj")),PathClass(os.path.join(self.module_autogen.D= ebugDir,"AutoGen.c"))) + targets["AutoGen.obj"] =3D (PathClass(os.path.join(self.module_aut= ogen.OutputDir, "AutoGen.obj")), PathClass( + os.path.join(self.module_autogen.DebugDir, "AutoGen.c"))) for item in self.module_autogen.Targets.values(): for block in item: - targets[block.Target.Path] =3D (block.Target,block.Inputs[= 0]) + targets[block.Target.Path] =3D (block.Target, block.Inputs= [0]) return targets =20 - def GetRealTarget(self,source_file_abs): + def GetRealTarget(self, source_file_abs): """ Get the final target file based on source file abspath """ - source_target_map =3D {item[1].Path:item[0].Path for item in self.= TargetFileList.values()} - source_name_map =3D {item[1].File:item[0].Path for item in self.Ta= rgetFileList.values()} + source_target_map =3D { + item[1].Path: item[0].Path for item in self.TargetFileList.val= ues()} + source_name_map =3D { + item[1].File: item[0].Path for item in self.TargetFileList.val= ues()} target_abs =3D source_target_map.get(source_file_abs) if target_abs is None: if source_file_abs.strip().endswith(".i"): @@ -205,28 +223,33 @@ ${END} if not item.startswith("/"): if item.endswith(".txt") and item.startswi= th("@"): with open(item[1:], "r") as file: - source_files =3D file.readlines()[= 0].split() + source_files =3D file.readlines()[ + 0].split() SourceFileAbsPathMap =3D {os.path.= basename(file): file for file in source_files if os.path.ex= ists(file)} else: if os.path.exists(item): - SourceFileAbsPathMap.update({os.pa= th.basename(item): item.strip()}) + SourceFileAbsPathMap.update( + {os.path.basename(item): item.= strip()}) # SourceFileAbsPathMap =3D {os.path.basename(item)= :item for item in cc_options if not item.startswith("/") and os.path.exists= (item)} if line in SourceFileAbsPathMap: current_source =3D line if current_source not in ModuleDepDict: ModuleDepDict[SourceFileAbsPathMap[current_source]] = =3D [] - elif "Note: including file:" =3D=3D line.lstrip()[:21]: + elif "Note: including file:" =3D=3D line.lstrip()[:21]: if not current_source: - EdkLogger.error("build",BUILD_ERROR, "Parse /showInclu= des output failed. line: %s. \n" % line, RaiseError=3DFalse) + EdkLogger.error( + "build", BUILD_ERROR, "Parse /showIncludes output = failed. line: %s. \n" % line, RaiseError=3DFalse) else: - ModuleDepDict[SourceFileAbsPathMap[current_source]].ap= pend(line.lstrip()[22:].strip()) + ModuleDepDict[SourceFileAbsPathMap[current_source]].ap= pend(line.lstrip()[ + = 22:].strip()) =20 for source_abs in ModuleDepDict: if ModuleDepDict[source_abs]: target_abs =3D self.GetRealTarget(source_abs) dep_file_name =3D os.path.basename(source_abs) + ".deps" - SaveFileOnChange(os.path.join(os.path.dirname(target_abs),= dep_file_name)," \\\n".join([target_abs+":"] + ['''"''' + item +'''"''' for= item in ModuleDepDict[source_abs]]),False) + SaveFileOnChange(os.path.join(os.path.dirname(target_abs),= dep_file_name), " \\\n".join( + [target_abs+":"] + ['''"''' + item + '''"''' for item = in ModuleDepDict[source_abs]]), False) =20 def UpdateDepsFileforNonMsvc(self): """ Update .deps files. @@ -239,7 +262,7 @@ ${END} continue try: newcontent =3D [] - with open(abspath,"r") as fd: + with open(abspath, "r") as fd: lines =3D fd.readlines() if lines[-1] =3D=3D DEP_FILE_TAIL: continue @@ -250,7 +273,7 @@ ${END} else: sourceitem =3D lines[1].strip().split(" ")[0] =20 - source_abs =3D self.SourceFileList.get(sourceitem,sourceit= em) + source_abs =3D self.SourceFileList.get(sourceitem, sourcei= tem) firstlineitems[0] =3D self.GetRealTarget(source_abs) p_target =3D firstlineitems if not p_target[0].strip().endswith(":"): @@ -268,10 +291,11 @@ ${END} =20 newcontent.append("\n") newcontent.append(DEP_FILE_TAIL) - with open(abspath,"w") as fw: + with open(abspath, "w") as fw: fw.write("".join(newcontent)) except Exception as e: - EdkLogger.error("build",FILE_NOT_FOUND, "%s doesn't exist"= % abspath, ExtraData=3Dstr(e), RaiseError=3DFalse) + EdkLogger.error("build", FILE_NOT_FOUND, "%s doesn't exist= " % + abspath, ExtraData=3Dstr(e), RaiseError=3D= False) continue =20 def UpdateDepsFileforTrim(self): @@ -282,7 +306,7 @@ ${END} continue try: newcontent =3D [] - with open(abspath,"r") as fd: + with open(abspath, "r") as fd: lines =3D fd.readlines() if lines[-1] =3D=3D DEP_FILE_TAIL: continue @@ -291,14 +315,15 @@ ${END} targetitem =3D self.GetRealTarget(source_abs.strip(" :")) =20 targetitem +=3D ": " - if len(lines)>=3D2: + if len(lines) >=3D 2: targetitem +=3D lines[1] newcontent.append(targetitem) newcontent.extend(lines[2:]) newcontent.append("\n") newcontent.append(DEP_FILE_TAIL) - with open(abspath,"w") as fw: + with open(abspath, "w") as fw: fw.write("".join(newcontent)) except Exception as e: - EdkLogger.error("build",FILE_NOT_FOUND, "%s doesn't exist"= % abspath, ExtraData=3Dstr(e), RaiseError=3DFalse) + EdkLogger.error("build", FILE_NOT_FOUND, "%s doesn't exist= " % + abspath, ExtraData=3Dstr(e), RaiseError=3D= False) continue diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTool= s/Source/Python/AutoGen/InfSectionParser.py index a55ddac341b6..0b27fa4e4ea4 100644 --- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py +++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py @@ -1,11 +1,11 @@ -## @file +# @file # Parser a Inf file and Get specify section data. # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # =20 import Common.EdkLogger as EdkLogger @@ -31,7 +31,8 @@ class InfSectionParser(): with open(self._FilePath, "r") as File: FileLinesList =3D File.readlines() except BaseException: - EdkLogger.error("build", AUTOGEN_ERROR, 'File %s is opened fai= led.' % self._FilePath) + EdkLogger.error("build", AUTOGEN_ERROR, + 'File %s is opened failed.' % self._FilePath) =20 for Index in range(0, len(FileLinesList)): line =3D str(FileLinesList[Index]).strip() @@ -48,8 +49,8 @@ class InfSectionParser(): UserExtFind =3D True FindEnd =3D False =20 - if (NextLine !=3D '' and NextLine[0] =3D=3D TAB_SECTION_START = and \ - NextLine[-1] =3D=3D TAB_SECTION_END) or FileLastLine: + if (NextLine !=3D '' and NextLine[0] =3D=3D TAB_SECTION_START = and + NextLine[-1] =3D=3D TAB_SECTION_END) or FileLastLine: UserExtFind =3D False FindEnd =3D True self._FileSectionDataList.append({SectionLine: SectionData= [:]}) @@ -66,13 +67,16 @@ class InfSectionParser(): for SectionDataDict in self._FileSectionDataList: for key in SectionDataDict: if key.lower().startswith("[userextensions") and key.lower= ().find('.tianocore.') > -1: - SectionLine =3D key.lstrip(TAB_SECTION_START).rstrip(T= AB_SECTION_END) + SectionLine =3D key.lstrip( + TAB_SECTION_START).rstrip(TAB_SECTION_END) SubSectionList =3D [SectionLine] if str(SectionLine).find(TAB_COMMA_SPLIT) > -1: - SubSectionList =3D str(SectionLine).split(TAB_COMM= A_SPLIT) + SubSectionList =3D str( + SectionLine).split(TAB_COMMA_SPLIT) for SubSection in SubSectionList: if SubSection.lower().find('.tianocore.') > -1: - UserExtensionTianoCore.append({SubSection: Sec= tionDataDict[key]}) + UserExtensionTianoCore.append( + {SubSection: SectionDataDict[key]}) return UserExtensionTianoCore =20 # Get depex expression @@ -85,10 +89,12 @@ class InfSectionParser(): for SectionDataDict in self._FileSectionDataList: for key in SectionDataDict: if key.lower() =3D=3D "[depex]" or key.lower().startswith(= "[depex."): - SectionLine =3D key.lstrip(TAB_SECTION_START).rstrip(T= AB_SECTION_END) + SectionLine =3D key.lstrip( + TAB_SECTION_START).rstrip(TAB_SECTION_END) SubSectionList =3D [SectionLine] if str(SectionLine).find(TAB_COMMA_SPLIT) > -1: - SubSectionList =3D str(SectionLine).split(TAB_COMM= A_SPLIT) + SubSectionList =3D str( + SectionLine).split(TAB_COMMA_SPLIT) for SubSection in SubSectionList: SectionList =3D SubSection.split(TAB_SPLIT) SubKey =3D () @@ -99,21 +105,8 @@ class InfSectionParser(): elif len(SectionList) =3D=3D 3: SubKey =3D (SectionList[1], SectionList[2]) else: - EdkLogger.error("build", AUTOGEN_ERROR, 'Secti= on %s is invalid.' % key) - DepexExpressionList.append({SubKey: SectionDataDic= t[key]}) + EdkLogger.error( + "build", AUTOGEN_ERROR, 'Section %s is inv= alid.' % key) + DepexExpressionList.append( + {SubKey: SectionDataDict[key]}) return DepexExpressionList - - - - - - - - - - - - - - - diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index d05410b32966..4983a2e124fb 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -1,4 +1,4 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019, Intel Corporation. All rights reserved.
        @@ -10,7 +10,7 @@ from Common.LongFilePathSupport import LongFilePath, Copy= LongFilePath from Common.BuildToolError import * from Common.DataType import * from Common.Misc import * -from Common.StringUtils import NormPath,GetSplitList +from Common.StringUtils import NormPath, GetSplitList from collections import defaultdict from Workspace.WorkspaceCommon import OrderedListDict import os.path as path @@ -25,20 +25,22 @@ from GenPatchPcdTable.GenPatchPcdTable import parsePcdI= nfoFromMapFile from Workspace.MetaFileCommentParser import UsageList from .GenPcdDb import CreatePcdDatabaseCode from Common.caching import cached_class_function -from AutoGen.ModuleAutoGenHelper import PlatformInfo,WorkSpaceInfo +from AutoGen.ModuleAutoGenHelper import PlatformInfo, WorkSpaceInfo import json import tempfile =20 -## Mapping Makefile type -gMakeTypeMap =3D {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"} +# Mapping Makefile type +gMakeTypeMap =3D {TAB_COMPILER_MSFT: "nmake", "GCC": "gmake"} # # Regular expression for finding Include Directories, the difference betwe= en MSFT and INTEL/GCC # is the former use /I , the Latter used -I to specify include directories # -gBuildOptIncludePatternMsft =3D re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.M= ULTILINE | re.DOTALL) -gBuildOptIncludePatternOther =3D re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.= MULTILINE | re.DOTALL) +gBuildOptIncludePatternMsft =3D re.compile( + r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL) +gBuildOptIncludePatternOther =3D re.compile( + r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL) =20 -## default file name for AutoGen +# default file name for AutoGen gAutoGenCodeFileName =3D "AutoGen.c" gAutoGenHeaderFileName =3D "AutoGen.h" gAutoGenStringFileName =3D "%(module_name)sStrDefs.h" @@ -133,11 +135,15 @@ ${tail_comments} # extend lists contained in a dictionary with lists stored in another dict= ionary # if CopyToDict is not derived from DefaultDict(list) then this may raise = exception # + + def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict): for Key in CopyFromDict: CopyToDict[Key].extend(CopyFromDict[Key]) =20 # Create a directory specified by a set of path elements and return the fu= ll path + + def _MakeDir(PathList): RetVal =3D path.join(*PathList) CreateDirectory(RetVal) @@ -146,6 +152,8 @@ def _MakeDir(PathList): # # Convert string to C format array # + + def _ConvertStringToByteArray(Value): Value =3D Value.strip() if not Value: @@ -182,32 +190,35 @@ def _ConvertStringToByteArray(Value): Value =3D NewValue + '0}' return Value =20 -## ModuleAutoGen class +# ModuleAutoGen class # # This class encapsules the AutoGen behaviors for the build tools. In addi= tion to # the generation of AutoGen.h and AutoGen.c, it will generate *.depex file= according # to the [depex] section in module's inf file. # + + class ModuleAutoGen(AutoGen): # call super().__init__ then call the worker function with different p= arameter count def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args= , **kwargs): if not hasattr(self, "_Init"): - self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch,= *args) + self._InitWorker(Workspace, MetaFile, Target, + Toolchain, Arch, *args) self._Init =3D True =20 - ## Cache the timestamps of metafiles of every module in a class attrib= ute + # Cache the timestamps of metafiles of every module in a class attribu= te # TimeDict =3D {} =20 def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, = **kwargs): -# check if this module is employed by active platform - if not PlatformInfo(Workspace, args[0], Target, Toolchain, Arch,ar= gs[-1]).ValidModule(MetaFile): - EdkLogger.verbose("Module [%s] for [%s] is not employed by act= ive platform\n" \ + # check if this module is employed by active platform + if not PlatformInfo(Workspace, args[0], Target, Toolchain, Arch, a= rgs[-1]).ValidModule(MetaFile): + EdkLogger.verbose("Module [%s] for [%s] is not employed by act= ive platform\n" % (MetaFile, Arch)) return None return super(ModuleAutoGen, cls).__new__(cls, Workspace, MetaFile,= Target, Toolchain, Arch, *args, **kwargs) =20 - ## Initialize ModuleAutoGen + # Initialize ModuleAutoGen # # @param Workspace EdkIIWorkspaceBuild object # @param ModuleFile The path of module file @@ -216,9 +227,11 @@ class ModuleAutoGen(AutoGen): # @param Arch The arch the module supports # @param PlatformFile Platform meta-file # - def _InitWorker(self, Workspace, ModuleFile, Target, Toolchain, Arch, = PlatformFile,DataPipe): - EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen module [%s] [%s]" % (M= oduleFile, Arch)) - GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % (ModuleFile, Ar= ch, Toolchain, Target) + def _InitWorker(self, Workspace, ModuleFile, Target, Toolchain, Arch, = PlatformFile, DataPipe): + EdkLogger.debug(EdkLogger.DEBUG_9, + "AutoGen module [%s] [%s]" % (ModuleFile, Arch)) + GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % ( + ModuleFile, Arch, Toolchain, Target) =20 self.Workspace =3D Workspace self.WorkspaceDir =3D "" @@ -241,35 +254,38 @@ class ModuleAutoGen(AutoGen): =20 self.BuildDatabase =3D self.Workspace.BuildDatabase self.BuildRuleOrder =3D None - self.BuildTime =3D 0 + self.BuildTime =3D 0 =20 self._GuidComments =3D OrderedListDict() self._ProtocolComments =3D OrderedListDict() self._PpiComments =3D OrderedListDict() - self._BuildTargets =3D None - self._IntroBuildTargetList =3D None - self._FinalBuildTargetList =3D None - self._FileTypes =3D None + self._BuildTargets =3D None + self._IntroBuildTargetList =3D None + self._FinalBuildTargetList =3D None + self._FileTypes =3D None =20 self.AutoGenDepSet =3D set() self.ReferenceModules =3D [] - self.ConstPcd =3D {} - self.FileDependCache =3D {} + self.ConstPcd =3D {} + self.FileDependCache =3D {} =20 def __init_platform_info__(self): pinfo =3D self.DataPipe.Get("P_Info") self.WorkspaceDir =3D pinfo.get("WorkspaceDir") - self.PlatformInfo =3D PlatformInfo(self.Workspace,pinfo.get("Activ= ePlatform"),pinfo.get("Target"),pinfo.get("ToolChain"),pinfo.get("Arch"),se= lf.DataPipe) - ## hash() operator of ModuleAutoGen + self.PlatformInfo =3D PlatformInfo(self.Workspace, pinfo.get("Acti= vePlatform"), pinfo.get( + "Target"), pinfo.get("ToolChain"), pinfo.get("Arch"), self.Dat= aPipe) + # hash() operator of ModuleAutoGen # # The module file path and arch string will be used to represent # hash value of this object # # @retval int Hash value of the module file path and arch # + @cached_class_function def __hash__(self): - return hash((self.MetaFile, self.Arch, self.ToolChain,self.BuildTa= rget)) + return hash((self.MetaFile, self.Arch, self.ToolChain, self.BuildT= arget)) + def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) =20 @@ -290,7 +306,8 @@ class ModuleAutoGen(AutoGen): for Pcd in self.FixedAtBuildPcds: if Pcd.DatumType =3D=3D TAB_VOID: if '.'.join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) not= in RetVal: - RetVal['.'.join((Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me))] =3D Pcd.DefaultValue + RetVal['.'.join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName))] =3D Pc= d.DefaultValue return RetVal =20 @property @@ -298,61 +315,61 @@ class ModuleAutoGen(AutoGen): ModuleNames =3D self.DataPipe.Get("M_Name") if not ModuleNames: return self.Name - return ModuleNames.get((self.Name,self.MetaFile),self.Name) + return ModuleNames.get((self.Name, self.MetaFile), self.Name) =20 # Macros could be used in build_rule.txt (also Makefile) @cached_property def Macros(self): return OrderedDict(( - ("WORKSPACE" ,self.WorkspaceDir), - ("MODULE_NAME" ,self.Name), - ("MODULE_NAME_GUID" ,self.UniqueBaseName), - ("MODULE_GUID" ,self.Guid), - ("MODULE_VERSION" ,self.Version), - ("MODULE_TYPE" ,self.ModuleType), - ("MODULE_FILE" ,str(self.MetaFile)), - ("MODULE_FILE_BASE_NAME" ,self.MetaFile.BaseName), - ("MODULE_RELATIVE_DIR" ,self.SourceDir), - ("MODULE_DIR" ,self.SourceDir), - ("BASE_NAME" ,self.Name), - ("ARCH" ,self.Arch), - ("TOOLCHAIN" ,self.ToolChain), - ("TOOLCHAIN_TAG" ,self.ToolChain), - ("TOOL_CHAIN_TAG" ,self.ToolChain), - ("TARGET" ,self.BuildTarget), - ("BUILD_DIR" ,self.PlatformInfo.BuildDir), - ("BIN_DIR" ,os.path.join(self.PlatformInfo.BuildDir, self.Arch= )), - ("LIB_DIR" ,os.path.join(self.PlatformInfo.BuildDir, self.Arch= )), - ("MODULE_BUILD_DIR" ,self.BuildDir), - ("OUTPUT_DIR" ,self.OutputDir), - ("DEBUG_DIR" ,self.DebugDir), - ("DEST_DIR_OUTPUT" ,self.OutputDir), - ("DEST_DIR_DEBUG" ,self.DebugDir), - ("PLATFORM_NAME" ,self.PlatformInfo.Name), - ("PLATFORM_GUID" ,self.PlatformInfo.Guid), - ("PLATFORM_VERSION" ,self.PlatformInfo.Version), - ("PLATFORM_RELATIVE_DIR" ,self.PlatformInfo.SourceDir), - ("PLATFORM_DIR" ,mws.join(self.WorkspaceDir, self.PlatformInfo= .SourceDir)), - ("PLATFORM_OUTPUT_DIR" ,self.PlatformInfo.OutputDir), - ("FFS_OUTPUT_DIR" ,self.FfsOutputDir) - )) + ("WORKSPACE", self.WorkspaceDir), + ("MODULE_NAME", self.Name), + ("MODULE_NAME_GUID", self.UniqueBaseName), + ("MODULE_GUID", self.Guid), + ("MODULE_VERSION", self.Version), + ("MODULE_TYPE", self.ModuleType), + ("MODULE_FILE", str(self.MetaFile)), + ("MODULE_FILE_BASE_NAME", self.MetaFile.BaseName), + ("MODULE_RELATIVE_DIR", self.SourceDir), + ("MODULE_DIR", self.SourceDir), + ("BASE_NAME", self.Name), + ("ARCH", self.Arch), + ("TOOLCHAIN", self.ToolChain), + ("TOOLCHAIN_TAG", self.ToolChain), + ("TOOL_CHAIN_TAG", self.ToolChain), + ("TARGET", self.BuildTarget), + ("BUILD_DIR", self.PlatformInfo.BuildDir), + ("BIN_DIR", os.path.join(self.PlatformInfo.BuildDir, self.Arch= )), + ("LIB_DIR", os.path.join(self.PlatformInfo.BuildDir, self.Arch= )), + ("MODULE_BUILD_DIR", self.BuildDir), + ("OUTPUT_DIR", self.OutputDir), + ("DEBUG_DIR", self.DebugDir), + ("DEST_DIR_OUTPUT", self.OutputDir), + ("DEST_DIR_DEBUG", self.DebugDir), + ("PLATFORM_NAME", self.PlatformInfo.Name), + ("PLATFORM_GUID", self.PlatformInfo.Guid), + ("PLATFORM_VERSION", self.PlatformInfo.Version), + ("PLATFORM_RELATIVE_DIR", self.PlatformInfo.SourceDir), + ("PLATFORM_DIR", mws.join(self.WorkspaceDir, self.PlatformInfo= .SourceDir)), + ("PLATFORM_OUTPUT_DIR", self.PlatformInfo.OutputDir), + ("FFS_OUTPUT_DIR", self.FfsOutputDir) + )) =20 - ## Return the module build data object + # Return the module build data object @cached_property def Module(self): return self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarg= et, self.ToolChain] =20 - ## Return the module name + # Return the module name @cached_property def Name(self): return self.Module.BaseName =20 - ## Return the module DxsFile if exist + # Return the module DxsFile if exist @cached_property def DxsFile(self): return self.Module.DxsFile =20 - ## Return the module meta-file GUID + # Return the module meta-file GUID @cached_property def Guid(self): # @@ -367,84 +384,85 @@ class ModuleAutoGen(AutoGen): return os.path.basename(self.MetaFile.Path)[:36] return self.Module.Guid =20 - ## Return the module version + # Return the module version @cached_property def Version(self): return self.Module.Version =20 - ## Return the module type + # Return the module type @cached_property def ModuleType(self): return self.Module.ModuleType =20 - ## Return the component type (for Edk.x style of module) + # Return the component type (for Edk.x style of module) @cached_property def ComponentType(self): return self.Module.ComponentType =20 - ## Return the build type + # Return the build type @cached_property def BuildType(self): return self.Module.BuildType =20 - ## Return the PCD_IS_DRIVER setting + # Return the PCD_IS_DRIVER setting @cached_property def PcdIsDriver(self): return self.Module.PcdIsDriver =20 - ## Return the autogen version, i.e. module meta-file version + # Return the autogen version, i.e. module meta-file version @cached_property def AutoGenVersion(self): return self.Module.AutoGenVersion =20 - ## Check if the module is library or not + # Check if the module is library or not @cached_property def IsLibrary(self): return bool(self.Module.LibraryClass) =20 - ## Check if the module is binary module or not + # Check if the module is binary module or not @cached_property def IsBinaryModule(self): return self.Module.IsBinaryModule =20 - ## Return the directory to store intermediate files of the module + # Return the directory to store intermediate files of the module @cached_property def BuildDir(self): return _MakeDir(( - self.PlatformInfo.BuildDir, - self.Arch, - self.SourceDir, - self.MetaFile.BaseName - )) + self.PlatformInfo.BuildDir, + self.Arch, + self.SourceDir, + self.MetaFile.BaseName + )) =20 - ## Return the directory to store the intermediate object files of the = module + # Return the directory to store the intermediate object files of the m= odule @cached_property def OutputDir(self): return _MakeDir((self.BuildDir, "OUTPUT")) =20 - ## Return the directory path to store ffs file + # Return the directory path to store ffs file @cached_property def FfsOutputDir(self): if GlobalData.gFdfParser: return path.join(self.PlatformInfo.BuildDir, TAB_FV_DIRECTORY,= "Ffs", self.Guid + self.Name) return '' =20 - ## Return the directory to store auto-gened source files of the module + # Return the directory to store auto-gened source files of the module @cached_property def DebugDir(self): return _MakeDir((self.BuildDir, "DEBUG")) =20 - ## Return the path of custom file + # Return the path of custom file @cached_property def CustomMakefile(self): RetVal =3D {} for Type in self.Module.CustomMakefile: MakeType =3D gMakeTypeMap[Type] if Type in gMakeTypeMap else '= nmake' - File =3D os.path.join(self.SourceDir, self.Module.CustomMakefi= le[Type]) + File =3D os.path.join( + self.SourceDir, self.Module.CustomMakefile[Type]) RetVal[MakeType] =3D File return RetVal =20 - ## Return the directory of the makefile + # Return the directory of the makefile # # @retval string The directory string of module's makefile # @@ -452,7 +470,7 @@ class ModuleAutoGen(AutoGen): def MakeFileDir(self): return self.BuildDir =20 - ## Return build command string + # Return build command string # # @retval string Build command string # @@ -460,7 +478,7 @@ class ModuleAutoGen(AutoGen): def BuildCommand(self): return self.PlatformInfo.BuildCommand =20 - ## Get Module package and Platform package + # Get Module package and Platform package # # @retval list The list of package object # @@ -469,14 +487,15 @@ class ModuleAutoGen(AutoGen): PkagList =3D [] if self.Module.Packages: PkagList.extend(self.Module.Packages) - Platform =3D self.BuildDatabase[self.PlatformInfo.MetaFile, self.A= rch, self.BuildTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.PlatformInfo.MetaFile, + self.Arch, self.BuildTarget, self.To= olChain] for Package in Platform.Packages: if Package in PkagList: continue PkagList.append(Package) return PkagList =20 - ## Get object list of all packages the module and its dependent librar= ies belong to and the Platform depends on + # Get object list of all packages the module and its dependent librari= es belong to and the Platform depends on # # @retval list The list of package object # @@ -491,13 +510,13 @@ class ModuleAutoGen(AutoGen): PackageList.append(Package) return PackageList =20 - ## Get the depex string + # Get the depex string # # @return : a string contain all depex expression. def _GetDepexExpresionString(self): DepexStr =3D '' DepexList =3D [] - ## DPX_SOURCE IN Define section. + # DPX_SOURCE IN Define section. if self.Module.DxsFile: return DepexStr for M in [self.Module] + self.DependentLibraryList: @@ -507,7 +526,8 @@ class ModuleAutoGen(AutoGen): for DepexExpression in DepexExpressionList: for key in DepexExpression: Arch, ModuleType =3D key - DepexExpr =3D [x for x in DepexExpression[key] if not = str(x).startswith('#')] + DepexExpr =3D [x for x in DepexExpression[key] + if not str(x).startswith('#')] # the type of build module is USER_DEFINED. # All different DEPEX section tags would be copied int= o the As Built INF file # and there would be separate DEPEX section tags @@ -516,22 +536,22 @@ class ModuleAutoGen(AutoGen): DepexList.append({(Arch, ModuleType): DepexExp= r}) else: if Arch.upper() =3D=3D TAB_ARCH_COMMON or \ - (Arch.upper() =3D=3D self.Arch.upper() and \ - ModuleType.upper() in [TAB_ARCH_COMMON, self.Mod= uleType.upper()]): + (Arch.upper() =3D=3D self.Arch.upper() and + ModuleType.upper() in [TAB_ARCH_COMMON, self.Mo= duleType.upper()]): DepexList.append({(Arch, ModuleType): DepexExp= r}) =20 - #the type of build module is USER_DEFINED. + # the type of build module is USER_DEFINED. if self.ModuleType.upper() =3D=3D SUP_MODULE_USER_DEFINED or self.= ModuleType.upper() =3D=3D SUP_MODULE_HOST_APPLICATION: for Depex in DepexList: for key in Depex: DepexStr +=3D '[Depex.%s.%s]\n' % key - DepexStr +=3D '\n'.join('# '+ val for val in Depex[key= ]) + DepexStr +=3D '\n'.join('# ' + val for val in Depex[ke= y]) DepexStr +=3D '\n\n' if not DepexStr: return '[Depex.%s]\n' % self.Arch return DepexStr =20 - #the type of build module not is USER_DEFINED. + # the type of build module not is USER_DEFINED. Count =3D 0 for Depex in DepexList: Count +=3D 1 @@ -551,7 +571,7 @@ class ModuleAutoGen(AutoGen): return '[Depex.%s]\n' % self.Arch return '[Depex.%s]\n# ' % self.Arch + DepexStr =20 - ## Merge dependency expression + # Merge dependency expression # # @retval list The token list of the dependency expression af= ter parsed # @@ -573,7 +593,7 @@ class ModuleAutoGen(AutoGen): if DepexList !=3D []: DepexList.append('AND') DepexList.append('(') - #replace D with value if D is FixedAtBuild PCD + # replace D with value if D is FixedAtBuild PCD NewList =3D [] for item in D: if '.' not in item: @@ -586,7 +606,8 @@ class ModuleAutoGen(AutoGen): "{} used in [Depex] sectio= n should be used as FixedAtBuild type and VOID* datum type and 16 bytes in = the module.".format(item)) NewList.append(Value) except: - EdkLogger.error("build", FORMAT_INVALID, "{} u= sed in [Depex] section should be used as FixedAtBuild type and VOID* datum = type in the module.".format(item)) + EdkLogger.error( + "build", FORMAT_INVALID, "{} used in [Depe= x] section should be used as FixedAtBuild type and VOID* datum type in the = module.".format(item)) =20 DepexList.extend(NewList) if DepexList[-1] =3D=3D 'END': # no need of a END at this= time @@ -594,14 +615,15 @@ class ModuleAutoGen(AutoGen): DepexList.append(')') Inherited =3D True if Inherited: - EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Name, M= .Module.BaseName, DepexList)) + EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % + (self.Name, M.Module.BaseName, DepexList= )) if 'BEFORE' in DepexList or 'AFTER' in DepexList: break if len(DepexList) > 0: EdkLogger.verbose('') - return {self.ModuleType:DepexList} + return {self.ModuleType: DepexList} =20 - ## Merge dependency expression + # Merge dependency expression # # @retval list The token list of the dependency expression af= ter parsed # @@ -621,17 +643,19 @@ class ModuleAutoGen(AutoGen): DepexExpressionString +=3D ' AND ' DepexExpressionString +=3D '(' DepexExpressionString +=3D D - DepexExpressionString =3D DepexExpressionString.rstrip('EN= D').strip() + DepexExpressionString =3D DepexExpressionString.rstrip( + 'END').strip() DepexExpressionString +=3D ')' Inherited =3D True if Inherited: - EdkLogger.verbose("DEPEX[%s] (+%s) =3D %s" % (self.Name, M= .BaseName, DepexExpressionString)) + EdkLogger.verbose( + "DEPEX[%s] (+%s) =3D %s" % (self.Name, M.BaseName, Dep= exExpressionString)) if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpres= sionString: break if len(DepexExpressionString) > 0: EdkLogger.verbose('') =20 - return {self.ModuleType:DepexExpressionString} + return {self.ModuleType: DepexExpressionString} =20 # Get the tiano core user extension, it is contain dependent library. # @retval: a list contain tiano core userextension. @@ -650,14 +674,15 @@ class ModuleAutoGen(AutoGen): Arch =3D ItemList[3] if Arch.upper() =3D=3D TAB_ARCH_COMMON or Arch.upper()= =3D=3D self.Arch.upper(): TianoCoreList =3D [] - TianoCoreList.extend([TAB_SECTION_START + Section = + TAB_SECTION_END]) + TianoCoreList.extend( + [TAB_SECTION_START + Section + TAB_SECTION_END= ]) TianoCoreList.extend(TianoCoreUserExtent[Section][= :]) TianoCoreList.append('\n') TianoCoreUserExtentionList.append(TianoCoreList) =20 return TianoCoreUserExtentionList =20 - ## Return the list of specification version required for the module + # Return the list of specification version required for the module # # @retval list The list of specification defined in module fi= le # @@ -665,19 +690,21 @@ class ModuleAutoGen(AutoGen): def Specification(self): return self.Module.Specification =20 - ## Tool option for the module build + # Tool option for the module build # # @param PlatformInfo The object of PlatformBuildInfo # @retval dict The dict containing valid options # @cached_property def BuildOption(self): - RetVal, self.BuildRuleOrder =3D self.PlatformInfo.ApplyBuildOption= (self.Module) + RetVal, self.BuildRuleOrder =3D self.PlatformInfo.ApplyBuildOption( + self.Module) if self.BuildRuleOrder: - self.BuildRuleOrder =3D ['.%s' % Ext for Ext in self.BuildRule= Order.split()] + self.BuildRuleOrder =3D ['.%s' % + Ext for Ext in self.BuildRuleOrder.spli= t()] return RetVal =20 - ## Get include path list from tool option for the module build + # Get include path list from tool option for the module build # # @retval list The include path list # @@ -704,7 +731,8 @@ class ModuleAutoGen(AutoGen): except KeyError: FlagOption =3D '' =20 - IncPathList =3D [NormPath(Path, self.Macros) for Path in Build= OptIncludeRegEx.findall(FlagOption)] + IncPathList =3D [NormPath(Path, self.Macros) + for Path in BuildOptIncludeRegEx.findall(FlagOp= tion)] =20 # # EDK II modules must not reference header files outside of th= e packages they depend on or @@ -713,7 +741,8 @@ class ModuleAutoGen(AutoGen): if GlobalData.gDisableIncludePathCheck =3D=3D False: for Path in IncPathList: if (Path not in self.IncludePathList) and (CommonPath(= [Path, self.MetaFile.Dir]) !=3D self.MetaFile.Dir): - ErrMsg =3D "The include directory for the EDK II m= odule in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool,= FlagOption) + ErrMsg =3D "The include directory for the EDK II m= odule in this line is invalid %s specified in %s FLAGS '%s'" % ( + Path, Tool, FlagOption) EdkLogger.error("build", PARAMETER_INVALID, ExtraData=3DErrMsg, @@ -721,7 +750,7 @@ class ModuleAutoGen(AutoGen): RetVal +=3D IncPathList return RetVal =20 - ## Return a list of files which can be built from source + # Return a list of files which can be built from source # # What kind of files can be built is determined by build rules in # $(CONF_DIRECTORY)/build_rule.txt and toolchain family. @@ -730,7 +759,8 @@ class ModuleAutoGen(AutoGen): def SourceFileList(self): RetVal =3D [] ToolChainTagSet =3D {"", TAB_STAR, self.ToolChain} - ToolChainFamilySet =3D {"", TAB_STAR, self.ToolChainFamily, self.B= uildRuleFamily} + ToolChainFamilySet =3D {"", TAB_STAR, + self.ToolChainFamily, self.BuildRuleFamily} for F in self.Module.Sources: # match tool chain if F.TagName not in ToolChainTagSet: @@ -740,10 +770,10 @@ class ModuleAutoGen(AutoGen): # match tool chain family or build rule family if F.ToolChainFamily not in ToolChainFamilySet: EdkLogger.debug( - EdkLogger.DEBUG_0, - "The file [%s] must be built by tools of [%s],= " \ - "but current toolchain family is [%s], buildru= le family is [%s]" \ - % (str(F), F.ToolChainFamily, self.ToolCha= inFamily, self.BuildRuleFamily)) + EdkLogger.DEBUG_0, + "The file [%s] must be built by tools of [%s], " + "but current toolchain family is [%s], buildrule famil= y is [%s]" + % (str(F), F.ToolChainFamily, self.ToolChainFamily, se= lf.BuildRuleFamily)) continue =20 # add the file path into search path list for file including @@ -762,7 +792,7 @@ class ModuleAutoGen(AutoGen): self.BuildOption for SingleFile in FileList: if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrd= er and SingleFile.Ext in self.BuildRules: - key =3D SingleFile.Path.rsplit(SingleFile.Ext,1)[0] + key =3D SingleFile.Path.rsplit(SingleFile.Ext, 1)[0] if key in Order_Dict: Order_Dict[key].append(SingleFile.Ext) else: @@ -780,22 +810,22 @@ class ModuleAutoGen(AutoGen): =20 return FileList =20 - ## Return the list of unicode files + # Return the list of unicode files @cached_property def UnicodeFileList(self): - return self.FileTypes.get(TAB_UNICODE_FILE,[]) + return self.FileTypes.get(TAB_UNICODE_FILE, []) =20 - ## Return the list of vfr files + # Return the list of vfr files @cached_property def VfrFileList(self): return self.FileTypes.get(TAB_VFR_FILE, []) =20 - ## Return the list of Image Definition files + # Return the list of Image Definition files @cached_property def IdfFileList(self): - return self.FileTypes.get(TAB_IMAGE_FILE,[]) + return self.FileTypes.get(TAB_IMAGE_FILE, []) =20 - ## Return a list of files which can be built from binary + # Return a list of files which can be built from binary # # "Build" binary files are just to copy them to build directory. # @@ -816,19 +846,23 @@ class ModuleAutoGen(AutoGen): RetVal =3D {} BuildRuleDatabase =3D self.PlatformInfo.BuildRule for Type in BuildRuleDatabase.FileTypeList: - #first try getting build rule by BuildRuleFamily - RuleObject =3D BuildRuleDatabase[Type, self.BuildType, self.Ar= ch, self.BuildRuleFamily] + # first try getting build rule by BuildRuleFamily + RuleObject =3D BuildRuleDatabase[Type, + self.BuildType, self.Arch, self= .BuildRuleFamily] if not RuleObject: # build type is always module type, but ... if self.ModuleType !=3D self.BuildType: - RuleObject =3D BuildRuleDatabase[Type, self.ModuleType= , self.Arch, self.BuildRuleFamily] - #second try getting build rule by ToolChainFamily + RuleObject =3D BuildRuleDatabase[Type, + self.ModuleType, self.A= rch, self.BuildRuleFamily] + # second try getting build rule by ToolChainFamily if not RuleObject: - RuleObject =3D BuildRuleDatabase[Type, self.BuildType, sel= f.Arch, self.ToolChainFamily] + RuleObject =3D BuildRuleDatabase[Type, + self.BuildType, self.Arch, = self.ToolChainFamily] if not RuleObject: # build type is always module type, but ... if self.ModuleType !=3D self.BuildType: - RuleObject =3D BuildRuleDatabase[Type, self.Module= Type, self.Arch, self.ToolChainFamily] + RuleObject =3D BuildRuleDatabase[Type, + self.ModuleType, se= lf.Arch, self.ToolChainFamily] if not RuleObject: continue RuleObject =3D RuleObject.Instantiate(self.Macros) @@ -906,7 +940,8 @@ class ModuleAutoGen(AutoGen): =20 # to avoid cyclic rule if FileType in RuleChain: - EdkLogger.error("build", ERROR_STATEMENT, "Cyclic dependen= cy detected while generating rule for %s" % str(Source)) + EdkLogger.error( + "build", ERROR_STATEMENT, "Cyclic dependency detected = while generating rule for %s" % str(Source)) =20 RuleChain.add(FileType) SourceList.extend(Target.Outputs) @@ -925,10 +960,10 @@ class ModuleAutoGen(AutoGen): self._BuildTargets =3D defaultdict(set) self._FileTypes =3D defaultdict(set) =20 - #TRICK: call SourceFileList property to apply build rule for sourc= e files + # TRICK: call SourceFileList property to apply build rule for sour= ce files self.SourceFileList =20 - #TRICK: call _GetBinaryFileList to apply build rule for binary fil= es + # TRICK: call _GetBinaryFileList to apply build rule for binary fi= les self.BinaryFileList =20 return self._BuildTargets @@ -948,7 +983,7 @@ class ModuleAutoGen(AutoGen): self.Targets return self._FileTypes =20 - ## Get the list of package object the module depends on and the Platfo= rm depends on + # Get the list of package object the module depends on and the Platfor= m depends on # # @retval list The package object list # @@ -956,7 +991,7 @@ class ModuleAutoGen(AutoGen): def DependentPackageList(self): return self.PackageList =20 - ## Return the list of auto-generated code file + # Return the list of auto-generated code file # # @retval list The list of auto-generated file # @@ -970,7 +1005,8 @@ class ModuleAutoGen(AutoGen): AutoGenH =3D TemplateString() StringH =3D TemplateString() StringIdf =3D TemplateString() - GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, AutoGenUniIdf, = UniStringBinBuffer, StringIdf, AutoGenUniIdf, IdfGenBinBuffer) + GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, AutoGenUniIdf, + UniStringBinBuffer, StringIdf, AutoGenUniIdf, IdfG= enBinBuffer) # # AutoGen.c is generated if there are library classes in inf, or t= here are object files # @@ -984,22 +1020,26 @@ class ModuleAutoGen(AutoGen): RetVal[AutoFile] =3D str(AutoGenH) self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) if str(StringH) !=3D "": - AutoFile =3D PathClass(gAutoGenStringFileName % {"module_name"= :self.Name}, self.DebugDir) + AutoFile =3D PathClass(gAutoGenStringFileName % + {"module_name": self.Name}, self.DebugDir) RetVal[AutoFile] =3D str(StringH) self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) if UniStringBinBuffer is not None and UniStringBinBuffer.getvalue(= ) !=3D b"": - AutoFile =3D PathClass(gAutoGenStringFormFileName % {"module_n= ame":self.Name}, self.OutputDir) + AutoFile =3D PathClass(gAutoGenStringFormFileName % + {"module_name": self.Name}, self.OutputDi= r) RetVal[AutoFile] =3D UniStringBinBuffer.getvalue() AutoFile.IsBinary =3D True self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) if UniStringBinBuffer is not None: UniStringBinBuffer.close() if str(StringIdf) !=3D "": - AutoFile =3D PathClass(gAutoGenImageDefFileName % {"module_nam= e":self.Name}, self.DebugDir) + AutoFile =3D PathClass(gAutoGenImageDefFileName % + {"module_name": self.Name}, self.DebugDir) RetVal[AutoFile] =3D str(StringIdf) self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) if IdfGenBinBuffer is not None and IdfGenBinBuffer.getvalue() !=3D= b"": - AutoFile =3D PathClass(gAutoGenIdfFileName % {"module_name":se= lf.Name}, self.OutputDir) + AutoFile =3D PathClass(gAutoGenIdfFileName % + {"module_name": self.Name}, self.OutputDi= r) RetVal[AutoFile] =3D IdfGenBinBuffer.getvalue() AutoFile.IsBinary =3D True self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE) @@ -1007,7 +1047,7 @@ class ModuleAutoGen(AutoGen): IdfGenBinBuffer.close() return RetVal =20 - ## Return the list of library modules explicitly or implicitly used by= this module + # Return the list of library modules explicitly or implicitly used by = this module @cached_property def DependentLibraryList(self): # only merge library classes and PCD for non-library module @@ -1015,7 +1055,7 @@ class ModuleAutoGen(AutoGen): return [] return self.PlatformInfo.ApplyLibraryInstance(self.Module) =20 - ## Get the list of PCDs from current module + # Get the list of PCDs from current module # # @retval list The list of PCD # @@ -1025,6 +1065,7 @@ class ModuleAutoGen(AutoGen): RetVal =3D self.PlatformInfo.ApplyPcdSetting(self, self.Module.Pcd= s) =20 return RetVal + @cached_property def _PcdComments(self): ReVal =3D OrderedListDict() @@ -1034,7 +1075,7 @@ class ModuleAutoGen(AutoGen): ExtendCopyDictionaryLists(ReVal, Library.PcdComments) return ReVal =20 - ## Get the list of PCDs from dependent libraries + # Get the list of PCDs from dependent libraries # # @retval list The list of PCD # @@ -1053,10 +1094,11 @@ class ModuleAutoGen(AutoGen): continue Pcds.add(Key) PcdsInLibrary[Key] =3D copy.copy(Library.Pcds[Key]) - RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self, PcdsInLi= brary, Library=3DLibrary)) + RetVal.extend(self.PlatformInfo.ApplyPcdSetting( + self, PcdsInLibrary, Library=3DLibrary)) return RetVal =20 - ## Get the GUID value mapping + # Get the GUID value mapping # # @retval dict The mapping between GUID cname and its value # @@ -1075,20 +1117,23 @@ class ModuleAutoGen(AutoGen): for Library in self.DependentLibraryList: RetVal.update(Library.GetGuidsUsedByPcd()) return RetVal - ## Get the protocol value mapping + # Get the protocol value mapping # # @retval dict The mapping between protocol cname and its val= ue # + @cached_property def ProtocolList(self): RetVal =3D OrderedDict(self.Module.Protocols) for Library in self.DependentLibraryList: RetVal.update(Library.Protocols) - ExtendCopyDictionaryLists(self._ProtocolComments, Library.Prot= ocolComments) - ExtendCopyDictionaryLists(self._ProtocolComments, self.Module.Prot= ocolComments) + ExtendCopyDictionaryLists( + self._ProtocolComments, Library.ProtocolComments) + ExtendCopyDictionaryLists( + self._ProtocolComments, self.Module.ProtocolComments) return RetVal =20 - ## Get the PPI value mapping + # Get the PPI value mapping # # @retval dict The mapping between PPI cname and its value # @@ -1101,7 +1146,7 @@ class ModuleAutoGen(AutoGen): ExtendCopyDictionaryLists(self._PpiComments, self.Module.PpiCommen= ts) return RetVal =20 - ## Get the list of include search path + # Get the list of include search path # # @retval list The list path # @@ -1118,7 +1163,8 @@ class ModuleAutoGen(AutoGen): IncludesList =3D Package.Includes if Package._PrivateIncludes: if not self.MetaFile.OriginalPath.Path.startswith(PackageD= ir): - IncludesList =3D list(set(Package.Includes).difference= (set(Package._PrivateIncludes))) + IncludesList =3D list(set(Package.Includes).difference( + set(Package._PrivateIncludes))) for Inc in IncludesList: if Inc not in RetVal: RetVal.append(str(Inc)) @@ -1134,8 +1180,8 @@ class ModuleAutoGen(AutoGen): whitespace =3D False for flag in flags.split(" "): flag =3D flag.strip() - if flag.startswith(("/I","-I")): - if len(flag)>2: + if flag.startswith(("/I", "-I")): + if len(flag) > 2: if os.path.exists(flag[2:]): IncPathList.append(flag[2:]) else: @@ -1151,7 +1197,7 @@ class ModuleAutoGen(AutoGen): def IncludePathLength(self): return sum(len(inc)+1 for inc in self.IncludePathList) =20 - ## Get the list of include paths from the packages + # Get the list of include paths from the packages # # @IncludesList list The list path # @@ -1163,10 +1209,11 @@ class ModuleAutoGen(AutoGen): IncludesList =3D Package.Includes if Package._PrivateIncludes: if not self.MetaFile.Path.startswith(PackageDir): - IncludesList =3D list(set(Package.Includes).difference= (set(Package._PrivateIncludes))) + IncludesList =3D list(set(Package.Includes).difference( + set(Package._PrivateIncludes))) return IncludesList =20 - ## Get HII EX PCDs which maybe used by VFR + # Get HII EX PCDs which maybe used by VFR # # efivarstore used by VFR may relate with HII EX PCDs # Get the variable name and GUID from efivarstore and HII EX PCD @@ -1209,8 +1256,10 @@ class ModuleAutoGen(AutoGen): Guid =3D gEfiVarStoreGuidPattern.search(Content, Pos) if not Guid: break - NameArray =3D _ConvertStringToByteArray('L"' + Name.group(= 1) + '"') - NameGuids.add((NameArray, GuidStructureStringToGuidString(= Guid.group(1)))) + NameArray =3D _ConvertStringToByteArray( + 'L"' + Name.group(1) + '"') + NameGuids.add( + (NameArray, GuidStructureStringToGuidString(Guid.group= (1)))) Pos =3D Content.find('efivarstore', Name.end()) if not NameGuids: return [] @@ -1219,7 +1268,8 @@ class ModuleAutoGen(AutoGen): if Pcd.Type !=3D TAB_PCDS_DYNAMIC_EX_HII: continue for SkuInfo in Pcd.SkuInfoList.values(): - Value =3D GuidValue(SkuInfo.VariableGuid, self.PlatformInf= o.PackageList, self.MetaFile.Path) + Value =3D GuidValue( + SkuInfo.VariableGuid, self.PlatformInfo.PackageList, s= elf.MetaFile.Path) if not Value: continue Name =3D _ConvertStringToByteArray(SkuInfo.VariableName) @@ -1233,12 +1283,13 @@ class ModuleAutoGen(AutoGen): def _GenOffsetBin(self): VfrUniBaseName =3D {} for SourceFile in self.Module.Sources: - if SourceFile.Type.upper() =3D=3D ".VFR" : + if SourceFile.Type.upper() =3D=3D ".VFR": # # search the .map file to find the offset of vfr binary in= the PE32+/TE file. # - VfrUniBaseName[SourceFile.BaseName] =3D (SourceFile.BaseNa= me + "Bin") - elif SourceFile.Type.upper() =3D=3D ".UNI" : + VfrUniBaseName[SourceFile.BaseName] =3D ( + SourceFile.BaseName + "Bin") + elif SourceFile.Type.upper() =3D=3D ".UNI": # # search the .map file to find the offset of Uni strings b= inary in the PE32+/TE file. # @@ -1248,17 +1299,19 @@ class ModuleAutoGen(AutoGen): return None MapFileName =3D os.path.join(self.OutputDir, self.Name + ".map") EfiFileName =3D os.path.join(self.OutputDir, self.Name + ".efi") - VfrUniOffsetList =3D GetVariableOffset(MapFileName, EfiFileName, l= ist(VfrUniBaseName.values())) + VfrUniOffsetList =3D GetVariableOffset( + MapFileName, EfiFileName, list(VfrUniBaseName.values())) if not VfrUniOffsetList: return None =20 OutputName =3D '%sOffset.bin' % self.Name - UniVfrOffsetFileName =3D os.path.join( self.OutputDir, OutputN= ame) + UniVfrOffsetFileName =3D os.path.join(self.OutputDir, OutputName) =20 try: fInputfile =3D open(UniVfrOffsetFileName, "wb+", 0) except: - EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed = for %s" % UniVfrOffsetFileName, None) + EdkLogger.error("build", FILE_OPEN_FAILURE, + "File open failed for %s" % UniVfrOffsetFileNa= me, None) =20 # Use a instance of BytesIO to cache data fStringIO =3D BytesIO() @@ -1272,8 +1325,8 @@ class ModuleAutoGen(AutoGen): # UniGuid =3D b'\xe0\xc5\x13\x89\xf63\x86M\x9b\xf1C\xef\x89\= xfc\x06f' fStringIO.write(UniGuid) - UniValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (UniValue) + UniValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(UniValue) else: # # VFR binary offset in image. @@ -1282,19 +1335,19 @@ class ModuleAutoGen(AutoGen): # VfrGuid =3D b'\xb4|\xbc\xd0Gj_I\xaa\x11q\x07F\xda\x06\xa2' fStringIO.write(VfrGuid) - VfrValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (VfrValue) + VfrValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(VfrValue) # # write data into file. # - try : - fInputfile.write (fStringIO.getvalue()) + try: + fInputfile.write(fStringIO.getvalue()) except: EdkLogger.error("build", FILE_WRITE_FAILURE, "Write data to fi= le %s failed, please check whether the " - "file been locked or using by other applicatio= ns." %UniVfrOffsetFileName, None) + "file been locked or using by other applicatio= ns." % UniVfrOffsetFileName, None) =20 - fStringIO.close () - fInputfile.close () + fStringIO.close() + fInputfile.close() return OutputName =20 @cached_property @@ -1315,7 +1368,7 @@ class ModuleAutoGen(AutoGen): =20 return retVal =20 - ## Create AsBuilt INF file the module + # Create AsBuilt INF file the module # def CreateAsBuiltInf(self): =20 @@ -1334,7 +1387,7 @@ class ModuleAutoGen(AutoGen): if self.BinaryFileList: return =20 - ### TODO: How to handles mixed source and binary modules + # TODO: How to handles mixed source and binary modules =20 # Find all DynamicEx and PatchableInModule PCDs used by this modul= e and dependent libraries # Also find all packages that the DynamicEx PCDs depend on @@ -1346,12 +1399,15 @@ class ModuleAutoGen(AutoGen): for Pcd in self.ModulePcdList + self.LibraryPcdList: if Pcd.Type =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: PatchablePcds.append(Pcd) - PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCNa= me, TAB_PCDS_PATCHABLE_IN_MODULE)) + PcdCheckList.append( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_PAT= CHABLE_IN_MODULE)) elif Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if Pcd not in Pcds: Pcds.append(Pcd) - PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGui= dCName, TAB_PCDS_DYNAMIC_EX)) - PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGui= dCName, TAB_PCDS_DYNAMIC)) + PcdCheckList.append( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS= _DYNAMIC_EX)) + PcdCheckList.append( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS= _DYNAMIC)) PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName) GuidList =3D OrderedDict(self.GuidList) for TokenSpace in self.GetGuidsUsedByPcd: @@ -1363,7 +1419,8 @@ class ModuleAutoGen(AutoGen): for Package in self.DerivedPackageList: if Package in Packages: continue - BeChecked =3D (Package.Guids, Package.Ppis, Package.Protocols,= Package.Pcds) + BeChecked =3D (Package.Guids, Package.Ppis, + Package.Protocols, Package.Pcds) Found =3D False for Index in range(len(BeChecked)): for Item in CheckList[Index]: @@ -1380,7 +1437,7 @@ class ModuleAutoGen(AutoGen): continue for VfrPcd in VfrPcds: if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PC= DS_DYNAMIC_EX) in Pkg.Pcds or - (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PC= DS_DYNAMIC) in Pkg.Pcds): + (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TA= B_PCDS_DYNAMIC) in Pkg.Pcds): Packages.append(Pkg) break =20 @@ -1390,36 +1447,36 @@ class ModuleAutoGen(AutoGen): MDefs =3D self.Module.Defines =20 AsBuiltInfDict =3D { - 'module_name' : self.Name, - 'module_guid' : Guid, - 'module_module_type' : ModuleType, - 'module_version_string' : [MDefs['VERSION_STRING']] = if 'VERSION_STRING' in MDefs else [], - 'pcd_is_driver_string' : [], - 'module_uefi_specification_version' : [], - 'module_pi_specification_version' : [], - 'module_entry_point' : self.Module.ModuleEntryPoi= ntList, - 'module_unload_image' : self.Module.ModuleUnloadIm= ageList, - 'module_constructor' : self.Module.ConstructorLis= t, - 'module_destructor' : self.Module.DestructorList, - 'module_shadow' : [MDefs['SHADOW']] if 'SHAD= OW' in MDefs else [], - 'module_pci_vendor_id' : [MDefs['PCI_VENDOR_ID']] i= f 'PCI_VENDOR_ID' in MDefs else [], - 'module_pci_device_id' : [MDefs['PCI_DEVICE_ID']] i= f 'PCI_DEVICE_ID' in MDefs else [], - 'module_pci_class_code' : [MDefs['PCI_CLASS_CODE']] = if 'PCI_CLASS_CODE' in MDefs else [], - 'module_pci_revision' : [MDefs['PCI_REVISION']] if= 'PCI_REVISION' in MDefs else [], - 'module_build_number' : [MDefs['BUILD_NUMBER']] if= 'BUILD_NUMBER' in MDefs else [], - 'module_spec' : [MDefs['SPEC']] if 'SPEC' = in MDefs else [], - 'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_= SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [], - 'module_uni_file' : [MDefs['MODULE_UNI_FILE']]= if 'MODULE_UNI_FILE' in MDefs else [], - 'module_arch' : self.Arch, - 'package_item' : [Package.MetaFile.File.rep= lace('\\', '/') for Package in Packages], - 'binary_item' : [], - 'patchablepcd_item' : [], - 'pcd_item' : [], - 'protocol_item' : [], - 'ppi_item' : [], - 'guid_item' : [], - 'flags_item' : [], - 'libraryclasses_item' : [] + 'module_name': self.Name, + 'module_guid': Guid, + 'module_module_type': ModuleType, + 'module_version_string': [MDefs['VERSION_STRING']] if 'VERSION= _STRING' in MDefs else [], + 'pcd_is_driver_string': [], + 'module_uefi_specification_version': [], + 'module_pi_specification_version': [], + 'module_entry_point': self.Module.ModuleEntryPointList, + 'module_unload_image': self.Module.ModuleUnloadImageList, + 'module_constructor': self.Module.ConstructorList, + 'module_destructor': self.Module.DestructorList, + 'module_shadow': [MDefs['SHADOW']] if 'SHADOW' in MDefs else [= ], + 'module_pci_vendor_id': [MDefs['PCI_VENDOR_ID']] if 'PCI_VENDO= R_ID' in MDefs else [], + 'module_pci_device_id': [MDefs['PCI_DEVICE_ID']] if 'PCI_DEVIC= E_ID' in MDefs else [], + 'module_pci_class_code': [MDefs['PCI_CLASS_CODE']] if 'PCI_CLA= SS_CODE' in MDefs else [], + 'module_pci_revision': [MDefs['PCI_REVISION']] if 'PCI_REVISIO= N' in MDefs else [], + 'module_build_number': [MDefs['BUILD_NUMBER']] if 'BUILD_NUMBE= R' in MDefs else [], + 'module_spec': [MDefs['SPEC']] if 'SPEC' in MDefs else [], + 'module_uefi_hii_resource_section': [MDefs['UEFI_HII_RESOURCE_= SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [], + 'module_uni_file': [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_F= ILE' in MDefs else [], + 'module_arch': self.Arch, + 'package_item': [Package.MetaFile.File.replace('\\', '/') for = Package in Packages], + 'binary_item': [], + 'patchablepcd_item': [], + 'pcd_item': [], + 'protocol_item': [], + 'ppi_item': [], + 'guid_item': [], + 'flags_item': [], + 'libraryclasses_item': [] } =20 if 'MODULE_UNI_FILE' in MDefs: @@ -1436,22 +1493,27 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['pcd_is_driver_string'].append(DriverType) =20 if 'UEFI_SPECIFICATION_VERSION' in self.Specification: - AsBuiltInfDict['module_uefi_specification_version'].append(sel= f.Specification['UEFI_SPECIFICATION_VERSION']) + AsBuiltInfDict['module_uefi_specification_version'].append( + self.Specification['UEFI_SPECIFICATION_VERSION']) if 'PI_SPECIFICATION_VERSION' in self.Specification: - AsBuiltInfDict['module_pi_specification_version'].append(self.= Specification['PI_SPECIFICATION_VERSION']) + AsBuiltInfDict['module_pi_specification_version'].append( + self.Specification['PI_SPECIFICATION_VERSION']) =20 OutputDir =3D self.OutputDir.replace('\\', '/').strip('/') DebugDir =3D self.DebugDir.replace('\\', '/').strip('/') for Item in self.CodaTargetList: - File =3D Item.Target.Path.replace('\\', '/').strip('/').replac= e(DebugDir, '').replace(OutputDir, '').strip('/') + File =3D Item.Target.Path.replace( + '\\', '/').strip('/').replace(DebugDir, '').replace(Output= Dir, '').strip('/') if os.path.isabs(File): - File =3D File.replace('\\', '/').strip('/').replace(Output= Dir, '').strip('/') + File =3D File.replace( + '\\', '/').strip('/').replace(OutputDir, '').strip('/') if Item.Target.Ext.lower() =3D=3D '.aml': AsBuiltInfDict['binary_item'].append('ASL|' + File) elif Item.Target.Ext.lower() =3D=3D '.acpi': AsBuiltInfDict['binary_item'].append('ACPI|' + File) elif Item.Target.Ext.lower() =3D=3D '.efi': - AsBuiltInfDict['binary_item'].append('PE32|' + self.Name += '.efi') + AsBuiltInfDict['binary_item'].append( + 'PE32|' + self.Name + '.efi') else: AsBuiltInfDict['binary_item'].append('BIN|' + File) if not self.DepexGenerated: @@ -1460,11 +1522,14 @@ class ModuleAutoGen(AutoGen): self.DepexGenerated =3D True if self.DepexGenerated: if self.ModuleType in [SUP_MODULE_PEIM]: - AsBuiltInfDict['binary_item'].append('PEI_DEPEX|' + self.N= ame + '.depex') + AsBuiltInfDict['binary_item'].append( + 'PEI_DEPEX|' + self.Name + '.depex') elif self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE= _RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: - AsBuiltInfDict['binary_item'].append('DXE_DEPEX|' + self.N= ame + '.depex') + AsBuiltInfDict['binary_item'].append( + 'DXE_DEPEX|' + self.Name + '.depex') elif self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]: - AsBuiltInfDict['binary_item'].append('SMM_DEPEX|' + self.N= ame + '.depex') + AsBuiltInfDict['binary_item'].append( + 'SMM_DEPEX|' + self.Name + '.depex') =20 Bin =3D self._GenOffsetBin() if Bin: @@ -1478,10 +1543,12 @@ class ModuleAutoGen(AutoGen): StartPos =3D 0 for Index in range(len(HeaderComments)): if HeaderComments[Index].find('@BinaryHeader') !=3D -1: - HeaderComments[Index] =3D HeaderComments[Index].replace('@= BinaryHeader', '@file') + HeaderComments[Index] =3D HeaderComments[Index].replace( + '@BinaryHeader', '@file') StartPos =3D Index break - AsBuiltInfDict['header_comments'] =3D '\n'.join(HeaderComments[Sta= rtPos:]).replace(':#', '://') + AsBuiltInfDict['header_comments'] =3D '\n'.join( + HeaderComments[StartPos:]).replace(':#', '://') AsBuiltInfDict['tail_comments'] =3D '\n'.join(self.Module.TailComm= ents) =20 GenList =3D [ @@ -1491,13 +1558,14 @@ class ModuleAutoGen(AutoGen): ] for Item in GenList: for CName in Item[0]: - Comments =3D '\n '.join(Item[1][CName]) if CName in Item[= 1] else '' + Comments =3D '\n '.join( + Item[1][CName]) if CName in Item[1] else '' Entry =3D Comments + '\n ' + CName if Comments else CName AsBuiltInfDict[Item[2]].append(Entry) PatchList =3D parsePcdInfoFromMapFile( - os.path.join(self.OutputDir, self.Name + '.map= '), - os.path.join(self.OutputDir, self.Name + '.efi= ') - ) + os.path.join(self.OutputDir, self.Name + '.map'), + os.path.join(self.OutputDir, self.Name + '.efi') + ) if PatchList: for Pcd in PatchablePcds: TokenCName =3D Pcd.TokenCName @@ -1530,7 +1598,8 @@ class ModuleAutoGen(AutoGen): else: if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize =3D=3D= '': EdkLogger.error("build", AUTOGEN_ERROR, - "Unknown [MaxDatumSize] of PCD [%s= .%s]" % (Pcd.TokenSpaceGuidCName, TokenCName) + "Unknown [MaxDatumSize] of PCD [%s= .%s]" % ( + Pcd.TokenSpaceGuidCName, Token= CName) ) ArraySize =3D int(Pcd.MaxDatumSize, 0) PcdValue =3D Pcd.DefaultValue @@ -1545,9 +1614,11 @@ class ModuleAutoGen(AutoGen): if Unicode: CharVal =3D ord(PcdValue[Index]) NewValue =3D NewValue + '0x%02x' % (CharVa= l & 0x00FF) + ', ' \ - + '0x%02x' % (CharVal >> 8) + ', ' + + '0x%02x' % (CharVal >> 8) + ', ' else: - NewValue =3D NewValue + '0x%02x' % (ord(Pc= dValue[Index]) % 0x100) + ', ' + NewValue =3D NewValue + \ + '0x%02x' % ( + ord(PcdValue[Index]) % 0x100) + ',= ' Padding =3D '0x00, ' if Unicode: Padding =3D Padding * 2 @@ -1555,28 +1626,34 @@ class ModuleAutoGen(AutoGen): if ArraySize < (len(PcdValue) + 1): if Pcd.MaxSizeUserSet: EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* typ= e PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuid= CName, TokenCName) - ) + "The maximum size of VOID*= type PCD '%s.%s' is less than its actual size occupied." % ( + Pcd.TokenSpaceGuidCNam= e, TokenCName) + ) else: ArraySize =3D len(PcdValue) + 1 if ArraySize > len(PcdValue) + 1: - NewValue =3D NewValue + Padding * (ArraySize -= len(PcdValue) - 1) + NewValue =3D NewValue + Padding * \ + (ArraySize - len(PcdValue) - 1) PcdValue =3D NewValue + Padding.strip().rstrip(','= ) + '}' elif len(PcdValue.split(',')) <=3D ArraySize: - PcdValue =3D PcdValue.rstrip('}') + ', 0x00' * (Ar= raySize - len(PcdValue.split(','))) + PcdValue =3D PcdValue.rstrip( + '}') + ', 0x00' * (ArraySize - len(PcdValue.sp= lit(','))) PcdValue +=3D '}' else: if Pcd.MaxSizeUserSet: EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* type PC= D '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCNam= e, TokenCName) - ) + "The maximum size of VOID* typ= e PCD '%s.%s' is less than its actual size occupied." % ( + Pcd.TokenSpaceGuidCName, T= okenCName) + ) else: ArraySize =3D len(PcdValue) + 1 PcdItem =3D '%s.%s|%s|0x%X' % \ - (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchP= cd[1]) + (Pcd.TokenSpaceGuidCName, + TokenCName, PcdValue, PatchPcd[1]) PcdComments =3D '' if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdC= omments: - PcdComments =3D '\n '.join(self._PcdComments[Pcd.Toke= nSpaceGuidCName, Pcd.TokenCName]) + PcdComments =3D '\n '.join( + self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.Tok= enCName]) if PcdComments: PcdItem =3D PcdComments + '\n ' + PcdItem AsBuiltInfDict['patchablepcd_item'].append(PcdItem) @@ -1592,10 +1669,12 @@ class ModuleAutoGen(AutoGen): if Pcd.Type =3D=3D TAB_PCDS_DYNAMIC_EX_HII: for SkuName in Pcd.SkuInfoList: SkuInfo =3D Pcd.SkuInfoList[SkuName] - HiiInfo =3D '## %s|%s|%s' % (SkuInfo.VariableName, Sku= Info.VariableGuid, SkuInfo.VariableOffset) + HiiInfo =3D '## %s|%s|%s' % ( + SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInf= o.VariableOffset) break if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComme= nts: - PcdCommentList =3D self._PcdComments[Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName][:] + PcdCommentList =3D self._PcdComments[Pcd.TokenSpaceGuidCNa= me, + Pcd.TokenCName][:] if HiiInfo: UsageIndex =3D -1 UsageStr =3D '' @@ -1606,7 +1685,8 @@ class ModuleAutoGen(AutoGen): UsageIndex =3D Index break if UsageIndex !=3D -1: - PcdCommentList[UsageIndex] =3D '## %s %s %s' % (UsageS= tr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, '')) + PcdCommentList[UsageIndex] =3D '## %s %s %s' % ( + UsageStr, HiiInfo, PcdCommentList[UsageIndex].repl= ace(UsageStr, '')) else: PcdCommentList.append('## UNDEFINED ' + HiiInfo) PcdComments =3D '\n '.join(PcdCommentList) @@ -1616,11 +1696,13 @@ class ModuleAutoGen(AutoGen): AsBuiltInfDict['pcd_item'].append(PcdEntry) for Item in self.BuildOption: if 'FLAGS' in self.BuildOption[Item]: - AsBuiltInfDict['flags_item'].append('%s:%s_%s_%s_%s_FLAGS = =3D %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arc= h, Item, self.BuildOption[Item]['FLAGS'].strip())) + AsBuiltInfDict['flags_item'].append('%s:%s_%s_%s_%s_FLAGS = =3D %s' % ( + self.ToolChainFamily, self.BuildTarget, self.ToolChain= , self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())) =20 # Generated LibraryClasses section in comments. for Library in self.LibraryAutoGenList: - AsBuiltInfDict['libraryclasses_item'].append(Library.MetaFile.= File.replace('\\', '/')) + AsBuiltInfDict['libraryclasses_item'].append( + Library.MetaFile.File.replace('\\', '/')) =20 # Generated UserExtensions TianoCore section. # All tianocore user extensions are copied. @@ -1639,7 +1721,8 @@ class ModuleAutoGen(AutoGen): AsBuiltInf =3D TemplateString() AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict)) =20 - SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'),= str(AsBuiltInf), False) + SaveFileOnChange(os.path.join( + self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False) =20 self.IsAsBuiltInfCreated =3D True =20 @@ -1654,7 +1737,8 @@ class ModuleAutoGen(AutoGen): try: CopyFileOnChange(File, destination_dir) except: - EdkLogger.quiet("[cache warning]: fail to copy file:%s to fold= er:%s" % (File, destination_dir)) + EdkLogger.quiet("[cache warning]: fail to copy file:%s to fold= er:%s" % ( + File, destination_dir)) return =20 def CopyModuleToCache(self): @@ -1664,42 +1748,52 @@ class ModuleAutoGen(AutoGen): PreMakeHashStr =3D None MakeTimeStamp =3D 0 PreMakeTimeStamp =3D 0 - Files =3D [f for f in os.listdir(LongFilePath(self.BuildDir)) if p= ath.isfile(LongFilePath(path.join(self.BuildDir, f)))] + Files =3D [f for f in os.listdir(LongFilePath(self.BuildDir)) if p= ath.isfile( + LongFilePath(path.join(self.BuildDir, f)))] for File in Files: if ".MakeHashFileList." in File: - #find lastest file through time stamp - FileTimeStamp =3D os.stat(LongFilePath(path.join(self.Buil= dDir, File)))[8] + # find lastest file through time stamp + FileTimeStamp =3D os.stat(LongFilePath( + path.join(self.BuildDir, File)))[8] if FileTimeStamp > MakeTimeStamp: MakeTimeStamp =3D FileTimeStamp MakeHashStr =3D File.split('.')[-1] if len(MakeHashStr) !=3D 32: - EdkLogger.quiet("[cache error]: wrong MakeHashFile= List file:%s" % (File)) + EdkLogger.quiet( + "[cache error]: wrong MakeHashFileList file:%s= " % (File)) if ".PreMakeHashFileList." in File: - FileTimeStamp =3D os.stat(LongFilePath(path.join(self.Buil= dDir, File)))[8] + FileTimeStamp =3D os.stat(LongFilePath( + path.join(self.BuildDir, File)))[8] if FileTimeStamp > PreMakeTimeStamp: PreMakeTimeStamp =3D FileTimeStamp PreMakeHashStr =3D File.split('.')[-1] if len(PreMakeHashStr) !=3D 32: - EdkLogger.quiet("[cache error]: wrong PreMakeHashF= ileList file:%s" % (File)) + EdkLogger.quiet( + "[cache error]: wrong PreMakeHashFileList file= :%s" % (File)) =20 if not MakeHashStr: - EdkLogger.quiet("[cache error]: No MakeHashFileList file for m= odule:%s[%s]" % (self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache error]: No MakeHashFileList file for m= odule:%s[%s]" % ( + self.MetaFile.Path, self.Arch)) return if not PreMakeHashStr: - EdkLogger.quiet("[cache error]: No PreMakeHashFileList file fo= r module:%s[%s]" % (self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache error]: No PreMakeHashFileList file fo= r module:%s[%s]" % ( + self.MetaFile.Path, self.Arch)) return =20 # Create Cache destination dirs - FileDir =3D path.join(GlobalData.gBinCacheDest, self.PlatformInfo.= OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, self.SourceD= ir, self.MetaFile.BaseName) - FfsDir =3D path.join(GlobalData.gBinCacheDest, self.PlatformInfo.O= utputDir, self.BuildTarget + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs",= self.Guid + self.Name) + FileDir =3D path.join(GlobalData.gBinCacheDest, self.PlatformInfo.= OutputDir, self.BuildTarget + + "_" + self.ToolChain, self.Arch, self.SourceDi= r, self.MetaFile.BaseName) + FfsDir =3D path.join(GlobalData.gBinCacheDest, self.PlatformInfo.O= utputDir, self.BuildTarget + + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs", = self.Guid + self.Name) CacheFileDir =3D path.join(FileDir, MakeHashStr) CacheFfsDir =3D path.join(FfsDir, MakeHashStr) - CreateDirectory (CacheFileDir) - CreateDirectory (CacheFfsDir) + CreateDirectory(CacheFileDir) + CreateDirectory(CacheFfsDir) =20 # Create ModuleHashPair file to support multiple version cache tog= ether ModuleHashPair =3D path.join(FileDir, self.Name + ".ModuleHashPair= ") - ModuleHashPairList =3D [] # tuple list: [tuple(PreMakefileHash, Ma= keHash)] + # tuple list: [tuple(PreMakefileHash, MakeHash)] + ModuleHashPairList =3D [] if os.path.exists(ModuleHashPair): with open(ModuleHashPair, 'r') as f: ModuleHashPairList =3D json.load(f) @@ -1710,44 +1804,46 @@ class ModuleAutoGen(AutoGen): =20 # Copy files to Cache destination dirs if not self.OutputFile: - Ma =3D self.BuildDatabase[self.MetaFile, self.Arch, self.Build= Target, self.ToolChain] + Ma =3D self.BuildDatabase[self.MetaFile, + self.Arch, self.BuildTarget, self.Tool= Chain] self.OutputFile =3D Ma.Binaries for File in self.OutputFile: if File.startswith(os.path.abspath(self.FfsOutputDir)+os.sep): self.CacheCopyFile(CacheFfsDir, self.FfsOutputDir, File) else: - if self.Name + ".autogen.hash." in File or \ - self.Name + ".autogen.hashchain." in File or \ - self.Name + ".hash." in File or \ - self.Name + ".hashchain." in File or \ - self.Name + ".PreMakeHashFileList." in File or \ - self.Name + ".MakeHashFileList." in File: + if self.Name + ".autogen.hash." in File or \ + self.Name + ".autogen.hashchain." in File or \ + self.Name + ".hash." in File or \ + self.Name + ".hashchain." in File or \ + self.Name + ".PreMakeHashFileList." in File or \ + self.Name + ".MakeHashFileList." in File: self.CacheCopyFile(FileDir, self.BuildDir, File) else: self.CacheCopyFile(CacheFileDir, self.BuildDir, File) - ## Create makefile for the module and its dependent libraries + # Create makefile for the module and its dependent libraries # # @param CreateLibraryMakeFile Flag indicating if or not the = makefiles of # dependent libraries will be cr= eated # + @cached_class_function - def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue, GenFfsList =3D = []): + def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue, GenFfsList=3D[]= ): =20 # nest this function inside it's only caller. def CreateTimeStamp(): FileSet =3D {self.MetaFile.Path} =20 for SourceFile in self.Module.Sources: - FileSet.add (SourceFile.Path) + FileSet.add(SourceFile.Path) =20 for Lib in self.DependentLibraryList: - FileSet.add (Lib.MetaFile.Path) + FileSet.add(Lib.MetaFile.Path) =20 for f in self.AutoGenDepSet: - FileSet.add (f.Path) + FileSet.add(f.Path) =20 - if os.path.exists (self.TimeStampPath): - os.remove (self.TimeStampPath) + if os.path.exists(self.TimeStampPath): + os.remove(self.TimeStampPath) =20 SaveFileOnChange(self.TimeStampPath, "\n".join(FileSet), False) =20 @@ -1789,11 +1885,12 @@ class ModuleAutoGen(AutoGen): SrcPath =3D File.Path DstPath =3D os.path.join(self.OutputDir, os.path.basename(SrcP= ath)) CopyLongFilePath(SrcPath, DstPath) - ## Create autogen code for the module and its dependent libraries + # Create autogen code for the module and its dependent libraries # # @param CreateLibraryCodeFile Flag indicating if or not the = code of # dependent libraries will be cr= eated # + def CreateCodeFile(self, CreateLibraryCodeFile=3DTrue): =20 if self.IsCodeFileCreated: @@ -1822,14 +1919,14 @@ class ModuleAutoGen(AutoGen): else: IgoredAutoGenList.append(str(File)) =20 - for ModuleType in self.DepexList: # Ignore empty [depex] section or [depex] section for SUP_MODU= LE_USER_DEFINED module if len(self.DepexList[ModuleType]) =3D=3D 0 or ModuleType =3D= =3D SUP_MODULE_USER_DEFINED or ModuleType =3D=3D SUP_MODULE_HOST_APPLICATIO= N: continue =20 - Dpx =3D GenDepex.DependencyExpression(self.DepexList[ModuleTyp= e], ModuleType, True) - DpxFile =3D gAutoGenDepexFileName % {"module_name" : self.Name} + Dpx =3D GenDepex.DependencyExpression( + self.DepexList[ModuleType], ModuleType, True) + DpxFile =3D gAutoGenDepexFileName % {"module_name": self.Name} =20 if len(Dpx.PostfixNotation) !=3D 0: self.DepexGenerated =3D True @@ -1853,20 +1950,20 @@ class ModuleAutoGen(AutoGen): =20 return AutoGenList =20 - ## Summarize the ModuleAutoGen objects of all libraries used by this m= odule + # Summarize the ModuleAutoGen objects of all libraries used by this mo= dule @cached_property def LibraryAutoGenList(self): RetVal =3D [] for Library in self.DependentLibraryList: La =3D ModuleAutoGen( - self.Workspace, - Library.MetaFile, - self.BuildTarget, - self.ToolChain, - self.Arch, - self.PlatformInfo.MetaFile, - self.DataPipe - ) + self.Workspace, + Library.MetaFile, + self.BuildTarget, + self.ToolChain, + self.Arch, + self.PlatformInfo.MetaFile, + self.DataPipe + ) La.IsLibrary =3D True if La not in RetVal: RetVal.append(La) @@ -1888,10 +1985,11 @@ class ModuleAutoGen(AutoGen): # Add Makefile abspath =3D path.join(self.BuildDir, self.Name + ".makefile") try: - with open(LongFilePath(abspath),"r") as fd: + with open(LongFilePath(abspath), "r") as fd: lines =3D fd.readlines() except Exception as e: - EdkLogger.error("build",FILE_NOT_FOUND, "%s doesn't exist" % a= bspath, ExtraData=3Dstr(e), RaiseError=3DFalse) + EdkLogger.error("build", FILE_NOT_FOUND, "%s doesn't exist" % + abspath, ExtraData=3Dstr(e), RaiseError=3DFals= e) if lines: DependencyFileSet.update(lines) =20 @@ -1901,20 +1999,24 @@ class ModuleAutoGen(AutoGen): m =3D hashlib.md5() for File in sorted(DependencyFileSet, key=3Dlambda x: str(x)): if not path.exists(LongFilePath(str(File))): - EdkLogger.quiet("[cache warning]: header file %s is missin= g for module: %s[%s]" % (File, self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache warning]: header file %s is missin= g for module: %s[%s]" % ( + File, self.MetaFile.Path, self.Arch)) continue with open(LongFilePath(str(File)), 'rb') as f: Content =3D f.read() m.update(Content) FileList.append((str(File), hashlib.md5(Content).hexdigest())) =20 - HashChainFile =3D path.join(self.BuildDir, self.Name + ".autogen.h= ashchain." + m.hexdigest()) - GlobalData.gCMakeHashFile[(self.MetaFile.Path, self.Arch)] =3D Has= hChainFile + HashChainFile =3D path.join( + self.BuildDir, self.Name + ".autogen.hashchain." + m.hexdigest= ()) + GlobalData.gCMakeHashFile[( + self.MetaFile.Path, self.Arch)] =3D HashChainFile try: with open(LongFilePath(HashChainFile), 'w') as f: json.dump(FileList, f, indent=3D2) except: - EdkLogger.quiet("[cache warning]: fail to save hashchain file:= %s" % HashChainFile) + EdkLogger.quiet( + "[cache warning]: fail to save hashchain file:%s" % HashCh= ainFile) return False =20 def GenModuleHash(self): @@ -1939,17 +2041,18 @@ class ModuleAutoGen(AutoGen): abspath =3D path.join(self.BuildDir, "deps.txt") rt =3D None try: - with open(LongFilePath(abspath),"r") as fd: + with open(LongFilePath(abspath), "r") as fd: lines =3D fd.readlines() if lines: - rt =3D set([item.lstrip().strip("\n") for item in line= s if item.strip("\n").endswith(".h")]) + rt =3D set([item.lstrip().strip("\n") + for item in lines if item.strip("\n").endswit= h(".h")]) except Exception as e: - EdkLogger.error("build",FILE_NOT_FOUND, "%s doesn't exist" % a= bspath, ExtraData=3Dstr(e), RaiseError=3DFalse) + EdkLogger.error("build", FILE_NOT_FOUND, "%s doesn't exist" % + abspath, ExtraData=3Dstr(e), RaiseError=3DFals= e) =20 if rt: DependencyFileSet.update(rt) =20 - # Caculate all above dependency files hash # Initialze hash object FileList =3D [] @@ -1961,20 +2064,24 @@ class ModuleAutoGen(AutoGen): if BuildDirStr in path.abspath(File).lower(): continue if not path.exists(LongFilePath(File)): - EdkLogger.quiet("[cache warning]: header file %s is missin= g for module: %s[%s]" % (File, self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache warning]: header file %s is missin= g for module: %s[%s]" % ( + File, self.MetaFile.Path, self.Arch)) continue with open(LongFilePath(File), 'rb') as f: Content =3D f.read() m.update(Content) FileList.append((File, hashlib.md5(Content).hexdigest())) =20 - HashChainFile =3D path.join(self.BuildDir, self.Name + ".hashchain= ." + m.hexdigest()) - GlobalData.gModuleHashFile[(self.MetaFile.Path, self.Arch)] =3D Ha= shChainFile + HashChainFile =3D path.join( + self.BuildDir, self.Name + ".hashchain." + m.hexdigest()) + GlobalData.gModuleHashFile[( + self.MetaFile.Path, self.Arch)] =3D HashChainFile try: with open(LongFilePath(HashChainFile), 'w') as f: json.dump(FileList, f, indent=3D2) except: - EdkLogger.quiet("[cache warning]: fail to save hashchain file:= %s" % HashChainFile) + EdkLogger.quiet( + "[cache warning]: fail to save hashchain file:%s" % HashCh= ainFile) return False =20 def GenPreMakefileHashList(self): @@ -1998,56 +2105,68 @@ class ModuleAutoGen(AutoGen): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]: No Platform HashFile: %s" % = HashFile) + EdkLogger.quiet( + "[cache warning]: No Platform HashFile: %s" % HashFile) =20 # Add Package level hash if self.DependentPackageList: for Pkg in sorted(self.DependentPackageList, key=3Dlambda x: x= .PackageName): if not (Pkg.PackageName, Pkg.Arch) in GlobalData.gPackageH= ashFile: - EdkLogger.quiet("[cache warning]:No Package %s for mod= ule %s[%s]" % (Pkg.PackageName, self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache warning]:No Package %s for mod= ule %s[%s]" % ( + Pkg.PackageName, self.MetaFile.Path, self.Arch)) continue - HashFile =3D GlobalData.gPackageHashFile[(Pkg.PackageName,= Pkg.Arch)] + HashFile =3D GlobalData.gPackageHashFile[( + Pkg.PackageName, Pkg.Arch)] if path.exists(LongFilePath(HashFile)): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No Package HashFile: = %s" % HashFile) + EdkLogger.quiet( + "[cache warning]:No Package HashFile: %s" % HashFi= le) =20 # Add Module self # GenPreMakefileHashList needed in both --binary-destination # and --hash. And --hash might save ModuleHashFile in remote dict # during multiprocessing. if (self.MetaFile.Path, self.Arch) in GlobalData.gModuleHashFile: - HashFile =3D GlobalData.gModuleHashFile[(self.MetaFile.Path, s= elf.Arch)] + HashFile =3D GlobalData.gModuleHashFile[( + self.MetaFile.Path, self.Arch)] else: - EdkLogger.quiet("[cache error]:No ModuleHashFile for module: %= s[%s]" % (self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache error]:No ModuleHashFile for module: %= s[%s]" % ( + self.MetaFile.Path, self.Arch)) if path.exists(LongFilePath(HashFile)): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No Module HashFile: %s" % Has= hFile) + EdkLogger.quiet( + "[cache warning]:No Module HashFile: %s" % HashFile) =20 # Add Library hash if self.LibraryAutoGenList: for Lib in sorted(self.LibraryAutoGenList, key=3Dlambda x: x.M= etaFile.Path): =20 if (Lib.MetaFile.Path, Lib.Arch) in GlobalData.gModuleHash= File: - HashFile =3D GlobalData.gModuleHashFile[(Lib.MetaFile.= Path, Lib.Arch)] + HashFile =3D GlobalData.gModuleHashFile[( + Lib.MetaFile.Path, Lib.Arch)] else: - EdkLogger.quiet("[cache error]:No ModuleHashFile for l= ib: %s[%s]" % (Lib.MetaFile.Path, Lib.Arch)) + EdkLogger.quiet("[cache error]:No ModuleHashFile for l= ib: %s[%s]" % ( + Lib.MetaFile.Path, Lib.Arch)) if path.exists(LongFilePath(HashFile)): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No Lib HashFile: %s" = % HashFile) + EdkLogger.quiet( + "[cache warning]:No Lib HashFile: %s" % HashFile) =20 # Save PreMakeHashFileList - FilePath =3D path.join(self.BuildDir, self.Name + ".PreMakeHashFil= eList." + m.hexdigest()) + FilePath =3D path.join(self.BuildDir, self.Name + + ".PreMakeHashFileList." + m.hexdigest()) try: with open(LongFilePath(FilePath), 'w') as f: json.dump(FileList, f, indent=3D0) except: - EdkLogger.quiet("[cache warning]: fail to save PreMake HashFil= eList: %s" % FilePath) + EdkLogger.quiet( + "[cache warning]: fail to save PreMake HashFileList: %s" %= FilePath) =20 def GenMakefileHashList(self): # GenMakefileHashList only need in --binary-destination which will @@ -2065,39 +2184,48 @@ class ModuleAutoGen(AutoGen): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No AutoGen HashFile: %s" % Ha= shFile) + EdkLogger.quiet( + "[cache warning]:No AutoGen HashFile: %s" % HashFile) =20 # Add Module self if (self.MetaFile.Path, self.Arch) in GlobalData.gModuleHashFile: - HashFile =3D GlobalData.gModuleHashFile[(self.MetaFile.Path, s= elf.Arch)] + HashFile =3D GlobalData.gModuleHashFile[( + self.MetaFile.Path, self.Arch)] else: - EdkLogger.quiet("[cache error]:No ModuleHashFile for module: %= s[%s]" % (self.MetaFile.Path, self.Arch)) + EdkLogger.quiet("[cache error]:No ModuleHashFile for module: %= s[%s]" % ( + self.MetaFile.Path, self.Arch)) if path.exists(LongFilePath(HashFile)): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No Module HashFile: %s" % Has= hFile) + EdkLogger.quiet( + "[cache warning]:No Module HashFile: %s" % HashFile) =20 # Add Library hash if self.LibraryAutoGenList: for Lib in sorted(self.LibraryAutoGenList, key=3Dlambda x: x.M= etaFile.Path): if (Lib.MetaFile.Path, Lib.Arch) in GlobalData.gModuleHash= File: - HashFile =3D GlobalData.gModuleHashFile[(Lib.MetaFile.= Path, Lib.Arch)] + HashFile =3D GlobalData.gModuleHashFile[( + Lib.MetaFile.Path, Lib.Arch)] else: - EdkLogger.quiet("[cache error]:No ModuleHashFile for l= ib: %s[%s]" % (Lib.MetaFile.Path, Lib.Arch)) + EdkLogger.quiet("[cache error]:No ModuleHashFile for l= ib: %s[%s]" % ( + Lib.MetaFile.Path, Lib.Arch)) if path.exists(LongFilePath(HashFile)): FileList.append(HashFile) m.update(HashFile.encode('utf-8')) else: - EdkLogger.quiet("[cache warning]:No Lib HashFile: %s" = % HashFile) + EdkLogger.quiet( + "[cache warning]:No Lib HashFile: %s" % HashFile) =20 # Save MakeHashFileList - FilePath =3D path.join(self.BuildDir, self.Name + ".MakeHashFileLi= st." + m.hexdigest()) + FilePath =3D path.join(self.BuildDir, self.Name + + ".MakeHashFileList." + m.hexdigest()) try: with open(LongFilePath(FilePath), 'w') as f: json.dump(FileList, f, indent=3D0) except: - EdkLogger.quiet("[cache warning]: fail to save Make HashFileLi= st: %s" % FilePath) + EdkLogger.quiet( + "[cache warning]: fail to save Make HashFileList: %s" % Fi= lePath) =20 def CheckHashChainFile(self, HashChainFile): # Assume the HashChainFile basename format is the 'x.hashchain.16B= ytesHexStr' @@ -2105,19 +2233,21 @@ class ModuleAutoGen(AutoGen): # all hashchain files content HashStr =3D HashChainFile.split('.')[-1] if len(HashStr) !=3D 32: - EdkLogger.quiet("[cache error]: wrong format HashChainFile:%s"= % (File)) + EdkLogger.quiet( + "[cache error]: wrong format HashChainFile:%s" % (File)) return False =20 try: with open(LongFilePath(HashChainFile), 'r') as f: HashChainList =3D json.load(f) except: - EdkLogger.quiet("[cache error]: fail to load HashChainFile: %s= " % HashChainFile) + EdkLogger.quiet( + "[cache error]: fail to load HashChainFile: %s" % HashChai= nFile) return False =20 # Print the different file info # print(HashChainFile) - for idx, (SrcFile, SrcHash) in enumerate (HashChainList): + for idx, (SrcFile, SrcHash) in enumerate(HashChainList): if SrcFile in GlobalData.gFileHashDict: DestHash =3D GlobalData.gFileHashDict[SrcFile] else: @@ -2129,15 +2259,17 @@ class ModuleAutoGen(AutoGen): except IOError as X: # cache miss if SrcFile is removed in new version code GlobalData.gFileHashDict[SrcFile] =3D 0 - EdkLogger.quiet("[cache insight]: first cache miss fil= e in %s is %s" % (HashChainFile, SrcFile)) + EdkLogger.quiet("[cache insight]: first cache miss fil= e in %s is %s" % ( + HashChainFile, SrcFile)) return False if SrcHash !=3D DestHash: - EdkLogger.quiet("[cache insight]: first cache miss file in= %s is %s" % (HashChainFile, SrcFile)) + EdkLogger.quiet("[cache insight]: first cache miss file in= %s is %s" % ( + HashChainFile, SrcFile)) return False =20 return True =20 - ## Decide whether we can skip the left autogen and make process + # Decide whether we can skip the left autogen and make process def CanSkipbyMakeCache(self): # For --binary-source only # CanSkipbyMakeCache consume below dicts: @@ -2155,44 +2287,57 @@ class ModuleAutoGen(AutoGen): =20 # If Module is binary, which has special build rule, do not skip b= y cache. if self.IsBinaryModule: - print("[cache miss]: MakeCache: Skip BinaryModule:", self.Meta= File.Path, self.Arch) - GlobalData.gModuleMakeCacheStatus[(self.MetaFile.Path, self.Ar= ch)] =3D False + print("[cache miss]: MakeCache: Skip BinaryModule:", + self.MetaFile.Path, self.Arch) + GlobalData.gModuleMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 # see .inc as binary file, do not skip by hash for f_ext in self.SourceFileList: if '.inc' in str(f_ext): - print("[cache miss]: MakeCache: Skip '.inc' File:", self.M= etaFile.Path, self.Arch) - GlobalData.gModuleMakeCacheStatus[(self.MetaFile.Path, sel= f.Arch)] =3D False + print("[cache miss]: MakeCache: Skip '.inc' File:", + self.MetaFile.Path, self.Arch) + GlobalData.gModuleMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 - ModuleCacheDir =3D path.join(GlobalData.gBinCacheSource, self.Plat= formInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, sel= f.SourceDir, self.MetaFile.BaseName) - FfsDir =3D path.join(GlobalData.gBinCacheSource, self.PlatformInfo= .OutputDir, self.BuildTarget + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs= ", self.Guid + self.Name) + ModuleCacheDir =3D path.join(GlobalData.gBinCacheSource, self.Plat= formInfo.OutputDir, + self.BuildTarget + "_" + self.ToolChain= , self.Arch, self.SourceDir, self.MetaFile.BaseName) + FfsDir =3D path.join(GlobalData.gBinCacheSource, self.PlatformInfo= .OutputDir, + self.BuildTarget + "_" + self.ToolChain, TAB_FV= _DIRECTORY, "Ffs", self.Guid + self.Name) =20 - ModuleHashPairList =3D [] # tuple list: [tuple(PreMakefileHash, Ma= keHash)] - ModuleHashPair =3D path.join(ModuleCacheDir, self.Name + ".ModuleH= ashPair") + # tuple list: [tuple(PreMakefileHash, MakeHash)] + ModuleHashPairList =3D [] + ModuleHashPair =3D path.join( + ModuleCacheDir, self.Name + ".ModuleHashPair") try: with open(LongFilePath(ModuleHashPair), 'r') as f: ModuleHashPairList =3D json.load(f) except: # ModuleHashPair might not exist for new added module - GlobalData.gModuleMakeCacheStatus[(self.MetaFile.Path, self.Ar= ch)] =3D False - EdkLogger.quiet("[cache warning]: fail to load ModuleHashPair = file: %s" % ModuleHashPair) + GlobalData.gModuleMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False + EdkLogger.quiet( + "[cache warning]: fail to load ModuleHashPair file: %s" % = ModuleHashPair) print("[cache miss]: MakeCache:", self.MetaFile.Path, self.Arc= h) return False =20 # Check the PreMakeHash in ModuleHashPairList one by one - for idx, (PreMakefileHash, MakeHash) in enumerate (ModuleHashPairL= ist): + for idx, (PreMakefileHash, MakeHash) in enumerate(ModuleHashPairLi= st): SourceHashDir =3D path.join(ModuleCacheDir, MakeHash) SourceFfsHashDir =3D path.join(FfsDir, MakeHash) - PreMakeHashFileList_FilePah =3D path.join(ModuleCacheDir, self= .Name + ".PreMakeHashFileList." + PreMakefileHash) - MakeHashFileList_FilePah =3D path.join(ModuleCacheDir, self.Na= me + ".MakeHashFileList." + MakeHash) + PreMakeHashFileList_FilePah =3D path.join( + ModuleCacheDir, self.Name + ".PreMakeHashFileList." + PreM= akefileHash) + MakeHashFileList_FilePah =3D path.join( + ModuleCacheDir, self.Name + ".MakeHashFileList." + MakeHas= h) =20 try: with open(LongFilePath(MakeHashFileList_FilePah), 'r') as = f: MakeHashFileList =3D json.load(f) except: - EdkLogger.quiet("[cache error]: fail to load MakeHashFileL= ist file: %s" % MakeHashFileList_FilePah) + EdkLogger.quiet( + "[cache error]: fail to load MakeHashFileList file: %s= " % MakeHashFileList_FilePah) continue =20 HashMiss =3D False @@ -2206,13 +2351,16 @@ class ModuleAutoGen(AutoGen): elif HashChainStatus =3D=3D True: continue # Convert to path start with cache source dir - RelativePath =3D os.path.relpath(HashChainFile, self.Works= paceDir) - NewFilePath =3D os.path.join(GlobalData.gBinCacheSource, R= elativePath) + RelativePath =3D os.path.relpath( + HashChainFile, self.WorkspaceDir) + NewFilePath =3D os.path.join( + GlobalData.gBinCacheSource, RelativePath) if self.CheckHashChainFile(NewFilePath): GlobalData.gHashChainStatus[HashChainFile] =3D True # Save the module self HashFile for GenPreMakefileHash= List later usage if self.Name + ".hashchain." in HashChainFile: - GlobalData.gModuleHashFile[(self.MetaFile.Path, se= lf.Arch)] =3D HashChainFile + GlobalData.gModuleHashFile[( + self.MetaFile.Path, self.Arch)] =3D HashChainF= ile else: GlobalData.gHashChainStatus[HashChainFile] =3D False HashMiss =3D True @@ -2230,20 +2378,23 @@ class ModuleAutoGen(AutoGen): for root, dir, files in os.walk(SourceFfsHashDir): for f in files: File =3D path.join(root, f) - self.CacheCopyFile(self.FfsOutputDir, SourceFfsHas= hDir, File) + self.CacheCopyFile( + self.FfsOutputDir, SourceFfsHashDir, File) =20 if self.Name =3D=3D "PcdPeim" or self.Name =3D=3D "PcdDxe": CreatePcdDatabaseCode(self, TemplateString(), TemplateStri= ng()) =20 print("[cache hit]: MakeCache:", self.MetaFile.Path, self.Arch) - GlobalData.gModuleMakeCacheStatus[(self.MetaFile.Path, self.Ar= ch)] =3D True + GlobalData.gModuleMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D True return True =20 print("[cache miss]: MakeCache:", self.MetaFile.Path, self.Arch) - GlobalData.gModuleMakeCacheStatus[(self.MetaFile.Path, self.Arch)]= =3D False + GlobalData.gModuleMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 - ## Decide whether we can skip the left autogen and make process + # Decide whether we can skip the left autogen and make process def CanSkipbyPreMakeCache(self): # CanSkipbyPreMakeCache consume below dicts: # gModulePreMakeCacheStatus @@ -2261,20 +2412,25 @@ class ModuleAutoGen(AutoGen): =20 # If Module is binary, which has special build rule, do not skip b= y cache. if self.IsBinaryModule: - print("[cache miss]: PreMakeCache: Skip BinaryModule:", self.M= etaFile.Path, self.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, self= .Arch)] =3D False + print("[cache miss]: PreMakeCache: Skip BinaryModule:", + self.MetaFile.Path, self.Arch) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 # see .inc as binary file, do not skip by hash for f_ext in self.SourceFileList: if '.inc' in str(f_ext): - print("[cache miss]: PreMakeCache: Skip '.inc' File:", sel= f.MetaFile.Path, self.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, = self.Arch)] =3D False + print("[cache miss]: PreMakeCache: Skip '.inc' File:", + self.MetaFile.Path, self.Arch) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 # For --hash only in the incremental build if not GlobalData.gBinCacheSource: - Files =3D [path.join(self.BuildDir, f) for f in os.listdir(sel= f.BuildDir) if path.isfile(path.join(self.BuildDir, f))] + Files =3D [path.join(self.BuildDir, f) for f in os.listdir( + self.BuildDir) if path.isfile(path.join(self.BuildDir, f))] PreMakeHashFileList_FilePah =3D None MakeTimeStamp =3D 0 # Find latest PreMakeHashFileList file in self.BuildDir folder @@ -2285,16 +2441,20 @@ class ModuleAutoGen(AutoGen): MakeTimeStamp =3D FileTimeStamp PreMakeHashFileList_FilePah =3D File if not PreMakeHashFileList_FilePah: - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, = self.Arch)] =3D False + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 try: with open(LongFilePath(PreMakeHashFileList_FilePah), 'r') = as f: PreMakeHashFileList =3D json.load(f) except: - EdkLogger.quiet("[cache error]: fail to load PreMakeHashFi= leList file: %s" % PreMakeHashFileList_FilePah) - print("[cache miss]: PreMakeCache:", self.MetaFile.Path, s= elf.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, = self.Arch)] =3D False + EdkLogger.quiet( + "[cache error]: fail to load PreMakeHashFileList file:= %s" % PreMakeHashFileList_FilePah) + print("[cache miss]: PreMakeCache:", + self.MetaFile.Path, self.Arch) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 HashMiss =3D False @@ -2311,48 +2471,62 @@ class ModuleAutoGen(AutoGen): GlobalData.gHashChainStatus[HashChainFile] =3D True # Save the module self HashFile for GenPreMakefileHash= List later usage if self.Name + ".hashchain." in HashChainFile: - GlobalData.gModuleHashFile[(self.MetaFile.Path, se= lf.Arch)] =3D HashChainFile + GlobalData.gModuleHashFile[( + self.MetaFile.Path, self.Arch)] =3D HashChainF= ile else: GlobalData.gHashChainStatus[HashChainFile] =3D False HashMiss =3D True break =20 if HashMiss: - print("[cache miss]: PreMakeCache:", self.MetaFile.Path, s= elf.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, = self.Arch)] =3D False + print("[cache miss]: PreMakeCache:", + self.MetaFile.Path, self.Arch) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False else: - print("[cache hit]: PreMakeCache:", self.MetaFile.Path, se= lf.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, = self.Arch)] =3D True + print("[cache hit]: PreMakeCache:", + self.MetaFile.Path, self.Arch) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D True return True =20 - ModuleCacheDir =3D path.join(GlobalData.gBinCacheSource, self.Plat= formInfo.OutputDir, self.BuildTarget + "_" + self.ToolChain, self.Arch, sel= f.SourceDir, self.MetaFile.BaseName) - FfsDir =3D path.join(GlobalData.gBinCacheSource, self.PlatformInfo= .OutputDir, self.BuildTarget + "_" + self.ToolChain, TAB_FV_DIRECTORY, "Ffs= ", self.Guid + self.Name) + ModuleCacheDir =3D path.join(GlobalData.gBinCacheSource, self.Plat= formInfo.OutputDir, + self.BuildTarget + "_" + self.ToolChain= , self.Arch, self.SourceDir, self.MetaFile.BaseName) + FfsDir =3D path.join(GlobalData.gBinCacheSource, self.PlatformInfo= .OutputDir, + self.BuildTarget + "_" + self.ToolChain, TAB_FV= _DIRECTORY, "Ffs", self.Guid + self.Name) =20 - ModuleHashPairList =3D [] # tuple list: [tuple(PreMakefileHash, Ma= keHash)] - ModuleHashPair =3D path.join(ModuleCacheDir, self.Name + ".ModuleH= ashPair") + # tuple list: [tuple(PreMakefileHash, MakeHash)] + ModuleHashPairList =3D [] + ModuleHashPair =3D path.join( + ModuleCacheDir, self.Name + ".ModuleHashPair") try: with open(LongFilePath(ModuleHashPair), 'r') as f: ModuleHashPairList =3D json.load(f) except: # ModuleHashPair might not exist for new added module - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, self= .Arch)] =3D False - EdkLogger.quiet("[cache warning]: fail to load ModuleHashPair = file: %s" % ModuleHashPair) + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False + EdkLogger.quiet( + "[cache warning]: fail to load ModuleHashPair file: %s" % = ModuleHashPair) print("[cache miss]: PreMakeCache:", self.MetaFile.Path, self.= Arch) return False =20 # Check the PreMakeHash in ModuleHashPairList one by one - for idx, (PreMakefileHash, MakeHash) in enumerate (ModuleHashPairL= ist): + for idx, (PreMakefileHash, MakeHash) in enumerate(ModuleHashPairLi= st): SourceHashDir =3D path.join(ModuleCacheDir, MakeHash) SourceFfsHashDir =3D path.join(FfsDir, MakeHash) - PreMakeHashFileList_FilePah =3D path.join(ModuleCacheDir, self= .Name + ".PreMakeHashFileList." + PreMakefileHash) - MakeHashFileList_FilePah =3D path.join(ModuleCacheDir, self.Na= me + ".MakeHashFileList." + MakeHash) + PreMakeHashFileList_FilePah =3D path.join( + ModuleCacheDir, self.Name + ".PreMakeHashFileList." + PreM= akefileHash) + MakeHashFileList_FilePah =3D path.join( + ModuleCacheDir, self.Name + ".MakeHashFileList." + MakeHas= h) =20 try: with open(LongFilePath(PreMakeHashFileList_FilePah), 'r') = as f: PreMakeHashFileList =3D json.load(f) except: - EdkLogger.quiet("[cache error]: fail to load PreMakeHashFi= leList file: %s" % PreMakeHashFileList_FilePah) + EdkLogger.quiet( + "[cache error]: fail to load PreMakeHashFileList file:= %s" % PreMakeHashFileList_FilePah) continue =20 HashMiss =3D False @@ -2366,8 +2540,10 @@ class ModuleAutoGen(AutoGen): elif HashChainStatus =3D=3D True: continue # Convert to path start with cache source dir - RelativePath =3D os.path.relpath(HashChainFile, self.Works= paceDir) - NewFilePath =3D os.path.join(GlobalData.gBinCacheSource, R= elativePath) + RelativePath =3D os.path.relpath( + HashChainFile, self.WorkspaceDir) + NewFilePath =3D os.path.join( + GlobalData.gBinCacheSource, RelativePath) if self.CheckHashChainFile(NewFilePath): GlobalData.gHashChainStatus[HashChainFile] =3D True else: @@ -2387,20 +2563,23 @@ class ModuleAutoGen(AutoGen): for root, dir, files in os.walk(SourceFfsHashDir): for f in files: File =3D path.join(root, f) - self.CacheCopyFile(self.FfsOutputDir, SourceFfsHas= hDir, File) + self.CacheCopyFile( + self.FfsOutputDir, SourceFfsHashDir, File) =20 if self.Name =3D=3D "PcdPeim" or self.Name =3D=3D "PcdDxe": CreatePcdDatabaseCode(self, TemplateString(), TemplateStri= ng()) =20 print("[cache hit]: PreMakeCache:", self.MetaFile.Path, self.A= rch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, self= .Arch)] =3D True + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D True return True =20 print("[cache miss]: PreMakeCache:", self.MetaFile.Path, self.Arch) - GlobalData.gModulePreMakeCacheStatus[(self.MetaFile.Path, self.Arc= h)] =3D False + GlobalData.gModulePreMakeCacheStatus[( + self.MetaFile.Path, self.Arch)] =3D False return False =20 - ## Decide whether we can skip the Module build + # Decide whether we can skip the Module build def CanSkipbyCache(self, gHitSet): # Hashing feature is off if not GlobalData.gBinCacheSource: @@ -2411,7 +2590,7 @@ class ModuleAutoGen(AutoGen): =20 return False =20 - ## Decide whether we can skip the ModuleAutoGen process + # Decide whether we can skip the ModuleAutoGen process # If any source file is newer than the module than we cannot skip # def CanSkip(self): @@ -2422,19 +2601,19 @@ class ModuleAutoGen(AutoGen): return True if not os.path.exists(self.TimeStampPath): return False - #last creation time of the module + # last creation time of the module DstTimeStamp =3D os.stat(self.TimeStampPath)[8] =20 SrcTimeStamp =3D self.Workspace._SrcTimeStamp if SrcTimeStamp > DstTimeStamp: return False =20 - with open(self.TimeStampPath,'r') as f: + with open(self.TimeStampPath, 'r') as f: for source in f: source =3D source.rstrip('\n') if not os.path.exists(source): return False - if source not in ModuleAutoGen.TimeDict : + if source not in ModuleAutoGen.TimeDict: ModuleAutoGen.TimeDict[source] =3D os.stat(source)[8] if ModuleAutoGen.TimeDict[source] > DstTimeStamp: return False diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseT= ools/Source/Python/AutoGen/ModuleAutoGenHelper.py index 036fdac3d7df..1fa3805d2480 100644 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py @@ -1,21 +1,21 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent # from __future__ import absolute_import -from Workspace.WorkspaceDatabase import WorkspaceDatabase,BuildDB +from Workspace.WorkspaceDatabase import WorkspaceDatabase, BuildDB from Common.caching import cached_property -from AutoGen.BuildEngine import BuildRule,AutoGenReqBuildRuleVerNum +from AutoGen.BuildEngine import BuildRule, AutoGenReqBuildRuleVerNum from AutoGen.AutoGen import CalculatePriorityValue -from Common.Misc import CheckPcdDatum,GuidValue +from Common.Misc import CheckPcdDatum, GuidValue from Common.Expression import ValueExpressionEx from Common.DataType import * from CommonDataClass.Exceptions import * from CommonDataClass.CommonClass import SkuInfoClass import Common.EdkLogger as EdkLogger -from Common.BuildToolError import OPTION_CONFLICT,FORMAT_INVALID,RESOURCE_= NOT_AVAILABLE +from Common.BuildToolError import OPTION_CONFLICT, FORMAT_INVALID, RESOURC= E_NOT_AVAILABLE from Common.MultipleWorkspace import MultipleWorkspace as mws from collections import defaultdict from Common.Misc import PathClass @@ -25,31 +25,34 @@ import os # # The priority list while override build option # -PrioList =3D {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_AT= TRIBUTE (Highest) - "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTR= IBUTE - "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTR= IBUTE - "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTR= IBUTE - "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTR= IBUTE - "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTR= IBUTE - "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTR= IBUTE - "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTR= IBUTE - "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTR= IBUTE - "0x00101" : 5, # ******_*********_ARCH_***********_ATTR= IBUTE - "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTR= IBUTE - "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTR= IBUTE - "0x10001" : 2, # TARGET_*********_****_***********_ATTR= IBUTE - "0x00001" : 1} # ******_*********_****_***********_ATTR= IBUTE (Lowest) -## Base class for AutoGen +PrioList =3D {"0x11111": 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUT= E (Highest) + "0x01111": 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE + "0x10111": 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE + "0x00111": 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE + "0x11011": 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE + "0x01011": 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE + "0x10011": 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE + "0x00011": 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE + "0x11101": 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE + "0x01101": 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE + "0x10101": 6, # TARGET_*********_ARCH_***********_ATTRIBUTE + "0x00101": 5, # ******_*********_ARCH_***********_ATTRIBUTE + "0x11001": 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE + "0x01001": 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE + "0x10001": 2, # TARGET_*********_****_***********_ATTRIBUTE + "0x00001": 1} # ******_*********_****_***********_ATTRIBUTE (= Lowest) +# Base class for AutoGen # # This class just implements the cache mechanism of AutoGen objects. # + + class AutoGenInfo(object): # database to maintain the objects in each child class - __ObjectCache =3D {} # (BuildTarget, ToolChain, ARCH, platform file= ): AutoGen object + # (BuildTarget, ToolChain, ARCH, platform file): AutoGen object + __ObjectCache =3D {} =20 - ## Factory method + # Factory method # # @param Class class object of real AutoGen class # (WorkspaceAutoGen, ModuleAutoGen or Platfo= rmAutoGen) @@ -64,6 +67,7 @@ class AutoGenInfo(object): @classmethod def GetCache(cls): return cls.__ObjectCache + def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, = **kwargs): # check if the object has been created Key =3D (Target, Toolchain, Arch, MetaFile) @@ -74,17 +78,17 @@ class AutoGenInfo(object): RetVal =3D cls.__ObjectCache[Key] =3D super(AutoGenInfo, cls).__ne= w__(cls) return RetVal =20 - - ## hash() operator + # hash() operator # # The file path of platform file will be used to represent hash value= of this object # # @retval int Hash value of the file path of platform file # + def __hash__(self): return hash(self.MetaFile) =20 - ## str() operator + # str() operator # # The file path of platform file will be used to represent this object # @@ -93,11 +97,11 @@ class AutoGenInfo(object): def __str__(self): return str(self.MetaFile) =20 - ## "=3D=3D" operator + # "=3D=3D" operator def __eq__(self, Other): return Other and self.MetaFile =3D=3D Other =20 - ## Expand * in build option key + # Expand * in build option key # # @param Options Options to be expanded # @param ToolDef Use specified ToolDef instead of full version. @@ -111,7 +115,7 @@ class AutoGenInfo(object): if not ToolDef: ToolDef =3D self.ToolDefinition BuildOptions =3D {} - FamilyMatch =3D False + FamilyMatch =3D False FamilyIsNull =3D True =20 OverrideList =3D {} @@ -124,12 +128,12 @@ class AutoGenInfo(object): # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE # if (Key[0] =3D=3D self.BuildRuleFamily and - (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and = Key[2] =3D=3D ModuleStyle))): + (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 = and Key[2] =3D=3D ModuleStyle))): Target, ToolChain, Arch, CommandType, Attr =3D Key[1].spli= t('_') if (Target =3D=3D self.BuildTarget or Target =3D=3D TAB_ST= AR) and\ (ToolChain =3D=3D self.ToolChain or ToolChain =3D=3D T= AB_STAR) and\ (Arch =3D=3D self.Arch or Arch =3D=3D TAB_STAR) and\ - Options[Key].startswith("=3D"): + Options[Key].startswith("=3D"): =20 if OverrideList.get(Key[1]) is not None: OverrideList.pop(Key[1]) @@ -142,18 +146,20 @@ class AutoGenInfo(object): KeyList =3D list(OverrideList.keys()) for Index in range(len(KeyList)): NowKey =3D KeyList[Index] - Target1, ToolChain1, Arch1, CommandType1, Attr1 =3D NowKey= .split("_") + Target1, ToolChain1, Arch1, CommandType1, Attr1 =3D NowKey= .split( + "_") for Index1 in range(len(KeyList) - Index - 1): NextKey =3D KeyList[Index1 + Index + 1] # # Compare two Key, if one is included by another, choo= se the higher priority one # - Target2, ToolChain2, Arch2, CommandType2, Attr2 =3D Ne= xtKey.split("_") + Target2, ToolChain2, Arch2, CommandType2, Attr2 =3D Ne= xtKey.split( + "_") if (Target1 =3D=3D Target2 or Target1 =3D=3D TAB_STAR = or Target2 =3D=3D TAB_STAR) and\ (ToolChain1 =3D=3D ToolChain2 or ToolChain1 =3D=3D= TAB_STAR or ToolChain2 =3D=3D TAB_STAR) and\ (Arch1 =3D=3D Arch2 or Arch1 =3D=3D TAB_STAR or Ar= ch2 =3D=3D TAB_STAR) and\ (CommandType1 =3D=3D CommandType2 or CommandType1 = =3D=3D TAB_STAR or CommandType2 =3D=3D TAB_STAR) and\ - (Attr1 =3D=3D Attr2 or Attr1 =3D=3D TAB_STAR or At= tr2 =3D=3D TAB_STAR): + (Attr1 =3D=3D Attr2 or Attr1 =3D=3D TAB_STAR o= r Attr2 =3D=3D TAB_STAR): =20 if CalculatePriorityValue(NowKey) > CalculatePrior= ityValue(NextKey): if Options.get((self.BuildRuleFamily, NextKey)= ) is not None: @@ -163,7 +169,7 @@ class AutoGenInfo(object): Options.pop((self.BuildRuleFamily, NowKey)) =20 for Key in Options: - if ModuleStyle is not None and len (Key) > 2: + if ModuleStyle is not None and len(Key) > 2: # Check Module style is EDK or EDKII. # Only append build option for the matched style module. if ModuleStyle =3D=3D EDK_NAME and Key[2] !=3D EDK_NAME: @@ -208,7 +214,7 @@ class AutoGenInfo(object): return BuildOptions =20 for Key in Options: - if ModuleStyle is not None and len (Key) > 2: + if ModuleStyle is not None and len(Key) > 2: # Check Module style is EDK or EDKII. # Only append build option for the matched style module. if ModuleStyle =3D=3D EDK_NAME and Key[2] !=3D EDK_NAME: @@ -249,14 +255,17 @@ class AutoGenInfo(object): BuildOptions[Tool][Attr] =3D Options[Key] return BuildOptions # -#This class is the pruned WorkSpaceAutoGen for ModuleAutoGen in multiple t= hread +# This class is the pruned WorkSpaceAutoGen for ModuleAutoGen in multiple = thread # + + class WorkSpaceInfo(AutoGenInfo): - def __init__(self,Workspace, MetaFile, Target, ToolChain, Arch): + def __init__(self, Workspace, MetaFile, Target, ToolChain, Arch): if not hasattr(self, "_Init"): self.do_init(Workspace, MetaFile, Target, ToolChain, Arch) self._Init =3D True - def do_init(self,Workspace, MetaFile, Target, ToolChain, Arch): + + def do_init(self, Workspace, MetaFile, Target, ToolChain, Arch): self._SrcTimeStamp =3D 0 self.Db =3D BuildDB self.BuildDatabase =3D self.Db.BuildObject @@ -266,6 +275,7 @@ class WorkSpaceInfo(AutoGenInfo): self.ActivePlatform =3D MetaFile self.ArchList =3D Arch self.AutoGenObjectList =3D [] + @property def BuildDir(self): return self.AutoGenObjectList[0].BuildDir @@ -277,9 +287,11 @@ class WorkSpaceInfo(AutoGenInfo): @property def FlashDefinition(self): return self.AutoGenObjectList[0].Platform.FlashDefinition + @property def GenFdsCommandDict(self): - FdsCommandDict =3D self.AutoGenObjectList[0].DataPipe.Get("FdsComm= andDict") + FdsCommandDict =3D self.AutoGenObjectList[0].DataPipe.Get( + "FdsCommandDict") if FdsCommandDict: return FdsCommandDict return {} @@ -288,12 +300,15 @@ class WorkSpaceInfo(AutoGenInfo): def FvDir(self): return os.path.join(self.BuildDir, TAB_FV_DIRECTORY) =20 + class PlatformInfo(AutoGenInfo): - def __init__(self, Workspace, MetaFile, Target, ToolChain, Arch,DataPi= pe): + def __init__(self, Workspace, MetaFile, Target, ToolChain, Arch, DataP= ipe): if not hasattr(self, "_Init"): - self.do_init(Workspace, MetaFile, Target, ToolChain, Arch,Data= Pipe) + self.do_init(Workspace, MetaFile, Target, + ToolChain, Arch, DataPipe) self._Init =3D True - def do_init(self,Workspace, MetaFile, Target, ToolChain, Arch,DataPipe= ): + + def do_init(self, Workspace, MetaFile, Target, ToolChain, Arch, DataPi= pe): self.Wa =3D Workspace self.WorkspaceDir =3D self.Wa.WorkspaceDir self.MetaFile =3D MetaFile @@ -301,10 +316,12 @@ class PlatformInfo(AutoGenInfo): self.Target =3D Target self.BuildTarget =3D Target self.ToolChain =3D ToolChain - self.Platform =3D self.Wa.BuildDatabase[self.MetaFile, self.Arch, = self.Target, self.ToolChain] + self.Platform =3D self.Wa.BuildDatabase[self.MetaFile, + self.Arch, self.Target, self= .ToolChain] =20 self.SourceDir =3D MetaFile.SubDir self.DataPipe =3D DataPipe + @cached_property def _AsBuildModuleList(self): retVal =3D self.DataPipe.Get("AsBuildModuleList") @@ -312,7 +329,7 @@ class PlatformInfo(AutoGenInfo): retVal =3D {} return retVal =20 - ## Test if a module is supported by the platform + # Test if a module is supported by the platform # # An error will be raised directly if the module or its arch is not s= upported # by the platform or current configuration @@ -342,47 +359,48 @@ class PlatformInfo(AutoGenInfo): @cached_property def PackageList(self): RetVal =3D set() - for dec_file,Arch in self.DataPipe.Get("PackageList"): - RetVal.add(self.Wa.BuildDatabase[dec_file,Arch,self.BuildTarge= t, self.ToolChain]) + for dec_file, Arch in self.DataPipe.Get("PackageList"): + RetVal.add( + self.Wa.BuildDatabase[dec_file, Arch, self.BuildTarget, se= lf.ToolChain]) return list(RetVal) =20 - ## Return the directory to store all intermediate and final files built + # Return the directory to store all intermediate and final files built @cached_property def BuildDir(self): if os.path.isabs(self.OutputDir): RetVal =3D os.path.join( - os.path.abspath(self.OutputDir), - self.Target + "_" + self.ToolChain, - ) + os.path.abspath(self.OutputDir), + self.Target + "_" + self.ToolChain, + ) else: RetVal =3D os.path.join( - self.WorkspaceDir, - self.OutputDir, - self.Target + "_" + self.ToolChain, - ) + self.WorkspaceDir, + self.OutputDir, + self.Target + "_" + self.ToolChain, + ) return RetVal =20 - ## Return the build output directory platform specifies + # Return the build output directory platform specifies @cached_property def OutputDir(self): return self.Platform.OutputDirectory =20 - ## Return platform name + # Return platform name @cached_property def Name(self): return self.Platform.PlatformName =20 - ## Return meta-file GUID + # Return meta-file GUID @cached_property def Guid(self): return self.Platform.Guid =20 - ## Return platform version + # Return platform version @cached_property def Version(self): return self.Platform.Version =20 - ## Return paths of tools + # Return paths of tools @cached_property def ToolDefinition(self): retVal =3D self.DataPipe.Get("TOOLDEF") @@ -390,7 +408,7 @@ class PlatformInfo(AutoGenInfo): retVal =3D {} return retVal =20 - ## Return build command string + # Return build command string # # @retval string Build command string # @@ -408,7 +426,7 @@ class PlatformInfo(AutoGenInfo): retVal =3D {} return retVal =20 - ## Override PCD setting (type, value, ...) + # Override PCD setting (type, value, ...) # # @param ToPcd The PCD to be overridden # @param FromPcd The PCD overriding from @@ -428,15 +446,16 @@ class PlatformInfo(AutoGenInfo): if ToPcd.Pending and FromPcd.Type: ToPcd.Type =3D FromPcd.Type elif ToPcd.Type and FromPcd.Type\ - and ToPcd.Type !=3D FromPcd.Type and ToPcd.Type in FromPcd= .Type: + and ToPcd.Type !=3D FromPcd.Type and ToPcd.Type in Fro= mPcd.Type: if ToPcd.Type.strip() =3D=3D TAB_PCDS_DYNAMIC_EX: ToPcd.Type =3D FromPcd.Type elif ToPcd.Type and FromPcd.Type \ - and ToPcd.Type !=3D FromPcd.Type: + and ToPcd.Type !=3D FromPcd.Type: if Library: - Module =3D str(Module) + " 's library file (" + str(Li= brary) + ")" + Module =3D str(Module) + \ + " 's library file (" + str(Library) + ")" EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD = type", - ExtraData=3D"%s.%s is used as [%s] in modu= le %s, but as [%s] in %s."\ + ExtraData=3D"%s.%s is used as [%s] in modu= le %s, but as [%s] in %s." % (ToPcd.TokenSpaceGuidCName, To= kenCName, ToPcd.Type, Module, FromPcd.T= ype, Msg), File=3Dself.MetaFile) @@ -457,10 +476,11 @@ class PlatformInfo(AutoGenInfo): # Add Flexible PCD format parse if ToPcd.DefaultValue: try: - ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Default= Value, ToPcd.DatumType, self._GuidDict)(True) + ToPcd.DefaultValue =3D ValueExpressionEx( + ToPcd.DefaultValue, ToPcd.DatumType, self._GuidDic= t)(True) except BadExpression as Value: - EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), - File=3Dself.MetaFile) + EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defa= ultValue, Value), + File=3Dself.MetaFile) =20 # check the validation of datum IsValid, Cause =3D CheckPcdDatum(ToPcd.DatumType, ToPcd.Defaul= tValue) @@ -473,7 +493,7 @@ class PlatformInfo(AutoGenInfo): ToPcd.CustomAttribute =3D FromPcd.CustomAttribute =20 if FromPcd is not None and ToPcd.DatumType =3D=3D TAB_VOID and not= ToPcd.MaxDatumSize: - EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified = for PCD %s.%s" \ + EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified = for PCD %s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value =3D ToPcd.DefaultValue if not Value: @@ -487,18 +507,19 @@ class PlatformInfo(AutoGenInfo): =20 # apply default SKU for dynamic PCDS if specified one is not avail= able if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMI= C_EX_TYPE_SET) \ - and not ToPcd.SkuInfoList: + and not ToPcd.SkuInfoList: if self.Platform.SkuName in self.Platform.SkuIds: SkuName =3D self.Platform.SkuName else: SkuName =3D TAB_DEFAULT ToPcd.SkuInfoList =3D { - SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuNa= me][0], '', '', '', '', '', ToPcd.DefaultValue) + SkuName: SkuInfoClass( + SkuName, self.Platform.SkuIds[SkuName][0], '', '', '',= '', '', ToPcd.DefaultValue) } =20 def ApplyPcdSetting(self, Ma, Pcds, Library=3D""): # for each PCD in module - Module=3DMa.Module + Module =3D Ma.Module for Name, Guid in Pcds: PcdInModule =3D Pcds[Name, Guid] # find out the PCD setting in platform @@ -507,34 +528,40 @@ class PlatformInfo(AutoGenInfo): else: PcdInPlatform =3D None # then override the settings if any - self._OverridePcd(PcdInModule, PcdInPlatform, Module, Msg=3D"D= SC PCD sections", Library=3DLibrary) + self._OverridePcd(PcdInModule, PcdInPlatform, + Module, Msg=3D"DSC PCD sections", Library=3D= Library) # resolve the VariableGuid value for SkuId in PcdInModule.SkuInfoList: Sku =3D PcdInModule.SkuInfoList[SkuId] - if Sku.VariableGuid =3D=3D '': continue - Sku.VariableGuidValue =3D GuidValue(Sku.VariableGuid, self= .PackageList, self.MetaFile.Path) + if Sku.VariableGuid =3D=3D '': + continue + Sku.VariableGuidValue =3D GuidValue( + Sku.VariableGuid, self.PackageList, self.MetaFile.Path) if Sku.VariableGuidValue is None: PackageList =3D "\n\t".join(str(P) for P in self.Packa= geList) EdkLogger.error( - 'build', - RESOURCE_NOT_AVAILABLE, - "Value of GUID [%s] is not found in" % Sku= .VariableGuid, - ExtraData=3DPackageList + "\n\t(used with = %s.%s from module %s)" \ - % (Guid, Name, str= (Module)), - File=3Dself.MetaFile - ) + 'build', + RESOURCE_NOT_AVAILABLE, + "Value of GUID [%s] is not found in" % Sku.Variabl= eGuid, + ExtraData=3DPackageList + + "\n\t(used with %s.%s from module %s)" + % (Guid, Name, str(Module)), + File=3Dself.MetaFile + ) =20 # override PCD settings with module specific setting ModuleScopePcds =3D self.DataPipe.Get("MOL_PCDS") if Module in self.Platform.Modules: PlatformModule =3D self.Platform.Modules[str(Module)] - PCD_DATA =3D ModuleScopePcds.get(Ma.Guid,{}) - mPcds =3D {(pcd.TokenCName,pcd.TokenSpaceGuidCName): pcd for p= cd in PCD_DATA} - for Key in mPcds: + PCD_DATA =3D ModuleScopePcds.get(Ma.Guid, {}) + mPcds =3D {(pcd.TokenCName, pcd.TokenSpaceGuidCName) + : pcd for pcd in PCD_DATA} + for Key in mPcds: if self.BuildOptionPcd: for pcd in self.BuildOptionPcd: - (TokenSpaceGuidCName, TokenCName, FieldName, pcdva= lue, _) =3D pcd - if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D"": + (TokenSpaceGuidCName, TokenCName, + FieldName, pcdvalue, _) =3D pcd + if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D "": PlatformModule.Pcds[Key].DefaultValue =3D pcdv= alue PlatformModule.Pcds[Key].PcdValueFromComm =3D = pcdvalue break @@ -549,7 +576,8 @@ class PlatformInfo(AutoGenInfo): Flag =3D True break if Flag: - self._OverridePcd(ToPcd, mPcds[Key], Module, Msg=3D"DS= C Components Module scoped PCD section", Library=3DLibrary) + self._OverridePcd( + ToPcd, mPcds[Key], Module, Msg=3D"DSC Components M= odule scoped PCD section", Library=3DLibrary) # use PCD value to calculate the MaxDatumSize when it is not speci= fied for Name, Guid in Pcds: Pcd =3D Pcds[Name, Guid] @@ -572,9 +600,9 @@ class PlatformInfo(AutoGenInfo): # for pcd in PlatformPcdData: # for skuid in pcd.SkuInfoList: # pcd.SkuInfoList[skuid] =3D self.CreateSkuInfoFromDict(pc= d.SkuInfoList[skuid]) - return {(pcddata.TokenCName,pcddata.TokenSpaceGuidCName):pcddata f= or pcddata in PlatformPcdData} + return {(pcddata.TokenCName, pcddata.TokenSpaceGuidCName): pcddata= for pcddata in PlatformPcdData} =20 - def CreateSkuInfoFromDict(self,SkuInfoDict): + def CreateSkuInfoFromDict(self, SkuInfoDict): return SkuInfoClass( SkuInfoDict.get("SkuIdName"), SkuInfoDict.get("SkuId"), @@ -585,27 +613,33 @@ class PlatformInfo(AutoGenInfo): SkuInfoDict.get("VpdOffset"), SkuInfoDict.get("DefaultValue"), SkuInfoDict.get("VariableGuidValue"), - SkuInfoDict.get("VariableAttribute",""), - SkuInfoDict.get("DefaultStore",None) - ) + SkuInfoDict.get("VariableAttribute", ""), + SkuInfoDict.get("DefaultStore", None) + ) + @cached_property def MixedPcd(self): return self.DataPipe.Get("MixedPcd") + @cached_property def _GuidDict(self): RetVal =3D self.DataPipe.Get("GuidDict") if RetVal is None: RetVal =3D {} return RetVal + @cached_property def BuildOptionPcd(self): return self.DataPipe.Get("BuildOptPcd") - def ApplyBuildOption(self,module): + + def ApplyBuildOption(self, module): PlatformOptions =3D self.DataPipe.Get("PLA_BO") ModuleBuildOptions =3D self.DataPipe.Get("MOL_BO") - ModuleOptionFromDsc =3D ModuleBuildOptions.get((module.MetaFile.Fi= le,module.MetaFile.Root)) + ModuleOptionFromDsc =3D ModuleBuildOptions.get( + (module.MetaFile.File, module.MetaFile.Root)) if ModuleOptionFromDsc: - ModuleTypeOptions, PlatformModuleOptions =3D ModuleOptionFromD= sc["ModuleTypeOptions"],ModuleOptionFromDsc["PlatformModuleOptions"] + ModuleTypeOptions, PlatformModuleOptions =3D ModuleOptionFromD= sc[ + "ModuleTypeOptions"], ModuleOptionFromDsc["PlatformModuleO= ptions"] else: ModuleTypeOptions, PlatformModuleOptions =3D {}, {} ToolDefinition =3D self.DataPipe.Get("TOOLDEF") @@ -639,29 +673,34 @@ class PlatformInfo(AutoGenInfo): for ExpandedTool in ToolList: # check if override is indicated if Value.startswith('=3D'): - BuildOptions[ExpandedTool][Attr] =3D mws.handl= eWsMacro(Value[1:]) + BuildOptions[ExpandedTool][Attr] =3D mws.handl= eWsMacro( + Value[1:]) else: if Attr !=3D 'PATH': - BuildOptions[ExpandedTool][Attr] +=3D " " = + mws.handleWsMacro(Value) + BuildOptions[ExpandedTool][Attr] +=3D " " = + \ + mws.handleWsMacro(Value) else: - BuildOptions[ExpandedTool][Attr] =3D mws.h= andleWsMacro(Value) + BuildOptions[ExpandedTool][Attr] =3D mws.h= andleWsMacro( + Value) =20 return BuildOptions, BuildRuleOrder =20 - def ApplyLibraryInstance(self,module): + def ApplyLibraryInstance(self, module): alldeps =3D self.DataPipe.Get("DEPS") if alldeps is None: alldeps =3D {} - mod_libs =3D alldeps.get((module.MetaFile.File,module.MetaFile.Roo= t,module.Arch,module.MetaFile.Path),[]) + mod_libs =3D alldeps.get( + (module.MetaFile.File, module.MetaFile.Root, module.Arch, modu= le.MetaFile.Path), []) retVal =3D [] - for (file_path,root,arch,abs_path) in mod_libs: - libMetaFile =3D PathClass(file_path,root) - libMetaFile.OriginalPath =3D PathClass(file_path,root) + for (file_path, root, arch, abs_path) in mod_libs: + libMetaFile =3D PathClass(file_path, root) + libMetaFile.OriginalPath =3D PathClass(file_path, root) libMetaFile.Path =3D abs_path - retVal.append(self.Wa.BuildDatabase[libMetaFile, arch, self.Ta= rget,self.ToolChain]) + retVal.append( + self.Wa.BuildDatabase[libMetaFile, arch, self.Target, self= .ToolChain]) return retVal =20 - ## Parse build_rule.txt in Conf Directory. + # Parse build_rule.txt in Conf Directory. # # @retval BuildRule object # diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools= /Source/Python/AutoGen/PlatformAutoGen.py index 592d4824a4b3..292466053c9c 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -1,4 +1,4 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
        @@ -6,7 +6,7 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # from __future__ import print_function from __future__ import absolute_import @@ -14,7 +14,7 @@ import os.path as path import copy from collections import defaultdict =20 -from .BuildEngine import BuildRule,gDefaultBuildRuleFile,AutoGenReqBuildRu= leVerNum +from .BuildEngine import BuildRule, gDefaultBuildRuleFile, AutoGenReqBuild= RuleVerNum from .GenVar import VariableMgr, var_info from . import GenMake from AutoGen.DataPipe import MemoryDataPipe @@ -25,17 +25,19 @@ from Workspace.WorkspaceCommon import GetModuleLibInsta= nces from CommonDataClass.CommonClass import SkuInfoClass from Common.caching import cached_class_function from Common.Expression import ValueExpressionEx -from Common.StringUtils import StringToArray,NormPath +from Common.StringUtils import StringToArray, NormPath from Common.BuildToolError import * from Common.DataType import * from Common.Misc import * import Common.VpdInfoFile as VpdInfoFile =20 -## Split command line option string to list +# Split command line option string to list # # subprocess.Popen needs the args to be a sequence. Otherwise there's prob= lem # in non-windows platform to launch command # + + def _SplitOption(OptionString): OptionList =3D [] LastChar =3D " " @@ -60,11 +62,13 @@ def _SplitOption(OptionString): OptionList.append(OptionString[OptionStart:]) return OptionList =20 -## AutoGen class for platform +# AutoGen class for platform # # PlatformAutoGen class will process the original information in platform # file in order to generate makefile for platform. # + + class PlatformAutoGen(AutoGen): # call super().__init__ then call the worker function with different p= arameter count def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args= , **kwargs): @@ -79,9 +83,7 @@ class PlatformAutoGen(AutoGen): _NonDynaPcdList_ =3D [] _PlatformPcds =3D {} =20 - - - ## Initialize PlatformAutoGen + # Initialize PlatformAutoGen # # # @param Workspace WorkspaceAutoGen object @@ -90,9 +92,12 @@ class PlatformAutoGen(AutoGen): # @param Toolchain Name of tool chain # @param Arch arch of the platform supports # + def _InitWorker(self, Workspace, PlatformFile, Target, Toolchain, Arch= ): - EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen platform [%s] [%s]" % = (PlatformFile, Arch)) - GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % (PlatformFile, = Arch, Toolchain, Target) + EdkLogger.debug(EdkLogger.DEBUG_9, + "AutoGen platform [%s] [%s]" % (PlatformFile, Arch= )) + GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % ( + PlatformFile, Arch, Toolchain, Target) =20 self.MetaFile =3D PlatformFile self.Workspace =3D Workspace @@ -111,8 +116,10 @@ class PlatformAutoGen(AutoGen): # indicating whether the file has been created. self.MakeFileName =3D "" =20 - self._DynamicPcdList =3D None # [(TokenCName1, TokenSpaceGuidCN= ame1), (TokenCName2, TokenSpaceGuidCName2), ...] - self._NonDynamicPcdList =3D None # [(TokenCName1, TokenSpaceGuidCN= ame1), (TokenCName2, TokenSpaceGuidCName2), ...] + # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGu= idCName2), ...] + self._DynamicPcdList =3D None + # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGu= idCName2), ...] + self._NonDynamicPcdList =3D None =20 self._AsBuildInfList =3D [] self._AsBuildModuleList =3D [] @@ -122,8 +129,10 @@ class PlatformAutoGen(AutoGen): if GlobalData.gFdfParser is not None: self._AsBuildInfList =3D GlobalData.gFdfParser.Profile.InfList for Inf in self._AsBuildInfList: - InfClass =3D PathClass(NormPath(Inf), GlobalData.gWorkspac= e, self.Arch) - M =3D self.BuildDatabase[InfClass, self.Arch, self.BuildTa= rget, self.ToolChain] + InfClass =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, self.Arch) + M =3D self.BuildDatabase[InfClass, self.Arch, + self.BuildTarget, self.ToolChain] if not M.IsBinaryModule: continue self._AsBuildModuleList.append(InfClass) @@ -135,27 +144,31 @@ class PlatformAutoGen(AutoGen): self.DataPipe.FillData(self) =20 return True + def FillData_LibConstPcd(self): libConstPcd =3D {} for LibAuto in self.LibraryAutoGenList: if LibAuto.ConstPcd: - libConstPcd[(LibAuto.MetaFile.File,LibAuto.MetaFile.Root,L= ibAuto.Arch,LibAuto.MetaFile.Path)] =3D LibAuto.ConstPcd - self.DataPipe.DataContainer =3D {"LibConstPcd":libConstPcd} - ## hash() operator of PlatformAutoGen + libConstPcd[(LibAuto.MetaFile.File, LibAuto.MetaFile.Root, + LibAuto.Arch, LibAuto.MetaFile.Path)] =3D Lib= Auto.ConstPcd + self.DataPipe.DataContainer =3D {"LibConstPcd": libConstPcd} + # hash() operator of PlatformAutoGen # # The platform file path and arch string will be used to represent # hash value of this object # # @retval int Hash value of the platform file path and arch # + @cached_class_function def __hash__(self): - return hash((self.MetaFile, self.Arch,self.ToolChain,self.BuildTar= get)) + return hash((self.MetaFile, self.Arch, self.ToolChain, self.BuildT= arget)) + @cached_class_function def __repr__(self): return "%s [%s]" % (self.MetaFile, self.Arch) =20 - ## Create autogen code for platform and modules + # Create autogen code for platform and modules # # Since there's no autogen code for platform, this method will do not= hing # if CreateModuleCodeFile is set to False. @@ -172,17 +185,17 @@ class PlatformAutoGen(AutoGen): for Ma in self.ModuleAutoGenList: Ma.CreateCodeFile(CreateModuleCodeFile) =20 - ## Generate Fds Command + # Generate Fds Command @cached_property def GenFdsCommand(self): return self.Workspace.GenFdsCommand =20 - ## Create makefile for the platform and modules in it + # Create makefile for the platform and modules in it # # @param CreateModuleMakeFile Flag indicating if the makefil= e for # modules will be created as well # - def CreateMakeFile(self, CreateModuleMakeFile=3DFalse, FfsCommand =3D = {}): + def CreateMakeFile(self, CreateModuleMakeFile=3DFalse, FfsCommand=3D{}= ): if CreateModuleMakeFile: for Ma in self._MaList: key =3D (Ma.MetaFile.File, self.Arch) @@ -206,8 +219,9 @@ class PlatformAutoGen(AutoGen): @property def AllPcdList(self): return self.DynamicPcdList + self.NonDynamicPcdList - ## Deal with Shared FixedAtBuild Pcds + # Deal with Shared FixedAtBuild Pcds # + def CollectFixedAtBuildPcds(self): for LibAuto in self.LibraryAutoGenList: FixedAtBuildPcds =3D {} @@ -231,7 +245,8 @@ class PlatformAutoGen(AutoGen): if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in self.N= onDynamicPcdDict: continue else: - DscPcd =3D self.NonDynamicPcdDict[(Pcd.TokenCName, Pcd= .TokenSpaceGuidCName)] + DscPcd =3D self.NonDynamicPcdDict[( + Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] if DscPcd.Type !=3D TAB_PCDS_FIXED_AT_BUILD: continue if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtB= uildPcdsSameValue[key]: @@ -249,7 +264,8 @@ class PlatformAutoGen(AutoGen): VpdRegionBase =3D FdRegion.Offset break =20 - VariableInfo =3D VariableMgr(self.DscBuildDataObj._GetDefaultStore= s(), self.DscBuildDataObj.SkuIds) + VariableInfo =3D VariableMgr( + self.DscBuildDataObj._GetDefaultStores(), self.DscBuildDataObj= .SkuIds) VariableInfo.SetVpdRegionMaxSize(VpdRegionSize) VariableInfo.SetVpdRegionOffset(VpdRegionBase) Index =3D 0 @@ -264,40 +280,52 @@ class PlatformAutoGen(AutoGen): if Sku.VariableAttribute and 'NV' not in Sku.VariableA= ttribute: continue VariableGuidStructure =3D Sku.VariableGuidValue - VariableGuid =3D GuidStructureStringToGuidString(Varia= bleGuidStructure) + VariableGuid =3D GuidStructureStringToGuidString( + VariableGuidStructure) for StorageName in Sku.DefaultStoreDict: - VariableInfo.append_variable(var_info(Index, pcdna= me, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sk= u.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultSt= oreDict[StorageName] if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES else StringT= oArray(Sku.DefaultStoreDict[StorageName]), Pcd.DatumType, Pcd.CustomAttribu= te['DscPosition'], Pcd.CustomAttribute.get('IsStru',False))) + VariableInfo.append_variable(var_info(Index, pcdna= me, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sk= u.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultSt= oreDict[ + StorageName] if Pcd.D= atumType in TAB_PCD_NUMERIC_TYPES else StringToArray(Sku.DefaultStoreDict[S= torageName]), Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.Custom= Attribute.get('IsStru', False))) Index +=3D 1 return VariableInfo =20 def UpdateNVStoreMaxSize(self, OrgVpdFile): if self.VariableInfo: - VpdMapFilePath =3D os.path.join(self.BuildDir, TAB_FV_DIRECTOR= Y, "%s.map" % self.Platform.VpdToolGuid) - PcdNvStoreDfBuffer =3D [item for item in self._DynamicPcdList = if item.TokenCName =3D=3D "PcdNvStoreDefaultValueBuffer" and item.TokenSpac= eGuidCName =3D=3D "gEfiMdeModulePkgTokenSpaceGuid"] + VpdMapFilePath =3D os.path.join( + self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.= VpdToolGuid) + PcdNvStoreDfBuffer =3D [item for item in self._DynamicPcdList = if item.TokenCName =3D=3D + "PcdNvStoreDefaultValueBuffer" and item.= TokenSpaceGuidCName =3D=3D "gEfiMdeModulePkgTokenSpaceGuid"] =20 if PcdNvStoreDfBuffer: try: OrgVpdFile.Read(VpdMapFilePath) PcdItems =3D OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0= ]) - NvStoreOffset =3D list(PcdItems.values())[0].strip() i= f PcdItems else '0' + NvStoreOffset =3D list(PcdItems.values())[ + 0].strip() if PcdItems else '0' except: - EdkLogger.error("build", FILE_READ_FAILURE, "Can not f= ind VPD map file %s to fix up VPD offset." % VpdMapFilePath) + EdkLogger.error( + "build", FILE_READ_FAILURE, "Can not find VPD map = file %s to fix up VPD offset." % VpdMapFilePath) =20 - NvStoreOffset =3D int(NvStoreOffset, 16) if NvStoreOffset.= upper().startswith("0X") else int(NvStoreOffset) - default_skuobj =3D PcdNvStoreDfBuffer[0].SkuInfoList.get(T= AB_DEFAULT) - maxsize =3D self.VariableInfo.VpdRegionSize - NvStoreOffs= et if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.= split(",")) - var_data =3D self.VariableInfo.PatchNVStoreDefaultMaxSize(= maxsize) + NvStoreOffset =3D int(NvStoreOffset, 16) if NvStoreOffset.= upper( + ).startswith("0X") else int(NvStoreOffset) + default_skuobj =3D PcdNvStoreDfBuffer[0].SkuInfoList.get( + TAB_DEFAULT) + maxsize =3D self.VariableInfo.VpdRegionSize - \ + NvStoreOffset if self.VariableInfo.VpdRegionSize else = len( + default_skuobj.DefaultValue.split(",")) + var_data =3D self.VariableInfo.PatchNVStoreDefaultMaxSize( + maxsize) =20 if var_data and default_skuobj: default_skuobj.DefaultValue =3D var_data PcdNvStoreDfBuffer[0].DefaultValue =3D var_data PcdNvStoreDfBuffer[0].SkuInfoList.clear() PcdNvStoreDfBuffer[0].SkuInfoList[TAB_DEFAULT] =3D def= ault_skuobj - PcdNvStoreDfBuffer[0].MaxDatumSize =3D str(len(default= _skuobj.DefaultValue.split(","))) + PcdNvStoreDfBuffer[0].MaxDatumSize =3D str( + len(default_skuobj.DefaultValue.split(","))) =20 return OrgVpdFile =20 - ## Collect dynamic PCDs + # Collect dynamic PCDs # # Gather dynamic PCDs list from each module and their settings from p= latform # This interface should be invoked explicitly when platform action is= created. @@ -315,23 +343,26 @@ class PlatformAutoGen(AutoGen): InfName =3D mws.join(self.WorkspaceDir, InfName) FdfModuleList.append(os.path.normpath(InfName)) for M in self._MbList: -# F is the Module for which M is the module autogen + # F is the Module for which M is the module autogen ModPcdList =3D self.ApplyPcdSetting(M, M.ModulePcdList) LibPcdList =3D [] for lib in M.LibraryPcdList: - LibPcdList.extend(self.ApplyPcdSetting(M, M.LibraryPcdList= [lib], lib)) + LibPcdList.extend(self.ApplyPcdSetting( + M, M.LibraryPcdList[lib], lib)) for PcdFromModule in ModPcdList + LibPcdList: =20 # make sure that the "VOID*" kind of datum has MaxDatumSiz= e set if PcdFromModule.DatumType =3D=3D TAB_VOID and not PcdFrom= Module.MaxDatumSize: - NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.T= okenSpaceGuidCName, PcdFromModule.TokenCName, M.MetaFile)) + NoDatumTypePcdList.add("%s.%s [%s]" % ( + PcdFromModule.TokenSpaceGuidCName, PcdFromModule.T= okenCName, M.MetaFile)) =20 # Check the PCD from Binary INF or Source INF if M.IsBinaryModule =3D=3D True: PcdFromModule.IsFromBinaryInf =3D True =20 # Check the PCD from DSC or not - PcdFromModule.IsFromDsc =3D (PcdFromModule.TokenCName, Pcd= FromModule.TokenSpaceGuidCName) in self.Platform.Pcds + PcdFromModule.IsFromDsc =3D ( + PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuid= CName) in self.Platform.Pcds =20 if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET or PcdFromMo= dule.Type in PCD_DYNAMIC_EX_TYPE_SET: if M.MetaFile.Path not in FdfModuleList: @@ -344,7 +375,7 @@ class PlatformAutoGen(AutoGen): # PCD will not be added into the Database unless i= t is used by other # modules that are included in the FDF file. if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET and \ - PcdFromModule.IsFromBinaryInf =3D=3D False: + PcdFromModule.IsFromBinaryInf =3D=3D False: # Print warning message to let the developer m= ake a determine. continue # If one of the Source built modules listed in the= DSC is not listed in @@ -373,16 +404,19 @@ class PlatformAutoGen(AutoGen): elif PcdFromModule in self._NonDynaPcdList_ and PcdFromMod= ule.IsFromBinaryInf =3D=3D True: Index =3D self._NonDynaPcdList_.index(PcdFromModule) if self._NonDynaPcdList_[Index].IsFromBinaryInf =3D=3D= False: - #The PCD from Binary INF will override the same on= e from source INF - self._NonDynaPcdList_.remove (self._NonDynaPcdList= _[Index]) + # The PCD from Binary INF will override the same o= ne from source INF + self._NonDynaPcdList_.remove( + self._NonDynaPcdList_[Index]) PcdFromModule.Pending =3D False - self._NonDynaPcdList_.append (PcdFromModule) - DscModuleSet =3D {os.path.normpath(ModuleInf.Path) for ModuleInf i= n self.Platform.Modules} + self._NonDynaPcdList_.append(PcdFromModule) + DscModuleSet =3D {os.path.normpath(ModuleInf.Path) + for ModuleInf in self.Platform.Modules} # add the PCD from modules that listed in FDF but not in DSC to Da= tabase for InfName in FdfModuleList: if InfName not in DscModuleSet: InfClass =3D PathClass(InfName) - M =3D self.BuildDatabase[InfClass, self.Arch, self.BuildTa= rget, self.ToolChain] + M =3D self.BuildDatabase[InfClass, self.Arch, + self.BuildTarget, self.ToolChain] # If a module INF in FDF but not in current arch's DSC mod= ule list, it must be module (either binary or source) # for different Arch. PCDs in source module for different = Arch is already added before, so skip the source module here. # For binary module, if in current arch, we need to list t= he PCDs into database. @@ -401,7 +435,8 @@ class PlatformAutoGen(AutoGen): % (PcdFromModule.Type, PcdFromModu= le.TokenCName, InfName)) # make sure that the "VOID*" kind of datum has MaxDatu= mSize set if PcdFromModule.DatumType =3D=3D TAB_VOID and not Pcd= FromModule.MaxDatumSize: - NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModu= le.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName)) + NoDatumTypePcdList.add("%s.%s [%s]" % ( + PcdFromModule.TokenSpaceGuidCName, PcdFromModu= le.TokenCName, InfName)) if M.ModuleType in SUP_MODULE_SET_PEI: PcdFromModule.Phase =3D "PEI" if PcdFromModule not in self._DynaPcdList_ and PcdFrom= Module.Type in PCD_DYNAMIC_EX_TYPE_SET: @@ -429,11 +464,11 @@ class PlatformAutoGen(AutoGen): continue Index =3D self._DynaPcdList_.index(PcdFromModule) if PcdFromModule.IsFromDsc =3D=3D False and \ - PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and \ - PcdFromModule.IsFromBinaryInf =3D=3D True and \ - self._DynaPcdList_[Index].IsFromBinaryInf =3D=3D False: + PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and= \ + PcdFromModule.IsFromBinaryInf =3D=3D True and \ + self._DynaPcdList_[Index].IsFromBinaryInf =3D=3D False: Index =3D self._DynaPcdList_.index(PcdFromModule) - self._DynaPcdList_.remove (self._DynaPcdList_[Index]) + self._DynaPcdList_.remove(self._DynaPcdList_[Index]) =20 # print out error information and break the build, if error found if len(NoDatumTypePcdList) > 0: @@ -455,10 +490,10 @@ class PlatformAutoGen(AutoGen): # The reason of sorting is make sure the unicode string is in doub= le-byte alignment in string table. # UnicodePcdArray =3D set() - HiiPcdArray =3D set() - OtherPcdArray =3D set() - VpdPcdDict =3D {} - VpdFile =3D VpdInfoFile.VpdInfoFile() + HiiPcdArray =3D set() + OtherPcdArray =3D set() + VpdPcdDict =3D {} + VpdFile =3D VpdInfoFile.VpdInfoFile() NeedProcessVpdMapFile =3D False =20 for pcd in self.Platform.Pcds: @@ -483,27 +518,31 @@ class PlatformAutoGen(AutoGen): if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_= VPD]: VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = =3D Pcd =20 - #Collect DynamicHii PCD values and assign it to DynamicExVpd P= CD gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer - PcdNvStoreDfBuffer =3D VpdPcdDict.get(("PcdNvStoreDefaultValue= Buffer", "gEfiMdeModulePkgTokenSpaceGuid")) + # Collect DynamicHii PCD values and assign it to DynamicExVpd = PCD gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer + PcdNvStoreDfBuffer =3D VpdPcdDict.get( + ("PcdNvStoreDefaultValueBuffer", "gEfiMdeModulePkgTokenSpa= ceGuid")) if PcdNvStoreDfBuffer: self.VariableInfo =3D self.CollectVariables(self._DynamicP= cdList) vardump =3D self.VariableInfo.dump() if vardump: # - #According to PCD_DATABASE_INIT in edk2\MdeModulePkg\I= nclude\Guid\PcdDataBaseSignatureGuid.h, - #the max size for string PCD should not exceed USHRT_M= AX 65535(0xffff). - #typedef UINT16 SIZE_INFO; - #//SIZE_INFO SizeTable[]; + # According to PCD_DATABASE_INIT in edk2\MdeModulePkg\= Include\Guid\PcdDataBaseSignatureGuid.h, + # the max size for string PCD should not exceed USHRT_= MAX 65535(0xffff). + # typedef UINT16 SIZE_INFO; + # //SIZE_INFO SizeTable[]; if len(vardump.split(",")) > 0xffff: - EdkLogger.error("build", RESOURCE_OVERFLOW, 'The c= urrent length of PCD %s value is %d, it exceeds to the max size of String P= CD.' %(".".join([PcdNvStoreDfBuffer.TokenSpaceGuidCName,PcdNvStoreDfBuffer.= TokenCName]) ,len(vardump.split(",")))) + EdkLogger.error("build", RESOURCE_OVERFLOW, 'The c= urrent length of PCD %s value is %d, it exceeds to the max size of String P= CD.' % ( + ".".join([PcdNvStoreDfBuffer.TokenSpaceGuidCNa= me, PcdNvStoreDfBuffer.TokenCName]), len(vardump.split(",")))) PcdNvStoreDfBuffer.DefaultValue =3D vardump for skuname in PcdNvStoreDfBuffer.SkuInfoList: PcdNvStoreDfBuffer.SkuInfoList[skuname].DefaultVal= ue =3D vardump - PcdNvStoreDfBuffer.MaxDatumSize =3D str(len(vardum= p.split(","))) + PcdNvStoreDfBuffer.MaxDatumSize =3D str( + len(vardump.split(","))) else: - #If the end user define [DefaultStores] and [XXX.Menufactu= ring] in DSC, but forget to configure PcdNvStoreDefaultValueBuffer to PcdsD= ynamicVpd + # If the end user define [DefaultStores] and [XXX.Menufact= uring] in DSC, but forget to configure PcdNvStoreDefaultValueBuffer to Pcds= DynamicVpd if [Pcd for Pcd in self._DynamicPcdList if Pcd.UserDefined= DefaultStoresFlag]: - EdkLogger.warn("build", "PcdNvStoreDefaultValueBuffer = should be defined as PcdsDynamicExVpd in dsc file since the DefaultStores i= s enabled for this platform.\n%s" %self.Platform.MetaFile.Path) + EdkLogger.warn( + "build", "PcdNvStoreDefaultValueBuffer should be d= efined as PcdsDynamicExVpd in dsc file since the DefaultStores is enabled f= or this platform.\n%s" % self.Platform.MetaFile.Path) PlatformPcds =3D sorted(self._PlatformPcds.keys()) # # Add VPD type PCD into VpdFile and determine whether the VPD = PCD need to be fixed up. @@ -527,7 +566,7 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset =3D Sku.VpdOffset.strip() PcdValue =3D Sku.DefaultValue if PcdValue =3D=3D "": - PcdValue =3D Pcd.DefaultValue + PcdValue =3D Pcd.DefaultValue if Sku.VpdOffset !=3D TAB_STAR: if PcdValue.startswith("{"): Alignment =3D 8 @@ -541,12 +580,15 @@ class PlatformAutoGen(AutoGen): try: VpdOffset =3D int(Sku.VpdOffset, 16) except: - EdkLogger.error("build", FORMAT_INVALI= D, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, Pcd.TokenSpac= eGuidCName, Pcd.TokenCName)) + EdkLogger.error("build", FORMAT_INVALI= D, "Invalid offset value %s for PCD %s.%s." % ( + Sku.VpdOffset, Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName)) if VpdOffset % Alignment !=3D 0: if PcdValue.startswith("{"): - EdkLogger.warn("build", "The offset va= lue of PCD %s.%s is not 8-byte aligned!" %(Pcd.TokenSpaceGuidCName, Pcd.Tok= enCName), File=3Dself.MetaFile) + EdkLogger.warn("build", "The offset va= lue of PCD %s.%s is not 8-byte aligned!" % ( + Pcd.TokenSpaceGuidCName, Pcd.Token= CName), File=3Dself.MetaFile) else: - EdkLogger.error("build", FORMAT_INVALI= D, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenS= paceGuidCName, Pcd.TokenCName, Alignment)) + EdkLogger.error("build", FORMAT_INVALI= D, 'The offset value of PCD %s.%s should be %s-byte aligned.' % ( + Pcd.TokenSpaceGuidCName, Pcd.Token= CName, Alignment)) if PcdValue not in SkuValueMap: SkuValueMap[PcdValue] =3D [] VpdFile.Add(Pcd, SkuName, Sku.VpdOffset) @@ -555,7 +597,7 @@ class PlatformAutoGen(AutoGen): if not NeedProcessVpdMapFile and Sku.VpdOffset =3D= =3D TAB_STAR: NeedProcessVpdMapFile =3D True if self.Platform.VpdToolGuid is None or self.P= latform.VpdToolGuid =3D=3D '': - EdkLogger.error("Build", FILE_NOT_FOUND, \ + EdkLogger.error("Build", FILE_NOT_FOUND, "Fail to find third-party = BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_d= ef.txt and VPD_TOOL_GUID need to be provided in DSC file.") =20 VpdSkuMap[PcdKey] =3D SkuValueMap @@ -572,16 +614,18 @@ class PlatformAutoGen(AutoGen): # This PCD has been referenced by module if (VpdPcd.TokenSpaceGuidCName =3D=3D DscPcdEn= try.TokenSpaceGuidCName) and \ (VpdPcd.TokenCName =3D=3D DscPcdEntry.Token= CName): - FoundFlag =3D True + FoundFlag =3D True =20 # Not found, it should be signature - if not FoundFlag : + if not FoundFlag: # just pick the a value to determine whether i= s unicode string type SkuValueMap =3D {} SkuObjList =3D list(DscPcdEntry.SkuInfoList.it= ems()) - DefaultSku =3D DscPcdEntry.SkuInfoList.get(TAB= _DEFAULT) + DefaultSku =3D DscPcdEntry.SkuInfoList.get( + TAB_DEFAULT) if DefaultSku: - defaultindex =3D SkuObjList.index((TAB_DEF= AULT, DefaultSku)) + defaultindex =3D SkuObjList.index( + (TAB_DEFAULT, DefaultSku)) SkuObjList[0], SkuObjList[defaultindex] = =3D SkuObjList[defaultindex], SkuObjList[0] for (SkuName, Sku) in SkuObjList: Sku.VpdOffset =3D Sku.VpdOffset.strip() @@ -594,24 +638,26 @@ class PlatformAutoGen(AutoGen): (DecPcdEntry.TokenCName =3D=3D = DscPcdEntry.TokenCName): # Print warning message to let= the developer make a determine. EdkLogger.warn("build", "Unref= erenced vpd pcd used!", - File=3Dself.Me= taFile, \ - ExtraData =3D = "PCD: %s.%s used in the DSC file %s is unreferenced." \ - %(DscPcdEntry.= TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) + File=3Dself.Met= aFile, + ExtraData=3D"PC= D: %s.%s used in the DSC file %s is unreferenced." + % (DscPcdEntry.= TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) =20 - DscPcdEntry.DatumType =3D D= ecPcdEntry.DatumType + DscPcdEntry.DatumType =3D DecP= cdEntry.DatumType DscPcdEntry.DefaultValue =3D D= ecPcdEntry.DefaultValue DscPcdEntry.TokenValue =3D Dec= PcdEntry.TokenValue - DscPcdEntry.TokenSpaceGuidValu= e =3D eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName] + DscPcdEntry.TokenSpaceGuidValu= e =3D eachDec.Guids[ + DecPcdEntry.TokenSpaceGuid= CName] # Only fix the value while no = value provided in DSC file. if not Sku.DefaultValue: - DscPcdEntry.SkuInfoList[li= st(DscPcdEntry.SkuInfoList.keys())[0]].DefaultValue =3D DecPcdEntry.Default= Value + DscPcdEntry.SkuInfoList[li= st(DscPcdEntry.SkuInfoList.keys())[ + 0]].DefaultValue =3D D= ecPcdEntry.DefaultValue =20 if DscPcdEntry not in self._DynamicPcdList: self._DynamicPcdList.append(DscPcdEntr= y) Sku.VpdOffset =3D Sku.VpdOffset.strip() PcdValue =3D Sku.DefaultValue if PcdValue =3D=3D "": - PcdValue =3D DscPcdEntry.DefaultValue + PcdValue =3D DscPcdEntry.DefaultValue if Sku.VpdOffset !=3D TAB_STAR: if PcdValue.startswith("{"): Alignment =3D 8 @@ -625,15 +671,19 @@ class PlatformAutoGen(AutoGen): try: VpdOffset =3D int(Sku.VpdOffse= t, 16) except: - EdkLogger.error("build", FORMA= T_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, DscPc= dEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName)) + EdkLogger.error("build", FORMA= T_INVALID, "Invalid offset value %s for PCD %s.%s." % ( + Sku.VpdOffset, DscPcdEntry= .TokenSpaceGuidCName, DscPcdEntry.TokenCName)) if VpdOffset % Alignment !=3D 0: if PcdValue.startswith("{"): - EdkLogger.warn("build", "The o= ffset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry.TokenSpaceGu= idCName, DscPcdEntry.TokenCName), File=3Dself.MetaFile) + EdkLogger.warn("build", "The o= ffset value of PCD %s.%s is not 8-byte aligned!" % ( + DscPcdEntry.TokenSpaceGuid= CName, DscPcdEntry.TokenCName), File=3Dself.MetaFile) else: - EdkLogger.error("build", FORMA= T_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Ds= cPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment)) + EdkLogger.error("build", FORMA= T_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % ( + DscPcdEntry.TokenSpaceGuid= CName, DscPcdEntry.TokenCName, Alignment)) if PcdValue not in SkuValueMap: SkuValueMap[PcdValue] =3D [] - VpdFile.Add(DscPcdEntry, SkuName, Sku.= VpdOffset) + VpdFile.Add( + DscPcdEntry, SkuName, Sku.VpdOffse= t) SkuValueMap[PcdValue].append(Sku) if not NeedProcessVpdMapFile and Sku.VpdOf= fset =3D=3D TAB_STAR: NeedProcessVpdMapFile =3D True @@ -656,16 +706,20 @@ class PlatformAutoGen(AutoGen): self.FixVpdOffset(VpdFile) =20 self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile)) - PcdNvStoreDfBuffer =3D [item for item in self._DynamicPcdL= ist if item.TokenCName =3D=3D "PcdNvStoreDefaultValueBuffer" and item.Token= SpaceGuidCName =3D=3D "gEfiMdeModulePkgTokenSpaceGuid"] + PcdNvStoreDfBuffer =3D [item for item in self._DynamicPcdL= ist if item.TokenCName =3D=3D + "PcdNvStoreDefaultValueBuffer" and i= tem.TokenSpaceGuidCName =3D=3D "gEfiMdeModulePkgTokenSpaceGuid"] if PcdNvStoreDfBuffer: - PcdName,PcdGuid =3D PcdNvStoreDfBuffer[0].TokenCName, = PcdNvStoreDfBuffer[0].TokenSpaceGuidCName - if (PcdName,PcdGuid) in VpdSkuMap: - DefaultSku =3D PcdNvStoreDfBuffer[0].SkuInfoList.g= et(TAB_DEFAULT) - VpdSkuMap[(PcdName,PcdGuid)] =3D {DefaultSku.Defau= ltValue:[SkuObj for SkuObj in PcdNvStoreDfBuffer[0].SkuInfoList.values() ]} + PcdName, PcdGuid =3D PcdNvStoreDfBuffer[0].TokenCName,= PcdNvStoreDfBuffer[0].TokenSpaceGuidCName + if (PcdName, PcdGuid) in VpdSkuMap: + DefaultSku =3D PcdNvStoreDfBuffer[0].SkuInfoList.g= et( + TAB_DEFAULT) + VpdSkuMap[(PcdName, PcdGuid)] =3D {DefaultSku.Defa= ultValue: [ + SkuObj for SkuObj in PcdNvStoreDfBuffer[0].Sku= InfoList.values()]} =20 # Process VPD map file generated by third party BPDG tool if NeedProcessVpdMapFile: - VpdMapFilePath =3D os.path.join(self.BuildDir, TAB_FV_= DIRECTORY, "%s.map" % self.Platform.VpdToolGuid) + VpdMapFilePath =3D os.path.join( + self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.P= latform.VpdToolGuid) try: VpdFile.Read(VpdMapFilePath) =20 @@ -673,7 +727,7 @@ class PlatformAutoGen(AutoGen): for pcd in VpdSkuMap: vpdinfo =3D VpdFile.GetVpdInfo(pcd) if vpdinfo is None: - # just pick the a value to determine whether i= s unicode string type + # just pick the a value to determine wheth= er is unicode string type continue for pcdvalue in VpdSkuMap[pcd]: for sku in VpdSkuMap[pcd][pcdvalue]: @@ -681,7 +735,8 @@ class PlatformAutoGen(AutoGen): if item[2] =3D=3D pcdvalue: sku.VpdOffset =3D item[1] except: - EdkLogger.error("build", FILE_READ_FAILURE, "Can n= ot find VPD map file %s to fix up VPD offset." % VpdMapFilePath) + EdkLogger.error( + "build", FILE_READ_FAILURE, "Can not find VPD = map file %s to fix up VPD offset." % VpdMapFilePath) =20 # Delete the DynamicPcdList At the last time enter into this f= unction for Pcd in self._DynamicPcdList: @@ -706,25 +761,29 @@ class PlatformAutoGen(AutoGen): self._DynamicPcdList.extend(list(HiiPcdArray)) self._DynamicPcdList.extend(list(OtherPcdArray)) self._DynamicPcdList.sort() - allskuset =3D [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdLis= t for (SkuName, Sku) in pcd.SkuInfoList.items()] + allskuset =3D [(SkuName, Sku.SkuId) for pcd in self._DynamicPcdLis= t for ( + SkuName, Sku) in pcd.SkuInfoList.items()] for pcd in self._DynamicPcdList: if len(pcd.SkuInfoList) =3D=3D 1: for (SkuName, SkuId) in allskuset: if isinstance(SkuId, str) and eval(SkuId) =3D=3D 0 or = SkuId =3D=3D 0: continue - pcd.SkuInfoList[SkuName] =3D copy.deepcopy(pcd.SkuInfo= List[TAB_DEFAULT]) + pcd.SkuInfoList[SkuName] =3D copy.deepcopy( + pcd.SkuInfoList[TAB_DEFAULT]) pcd.SkuInfoList[SkuName].SkuId =3D SkuId pcd.SkuInfoList[SkuName].SkuIdName =3D SkuName =20 - def FixVpdOffset(self, VpdFile ): + def FixVpdOffset(self, VpdFile): FvPath =3D os.path.join(self.BuildDir, TAB_FV_DIRECTORY) if not os.path.exists(FvPath): try: os.makedirs(FvPath) except: - EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to crea= te FV folder under %s" % self.BuildDir) + EdkLogger.error("build", FILE_WRITE_FAILURE, + "Fail to create FV folder under %s" % self= .BuildDir) =20 - VpdFilePath =3D os.path.join(FvPath, "%s.txt" % self.Platform.VpdT= oolGuid) + VpdFilePath =3D os.path.join(FvPath, "%s.txt" % + self.Platform.VpdToolGuid) =20 if VpdFile.Write(VpdFilePath): # retrieve BPDG tool's path from tool_def.txt according to VPD= _TOOL_GUID defined in DSC file. @@ -732,66 +791,68 @@ class PlatformAutoGen(AutoGen): for ToolDef in self.ToolDefinition.values(): if TAB_GUID in ToolDef and ToolDef[TAB_GUID] =3D=3D self.P= latform.VpdToolGuid: if "PATH" not in ToolDef: - EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, = "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % = self.Platform.VpdToolGuid) + EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, + "PATH attribute was not provided f= or BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid) BPDGToolName =3D ToolDef["PATH"] break # Call third party GUID BPDG tool. if BPDGToolName is not None: VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath) else: - EdkLogger.error("Build", FILE_NOT_FOUND, "Fail to find thi= rd-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined i= n tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.") + EdkLogger.error( + "Build", FILE_NOT_FOUND, "Fail to find third-party BPD= G tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.= txt and VPD_TOOL_GUID need to be provided in DSC file.") =20 - ## Return the platform build data object + # Return the platform build data object @cached_property def Platform(self): return self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarg= et, self.ToolChain] =20 - ## Return platform name + # Return platform name @cached_property def Name(self): return self.Platform.PlatformName =20 - ## Return the meta file GUID + # Return the meta file GUID @cached_property def Guid(self): return self.Platform.Guid =20 - ## Return the platform version + # Return the platform version @cached_property def Version(self): return self.Platform.Version =20 - ## Return the FDF file name + # Return the FDF file name @cached_property def FdfFile(self): if self.Workspace.FdfFile: - RetVal=3D mws.join(self.WorkspaceDir, self.Workspace.FdfFile) + RetVal =3D mws.join(self.WorkspaceDir, self.Workspace.FdfFile) else: RetVal =3D '' return RetVal =20 - ## Return the build output directory platform specifies + # Return the build output directory platform specifies @cached_property def OutputDir(self): return self.Platform.OutputDirectory =20 - ## Return the directory to store all intermediate and final files built + # Return the directory to store all intermediate and final files built @cached_property def BuildDir(self): if os.path.isabs(self.OutputDir): GlobalData.gBuildDirectory =3D RetVal =3D path.join( - path.abspath(self.OutputDir), - self.BuildTarget + "_" + self.Tool= Chain, - ) + path.abspath(self.OutputDir), + self.BuildTarget + "_" + self.ToolChain, + ) else: GlobalData.gBuildDirectory =3D RetVal =3D path.join( - self.WorkspaceDir, - self.OutputDir, - self.BuildTarget + "_" + self.Tool= Chain, - ) + self.WorkspaceDir, + self.OutputDir, + self.BuildTarget + "_" + self.ToolChain, + ) return RetVal =20 - ## Return directory of platform makefile + # Return directory of platform makefile # # @retval string Makefile directory # @@ -799,7 +860,7 @@ class PlatformAutoGen(AutoGen): def MakeFileDir(self): return path.join(self.BuildDir, self.Arch) =20 - ## Return build command string + # Return build command string # # @retval string Build command string # @@ -827,7 +888,7 @@ class PlatformAutoGen(AutoGen): RetVal =3D RetVal + _SplitOption(Flags.strip()) return RetVal =20 - ## Compute a tool defintion key priority value in range 0..15 + # Compute a tool defintion key priority value in range 0..15 # # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 15 # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 14 @@ -846,15 +907,15 @@ class PlatformAutoGen(AutoGen): # TARGET_*********_****_***********_ATTRIBUTE 1 # ******_*********_****_***********_ATTRIBUTE 0 # - def ToolDefinitionPriority (self,Key): + def ToolDefinitionPriority(self, Key): KeyList =3D Key.split('_') Priority =3D 0 - for Index in range (0, min(4, len(KeyList))): + for Index in range(0, min(4, len(KeyList))): if KeyList[Index] !=3D '*': Priority +=3D (1 << Index) return Priority =20 - ## Get tool chain definition + # Get tool chain definition # # Get each tool definition for given tool chain from tools_def.txt an= d platform # @@ -867,7 +928,8 @@ class PlatformAutoGen(AutoGen): RetVal =3D OrderedDict() DllPathList =3D set() =20 - PrioritizedDefList =3D sorted(ToolDefinition.keys(), key=3Dself.To= olDefinitionPriority, reverse=3DTrue) + PrioritizedDefList =3D sorted(ToolDefinition.keys( + ), key=3Dself.ToolDefinitionPriority, reverse=3DTrue) for Def in PrioritizedDefList: Target, Tag, Arch, Tool, Attr =3D Def.split("_") if Target =3D=3D TAB_STAR: @@ -918,13 +980,17 @@ class PlatformAutoGen(AutoGen): if Tool in self._BuildOptionWithToolDef(RetVal) and Attr i= n self._BuildOptionWithToolDef(RetVal)[Tool]: # check if override is indicated if self._BuildOptionWithToolDef(RetVal)[Tool][Attr].st= artswith('=3D'): - Value =3D self._BuildOptionWithToolDef(RetVal)[Too= l][Attr][1:].strip() + Value =3D self._BuildOptionWithToolDef( + RetVal)[Tool][Attr][1:].strip() else: # Do not append PATH or GUID if Attr !=3D 'PATH' and Attr !=3D 'GUID': - Value +=3D " " + self._BuildOptionWithToolDef(= RetVal)[Tool][Attr] + Value +=3D " " + \ + self._BuildOptionWithToolDef(RetVal)[ + Tool][Attr] else: - Value =3D self._BuildOptionWithToolDef(RetVal)= [Tool][Attr] + Value =3D self._BuildOptionWithToolDef(RetVal)[ + Tool][Attr] if Attr =3D=3D "PATH": # Don't put MAKE definition in the file if Tool !=3D "MAKE": @@ -938,7 +1004,8 @@ class PlatformAutoGen(AutoGen): ToolsDef +=3D "%s_%s =3D %s\n" % (Tool, Attr, Valu= e) ToolsDef +=3D "\n" =20 - tool_def_file =3D os.path.join(self.MakeFileDir, "TOOLS_DEF." + se= lf.Arch) + tool_def_file =3D os.path.join( + self.MakeFileDir, "TOOLS_DEF." + self.Arch) SaveFileOnChange(tool_def_file, ToolsDef, False) for DllPath in DllPathList: os.environ["PATH"] =3D DllPath + os.pathsep + os.environ["PATH= "] @@ -946,23 +1013,24 @@ class PlatformAutoGen(AutoGen): =20 return RetVal =20 - ## Return the paths of tools + # Return the paths of tools @cached_property def ToolDefinitionFile(self): - tool_def_file =3D os.path.join(self.MakeFileDir, "TOOLS_DEF." + se= lf.Arch) + tool_def_file =3D os.path.join( + self.MakeFileDir, "TOOLS_DEF." + self.Arch) if not os.path.exists(tool_def_file): self.ToolDefinition return tool_def_file =20 - ## Retrieve the toolchain family of given toolchain tag. Default to 'M= SFT'. + # Retrieve the toolchain family of given toolchain tag. Default to 'MS= FT'. @cached_property def ToolChainFamily(self): ToolDefinition =3D self.Workspace.ToolDef.ToolsDefTxtDatabase if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \ or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY]= \ or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]: - EdkLogger.verbose("No tool chain family found in configuration= for %s. Default to MSFT." \ - % self.ToolChain) + EdkLogger.verbose("No tool chain family found in configuration= for %s. Default to MSFT." + % self.ToolChain) RetVal =3D TAB_COMPILER_MSFT else: RetVal =3D ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolCha= in] @@ -974,13 +1042,13 @@ class PlatformAutoGen(AutoGen): if TAB_TOD_DEFINES_BUILDRULEFAMILY not in ToolDefinition \ or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_BUILDRU= LEFAMILY] \ or not ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.Too= lChain]: - EdkLogger.verbose("No tool chain family found in configuration= for %s. Default to MSFT." \ - % self.ToolChain) + EdkLogger.verbose("No tool chain family found in configuration= for %s. Default to MSFT." + % self.ToolChain) return TAB_COMPILER_MSFT =20 return ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolCh= ain] =20 - ## Return the build options specific for all modules in this platform + # Return the build options specific for all modules in this platform @cached_property def BuildOption(self): return self._ExpandBuildOption(self.Platform.BuildOptions) @@ -988,17 +1056,17 @@ class PlatformAutoGen(AutoGen): def _BuildOptionWithToolDef(self, ToolDef): return self._ExpandBuildOption(self.Platform.BuildOptions, ToolDef= =3DToolDef) =20 - ## Return the build options specific for EDK modules in this platform + # Return the build options specific for EDK modules in this platform @cached_property def EdkBuildOption(self): return self._ExpandBuildOption(self.Platform.BuildOptions, EDK_NAM= E) =20 - ## Return the build options specific for EDKII modules in this platform + # Return the build options specific for EDKII modules in this platform @cached_property def EdkIIBuildOption(self): return self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_N= AME) =20 - ## Parse build_rule.txt in Conf Directory. + # Parse build_rule.txt in Conf Directory. # # @retval BuildRule object # @@ -1006,21 +1074,22 @@ class PlatformAutoGen(AutoGen): def BuildRule(self): BuildRuleFile =3D None if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.Tar= getTxtDictionary: - BuildRuleFile =3D self.Workspace.TargetTxt.TargetTxtDictionary= [TAB_TAT_DEFINES_BUILD_RULE_CONF] + BuildRuleFile =3D self.Workspace.TargetTxt.TargetTxtDictionary[ + TAB_TAT_DEFINES_BUILD_RULE_CONF] if not BuildRuleFile: BuildRuleFile =3D gDefaultBuildRuleFile RetVal =3D BuildRule(BuildRuleFile) if RetVal._FileVersion =3D=3D "": RetVal._FileVersion =3D AutoGenReqBuildRuleVerNum else: - if RetVal._FileVersion < AutoGenReqBuildRuleVerNum : + if RetVal._FileVersion < AutoGenReqBuildRuleVerNum: # If Build Rule's version is less than the version number = required by the tools, halting the build. EdkLogger.error("build", AUTOGEN_ERROR, - ExtraData=3D"The version number [%s] of bu= ild_rule.txt is less than the version number required by the AutoGen.(the m= inimum required version number is [%s])"\ - % (RetVal._FileVersion, AutoGenReqBuildRu= leVerNum)) + ExtraData=3D"The version number [%s] of bu= ild_rule.txt is less than the version number required by the AutoGen.(the m= inimum required version number is [%s])" + % (RetVal._FileVersion, AutoGenReqBuildRul= eVerNum)) return RetVal =20 - ## Summarize the packages used by modules in this platform + # Summarize the packages used by modules in this platform @cached_property def PackageList(self): RetVal =3D set() @@ -1028,34 +1097,35 @@ class PlatformAutoGen(AutoGen): RetVal.update(Mb.Packages) for lb in Mb.LibInstances: RetVal.update(lb.Packages) - #Collect package set information from INF of FDF + # Collect package set information from INF of FDF for ModuleFile in self._AsBuildModuleList: if ModuleFile in self.Platform.Modules: continue - ModuleData =3D self.BuildDatabase[ModuleFile, self.Arch, self.= BuildTarget, self.ToolChain] + ModuleData =3D self.BuildDatabase[ModuleFile, + self.Arch, self.BuildTarget, s= elf.ToolChain] RetVal.update(ModuleData.Packages) RetVal.update(self.Platform.Packages) return list(RetVal) =20 @cached_property def NonDynamicPcdDict(self): - return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):Pcd for Pcd in s= elf.NonDynamicPcdList} + return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName): Pcd for Pcd in = self.NonDynamicPcdList} =20 - ## Get list of non-dynamic PCDs + # Get list of non-dynamic PCDs @property def NonDynamicPcdList(self): if not self._NonDynamicPcdList: self.CollectPlatformDynamicPcds() return self._NonDynamicPcdList =20 - ## Get list of dynamic PCDs + # Get list of dynamic PCDs @property def DynamicPcdList(self): if not self._DynamicPcdList: self.CollectPlatformDynamicPcds() return self._DynamicPcdList =20 - ## Generate Token Number for all PCD + # Generate Token Number for all PCD @cached_property def PcdTokenNumber(self): RetVal =3D OrderedDict() @@ -1071,25 +1141,29 @@ class PlatformAutoGen(AutoGen): # for Pcd in self.DynamicPcdList: if Pcd.Phase =3D=3D "PEI" and Pcd.Type in PCD_DYNAMIC_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (P= cd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, = Pcd.Phase, TokenNumber)) RetVal[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] =3D TokenN= umber TokenNumber +=3D 1 =20 for Pcd in self.DynamicPcdList: if Pcd.Phase =3D=3D "PEI" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_= SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (P= cd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, = Pcd.Phase, TokenNumber)) RetVal[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] =3D TokenN= umber TokenNumber +=3D 1 =20 for Pcd in self.DynamicPcdList: if Pcd.Phase =3D=3D "DXE" and Pcd.Type in PCD_DYNAMIC_TYPE_SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (P= cd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, = Pcd.Phase, TokenNumber)) RetVal[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] =3D TokenN= umber TokenNumber +=3D 1 =20 for Pcd in self.DynamicPcdList: if Pcd.Phase =3D=3D "DXE" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_= SET: - EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (P= cd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber)) + EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, = Pcd.Phase, TokenNumber)) RetVal[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] =3D TokenN= umber TokenNumber +=3D 1 =20 @@ -1102,7 +1176,8 @@ class PlatformAutoGen(AutoGen): ModuleList =3D [] for m in self.Platform.Modules: component =3D self.Platform.Modules[m] - module =3D self.BuildDatabase[m, self.Arch, self.BuildTarget, = self.ToolChain] + module =3D self.BuildDatabase[m, self.Arch, + self.BuildTarget, self.ToolChain] module.Guid =3D component.Guid ModuleList.append(module) return ModuleList @@ -1111,18 +1186,18 @@ class PlatformAutoGen(AutoGen): def _MaList(self): for ModuleFile in self.Platform.Modules: Ma =3D ModuleAutoGen( - self.Workspace, - ModuleFile, - self.BuildTarget, - self.ToolChain, - self.Arch, - self.MetaFile, - self.DataPipe - ) + self.Workspace, + ModuleFile, + self.BuildTarget, + self.ToolChain, + self.Arch, + self.MetaFile, + self.DataPipe + ) self.Platform.Modules[ModuleFile].M =3D Ma return [x.M for x in self.Platform.Modules.values()] =20 - ## Summarize ModuleAutoGen objects of all modules to be built for this= platform + # Summarize ModuleAutoGen objects of all modules to be built for this = platform @cached_property def ModuleAutoGenList(self): RetVal =3D [] @@ -1131,7 +1206,7 @@ class PlatformAutoGen(AutoGen): RetVal.append(Ma) return RetVal =20 - ## Summarize ModuleAutoGen objects of all libraries to be built for th= is platform + # Summarize ModuleAutoGen objects of all libraries to be built for thi= s platform @cached_property def LibraryAutoGenList(self): RetVal =3D [] @@ -1143,7 +1218,7 @@ class PlatformAutoGen(AutoGen): La.ReferenceModules.append(Ma) return RetVal =20 - ## Test if a module is supported by the platform + # Test if a module is supported by the platform # # An error will be raised directly if the module or its arch is not s= upported # by the platform or current configuration @@ -1151,23 +1226,28 @@ class PlatformAutoGen(AutoGen): def ValidModule(self, Module): return Module in self.Platform.Modules or Module in self.Platform.= LibraryInstances \ or Module in self._AsBuildModuleList + @cached_property - def GetAllModuleInfo(self,WithoutPcd=3DTrue): + def GetAllModuleInfo(self, WithoutPcd=3DTrue): ModuleLibs =3D set() for m in self.Platform.Modules: - module_obj =3D self.BuildDatabase[m,self.Arch,self.BuildTarget= ,self.ToolChain] + module_obj =3D self.BuildDatabase[m, self.Arch, + self.BuildTarget, self.ToolCha= in] if not bool(module_obj.LibraryClass): - Libs =3D GetModuleLibInstances(module_obj, self.Platform, = self.BuildDatabase, self.Arch,self.BuildTarget,self.ToolChain,self.MetaFile= ,EdkLogger) + Libs =3D GetModuleLibInstances(module_obj, self.Platform, = self.BuildDatabase, + self.Arch, self.BuildTarget, = self.ToolChain, self.MetaFile, EdkLogger) else: Libs =3D [] - ModuleLibs.update( set([(l.MetaFile.File,l.MetaFile.Root,l.Met= aFile.Path,l.MetaFile.BaseName,l.MetaFile.OriginalPath,l.Arch,True) for l i= n Libs])) + ModuleLibs.update(set([(l.MetaFile.File, l.MetaFile.Root, l.Me= taFile.Path, + l.MetaFile.BaseName, l.MetaFile.OriginalPath= , l.Arch, True) for l in Libs])) if WithoutPcd and module_obj.PcdIsDriver: continue - ModuleLibs.add((m.File,m.Root,m.Path,m.BaseName,m.OriginalPath= ,module_obj.Arch,bool(module_obj.LibraryClass))) + ModuleLibs.add((m.File, m.Root, m.Path, m.BaseName, m.Original= Path, + module_obj.Arch, bool(module_obj.LibraryClass))) =20 return ModuleLibs =20 - ## Resolve the library classes in a module to library instances + # Resolve the library classes in a module to library instances # # This method will not only resolve library classes but also sort the = library # instances according to the dependency-ship. @@ -1190,7 +1270,7 @@ class PlatformAutoGen(AutoGen): self.MetaFile, EdkLogger) =20 - ## Override PCD setting (type, value, ...) + # Override PCD setting (type, value, ...) # # @param ToPcd The PCD to be overridden # @param FromPcd The PCD overriding from @@ -1210,15 +1290,16 @@ class PlatformAutoGen(AutoGen): if ToPcd.Pending and FromPcd.Type: ToPcd.Type =3D FromPcd.Type elif ToPcd.Type and FromPcd.Type\ - and ToPcd.Type !=3D FromPcd.Type and ToPcd.Type in FromPcd= .Type: + and ToPcd.Type !=3D FromPcd.Type and ToPcd.Type in Fro= mPcd.Type: if ToPcd.Type.strip() =3D=3D TAB_PCDS_DYNAMIC_EX: ToPcd.Type =3D FromPcd.Type elif ToPcd.Type and FromPcd.Type \ - and ToPcd.Type !=3D FromPcd.Type: + and ToPcd.Type !=3D FromPcd.Type: if Library: - Module =3D str(Module) + " 's library file (" + str(Li= brary) + ")" + Module =3D str(Module) + \ + " 's library file (" + str(Library) + ")" EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD = type", - ExtraData=3D"%s.%s is used as [%s] in modu= le %s, but as [%s] in %s."\ + ExtraData=3D"%s.%s is used as [%s] in modu= le %s, but as [%s] in %s." % (ToPcd.TokenSpaceGuidCName, To= kenCName, ToPcd.Type, Module, FromPcd.T= ype, Msg), File=3Dself.MetaFile) @@ -1239,10 +1320,11 @@ class PlatformAutoGen(AutoGen): # Add Flexible PCD format parse if ToPcd.DefaultValue: try: - ToPcd.DefaultValue =3D ValueExpressionEx(ToPcd.Default= Value, ToPcd.DatumType, self.Platform._GuidDict)(True) + ToPcd.DefaultValue =3D ValueExpressionEx( + ToPcd.DefaultValue, ToPcd.DatumType, self.Platform= ._GuidDict)(True) except BadExpression as Value: - EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defau= ltValue, Value), - File=3Dself.MetaFile) + EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s]= Value "%s", %s' % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.Defa= ultValue, Value), + File=3Dself.MetaFile) =20 # check the validation of datum IsValid, Cause =3D CheckPcdDatum(ToPcd.DatumType, ToPcd.Defaul= tValue) @@ -1255,7 +1337,7 @@ class PlatformAutoGen(AutoGen): ToPcd.CustomAttribute =3D FromPcd.CustomAttribute =20 if FromPcd is not None and ToPcd.DatumType =3D=3D TAB_VOID and not= ToPcd.MaxDatumSize: - EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified = for PCD %s.%s" \ + EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified = for PCD %s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value =3D ToPcd.DefaultValue if not Value: @@ -1269,16 +1351,17 @@ class PlatformAutoGen(AutoGen): =20 # apply default SKU for dynamic PCDS if specified one is not avail= able if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMI= C_EX_TYPE_SET) \ - and not ToPcd.SkuInfoList: + and not ToPcd.SkuInfoList: if self.Platform.SkuName in self.Platform.SkuIds: SkuName =3D self.Platform.SkuName else: SkuName =3D TAB_DEFAULT ToPcd.SkuInfoList =3D { - SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuNa= me][0], '', '', '', '', '', ToPcd.DefaultValue) + SkuName: SkuInfoClass( + SkuName, self.Platform.SkuIds[SkuName][0], '', '', '',= '', '', ToPcd.DefaultValue) } =20 - ## Apply PCD setting defined platform to a module + # Apply PCD setting defined platform to a module # # @param Module The module from which the PCD setting will be over= ridden # @@ -1294,31 +1377,36 @@ class PlatformAutoGen(AutoGen): else: PcdInPlatform =3D None # then override the settings if any - self._OverridePcd(PcdInModule, PcdInPlatform, Module, Msg=3D"D= SC PCD sections", Library=3DLibrary) + self._OverridePcd(PcdInModule, PcdInPlatform, + Module, Msg=3D"DSC PCD sections", Library=3D= Library) # resolve the VariableGuid value for SkuId in PcdInModule.SkuInfoList: Sku =3D PcdInModule.SkuInfoList[SkuId] - if Sku.VariableGuid =3D=3D '': continue - Sku.VariableGuidValue =3D GuidValue(Sku.VariableGuid, self= .PackageList, self.MetaFile.Path) + if Sku.VariableGuid =3D=3D '': + continue + Sku.VariableGuidValue =3D GuidValue( + Sku.VariableGuid, self.PackageList, self.MetaFile.Path) if Sku.VariableGuidValue is None: PackageList =3D "\n\t".join(str(P) for P in self.Packa= geList) EdkLogger.error( - 'build', - RESOURCE_NOT_AVAILABLE, - "Value of GUID [%s] is not found in" % Sku= .VariableGuid, - ExtraData=3DPackageList + "\n\t(used with = %s.%s from module %s)" \ - % (Guid, Name, str= (Module)), - File=3Dself.MetaFile - ) + 'build', + RESOURCE_NOT_AVAILABLE, + "Value of GUID [%s] is not found in" % Sku.Variabl= eGuid, + ExtraData=3DPackageList + + "\n\t(used with %s.%s from module %s)" + % (Guid, Name, str(Module)), + File=3Dself.MetaFile + ) =20 # override PCD settings with module specific setting if Module in self.Platform.Modules: PlatformModule =3D self.Platform.Modules[str(Module)] - for Key in PlatformModule.Pcds: + for Key in PlatformModule.Pcds: if GlobalData.BuildOptionPcd: for pcd in GlobalData.BuildOptionPcd: - (TokenSpaceGuidCName, TokenCName, FieldName, pcdva= lue, _) =3D pcd - if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D"": + (TokenSpaceGuidCName, TokenCName, + FieldName, pcdvalue, _) =3D pcd + if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D "": PlatformModule.Pcds[Key].DefaultValue =3D pcdv= alue PlatformModule.Pcds[Key].PcdValueFromComm =3D = pcdvalue break @@ -1333,7 +1421,8 @@ class PlatformAutoGen(AutoGen): Flag =3D True break if Flag: - self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Mod= ule, Msg=3D"DSC Components Module scoped PCD section", Library=3DLibrary) + self._OverridePcd( + ToPcd, PlatformModule.Pcds[Key], Module, Msg=3D"DS= C Components Module scoped PCD section", Library=3DLibrary) # use PCD value to calculate the MaxDatumSize when it is not speci= fied for Name, Guid in Pcds: Pcd =3D Pcds[Name, Guid] @@ -1350,7 +1439,7 @@ class PlatformAutoGen(AutoGen): Pcd.MaxDatumSize =3D str(len(Value) - 1) return list(Pcds.values()) =20 - ## Append build options in platform to a module + # Append build options in platform to a module # # @param Module The module to which the build options will be appe= nded # @@ -1359,12 +1448,14 @@ class PlatformAutoGen(AutoGen): def ApplyBuildOption(self, Module): # Get the different options for the different style module PlatformOptions =3D self.EdkIIBuildOption - ModuleTypeOptions =3D self.Platform.GetBuildOptionsByModuleType(ED= KII_NAME, Module.ModuleType) + ModuleTypeOptions =3D self.Platform.GetBuildOptionsByModuleType( + EDKII_NAME, Module.ModuleType) ModuleTypeOptions =3D self._ExpandBuildOption(ModuleTypeOptions) ModuleOptions =3D self._ExpandBuildOption(Module.BuildOptions) if Module in self.Platform.Modules: PlatformModule =3D self.Platform.Modules[str(Module)] - PlatformModuleOptions =3D self._ExpandBuildOption(PlatformModu= le.BuildOptions) + PlatformModuleOptions =3D self._ExpandBuildOption( + PlatformModule.BuildOptions) else: PlatformModuleOptions =3D {} =20 @@ -1397,59 +1488,67 @@ class PlatformAutoGen(AutoGen): for ExpandedTool in ToolList: # check if override is indicated if Value.startswith('=3D'): - BuildOptions[ExpandedTool][Attr] =3D mws.handl= eWsMacro(Value[1:]) + BuildOptions[ExpandedTool][Attr] =3D mws.handl= eWsMacro( + Value[1:]) else: if Attr !=3D 'PATH': - BuildOptions[ExpandedTool][Attr] +=3D " " = + mws.handleWsMacro(Value) + BuildOptions[ExpandedTool][Attr] +=3D " " = + \ + mws.handleWsMacro(Value) else: - BuildOptions[ExpandedTool][Attr] =3D mws.h= andleWsMacro(Value) + BuildOptions[ExpandedTool][Attr] =3D mws.h= andleWsMacro( + Value) =20 return BuildOptions, BuildRuleOrder =20 - - def GetGlobalBuildOptions(self,Module): - ModuleTypeOptions =3D self.Platform.GetBuildOptionsByModuleType(ED= KII_NAME, Module.ModuleType) + def GetGlobalBuildOptions(self, Module): + ModuleTypeOptions =3D self.Platform.GetBuildOptionsByModuleType( + EDKII_NAME, Module.ModuleType) ModuleTypeOptions =3D self._ExpandBuildOption(ModuleTypeOptions) =20 if Module in self.Platform.Modules: PlatformModule =3D self.Platform.Modules[str(Module)] - PlatformModuleOptions =3D self._ExpandBuildOption(PlatformModu= le.BuildOptions) + PlatformModuleOptions =3D self._ExpandBuildOption( + PlatformModule.BuildOptions) else: PlatformModuleOptions =3D {} =20 - return ModuleTypeOptions,PlatformModuleOptions - def ModuleGuid(self,Module): + return ModuleTypeOptions, PlatformModuleOptions + + def ModuleGuid(self, Module): if os.path.basename(Module.MetaFile.File) !=3D os.path.basename(Mo= dule.MetaFile.Path): # # Length of GUID is 36 # return os.path.basename(Module.MetaFile.Path)[:36] return Module.Guid + @cached_property def UniqueBaseName(self): - retVal =3D{} + retVal =3D {} ModuleNameDict =3D {} UniqueName =3D {} for Module in self._MbList: - unique_base_name =3D '%s_%s' % (Module.BaseName,self.ModuleGui= d(Module)) + unique_base_name =3D '%s_%s' % ( + Module.BaseName, self.ModuleGuid(Module)) if unique_base_name not in ModuleNameDict: ModuleNameDict[unique_base_name] =3D [] ModuleNameDict[unique_base_name].append(Module.MetaFile) if Module.BaseName not in UniqueName: UniqueName[Module.BaseName] =3D set() - UniqueName[Module.BaseName].add((self.ModuleGuid(Module),Modul= e.MetaFile)) + UniqueName[Module.BaseName].add( + (self.ModuleGuid(Module), Module.MetaFile)) for module_paths in ModuleNameDict.values(): - if len(set(module_paths))>1: + if len(set(module_paths)) > 1: samemodules =3D list(set(module_paths)) EdkLogger.error("build", FILE_DUPLICATED, 'Modules have sa= me BaseName and FILE_GUID:\n' - ' %s\n %s' % (samemodules[0], samemo= dules[1])) + ' %s\n %s' % (samemodules[0], samemodule= s[1])) for name in UniqueName: Guid_Path =3D UniqueName[name] if len(Guid_Path) > 1: - for guid,mpath in Guid_Path: - retVal[(name,mpath)] =3D '%s_%s' % (name,guid) + for guid, mpath in Guid_Path: + retVal[(name, mpath)] =3D '%s_%s' % (name, guid) return retVal - ## Expand * in build option key + # Expand * in build option key # # @param Options Options to be expanded # @param ToolDef Use specified ToolDef instead of full version. @@ -1459,11 +1558,12 @@ class PlatformAutoGen(AutoGen): # # @retval options Options expanded # + def _ExpandBuildOption(self, Options, ModuleStyle=3DNone, ToolDef=3DNo= ne): if not ToolDef: ToolDef =3D self.ToolDefinition BuildOptions =3D {} - FamilyMatch =3D False + FamilyMatch =3D False FamilyIsNull =3D True =20 OverrideList =3D {} @@ -1476,12 +1576,12 @@ class PlatformAutoGen(AutoGen): # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE # if (Key[0] =3D=3D self.BuildRuleFamily and - (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and = Key[2] =3D=3D ModuleStyle))): + (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 = and Key[2] =3D=3D ModuleStyle))): Target, ToolChain, Arch, CommandType, Attr =3D Key[1].spli= t('_') if (Target =3D=3D self.BuildTarget or Target =3D=3D TAB_ST= AR) and\ (ToolChain =3D=3D self.ToolChain or ToolChain =3D=3D T= AB_STAR) and\ (Arch =3D=3D self.Arch or Arch =3D=3D TAB_STAR) and\ - Options[Key].startswith("=3D"): + Options[Key].startswith("=3D"): =20 if OverrideList.get(Key[1]) is not None: OverrideList.pop(Key[1]) @@ -1494,18 +1594,20 @@ class PlatformAutoGen(AutoGen): KeyList =3D list(OverrideList.keys()) for Index in range(len(KeyList)): NowKey =3D KeyList[Index] - Target1, ToolChain1, Arch1, CommandType1, Attr1 =3D NowKey= .split("_") + Target1, ToolChain1, Arch1, CommandType1, Attr1 =3D NowKey= .split( + "_") for Index1 in range(len(KeyList) - Index - 1): NextKey =3D KeyList[Index1 + Index + 1] # # Compare two Key, if one is included by another, choo= se the higher priority one # - Target2, ToolChain2, Arch2, CommandType2, Attr2 =3D Ne= xtKey.split("_") + Target2, ToolChain2, Arch2, CommandType2, Attr2 =3D Ne= xtKey.split( + "_") if (Target1 =3D=3D Target2 or Target1 =3D=3D TAB_STAR = or Target2 =3D=3D TAB_STAR) and\ (ToolChain1 =3D=3D ToolChain2 or ToolChain1 =3D=3D= TAB_STAR or ToolChain2 =3D=3D TAB_STAR) and\ (Arch1 =3D=3D Arch2 or Arch1 =3D=3D TAB_STAR or Ar= ch2 =3D=3D TAB_STAR) and\ (CommandType1 =3D=3D CommandType2 or CommandType1 = =3D=3D TAB_STAR or CommandType2 =3D=3D TAB_STAR) and\ - (Attr1 =3D=3D Attr2 or Attr1 =3D=3D TAB_STAR or At= tr2 =3D=3D TAB_STAR): + (Attr1 =3D=3D Attr2 or Attr1 =3D=3D TAB_STAR o= r Attr2 =3D=3D TAB_STAR): =20 if CalculatePriorityValue(NowKey) > CalculatePrior= ityValue(NextKey): if Options.get((self.BuildRuleFamily, NextKey)= ) is not None: @@ -1515,7 +1617,7 @@ class PlatformAutoGen(AutoGen): Options.pop((self.BuildRuleFamily, NowKey)) =20 for Key in Options: - if ModuleStyle is not None and len (Key) > 2: + if ModuleStyle is not None and len(Key) > 2: # Check Module style is EDK or EDKII. # Only append build option for the matched style module. if ModuleStyle =3D=3D EDK_NAME and Key[2] !=3D EDK_NAME: @@ -1561,7 +1663,7 @@ class PlatformAutoGen(AutoGen): return BuildOptions =20 for Key in Options: - if ModuleStyle is not None and len (Key) > 2: + if ModuleStyle is not None and len(Key) > 2: # Check Module style is EDK or EDKII. # Only append build option for the matched style module. if ModuleStyle =3D=3D EDK_NAME and Key[2] !=3D EDK_NAME: diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Sourc= e/Python/AutoGen/StrGather.py index eed30388bea1..441f6ebcbf0e 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a strings file and create or add to a string = database # file. # @@ -54,7 +54,8 @@ NOT_REFERENCED =3D 'not referenced' COMMENT_NOT_REFERENCED =3D ' ' + COMMENT + NOT_REFERENCED CHAR_ARRAY_DEFIN =3D 'unsigned char' COMMON_FILE_NAME =3D 'Strings' -STRING_TOKEN =3D re.compile('STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILI= NE | re.UNICODE) +STRING_TOKEN =3D re.compile( + 'STRING_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE) =20 EFI_HII_ARRAY_SIZE_LENGTH =3D 4 EFI_HII_PACKAGE_HEADER_LENGTH =3D 4 @@ -65,17 +66,19 @@ EFI_STRING_ID_LENGTH =3D 2 EFI_HII_LANGUAGE_WINDOW =3D 0 EFI_HII_LANGUAGE_WINDOW_LENGTH =3D 2 EFI_HII_LANGUAGE_WINDOW_NUMBER =3D 16 -EFI_HII_STRING_PACKAGE_HDR_LENGTH =3D EFI_HII_PACKAGE_HEADER_LENGTH + EFI_= HII_HDR_SIZE_LENGTH + EFI_HII_STRING_OFFSET_LENGTH + EFI_HII_LANGUAGE_WINDO= W_LENGTH * EFI_HII_LANGUAGE_WINDOW_NUMBER + EFI_STRING_ID_LENGTH +EFI_HII_STRING_PACKAGE_HDR_LENGTH =3D EFI_HII_PACKAGE_HEADER_LENGTH + EFI_= HII_HDR_SIZE_LENGTH + \ + EFI_HII_STRING_OFFSET_LENGTH + EFI_HII_LANGUAGE_WINDOW_LENGTH * \ + EFI_HII_LANGUAGE_WINDOW_NUMBER + EFI_STRING_ID_LENGTH =20 -H_C_FILE_HEADER =3D ['//', \ - '// DO NOT EDIT -- auto-generated file', \ - '//', \ - '// This file is generated by the StrGather utility', \ +H_C_FILE_HEADER =3D ['//', + '// DO NOT EDIT -- auto-generated file', + '//', + '// This file is generated by the StrGather utility', '//'] LANGUAGE_NAME_STRING_NAME =3D '$LANGUAGE_NAME' PRINTABLE_LANGUAGE_NAME_STRING_NAME =3D '$PRINTABLE_LANGUAGE_NAME' =20 -## Convert a dec number to a hex string +# Convert a dec number to a hex string # # Convert a dec number to a formatted hex string in length digit # The digit is set to default 8 @@ -88,10 +91,12 @@ PRINTABLE_LANGUAGE_NAME_STRING_NAME =3D '$PRINTABLE_LAN= GUAGE_NAME' # # @retval: The formatted hex string # -def DecToHexStr(Dec, Digit =3D 8): + + +def DecToHexStr(Dec, Digit=3D8): return '0x{0:0{1}X}'.format(Dec, Digit) =20 -## Convert a dec number to a hex list +# Convert a dec number to a hex list # # Convert a dec number to a formatted hex list in size digit # The digit is set to default 8 @@ -103,11 +108,13 @@ def DecToHexStr(Dec, Digit =3D 8): # # @retval: A list for formatted hex string # -def DecToHexList(Dec, Digit =3D 8): + + +def DecToHexList(Dec, Digit=3D8): Hex =3D '{0:0{1}X}'.format(Dec, Digit) return ["0x" + Hex[Bit:Bit + 2] for Bit in range(Digit - 2, -1, -2)] =20 -## Convert a acsii string to a hex list +# Convert a acsii string to a hex list # # Convert a acsii string to a formatted hex list # AscToHexList('en-US') is ['0x65', '0x6E', '0x2D', '0x55', '0x53'] @@ -116,13 +123,15 @@ def DecToHexList(Dec, Digit =3D 8): # # @retval: A list for formatted hex string # + + def AscToHexList(Ascii): try: return ['0x{0:02X}'.format(Item) for Item in Ascii] except: return ['0x{0:02X}'.format(ord(Item)) for Item in Ascii] =20 -## Create content of .h file +# Create content of .h file # # Create content of .h file # @@ -133,16 +142,22 @@ def AscToHexList(Ascii): # # @retval Str: A string of .h file content # + + def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenC= Flag): Str =3D [] ValueStartPtr =3D 60 - Line =3D COMMENT_DEFINE_STR + ' ' + LANGUAGE_NAME_STRING_NAME + ' ' * = (ValueStartPtr - len(DEFINE_STR + LANGUAGE_NAME_STRING_NAME)) + DecToHexStr= (0, 4) + COMMENT_NOT_REFERENCED + Line =3D COMMENT_DEFINE_STR + ' ' + LANGUAGE_NAME_STRING_NAME + ' ' * \ + (ValueStartPtr - len(DEFINE_STR + LANGUAGE_NAME_STRING_NAME)) + \ + DecToHexStr(0, 4) + COMMENT_NOT_REFERENCED Str =3D WriteLine(Str, Line) - Line =3D COMMENT_DEFINE_STR + ' ' + PRINTABLE_LANGUAGE_NAME_STRING_NAM= E + ' ' * (ValueStartPtr - len(DEFINE_STR + PRINTABLE_LANGUAGE_NAME_STRING_= NAME)) + DecToHexStr(1, 4) + COMMENT_NOT_REFERENCED + Line =3D COMMENT_DEFINE_STR + ' ' + PRINTABLE_LANGUAGE_NAME_STRING_NAM= E + ' ' * \ + (ValueStartPtr - len(DEFINE_STR + PRINTABLE_LANGUAGE_NAME_STRING_N= AME) + ) + DecToHexStr(1, 4) + COMMENT_NOT_REFERENCED Str =3D WriteLine(Str, Line) UnusedStr =3D '' =20 - #Group the referred/Unused STRING token together. + # Group the referred/Unused STRING token together. for Index in range(2, len(UniObjectClass.OrderedStringList[UniObjectCl= ass.LanguageDef[0][0]])): StringItem =3D UniObjectClass.OrderedStringList[UniObjectClass.Lan= guageDef[0][0]][Index] Name =3D StringItem.StringName @@ -152,25 +167,31 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniGenCFlag): Line =3D '' if Referenced =3D=3D True: if (ValueStartPtr - len(DEFINE_STR + Name)) <=3D 0: - Line =3D DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(T= oken, 4) + Line =3D DEFINE_STR + ' ' + Name + \ + ' ' + DecToHexStr(Token, 4) else: - Line =3D DEFINE_STR + ' ' + Name + ' ' * (ValueStartPt= r - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + Line =3D DEFINE_STR + ' ' + Name + ' ' * \ + (ValueStartPtr - len(DEFINE_STR + Name)) + \ + DecToHexStr(Token, 4) Str =3D WriteLine(Str, Line) else: if (ValueStartPtr - len(DEFINE_STR + Name)) <=3D 0: - Line =3D COMMENT_DEFINE_STR + ' ' + Name + ' ' + DecTo= HexStr(Token, 4) + COMMENT_NOT_REFERENCED + Line =3D COMMENT_DEFINE_STR + ' ' + Name + ' ' + \ + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED else: - Line =3D COMMENT_DEFINE_STR + ' ' + Name + ' ' * (Valu= eStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_R= EFERENCED + Line =3D COMMENT_DEFINE_STR + ' ' + Name + ' ' * \ + (ValueStartPtr - len(DEFINE_STR + Name)) + \ + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED UnusedStr =3D WriteLine(UnusedStr, Line) =20 - Str.extend( UnusedStr) + Str.extend(UnusedStr) =20 Str =3D WriteLine(Str, '') if IsCompatibleMode or UniGenCFlag: Str =3D WriteLine(Str, 'extern unsigned char ' + BaseName + 'Strin= gs[];') return "".join(Str) =20 -## Create a complete .h file +# Create a complete .h file # # Create a complet .h file with file header and file content # @@ -181,21 +202,26 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniGenCFlag): # # @retval Str: A string of complete .h file # + + def CreateHFile(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag): - HFile =3D WriteLine('', CreateHFileContent(BaseName, UniObjectClass, I= sCompatibleMode, UniGenCFlag)) + HFile =3D WriteLine('', CreateHFileContent( + BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag)) =20 return "".join(HFile) =20 -## Create a buffer to store all items in an array +# Create a buffer to store all items in an array # # @param BinBuffer Buffer to contain Binary data. # @param Array: The array need to be formatted # + + def CreateBinBuffer(BinBuffer, Array): for Item in Array: BinBuffer.write(pack("B", int(Item, 16))) =20 -## Create a formatted string all items in an array +# Create a formatted string all items in an array # # Use ',' to join each item in an array, and break an new line when reachi= ng the width (default is 16) # @@ -204,7 +230,9 @@ def CreateBinBuffer(BinBuffer, Array): # # @retval ArrayItem: A string for all formatted array items # -def CreateArrayItem(Array, Width =3D 16): + + +def CreateArrayItem(Array, Width=3D16): MaxLength =3D Width Index =3D 0 Line =3D ' ' @@ -222,7 +250,7 @@ def CreateArrayItem(Array, Width =3D 16): =20 return "".join(ArrayItem) =20 -## CreateCFileStringValue +# CreateCFileStringValue # # Create a line with string value # @@ -231,13 +259,14 @@ def CreateArrayItem(Array, Width =3D 16): # @retval Str: A formatted string with string value # =20 + def CreateCFileStringValue(Value): Value =3D [StringBlockType] + Value Str =3D WriteLine('', CreateArrayItem(Value)) =20 return "".join(Str) =20 -## GetFilteredLanguage +# GetFilteredLanguage # # apply get best language rules to the UNI language code list # @@ -246,6 +275,8 @@ def CreateCFileStringValue(Value): # # @retval UniLanguageListFiltered: the filtered language code # + + def GetFilteredLanguage(UniLanguageList, LanguageFilterList): UniLanguageListFiltered =3D [] # if filter list is empty, then consider there is no filter @@ -269,12 +300,14 @@ def GetFilteredLanguage(UniLanguageList, LanguageFilt= erList): =20 for UniLanguage in UniLanguageList: if UniLanguage.find('-') !=3D -1: - UniLanguagePrimaryTag =3D UniLanguage[0:UniLanguage.fi= nd('-')].lower() + UniLanguagePrimaryTag =3D UniLanguage[0:UniLanguage.fi= nd( + '-')].lower() else: UniLanguagePrimaryTag =3D UniLanguage =20 if len(UniLanguagePrimaryTag) =3D=3D 3: - UniLanguagePrimaryTag =3D LangConvTable.get(UniLanguag= ePrimaryTag) + UniLanguagePrimaryTag =3D LangConvTable.get( + UniLanguagePrimaryTag) =20 if PrimaryTag =3D=3D UniLanguagePrimaryTag: if UniLanguage not in UniLanguageListFiltered: @@ -294,10 +327,10 @@ def GetFilteredLanguage(UniLanguageList, LanguageFilt= erList): break else: UniLanguageListFiltered.append(DefaultTag) - return UniLanguageListFiltered + return UniLanguageListFiltered =20 =20 -## Create content of .c file +# Create content of .c file # # Create content of .c file # @@ -322,14 +355,15 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniBinBuffer, LanguageFilterList =3D FilterInfo[1] else: # EDK module is using ISO639-2 format filter, convert to the RFC46= 46 format - LanguageFilterList =3D [LangConvTable.get(F.lower()) for F in Filt= erInfo[1]] + LanguageFilterList =3D [LangConvTable.get( + F.lower()) for F in FilterInfo[1]] =20 UniLanguageList =3D [] for IndexI in range(len(UniObjectClass.LanguageDef)): UniLanguageList +=3D [UniObjectClass.LanguageDef[IndexI][0]] =20 - UniLanguageListFiltered =3D GetFilteredLanguage(UniLanguageList, Langu= ageFilterList) - + UniLanguageListFiltered =3D GetFilteredLanguage( + UniLanguageList, LanguageFilterList) =20 # # Create lines for each language's strings @@ -358,16 +392,21 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniBinBuffer, Index =3D Index + 1 else: if NumberOfUseOtherLangDef > 0: - StrStringValue =3D WriteLine(StrStringValue, CreateArr= ayItem([StringSkipType] + DecToHexList(NumberOfUseOtherLangDef, 4))) - CreateBinBuffer (StringBuffer, ([StringSkipType] + Dec= ToHexList(NumberOfUseOtherLangDef, 4))) + StrStringValue =3D WriteLine(StrStringValue, CreateArr= ayItem( + [StringSkipType] + DecToHexList(NumberOfUseOtherLa= ngDef, 4))) + CreateBinBuffer( + StringBuffer, ([StringSkipType] + DecToHexList(Num= berOfUseOtherLangDef, 4))) NumberOfUseOtherLangDef =3D 0 ArrayLength =3D ArrayLength + 3 if Referenced and Item.Token > 0: Index =3D Index + 1 - StrStringValue =3D WriteLine(StrStringValue, "// %s: %= s:%s" % (DecToHexStr(Index, 4), Name, DecToHexStr(Token, 4))) - StrStringValue =3D Write(StrStringValue, CreateCFileSt= ringValue(Value)) - CreateBinBuffer (StringBuffer, [StringBlockType] + Val= ue) - ArrayLength =3D ArrayLength + Item.Length + 1 # 1 is f= or the length of string type + StrStringValue =3D WriteLine( + StrStringValue, "// %s: %s:%s" % (DecToHexStr(Inde= x, 4), Name, DecToHexStr(Token, 4))) + StrStringValue =3D Write( + StrStringValue, CreateCFileStringValue(Value)) + CreateBinBuffer(StringBuffer, [StringBlockType] + Valu= e) + ArrayLength =3D ArrayLength + Item.Length + \ + 1 # 1 is for the length of string type =20 # # EFI_HII_PACKAGE_HEADER @@ -382,13 +421,13 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniBinBuffer, TotalLength =3D TotalLength + ArrayLength =20 List =3D DecToHexList(ArrayLength, 6) + \ - [StringPackageType] + \ - DecToHexList(Offset) + \ - DecToHexList(Offset) + \ - DecToHexList(EFI_HII_LANGUAGE_WINDOW, EFI_HII_LANGUAGE_WIND= OW_LENGTH * 2) * EFI_HII_LANGUAGE_WINDOW_NUMBER + \ - DecToHexList(EFI_STRING_ID, 4) + \ - AscToHexList(Language) + \ - DecToHexList(0, 2) + [StringPackageType] + \ + DecToHexList(Offset) + \ + DecToHexList(Offset) + \ + DecToHexList(EFI_HII_LANGUAGE_WINDOW, EFI_HII_LANGUAGE_WINDOW_= LENGTH * 2) * EFI_HII_LANGUAGE_WINDOW_NUMBER + \ + DecToHexList(EFI_STRING_ID, 4) + \ + AscToHexList(Language) + \ + DecToHexList(0, 2) Str =3D WriteLine(Str, CreateArrayItem(List, 16) + '\n') =20 # @@ -406,23 +445,25 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniBinBuffer, # Create binary UNI string # if UniBinBuffer: - CreateBinBuffer (UniBinBuffer, List) - UniBinBuffer.write (StringBuffer.getvalue()) - UniBinBuffer.write (pack("B", int(EFI_HII_SIBT_END, 16))) + CreateBinBuffer(UniBinBuffer, List) + UniBinBuffer.write(StringBuffer.getvalue()) + UniBinBuffer.write(pack("B", int(EFI_HII_SIBT_END, 16))) StringBuffer.close() =20 # # Create line for string variable name # "unsigned char $(BaseName)Strings[] =3D {" # - AllStr =3D WriteLine('', CHAR_ARRAY_DEFIN + ' ' + BaseName + COMMON_FI= LE_NAME + '[] =3D {\n') + AllStr =3D WriteLine('', CHAR_ARRAY_DEFIN + ' ' + + BaseName + COMMON_FILE_NAME + '[] =3D {\n') =20 if IsCompatibleMode: # # Create FRAMEWORK_EFI_HII_PACK_HEADER in compatible mode # AllStr =3D WriteLine(AllStr, '// FRAMEWORK PACKAGE HEADER Length') - AllStr =3D WriteLine(AllStr, CreateArrayItem(DecToHexList(TotalLen= gth + 2)) + '\n') + AllStr =3D WriteLine(AllStr, CreateArrayItem( + DecToHexList(TotalLength + 2)) + '\n') AllStr =3D WriteLine(AllStr, '// FRAMEWORK PACKAGE HEADER Type') AllStr =3D WriteLine(AllStr, CreateArrayItem(DecToHexList(2, 4)) += '\n') else: @@ -430,7 +471,8 @@ def CreateCFileContent(BaseName, UniObjectClass, IsComp= atibleMode, UniBinBuffer, # Create whole array length in UEFI mode # AllStr =3D WriteLine(AllStr, '// STRGATHER_OUTPUT_HEADER') - AllStr =3D WriteLine(AllStr, CreateArrayItem(DecToHexList(TotalLen= gth)) + '\n') + AllStr =3D WriteLine(AllStr, CreateArrayItem( + DecToHexList(TotalLength)) + '\n') =20 # # Join package data @@ -439,17 +481,19 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCo= mpatibleMode, UniBinBuffer, =20 return "".join(AllStr) =20 -## Create end of .c file +# Create end of .c file # # Create end of .c file # # @retval Str: A string of .h file end # + + def CreateCFileEnd(): Str =3D Write('', '};') return Str =20 -## Create a .c file +# Create a .c file # # Create a complete .c file # @@ -460,13 +504,16 @@ def CreateCFileEnd(): # # @retval CFile: A string of complete .c file # + + def CreateCFile(BaseName, UniObjectClass, IsCompatibleMode, FilterInfo): CFile =3D '' - CFile =3D WriteLine(CFile, CreateCFileContent(BaseName, UniObjectClass= , IsCompatibleMode, None, FilterInfo)) + CFile =3D WriteLine(CFile, CreateCFileContent( + BaseName, UniObjectClass, IsCompatibleMode, None, FilterInfo)) CFile =3D WriteLine(CFile, CreateCFileEnd()) return "".join(CFile) =20 -## GetFileList +# GetFileList # # Get a list for all files # @@ -475,9 +522,12 @@ def CreateCFile(BaseName, UniObjectClass, IsCompatible= Mode, FilterInfo): # # @retval FileList: A list of all files found # + + def GetFileList(SourceFileList, IncludeList, SkipList): if IncludeList is None: - EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, "Include pat= h for unicode file is not defined") + EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, + "Include path for unicode file is not defined") =20 FileList =3D [] if SkipList is None: @@ -499,7 +549,8 @@ def GetFileList(SourceFileList, IncludeList, SkipList): IsSkip =3D False for Skip in SkipList: if os.path.splitext(File)[1].upper() =3D=3D Skip.upper(): - EdkLogger.verbose("Skipped %s for string token uses se= arch" % File) + EdkLogger.verbose( + "Skipped %s for string token uses search" % File) IsSkip =3D True break =20 @@ -510,7 +561,7 @@ def GetFileList(SourceFileList, IncludeList, SkipList): =20 return FileList =20 -## SearchString +# SearchString # # Search whether all string defined in UniObjectClass are referenced # All string used should be set to Referenced @@ -521,6 +572,8 @@ def GetFileList(SourceFileList, IncludeList, SkipList): # # @retval UniObjectClass: UniObjectClass after searched # + + def SearchString(UniObjectClass, FileList, IsCompatibleMode): if FileList =3D=3D []: return UniObjectClass @@ -531,55 +584,65 @@ def SearchString(UniObjectClass, FileList, IsCompatib= leMode): Lines =3D open(File, 'r') for Line in Lines: for StrName in STRING_TOKEN.findall(Line): - EdkLogger.debug(EdkLogger.DEBUG_5, "Found string i= dentifier: " + StrName) + EdkLogger.debug(EdkLogger.DEBUG_5, + "Found string identifier: " + StrN= ame) UniObjectClass.SetStringReferenced(StrName) except: - EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, "SearchS= tring: Error while processing file", File=3DFile, RaiseError=3DFalse) + EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, + "SearchString: Error while processing file", F= ile=3DFile, RaiseError=3DFalse) raise =20 UniObjectClass.ReToken() =20 return UniObjectClass =20 -## GetStringFiles +# GetStringFiles # # This function is used for UEFI2.1 spec # # -def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathLis= t, SkipList, BaseName, IsCompatibleMode =3D False, ShellMode =3D False, Uni= GenCFlag =3D True, UniGenBinBuffer =3D None, FilterInfo =3D [True, []]): + + +def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathLis= t, SkipList, BaseName, IsCompatibleMode=3DFalse, ShellMode=3DFalse, UniGenC= Flag=3DTrue, UniGenBinBuffer=3DNone, FilterInfo=3D[True, []]): if len(UniFilList) > 0: if ShellMode: # # support ISO 639-2 codes in .UNI files of EDK Shell # - Uni =3D UniFileClassObject(sorted(UniFilList, key=3Dlambda x: = x.File), True, IncludePathList) + Uni =3D UniFileClassObject( + sorted(UniFilList, key=3Dlambda x: x.File), True, IncludeP= athList) else: - Uni =3D UniFileClassObject(sorted(UniFilList, key=3Dlambda x: = x.File), IsCompatibleMode, IncludePathList) + Uni =3D UniFileClassObject( + sorted(UniFilList, key=3Dlambda x: x.File), IsCompatibleMo= de, IncludePathList) else: - EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, 'No unicode = files given') + EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, + 'No unicode files given') =20 FileList =3D GetFileList(SourceFileList, IncludeList, SkipList) =20 - Uni =3D SearchString(Uni, sorted (FileList), IsCompatibleMode) + Uni =3D SearchString(Uni, sorted(FileList), IsCompatibleMode) =20 HFile =3D CreateHFile(BaseName, Uni, IsCompatibleMode, UniGenCFlag) CFile =3D None if IsCompatibleMode or UniGenCFlag: CFile =3D CreateCFile(BaseName, Uni, IsCompatibleMode, FilterInfo) if UniGenBinBuffer: - CreateCFileContent(BaseName, Uni, IsCompatibleMode, UniGenBinBuffe= r, FilterInfo) + CreateCFileContent(BaseName, Uni, IsCompatibleMode, + UniGenBinBuffer, FilterInfo) =20 return HFile, CFile =20 # # Write an item # + + def Write(Target, Item): - if isinstance(Target,str): + if isinstance(Target, str): Target =3D [Target] if not Target: Target =3D [] - if isinstance(Item,list): + if isinstance(Item, list): Target.extend(Item) else: Target.append(Item) @@ -588,8 +651,10 @@ def Write(Target, Item): # # Write an item with a break line # + + def WriteLine(Target, Item): - if isinstance(Target,str): + if isinstance(Target, str): Target =3D [Target] if not Target: Target =3D [] @@ -600,14 +665,15 @@ def WriteLine(Target, Item): Target.append('\n') return Target =20 + # This acts like the main() function for the script, unless it is 'import'= ed into another # script. if __name__ =3D=3D '__main__': EdkLogger.info('start') =20 UniFileList =3D [ - r'C:\\Edk\\Strings2.uni', - r'C:\\Edk\\Strings.uni' + r'C:\\Edk\\Strings2.uni', + r'C:\\Edk\\Strings.uni' ] =20 SrcFileList =3D [] @@ -616,12 +682,13 @@ if __name__ =3D=3D '__main__': SrcFileList.append(File) =20 IncludeList =3D [ - r'C:\\Edk' + r'C:\\Edk' ] =20 SkipList =3D ['.inf', '.uni'] BaseName =3D 'DriverSample' - (h, c) =3D GetStringFiles(UniFileList, SrcFileList, IncludeList, SkipL= ist, BaseName, True) + (h, c) =3D GetStringFiles(UniFileList, SrcFileList, + IncludeList, SkipList, BaseName, True) hfile =3D open('unistring.h', 'w') cfile =3D open('unistring.c', 'w') hfile.write(h) diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/= Source/Python/AutoGen/UniClassObject.py index b16330e36825..753364560e04 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to collect all defined strings in multiple uni files # # @@ -11,7 +11,9 @@ # Import Modules # from __future__ import print_function -import Common.LongFilePathOs as os, codecs, re +import Common.LongFilePathOs as os +import codecs +import re import shlex import Common.EdkLogger as EdkLogger from io import BytesIO @@ -38,9 +40,10 @@ NULL =3D u'\u0000' TAB =3D u'\t' BACK_SLASH_PLACEHOLDER =3D u'\u0006' =20 -gIncludePattern =3D re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.M= ULTILINE | re.UNICODE) +gIncludePattern =3D re.compile( + "^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE) =20 -## Convert a unicode string to a Hex list +# Convert a unicode string to a Hex list # # Convert a unicode string to a Hex list # UniToHexList('ABC') is ['0x41', '0x00', '0x42', '0x00', '0x43', '0x00'] @@ -49,6 +52,8 @@ gIncludePattern =3D re.compile("^#include +[\"<]+([^\"< >= ]+)[>\"]+$", re.MULTILINE # # @retval List: The formatted hex list # + + def UniToHexList(Uni): List =3D [] for Item in Uni: @@ -57,40 +62,41 @@ def UniToHexList(Uni): List.append('0x' + Temp[0:2]) return List =20 -LangConvTable =3D {'eng':'en', 'fra':'fr', \ - 'aar':'aa', 'abk':'ab', 'ave':'ae', 'afr':'af', 'aka':'ak= ', 'amh':'am', \ - 'arg':'an', 'ara':'ar', 'asm':'as', 'ava':'av', 'aym':'ay= ', 'aze':'az', \ - 'bak':'ba', 'bel':'be', 'bul':'bg', 'bih':'bh', 'bis':'bi= ', 'bam':'bm', \ - 'ben':'bn', 'bod':'bo', 'bre':'br', 'bos':'bs', 'cat':'ca= ', 'che':'ce', \ - 'cha':'ch', 'cos':'co', 'cre':'cr', 'ces':'cs', 'chu':'cu= ', 'chv':'cv', \ - 'cym':'cy', 'dan':'da', 'deu':'de', 'div':'dv', 'dzo':'dz= ', 'ewe':'ee', \ - 'ell':'el', 'epo':'eo', 'spa':'es', 'est':'et', 'eus':'eu= ', 'fas':'fa', \ - 'ful':'ff', 'fin':'fi', 'fij':'fj', 'fao':'fo', 'fry':'fy= ', 'gle':'ga', \ - 'gla':'gd', 'glg':'gl', 'grn':'gn', 'guj':'gu', 'glv':'gv= ', 'hau':'ha', \ - 'heb':'he', 'hin':'hi', 'hmo':'ho', 'hrv':'hr', 'hat':'ht= ', 'hun':'hu', \ - 'hye':'hy', 'her':'hz', 'ina':'ia', 'ind':'id', 'ile':'ie= ', 'ibo':'ig', \ - 'iii':'ii', 'ipk':'ik', 'ido':'io', 'isl':'is', 'ita':'it= ', 'iku':'iu', \ - 'jpn':'ja', 'jav':'jv', 'kat':'ka', 'kon':'kg', 'kik':'ki= ', 'kua':'kj', \ - 'kaz':'kk', 'kal':'kl', 'khm':'km', 'kan':'kn', 'kor':'ko= ', 'kau':'kr', \ - 'kas':'ks', 'kur':'ku', 'kom':'kv', 'cor':'kw', 'kir':'ky= ', 'lat':'la', \ - 'ltz':'lb', 'lug':'lg', 'lim':'li', 'lin':'ln', 'lao':'lo= ', 'lit':'lt', \ - 'lub':'lu', 'lav':'lv', 'mlg':'mg', 'mah':'mh', 'mri':'mi= ', 'mkd':'mk', \ - 'mal':'ml', 'mon':'mn', 'mar':'mr', 'msa':'ms', 'mlt':'mt= ', 'mya':'my', \ - 'nau':'na', 'nob':'nb', 'nde':'nd', 'nep':'ne', 'ndo':'ng= ', 'nld':'nl', \ - 'nno':'nn', 'nor':'no', 'nbl':'nr', 'nav':'nv', 'nya':'ny= ', 'oci':'oc', \ - 'oji':'oj', 'orm':'om', 'ori':'or', 'oss':'os', 'pan':'pa= ', 'pli':'pi', \ - 'pol':'pl', 'pus':'ps', 'por':'pt', 'que':'qu', 'roh':'rm= ', 'run':'rn', \ - 'ron':'ro', 'rus':'ru', 'kin':'rw', 'san':'sa', 'srd':'sc= ', 'snd':'sd', \ - 'sme':'se', 'sag':'sg', 'sin':'si', 'slk':'sk', 'slv':'sl= ', 'smo':'sm', \ - 'sna':'sn', 'som':'so', 'sqi':'sq', 'srp':'sr', 'ssw':'ss= ', 'sot':'st', \ - 'sun':'su', 'swe':'sv', 'swa':'sw', 'tam':'ta', 'tel':'te= ', 'tgk':'tg', \ - 'tha':'th', 'tir':'ti', 'tuk':'tk', 'tgl':'tl', 'tsn':'tn= ', 'ton':'to', \ - 'tur':'tr', 'tso':'ts', 'tat':'tt', 'twi':'tw', 'tah':'ty= ', 'uig':'ug', \ - 'ukr':'uk', 'urd':'ur', 'uzb':'uz', 'ven':'ve', 'vie':'vi= ', 'vol':'vo', \ - 'wln':'wa', 'wol':'wo', 'xho':'xh', 'yid':'yi', 'yor':'yo= ', 'zha':'za', \ - 'zho':'zh', 'zul':'zu'} =20 -## GetLanguageCode +LangConvTable =3D {'eng': 'en', 'fra': 'fr', + 'aar': 'aa', 'abk': 'ab', 'ave': 'ae', 'afr': 'af', 'aka'= : 'ak', 'amh': 'am', + 'arg': 'an', 'ara': 'ar', 'asm': 'as', 'ava': 'av', 'aym'= : 'ay', 'aze': 'az', + 'bak': 'ba', 'bel': 'be', 'bul': 'bg', 'bih': 'bh', 'bis'= : 'bi', 'bam': 'bm', + 'ben': 'bn', 'bod': 'bo', 'bre': 'br', 'bos': 'bs', 'cat'= : 'ca', 'che': 'ce', + 'cha': 'ch', 'cos': 'co', 'cre': 'cr', 'ces': 'cs', 'chu'= : 'cu', 'chv': 'cv', + 'cym': 'cy', 'dan': 'da', 'deu': 'de', 'div': 'dv', 'dzo'= : 'dz', 'ewe': 'ee', + 'ell': 'el', 'epo': 'eo', 'spa': 'es', 'est': 'et', 'eus'= : 'eu', 'fas': 'fa', + 'ful': 'ff', 'fin': 'fi', 'fij': 'fj', 'fao': 'fo', 'fry'= : 'fy', 'gle': 'ga', + 'gla': 'gd', 'glg': 'gl', 'grn': 'gn', 'guj': 'gu', 'glv'= : 'gv', 'hau': 'ha', + 'heb': 'he', 'hin': 'hi', 'hmo': 'ho', 'hrv': 'hr', 'hat'= : 'ht', 'hun': 'hu', + 'hye': 'hy', 'her': 'hz', 'ina': 'ia', 'ind': 'id', 'ile'= : 'ie', 'ibo': 'ig', + 'iii': 'ii', 'ipk': 'ik', 'ido': 'io', 'isl': 'is', 'ita'= : 'it', 'iku': 'iu', + 'jpn': 'ja', 'jav': 'jv', 'kat': 'ka', 'kon': 'kg', 'kik'= : 'ki', 'kua': 'kj', + 'kaz': 'kk', 'kal': 'kl', 'khm': 'km', 'kan': 'kn', 'kor'= : 'ko', 'kau': 'kr', + 'kas': 'ks', 'kur': 'ku', 'kom': 'kv', 'cor': 'kw', 'kir'= : 'ky', 'lat': 'la', + 'ltz': 'lb', 'lug': 'lg', 'lim': 'li', 'lin': 'ln', 'lao'= : 'lo', 'lit': 'lt', + 'lub': 'lu', 'lav': 'lv', 'mlg': 'mg', 'mah': 'mh', 'mri'= : 'mi', 'mkd': 'mk', + 'mal': 'ml', 'mon': 'mn', 'mar': 'mr', 'msa': 'ms', 'mlt'= : 'mt', 'mya': 'my', + 'nau': 'na', 'nob': 'nb', 'nde': 'nd', 'nep': 'ne', 'ndo'= : 'ng', 'nld': 'nl', + 'nno': 'nn', 'nor': 'no', 'nbl': 'nr', 'nav': 'nv', 'nya'= : 'ny', 'oci': 'oc', + 'oji': 'oj', 'orm': 'om', 'ori': 'or', 'oss': 'os', 'pan'= : 'pa', 'pli': 'pi', + 'pol': 'pl', 'pus': 'ps', 'por': 'pt', 'que': 'qu', 'roh'= : 'rm', 'run': 'rn', + 'ron': 'ro', 'rus': 'ru', 'kin': 'rw', 'san': 'sa', 'srd'= : 'sc', 'snd': 'sd', + 'sme': 'se', 'sag': 'sg', 'sin': 'si', 'slk': 'sk', 'slv'= : 'sl', 'smo': 'sm', + 'sna': 'sn', 'som': 'so', 'sqi': 'sq', 'srp': 'sr', 'ssw'= : 'ss', 'sot': 'st', + 'sun': 'su', 'swe': 'sv', 'swa': 'sw', 'tam': 'ta', 'tel'= : 'te', 'tgk': 'tg', + 'tha': 'th', 'tir': 'ti', 'tuk': 'tk', 'tgl': 'tl', 'tsn'= : 'tn', 'ton': 'to', + 'tur': 'tr', 'tso': 'ts', 'tat': 'tt', 'twi': 'tw', 'tah'= : 'ty', 'uig': 'ug', + 'ukr': 'uk', 'urd': 'ur', 'uzb': 'uz', 'ven': 've', 'vie'= : 'vi', 'vol': 'vo', + 'wln': 'wa', 'wol': 'wo', 'xho': 'xh', 'yid': 'yi', 'yor'= : 'yo', 'zha': 'za', + 'zho': 'zh', 'zul': 'zu'} + +# GetLanguageCode # # Check the language code read from .UNI file and convert ISO 639-2 codes = to RFC 4646 codes if appropriate # ISO 639-2 language codes supported in compatibility mode @@ -100,6 +106,8 @@ LangConvTable =3D {'eng':'en', 'fra':'fr', \ # # @retval LangName: Valid language code in RFC 4646 format or None # + + def GetLanguageCode(LangName, IsCompatibleMode, File): length =3D len(LangName) if IsCompatibleMode: @@ -109,7 +117,8 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): return TempLangName return LangName else: - EdkLogger.error("Unicode File Parser", FORMAT_INVALID, "Invali= d ISO 639-2 language code : %s" % LangName, File) + EdkLogger.error("Unicode File Parser", FORMAT_INVALID, + "Invalid ISO 639-2 language code : %s" % LangN= ame, File) =20 if (LangName[0] =3D=3D 'X' or LangName[0] =3D=3D 'x') and LangName[1] = =3D=3D '-': return LangName @@ -128,14 +137,17 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): if LangName[0:3].isalpha() and LangConvTable.get(LangName.lower())= is None and LangName[3] =3D=3D '-': return LangName =20 - EdkLogger.error("Unicode File Parser", FORMAT_INVALID, "Invalid RFC 46= 46 language code : %s" % LangName, File) + EdkLogger.error("Unicode File Parser", FORMAT_INVALID, + "Invalid RFC 4646 language code : %s" % LangName, File) =20 -## Ucs2Codec +# Ucs2Codec # # This is only a partial codec implementation. It only supports # encoding, and is primarily used to check that all the characters are # valid for UCS-2. # + + class Ucs2Codec(codecs.Codec): def __init__(self): self.__utf16 =3D codecs.lookup('utf-16') @@ -150,7 +162,10 @@ class Ucs2Codec(codecs.Codec): raise ValueError("Code Point too large to encode in UCS-2") return self.__utf16.encode(input) =20 + TheUcs2Codec =3D Ucs2Codec() + + def Ucs2Search(name): if name in ['ucs-2', 'ucs_2']: return codecs.CodecInfo( @@ -159,14 +174,18 @@ def Ucs2Search(name): decode=3DTheUcs2Codec.decode) else: return None + + codecs.register(Ucs2Search) =20 -## StringDefClassObject +# StringDefClassObject # # A structure for language definition # + + class StringDefClassObject(object): - def __init__(self, Name =3D None, Value =3D None, Referenced =3D False= , Token =3D None, UseOtherLangDef =3D ''): + def __init__(self, Name=3DNone, Value=3DNone, Referenced=3DFalse, Toke= n=3DNone, UseOtherLangDef=3D''): self.StringName =3D '' self.StringNameByteList =3D [] self.StringValue =3D '' @@ -188,42 +207,48 @@ class StringDefClassObject(object): =20 def __str__(self): return repr(self.StringName) + ' ' + \ - repr(self.Token) + ' ' + \ - repr(self.Referenced) + ' ' + \ - repr(self.StringValue) + ' ' + \ - repr(self.UseOtherLangDef) + repr(self.Token) + ' ' + \ + repr(self.Referenced) + ' ' + \ + repr(self.StringValue) + ' ' + \ + repr(self.UseOtherLangDef) =20 - def UpdateValue(self, Value =3D None): + def UpdateValue(self, Value=3DNone): if Value is not None: self.StringValue =3D Value + u'\x00' # Add a NULL at st= ring tail self.StringValueByteList =3D UniToHexList(self.StringValue) self.Length =3D len(self.StringValueByteList) =20 + def StripComments(Line): Comment =3D u'//' CommentPos =3D Line.find(Comment) while CommentPos >=3D 0: - # if there are non matched quotes before the comment header - # then we are in the middle of a string - # but we need to ignore the escaped quotes and backslashes. + # if there are non matched quotes before the comment header + # then we are in the middle of a string + # but we need to ignore the escaped quotes and backslashes. if ((Line.count(u'"', 0, CommentPos) - Line.count(u'\\"', 0, Comme= ntPos)) & 1) =3D=3D 1: - CommentPos =3D Line.find (Comment, CommentPos + 1) + CommentPos =3D Line.find(Comment, CommentPos + 1) else: return Line[:CommentPos].strip() return Line.strip() =20 -## UniFileClassObject +# UniFileClassObject # # A structure for .uni file definition # + + class UniFileClassObject(object): - def __init__(self, FileList =3D [], IsCompatibleMode =3D False, Includ= ePathList =3D []): + def __init__(self, FileList=3D[], IsCompatibleMode=3DFalse, IncludePat= hList=3D[]): self.FileList =3D FileList self.Token =3D 2 - self.LanguageDef =3D [] #[ [u'LanguageIdentifier= ', u'PrintableName'], ... ] - self.OrderedStringList =3D {} #{ u'LanguageIdentifier'= : [StringDefClassObject] } - self.OrderedStringDict =3D {} #{ u'LanguageIdentifier'= : {StringName:(IndexInList)} } - self.OrderedStringListByToken =3D {} #{ u'LanguageIdentifier'= : {Token: StringDefClassObject} } + self.LanguageDef =3D [] # [ [u'LanguageIdentifier', u'PrintableNa= me'], ... ] + # { u'LanguageIdentifier' : [StringDefClassObject] } + self.OrderedStringList =3D {} + # { u'LanguageIdentifier' : {StringName:(IndexInList)} } + self.OrderedStringDict =3D {} + # { u'LanguageIdentifier' : {Token: StringDefClassObject} } + self.OrderedStringListByToken =3D {} self.IsCompatibleMode =3D IsCompatibleMode self.IncludePathList =3D IncludePathList if len(self.FileList) > 0: @@ -236,23 +261,26 @@ class UniFileClassObject(object): Lang =3D shlex.split(Line.split(u"//")[0]) if len(Lang) !=3D 3: try: - FileIn =3D UniFileClassObject.OpenUniFile(LongFilePath(Fil= e.Path)) + FileIn =3D UniFileClassObject.OpenUniFile( + LongFilePath(File.Path)) except UnicodeError as X: - EdkLogger.error("build", FILE_READ_FAILURE, "File read fai= lure: %s" % str(X), ExtraData=3DFile); + EdkLogger.error("build", FILE_READ_FAILURE, + "File read failure: %s" % str(X), ExtraDat= a=3DFile) except: - EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFi= le); + EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFi= le) LineNo =3D GetLineNo(FileIn, Line, False) EdkLogger.error("Unicode File Parser", PARSER_ERROR, "Wrong la= nguage definition", ExtraData=3D"""%s\n\t*Correct format is like '= #langdef en-US "English"'""" % Line, File=3DFile, Line=3DLineNo) else: - LangName =3D GetLanguageCode(Lang[1], self.IsCompatibleMode, s= elf.File) + LangName =3D GetLanguageCode( + Lang[1], self.IsCompatibleMode, self.File) LangPrintName =3D Lang[2] =20 IsLangInDef =3D False for Item in self.LanguageDef: if Item[0] =3D=3D LangName: IsLangInDef =3D True - break; + break =20 if not IsLangInDef: self.LanguageDef.append([LangName, LangPrintName]) @@ -260,8 +288,10 @@ class UniFileClassObject(object): # # Add language string # - self.AddStringToList(u'$LANGUAGE_NAME', LangName, LangName, 0, Tru= e, Index=3D0) - self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', LangName, LangPr= intName, 1, True, Index=3D1) + self.AddStringToList(u'$LANGUAGE_NAME', LangName, + LangName, 0, True, Index=3D0) + self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', + LangName, LangPrintName, 1, True, Index=3D1) =20 if not IsLangInDef: # @@ -270,14 +300,16 @@ class UniFileClassObject(object): # FirstLangName =3D self.LanguageDef[0][0] if LangName !=3D FirstLangName: - for Index in range (2, len (self.OrderedStringList[FirstLa= ngName])): + for Index in range(2, len(self.OrderedStringList[FirstLang= Name])): Item =3D self.OrderedStringList[FirstLangName][Index] if Item.UseOtherLangDef !=3D '': OtherLang =3D Item.UseOtherLangDef else: OtherLang =3D FirstLangName - self.OrderedStringList[LangName].append (StringDefClas= sObject(Item.StringName, '', Item.Referenced, Item.Token, OtherLang)) - self.OrderedStringDict[LangName][Item.StringName] =3D = len(self.OrderedStringList[LangName]) - 1 + self.OrderedStringList[LangName].append(StringDefClass= Object( + Item.StringName, '', Item.Referenced, Item.Token, = OtherLang)) + self.OrderedStringDict[LangName][Item.StringName] =3D = len( + self.OrderedStringList[LangName]) - 1 return True =20 @staticmethod @@ -297,7 +329,7 @@ class UniFileClassObject(object): # Encoding =3D 'utf-8' if (FileIn.startswith(codecs.BOM_UTF16_BE) or - FileIn.startswith(codecs.BOM_UTF16_LE)): + FileIn.startswith(codecs.BOM_UTF16_LE)): Encoding =3D 'utf-16' =20 UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding) @@ -322,9 +354,10 @@ class UniFileClassObject(object): (Reader, Writer) =3D (Info.streamreader, Info.streamwriter) File =3D codecs.StreamReaderWriter(UniFile, Reader, Writer) LineNumber =3D 0 - ErrMsg =3D lambda Encoding, LineNumber: \ - '%s contains invalid %s characters on line %d.' % \ - (FileName, Encoding, LineNumber) + + def ErrMsg(Encoding, LineNumber): return \ + '%s contains invalid %s characters on line %d.' % \ + (FileName, Encoding, LineNumber) while True: LineNumber =3D LineNumber + 1 try: @@ -349,22 +382,26 @@ class UniFileClassObject(object): if Name !=3D '': MatchString =3D gIdentifierPattern.match(Name) if MatchString is None: - EdkLogger.error('Unicode File Parser', FORMAT_INVALID, 'Th= e string token name %s defined in UNI file %s contains the invalid characte= r.' % (Name, self.File)) + EdkLogger.error('Unicode File Parser', FORMAT_INVALID, + 'The string token name %s defined in UNI f= ile %s contains the invalid character.' % (Name, self.File)) LanguageList =3D Item.split(u'#language ') for IndexI in range(len(LanguageList)): if IndexI =3D=3D 0: continue else: Language =3D LanguageList[IndexI].split()[0] - Value =3D LanguageList[IndexI][LanguageList[IndexI].find(u= '\"') + len(u'\"') : LanguageList[IndexI].rfind(u'\"')] #.replace(u'\r\n', = u'') - Language =3D GetLanguageCode(Language, self.IsCompatibleMo= de, self.File) + Value =3D LanguageList[IndexI][LanguageList[IndexI].find( + u'\"') + len(u'\"'): LanguageList[IndexI].rfind(u'\"')= ] # .replace(u'\r\n', u'') + Language =3D GetLanguageCode( + Language, self.IsCompatibleMode, self.File) self.AddStringToList(Name, Language, Value) =20 # # Get include file list and load them # def GetIncludeFile(self, Item, Dir): - FileName =3D Item[Item.find(u'#include ') + len(u'#include ') :Ite= m.find(u' ', len(u'#include '))][1:-1] + FileName =3D Item[Item.find( + u'#include ') + len(u'#include '):Item.find(u' ', len(u'#inclu= de '))][1:-1] self.LoadUniFile(FileName) =20 # @@ -374,11 +411,13 @@ class UniFileClassObject(object): try: FileIn =3D UniFileClassObject.OpenUniFile(LongFilePath(File.Pa= th)) except UnicodeError as X: - EdkLogger.error("build", FILE_READ_FAILURE, "File read failure= : %s" % str(X), ExtraData=3DFile.Path); + EdkLogger.error("build", FILE_READ_FAILURE, + "File read failure: %s" % str(X), ExtraData=3D= File.Path) except OSError: - EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, ExtraDa= ta=3DFile.Path) + EdkLogger.error("Unicode File Parser", + FILE_NOT_FOUND, ExtraData=3DFile.Path) except: - EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFile.P= ath); + EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DFile.P= ath) =20 Lines =3D [] # @@ -395,7 +434,6 @@ class UniFileClassObject(object): if len(Line) =3D=3D 0: continue =20 - Line =3D Line.replace(u'/langdef', u'#langdef') Line =3D Line.replace(u'/string', u'#string') Line =3D Line.replace(u'/language', u'#language') @@ -417,15 +455,15 @@ class UniFileClassObject(object): StartPos =3D Line.find(u'\\x') while (StartPos !=3D -1): EndPos =3D Line.find(u'\\', StartPos + 1, StartPos + 7) - if EndPos !=3D -1 and EndPos - StartPos =3D=3D 6 : - if g4HexChar.match(Line[StartPos + 2 : EndPos], re.UNI= CODE): - EndStr =3D Line[EndPos: ] + if EndPos !=3D -1 and EndPos - StartPos =3D=3D 6: + if g4HexChar.match(Line[StartPos + 2: EndPos], re.UNIC= ODE): + EndStr =3D Line[EndPos:] UniStr =3D Line[StartPos + 2: EndPos] if EndStr.startswith(u'\\x') and len(EndStr) >=3D = 7: - if EndStr[6] =3D=3D u'\\' and g4HexChar.match(= EndStr[2 : 6], re.UNICODE): - Line =3D Line[0 : StartPos] + UniStr + End= Str + if EndStr[6] =3D=3D u'\\' and g4HexChar.match(= EndStr[2: 6], re.UNICODE): + Line =3D Line[0: StartPos] + UniStr + EndS= tr else: - Line =3D Line[0 : StartPos] + UniStr + EndStr[= 1:] + Line =3D Line[0: StartPos] + UniStr + EndStr[1= :] StartPos =3D Line.find(u'\\x', StartPos + 1) =20 IncList =3D gIncludePattern.findall(Line) @@ -436,7 +474,8 @@ class UniFileClassObject(object): Lines.extend(self.PreProcess(IncFile)) break else: - EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND,= Message=3D"Cannot find include file", ExtraData=3Dstr(IncList[0])) + EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, + Message=3D"Cannot find include file", = ExtraData=3Dstr(IncList[0])) continue =20 Lines.append(Line) @@ -446,9 +485,10 @@ class UniFileClassObject(object): # # Load a .uni file # - def LoadUniFile(self, File =3D None): + def LoadUniFile(self, File=3DNone): if File is None: - EdkLogger.error("Unicode File Parser", PARSER_ERROR, 'No unico= de file is given') + EdkLogger.error("Unicode File Parser", PARSER_ERROR, + 'No unicode file is given') self.File =3D File # # Process special char in file @@ -488,10 +528,12 @@ class UniFileClassObject(object): # Mi segunda secuencia 2 # if Line.find(u'#string ') >=3D 0 and Line.find(u'#language ') = < 0 and \ - SecondLine.find(u'#string ') < 0 and SecondLine.find(u'#la= nguage ') >=3D 0 and \ - ThirdLine.find(u'#string ') < 0 and ThirdLine.find(u'#lang= uage ') < 0: - Name =3D Line[Line.find(u'#string ') + len(u'#string ') : = ].strip(' ') - Language =3D SecondLine[SecondLine.find(u'#language ') + l= en(u'#language ') : ].strip(' ') + SecondLine.find(u'#string ') < 0 and SecondLine.find(u= '#language ') >=3D 0 and \ + ThirdLine.find(u'#string ') < 0 and ThirdLine.find(u'#= language ') < 0: + Name =3D Line[Line.find(u'#string ') + + len(u'#string '):].strip(' ') + Language =3D SecondLine[SecondLine.find( + u'#language ') + len(u'#language '):].strip(' ') for IndexJ in range(IndexI + 2, len(Lines)): if Lines[IndexJ].find(u'#string ') < 0 and Lines[Index= J].find(u'#language ') < 0: Value =3D Value + Lines[IndexJ] @@ -499,12 +541,14 @@ class UniFileClassObject(object): IndexI =3D IndexJ break # Value =3D Value.replace(u'\r\n', u'') - Language =3D GetLanguageCode(Language, self.IsCompatibleMo= de, self.File) + Language =3D GetLanguageCode( + Language, self.IsCompatibleMode, self.File) # Check the string name if not self.IsCompatibleMode and Name !=3D '': MatchString =3D gIdentifierPattern.match(Name) if MatchString is None: - EdkLogger.error('Unicode File Parser', FORMAT_INVA= LID, 'The string token name %s defined in UNI file %s contains the invalid = character.' % (Name, self.File)) + EdkLogger.error('Unicode File Parser', FORMAT_INVA= LID, + 'The string token name %s defined = in UNI file %s contains the invalid character.' % (Name, self.File)) self.AddStringToList(Name, Language, Value) continue =20 @@ -529,7 +573,8 @@ class UniFileClassObject(object): elif Lines[IndexJ].find(u'#string ') < 0 and Lines[Ind= exJ].find(u'#language ') >=3D 0: StringItem =3D StringItem + Lines[IndexJ] elif Lines[IndexJ].count(u'\"') >=3D 2: - StringItem =3D StringItem[ : StringItem.rfind(u'\"= ')] + Lines[IndexJ][Lines[IndexJ].find(u'\"') + len(u'\"') : ] + StringItem =3D StringItem[: StringItem.rfind( + u'\"')] + Lines[IndexJ][Lines[IndexJ].find(u'\= "') + len(u'\"'):] self.GetStringObject(StringItem) continue =20 @@ -544,12 +589,12 @@ class UniFileClassObject(object): # # Add a string to list # - def AddStringToList(self, Name, Language, Value, Token =3D None, Refer= enced =3D False, UseOtherLangDef =3D '', Index =3D -1): + def AddStringToList(self, Name, Language, Value, Token=3DNone, Referen= ced=3DFalse, UseOtherLangDef=3D'', Index=3D-1): for LangNameItem in self.LanguageDef: if Language =3D=3D LangNameItem[0]: break else: - EdkLogger.error('Unicode File Parser', FORMAT_NOT_SUPPORTED, "= The language '%s' for %s is not defined in Unicode file %s." \ + EdkLogger.error('Unicode File Parser', FORMAT_NOT_SUPPORTED, "= The language '%s' for %s is not defined in Unicode file %s." % (Language, Name, self.File)) =20 if Language not in self.OrderedStringList: @@ -568,7 +613,8 @@ class UniFileClassObject(object): if IsAdded: Token =3D len(self.OrderedStringList[Language]) if Index =3D=3D -1: - self.OrderedStringList[Language].append(StringDefClassObje= ct(Name, Value, Referenced, Token, UseOtherLangDef)) + self.OrderedStringList[Language].append(StringDefClassObje= ct( + Name, Value, Referenced, Token, UseOtherLangDef)) self.OrderedStringDict[Language][Name] =3D Token for LangName in self.LanguageDef: # @@ -580,10 +626,13 @@ class UniFileClassObject(object): OtherLangDef =3D UseOtherLangDef else: OtherLangDef =3D Language - self.OrderedStringList[LangName[0]].append(StringD= efClassObject(Name, '', Referenced, Token, OtherLangDef)) - self.OrderedStringDict[LangName[0]][Name] =3D len(= self.OrderedStringList[LangName[0]]) - 1 + self.OrderedStringList[LangName[0]].append( + StringDefClassObject(Name, '', Referenced, Tok= en, OtherLangDef)) + self.OrderedStringDict[LangName[0]][Name] =3D len( + self.OrderedStringList[LangName[0]]) - 1 else: - self.OrderedStringList[Language].insert(Index, StringDefCl= assObject(Name, Value, Referenced, Token, UseOtherLangDef)) + self.OrderedStringList[Language].insert(Index, StringDefCl= assObject( + Name, Value, Referenced, Token, UseOtherLangDef)) self.OrderedStringDict[Language][Name] =3D Index =20 # @@ -637,7 +686,7 @@ class UniFileClassObject(object): # Use small token for all referred string stoken. # RefToken =3D 0 - for Index in range (0, len (self.OrderedStringList[FirstLangName])= ): + for Index in range(0, len(self.OrderedStringList[FirstLangName])): FirstLangItem =3D self.OrderedStringList[FirstLangName][Index] if FirstLangItem.Referenced =3D=3D True: for LangNameItem in self.LanguageDef: @@ -652,7 +701,7 @@ class UniFileClassObject(object): # Use big token for all unreferred string stoken. # UnRefToken =3D 0 - for Index in range (0, len (self.OrderedStringList[FirstLangName])= ): + for Index in range(0, len(self.OrderedStringList[FirstLangName])): FirstLangItem =3D self.OrderedStringList[FirstLangName][Index] if FirstLangItem.Referenced =3D=3D False: for LangNameItem in self.LanguageDef: @@ -667,17 +716,19 @@ class UniFileClassObject(object): # def ShowMe(self): print(self.LanguageDef) - #print self.OrderedStringList + # print self.OrderedStringList for Item in self.OrderedStringList: print(Item) for Member in self.OrderedStringList[Item]: print(str(Member)) =20 + # This acts like the main() function for the script, unless it is 'import'= ed into another # script. if __name__ =3D=3D '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.DEBUG_0) - a =3D UniFileClassObject([PathClass("C:\\Edk\\Strings.uni"), PathClass= ("C:\\Edk\\Strings2.uni")]) + a =3D UniFileClassObject( + [PathClass("C:\\Edk\\Strings.uni"), PathClass("C:\\Edk\\Strings2.u= ni")]) a.ReToken() a.ShowMe() diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/B= aseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py index ad8c9b598025..36907e983b60 100644 --- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py +++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py @@ -15,6 +15,7 @@ from io import BytesIO from struct import pack from Common.DataType import * =20 + class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): def __init__(self): self.var_check_info =3D [] @@ -56,7 +57,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): else: realLength +=3D item.StorageWidth realLength +=3D item.StorageWidth - if (index =3D=3D len(self.var_check_info)) : + if (index =3D=3D len(self.var_check_info)): if (itemIndex < len(var_check_tab.validtab)) and realL= ength % 4: realLength +=3D (4 - (realLength % 4)) else: @@ -136,14 +137,16 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): Buffer +=3D b realLength +=3D item.StorageWidth else: - b =3D pack(PACK_CODE_BY_SIZE[item.StorageWidth], v= _data[0]) + b =3D pack( + PACK_CODE_BY_SIZE[item.StorageWidth], v_data[0= ]) Buffer +=3D b realLength +=3D item.StorageWidth - b =3D pack(PACK_CODE_BY_SIZE[item.StorageWidth], v= _data[1]) + b =3D pack( + PACK_CODE_BY_SIZE[item.StorageWidth], v_data[1= ]) Buffer +=3D b realLength +=3D item.StorageWidth =20 - if (index =3D=3D len(self.var_check_info)) : + if (index =3D=3D len(self.var_check_info)): if (itemIndex < len(var_check_tab.validtab)) and realL= ength % 4: for i in range(4 - (realLength % 4)): b =3D pack("=3DB", var_check_tab.pad) @@ -173,6 +176,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): =20 class VAR_CHECK_PCD_VARIABLE_TAB(object): pad =3D 0xDA + def __init__(self, TokenSpaceGuid, PcdCName): self.Revision =3D 0x0001 self.HeaderLength =3D 0 @@ -180,7 +184,8 @@ class VAR_CHECK_PCD_VARIABLE_TAB(object): self.Type =3D 0 self.Reserved =3D 0 self.Attributes =3D 0x00000000 - self.Guid =3D eval("[" + TokenSpaceGuid.replace("{", "").replace("= }", "") + "]") + self.Guid =3D eval( + "[" + TokenSpaceGuid.replace("{", "").replace("}", "") + "]") self.Name =3D PcdCName self.validtab =3D [] =20 @@ -233,9 +238,11 @@ class VAR_CHECK_PCD_VALID_OBJ(object): def __eq__(self, validObj): return validObj and self.VarOffset =3D=3D validObj.VarOffset =20 + class VAR_CHECK_PCD_VALID_LIST(VAR_CHECK_PCD_VALID_OBJ): def __init__(self, VarOffset, validlist, PcdDataType): - super(VAR_CHECK_PCD_VALID_LIST, self).__init__(VarOffset, validlis= t, PcdDataType) + super(VAR_CHECK_PCD_VALID_LIST, self).__init__( + VarOffset, validlist, PcdDataType) self.Type =3D 1 valid_num_list =3D [] for item in self.rawdata: @@ -249,13 +256,13 @@ class VAR_CHECK_PCD_VALID_LIST(VAR_CHECK_PCD_VALID_OB= J): else: self.data.add(int(valid_num)) =20 - self.Length =3D 5 + len(self.data) * self.StorageWidth =20 =20 class VAR_CHECK_PCD_VALID_RANGE(VAR_CHECK_PCD_VALID_OBJ): def __init__(self, VarOffset, validrange, PcdDataType): - super(VAR_CHECK_PCD_VALID_RANGE, self).__init__(VarOffset, validra= nge, PcdDataType) + super(VAR_CHECK_PCD_VALID_RANGE, self).__init__( + VarOffset, validrange, PcdDataType) self.Type =3D 2 RangeExpr =3D "" i =3D 0 diff --git a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py b/BaseTool= s/Source/Python/AutoGen/WorkspaceAutoGen.py index f86c749c08c3..1f10e03c268f 100644 --- a/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/WorkspaceAutoGen.py @@ -1,11 +1,11 @@ -## @file +# @file # Create makefile for MS nmake and GNU make # # Copyright (c) 2019, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # from __future__ import print_function from __future__ import absolute_import @@ -25,25 +25,28 @@ from Common.DataType import * from Common.Misc import * import json =20 -## Regular expression for splitting Dependency Expression string into toke= ns +# Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern =3D re.compile("(\(|\)|\w+| \S+\.inf)") =20 -## Regular expression for match: PCD(xxxx.yyy) +# Regular expression for match: PCD(xxxx.yyy) gPCDAsGuidPattern =3D re.compile(r"^PCD\(.+\..+\)$") =20 -## Workspace AutoGen class +# Workspace AutoGen class # # This class is used mainly to control the whole platform build for diff= erent # architecture. This class will generate top level makefile. # + + class WorkspaceAutoGen(AutoGen): # call super().__init__ then call the worker function with different p= arameter count def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args= , **kwargs): if not hasattr(self, "_Init"): - self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch,= *args, **kwargs) + self._InitWorker(Workspace, MetaFile, Target, + Toolchain, Arch, *args, **kwargs) self._Init =3D True =20 - ## Initialize WorkspaceAutoGen + # Initialize WorkspaceAutoGen # # @param WorkspaceDir Root directory of workspace # @param ActivePlatform Meta-file of active platform @@ -60,25 +63,26 @@ class WorkspaceAutoGen(AutoGen): # @param SkuId SKU id from command line # def _InitWorker(self, WorkspaceDir, ActivePlatform, Target, Toolchain,= ArchList, MetaFileDb, - BuildConfig, ToolDefinition, FlashDefinitionFile=3D'', Fds= =3DNone, Fvs=3DNone, Caps=3DNone, SkuId=3D'', UniFlag=3DNone, - Progress=3DNone, BuildModule=3DNone): - self.BuildDatabase =3D MetaFileDb - self.MetaFile =3D ActivePlatform - self.WorkspaceDir =3D WorkspaceDir - self.Platform =3D self.BuildDatabase[self.MetaFile, TAB_ARCH= _COMMON, Target, Toolchain] + BuildConfig, ToolDefinition, FlashDefinitionFile=3D'',= Fds=3DNone, Fvs=3DNone, Caps=3DNone, SkuId=3D'', UniFlag=3DNone, + Progress=3DNone, BuildModule=3DNone): + self.BuildDatabase =3D MetaFileDb + self.MetaFile =3D ActivePlatform + self.WorkspaceDir =3D WorkspaceDir + self.Platform =3D self.BuildDatabase[self.MetaFile, + TAB_ARCH_COMMON, Target, Toolch= ain] GlobalData.gActivePlatform =3D self.Platform - self.BuildTarget =3D Target - self.ToolChain =3D Toolchain - self.ArchList =3D ArchList - self.SkuId =3D SkuId - self.UniFlag =3D UniFlag + self.BuildTarget =3D Target + self.ToolChain =3D Toolchain + self.ArchList =3D ArchList + self.SkuId =3D SkuId + self.UniFlag =3D UniFlag =20 - self.TargetTxt =3D BuildConfig - self.ToolDef =3D ToolDefinition - self.FdfFile =3D FlashDefinitionFile - self.FdTargetList =3D Fds if Fds else [] - self.FvTargetList =3D Fvs if Fvs else [] - self.CapTargetList =3D Caps if Caps else [] + self.TargetTxt =3D BuildConfig + self.ToolDef =3D ToolDefinition + self.FdfFile =3D FlashDefinitionFile + self.FdTargetList =3D Fds if Fds else [] + self.FvTargetList =3D Fvs if Fvs else [] + self.CapTargetList =3D Caps if Caps else [] self.AutoGenObjectList =3D [] self._GuidDict =3D {} =20 @@ -90,7 +94,8 @@ class WorkspaceAutoGen(AutoGen): =20 EdkLogger.info("") if self.ArchList: - EdkLogger.info('%-16s =3D %s' % ("Architecture(s)", ' '.join(s= elf.ArchList))) + EdkLogger.info('%-16s =3D %s' % + ("Architecture(s)", ' '.join(self.ArchList))) EdkLogger.info('%-16s =3D %s' % ("Build target", self.BuildTarget)) EdkLogger.info('%-16s =3D %s' % ("Toolchain", self.ToolChain)) =20 @@ -99,7 +104,8 @@ class WorkspaceAutoGen(AutoGen): EdkLogger.info('%-24s =3D %s' % ("Active Module", BuildModule)) =20 if self.FdfFile: - EdkLogger.info('%-24s =3D %s' % ("Flash Image Definition", sel= f.FdfFile)) + EdkLogger.info('%-24s =3D %s' % + ("Flash Image Definition", self.FdfFile)) =20 EdkLogger.verbose("\nFLASH_DEFINITION =3D %s" % self.FdfFile) =20 @@ -144,9 +150,10 @@ class WorkspaceAutoGen(AutoGen): ArchList =3D set(self.ArchList) & set(self.Platform.SupArchLis= t) if not ArchList: EdkLogger.error("build", PARAMETER_INVALID, - ExtraData =3D "Invalid ARCH specified. [Valid = ARCH: %s]" % (" ".join(self.Platform.SupArchList))) + ExtraData=3D"Invalid ARCH specified. [Valid AR= CH: %s]" % (" ".join(self.Platform.SupArchList))) elif self.ArchList and len(ArchList) !=3D len(self.ArchList): - SkippedArchList =3D set(self.ArchList).symmetric_difference(se= t(self.Platform.SupArchList)) + SkippedArchList =3D set(self.ArchList).symmetric_difference( + set(self.Platform.SupArchList)) EdkLogger.verbose("\nArch [%s] is ignored because the platform= supports [%s] only!" % (" ".join(SkippedArchList), " ".join(self.= Platform.SupArchList))) self.ArchList =3D tuple(ArchList) @@ -163,10 +170,12 @@ class WorkspaceAutoGen(AutoGen): oriPkgSet =3D set() PlatformPkg =3D set() for Arch in self.ArchList: - Platform =3D self.BuildDatabase[self.MetaFile, Arch, self.Buil= dTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.MetaFile, + Arch, self.BuildTarget, self.Too= lChain] oriInfList =3D Platform.Modules for ModuleFile in oriInfList: - ModuleData =3D self.BuildDatabase[ModuleFile, Platform._Ar= ch, Platform._Target, Platform._Toolchain] + ModuleData =3D self.BuildDatabase[ModuleFile, + Platform._Arch, Platform._= Target, Platform._Toolchain] oriPkgSet.update(ModuleData.Packages) for Pkg in oriPkgSet: Guids =3D Pkg.Guids @@ -192,17 +201,21 @@ class WorkspaceAutoGen(AutoGen): for FdRegion in FdDict.RegionList: if str(FdRegion.RegionType) =3D=3D 'FILE' and self.Pla= tform.VpdToolGuid in str(FdRegion.RegionDataList): if int(FdRegion.Offset) % 8 !=3D 0: - EdkLogger.error("build", FORMAT_INVALID, 'The = VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset)) + EdkLogger.error( + "build", FORMAT_INVALID, 'The VPD Base Add= ress %s must be 8-byte aligned.' % (FdRegion.Offset)) FdfProfile =3D Fdf.Profile else: if self.FdTargetList: - EdkLogger.info("No flash definition file found. FD [%s] wi= ll be ignored." % " ".join(self.FdTargetList)) + EdkLogger.info("No flash definition file found. FD [%s] wi= ll be ignored." % " ".join( + self.FdTargetList)) self.FdTargetList =3D [] if self.FvTargetList: - EdkLogger.info("No flash definition file found. FV [%s] wi= ll be ignored." % " ".join(self.FvTargetList)) + EdkLogger.info("No flash definition file found. FV [%s] wi= ll be ignored." % " ".join( + self.FvTargetList)) self.FvTargetList =3D [] if self.CapTargetList: - EdkLogger.info("No flash definition file found. Capsule [%= s] will be ignored." % " ".join(self.CapTargetList)) + EdkLogger.info("No flash definition file found. Capsule [%= s] will be ignored." % " ".join( + self.CapTargetList)) self.CapTargetList =3D [] =20 return FdfProfile @@ -221,37 +234,46 @@ class WorkspaceAutoGen(AutoGen): if key =3D=3D 'ArchTBD': MetaFile_cache =3D defaultdict(set) for Arch in self.ArchList: - Current_Platform_cache =3D self.BuildDatabase[self= .MetaFile, Arch, self.BuildTarget, self.ToolChain] + Current_Platform_cache =3D self.BuildDatabase[self= .MetaFile, + Arch, = self.BuildTarget, self.ToolChain] for Pkey in Current_Platform_cache.Modules: - MetaFile_cache[Arch].add(Current_Platform_cach= e.Modules[Pkey].MetaFile) + MetaFile_cache[Arch].add( + Current_Platform_cache.Modules[Pkey].MetaF= ile) for Inf in self.FdfProfile.InfDict[key]: - ModuleFile =3D PathClass(NormPath(Inf), GlobalData= .gWorkspace, Arch) + ModuleFile =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, Arch) for Arch in self.ArchList: if ModuleFile in MetaFile_cache[Arch]: break else: - ModuleData =3D self.BuildDatabase[ModuleFile, = Arch, self.BuildTarget, self.ToolChain] + ModuleData =3D self.BuildDatabase[ModuleFile, + Arch, self.Bui= ldTarget, self.ToolChain] if not ModuleData.IsBinaryModule: - EdkLogger.error('build', PARSER_ERROR, "Mo= dule %s NOT found in DSC file; Is it really a binary module?" % ModuleFile) + EdkLogger.error( + 'build', PARSER_ERROR, "Module %s NOT = found in DSC file; Is it really a binary module?" % ModuleFile) =20 else: for Arch in self.ArchList: if Arch =3D=3D key: - Platform =3D self.BuildDatabase[self.MetaFile,= Arch, self.BuildTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.MetaFile, + Arch, self.Build= Target, self.ToolChain] MetaFileList =3D set() for Pkey in Platform.Modules: - MetaFileList.add(Platform.Modules[Pkey].Me= taFile) + MetaFileList.add( + Platform.Modules[Pkey].MetaFile) for Inf in self.FdfProfile.InfDict[key]: - ModuleFile =3D PathClass(NormPath(Inf), Gl= obalData.gWorkspace, Arch) + ModuleFile =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, = Arch) if ModuleFile in MetaFileList: continue - ModuleData =3D self.BuildDatabase[ModuleFi= le, Arch, self.BuildTarget, self.ToolChain] + ModuleData =3D self.BuildDatabase[ModuleFi= le, + Arch, self= .BuildTarget, self.ToolChain] if not ModuleData.IsBinaryModule: - EdkLogger.error('build', PARSER_ERROR,= "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleF= ile) - - + EdkLogger.error( + 'build', PARSER_ERROR, "Module %s = NOT found in DSC file; Is it really a binary module?" % ModuleFile) =20 # parse FDF file to get PCDs in it, if any + def VerifyPcdsFromFDF(self): =20 if self.FdfProfile: @@ -260,22 +282,23 @@ class WorkspaceAutoGen(AutoGen): =20 def ProcessPcdType(self): for Arch in self.ArchList: - Platform =3D self.BuildDatabase[self.MetaFile, Arch, self.Buil= dTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.MetaFile, + Arch, self.BuildTarget, self.Too= lChain] Platform.Pcds # generate the SourcePcdDict and BinaryPcdDict Libs =3D [] for BuildData in list(self.BuildDatabase._CACHE_.values()): if BuildData.Arch !=3D Arch: continue - if BuildData.MetaFile.Ext =3D=3D '.inf' and str(BuildData)= in Platform.Modules : + if BuildData.MetaFile.Ext =3D=3D '.inf' and str(BuildData)= in Platform.Modules: Libs.extend(GetModuleLibInstances(BuildData, Platform, - self.BuildDatabase, - Arch, - self.BuildTarget, - self.ToolChain, - self.Platform.MetaFile, - EdkLogger - )) + self.BuildDatabase, + Arch, + self.BuildTarget, + self.ToolChain, + self.Platform.MetaFi= le, + EdkLogger + )) for BuildData in list(self.BuildDatabase._CACHE_.values()): if BuildData.Arch !=3D Arch: continue @@ -289,21 +312,23 @@ class WorkspaceAutoGen(AutoGen): BuildData.Pcds[key].Pending =3D False =20 if BuildData.MetaFile in Platform.Modules: - PlatformModule =3D Platform.Modules[str(Bu= ildData.MetaFile)] + PlatformModule =3D Platform.Modules[str( + BuildData.MetaFile)] if key in PlatformModule.Pcds: PcdInPlatform =3D PlatformModule.Pcds[= key] if PcdInPlatform.Type: BuildData.Pcds[key].Type =3D PcdIn= Platform.Type BuildData.Pcds[key].Pending =3D Fa= lse else: - #Pcd used in Library, Pcd Type from refere= nce module if Pcd Type is Pending + # Pcd used in Library, Pcd Type from refer= ence module if Pcd Type is Pending if BuildData.Pcds[key].Pending: if bool(BuildData.LibraryClass): if BuildData in set(Libs): ReferenceModules =3D BuildData= .ReferenceModules for ReferenceModule in Referen= ceModules: if ReferenceModule.MetaFil= e in Platform.Modules: - RefPlatformModule =3D = Platform.Modules[str(ReferenceModule.MetaFile)] + RefPlatformModule =3D = Platform.Modules[str( + ReferenceModule.Me= taFile)] if key in RefPlatformM= odule.Pcds: PcdInReferenceModu= le =3D RefPlatformModule.Pcds[key] if PcdInReferenceM= odule.Type: @@ -313,8 +338,10 @@ class WorkspaceAutoGen(AutoGen): =20 def ProcessMixedPcd(self): for Arch in self.ArchList: - SourcePcdDict =3D {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHAB= LE_IN_MODULE:set(),TAB_PCDS_DYNAMIC:set(),TAB_PCDS_FIXED_AT_BUILD:set()} - BinaryPcdDict =3D {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHAB= LE_IN_MODULE:set()} + SourcePcdDict =3D {TAB_PCDS_DYNAMIC_EX: set(), TAB_PCDS_PATCHA= BLE_IN_MODULE: set( + ), TAB_PCDS_DYNAMIC: set(), TAB_PCDS_FIXED_AT_BUILD: set()} + BinaryPcdDict =3D {TAB_PCDS_DYNAMIC_EX: set( + ), TAB_PCDS_PATCHABLE_IN_MODULE: set()} SourcePcdDict_Keys =3D SourcePcdDict.keys() BinaryPcdDict_Keys =3D BinaryPcdDict.keys() =20 @@ -327,21 +354,27 @@ class WorkspaceAutoGen(AutoGen): for key in BuildData.Pcds: if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type: if BuildData.IsBinaryModule: - BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add((Bu= ildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName)) + BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add( + (BuildData.Pcds[key].TokenCName, Build= Data.Pcds[key].TokenSpaceGuidCName)) else: - SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add((Bu= ildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName)) + SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add( + (BuildData.Pcds[key].TokenCName, Build= Data.Pcds[key].TokenSpaceGuidCName)) =20 elif TAB_PCDS_PATCHABLE_IN_MODULE in BuildData.Pcd= s[key].Type: if BuildData.MetaFile.Ext =3D=3D '.inf': if BuildData.IsBinaryModule: - BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MO= DULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGu= idCName)) + BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MO= DULE].add( + (BuildData.Pcds[key].TokenCName, B= uildData.Pcds[key].TokenSpaceGuidCName)) else: - SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MO= DULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGu= idCName)) + SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MO= DULE].add( + (BuildData.Pcds[key].TokenCName, B= uildData.Pcds[key].TokenSpaceGuidCName)) =20 elif TAB_PCDS_DYNAMIC in BuildData.Pcds[key].Type: - SourcePcdDict[TAB_PCDS_DYNAMIC].add((BuildData= .Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName)) + SourcePcdDict[TAB_PCDS_DYNAMIC].add( + (BuildData.Pcds[key].TokenCName, BuildData= .Pcds[key].TokenSpaceGuidCName)) elif TAB_PCDS_FIXED_AT_BUILD in BuildData.Pcds[key= ].Type: - SourcePcdDict[TAB_PCDS_FIXED_AT_BUILD].add((Bu= ildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName)) + SourcePcdDict[TAB_PCDS_FIXED_AT_BUILD].add( + (BuildData.Pcds[key].TokenCName, BuildData= .Pcds[key].TokenSpaceGuidCName)) =20 # # A PCD can only use one type for all source modules @@ -349,13 +382,16 @@ class WorkspaceAutoGen(AutoGen): for i in SourcePcdDict_Keys: for j in SourcePcdDict_Keys: if i !=3D j: - Intersections =3D SourcePcdDict[i].intersection(So= urcePcdDict[j]) + Intersections =3D SourcePcdDict[i].intersection( + SourcePcdDict[j]) if len(Intersections) > 0: EdkLogger.error( - 'build', - FORMAT_INVALID, - "Building modules from source INFs, following = PCD use %s and %s access method. It must be corrected to use only one acces= s method." % (i, j), - ExtraData=3D'\n\t'.join(str(P[1]+'.'+P[0]) for= P in Intersections) + 'build', + FORMAT_INVALID, + "Building modules from source INFs, follow= ing PCD use %s and %s access method. It must be corrected to use only one a= ccess method." % ( + i, j), + ExtraData=3D'\n\t'.join( + str(P[1]+'.'+P[0]) for P in Intersecti= ons) ) =20 # @@ -364,7 +400,8 @@ class WorkspaceAutoGen(AutoGen): for i in BinaryPcdDict_Keys: for j in BinaryPcdDict_Keys: if i !=3D j: - Intersections =3D BinaryPcdDict[i].intersection(Bi= naryPcdDict[j]) + Intersections =3D BinaryPcdDict[i].intersection( + BinaryPcdDict[j]) for item in Intersections: NewPcd1 =3D (item[0] + '_' + i, item[1]) NewPcd2 =3D (item[0] + '_' + j, item[1]) @@ -382,7 +419,8 @@ class WorkspaceAutoGen(AutoGen): for i in SourcePcdDict_Keys: for j in BinaryPcdDict_Keys: if i !=3D j: - Intersections =3D SourcePcdDict[i].intersection(Bi= naryPcdDict[j]) + Intersections =3D SourcePcdDict[i].intersection( + BinaryPcdDict[j]) for item in Intersections: NewPcd1 =3D (item[0] + '_' + i, item[1]) NewPcd2 =3D (item[0] + '_' + j, item[1]) @@ -394,7 +432,8 @@ class WorkspaceAutoGen(AutoGen): if NewPcd2 not in GlobalData.MixedPcd[item= ]: GlobalData.MixedPcd[item].append(NewPc= d2) =20 - BuildData =3D self.BuildDatabase[self.MetaFile, Arch, self.Bui= ldTarget, self.ToolChain] + BuildData =3D self.BuildDatabase[self.MetaFile, + Arch, self.BuildTarget, self.To= olChain] for key in BuildData.Pcds: for SinglePcd in GlobalData.MixedPcd: if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key= ].TokenSpaceGuidCName) =3D=3D SinglePcd: @@ -403,7 +442,8 @@ class WorkspaceAutoGen(AutoGen): if (Pcd_Type =3D=3D BuildData.Pcds[key].Type) = or (Pcd_Type =3D=3D TAB_PCDS_DYNAMIC_EX and BuildData.Pcds[key].Type in PCD= _DYNAMIC_EX_TYPE_SET) or \ (Pcd_Type =3D=3D TAB_PCDS_DYNAMIC and Build= Data.Pcds[key].Type in PCD_DYNAMIC_TYPE_SET): Value =3D BuildData.Pcds[key] - Value.TokenCName =3D BuildData.Pcds[key].T= okenCName + '_' + Pcd_Type + Value.TokenCName =3D BuildData.Pcds[key].T= okenCName + \ + '_' + Pcd_Type if len(key) =3D=3D 2: newkey =3D (Value.TokenCName, key[1]) elif len(key) =3D=3D 3: @@ -423,7 +463,7 @@ class WorkspaceAutoGen(AutoGen): for item in GlobalData.MixedPcd[key]: PcdSet[item] =3D Value =20 - #Collect package set information from INF of FDF + # Collect package set information from INF of FDF @cached_property def PkgSet(self): if not self.FdfFile: @@ -435,23 +475,27 @@ class WorkspaceAutoGen(AutoGen): ModuleList =3D [] Pkgs =3D {} for Arch in self.ArchList: - Platform =3D self.BuildDatabase[self.MetaFile, Arch, self.Buil= dTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.MetaFile, + Arch, self.BuildTarget, self.Too= lChain] PkgSet =3D set() for mb in [self.BuildDatabase[m, Arch, self.BuildTarget, self.= ToolChain] for m in Platform.Modules]: PkgSet.update(mb.Packages) for Inf in ModuleList: - ModuleFile =3D PathClass(NormPath(Inf), GlobalData.gWorksp= ace, Arch) + ModuleFile =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, Arch) if ModuleFile in Platform.Modules: continue - ModuleData =3D self.BuildDatabase[ModuleFile, Arch, self.B= uildTarget, self.ToolChain] + ModuleData =3D self.BuildDatabase[ModuleFile, + Arch, self.BuildTarget, se= lf.ToolChain] PkgSet.update(ModuleData.Packages) PkgSet.update(Platform.Packages) Pkgs[Arch] =3D list(PkgSet) return Pkgs =20 - def VerifyPcdDeclearation(self,PcdSet): + def VerifyPcdDeclearation(self, PcdSet): for Arch in self.ArchList: - Platform =3D self.BuildDatabase[self.MetaFile, Arch, self.Buil= dTarget, self.ToolChain] + Platform =3D self.BuildDatabase[self.MetaFile, + Arch, self.BuildTarget, self.Too= lChain] Pkgs =3D self.PkgSet[Arch] DecPcds =3D set() DecPcdsKey =3D set() @@ -461,33 +505,41 @@ class WorkspaceAutoGen(AutoGen): DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2])) =20 Platform.SkuName =3D self.SkuId - for Name, Guid,Fileds in PcdSet: + for Name, Guid, Fileds in PcdSet: if (Name, Guid) not in DecPcds: EdkLogger.error( 'build', PARSER_ERROR, - "PCD (%s.%s) used in FDF is not declared in DEC fi= les." % (Guid, Name), - File =3D self.FdfProfile.PcdFileLineDict[Name, Gui= d, Fileds][0], - Line =3D self.FdfProfile.PcdFileLineDict[Name, Gui= d, Fileds][1] + "PCD (%s.%s) used in FDF is not declared in DEC fi= les." % ( + Guid, Name), + File=3Dself.FdfProfile.PcdFileLineDict[Name, + Guid, Fileds]= [0], + Line=3Dself.FdfProfile.PcdFileLineDict[Name, + Guid, Fileds]= [1] ) else: # Check whether Dynamic or DynamicEx PCD used in FDF f= ile. If used, build break and give a error message. if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey= \ - or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in D= ecPcdsKey \ - or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecPcdsK= ey: + or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) = in DecPcdsKey \ + or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecP= cdsKey: continue elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (= Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey: EdkLogger.error( - 'build', - PARSER_ERROR, - "Using Dynamic or DynamicEx type of PCD [%= s.%s] in FDF file is not allowed." % (Guid, Name), - File =3D self.FdfProfile.PcdFileLineDict[N= ame, Guid, Fileds][0], - Line =3D self.FdfProfile.PcdFileLineDict[N= ame, Guid, Fileds][1] + 'build', + PARSER_ERROR, + "Using Dynamic or DynamicEx type of PCD [%s.%s= ] in FDF file is not allowed." % ( + Guid, Name), + File=3Dself.FdfProfile.PcdFileLineDict[Name, + Guid, Fil= eds][0], + Line=3Dself.FdfProfile.PcdFileLineDict[Name, + Guid, Fil= eds][1] ) + def CollectAllPcds(self): =20 for Arch in self.ArchList: - Pa =3D PlatformAutoGen(self, self.MetaFile, self.BuildTarget, = self.ToolChain, Arch) + Pa =3D PlatformAutoGen(self, self.MetaFile, + self.BuildTarget, self.ToolChain, Arch) # # Explicitly collect platform's dynamic PCDs # @@ -496,21 +548,24 @@ class WorkspaceAutoGen(AutoGen): self.AutoGenObjectList.append(Pa) # We need to calculate the PcdTokenNumber after all Arch Pcds are = collected. for Arch in self.ArchList: - #Pcd TokenNumber - Pa =3D PlatformAutoGen(self, self.MetaFile, self.BuildTarget, = self.ToolChain, Arch) - self.UpdateModuleDataPipe(Arch, {"PCD_TNUM":Pa.PcdTokenNumber= }) + # Pcd TokenNumber + Pa =3D PlatformAutoGen(self, self.MetaFile, + self.BuildTarget, self.ToolChain, Arch) + self.UpdateModuleDataPipe(Arch, {"PCD_TNUM": Pa.PcdTokenNumbe= r}) =20 - def UpdateModuleDataPipe(self,arch, attr_dict): + def UpdateModuleDataPipe(self, arch, attr_dict): for (Target, Toolchain, Arch, MetaFile) in AutoGen.Cache(): if Arch !=3D arch: continue try: - AutoGen.Cache()[(Target, Toolchain, Arch, MetaFile)].DataP= ipe.DataContainer =3D attr_dict + AutoGen.Cache()[(Target, Toolchain, Arch, MetaFile) + ].DataPipe.DataContainer =3D attr_dict except Exception: pass # # Generate Package level hash value # + def GeneratePkgLevelHash(self): for Arch in self.ArchList: GlobalData.gPackageHash =3D {} @@ -518,7 +573,6 @@ class WorkspaceAutoGen(AutoGen): for Pkg in self.PkgSet[Arch]: self._GenPkgLevelHash(Pkg) =20 - def CreateBuildOptionsFile(self): # # Create BuildOptions Macro & PCD metafile, also add the Active Pl= atform and FDF file. @@ -536,7 +590,8 @@ class WorkspaceAutoGen(AutoGen): content +=3D 'Flash Image Definition: ' content +=3D str(self.FdfFile) content +=3D TAB_LINE_BREAK - SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), cont= ent, False) + SaveFileOnChange(os.path.join( + self.BuildDir, 'BuildOptions'), content, False) =20 def CreatePcdTokenNumberFile(self): # @@ -548,17 +603,22 @@ class WorkspaceAutoGen(AutoGen): if Pa.DynamicPcdList: for Pcd in Pa.DynamicPcdList: PcdTokenNumber +=3D TAB_LINE_BREAK - PcdTokenNumber +=3D str((Pcd.TokenCName, Pcd.TokenSpac= eGuidCName)) + PcdTokenNumber +=3D str((Pcd.TokenCName, + Pcd.TokenSpaceGuidCName)) PcdTokenNumber +=3D ' : ' - PcdTokenNumber +=3D str(Pa.PcdTokenNumber[Pcd.TokenCNa= me, Pcd.TokenSpaceGuidCName]) - SaveFileOnChange(os.path.join(self.BuildDir, 'PcdTokenNumber'), Pc= dTokenNumber, False) + PcdTokenNumber +=3D str( + Pa.PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGu= idCName]) + SaveFileOnChange(os.path.join( + self.BuildDir, 'PcdTokenNumber'), PcdTokenNumber, False) =20 def GeneratePlatformLevelHash(self): # # Get set of workspace metafiles # - AllWorkSpaceMetaFiles =3D self._GetMetaFiles(self.BuildTarget, sel= f.ToolChain) - AllWorkSpaceMetaFileList =3D sorted(AllWorkSpaceMetaFiles, key=3Dl= ambda x: str(x)) + AllWorkSpaceMetaFiles =3D self._GetMetaFiles( + self.BuildTarget, self.ToolChain) + AllWorkSpaceMetaFileList =3D sorted( + AllWorkSpaceMetaFiles, key=3Dlambda x: str(x)) # # Retrieve latest modified time of all metafiles # @@ -583,17 +643,20 @@ class WorkspaceAutoGen(AutoGen): HashDir =3D path.join(self.BuildDir, "Hash_Platform") HashFile =3D path.join(HashDir, 'Platform.hash.' + m.hexdigest= ()) SaveFileOnChange(HashFile, m.hexdigest(), False) - HashChainFile =3D path.join(HashDir, 'Platform.hashchain.' + m= .hexdigest()) + HashChainFile =3D path.join( + HashDir, 'Platform.hashchain.' + m.hexdigest()) GlobalData.gPlatformHashFile =3D HashChainFile try: with open(HashChainFile, 'w') as f: json.dump(FileList, f, indent=3D2) except: - EdkLogger.quiet("[cache warning]: fail to save hashchain f= ile:%s" % HashChainFile) + EdkLogger.quiet( + "[cache warning]: fail to save hashchain file:%s" % Ha= shChainFile) =20 if GlobalData.gBinCacheDest: # Copy platform hash files to cache destination - FileDir =3D path.join(GlobalData.gBinCacheDest, self.Outpu= tDir, self.BuildTarget + "_" + self.ToolChain, "Hash_Platform") + FileDir =3D path.join(GlobalData.gBinCacheDest, self.Outpu= tDir, + self.BuildTarget + "_" + self.ToolChai= n, "Hash_Platform") CacheFileDir =3D FileDir CreateDirectory(CacheFileDir) CopyFileOnChange(HashFile, CacheFileDir) @@ -603,7 +666,7 @@ class WorkspaceAutoGen(AutoGen): # Write metafile list to build directory # AutoGenFilePath =3D os.path.join(self.BuildDir, 'AutoGen') - if os.path.exists (AutoGenFilePath): + if os.path.exists(AutoGenFilePath): os.remove(AutoGenFilePath) if not os.path.exists(self.BuildDir): os.makedirs(self.BuildDir) @@ -616,7 +679,8 @@ class WorkspaceAutoGen(AutoGen): if Pkg.PackageName in GlobalData.gPackageHash: return =20 - PkgDir =3D os.path.join(self.BuildDir, Pkg.Arch, "Hash_Pkg", Pkg.P= ackageName) + PkgDir =3D os.path.join(self.BuildDir, Pkg.Arch, + "Hash_Pkg", Pkg.PackageName) CreateDirectory(PkgDir) FileList =3D [] m =3D hashlib.md5() @@ -625,7 +689,8 @@ class WorkspaceAutoGen(AutoGen): Content =3D f.read() f.close() m.update(Content) - FileList.append((str(Pkg.MetaFile.Path), hashlib.md5(Content).hexd= igest())) + FileList.append( + (str(Pkg.MetaFile.Path), hashlib.md5(Content).hexdigest())) # Get include files hash value if Pkg.Includes: for inc in sorted(Pkg.Includes, key=3Dlambda x: str(x)): @@ -636,23 +701,29 @@ class WorkspaceAutoGen(AutoGen): Content =3D f.read() f.close() m.update(Content) - FileList.append((str(File_Path), hashlib.md5(Conte= nt).hexdigest())) + FileList.append( + (str(File_Path), hashlib.md5(Content).hexdiges= t())) GlobalData.gPackageHash[Pkg.PackageName] =3D m.hexdigest() =20 HashDir =3D PkgDir - HashFile =3D path.join(HashDir, Pkg.PackageName + '.hash.' + m.hex= digest()) + HashFile =3D path.join(HashDir, Pkg.PackageName + + '.hash.' + m.hexdigest()) SaveFileOnChange(HashFile, m.hexdigest(), False) - HashChainFile =3D path.join(HashDir, Pkg.PackageName + '.hashchain= .' + m.hexdigest()) - GlobalData.gPackageHashFile[(Pkg.PackageName, Pkg.Arch)] =3D HashC= hainFile + HashChainFile =3D path.join( + HashDir, Pkg.PackageName + '.hashchain.' + m.hexdigest()) + GlobalData.gPackageHashFile[( + Pkg.PackageName, Pkg.Arch)] =3D HashChainFile try: with open(HashChainFile, 'w') as f: json.dump(FileList, f, indent=3D2) except: - EdkLogger.quiet("[cache warning]: fail to save hashchain file:= %s" % HashChainFile) + EdkLogger.quiet( + "[cache warning]: fail to save hashchain file:%s" % HashCh= ainFile) =20 if GlobalData.gBinCacheDest: # Copy Pkg hash files to cache destination dir - FileDir =3D path.join(GlobalData.gBinCacheDest, self.OutputDir= , self.BuildTarget + "_" + self.ToolChain, Pkg.Arch, "Hash_Pkg", Pkg.Packag= eName) + FileDir =3D path.join(GlobalData.gBinCacheDest, self.OutputDir= , self.BuildTarget + + "_" + self.ToolChain, Pkg.Arch, "Hash_Pkg"= , Pkg.PackageName) CacheFileDir =3D FileDir CreateDirectory(CacheFileDir) CopyFileOnChange(HashFile, CacheFileDir) @@ -664,9 +735,9 @@ class WorkspaceAutoGen(AutoGen): # add fdf # if self.FdfFile: - AllWorkSpaceMetaFiles.add (self.FdfFile.Path) + AllWorkSpaceMetaFiles.add(self.FdfFile.Path) for f in GlobalData.gFdfParser.GetAllIncludedFile(): - AllWorkSpaceMetaFiles.add (f.FileName) + AllWorkSpaceMetaFiles.add(f.FileName) # # add dsc # @@ -675,8 +746,10 @@ class WorkspaceAutoGen(AutoGen): # # add build_rule.txt & tools_def.txt # - AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, = gDefaultBuildRuleFile)) - AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, = gDefaultToolsDefFile)) + AllWorkSpaceMetaFiles.add(os.path.join( + GlobalData.gConfDirectory, gDefaultBuildRuleFile)) + AllWorkSpaceMetaFiles.add(os.path.join( + GlobalData.gConfDirectory, gDefaultToolsDefFile)) =20 # add BuildOption metafile # @@ -684,7 +757,8 @@ class WorkspaceAutoGen(AutoGen): =20 # add PcdToken Number file for Dynamic/DynamicEx Pcd # - AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'PcdTokenNum= ber')) + AllWorkSpaceMetaFiles.add(os.path.join( + self.BuildDir, 'PcdTokenNumber')) =20 for Pa in self.AutoGenObjectList: AllWorkSpaceMetaFiles.add(Pa.ToolDefinitionFile) @@ -706,10 +780,10 @@ class WorkspaceAutoGen(AutoGen): =20 def _CheckPcdDefineAndType(self): PcdTypeSet =3D {TAB_PCDS_FIXED_AT_BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE, - TAB_PCDS_FEATURE_FLAG, - TAB_PCDS_DYNAMIC, - TAB_PCDS_DYNAMIC_EX} + TAB_PCDS_PATCHABLE_IN_MODULE, + TAB_PCDS_FEATURE_FLAG, + TAB_PCDS_DYNAMIC, + TAB_PCDS_DYNAMIC_EX} =20 # This dict store PCDs which are not used by any modules with spec= ified arches UnusedPcd =3D OrderedDict() @@ -737,7 +811,7 @@ class WorkspaceAutoGen(AutoGen): EdkLogger.error( 'build', FORMAT_INVALID, - "Type [%s] of PCD [%s.%s] in DSC file does= n't match the type [%s] defined in DEC file." \ + "Type [%s] of PCD [%s.%s] in DSC file does= n't match the type [%s] defined in DEC file." % (Pa.Platform.Pcds[Pcd].Type, Pcd[1], Pcd= [0], Type), ExtraData=3DNone ) @@ -757,42 +831,42 @@ class WorkspaceAutoGen(AutoGen): def __repr__(self): return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList)) =20 - ## Return the directory to store FV files + # Return the directory to store FV files @cached_property def FvDir(self): return path.join(self.BuildDir, TAB_FV_DIRECTORY) =20 - ## Return the directory to store all intermediate and final files built + # Return the directory to store all intermediate and final files built @cached_property def BuildDir(self): return self.AutoGenObjectList[0].BuildDir =20 - ## Return the build output directory platform specifies + # Return the build output directory platform specifies @cached_property def OutputDir(self): return self.Platform.OutputDirectory =20 - ## Return platform name + # Return platform name @cached_property def Name(self): return self.Platform.PlatformName =20 - ## Return meta-file GUID + # Return meta-file GUID @cached_property def Guid(self): return self.Platform.Guid =20 - ## Return platform version + # Return platform version @cached_property def Version(self): return self.Platform.Version =20 - ## Return paths of tools + # Return paths of tools @cached_property def ToolDefinition(self): return self.AutoGenObjectList[0].ToolDefinition =20 - ## Return directory of platform makefile + # Return directory of platform makefile # # @retval string Makefile directory # @@ -800,7 +874,7 @@ class WorkspaceAutoGen(AutoGen): def MakeFileDir(self): return self.BuildDir =20 - ## Return build command string + # Return build command string # # @retval string Build command string # @@ -809,7 +883,7 @@ class WorkspaceAutoGen(AutoGen): # BuildCommand should be all the same. So just get one from platfo= rm AutoGen return self.AutoGenObjectList[0].BuildCommand =20 - ## Check the PCDs token value conflict in each DEC file. + # Check the PCDs token value conflict in each DEC file. # # Will cause build break and raise error message while two PCDs confli= ct. # @@ -821,7 +895,7 @@ class WorkspaceAutoGen(AutoGen): PcdList =3D list(Package.Pcds.values()) PcdList.sort(key=3Dlambda x: int(x.TokenValue, 0)) Count =3D 0 - while (Count < len(PcdList) - 1) : + while (Count < len(PcdList) - 1): Item =3D PcdList[Count] ItemNext =3D PcdList[Count + 1] # @@ -834,13 +908,15 @@ class WorkspaceAutoGen(AutoGen): RemainPcdListLength =3D len(PcdList) - Count - 2 for ValueSameCount in range(RemainPcdListLength): if int(PcdList[len(PcdList) - RemainPcdListLen= gth + ValueSameCount].TokenValue, 0) =3D=3D int(Item.TokenValue, 0): - SameTokenValuePcdList.append(PcdList[len(P= cdList) - RemainPcdListLength + ValueSameCount]) + SameTokenValuePcdList.append( + PcdList[len(PcdList) - RemainPcdListLe= ngth + ValueSameCount]) else: - break; + break # # Sort same token value PCD list with TokenGuid an= d TokenCName # - SameTokenValuePcdList.sort(key=3Dlambda x: "%s.%s"= % (x.TokenSpaceGuidCName, x.TokenCName)) + SameTokenValuePcdList.sort(key=3Dlambda x: "%s.%s"= % ( + x.TokenSpaceGuidCName, x.TokenCName)) SameTokenValuePcdListCount =3D 0 while (SameTokenValuePcdListCount < len(SameTokenV= aluePcdList) - 1): Flag =3D False @@ -850,24 +926,25 @@ class WorkspaceAutoGen(AutoGen): if (TemListItem.TokenSpaceGuidCName =3D=3D Tem= ListItemNext.TokenSpaceGuidCName) and (TemListItem.TokenCName !=3D TemListI= temNext.TokenCName): for PcdItem in GlobalData.MixedPcd: if (TemListItem.TokenCName, TemListIte= m.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem] or \ - (TemListItemNext.TokenCName, TemLi= stItemNext.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: + (TemListItemNext.TokenCName, T= emListItemNext.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: Flag =3D True if not Flag: EdkLogger.error( - 'build', - FORMAT_INVALID, - "The TokenValue [%s] of PC= D [%s.%s] is conflict with: [%s.%s] in %s"\ - % (TemListItem.TokenValue,= TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.T= okenSpaceGuidCName, TemListItemNext.TokenCName, Package), - ExtraData=3DNone - ) + 'build', + FORMAT_INVALID, + "The TokenValue [%s] of PCD [%s.%s= ] is conflict with: [%s.%s] in %s" + % (TemListItem.TokenValue, TemList= Item.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpac= eGuidCName, TemListItemNext.TokenCName, Package), + ExtraData=3DNone + ) SameTokenValuePcdListCount +=3D 1 Count +=3D SameTokenValuePcdListCount Count +=3D 1 =20 PcdList =3D list(Package.Pcds.values()) - PcdList.sort(key=3Dlambda x: "%s.%s" % (x.TokenSpaceGuidCN= ame, x.TokenCName)) + PcdList.sort(key=3Dlambda x: "%s.%s" % + (x.TokenSpaceGuidCName, x.TokenCName)) Count =3D 0 - while (Count < len(PcdList) - 1) : + while (Count < len(PcdList) - 1): Item =3D PcdList[Count] ItemNext =3D PcdList[Count + 1] # @@ -875,14 +952,15 @@ class WorkspaceAutoGen(AutoGen): # if (Item.TokenSpaceGuidCName =3D=3D ItemNext.TokenSpac= eGuidCName) and (Item.TokenCName =3D=3D ItemNext.TokenCName) and (int(Item.= TokenValue, 0) !=3D int(ItemNext.TokenValue, 0)): EdkLogger.error( - 'build', - FORMAT_INVALID, - "The TokenValue [%s] of PCD [%s.%s] in= %s defined in two places should be same as well."\ - % (Item.TokenValue, Item.TokenSpaceGui= dCName, Item.TokenCName, Package), - ExtraData=3DNone - ) + 'build', + FORMAT_INVALID, + "The TokenValue [%s] of PCD [%s.%s] in %s defi= ned in two places should be same as well." + % (Item.TokenValue, Item.TokenSpaceGuidCName, = Item.TokenCName, Package), + ExtraData=3DNone + ) Count +=3D 1 - ## Generate fds command + # Generate fds command + @property def GenFdsCommand(self): return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.= TopLevelMakefile(self)._TemplateDict)).strip() @@ -909,7 +987,8 @@ class WorkspaceAutoGen(AutoGen): else: pcdname =3D '.'.join(pcd[0:2]) if pcd[3].startswith('{'): - FdsCommandDict["OptionPcd"].append(pcdname + '=3D' + 'H' += '"' + pcd[3] + '"') + FdsCommandDict["OptionPcd"].append( + pcdname + '=3D' + 'H' + '"' + pcd[3] + '"') else: FdsCommandDict["OptionPcd"].append(pcdname + '=3D' + pcd[3= ]) =20 @@ -920,7 +999,8 @@ class WorkspaceAutoGen(AutoGen): MacroDict.update(GlobalData.gCommandLineDefines) for MacroName in MacroDict: if MacroDict[MacroName] !=3D "": - MacroList.append('"%s=3D%s"' % (MacroName, MacroDict[Macro= Name].replace('\\', '\\\\'))) + MacroList.append('"%s=3D%s"' % ( + MacroName, MacroDict[MacroName].replace('\\', '\\\\'))) else: MacroList.append('"%s"' % MacroName) FdsCommandDict["macro"] =3D MacroList @@ -939,7 +1019,7 @@ class WorkspaceAutoGen(AutoGen): FdsCommandDict["cap"] =3D self.CapTargetList return FdsCommandDict =20 - ## Create makefile for the platform and modules in it + # Create makefile for the platform and modules in it # # @param CreateDepsMakeFile Flag indicating if the makefil= e for # modules will be created as well @@ -950,7 +1030,7 @@ class WorkspaceAutoGen(AutoGen): for Pa in self.AutoGenObjectList: Pa.CreateMakeFile(CreateDepsMakeFile) =20 - ## Create autogen code for platform and modules + # Create autogen code for platform and modules # # Since there's no autogen code for platform, this method will do not= hing # if CreateModuleCodeFile is set to False. @@ -964,8 +1044,7 @@ class WorkspaceAutoGen(AutoGen): for Pa in self.AutoGenObjectList: Pa.CreateCodeFile(CreateDepsCodeFile) =20 - ## Create AsBuilt INF file the platform + # Create AsBuilt INF file the platform # def CreateAsBuiltInf(self): return - diff --git a/BaseTools/Source/Python/AutoGen/__init__.py b/BaseTools/Source= /Python/AutoGen/__init__.py index 47451c4c40fa..7e12731d6c86 100644 --- a/BaseTools/Source/Python/AutoGen/__init__.py +++ b/BaseTools/Source/Python/AutoGen/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'AutoGen' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python= /BPDG/BPDG.py index 283e08a37a0f..0820cfd5e7e0 100644 --- a/BaseTools/Source/Python/BPDG/BPDG.py +++ b/BaseTools/Source/Python/BPDG/BPDG.py @@ -1,4 +1,4 @@ -## @file +# @file # Intel Binary Product Data Generation Tool (Intel BPDG). # This tool provide a simple process for the creation of a binary file co= ntaining read-only # configuration data for EDK II platforms that contain Dynamic and Dynami= cEx PCDs described @@ -28,10 +28,10 @@ from Common.BuildVersion import gBUILD_VERSION from . import StringTable as st from . import GenVpd =20 -PROJECT_NAME =3D st.LBL_BPDG_LONG_UNI -VERSION =3D (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION) +PROJECT_NAME =3D st.LBL_BPDG_LONG_UNI +VERSION =3D (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION) =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -40,6 +40,8 @@ VERSION =3D (st.LBL_BPDG_VERSION + " Build " += gBUILD_VERSION) # @retval 0 Tool was successful # @retval 1 Tool failed # + + def main(): global Options, Args =20 @@ -59,24 +61,26 @@ def main(): EdkLogger.SetLevel(EdkLogger.INFO) =20 if Options.bin_filename is None: - EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -= o option to specify the file name for the VPD binary file") + EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, + "Please use the -o option to specify the file name= for the VPD binary file") if Options.filename is None: - EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -= m option to specify the file name for the mapping file") + EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, + "Please use the -m option to specify the file name= for the mapping file") =20 Force =3D False if Options.opt_force is not None: Force =3D True =20 - if (Args[0] is not None) : + if (Args[0] is not None): StartBpdg(Args[0], Options.filename, Options.bin_filename, Force) - else : + else: EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please specify t= he file which contain the VPD pcd info.", None) =20 return ReturnCode =20 =20 -## Parse command line options +# Parse command line options # # Using standard Python module optparse to parse command line option of th= is tool. # @@ -107,13 +111,14 @@ def MyOptionParser(): =20 (options, args) =3D parser.parse_args() if len(args) =3D=3D 0: - EdkLogger.info("Please specify the filename.txt file which contain= the VPD pcd info!") + EdkLogger.info( + "Please specify the filename.txt file which contain the VPD pc= d info!") EdkLogger.info(parser.usage) sys.exit(1) return options, args =20 =20 -## Start BPDG and call the main functions +# Start BPDG and call the main functions # # This method mainly focus on call GenVPD class member functions to comple= te # BPDG's target. It will process VpdFile override, and provide the interfa= ce file @@ -133,7 +138,7 @@ def StartBpdg(InputFileName, MapFileName, VpdFileName, = Force): if choice.strip().lower() not in ['y', 'yes', '']: return =20 - GenVPD =3D GenVpd.GenVPD (InputFileName, MapFileName, VpdFileName) + GenVPD =3D GenVpd.GenVPD(InputFileName, MapFileName, VpdFileName) =20 EdkLogger.info('%-24s =3D %s' % ("VPD input data file: ", InputFileNam= e)) EdkLogger.info('%-24s =3D %s' % ("VPD output map file: ", MapFileName)) @@ -146,13 +151,13 @@ def StartBpdg(InputFileName, MapFileName, VpdFileName= , Force): =20 EdkLogger.info("- Vpd pcd fixed done! -") =20 + if __name__ =3D=3D '__main__': try: r =3D main() except FatalError as e: r =3D e - ## 0-127 is a safe return range, and 1 is a standard default error - if r < 0 or r > 127: r =3D 1 + # 0-127 is a safe return range, and 1 is a standard default error + if r < 0 or r > 127: + r =3D 1 sys.exit(r) - - diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Pyth= on/BPDG/GenVpd.py index 049c082f40e2..371d5a8ebf06 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -1,4 +1,4 @@ -## @file +# @file # This file include GenVpd class for fix the Vpd type PCD offset, and Pcd= Entry for describe # and process each entry of vpd type PCD. # @@ -25,40 +25,42 @@ _FORMAT_CHAR =3D {1: 'B', 8: 'Q' } =20 -## The VPD PCD data structure for store and process each VPD PCD entry. +# The VPD PCD data structure for store and process each VPD PCD entry. # # This class contain method to format and pack pcd's value. # + + class PcdEntry: - def __init__(self, PcdCName, SkuId,PcdOffset, PcdSize, PcdValue, Linen= o=3DNone, FileName=3DNone, PcdUnpackValue=3DNone, + def __init__(self, PcdCName, SkuId, PcdOffset, PcdSize, PcdValue, Line= no=3DNone, FileName=3DNone, PcdUnpackValue=3DNone, PcdBinOffset=3DNone, PcdBinSize=3DNone, Alignment=3DNone): - self.PcdCName =3D PcdCName.strip() - self.SkuId =3D SkuId.strip() - self.PcdOffset =3D PcdOffset.strip() - self.PcdSize =3D PcdSize.strip() - self.PcdValue =3D PcdValue.strip() - self.Lineno =3D Lineno.strip() - self.FileName =3D FileName.strip() + self.PcdCName =3D PcdCName.strip() + self.SkuId =3D SkuId.strip() + self.PcdOffset =3D PcdOffset.strip() + self.PcdSize =3D PcdSize.strip() + self.PcdValue =3D PcdValue.strip() + self.Lineno =3D Lineno.strip() + self.FileName =3D FileName.strip() self.PcdUnpackValue =3D PcdUnpackValue - self.PcdBinOffset =3D PcdBinOffset - self.PcdBinSize =3D PcdBinSize - self.Alignment =3D Alignment + self.PcdBinOffset =3D PcdBinOffset + self.PcdBinSize =3D PcdBinSize + self.Alignment =3D Alignment =20 - if self.PcdValue =3D=3D '' : + if self.PcdValue =3D=3D '': EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD format(Name: %s File: %s line: %s= ) , no Value specified!" % (self.PcdCName, self.FileName, self.Lineno)) =20 - if self.PcdOffset =3D=3D '' : + if self.PcdOffset =3D=3D '': EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD format(Name: %s File: %s Line: %s= ) , no Offset specified!" % (self.PcdCName, self.FileName, self.Lineno)) =20 - if self.PcdSize =3D=3D '' : + if self.PcdSize =3D=3D '': EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD format(Name: %s File: %s Line: %s= ), no PcdSize specified!" % (self.PcdCName, self.FileName, self.Lineno)) =20 - self._GenOffsetValue () + self._GenOffsetValue() =20 - ## Analyze the string value to judge the PCD's datum type equal to Boo= lean or not. + # Analyze the string value to judge the PCD's datum type equal to Bool= ean or not. # # @param ValueString PCD's value # @param Size PCD's size @@ -75,7 +77,7 @@ class PcdEntry: =20 return False =20 - ## Convert the PCD's value from string to integer. + # Convert the PCD's value from string to integer. # # This function will try to convert the Offset value form string to i= nteger # for both hexadecimal and decimal. @@ -83,7 +85,7 @@ class PcdEntry: def _GenOffsetValue(self): if self.PcdOffset !=3D TAB_STAR: try: - self.PcdBinOffset =3D int (self.PcdOffset) + self.PcdBinOffset =3D int(self.PcdOffset) except: try: self.PcdBinOffset =3D int(self.PcdOffset, 16) @@ -91,7 +93,7 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid offset value %s for PCD %s (F= ile: %s Line: %s)" % (self.PcdOffset, self.PcdCName, self.FileName, self.Li= neno)) =20 - ## Pack Boolean type VPD PCD's value form string to binary type. + # Pack Boolean type VPD PCD's value form string to binary type. # # @param ValueString The boolean type string for pack. # @@ -110,7 +112,7 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid size or value for PCD %s to pack(= File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) =20 - ## Pack Integer type VPD PCD's value form string to binary type. + # Pack Integer type VPD PCD's value form string to binary type. # # @param ValueString The Integer type string for pack. # @@ -127,11 +129,11 @@ class PcdEntry: if IntValue < 0: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "PCD can't be set to negative value %d= for PCD %s in %s datum type(File: %s Line: %s)." % ( - IntValue, self.PcdCName, Type, self.Fi= leName, self.Lineno)) + IntValue, self.PcdCName, Type, sel= f.FileName, self.Lineno)) elif IntValue > MAX_VAL_TYPE[Type]: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Too large PCD value %d for datum type= %s for PCD %s(File: %s Line: %s)." % ( - IntValue, Type, self.PcdCName, self.Fi= leName, self.Lineno)) + IntValue, Type, self.PcdCName, sel= f.FileName, self.Lineno)) =20 try: self.PcdValue =3D pack(_FORMAT_CHAR[Size], IntValue) @@ -139,7 +141,7 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid size or value for PCD %s to pack(File= : %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) =20 - ## Pack VOID* type VPD PCD's value form string to binary type. + # Pack VOID* type VPD PCD's value form string to binary type. # # The VOID* type of string divided into 3 sub-type: # 1: L"String"/L'String', Unicode type string. @@ -159,7 +161,7 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid VOID* type PCD %s value %s (File: %s = Line: %s)" % (self.PcdCName, ValueString, self.FileName, self.Lineno)) =20 - ## Pack an Ascii PCD value. + # Pack an Ascii PCD value. # # An Ascii string for a PCD should be in format as ""/''. # @@ -168,7 +170,8 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s= Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno)) if (ValueString =3D=3D ""): - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpack= Value, self.PcdCName, self.FileName, self.Lineno)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter ValueString %s of PCD %s!(File: %s Line: %s)" % ( + self.PcdUnpackValue, self.PcdCName, self.FileName, self.Li= neno)) =20 QuotedFlag =3D True if ValueString.startswith("'"): @@ -185,15 +188,17 @@ class PcdEntry: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid size or value for PCD %s to pack(File= : %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno)) =20 - ## Pack a byte-array PCD value. + # Pack a byte-array PCD value. # # A byte-array for a PCD should be in format as {0x01, 0x02, ...}. # def _PackByteArray(self, ValueString, Size): if (Size < 0): - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self= .PcdCName, self.FileName, self.Lineno)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter Size %s of PCD %s!(File: %s Line: %s)" % ( + self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno= )) if (ValueString =3D=3D ""): - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpack= Value, self.PcdCName, self.FileName, self.Lineno)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter ValueString %s of PCD %s!(File: %s Line: %s)" % ( + self.PcdUnpackValue, self.PcdCName, self.FileName, self.Li= neno)) =20 ValueString =3D ValueString.strip() ValueString =3D ValueString.lstrip('{').strip('}') @@ -214,7 +219,7 @@ class PcdEntry: Value =3D int(ValueList[Index], 16) except: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, - "The value item %s in byte array %s is= an invalid HEX value.(File: %s Line: %s)" % \ + "The value item %s in byte array %s is= an invalid HEX value.(File: %s Line: %s)" % (ValueList[Index], ValueString, self.F= ileName, self.Lineno)) else: # translate decimal value @@ -222,12 +227,12 @@ class PcdEntry: Value =3D int(ValueList[Index], 10) except: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, - "The value item %s in byte array %s is= an invalid DECIMAL value.(File: %s Line: %s)" % \ + "The value item %s in byte array %s is= an invalid DECIMAL value.(File: %s Line: %s)" % (ValueList[Index], ValueString, self.F= ileName, self.Lineno)) =20 if Value > 255: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, - "The value item %s in byte array %s do not= in range 0 ~ 0xFF(File: %s Line: %s)" % \ + "The value item %s in byte array %s do not= in range 0 ~ 0xFF(File: %s Line: %s)" % (ValueList[Index], ValueString, self.FileN= ame, self.Lineno)) =20 ReturnArray.append(Value) @@ -237,14 +242,14 @@ class PcdEntry: =20 self.PcdValue =3D ReturnArray.tolist() =20 - ## Pack a unicode PCD value into byte array. + # Pack a unicode PCD value into byte array. # # A unicode string for a PCD should be in format as L""/L''. # def _PackUnicode(self, UnicodeString, Size): if (Size < 0): - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter Size %s of PCD %s!(File: %s Line: %s)" % \ - (self.PcdBinSize, self.PcdCName, self.FileNam= e, self.Lineno)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invali= d parameter Size %s of PCD %s!(File: %s Line: %s)" % + (self.PcdBinSize, self.PcdCName, self.FileName= , self.Lineno)) =20 QuotedFlag =3D True if UnicodeString.startswith("L'"): @@ -254,7 +259,7 @@ class PcdEntry: # No null-terminator in L'string' if (QuotedFlag and (len(UnicodeString) + 1) * 2 > Size) or (not Qu= otedFlag and len(UnicodeString) * 2 > Size): EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW, - "The size of unicode string %s is too larger f= or size %s(File: %s Line: %s)" % \ + "The size of unicode string %s is too larger f= or size %s(File: %s Line: %s)" % (UnicodeString, Size, self.FileName, self.Line= no)) =20 ReturnArray =3D array.array('B') @@ -264,7 +269,7 @@ class PcdEntry: ReturnArray.append(0) except: EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, - "Invalid unicode character %s in unicode s= tring %s(File: %s Line: %s)" % \ + "Invalid unicode character %s in unicode s= tring %s(File: %s Line: %s)" % (Value, UnicodeString, self.FileName, self= .Lineno)) =20 for Index in range(len(UnicodeString) * 2, Size): @@ -273,8 +278,7 @@ class PcdEntry: self.PcdValue =3D ReturnArray.tolist() =20 =20 - -## The class implementing the BPDG VPD PCD offset fix process +# The class implementing the BPDG VPD PCD offset fix process # # The VPD PCD offset fix process includes: # 1. Parse the input guided.txt file and store it in the data struct= ure; @@ -282,8 +286,8 @@ class PcdEntry: # 3. Fixed offset if needed; # 4. Generate output file, including guided.map and guided.bin file; # -class GenVPD : - ## Constructor of DscBuildData +class GenVPD: + # Constructor of DscBuildData # # Initialize object of GenVPD # @Param InputFileName The filename include the vpd type pcd = information @@ -293,28 +297,30 @@ class GenVPD : # @param VpdFileName The filename of Vpd file that hold vpd= pcd information. # def __init__(self, InputFileName, MapFileName, VpdFileName): - self.InputFileName =3D InputFileName - self.MapFileName =3D MapFileName - self.VpdFileName =3D VpdFileName - self.FileLinesList =3D [] - self.PcdFixedOffsetSizeList =3D [] - self.PcdUnknownOffsetList =3D [] + self.InputFileName =3D InputFileName + self.MapFileName =3D MapFileName + self.VpdFileName =3D VpdFileName + self.FileLinesList =3D [] + self.PcdFixedOffsetSizeList =3D [] + self.PcdUnknownOffsetList =3D [] try: fInputfile =3D open(InputFileName, "r") try: self.FileLinesList =3D fInputfile.readlines() except: - EdkLogger.error("BPDG", BuildToolError.FILE_READ_FAILURE, = "File read failed for %s" % InputFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_READ_FAILURE, + "File read failed for %s" % InputFileName,= None) finally: fInputfile.close() except: - EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "Fil= e open failed for %s" % InputFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, + "File open failed for %s" % InputFileName, Non= e) =20 ## # Parser the input file which is generated by the build tool. Convert = the value of each pcd's # from string to its real format. Also remove the useless line in the = input file. # - def ParserInputFile (self): + def ParserInputFile(self): count =3D 0 for line in self.FileLinesList: # Strip "\r\n" generated by readlines (). @@ -322,7 +328,7 @@ class GenVPD : line =3D line.rstrip(os.linesep) =20 # Skip the comment line - if (not line.startswith("#")) and len(line) > 1 : + if (not line.startswith("#")) and len(line) > 1: # # Enhanced for support "|" character in the string. # @@ -345,10 +351,10 @@ class GenVPD : self.FileLinesList[count] =3D ValueList # Store the line number self.FileLinesList[count].append(str(count + 1)) - elif len(line) <=3D 1 : + elif len(line) <=3D 1: # Set the blank line to "None" self.FileLinesList[count] =3D None - else : + else: # Set the comment line to "None" self.FileLinesList[count] =3D None count +=3D 1 @@ -356,40 +362,41 @@ class GenVPD : # The line count contain usage information count =3D 0 # Delete useless lines - while (True) : - try : - if (self.FileLinesList[count] is None) : + while (True): + try: + if (self.FileLinesList[count] is None): del(self.FileLinesList[count]) - else : + else: count +=3D 1 - except : + except: break # # After remove the useless line, if there are no data remain in th= e file line list, # Report warning messages to user's. # - if len(self.FileLinesList) =3D=3D 0 : + if len(self.FileLinesList) =3D=3D 0: EdkLogger.warn('BPDG', BuildToolError.RESOURCE_NOT_AVAILABLE, "There are no VPD type pcds defined in DSC file= , Please check it.") =20 # Process the pcds one by one base on the pcd's value and size count =3D 0 for line in self.FileLinesList: - if line is not None : - PCD =3D PcdEntry(line[0], line[1], line[2], line[3], line[= 4], line[5], self.InputFileName) + if line is not None: + PCD =3D PcdEntry(line[0], line[1], line[2], line[3], + line[4], line[5], self.InputFileName) # Strip the space char - PCD.PcdCName =3D PCD.PcdCName.strip(' ') - PCD.SkuId =3D PCD.SkuId.strip(' ') - PCD.PcdOffset =3D PCD.PcdOffset.strip(' ') - PCD.PcdSize =3D PCD.PcdSize.strip(' ') - PCD.PcdValue =3D PCD.PcdValue.strip(' ') - PCD.Lineno =3D PCD.Lineno.strip(' ') + PCD.PcdCName =3D PCD.PcdCName.strip(' ') + PCD.SkuId =3D PCD.SkuId.strip(' ') + PCD.PcdOffset =3D PCD.PcdOffset.strip(' ') + PCD.PcdSize =3D PCD.PcdSize.strip(' ') + PCD.PcdValue =3D PCD.PcdValue.strip(' ') + PCD.Lineno =3D PCD.Lineno.strip(' ') =20 # # Store the original pcd value. # This information will be useful while generate the outpu= t map file. # - PCD.PcdUnpackValue =3D str(PCD.PcdValue) + PCD.PcdUnpackValue =3D str(PCD.PcdValue) =20 # # Translate PCD size string to an integer value. @@ -402,7 +409,8 @@ class GenVPD : PackSize =3D int(PCD.PcdSize, 16) PCD.PcdBinSize =3D PackSize except: - EdkLogger.error("BPDG", BuildToolError.FORMAT_INVA= LID, "Invalid PCD size value %s at file: %s line: %s" % (PCD.PcdSize, self.= InputFileName, PCD.Lineno)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_INVA= LID, "Invalid PCD size value %s at file: %s line: %s" % ( + PCD.PcdSize, self.InputFileName, PCD.Lineno)) =20 # # If value is Unicode string (e.g. L""), then use 2-byte a= lignment @@ -420,12 +428,15 @@ class GenVPD : if PCD.PcdOffset !=3D TAB_STAR: if PCD.PcdOccupySize % Alignment !=3D 0: if PCD.PcdUnpackValue.startswith("{"): - EdkLogger.warn("BPDG", "The offset value of PC= D %s is not 8-byte aligned!" %(PCD.PcdCName), File=3Dself.InputFileName) + EdkLogger.warn("BPDG", "The offset value of PC= D %s is not 8-byte aligned!" % ( + PCD.PcdCName), File=3Dself.InputFileName) else: - EdkLogger.error("BPDG", BuildToolError.FORMAT_= INVALID, 'The offset value of PCD %s should be %s-byte aligned.' % (PCD.Pcd= CName, Alignment)) + EdkLogger.error("BPDG", BuildToolError.FORMAT_= INVALID, + 'The offset value of PCD %s sh= ould be %s-byte aligned.' % (PCD.PcdCName, Alignment)) else: if PCD.PcdOccupySize % Alignment !=3D 0: - PCD.PcdOccupySize =3D (PCD.PcdOccupySize // Alignm= ent + 1) * Alignment + PCD.PcdOccupySize =3D ( + PCD.PcdOccupySize // Alignment + 1) * Alignment =20 PackSize =3D PCD.PcdOccupySize if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize): @@ -453,29 +464,29 @@ class GenVPD : =20 self.FileLinesList[count] =3D PCD count +=3D 1 - else : + else: continue =20 ## # This function used to create a clean list only contain useful inform= ation and reorganized to make it # easy to be sorted # - def FormatFileLine (self) : + def FormatFileLine(self): =20 - for eachPcd in self.FileLinesList : - if eachPcd.PcdOffset !=3D TAB_STAR : + for eachPcd in self.FileLinesList: + if eachPcd.PcdOffset !=3D TAB_STAR: # Use pcd's Offset value as key, and pcd's Value as value self.PcdFixedOffsetSizeList.append(eachPcd) - else : + else: # Use pcd's CName as key, and pcd's Size as value self.PcdUnknownOffsetList.append(eachPcd) =20 - ## # This function is use to fix the offset value which the not specified= in the map file. # Usually it use the star (meaning any offset) character in the offset= field # - def FixVpdOffset (self): + + def FixVpdOffset(self): # At first, the offset should start at 0 # Sort fixed offset list in order to find out where has free space= s for the pcd's offset # value is TAB_STAR to insert into. @@ -487,187 +498,204 @@ class GenVPD : # self.PcdUnknownOffsetList.sort(key=3Dlambda x: x.PcdBinSize) =20 - index =3D0 + index =3D 0 for pcd in self.PcdUnknownOffsetList: index +=3D 1 if pcd.PcdCName =3D=3D ".".join(("gEfiMdeModulePkgTokenSpaceGu= id", "PcdNvStoreDefaultValueBuffer")): if index !=3D len(self.PcdUnknownOffsetList): for i in range(len(self.PcdUnknownOffsetList) - index): - self.PcdUnknownOffsetList[index+i -1 ], self.PcdUn= knownOffsetList[index+i] =3D self.PcdUnknownOffsetList[index+i], self.PcdUn= knownOffsetList[index+i -1] + self.PcdUnknownOffsetList[index+i - 1], self.PcdUn= knownOffsetList[index + + = i] =3D self.PcdUnknownOffsetList[index+i], self.PcdUnknownO= ffsetList[index+i - 1] =20 # # Process all Offset value are TAB_STAR # - if (len(self.PcdFixedOffsetSizeList) =3D=3D 0) and (len(self.PcdUn= knownOffsetList) !=3D 0) : + if (len(self.PcdFixedOffsetSizeList) =3D=3D 0) and (len(self.PcdUn= knownOffsetList) !=3D 0): # The offset start from 0 NowOffset =3D 0 - for Pcd in self.PcdUnknownOffsetList : + for Pcd in self.PcdUnknownOffsetList: if NowOffset % Pcd.Alignment !=3D 0: - NowOffset =3D (NowOffset// Pcd.Alignment + 1) * Pcd.Al= ignment + NowOffset =3D (NowOffset // Pcd.Alignment + 1) * \ + Pcd.Alignment Pcd.PcdBinOffset =3D NowOffset - Pcd.PcdOffset =3D str(hex(Pcd.PcdBinOffset)) - NowOffset +=3D Pcd.PcdOccupySize + Pcd.PcdOffset =3D str(hex(Pcd.PcdBinOffset)) + NowOffset +=3D Pcd.PcdOccupySize =20 self.PcdFixedOffsetSizeList =3D self.PcdUnknownOffsetList return =20 # Check the offset of VPD type pcd's offset start from 0. - if self.PcdFixedOffsetSizeList[0].PcdBinOffset !=3D 0 : + if self.PcdFixedOffsetSizeList[0].PcdBinOffset !=3D 0: EdkLogger.warn("BPDG", "The offset of VPD type pcd should star= t with 0, please check it.", - None) + None) =20 # Judge whether the offset in fixed pcd offset list is overlapped = or not. lenOfList =3D len(self.PcdFixedOffsetSizeList) - count =3D 0 - while (count < lenOfList - 1) : - PcdNow =3D self.PcdFixedOffsetSizeList[count] + count =3D 0 + while (count < lenOfList - 1): + PcdNow =3D self.PcdFixedOffsetSizeList[count] PcdNext =3D self.PcdFixedOffsetSizeList[count+1] # Two pcd's offset is same - if PcdNow.PcdBinOffset =3D=3D PcdNext.PcdBinOffset : + if PcdNow.PcdBinOffset =3D=3D PcdNext.PcdBinOffset: EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILU= RE, - "The offset of %s at line: %s is same with= %s at line: %s in file %s" % \ - (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.P= cdCName, PcdNext.Lineno, PcdNext.FileName), + "The offset of %s at line: %s is same with= %s at line: %s in file %s" % + (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.P= cdCName, + PcdNext.Lineno, PcdNext.FileName), None) =20 # Overlapped - if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize > PcdNext.PcdBin= Offset : + if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize > PcdNext.PcdBin= Offset: EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILU= RE, - "The offset of %s at line: %s is overlappe= d with %s at line: %s in file %s" % \ - (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.P= cdCName, PcdNext.Lineno, PcdNext.FileName), + "The offset of %s at line: %s is overlappe= d with %s at line: %s in file %s" % + (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.P= cdCName, + PcdNext.Lineno, PcdNext.FileName), None) =20 # Has free space, raise a warning message - if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize < PcdNext.PcdBin= Offset : + if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize < PcdNext.PcdBin= Offset: EdkLogger.warn("BPDG", BuildToolError.ATTRIBUTE_GET_FAILUR= E, - "The offsets have free space of between %s = at line: %s and %s at line: %s in file %s" % \ - (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.Pc= dCName, PcdNext.Lineno, PcdNext.FileName), - None) + "The offsets have free space of between %s = at line: %s and %s at line: %s in file %s" % + (PcdNow.PcdCName, PcdNow.Lineno, PcdNext.Pc= dCName, + PcdNext.Lineno, PcdNext.FileName), + None) count +=3D 1 =20 - LastOffset =3D self.PcdFixedOffsetSizeList[0].PcdBinO= ffset - FixOffsetSizeListCount =3D 0 - lenOfList =3D len(self.PcdFixedOffsetSizeList) - lenOfUnfixedList =3D len(self.PcdUnknownOffsetList) + LastOffset =3D self.PcdFixedOffsetSizeList[0].PcdBinOffset + FixOffsetSizeListCount =3D 0 + lenOfList =3D len(self.PcdFixedOffsetSizeList) + lenOfUnfixedList =3D len(self.PcdUnknownOffsetList) =20 ## # Insert the un-fixed offset pcd's list into fixed offset pcd's li= st if has free space between those pcds. # - while (FixOffsetSizeListCount < lenOfList) : + while (FixOffsetSizeListCount < lenOfList): =20 - eachFixedPcd =3D self.PcdFixedOffsetSizeList[FixOffsetSize= ListCount] - NowOffset =3D eachFixedPcd.PcdBinOffset + eachFixedPcd =3D self.PcdFixedOffsetSizeList[FixOffsetSizeList= Count] + NowOffset =3D eachFixedPcd.PcdBinOffset =20 # Has free space - if LastOffset < NowOffset : - if lenOfUnfixedList !=3D 0 : + if LastOffset < NowOffset: + if lenOfUnfixedList !=3D 0: countOfUnfixedList =3D 0 - while(countOfUnfixedList < lenOfUnfixedList) : - eachUnfixedPcd =3D self.PcdUnknownOffsetList[= countOfUnfixedList] - needFixPcdSize =3D eachUnfixedPcd.PcdOccupySi= ze + while(countOfUnfixedList < lenOfUnfixedList): + eachUnfixedPcd =3D self.PcdUnknownOffsetList[count= OfUnfixedList] + needFixPcdSize =3D eachUnfixedPcd.PcdOccupySize # Not been fixed - if eachUnfixedPcd.PcdOffset =3D=3D TAB_STAR : + if eachUnfixedPcd.PcdOffset =3D=3D TAB_STAR: if LastOffset % eachUnfixedPcd.Alignment !=3D = 0: - LastOffset =3D (LastOffset // eachUnfixedP= cd.Alignment + 1) * eachUnfixedPcd.Alignment + LastOffset =3D ( + LastOffset // eachUnfixedPcd.Alignment= + 1) * eachUnfixedPcd.Alignment # The offset un-fixed pcd can write into this = free space - if needFixPcdSize <=3D (NowOffset - LastOffset= ) : + if needFixPcdSize <=3D (NowOffset - LastOffset= ): # Change the offset value of un-fixed pcd - eachUnfixedPcd.PcdOffset =3D str(hex(La= stOffset)) + eachUnfixedPcd.PcdOffset =3D str(hex(LastO= ffset)) eachUnfixedPcd.PcdBinOffset =3D LastOffset # Insert this pcd into fixed offset pcd li= st. - self.PcdFixedOffsetSizeList.insert(FixOffs= etSizeListCount, eachUnfixedPcd) + self.PcdFixedOffsetSizeList.insert( + FixOffsetSizeListCount, eachUnfixedPcd) =20 # Delete the item's offset that has been f= ixed and added into fixed offset list - self.PcdUnknownOffsetList.pop(countOfUnfix= edList) + self.PcdUnknownOffsetList.pop( + countOfUnfixedList) =20 # After item added, should enlarge the len= gth of fixed pcd offset list - lenOfList +=3D 1 - FixOffsetSizeListCount +=3D 1 + lenOfList +=3D 1 + FixOffsetSizeListCount +=3D 1 =20 # Decrease the un-fixed pcd offset list's = length - lenOfUnfixedList -=3D 1 + lenOfUnfixedList -=3D 1 =20 # Modify the last offset value - LastOffset +=3D needFixPcdSize - else : + LastOffset +=3D needFixPcdSize + else: # It can not insert into those two pcds, n= eed to check still has other space can store it. - LastOffset =3D NowOffset + sel= f.PcdFixedOffsetSizeList[FixOffsetSizeListCount].PcdOccupySize + LastOffset =3D NowOffset + \ + self.PcdFixedOffsetSizeList[FixOffsetS= izeListCount].PcdOccupySize FixOffsetSizeListCount +=3D 1 break =20 # Set the FixOffsetSizeListCount =3D lenOfList for quit th= e loop - else : + else: FixOffsetSizeListCount =3D lenOfList =20 # No free space, smoothly connect with previous pcd. - elif LastOffset =3D=3D NowOffset : + elif LastOffset =3D=3D NowOffset: LastOffset =3D NowOffset + eachFixedPcd.PcdOccupySize FixOffsetSizeListCount +=3D 1 # Usually it will not enter into this thunk, if so, means it o= verlapped. - else : + else: EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_NOT_AVAIL= ABLE, - "The offset value definition has overlappe= d at pcd: %s, its offset is: %s, in file: %s line: %s" % \ - (eachFixedPcd.PcdCName, eachFixedPcd.PcdOf= fset, eachFixedPcd.InputFileName, eachFixedPcd.Lineno), + "The offset value definition has overlappe= d at pcd: %s, its offset is: %s, in file: %s line: %s" % + (eachFixedPcd.PcdCName, eachFixedPcd.PcdOf= fset, + eachFixedPcd.InputFileName, eachFixedPcd.= Lineno), None) FixOffsetSizeListCount +=3D 1 =20 # Continue to process the un-fixed offset pcd's list, add this tim= e, just append them behind the fixed pcd's offset list. - lenOfUnfixedList =3D len(self.PcdUnknownOffsetList) - lenOfList =3D len(self.PcdFixedOffsetSizeList) - while (lenOfUnfixedList > 0) : + lenOfUnfixedList =3D len(self.PcdUnknownOffsetList) + lenOfList =3D len(self.PcdFixedOffsetSizeList) + while (lenOfUnfixedList > 0): # Still has items need to process # The last pcd instance - LastPcd =3D self.PcdFixedOffsetSizeList[lenOfList-1] + LastPcd =3D self.PcdFixedOffsetSizeList[lenOfList-1] NeedFixPcd =3D self.PcdUnknownOffsetList[0] =20 NeedFixPcd.PcdBinOffset =3D LastPcd.PcdBinOffset + LastPcd.Pcd= OccupySize if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment !=3D 0: - NeedFixPcd.PcdBinOffset =3D (NeedFixPcd.PcdBinOffset // Ne= edFixPcd.Alignment + 1) * NeedFixPcd.Alignment + NeedFixPcd.PcdBinOffset =3D ( + NeedFixPcd.PcdBinOffset // NeedFixPcd.Alignment + 1) *= NeedFixPcd.Alignment =20 - NeedFixPcd.PcdOffset =3D str(hex(NeedFixPcd.PcdBinOffset)) + NeedFixPcd.PcdOffset =3D str(hex(NeedFixPcd.PcdBinOffset)) =20 # Insert this pcd into fixed offset pcd list's tail. self.PcdFixedOffsetSizeList.insert(lenOfList, NeedFixPcd) # Delete the item's offset that has been fixed and added into = fixed offset list self.PcdUnknownOffsetList.pop(0) =20 - lenOfList +=3D 1 - lenOfUnfixedList -=3D 1 + lenOfList +=3D 1 + lenOfUnfixedList -=3D 1 ## # Write the final data into output files. # - def GenerateVpdFile (self, MapFileName, BinFileName): - #Open an VPD file to process + + def GenerateVpdFile(self, MapFileName, BinFileName): + # Open an VPD file to process =20 try: fVpdFile =3D open(BinFileName, "wb") except: # Open failed - EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "Fil= e open failed for %s" % self.VpdFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, + "File open failed for %s" % self.VpdFileName, = None) =20 - try : + try: fMapFile =3D open(MapFileName, "w") except: # Open failed - EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "Fil= e open failed for %s" % self.MapFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, + "File open failed for %s" % self.MapFileName, = None) =20 # Use a instance of BytesIO to cache data fStringIO =3D BytesIO() =20 # Write the header of map file. - try : - fMapFile.write (st.MAP_FILE_COMMENT_TEMPLATE + "\n") + try: + fMapFile.write(st.MAP_FILE_COMMENT_TEMPLATE + "\n") except: - EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Wr= ite data to file %s failed, please check whether the file been locked or us= ing by other applications." % self.MapFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, + "Write data to file %s failed, please check wh= ether the file been locked or using by other applications." % self.MapFileN= ame, None) =20 - for eachPcd in self.PcdFixedOffsetSizeList : + for eachPcd in self.PcdFixedOffsetSizeList: # write map file - try : - fMapFile.write("%s | %s | %s | %s | %s \n" % (eachPcd.Pcd= CName, eachPcd.SkuId, eachPcd.PcdOffset, eachPcd.PcdSize, eachPcd.PcdUnpack= Value)) + try: + fMapFile.write("%s | %s | %s | %s | %s \n" % ( + eachPcd.PcdCName, eachPcd.SkuId, eachPcd.PcdOffset, ea= chPcd.PcdSize, eachPcd.PcdUnpackValue)) except: - EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE,= "Write data to file %s failed, please check whether the file been locked o= r using by other applications." % self.MapFileName, None) + EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, + "Write data to file %s failed, please chec= k whether the file been locked or using by other applications." % self.MapF= ileName, None) =20 # Write Vpd binary file - fStringIO.seek (eachPcd.PcdBinOffset) + fStringIO.seek(eachPcd.PcdBinOffset) if isinstance(eachPcd.PcdValue, list): for i in range(len(eachPcd.PcdValue)): Value =3D eachPcd.PcdValue[i:i + 1] @@ -676,14 +704,14 @@ class GenVPD : else: fStringIO.write(bytes(Value)) else: - fStringIO.write (eachPcd.PcdValue) + fStringIO.write(eachPcd.PcdValue) =20 - try : - fVpdFile.write (fStringIO.getvalue()) + try: + fVpdFile.write(fStringIO.getvalue()) except: - EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Wr= ite data to file %s failed, please check whether the file been locked or us= ing by other applications." % self.VpdFileName, None) - - fStringIO.close () - fVpdFile.close () - fMapFile.close () + EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, + "Write data to file %s failed, please check wh= ether the file been locked or using by other applications." % self.VpdFileN= ame, None) =20 + fStringIO.close() + fVpdFile.close() + fMapFile.close() diff --git a/BaseTools/Source/Python/BPDG/StringTable.py b/BaseTools/Source= /Python/BPDG/StringTable.py index cd8b2d732645..b142ebc60129 100644 --- a/BaseTools/Source/Python/BPDG/StringTable.py +++ b/BaseTools/Source/Python/BPDG/StringTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define strings used in the BPDG tool # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
        @@ -6,9 +6,9 @@ ## =20 =20 -#string table starts here... +# string table starts here... =20 -#strings are classified as following types +# strings are classified as following types # MSG_...: it is a message string # ERR_...: it is a error string # WRN_...: it is a warning string @@ -19,7 +19,7 @@ # XRC_...: it is a user visible string from xrc file =20 MAP_FILE_COMMENT_TEMPLATE =3D \ -""" + """ ## @file # # THIS IS AUTO-GENERATED FILE BY BPDG TOOLS AND PLEASE DO NOT MAKE MODIFI= CATION. @@ -38,12 +38,12 @@ MAP_FILE_COMMENT_TEMPLATE =3D \ """ =20 =20 - -LBL_BPDG_LONG_UNI =3D (u"Intel(r) Binary Product Data Generation= Tool (Intel(r) BPDG)") -LBL_BPDG_VERSION =3D (u"1.0") -LBL_BPDG_USAGE =3D \ -( -"""BPDG options -o Filename.bin -m Filename.map Filename.txt +LBL_BPDG_LONG_UNI =3D ( + u"Intel(r) Binary Product Data Generation Tool (Intel(r) BPDG)") +LBL_BPDG_VERSION =3D (u"1.0") +LBL_BPDG_USAGE =3D \ + ( + """BPDG options -o Filename.bin -m Filename.map Filename.txt Copyright (c) 2010 - 2018, Intel Corporation All Rights Reserved. =20 Intel(r) Binary Product Data Generation Tool (Intel(r) BPDG) @@ -56,17 +56,20 @@ Required Flags: the mapping of Pcd name, offset, datum size and value derived from the input file and any automatic calculations. """ -) + ) =20 -MSG_OPTION_HELP =3D ("Show this help message and exit.") -MSG_OPTION_DEBUG_LEVEL =3D ("Print DEBUG statements, where DEBUG_LEVE= L is 0-9.") -MSG_OPTION_VERBOSE =3D ("Print informational statements.") -MSG_OPTION_QUIET =3D ("Returns the exit code and will display o= nly error messages.") -MSG_OPTION_VPD_FILENAME =3D ("Specify the file name for the VPD binary= file.") -MSG_OPTION_MAP_FILENAME =3D ("Generate file name for consumption durin= g the build that contains the mapping of Pcd name, offset, datum size and v= alue derived from the input file and any automatic calculations.") -MSG_OPTION_FORCE =3D ("Will force overwriting existing output f= iles rather than returning an error message.") +MSG_OPTION_HELP =3D ("Show this help message and exit.") +MSG_OPTION_DEBUG_LEVEL =3D ("Print DEBUG statements, where DEBUG_LEVEL is = 0-9.") +MSG_OPTION_VERBOSE =3D ("Print informational statements.") +MSG_OPTION_QUIET =3D ( + "Returns the exit code and will display only error messages.") +MSG_OPTION_VPD_FILENAME =3D ("Specify the file name for the VPD binary fil= e.") +MSG_OPTION_MAP_FILENAME =3D ( + "Generate file name for consumption during the build that contains the= mapping of Pcd name, offset, datum size and value derived from the input f= ile and any automatic calculations.") +MSG_OPTION_FORCE =3D ( + "Will force overwriting existing output files rather than returning an= error message.") =20 -ERR_INVALID_DEBUG_LEVEL =3D ("Invalid level for debug message. Only " - "'DEBUG', 'INFO', 'WARNING', 'ERROR', " - "'CRITICAL' are supported for debugging " - "messages.") +ERR_INVALID_DEBUG_LEVEL =3D ("Invalid level for debug message. Only " + "'DEBUG', 'INFO', 'WARNING', 'ERROR', " + "'CRITICAL' are supported for debugging " + "messages.") diff --git a/BaseTools/Source/Python/BPDG/__init__.py b/BaseTools/Source/Py= thon/BPDG/__init__.py index ea120ab9c743..20f8a593e315 100644 --- a/BaseTools/Source/Python/BPDG/__init__.py +++ b/BaseTools/Source/Python/BPDG/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'BPDG' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/BaseTools= /Source/Python/Capsule/GenerateCapsule.py index 35435946c664..f44bc42022cb 100644 --- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py +++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py @@ -1,4 +1,4 @@ -## @file +# @file # Generate a capsule. # # This tool generates a UEFI Capsule around an FMP Capsule. The capsule pa= yload @@ -29,20 +29,21 @@ import shutil import platform import json from Common.Uefi.Capsule.UefiCapsuleHeader import UefiCapsuleHeaderClass -from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass -from Common.Uefi.Capsule.FmpAuthHeader import FmpAuthHeaderClass +from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass +from Common.Uefi.Capsule.FmpAuthHeader import FmpAuthHeaderClass from Common.Uefi.Capsule.CapsuleDependency import CapsuleDependencyClass -from Common.Edk2.Capsule.FmpPayloadHeader import FmpPayloadHeaderClass +from Common.Edk2.Capsule.FmpPayloadHeader import FmpPayloadHeaderClass =20 # # Globals for help information # -__prog__ =3D 'GenerateCapsule' -__version__ =3D '0.10' -__copyright__ =3D 'Copyright (c) 2022, Intel Corporation. All rights res= erved.' +__prog__ =3D 'GenerateCapsule' +__version__ =3D '0.10' +__copyright__ =3D 'Copyright (c) 2022, Intel Corporation. All rights reser= ved.' __description__ =3D 'Generate a capsule.\n' =20 -def SignPayloadSignTool (Payload, ToolPath, PfxFile, SubjectName, Verbose = =3D False): + +def SignPayloadSignTool(Payload, ToolPath, PfxFile, SubjectName, Verbose= =3DFalse): # # Create a temporary directory # @@ -51,17 +52,18 @@ def SignPayloadSignTool (Payload, ToolPath, PfxFile, Su= bjectName, Verbose =3D Fals # # Generate temp file name for the payload contents # - TempFileName =3D os.path.join (TempDirectoryName, 'Payload.bin') + TempFileName =3D os.path.join(TempDirectoryName, 'Payload.bin') =20 # # Create temporary payload file for signing # try: - with open (TempFileName, 'wb') as File: - File.write (Payload) + with open(TempFileName, 'wb') as File: + File.write(Payload) except: - shutil.rmtree (TempDirectoryName) - raise ValueError ('GenerateCapsule: error: can not write temporary= payload file.') + shutil.rmtree(TempDirectoryName) + raise ValueError( + 'GenerateCapsule: error: can not write temporary payload file.= ') =20 # # Build signtool command @@ -69,79 +71,89 @@ def SignPayloadSignTool (Payload, ToolPath, PfxFile, Su= bjectName, Verbose =3D Fals if ToolPath is None: ToolPath =3D '' Command =3D '' - Command =3D Command + '"{Path}" '.format (Path =3D os.path.join (ToolP= ath, 'signtool.exe')) + Command =3D Command + \ + '"{Path}" '.format(Path=3Dos.path.join(ToolPath, 'signtool.exe')) Command =3D Command + 'sign /fd sha256 /p7ce DetachedSignedData /p7co = 1.2.840.113549.1.7.2 ' - Command =3D Command + '/p7 {TempDir} '.format (TempDir =3D TempDirecto= ryName) + Command =3D Command + '/p7 {TempDir} '.format(TempDir=3DTempDirectoryN= ame) if PfxFile is not None: - Command =3D Command + '/f {PfxFile} '.format (PfxFile =3D PfxFile) + Command =3D Command + '/f {PfxFile} '.format(PfxFile=3DPfxFile) if SubjectName is not None: - Command =3D Command + '/n {SubjectName} '.format (SubjectName =3D = SubjectName) + Command =3D Command + '/n {SubjectName} '.format(SubjectName=3DSub= jectName) Command =3D Command + TempFileName if Verbose: - print (Command) + print(Command) =20 # # Sign the input file using the specified private key # try: - Process =3D subprocess.Popen (Command, stdin =3D subprocess.PIPE, = stdout =3D subprocess.PIPE, stderr =3D subprocess.PIPE, shell =3D True) + Process =3D subprocess.Popen(Command, stdin=3Dsubprocess.PIPE, + stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) Result =3D Process.communicate('') except: - shutil.rmtree (TempDirectoryName) - raise ValueError ('GenerateCapsule: error: can not run signtool.') + shutil.rmtree(TempDirectoryName) + raise ValueError('GenerateCapsule: error: can not run signtool.') =20 if Process.returncode !=3D 0: - shutil.rmtree (TempDirectoryName) - print (Result[1].decode()) - raise ValueError ('GenerateCapsule: error: signtool failed.') + shutil.rmtree(TempDirectoryName) + print(Result[1].decode()) + raise ValueError('GenerateCapsule: error: signtool failed.') =20 # # Read the signature from the generated output file # try: - with open (TempFileName + '.p7', 'rb') as File: - Signature =3D File.read () + with open(TempFileName + '.p7', 'rb') as File: + Signature =3D File.read() except: - shutil.rmtree (TempDirectoryName) - raise ValueError ('GenerateCapsule: error: can not read signature = file.') + shutil.rmtree(TempDirectoryName) + raise ValueError( + 'GenerateCapsule: error: can not read signature file.') =20 - shutil.rmtree (TempDirectoryName) + shutil.rmtree(TempDirectoryName) return Signature =20 -def VerifyPayloadSignTool (Payload, CertData, ToolPath, PfxFile, SubjectNa= me, Verbose =3D False): - print ('signtool verify is not supported.') - raise ValueError ('GenerateCapsule: error: signtool verify is not supp= orted.') =20 -def SignPayloadOpenSsl (Payload, ToolPath, SignerPrivateCertFile, OtherPub= licCertFile, TrustedPublicCertFile, Verbose =3D False): +def VerifyPayloadSignTool(Payload, CertData, ToolPath, PfxFile, SubjectNam= e, Verbose=3DFalse): + print('signtool verify is not supported.') + raise ValueError( + 'GenerateCapsule: error: signtool verify is not supported.') + + +def SignPayloadOpenSsl(Payload, ToolPath, SignerPrivateCertFile, OtherPubl= icCertFile, TrustedPublicCertFile, Verbose=3DFalse): # # Build openssl command # if ToolPath is None: ToolPath =3D '' Command =3D '' - Command =3D Command + '"{Path}" '.format (Path =3D os.path.join (ToolP= ath, 'openssl')) + Command =3D Command + \ + '"{Path}" '.format(Path=3Dos.path.join(ToolPath, 'openssl')) Command =3D Command + 'smime -sign -binary -outform DER -md sha256 ' - Command =3D Command + '-signer "{Private}" -certfile "{Public}"'.forma= t (Private =3D SignerPrivateCertFile, Public =3D OtherPublicCertFile) + Command =3D Command + '-signer "{Private}" -certfile "{Public}"'.forma= t( + Private=3DSignerPrivateCertFile, Public=3DOtherPublicCertFile) if Verbose: - print (Command) + print(Command) =20 # # Sign the input file using the specified private key and capture sign= ature from STDOUT # try: - Process =3D subprocess.Popen (Command, stdin =3D subprocess.PIPE, = stdout =3D subprocess.PIPE, stderr =3D subprocess.PIPE, shell =3D True) - Result =3D Process.communicate(input =3D Payload) + Process =3D subprocess.Popen(Command, stdin=3Dsubprocess.PIPE, + stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) + Result =3D Process.communicate(input=3DPayload) Signature =3D Result[0] except: - raise ValueError ('GenerateCapsule: error: can not run openssl.') + raise ValueError('GenerateCapsule: error: can not run openssl.') =20 if Process.returncode !=3D 0: - print (Result[1].decode()) - raise ValueError ('GenerateCapsule: error: openssl failed.') + print(Result[1].decode()) + raise ValueError('GenerateCapsule: error: openssl failed.') =20 return Signature =20 -def VerifyPayloadOpenSsl (Payload, CertData, ToolPath, SignerPrivateCertFi= le, OtherPublicCertFile, TrustedPublicCertFile, Verbose =3D False): + +def VerifyPayloadOpenSsl(Payload, CertData, ToolPath, SignerPrivateCertFil= e, OtherPublicCertFile, TrustedPublicCertFile, Verbose=3DFalse): # # Create a temporary directory # @@ -150,17 +162,18 @@ def VerifyPayloadOpenSsl (Payload, CertData, ToolPath= , SignerPrivateCertFile, Ot # # Generate temp file name for the payload contents # - TempFileName =3D os.path.join (TempDirectoryName, 'Payload.bin') + TempFileName =3D os.path.join(TempDirectoryName, 'Payload.bin') =20 # # Create temporary payload file for verification # try: - with open (TempFileName, 'wb') as File: - File.write (Payload) + with open(TempFileName, 'wb') as File: + File.write(Payload) except: - shutil.rmtree (TempDirectoryName) - raise ValueError ('GenerateCapsule: error: can not write temporary= payload file.') + shutil.rmtree(TempDirectoryName) + raise ValueError( + 'GenerateCapsule: error: can not write temporary payload file.= ') =20 # # Build openssl command @@ -168,30 +181,34 @@ def VerifyPayloadOpenSsl (Payload, CertData, ToolPath= , SignerPrivateCertFile, Ot if ToolPath is None: ToolPath =3D '' Command =3D '' - Command =3D Command + '"{Path}" '.format (Path =3D os.path.join (ToolP= ath, 'openssl')) + Command =3D Command + \ + '"{Path}" '.format(Path=3Dos.path.join(ToolPath, 'openssl')) Command =3D Command + 'smime -verify -inform DER ' - Command =3D Command + '-content {Content} -CAfile "{Public}"'.format (= Content =3D TempFileName, Public =3D TrustedPublicCertFile) + Command =3D Command + '-content {Content} -CAfile "{Public}"'.format( + Content=3DTempFileName, Public=3DTrustedPublicCertFile) if Verbose: - print (Command) + print(Command) =20 # # Verify signature # try: - Process =3D subprocess.Popen (Command, stdin =3D subprocess.PIPE, = stdout =3D subprocess.PIPE, stderr =3D subprocess.PIPE, shell =3D True) - Result =3D Process.communicate(input =3D CertData) + Process =3D subprocess.Popen(Command, stdin=3Dsubprocess.PIPE, + stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) + Result =3D Process.communicate(input=3DCertData) except: - shutil.rmtree (TempDirectoryName) - raise ValueError ('GenerateCapsule: error: can not run openssl.') + shutil.rmtree(TempDirectoryName) + raise ValueError('GenerateCapsule: error: can not run openssl.') =20 if Process.returncode !=3D 0: - shutil.rmtree (TempDirectoryName) - print (Result[1].decode()) - raise ValueError ('GenerateCapsule: error: openssl failed.') + shutil.rmtree(TempDirectoryName) + print(Result[1].decode()) + raise ValueError('GenerateCapsule: error: openssl failed.') =20 - shutil.rmtree (TempDirectoryName) + shutil.rmtree(TempDirectoryName) return Payload =20 + if __name__ =3D=3D '__main__': def convert_arg_line_to_args(arg_line): for arg in arg_line.split(): @@ -199,234 +216,286 @@ if __name__ =3D=3D '__main__': continue yield arg =20 - def ValidateUnsignedInteger (Argument): + def ValidateUnsignedInteger(Argument): try: - Value =3D int (Argument, 0) + Value =3D int(Argument, 0) except: - Message =3D '{Argument} is not a valid integer value.'.format = (Argument =3D Argument) - raise argparse.ArgumentTypeError (Message) + Message =3D '{Argument} is not a valid integer value.'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) if Value < 0: - Message =3D '{Argument} is a negative value.'.format (Argument= =3D Argument) - raise argparse.ArgumentTypeError (Message) + Message =3D '{Argument} is a negative value.'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) return Value =20 - def ValidateRegistryFormatGuid (Argument): + def ValidateRegistryFormatGuid(Argument): try: - Value =3D uuid.UUID (Argument) + Value =3D uuid.UUID(Argument) except: - Message =3D '{Argument} is not a valid registry format GUID va= lue.'.format (Argument =3D Argument) - raise argparse.ArgumentTypeError (Message) + Message =3D '{Argument} is not a valid registry format GUID va= lue.'.format( + Argument=3DArgument) + raise argparse.ArgumentTypeError(Message) return Value =20 - def ConvertJsonValue (Config, FieldName, Convert, Required =3D True, D= efault =3D None, Open =3D False): + def ConvertJsonValue(Config, FieldName, Convert, Required=3DTrue, Defa= ult=3DNone, Open=3DFalse): if FieldName not in Config: if Required: - print ('GenerateCapsule: error: Payload descriptor invalid= syntax. Could not find {Key} in payload descriptor.'.format(Key =3D FieldN= ame)) - sys.exit (1) + print('GenerateCapsule: error: Payload descriptor invalid = syntax. Could not find {Key} in payload descriptor.'.format( + Key=3DFieldName)) + sys.exit(1) return Default try: - Value =3D Convert (Config[FieldName]) + Value =3D Convert(Config[FieldName]) except: - print ('GenerateCapsule: error: {Key} in payload descriptor ha= s invalid syntax.'.format (Key =3D FieldName)) - sys.exit (1) + print('GenerateCapsule: error: {Key} in payload descriptor has= invalid syntax.'.format( + Key=3DFieldName)) + sys.exit(1) if Open: try: - Value =3D open (Value, "rb") + Value =3D open(Value, "rb") except: - print ('GenerateCapsule: error: can not open file {File}'.= format (File =3D FieldName)) - sys.exit (1) + print('GenerateCapsule: error: can not open file {File}'.f= ormat( + File=3DFieldName)) + sys.exit(1) return Value =20 - def DecodeJsonFileParse (Json): + def DecodeJsonFileParse(Json): if 'Payloads' not in Json: - print ('GenerateCapsule: error "Payloads" section not found in= JSON file {File}'.format (File =3D args.JsonFile.name)) - sys.exit (1) + print('GenerateCapsule: error "Payloads" section not found in = JSON file {File}'.format( + File=3Dargs.JsonFile.name)) + sys.exit(1) for Config in Json['Payloads']: # # Parse fields from JSON # - PayloadFile =3D ConvertJsonValue (Config, 'Pa= yload', os.path.expandvars, Required =3D False) - Guid =3D ConvertJsonValue (Config, 'Gu= id', ValidateRegistryFormatGuid, Required =3D False) - FwVersion =3D ConvertJsonValue (Config, 'Fw= Version', ValidateUnsignedInteger, Required =3D False) - LowestSupportedVersion =3D ConvertJsonValue (Config, 'Lo= westSupportedVersion', ValidateUnsignedInteger, Required =3D False) - HardwareInstance =3D ConvertJsonValue (Config, 'Ha= rdwareInstance', ValidateUnsignedInteger, Required =3D False, Default =3D 0) - MonotonicCount =3D ConvertJsonValue (Config, 'Mo= notonicCount', ValidateUnsignedInteger, Required =3D False, Default =3D 0) - SignToolPfxFile =3D ConvertJsonValue (Config, 'Si= gnToolPfxFile', os.path.expandvars, Required =3D False, Default =3D None, O= pen =3D True) - SignToolSubjectName =3D ConvertJsonValue (Config, 'Si= gnToolSubjectName', os.path.expandvars, Required =3D False, Default =3D Non= e, Open =3D True) - OpenSslSignerPrivateCertFile =3D ConvertJsonValue (Config, 'Op= enSslSignerPrivateCertFile', os.path.expandvars, Required =3D False, Defaul= t =3D None, Open =3D True) - OpenSslOtherPublicCertFile =3D ConvertJsonValue (Config, 'Op= enSslOtherPublicCertFile', os.path.expandvars, Required =3D False, Default = =3D None, Open =3D True) - OpenSslTrustedPublicCertFile =3D ConvertJsonValue (Config, 'Op= enSslTrustedPublicCertFile', os.path.expandvars, Required =3D False, Defaul= t =3D None, Open =3D True) - SigningToolPath =3D ConvertJsonValue (Config, 'Si= gningToolPath', os.path.expandvars, Required =3D False, Default =3D None) - UpdateImageIndex =3D ConvertJsonValue (Config, 'Up= dateImageIndex', ValidateUnsignedInteger, Required =3D False, Default =3D 1) + PayloadFile =3D ConvertJsonValue( + Config, 'Payload', os.path.expandvars, Required=3DFalse) + Guid =3D ConvertJsonValue( + Config, 'Guid', ValidateRegistryFormatGuid, Required=3DFal= se) + FwVersion =3D ConvertJsonValue( + Config, 'FwVersion', ValidateUnsignedInteger, Required=3DF= alse) + LowestSupportedVersion =3D ConvertJsonValue( + Config, 'LowestSupportedVersion', ValidateUnsignedInteger,= Required=3DFalse) + HardwareInstance =3D ConvertJsonValue( + Config, 'HardwareInstance', ValidateUnsignedInteger, Requi= red=3DFalse, Default=3D0) + MonotonicCount =3D ConvertJsonValue( + Config, 'MonotonicCount', ValidateUnsignedInteger, Require= d=3DFalse, Default=3D0) + SignToolPfxFile =3D ConvertJsonValue( + Config, 'SignToolPfxFile', os.path.expandvars, Required=3D= False, Default=3DNone, Open=3DTrue) + SignToolSubjectName =3D ConvertJsonValue( + Config, 'SignToolSubjectName', os.path.expandvars, Require= d=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslSignerPrivateCertFile =3D ConvertJsonValue( + Config, 'OpenSslSignerPrivateCertFile', os.path.expandvars= , Required=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslOtherPublicCertFile =3D ConvertJsonValue( + Config, 'OpenSslOtherPublicCertFile', os.path.expandvars, = Required=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslTrustedPublicCertFile =3D ConvertJsonValue( + Config, 'OpenSslTrustedPublicCertFile', os.path.expandvars= , Required=3DFalse, Default=3DNone, Open=3DTrue) + SigningToolPath =3D ConvertJsonValue( + Config, 'SigningToolPath', os.path.expandvars, Required=3D= False, Default=3DNone) + UpdateImageIndex =3D ConvertJsonValue( + Config, 'UpdateImageIndex', ValidateUnsignedInteger, Requi= red=3DFalse, Default=3D1) =20 - PayloadDescriptorList.append (PayloadDescriptor ( - PayloadFile, - Guid, - FwVersion, - LowestSupportedVersion, - MonotonicCount, - HardwareInstance, - UpdateImageIndex, - SignToolPfxFile, - SignToolSubjectName, - OpenSslSignerPrivateCertFile, - OpenSslOtherPublicCertFile, - OpenSslTrustedPublicCertFile, - SigningToolPath - )) + PayloadDescriptorList.append(PayloadDescriptor( + PayloadFile, + Guid, + FwVersion, + LowestSupportedVersion, + MonotonicCount, + HardwareInstance, + UpdateImageIndex, + SignToolPfxFile, + SignToolSubjectName, + OpenSslSignerPrivateCertFile, + OpenSslOtherPublicCertFile, + OpenSslTrustedPublicCertFile, + SigningToolPath + )) =20 - def EncodeJsonFileParse (Json): + def EncodeJsonFileParse(Json): if 'EmbeddedDrivers' not in Json: - print ('GenerateCapsule: warning "EmbeddedDrivers" section not= found in JSON file {File}'.format (File =3D args.JsonFile.name)) + print('GenerateCapsule: warning "EmbeddedDrivers" section not = found in JSON file {File}'.format( + File=3Dargs.JsonFile.name)) else: for Config in Json['EmbeddedDrivers']: - EmbeddedDriverFile =3D ConvertJsonValue(Config, 'Driv= er', os.path.expandvars, Open =3D True) + EmbeddedDriverFile =3D ConvertJsonValue( + Config, 'Driver', os.path.expandvars, Open=3DTrue) # - #Read EmbeddedDriver file + # Read EmbeddedDriver file # try: if args.Verbose: - print ('Read EmbeddedDriver file {File}'.format (F= ile =3D EmbeddedDriverFile.name)) + print('Read EmbeddedDriver file {File}'.format( + File=3DEmbeddedDriverFile.name)) Driver =3D EmbeddedDriverFile.read() except: - print ('GenerateCapsule: error: can not read EmbeddedD= river file {File}'.format (File =3D EmbeddedDriverFile.name)) - sys.exit (1) - EmbeddedDriverDescriptorList.append (Driver) + print('GenerateCapsule: error: can not read EmbeddedDr= iver file {File}'.format( + File=3DEmbeddedDriverFile.name)) + sys.exit(1) + EmbeddedDriverDescriptorList.append(Driver) =20 if 'Payloads' not in Json: - print ('GenerateCapsule: error: "Payloads" section not found i= n JSON file {File}'.format (File =3D args.JsonFile.name)) - sys.exit (1) + print('GenerateCapsule: error: "Payloads" section not found in= JSON file {File}'.format( + File=3Dargs.JsonFile.name)) + sys.exit(1) for Config in Json['Payloads']: # # Parse fields from JSON # - PayloadFile =3D ConvertJsonValue (Config, 'Pa= yload', os.path.expandvars, Open =3D True) - Guid =3D ConvertJsonValue (Config, 'Gu= id', ValidateRegistryFormatGuid) - FwVersion =3D ConvertJsonValue (Config, 'Fw= Version', ValidateUnsignedInteger) - LowestSupportedVersion =3D ConvertJsonValue (Config, 'Lo= westSupportedVersion', ValidateUnsignedInteger) - HardwareInstance =3D ConvertJsonValue (Config, 'Ha= rdwareInstance', ValidateUnsignedInteger, Required =3D False, Default =3D 0) - UpdateImageIndex =3D ConvertJsonValue (Config, 'Up= dateImageIndex', ValidateUnsignedInteger, Required =3D False, Default =3D 1) - MonotonicCount =3D ConvertJsonValue (Config, 'Mo= notonicCount', ValidateUnsignedInteger, Required =3D False, Default =3D 0) - SignToolPfxFile =3D ConvertJsonValue (Config, 'Si= gnToolPfxFile', os.path.expandvars, Required =3D False, Default =3D None, O= pen =3D True) - SignToolSubjectName =3D ConvertJsonValue (Config, 'Si= gnToolSubjectName', os.path.expandvars, Required =3D False, Default =3D Non= e, Open =3D True) - OpenSslSignerPrivateCertFile =3D ConvertJsonValue (Config, 'Op= enSslSignerPrivateCertFile', os.path.expandvars, Required =3D False, Defaul= t =3D None, Open =3D True) - OpenSslOtherPublicCertFile =3D ConvertJsonValue (Config, 'Op= enSslOtherPublicCertFile', os.path.expandvars, Required =3D False, Default = =3D None, Open =3D True) - OpenSslTrustedPublicCertFile =3D ConvertJsonValue (Config, 'Op= enSslTrustedPublicCertFile', os.path.expandvars, Required =3D False, Defaul= t =3D None, Open =3D True) - SigningToolPath =3D ConvertJsonValue (Config, 'Si= gningToolPath', os.path.expandvars, Required =3D False, Default =3D None) - DepexExp =3D ConvertJsonValue (Config, 'De= pendencies', str, Required =3D False, Default =3D None) + PayloadFile =3D ConvertJsonValue( + Config, 'Payload', os.path.expandvars, Open=3DTrue) + Guid =3D ConvertJsonValue(Config, 'Guid', ValidateRegistryForm= atGuid) + FwVersion =3D ConvertJsonValue( + Config, 'FwVersion', ValidateUnsignedInteger) + LowestSupportedVersion =3D ConvertJsonValue( + Config, 'LowestSupportedVersion', ValidateUnsignedInteger) + HardwareInstance =3D ConvertJsonValue( + Config, 'HardwareInstance', ValidateUnsignedInteger, Requi= red=3DFalse, Default=3D0) + UpdateImageIndex =3D ConvertJsonValue( + Config, 'UpdateImageIndex', ValidateUnsignedInteger, Requi= red=3DFalse, Default=3D1) + MonotonicCount =3D ConvertJsonValue( + Config, 'MonotonicCount', ValidateUnsignedInteger, Require= d=3DFalse, Default=3D0) + SignToolPfxFile =3D ConvertJsonValue( + Config, 'SignToolPfxFile', os.path.expandvars, Required=3D= False, Default=3DNone, Open=3DTrue) + SignToolSubjectName =3D ConvertJsonValue( + Config, 'SignToolSubjectName', os.path.expandvars, Require= d=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslSignerPrivateCertFile =3D ConvertJsonValue( + Config, 'OpenSslSignerPrivateCertFile', os.path.expandvars= , Required=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslOtherPublicCertFile =3D ConvertJsonValue( + Config, 'OpenSslOtherPublicCertFile', os.path.expandvars, = Required=3DFalse, Default=3DNone, Open=3DTrue) + OpenSslTrustedPublicCertFile =3D ConvertJsonValue( + Config, 'OpenSslTrustedPublicCertFile', os.path.expandvars= , Required=3DFalse, Default=3DNone, Open=3DTrue) + SigningToolPath =3D ConvertJsonValue( + Config, 'SigningToolPath', os.path.expandvars, Required=3D= False, Default=3DNone) + DepexExp =3D ConvertJsonValue( + Config, 'Dependencies', str, Required=3DFalse, Default=3DN= one) =20 # # Read binary input file # try: if args.Verbose: - print ('Read binary input file {File}'.format (File = =3D PayloadFile.name)) + print('Read binary input file {File}'.format( + File=3DPayloadFile.name)) Payload =3D PayloadFile.read() - PayloadFile.close () + PayloadFile.close() except: - print ('GenerateCapsule: error: can not read binary input = file {File}'.format (File =3D PayloadFile.name)) - sys.exit (1) - PayloadDescriptorList.append (PayloadDescriptor ( - Payload, - Guid, - FwVersion, - LowestSupportedVersion, - MonotonicCount, - HardwareInstance, - UpdateImageIndex, - SignToolPfxFile, - SignToolSubjectName, - OpenSslSignerPrivateCertFile, - OpenSslOtherPublicCertFile, - OpenSslTrustedPublicCertFile, - SigningToolPath, - DepexExp - )) + print('GenerateCapsule: error: can not read binary input f= ile {File}'.format( + File=3DPayloadFile.name)) + sys.exit(1) + PayloadDescriptorList.append(PayloadDescriptor( + Payload, + Guid, + FwVersion, + LowestSupportedVersion, + MonotonicCount, + HardwareInstance, + UpdateImageIndex, + SignToolPfxFile, + SignToolSubjectName, + OpenSslSignerPrivateCertFile, + OpenSslOtherPublicCertFile, + OpenSslTrustedPublicCertFile, + SigningToolPath, + DepexExp + )) =20 - def GenerateOutputJson (PayloadJsonDescriptorList): + def GenerateOutputJson(PayloadJsonDescriptorList): PayloadJson =3D { - "Payloads" : [ - { - "Guid": str(PayloadDescriptor.Guid).uppe= r(), - "FwVersion": str(PayloadDescriptor.FwVer= sion), - "LowestSupportedVersion": str(PayloadDes= criptor.LowestSupportedVersion), - "MonotonicCount": str(PayloadDescriptor.= MonotonicCount), - "Payload": PayloadDescriptor.Payload, - "HardwareInstance": str(PayloadDescripto= r.HardwareInstance), - "UpdateImageIndex": str(PayloadDescripto= r.UpdateImageIndex), - "SignToolPfxFile": str(PayloadDescriptor= .SignToolPfxFile), - "SignToolSubjectName": str(PayloadDescri= ptor.SignToolSubjectName), - "OpenSslSignerPrivateCertFile": str(Payl= oadDescriptor.OpenSslSignerPrivateCertFile), - "OpenSslOtherPublicCertFile": str(Payloa= dDescriptor.OpenSslOtherPublicCertFile), - "OpenSslTrustedPublicCertFile": str(Payl= oadDescriptor.OpenSslTrustedPublicCertFile), - "SigningToolPath": str(PayloadDescriptor= .SigningToolPath), - "Dependencies" : str(PayloadDescriptor.D= epexExp) - }for PayloadDescriptor in PayloadJsonDescrip= torList - ] - } + "Payloads": [ + { + "Guid": str(PayloadDescriptor.Guid).upper(), + "FwVersion": str(PayloadDescriptor.FwVersion), + "LowestSupportedVersion": str(PayloadDescriptor.Lowest= SupportedVersion), + "MonotonicCount": str(PayloadDescriptor.MonotonicCount= ), + "Payload": PayloadDescriptor.Payload, + "HardwareInstance": str(PayloadDescriptor.HardwareInst= ance), + "UpdateImageIndex": str(PayloadDescriptor.UpdateImageI= ndex), + "SignToolPfxFile": str(PayloadDescriptor.SignToolPfxFi= le), + "SignToolSubjectName": str(PayloadDescriptor.SignToolS= ubjectName), + "OpenSslSignerPrivateCertFile": str(PayloadDescriptor.= OpenSslSignerPrivateCertFile), + "OpenSslOtherPublicCertFile": str(PayloadDescriptor.Op= enSslOtherPublicCertFile), + "OpenSslTrustedPublicCertFile": str(PayloadDescriptor.= OpenSslTrustedPublicCertFile), + "SigningToolPath": str(PayloadDescriptor.SigningToolPa= th), + "Dependencies": str(PayloadDescriptor.DepexExp) + }for PayloadDescriptor in PayloadJsonDescriptorList + ] + } OutputJsonFile =3D args.OutputFile.name + '.json' if 'Payloads' in PayloadJson: - PayloadSection =3D PayloadJson ['Payloads'] + PayloadSection =3D PayloadJson['Payloads'] Index =3D 0 for PayloadField in PayloadSection: if PayloadJsonDescriptorList[Index].SignToolPfxFile is None: - del PayloadField ['SignToolPfxFile'] + del PayloadField['SignToolPfxFile'] if PayloadJsonDescriptorList[Index].SignToolSubjectName is Non= e: - del PayloadField ['SignToolSubjectName'] + del PayloadField['SignToolSubjectName'] if PayloadJsonDescriptorList[Index].OpenSslSignerPrivateCertFi= le is None: - del PayloadField ['OpenSslSignerPrivateCertFile'] + del PayloadField['OpenSslSignerPrivateCertFile'] if PayloadJsonDescriptorList[Index].OpenSslOtherPublicCertFile= is None: - del PayloadField ['OpenSslOtherPublicCertFile'] + del PayloadField['OpenSslOtherPublicCertFile'] if PayloadJsonDescriptorList[Index].OpenSslTrustedPublicCertFi= le is None: - del PayloadField ['OpenSslTrustedPublicCertFile'] + del PayloadField['OpenSslTrustedPublicCertFile'] if PayloadJsonDescriptorList[Index].SigningToolPath is None: - del PayloadField ['SigningToolPath'] + del PayloadField['SigningToolPath'] Index =3D Index + 1 - Result =3D json.dumps (PayloadJson, indent=3D4, sort_keys=3DTrue, = separators=3D(',', ': ')) - with open (OutputJsonFile, 'w') as OutputFile: - OutputFile.write (Result) + Result =3D json.dumps(PayloadJson, indent=3D4, + sort_keys=3DTrue, separators=3D(',', ': ')) + with open(OutputJsonFile, 'w') as OutputFile: + OutputFile.write(Result) =20 - def CheckArgumentConflict (args): + def CheckArgumentConflict(args): if args.Encode: if args.InputFile: - print ('GenerateCapsule: error: Argument InputFile conflic= ts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument InputFile conflicts = with Argument -j') + sys.exit(1) if args.EmbeddedDriver: - print ('GenerateCapsule: error: Argument --embedded-driver= conflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --embedded-driver co= nflicts with Argument -j') + sys.exit(1) if args.Guid: - print ('GenerateCapsule: error: Argument --guid conflicts with= Argument -j') - sys.exit (1) + print('GenerateCapsule: error: Argument --guid conflicts with = Argument -j') + sys.exit(1) if args.FwVersion: - print ('GenerateCapsule: error: Argument --fw-version conflict= s with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --fw-version conflicts w= ith Argument -j') + sys.exit(1) if args.LowestSupportedVersion: - print ('GenerateCapsule: error: Argument --lsv conflicts with = Argument -j') - sys.exit (1) + print('GenerateCapsule: error: Argument --lsv conflicts with A= rgument -j') + sys.exit(1) if args.MonotonicCount: - print ('GenerateCapsule: error: Argument --monotonic-count con= flicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --monotonic-count confli= cts with Argument -j') + sys.exit(1) if args.HardwareInstance: - print ('GenerateCapsule: error: Argument --hardware-instance c= onflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --hardware-instance conf= licts with Argument -j') + sys.exit(1) if args.SignToolPfxFile: - print ('GenerateCapsule: error: Argument --pfx-file conflicts = with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --pfx-file conflicts wit= h Argument -j') + sys.exit(1) if args.SignToolSubjectName: - print ('GenerateCapsule: error: Argument --SubjectName conflic= ts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --SubjectName conflicts = with Argument -j') + sys.exit(1) if args.OpenSslSignerPrivateCertFile: - print ('GenerateCapsule: error: Argument --signer-private-cert= conflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --signer-private-cert co= nflicts with Argument -j') + sys.exit(1) if args.OpenSslOtherPublicCertFile: - print ('GenerateCapsule: error: Argument --other-public-cert c= onflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --other-public-cert conf= licts with Argument -j') + sys.exit(1) if args.OpenSslTrustedPublicCertFile: - print ('GenerateCapsule: error: Argument --trusted-public-cert= conflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --trusted-public-cert co= nflicts with Argument -j') + sys.exit(1) if args.SigningToolPath: - print ('GenerateCapsule: error: Argument --signing-tool-path c= onflicts with Argument -j') - sys.exit (1) + print( + 'GenerateCapsule: error: Argument --signing-tool-path conf= licts with Argument -j') + sys.exit(1) =20 class PayloadDescriptor (object): def __init__(self, @@ -434,90 +503,108 @@ if __name__ =3D=3D '__main__': Guid, FwVersion, LowestSupportedVersion, - MonotonicCount =3D 0, - HardwareInstance =3D 0, - UpdateImageIndex =3D 1, - SignToolPfxFile =3D None, - SignToolSubjectName =3D None, - OpenSslSignerPrivateCertFile =3D None, - OpenSslOtherPublicCertFile =3D None, - OpenSslTrustedPublicCertFile =3D None, - SigningToolPath =3D None, - DepexExp =3D None + MonotonicCount=3D0, + HardwareInstance=3D0, + UpdateImageIndex=3D1, + SignToolPfxFile=3DNone, + SignToolSubjectName=3DNone, + OpenSslSignerPrivateCertFile=3DNone, + OpenSslOtherPublicCertFile=3DNone, + OpenSslTrustedPublicCertFile=3DNone, + SigningToolPath=3DNone, + DepexExp=3DNone ): - self.Payload =3D Payload - self.Guid =3D Guid - self.FwVersion =3D FwVersion - self.LowestSupportedVersion =3D LowestSupportedVersion - self.MonotonicCount =3D MonotonicCount - self.HardwareInstance =3D HardwareInstance - self.UpdateImageIndex =3D UpdateImageIndex - self.SignToolPfxFile =3D SignToolPfxFile - self.SignToolSubjectName =3D SignToolSubjectName + self.Payload =3D Payload + self.Guid =3D Guid + self.FwVersion =3D FwVersion + self.LowestSupportedVersion =3D LowestSupportedVersion + self.MonotonicCount =3D MonotonicCount + self.HardwareInstance =3D HardwareInstance + self.UpdateImageIndex =3D UpdateImageIndex + self.SignToolPfxFile =3D SignToolPfxFile + self.SignToolSubjectName =3D SignToolSubjectName self.OpenSslSignerPrivateCertFile =3D OpenSslSignerPrivateCert= File - self.OpenSslOtherPublicCertFile =3D OpenSslOtherPublicCertFi= le + self.OpenSslOtherPublicCertFile =3D OpenSslOtherPublicCertFile self.OpenSslTrustedPublicCertFile =3D OpenSslTrustedPublicCert= File - self.SigningToolPath =3D SigningToolPath - self.DepexExp =3D DepexExp + self.SigningToolPath =3D SigningToolPath + self.DepexExp =3D DepexExp =20 self.UseSignTool =3D (self.SignToolPfxFile is not None or self.SignToolSubjectName is not None) - self.UseOpenSsl =3D (self.OpenSslSignerPrivateCertFile is not= None and - self.OpenSslOtherPublicCertFile is not Non= e and - self.OpenSslTrustedPublicCertFile is not N= one) - self.AnyOpenSsl =3D (self.OpenSslSignerPrivateCertFile is not= None or - self.OpenSslOtherPublicCertFile is not Non= e or - self.OpenSslTrustedPublicCertFile is not N= one) + self.UseOpenSsl =3D (self.OpenSslSignerPrivateCertFile is not = None and + self.OpenSslOtherPublicCertFile is not None= and + self.OpenSslTrustedPublicCertFile is not No= ne) + self.AnyOpenSsl =3D (self.OpenSslSignerPrivateCertFile is not = None or + self.OpenSslOtherPublicCertFile is not None= or + self.OpenSslTrustedPublicCertFile is not No= ne) self.UseDependency =3D self.DepexExp is not None =20 def Validate(self, args): if self.UseSignTool and self.AnyOpenSsl: - raise argparse.ArgumentTypeError ('Providing both signtool= and OpenSSL options is not supported') + raise argparse.ArgumentTypeError( + 'Providing both signtool and OpenSSL options is not su= pported') if not self.UseSignTool and not self.UseOpenSsl and self.AnyOp= enSsl: if args.JsonFile: - raise argparse.ArgumentTypeError ('the following JSON = fields are required for OpenSSL: OpenSslSignerPrivateCertFile, OpenSslOther= PublicCertFile, OpenSslTrustedPublicCertFile') + raise argparse.ArgumentTypeError( + 'the following JSON fields are required for OpenSS= L: OpenSslSignerPrivateCertFile, OpenSslOtherPublicCertFile, OpenSslTrusted= PublicCertFile') else: - raise argparse.ArgumentTypeError ('the following optio= ns are required for OpenSSL: --signer-private-cert, --other-public-cert, --= trusted-public-cert') + raise argparse.ArgumentTypeError( + 'the following options are required for OpenSSL: -= -signer-private-cert, --other-public-cert, --trusted-public-cert') if self.UseSignTool and platform.system() !=3D 'Windows': - raise argparse.ArgumentTypeError ('Use of signtool is not = supported on this operating system.') + raise argparse.ArgumentTypeError( + 'Use of signtool is not supported on this operating sy= stem.') if args.Encode: if self.FwVersion is None or self.LowestSupportedVersion i= s None: if args.JsonFile: - raise argparse.ArgumentTypeError ('the following J= SON fields are required: FwVersion, LowestSupportedVersion') + raise argparse.ArgumentTypeError( + 'the following JSON fields are required: FwVer= sion, LowestSupportedVersion') else: - raise argparse.ArgumentTypeError ('the following o= ptions are required: --fw-version, --lsv') + raise argparse.ArgumentTypeError( + 'the following options are required: --fw-vers= ion, --lsv') if self.FwVersion > 0xFFFFFFFF: if args.JsonFile: - raise argparse.ArgumentTypeError ('JSON field FwVe= rsion must be an integer in range 0x0..0xffffffff') + raise argparse.ArgumentTypeError( + 'JSON field FwVersion must be an integer in ra= nge 0x0..0xffffffff') else: - raise argparse.ArgumentTypeError ('--fw-version mu= st be an integer in range 0x0..0xffffffff') + raise argparse.ArgumentTypeError( + '--fw-version must be an integer in range 0x0.= .0xffffffff') if self.LowestSupportedVersion > 0xFFFFFFFF: if args.JsonFile: - raise argparse.ArgumentTypeError ('JSON field Lowe= stSupportedVersion must be an integer in range 0x0..0xffffffff') + raise argparse.ArgumentTypeError( + 'JSON field LowestSupportedVersion must be an = integer in range 0x0..0xffffffff') else: - raise argparse.ArgumentTypeError ('--lsv must be a= n integer in range 0x0..0xffffffff') + raise argparse.ArgumentTypeError( + '--lsv must be an integer in range 0x0..0xffff= ffff') =20 if args.Encode: if self.Guid is None: if args.JsonFile: - raise argparse.ArgumentTypeError ('the following J= SON field is required: Guid') + raise argparse.ArgumentTypeError( + 'the following JSON field is required: Guid') else: - raise argparse.ArgumentTypeError ('the following o= ption is required: --guid') + raise argparse.ArgumentTypeError( + 'the following option is required: --guid') if self.HardwareInstance > 0xFFFFFFFFFFFFFFFF: if args.JsonFile: - raise argparse.ArgumentTypeError ('JSON field Hard= wareInstance must be an integer in range 0x0..0xffffffffffffffff') + raise argparse.ArgumentTypeError( + 'JSON field HardwareInstance must be an intege= r in range 0x0..0xffffffffffffffff') else: - raise argparse.ArgumentTypeError ('--hardware-inst= ance must be an integer in range 0x0..0xffffffffffffffff') + raise argparse.ArgumentTypeError( + '--hardware-instance must be an integer in ran= ge 0x0..0xffffffffffffffff') if self.MonotonicCount > 0xFFFFFFFFFFFFFFFF: if args.JsonFile: - raise argparse.ArgumentTypeError ('JSON field Mono= tonicCount must be an integer in range 0x0..0xffffffffffffffff') + raise argparse.ArgumentTypeError( + 'JSON field MonotonicCount must be an integer = in range 0x0..0xffffffffffffffff') else: - raise argparse.ArgumentTypeError ('--monotonic-cou= nt must be an integer in range 0x0..0xffffffffffffffff') - if self.UpdateImageIndex >0xFF: + raise argparse.ArgumentTypeError( + '--monotonic-count must be an integer in range= 0x0..0xffffffffffffffff') + if self.UpdateImageIndex > 0xFF: if args.JsonFile: - raise argparse.ArgumentTypeError ('JSON field Upda= teImageIndex must be an integer in range 0x0..0xff') + raise argparse.ArgumentTypeError( + 'JSON field UpdateImageIndex must be an intege= r in range 0x0..0xff') else: - raise argparse.ArgumentTypeError ('--update-image-= index must be an integer in range 0x0..0xff') + raise argparse.ArgumentTypeError( + '--update-image-index must be an integer in ra= nge 0x0..0xff') =20 if self.UseSignTool: if self.SignToolPfxFile is not None: @@ -528,7 +615,7 @@ if __name__ =3D=3D '__main__': self.OpenSslOtherPublicCertFile.close() self.OpenSslTrustedPublicCertFile.close() self.OpenSslSignerPrivateCertFile =3D self.OpenSslSignerPr= ivateCertFile.name - self.OpenSslOtherPublicCertFile =3D self.OpenSslOtherPub= licCertFile.name + self.OpenSslOtherPublicCertFile =3D self.OpenSslOtherPubli= cCertFile.name self.OpenSslTrustedPublicCertFile =3D self.OpenSslTrustedP= ublicCertFile.name =20 # @@ -537,487 +624,534 @@ if __name__ =3D=3D '__main__': if args.Encode: if 'PersistAcrossReset' not in args.CapsuleFlag: if 'InitiateReset' in args.CapsuleFlag: - raise argparse.ArgumentTypeError ('--capflag Initi= ateReset also requires --capflag PersistAcrossReset') + raise argparse.ArgumentTypeError( + '--capflag InitiateReset also requires --capfl= ag PersistAcrossReset') if args.CapsuleOemFlag > 0xFFFF: - raise argparse.ArgumentTypeError ('--capoemflag must b= e an integer between 0x0000 and 0xffff') + raise argparse.ArgumentTypeError( + '--capoemflag must be an integer between 0x0000 an= d 0xffff') =20 return True =20 - - def Encode (PayloadDescriptorList, EmbeddedDriverDescriptorList, Buffe= r): + def Encode(PayloadDescriptorList, EmbeddedDriverDescriptorList, Buffer= ): if args.JsonFile: CheckArgumentConflict(args) try: - Json =3D json.loads (args.JsonFile.read ()) + Json =3D json.loads(args.JsonFile.read()) except: - print ('GenerateCapsule: error: {JSONFile} loads failure. = '.format (JSONFile =3D args.JsonFile)) - sys.exit (1) + print('GenerateCapsule: error: {JSONFile} loads failure. '= .format( + JSONFile=3Dargs.JsonFile)) + sys.exit(1) EncodeJsonFileParse(Json) else: for Driver in args.EmbeddedDriver: - EmbeddedDriverDescriptorList.append (Driver.read()) - PayloadDescriptorList.append (PayloadDescriptor ( - Buffer, - args.Guid, - args.FwVersion, - args.LowestSupportedVersion, - args.MonotonicCount, - args.HardwareInstance, - args.UpdateImageIndex, - args.SignToolPfxFile, - args.SignToolSubjectName, - args.OpenSslSignerPrivateCertF= ile, - args.OpenSslOtherPublicCertFil= e, - args.OpenSslTrustedPublicCertF= ile, - args.SigningToolPath, - None - )) + EmbeddedDriverDescriptorList.append(Driver.read()) + PayloadDescriptorList.append(PayloadDescriptor( + Buffer, + args.Guid, + args.FwVersion, + args.LowestSupportedVersion, + args.MonotonicCount, + args.HardwareInstance, + args.UpdateImageIndex, + args.SignToolPfxFile, + args.SignToolSubjectName, + args.OpenSslSignerPrivateCertFile, + args.OpenSslOtherPublicCertFile, + args.OpenSslTrustedPublicCertFile, + args.SigningToolPath, + None + )) for SinglePayloadDescriptor in PayloadDescriptorList: try: - SinglePayloadDescriptor.Validate (args) + SinglePayloadDescriptor.Validate(args) except Exception as Msg: - print ('GenerateCapsule: error:' + str(Msg)) - sys.exit (1) + print('GenerateCapsule: error:' + str(Msg)) + sys.exit(1) for SinglePayloadDescriptor in PayloadDescriptorList: ImageCapsuleSupport =3D 0x0000000000000000 Result =3D SinglePayloadDescriptor.Payload try: - FmpPayloadHeader.FwVersion =3D SinglePayloadD= escriptor.FwVersion + FmpPayloadHeader.FwVersion =3D SinglePayloadDescriptor.FwV= ersion FmpPayloadHeader.LowestSupportedVersion =3D SinglePayloadD= escriptor.LowestSupportedVersion - FmpPayloadHeader.Payload =3D SinglePayloadD= escriptor.Payload - Result =3D FmpPayloadHeader.Encode () + FmpPayloadHeader.Payload =3D SinglePayloadDescriptor.Paylo= ad + Result =3D FmpPayloadHeader.Encode() if args.Verbose: - FmpPayloadHeader.DumpInfo () + FmpPayloadHeader.DumpInfo() except: - print ('GenerateCapsule: error: can not encode FMP Payload= Header') - sys.exit (1) + print('GenerateCapsule: error: can not encode FMP Payload = Header') + sys.exit(1) if SinglePayloadDescriptor.UseDependency: CapsuleDependency.Payload =3D Result CapsuleDependency.DepexExp =3D SinglePayloadDescriptor.Dep= exExp - ImageCapsuleSupport |=3D FmpCapsuleHeader.CAPSULE_S= UPPORT_DEPENDENCY - Result =3D CapsuleDependency.Encode () + ImageCapsuleSupport |=3D FmpCapsuleHeader.CAPSULE_SUPPORT_= DEPENDENCY + Result =3D CapsuleDependency.Encode() if args.Verbose: - CapsuleDependency.DumpInfo () + CapsuleDependency.DumpInfo() if SinglePayloadDescriptor.UseOpenSsl or SinglePayloadDescript= or.UseSignTool: # # Sign image with 64-bit MonotonicCount appended to end of= image # try: if SinglePayloadDescriptor.UseSignTool: - CertData =3D SignPayloadSignTool ( - Result + struct.pack (' 0: - Result =3D FmpCapsuleHeader.Decode (Result) + Result =3D UefiCapsuleHeader.Decode(Buffer) + if len(Result) > 0: + Result =3D FmpCapsuleHeader.Decode(Result) if args.JsonFile: - if FmpCapsuleHeader.PayloadItemCount !=3D len (Payload= DescriptorList): + if FmpCapsuleHeader.PayloadItemCount !=3D len(PayloadD= escriptorList): CapsulePayloadNum =3D FmpCapsuleHeader.PayloadItem= Count - JsonPayloadNum =3D len (PayloadDescriptorList) - print ('GenerateCapsule: Decode error: {JsonPayloa= dNumber} payloads in JSON file {File} and {CapsulePayloadNumber} payloads i= n Capsule {CapsuleName}'.format (JsonPayloadNumber =3D JsonPayloadNum, File= =3D args.JsonFile.name, CapsulePayloadNumber =3D CapsulePayloadNum, Capsul= eName =3D args.InputFile.name)) - sys.exit (1) - for Index in range (0, FmpCapsuleHeader.PayloadItemCou= nt): - if Index < len (PayloadDescriptorList): - GUID =3D FmpCapsuleHeader.GetFmpCapsuleImageHe= ader (Index).UpdateImageTypeId - HardwareInstance =3D FmpCapsuleHeader.GetFmpCa= psuleImageHeader (Index).UpdateHardwareInstance - UpdateImageIndex =3D FmpCapsuleHeader.GetFmpCa= psuleImageHeader (Index).UpdateImageIndex + JsonPayloadNum =3D len(PayloadDescriptorList) + print('GenerateCapsule: Decode error: {JsonPayload= Number} payloads in JSON file {File} and {CapsulePayloadNumber} payloads in= Capsule {CapsuleName}'.format( + JsonPayloadNumber=3DJsonPayloadNum, File=3Darg= s.JsonFile.name, CapsulePayloadNumber=3DCapsulePayloadNum, CapsuleName=3Dar= gs.InputFile.name)) + sys.exit(1) + for Index in range(0, FmpCapsuleHeader.PayloadItemCoun= t): + if Index < len(PayloadDescriptorList): + GUID =3D FmpCapsuleHeader.GetFmpCapsuleImageHe= ader( + Index).UpdateImageTypeId + HardwareInstance =3D FmpCapsuleHeader.GetFmpCa= psuleImageHeader( + Index).UpdateHardwareInstance + UpdateImageIndex =3D FmpCapsuleHeader.GetFmpCa= psuleImageHeader( + Index).UpdateImageIndex if PayloadDescriptorList[Index].Guid !=3D GUID= or PayloadDescriptorList[Index].HardwareInstance !=3D HardwareInstance: - print ('GenerateCapsule: Decode error: Gui= d or HardwareInstance pair in input JSON file {File} does not match the pay= load {PayloadIndex} in Capsule {InputCapsule}'.format (File =3D args.JsonFi= le.name, PayloadIndex =3D Index + 1, InputCapsule =3D args.InputFile.name)) - sys.exit (1) - PayloadDescriptorList[Index].Payload =3D FmpCa= psuleHeader.GetFmpCapsuleImageHeader (Index).Payload - DecodeJsonOutput =3D args.OutputFile.name + '.= Payload.{Index:d}.bin'.format (Index =3D Index + 1) - PayloadJsonDescriptorList.append (PayloadDescr= iptor ( - DecodeJson= Output, - GUID, - None, - None, - None, - HardwareIn= stance, - UpdateImag= eIndex, - PayloadDes= criptorList[Index].SignToolPfxFile, - PayloadDes= criptorList[Index].SignToolSubjectName, - PayloadDes= criptorList[Index].OpenSslSignerPrivateCertFile, - PayloadDes= criptorList[Index].OpenSslOtherPublicCertFile, - PayloadDes= criptorList[Index].OpenSslTrustedPublicCertFile, - PayloadDes= criptorList[Index].SigningToolPath, - None - )) + print('GenerateCapsule: Decode error: Guid= or HardwareInstance pair in input JSON file {File} does not match the payl= oad {PayloadIndex} in Capsule {InputCapsule}'.format( + File=3Dargs.JsonFile.name, PayloadInde= x=3DIndex + 1, InputCapsule=3Dargs.InputFile.name)) + sys.exit(1) + PayloadDescriptorList[Index].Payload =3D FmpCa= psuleHeader.GetFmpCapsuleImageHeader( + Index).Payload + DecodeJsonOutput =3D args.OutputFile.name + \ + '.Payload.{Index:d}.bin'.format( + Index=3DIndex + 1) + PayloadJsonDescriptorList.append(PayloadDescri= ptor( + DecodeJsonOutput, + GUID, + None, + None, + None, + HardwareInstance, + UpdateImageIndex, + PayloadDescriptorList[Index].SignToolPfxFi= le, + PayloadDescriptorList[Index].SignToolSubje= ctName, + PayloadDescriptorList[Index].OpenSslSigner= PrivateCertFile, + PayloadDescriptorList[Index].OpenSslOtherP= ublicCertFile, + PayloadDescriptorList[Index].OpenSslTruste= dPublicCertFile, + PayloadDescriptorList[Index].SigningToolPa= th, + None + )) else: - PayloadDescriptorList[0].Payload =3D FmpCapsuleHeader.= GetFmpCapsuleImageHeader (0).Payload - for Index in range (0, FmpCapsuleHeader.PayloadItemCou= nt): + PayloadDescriptorList[0].Payload =3D FmpCapsuleHeader.= GetFmpCapsuleImageHeader( + 0).Payload + for Index in range(0, FmpCapsuleHeader.PayloadItemCoun= t): if Index > 0: - PayloadDecodeFile =3D FmpCapsuleHeader.GetFmpC= apsuleImageHeader (Index).Payload - PayloadDescriptorList.append (PayloadDescripto= r (PayloadDecodeFile, - None, - None, - None, - None, - None, - None, - None, - None, - None, - None, - None, - None - )) - GUID =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader= (Index).UpdateImageTypeId - HardwareInstance =3D FmpCapsuleHeader.GetFmpCapsul= eImageHeader (Index).UpdateHardwareInstance - UpdateImageIndex =3D FmpCapsuleHeader.GetFmpCapsul= eImageHeader (Index).UpdateImageIndex - DecodeJsonOutput =3D args.OutputFile.name + '.Payl= oad.{Index:d}.bin'.format (Index =3D Index + 1) - PayloadJsonDescriptorList.append (PayloadDescripto= r ( - DecodeJsonOutp= ut, - GUID, - None, - None, - None, - HardwareInstan= ce, - UpdateImageInd= ex, - PayloadDescrip= torList[Index].SignToolPfxFile, - PayloadDescrip= torList[Index].SignToolSubjectName, - PayloadDescrip= torList[Index].OpenSslSignerPrivateCertFile, - PayloadDescrip= torList[Index].OpenSslOtherPublicCertFile, - PayloadDescrip= torList[Index].OpenSslTrustedPublicCertFile, - PayloadDescrip= torList[Index].SigningToolPath, - None - )) + PayloadDecodeFile =3D FmpCapsuleHeader.GetFmpC= apsuleImageHeader( + Index).Payload + PayloadDescriptorList.append(PayloadDescriptor= (PayloadDecodeFile, + = None, + = None, + = None, + = None, + = None, + = None, + = None, + = None, + = None, + = None, + = None, + = None + = )) + GUID =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader( + Index).UpdateImageTypeId + HardwareInstance =3D FmpCapsuleHeader.GetFmpCapsul= eImageHeader( + Index).UpdateHardwareInstance + UpdateImageIndex =3D FmpCapsuleHeader.GetFmpCapsul= eImageHeader( + Index).UpdateImageIndex + DecodeJsonOutput =3D args.OutputFile.name + \ + '.Payload.{Index:d}.bin'.format(Index=3DIndex = + 1) + PayloadJsonDescriptorList.append(PayloadDescriptor( + DecodeJsonOutput, + GUID, + None, + None, + None, + HardwareInstance, + UpdateImageIndex, + PayloadDescriptorList[Index].SignToolPfxFile, + PayloadDescriptorList[Index].SignToolSubjectNa= me, + PayloadDescriptorList[Index].OpenSslSignerPriv= ateCertFile, + PayloadDescriptorList[Index].OpenSslOtherPubli= cCertFile, + PayloadDescriptorList[Index].OpenSslTrustedPub= licCertFile, + PayloadDescriptorList[Index].SigningToolPath, + None + )) JsonIndex =3D 0 for SinglePayloadDescriptor in PayloadDescriptorList: if args.Verbose: - print ('=3D=3D=3D=3D=3D=3D=3D=3D') - UefiCapsuleHeader.DumpInfo () - print ('--------') - FmpCapsuleHeader.DumpInfo () + print('=3D=3D=3D=3D=3D=3D=3D=3D') + UefiCapsuleHeader.DumpInfo() + print('--------') + FmpCapsuleHeader.DumpInfo() if FmpAuthHeader.IsSigned(SinglePayloadDescriptor.Payl= oad): if not SinglePayloadDescriptor.UseOpenSsl and not = SinglePayloadDescriptor.UseSignTool: - print ('GenerateCapsule: decode warning: can n= ot verify singed payload without cert or pfx file. Index =3D {Index}'.forma= t (Index =3D JsonIndex + 1)) - SinglePayloadDescriptor.Payload =3D FmpAuthHeader.= Decode (SinglePayloadDescriptor.Payload) + print('GenerateCapsule: decode warning: can no= t verify singed payload without cert or pfx file. Index =3D {Index}'.format( + Index=3DJsonIndex + 1)) + SinglePayloadDescriptor.Payload =3D FmpAuthHeader.= Decode( + SinglePayloadDescriptor.Payload) PayloadJsonDescriptorList[JsonIndex].MonotonicCoun= t =3D FmpAuthHeader.MonotonicCount if args.Verbose: - print ('--------') - FmpAuthHeader.DumpInfo () + print('--------') + FmpAuthHeader.DumpInfo() =20 # # Verify Image with 64-bit MonotonicCount appended= to end of image # try: - if SinglePayloadDescriptor.UseSignTool: - CertData =3D VerifyPayloadSignTool ( - FmpAuthHeader.Payload + struct.= pack (' 0: - FmpCapsuleHeader.Decode (Result) - print ('--------') - FmpCapsuleHeader.DumpInfo () - for Index in range (0, FmpCapsuleHeader.PayloadItemCount): - Result =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader (= Index).Payload + Result =3D UefiCapsuleHeader.Decode(Buffer) + print('=3D=3D=3D=3D=3D=3D=3D=3D') + UefiCapsuleHeader.DumpInfo() + if len(Result) > 0: + FmpCapsuleHeader.Decode(Result) + print('--------') + FmpCapsuleHeader.DumpInfo() + for Index in range(0, FmpCapsuleHeader.PayloadItemCount): + Result =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader( + Index).Payload try: - Result =3D FmpAuthHeader.Decode (Result) - print ('--------') - FmpAuthHeader.DumpInfo () + Result =3D FmpAuthHeader.Decode(Result) + print('--------') + FmpAuthHeader.DumpInfo() except: - print ('--------') - print ('No EFI_FIRMWARE_IMAGE_AUTHENTICATION') + print('--------') + print('No EFI_FIRMWARE_IMAGE_AUTHENTICATION') =20 - PayloadSignature =3D struct.unpack (' @@ -21,30 +21,33 @@ import platform import re import logging from WindowsCapsuleSupportHelper import WindowsCapsuleSupportHelper -from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass +from Common.Uefi.Capsule.FmpCapsuleHeader import FmpCapsuleHeaderClass from Common.Uefi.Capsule.UefiCapsuleHeader import UefiCapsuleHeaderClass =20 # # Globals for help information # -__prog__ =3D 'GenerateWindowsDriver' -__version__ =3D '0.0' -__copyright__ =3D 'Copyright (c) 2019, Intel Corporation. All rights res= erved.' +__prog__ =3D 'GenerateWindowsDriver' +__version__ =3D '0.0' +__copyright__ =3D 'Copyright (c) 2019, Intel Corporation. All rights reser= ved.' __description__ =3D 'Generate Capsule Windows Driver.\n' =20 -def GetCapGuid (InputFile): + +def GetCapGuid(InputFile): with open(InputFile, 'rb') as File: Buffer =3D File.read() try: - Result =3D UefiCapsuleHeader.Decode (Buffer) - if len (Result) > 0: - FmpCapsuleHeader.Decode (Result) - for index in range (0, FmpCapsuleHeader.PayloadItemCount): - Guid =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader (index)= .UpdateImageTypeId + Result =3D UefiCapsuleHeader.Decode(Buffer) + if len(Result) > 0: + FmpCapsuleHeader.Decode(Result) + for index in range(0, FmpCapsuleHeader.PayloadItemCount): + Guid =3D FmpCapsuleHeader.GetFmpCapsuleImageHeader( + index).UpdateImageTypeId return Guid except: - print ('GenerateCapsule: error: can not decode capsule') - sys.exit (1) + print('GenerateCapsule: error: can not decode capsule') + sys.exit(1) + =20 def ArgCheck(args): Version =3D args.CapsuleVersion_DotString.split('.') @@ -53,20 +56,23 @@ def ArgCheck(args): logging.critical("Name invalid: '%s'", args.CapsuleVersion_DotStri= ng) raise ValueError("Name invalid.") for sub in Version: - if int(sub, 16) > 65536: - logging.critical("Name invalid: '%s'", args.CapsuleVersion_Dot= String) + if int(sub, 16) > 65536: + logging.critical("Name invalid: '%s'", + args.CapsuleVersion_DotString) raise ValueError("Name exceed limit 65536.") =20 if not (re.compile(r'[\a-fA-F0-9]*$')).match(args.CapsuleVersion_DotSt= ring): logging.critical("Name invalid: '%s'", args.CapsuleVersion_DotStri= ng) raise ValueError("Name has invalid chars.") =20 + def CapsuleGuidCheck(InputFile, Guid): CapGuid =3D GetCapGuid(InputFile) if (str(Guid).lower() !=3D str(CapGuid)): print('GenerateWindowsDriver error: Different Guid from Capsule') sys.exit(1) =20 + if __name__ =3D=3D '__main__': def convert_arg_line_to_args(arg_line): for arg in arg_line.split(): @@ -74,47 +80,58 @@ if __name__ =3D=3D '__main__': continue yield arg =20 - parser =3D argparse.ArgumentParser ( - prog =3D __prog__, - description =3D __description__ + __copyright__, - conflict_handler =3D 'resolve', - fromfile_prefix_chars =3D '@' - ) + parser =3D argparse.ArgumentParser( + prog=3D__prog__, + description=3D__description__ + __copyright__, + conflict_handler=3D'resolve', + fromfile_prefix_chars=3D'@' + ) parser.convert_arg_line_to_args =3D convert_arg_line_to_args - parser.add_argument("--output-folder", dest =3D 'OutputFolder', help = =3D "firmware resource update driver package output folder.") - parser.add_argument("--product-fmp-guid", dest =3D 'ProductFmpGuid', h= elp =3D "firmware GUID of resource update driver package") - parser.add_argument("--capsuleversion-dotstring", dest =3D 'CapsuleVer= sion_DotString', help =3D "firmware version with date on which update drive= r package is authored") - parser.add_argument("--capsuleversion-hexstring", dest =3D 'CapsuleVer= sion_HexString', help =3D "firmware version in Hex of update driver package= ") - parser.add_argument("--product-fw-provider", dest =3D 'ProductFwProvid= er', help =3D "vendor/provider of entire firmware resource update driver pa= ckage") - parser.add_argument("--product-fw-mfg-name", dest =3D 'ProductFwMfgNam= e', help =3D "manufacturer/vendor of firmware resource update driver packag= e") - parser.add_argument("--product-fw-desc", dest =3D "ProductFwDesc", hel= p =3D "description about resource update driver") - parser.add_argument("--capsule-file-name", dest =3D 'CapsuleFileName',= help =3D"firmware resource image file") - parser.add_argument("--pfx-file", dest =3D 'PfxFile', help =3D "pfx fi= le path used to sign resource update driver") - parser.add_argument("--arch", dest =3D 'Arch', help =3D "supported arc= hitecture:arm/x64/amd64/arm64/aarch64", default =3D 'amd64') - parser.add_argument("--operating-system-string", dest =3D 'OperatingSy= stemString', help =3D "supported operating system:win10/10/10_au/10_rs2/10_= rs3/10_rs4/server10/server2016/serverrs2/serverrs3/serverrs4", default =3D = "win10") + parser.add_argument("--output-folder", dest=3D'OutputFolder', + help=3D"firmware resource update driver package ou= tput folder.") + parser.add_argument("--product-fmp-guid", dest=3D'ProductFmpGuid', + help=3D"firmware GUID of resource update driver pa= ckage") + parser.add_argument("--capsuleversion-dotstring", dest=3D'CapsuleVersi= on_DotString', + help=3D"firmware version with date on which update= driver package is authored") + parser.add_argument("--capsuleversion-hexstring", dest=3D'CapsuleVersi= on_HexString', + help=3D"firmware version in Hex of update driver p= ackage") + parser.add_argument("--product-fw-provider", dest=3D'ProductFwProvider= ', + help=3D"vendor/provider of entire firmware resourc= e update driver package") + parser.add_argument("--product-fw-mfg-name", dest=3D'ProductFwMfgName', + help=3D"manufacturer/vendor of firmware resource u= pdate driver package") + parser.add_argument("--product-fw-desc", dest=3D"ProductFwDesc", + help=3D"description about resource update driver") + parser.add_argument("--capsule-file-name", dest=3D'CapsuleFileName', + help=3D"firmware resource image file") + parser.add_argument("--pfx-file", dest=3D'PfxFile', + help=3D"pfx file path used to sign resource update= driver") + parser.add_argument("--arch", dest=3D'Arch', + help=3D"supported architecture:arm/x64/amd64/arm64= /aarch64", default=3D'amd64') + parser.add_argument("--operating-system-string", dest=3D'OperatingSyst= emString', + help=3D"supported operating system:win10/10/10_au/= 10_rs2/10_rs3/10_rs4/server10/server2016/serverrs2/serverrs3/serverrs4", de= fault=3D"win10") =20 args =3D parser.parse_args() InputFile =3D os.path.join(args.OutputFolder, '') + args.CapsuleFileNa= me - UefiCapsuleHeader =3D UefiCapsuleHeaderClass () - FmpCapsuleHeader =3D FmpCapsuleHeaderClass () + UefiCapsuleHeader =3D UefiCapsuleHeaderClass() + FmpCapsuleHeader =3D FmpCapsuleHeaderClass() CapsuleGuidCheck(InputFile, args.ProductFmpGuid) ArgCheck(args) ProductName =3D os.path.splitext(args.CapsuleFileName)[0] - WindowsDriver =3D WindowsCapsuleSupportHelper () + WindowsDriver =3D WindowsCapsuleSupportHelper() =20 - WindowsDriver.PackageWindowsCapsuleFiles ( - args.OutputFolder, - ProductName, - args.ProductFmpGuid, - args.CapsuleVersion_Dot= String, - args.CapsuleVersion_Hex= String, - args.ProductFwProvider, - args.ProductFwMfgName, - args.ProductFwDesc, - args.CapsuleFileName, - args.PfxFile, - None, - None, - args.Arch, - args.OperatingSystemStr= ing - ) + WindowsDriver.PackageWindowsCapsuleFiles( + args.OutputFolder, + ProductName, + args.ProductFmpGuid, + args.CapsuleVersion_DotString, + args.CapsuleVersion_HexString, + args.ProductFwProvider, + args.ProductFwMfgName, + args.ProductFwDesc, + args.CapsuleFileName, + args.PfxFile, + None, + None, + args.Arch, + args.OperatingSystemString + ) diff --git a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py= b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py index a29ac21ae890..d6b0aa04832c 100644 --- a/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py +++ b/BaseTools/Source/Python/Capsule/WindowsCapsuleSupportHelper.py @@ -21,44 +21,49 @@ from edk2toollib.windows.capsule.inf_generator import I= nfGenerator from edk2toollib.utility_functions import CatalogSignWithSignTool from edk2toollib.windows.locate_tools import FindToolInWinSdk =20 + class WindowsCapsuleSupportHelper(object): =20 - def RegisterHelpers(self, obj): - fp =3D os.path.abspath(__file__) - obj.Register("PackageWindowsCapsuleFiles", WindowsCapsuleSupportHelp= er.PackageWindowsCapsuleFiles, fp) - - - @staticmethod - def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGuid= , CapsuleVersion_DotString, - CapsuleVersion_HexString, ProductFwProvider, ProductFwMfgName, Product= FwDesc, CapsuleFileName, PfxFile=3DNone, PfxPass=3DNone, - Rollback=3DFalse, Arch=3D'amd64', OperatingSystem_String=3D'Win10'): - - logging.debug("CapsulePackage: Create Windows Capsule Files") - - #Make INF - InfFilePath =3D os.path.join(OutputFolder, ProductName + ".inf") - InfTool =3D InfGenerator(ProductName, ProductFwProvider, ProductFmpG= uid, Arch, ProductFwDesc, CapsuleVersion_DotString, CapsuleVersion_HexStrin= g) - InfTool.Manufacturer =3D ProductFwMfgName #optional - ret =3D InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback) - if(ret !=3D 0): - raise Exception("CreateWindowsInf Failed with errorcode %d" % re= t) - - #Make CAT - CatFilePath =3D os.path.realpath(os.path.join(OutputFolder, ProductN= ame + ".cat")) - CatTool =3D CatGenerator(Arch, OperatingSystem_String) - ret =3D CatTool.MakeCat(CatFilePath) - - if(ret !=3D 0): - raise Exception("Creating Cat file Failed with errorcode %d" % r= et) - - if(PfxFile is not None): - #Find Signtool - SignToolPath =3D FindToolInWinSdk("signtool.exe") - if not os.path.exists(SignToolPath): - raise Exception("Can't find signtool on this machine.") - #dev sign the cat file - ret =3D CatalogSignWithSignTool(SignToolPath, CatFilePath, PfxFi= le, PfxPass) - if(ret !=3D 0): - raise Exception("Signing Cat file Failed with errorcode %d" = % ret) - - return ret + def RegisterHelpers(self, obj): + fp =3D os.path.abspath(__file__) + obj.Register("PackageWindowsCapsuleFiles", + WindowsCapsuleSupportHelper.PackageWindowsCapsuleFile= s, fp) + + @staticmethod + def PackageWindowsCapsuleFiles(OutputFolder, ProductName, ProductFmpGu= id, CapsuleVersion_DotString, + CapsuleVersion_HexString, ProductFwProv= ider, ProductFwMfgName, ProductFwDesc, CapsuleFileName, PfxFile=3DNone, Pfx= Pass=3DNone, + Rollback=3DFalse, Arch=3D'amd64', Opera= tingSystem_String=3D'Win10'): + + logging.debug("CapsulePackage: Create Windows Capsule Files") + + # Make INF + InfFilePath =3D os.path.join(OutputFolder, ProductName + ".inf") + InfTool =3D InfGenerator(ProductName, ProductFwProvider, ProductFm= pGuid, + Arch, ProductFwDesc, CapsuleVersion_DotStri= ng, CapsuleVersion_HexString) + InfTool.Manufacturer =3D ProductFwMfgName # optional + ret =3D InfTool.MakeInf(InfFilePath, CapsuleFileName, Rollback) + if(ret !=3D 0): + raise Exception("CreateWindowsInf Failed with errorcode %d" % = ret) + + # Make CAT + CatFilePath =3D os.path.realpath( + os.path.join(OutputFolder, ProductName + ".cat")) + CatTool =3D CatGenerator(Arch, OperatingSystem_String) + ret =3D CatTool.MakeCat(CatFilePath) + + if(ret !=3D 0): + raise Exception("Creating Cat file Failed with errorcode %d" %= ret) + + if(PfxFile is not None): + # Find Signtool + SignToolPath =3D FindToolInWinSdk("signtool.exe") + if not os.path.exists(SignToolPath): + raise Exception("Can't find signtool on this machine.") + # dev sign the cat file + ret =3D CatalogSignWithSignTool( + SignToolPath, CatFilePath, PfxFile, PfxPass) + if(ret !=3D 0): + raise Exception( + "Signing Cat file Failed with errorcode %d" % ret) + + return ret diff --git a/BaseTools/Source/Python/Common/BuildToolError.py b/BaseTools/S= ource/Python/Common/BuildToolError.py index 21549683cd19..2efd364fc4b3 100644 --- a/BaseTools/Source/Python/Common/BuildToolError.py +++ b/BaseTools/Source/Python/Common/BuildToolError.py @@ -1,4 +1,4 @@ -## @file +# @file # Standardized Error Handling infrastructures. # # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
        @@ -34,7 +34,7 @@ OPTION_UNKNOWN_ERROR =3D 0x1FFF =20 PARAMETER_INVALID =3D 0x2000 PARAMETER_MISSING =3D 0x2001 -PARAMETER_UNKNOWN_ERROR =3D0x2FFF +PARAMETER_UNKNOWN_ERROR =3D 0x2FFF =20 FORMAT_INVALID =3D 0x3000 FORMAT_NOT_SUPPORTED =3D 0x3001 @@ -89,72 +89,75 @@ ERROR_STATEMENT =3D 0xFFFD ABORT_ERROR =3D 0xFFFE UNKNOWN_ERROR =3D 0xFFFF =20 -## Error message of each error code +# Error message of each error code gErrorMessage =3D { - FILE_NOT_FOUND : "File/directory not found in workspace", - FILE_OPEN_FAILURE : "File open failure", - FILE_WRITE_FAILURE : "File write failure", - FILE_PARSE_FAILURE : "File parse failure", - FILE_READ_FAILURE : "File read failure", - FILE_CREATE_FAILURE : "File create failure", - FILE_CHECKSUM_FAILURE : "Invalid checksum of file", - FILE_COMPRESS_FAILURE : "File compress failure", - FILE_DECOMPRESS_FAILURE : "File decompress failure", - FILE_MOVE_FAILURE : "File move failure", - FILE_DELETE_FAILURE : "File delete failure", - FILE_COPY_FAILURE : "File copy failure", + FILE_NOT_FOUND: "File/directory not found in workspace", + FILE_OPEN_FAILURE: "File open failure", + FILE_WRITE_FAILURE: "File write failure", + FILE_PARSE_FAILURE: "File parse failure", + FILE_READ_FAILURE: "File read failure", + FILE_CREATE_FAILURE: "File create failure", + FILE_CHECKSUM_FAILURE: "Invalid checksum of file", + FILE_COMPRESS_FAILURE: "File compress failure", + FILE_DECOMPRESS_FAILURE: "File decompress failure", + FILE_MOVE_FAILURE: "File move failure", + FILE_DELETE_FAILURE: "File delete failure", + FILE_COPY_FAILURE: "File copy failure", FILE_POSITIONING_FAILURE: "Failed to seeking position", - FILE_ALREADY_EXIST : "File or directory already exists", - FILE_TYPE_MISMATCH : "Incorrect file type", - FILE_CASE_MISMATCH : "File name case mismatch", - FILE_DUPLICATED : "Duplicated file found", - FILE_UNKNOWN_ERROR : "Unknown error encountered on file", + FILE_ALREADY_EXIST: "File or directory already exists", + FILE_TYPE_MISMATCH: "Incorrect file type", + FILE_CASE_MISMATCH: "File name case mismatch", + FILE_DUPLICATED: "Duplicated file found", + FILE_UNKNOWN_ERROR: "Unknown error encountered on file", =20 - OPTION_UNKNOWN : "Unknown option", - OPTION_MISSING : "Missing option", - OPTION_CONFLICT : "Conflict options", - OPTION_VALUE_INVALID : "Invalid value of option", - OPTION_DEPRECATED : "Deprecated option", - OPTION_NOT_SUPPORTED : "Unsupported option", - OPTION_UNKNOWN_ERROR : "Unknown error when processing options", + OPTION_UNKNOWN: "Unknown option", + OPTION_MISSING: "Missing option", + OPTION_CONFLICT: "Conflict options", + OPTION_VALUE_INVALID: "Invalid value of option", + OPTION_DEPRECATED: "Deprecated option", + OPTION_NOT_SUPPORTED: "Unsupported option", + OPTION_UNKNOWN_ERROR: "Unknown error when processing options", =20 - PARAMETER_INVALID : "Invalid parameter", - PARAMETER_MISSING : "Missing parameter", - PARAMETER_UNKNOWN_ERROR : "Unknown error in parameters", + PARAMETER_INVALID: "Invalid parameter", + PARAMETER_MISSING: "Missing parameter", + PARAMETER_UNKNOWN_ERROR: "Unknown error in parameters", =20 - FORMAT_INVALID : "Invalid syntax/format", - FORMAT_NOT_SUPPORTED : "Not supported syntax/format", - FORMAT_UNKNOWN : "Unknown format", - FORMAT_UNKNOWN_ERROR : "Unknown error in syntax/format ", + FORMAT_INVALID: "Invalid syntax/format", + FORMAT_NOT_SUPPORTED: "Not supported syntax/format", + FORMAT_UNKNOWN: "Unknown format", + FORMAT_UNKNOWN_ERROR: "Unknown error in syntax/format ", =20 - RESOURCE_NOT_AVAILABLE : "Not available", - RESOURCE_ALLOCATE_FAILURE : "Allocate failure", - RESOURCE_FULL : "Full", - RESOURCE_OVERFLOW : "Overflow", - RESOURCE_UNDERRUN : "Underrun", - RESOURCE_UNKNOWN_ERROR : "Unknown error", + RESOURCE_NOT_AVAILABLE: "Not available", + RESOURCE_ALLOCATE_FAILURE: "Allocate failure", + RESOURCE_FULL: "Full", + RESOURCE_OVERFLOW: "Overflow", + RESOURCE_UNDERRUN: "Underrun", + RESOURCE_UNKNOWN_ERROR: "Unknown error", =20 - ATTRIBUTE_NOT_AVAILABLE : "Not available", - ATTRIBUTE_GET_FAILURE : "Failed to retrieve", - ATTRIBUTE_SET_FAILURE : "Failed to set", + ATTRIBUTE_NOT_AVAILABLE: "Not available", + ATTRIBUTE_GET_FAILURE: "Failed to retrieve", + ATTRIBUTE_SET_FAILURE: "Failed to set", ATTRIBUTE_UPDATE_FAILURE: "Failed to update", - ATTRIBUTE_ACCESS_DENIED : "Access denied", - ATTRIBUTE_UNKNOWN_ERROR : "Unknown error when accessing", + ATTRIBUTE_ACCESS_DENIED: "Access denied", + ATTRIBUTE_UNKNOWN_ERROR: "Unknown error when accessing", =20 - COMMAND_FAILURE : "Failed to execute command", + COMMAND_FAILURE: "Failed to execute command", =20 - IO_NOT_READY : "Not ready", - IO_BUSY : "Busy", - IO_TIMEOUT : "Timeout", - IO_UNKNOWN_ERROR : "Unknown error in IO operation", + IO_NOT_READY: "Not ready", + IO_BUSY: "Busy", + IO_TIMEOUT: "Timeout", + IO_UNKNOWN_ERROR: "Unknown error in IO operation", =20 - ERROR_STATEMENT : "!error statement", - UNKNOWN_ERROR : "Unknown error", + ERROR_STATEMENT: "!error statement", + UNKNOWN_ERROR: "Unknown error", } =20 -## Exception indicating a fatal error +# Exception indicating a fatal error + + class FatalError(Exception): pass =20 + if __name__ =3D=3D "__main__": pass diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Sou= rce/Python/Common/BuildVersion.py index 088609f54170..8e276013bcce 100644 --- a/BaseTools/Source/Python/Common/BuildVersion.py +++ b/BaseTools/Source/Python/Common/BuildVersion.py @@ -1,4 +1,4 @@ -## @file +# @file # # This file is for build version number auto generation # diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/= Python/Common/DataType.py index dc4962333351..67433b95c759 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common static strings used by INF/DEC/DSC fi= les # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -39,8 +39,10 @@ TAB_VOID =3D 'VOID*' TAB_GUID =3D 'GUID' =20 TAB_PCD_CLEAN_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UI= NT64} -TAB_PCD_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, = 'BOOLEAN'} -TAB_PCD_NUMERIC_TYPES_VOID =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UIN= T64, 'BOOLEAN', TAB_VOID} +TAB_PCD_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, + TAB_UINT32, TAB_UINT64, 'BOOLEAN'} +TAB_PCD_NUMERIC_TYPES_VOID =3D {TAB_UINT8, TAB_UINT16, + TAB_UINT32, TAB_UINT64, 'BOOLEAN', TAB_VOID} =20 TAB_WORKSPACE =3D '$(WORKSPACE)' TAB_FV_DIRECTORY =3D 'FV' @@ -55,7 +57,8 @@ TAB_ARCH_AARCH64 =3D 'AARCH64' =20 TAB_ARCH_RISCV64 =3D 'RISCV64' =20 -ARCH_SET_FULL =3D {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_ARM, TAB_ARCH_EBC= , TAB_ARCH_AARCH64, TAB_ARCH_RISCV64, TAB_ARCH_COMMON} +ARCH_SET_FULL =3D {TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_ARM, + TAB_ARCH_EBC, TAB_ARCH_AARCH64, TAB_ARCH_RISCV64, TAB_ARC= H_COMMON} =20 SUP_MODULE_BASE =3D 'BASE' SUP_MODULE_SEC =3D 'SEC' @@ -74,8 +77,8 @@ SUP_MODULE_SMM_CORE =3D 'SMM_CORE' SUP_MODULE_MM_STANDALONE =3D 'MM_STANDALONE' SUP_MODULE_MM_CORE_STANDALONE =3D 'MM_CORE_STANDALONE' =20 -SUP_MODULE_LIST =3D [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE,= SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, \ - SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVE= R, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \ +SUP_MODULE_LIST =3D [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE,= SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, + SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVE= R, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, S= UP_MODULE_HOST_APPLICATION, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, = SUP_MODULE_MM_CORE_STANDALONE] SUP_MODULE_LIST_STRING =3D TAB_VALUE_SPLIT.join(SUP_MODULE_LIST) SUP_MODULE_SET_PEI =3D {SUP_MODULE_PEIM, SUP_MODULE_PEI_CORE} @@ -95,18 +98,18 @@ EDKII_NAME =3D 'EDKII' MSG_EDKII_MAIL_ADDR =3D 'devel@edk2.groups.io' =20 COMPONENT_TO_MODULE_MAP_DICT =3D { - EDK_COMPONENT_TYPE_LIBRARY : SUP_MODULE_BASE, - EDK_COMPONENT_TYPE_SECURITY_CORE : SUP_MODULE_SEC, - EDK_COMPONENT_TYPE_PEI_CORE : SUP_MODULE_PEI_CORE, - EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER : SUP_MODULE_PEIM, - EDK_COMPONENT_TYPE_PIC_PEIM : SUP_MODULE_PEIM, - EDK_COMPONENT_TYPE_RELOCATABLE_PEIM : SUP_MODULE_PEIM, - "PE32_PEIM" : SUP_MODULE_PEIM, - EDK_COMPONENT_TYPE_BS_DRIVER : SUP_MODULE_DXE_DRIVER, - EDK_COMPONENT_TYPE_RT_DRIVER : SUP_MODULE_DXE_RUNTIME_DR= IVER, - EDK_COMPONENT_TYPE_SAL_RT_DRIVER : SUP_MODULE_DXE_SAL_DRIVER, - EDK_COMPONENT_TYPE_APPLICATION : SUP_MODULE_UEFI_APPLICATI= ON, - "LOGO" : SUP_MODULE_BASE, + EDK_COMPONENT_TYPE_LIBRARY: SUP_MODULE_BASE, + EDK_COMPONENT_TYPE_SECURITY_CORE: SUP_MODULE_SEC, + EDK_COMPONENT_TYPE_PEI_CORE: SUP_MODULE_PEI_CORE, + EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER: SUP_MODULE_PEIM, + EDK_COMPONENT_TYPE_PIC_PEIM: SUP_MODULE_PEIM, + EDK_COMPONENT_TYPE_RELOCATABLE_PEIM: SUP_MODULE_PEIM, + "PE32_PEIM": SUP_MODULE_PEIM, + EDK_COMPONENT_TYPE_BS_DRIVER: SUP_MODULE_DXE_DRIVER, + EDK_COMPONENT_TYPE_RT_DRIVER: SUP_MODULE_DXE_RUNTIME_DRIVER, + EDK_COMPONENT_TYPE_SAL_RT_DRIVER: SUP_MODULE_DXE_SAL_DRIVER, + EDK_COMPONENT_TYPE_APPLICATION: SUP_MODULE_UEFI_APPLICATION, + "LOGO": SUP_MODULE_BASE, } =20 BINARY_FILE_TYPE_FW =3D 'FW' @@ -208,57 +211,86 @@ TAB_PCDS_DYNAMIC_DEFAULT =3D 'DynamicDefault' TAB_PCDS_DYNAMIC_VPD =3D 'DynamicVpd' TAB_PCDS_DYNAMIC_HII =3D 'DynamicHii' =20 -PCD_DYNAMIC_TYPE_SET =3D {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_= PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII} -PCD_DYNAMIC_EX_TYPE_SET =3D {TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFA= ULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII} +PCD_DYNAMIC_TYPE_SET =3D {TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, + TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII} +PCD_DYNAMIC_EX_TYPE_SET =3D {TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFA= ULT, + TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HI= I} =20 # leave as a list for order -PCD_TYPE_LIST =3D [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, = TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX] +PCD_TYPE_LIST =3D [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, + TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC= _EX] =20 TAB_PCDS_FIXED_AT_BUILD_NULL =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD -TAB_PCDS_FIXED_AT_BUILD_COMMON =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TA= B_SPLIT + TAB_ARCH_COMMON -TAB_PCDS_FIXED_AT_BUILD_IA32 =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_= SPLIT + TAB_ARCH_IA32 -TAB_PCDS_FIXED_AT_BUILD_X64 =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_S= PLIT + TAB_ARCH_X64 -TAB_PCDS_FIXED_AT_BUILD_ARM =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_S= PLIT + TAB_ARCH_ARM -TAB_PCDS_FIXED_AT_BUILD_EBC =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + TAB_S= PLIT + TAB_ARCH_EBC -TAB_PCDS_FIXED_AT_BUILD_AARCH64 =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + T= AB_SPLIT + TAB_ARCH_AARCH64 +TAB_PCDS_FIXED_AT_BUILD_COMMON =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_COMMON +TAB_PCDS_FIXED_AT_BUILD_IA32 =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_IA32 +TAB_PCDS_FIXED_AT_BUILD_X64 =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_X64 +TAB_PCDS_FIXED_AT_BUILD_ARM =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_ARM +TAB_PCDS_FIXED_AT_BUILD_EBC =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FIXED_AT_BUILD_AARCH64 =3D TAB_PCDS + \ + TAB_PCDS_FIXED_AT_BUILD + TAB_SPLIT + TAB_ARCH_AARCH64 =20 TAB_PCDS_PATCHABLE_IN_MODULE_NULL =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MOD= ULE -TAB_PCDS_PATCHABLE_IN_MODULE_COMMON =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_M= ODULE + TAB_SPLIT + TAB_ARCH_COMMON -TAB_PCDS_PATCHABLE_IN_MODULE_IA32 =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MOD= ULE + TAB_SPLIT + TAB_ARCH_IA32 -TAB_PCDS_PATCHABLE_IN_MODULE_X64 =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + TAB_SPLIT + TAB_ARCH_X64 -TAB_PCDS_PATCHABLE_IN_MODULE_ARM =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + TAB_SPLIT + TAB_ARCH_ARM -TAB_PCDS_PATCHABLE_IN_MODULE_EBC =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + TAB_SPLIT + TAB_ARCH_EBC -TAB_PCDS_PATCHABLE_IN_MODULE_AARCH64 =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_= MODULE + TAB_SPLIT + TAB_ARCH_AARCH64 +TAB_PCDS_PATCHABLE_IN_MODULE_COMMON =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_COMMON +TAB_PCDS_PATCHABLE_IN_MODULE_IA32 =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_IA32 +TAB_PCDS_PATCHABLE_IN_MODULE_X64 =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_X64 +TAB_PCDS_PATCHABLE_IN_MODULE_ARM =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_ARM +TAB_PCDS_PATCHABLE_IN_MODULE_EBC =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_PATCHABLE_IN_MODULE_AARCH64 =3D TAB_PCDS + \ + TAB_PCDS_PATCHABLE_IN_MODULE + TAB_SPLIT + TAB_ARCH_AARCH64 =20 TAB_PCDS_FEATURE_FLAG_NULL =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG -TAB_PCDS_FEATURE_FLAG_COMMON =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SP= LIT + TAB_ARCH_COMMON -TAB_PCDS_FEATURE_FLAG_IA32 =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLI= T + TAB_ARCH_IA32 -TAB_PCDS_FEATURE_FLAG_X64 =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + TAB_ARCH_X64 -TAB_PCDS_FEATURE_FLAG_ARM =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + TAB_ARCH_ARM -TAB_PCDS_FEATURE_FLAG_EBC =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + TAB_ARCH_EBC -TAB_PCDS_FEATURE_FLAG_AARCH64 =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_S= PLIT + TAB_ARCH_AARCH64 +TAB_PCDS_FEATURE_FLAG_COMMON =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_COMMON +TAB_PCDS_FEATURE_FLAG_IA32 =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_IA32 +TAB_PCDS_FEATURE_FLAG_X64 =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_X64 +TAB_PCDS_FEATURE_FLAG_ARM =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_ARM +TAB_PCDS_FEATURE_FLAG_EBC =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_FEATURE_FLAG_AARCH64 =3D TAB_PCDS + \ + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT + TAB_ARCH_AARCH64 =20 TAB_PCDS_DYNAMIC_EX_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_DEFAULT TAB_PCDS_DYNAMIC_EX_HII_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_HII TAB_PCDS_DYNAMIC_EX_VPD_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_VPD -TAB_PCDS_DYNAMIC_EX_COMMON =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT = + TAB_ARCH_COMMON -TAB_PCDS_DYNAMIC_EX_IA32 =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + = TAB_ARCH_IA32 -TAB_PCDS_DYNAMIC_EX_X64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + T= AB_ARCH_X64 -TAB_PCDS_DYNAMIC_EX_ARM =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + T= AB_ARCH_ARM -TAB_PCDS_DYNAMIC_EX_EBC =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + T= AB_ARCH_EBC -TAB_PCDS_DYNAMIC_EX_AARCH64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT= + TAB_ARCH_AARCH64 +TAB_PCDS_DYNAMIC_EX_COMMON =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_COMMON +TAB_PCDS_DYNAMIC_EX_IA32 =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_IA32 +TAB_PCDS_DYNAMIC_EX_X64 =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_X64 +TAB_PCDS_DYNAMIC_EX_ARM =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_ARM +TAB_PCDS_DYNAMIC_EX_EBC =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_EBC +TAB_PCDS_DYNAMIC_EX_AARCH64 =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + TAB_ARCH_AARCH64 =20 TAB_PCDS_DYNAMIC_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC TAB_PCDS_DYNAMIC_DEFAULT_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_DEFAULT TAB_PCDS_DYNAMIC_HII_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_HII TAB_PCDS_DYNAMIC_VPD_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_VPD -TAB_PCDS_DYNAMIC_COMMON =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_= ARCH_COMMON +TAB_PCDS_DYNAMIC_COMMON =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_COMMON TAB_PCDS_DYNAMIC_IA32 =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_AR= CH_IA32 TAB_PCDS_DYNAMIC_X64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_X64 TAB_PCDS_DYNAMIC_ARM =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_ARM TAB_PCDS_DYNAMIC_EBC =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_EBC -TAB_PCDS_DYNAMIC_AARCH64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB= _ARCH_AARCH64 +TAB_PCDS_DYNAMIC_AARCH64 =3D TAB_PCDS + \ + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_AARCH64 =20 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE =3D 'PcdLoadFixAddressPe= iCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE =3D 'UINT32' @@ -268,15 +300,17 @@ TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE= =3D 'PcdLoadFixAddressRuntim TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE =3D 'UINT3= 2' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE =3D 'PcdLoadFixAddressSm= mCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE =3D 'UINT32' -TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SET =3D {TAB_PCDS_PATCHABLE_LOAD_FIX_= ADDRESS_PEI_PAGE_SIZE, \ - TAB_PCDS_PATCHABLE_LOAD_FIX_AD= DRESS_DXE_PAGE_SIZE, \ - TAB_PCDS_PATCHABLE_LOAD_FIX_AD= DRESS_RUNTIME_PAGE_SIZE, \ - TAB_PCDS_PATCHABLE_LOAD_FIX_AD= DRESS_SMM_PAGE_SIZE} +TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SET =3D {TAB_PCDS_PATCHABLE_LOAD_FIX_A= DDRESS_PEI_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADD= RESS_DXE_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADD= RESS_RUNTIME_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADD= RESS_SMM_PAGE_SIZE} =20 -## The mapping dictionary from datum type to its maximum number. -MAX_VAL_TYPE =3D {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_U= INT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} -## The mapping dictionary from datum type to size string. -MAX_SIZE_TYPE =3D {"BOOLEAN":1, TAB_UINT8:1, TAB_UINT16:2, TAB_UINT32:4, T= AB_UINT64:8} +# The mapping dictionary from datum type to its maximum number. +MAX_VAL_TYPE =3D {"BOOLEAN": 0x01, TAB_UINT8: 0xFF, TAB_UINT16: 0xFFFF, + TAB_UINT32: 0xFFFFFFFF, TAB_UINT64: 0xFFFFFFFFFFFFFFFF} +# The mapping dictionary from datum type to size string. +MAX_SIZE_TYPE =3D {"BOOLEAN": 1, TAB_UINT8: 1, + TAB_UINT16: 2, TAB_UINT32: 4, TAB_UINT64: 8} =20 TAB_DEPEX =3D 'Depex' TAB_DEPEX_COMMON =3D TAB_DEPEX + TAB_SPLIT + TAB_ARCH_COMMON @@ -343,7 +377,8 @@ TAB_INF_DEFINES_FFS_EXT =3D 'FFS_EXT' TAB_INF_DEFINES_FV_EXT =3D 'FV_EXT' TAB_INF_DEFINES_SOURCE_FV =3D 'SOURCE_FV' TAB_INF_DEFINES_VERSION_NUMBER =3D 'VERSION_NUMBER' -TAB_INF_DEFINES_VERSION =3D 'VERSION' # for Edk inf, the same as = VERSION_NUMBER +# for Edk inf, the same as VERSION_NUMBER +TAB_INF_DEFINES_VERSION =3D 'VERSION' TAB_INF_DEFINES_VERSION_STRING =3D 'VERSION_STRING' TAB_INF_DEFINES_PCD_IS_DRIVER =3D 'PCD_IS_DRIVER' TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H =3D 'TIANO_EDK_FLASHMAP_H' @@ -463,10 +498,11 @@ TAB_UNKNOWN =3D 'UNKNOWN' # # Build database path # -DATABASE_PATH =3D ":memory:" #"BuildDatabase.db" +DATABASE_PATH =3D ":memory:" # "BuildDatabase.db" =20 # used by ECC -MODIFIER_SET =3D {'IN', 'OUT', 'OPTIONAL', 'UNALIGNED', 'EFI_RUNTIMESERVIC= E', 'EFI_BOOTSERVICE', 'EFIAPI'} +MODIFIER_SET =3D {'IN', 'OUT', 'OPTIONAL', 'UNALIGNED', + 'EFI_RUNTIMESERVICE', 'EFI_BOOTSERVICE', 'EFIAPI'} =20 # Dependency Opcodes DEPEX_OPCODE_BEFORE =3D "BEFORE" @@ -481,7 +517,8 @@ DEPEX_OPCODE_TRUE =3D "TRUE" DEPEX_OPCODE_FALSE =3D "FALSE" =20 # Dependency Expression -DEPEX_SUPPORTED_OPCODE_SET =3D {"BEFORE", "AFTER", "PUSH", "AND", "OR", "N= OT", "END", "SOR", "TRUE", "FALSE", '(', ')'} +DEPEX_SUPPORTED_OPCODE_SET =3D {"BEFORE", "AFTER", "PUSH", + "AND", "OR", "NOT", "END", "SOR", "TRUE", "F= ALSE", '(', ')'} =20 TAB_STATIC_LIBRARY =3D "STATIC-LIBRARY-FILE" TAB_DYNAMIC_LIBRARY =3D "DYNAMIC-LIBRARY-FILE" @@ -513,29 +550,29 @@ PCDS_DYNAMICEX_DEFAULT =3D "PcdsDynamicExDefault" PCDS_DYNAMICEX_VPD =3D "PcdsDynamicExVpd" PCDS_DYNAMICEX_HII =3D "PcdsDynamicExHii" =20 -SECTIONS_HAVE_ITEM_PCD_SET =3D {PCDS_DYNAMIC_DEFAULT.upper(), PCDS_DYNAMIC= _VPD.upper(), PCDS_DYNAMIC_HII.upper(), \ +SECTIONS_HAVE_ITEM_PCD_SET =3D {PCDS_DYNAMIC_DEFAULT.upper(), PCDS_DYNAMIC= _VPD.upper(), PCDS_DYNAMIC_HII.upper(), PCDS_DYNAMICEX_DEFAULT.upper(), PCDS_DYNAMIC= EX_VPD.upper(), PCDS_DYNAMICEX_HII.upper()} # Section allowed to have items after arch SECTIONS_HAVE_ITEM_AFTER_ARCH_SET =3D {TAB_LIBRARY_CLASSES.upper(), TAB_DE= PEX.upper(), TAB_USER_EXTENSIONS.upper(), - PCDS_DYNAMIC_DEFAULT.upper(), - PCDS_DYNAMIC_VPD.upper(), - PCDS_DYNAMIC_HII.upper(), - PCDS_DYNAMICEX_DEFAULT.upper(), - PCDS_DYNAMICEX_VPD.upper(), - PCDS_DYNAMICEX_HII.upper(), - TAB_BUILD_OPTIONS.upper(), - TAB_PACKAGES.upper(), - TAB_INCLUDES.upper()} + PCDS_DYNAMIC_DEFAULT.upper(), + PCDS_DYNAMIC_VPD.upper(), + PCDS_DYNAMIC_HII.upper(), + PCDS_DYNAMICEX_DEFAULT.upper(), + PCDS_DYNAMICEX_VPD.upper(), + PCDS_DYNAMICEX_HII.upper(), + TAB_BUILD_OPTIONS.upper(), + TAB_PACKAGES.upper(), + TAB_INCLUDES.upper()} =20 # # pack codes as used in PcdDb and elsewhere # PACK_PATTERN_GUID =3D '=3DLHHBBBBBBBB' -PACK_CODE_BY_SIZE =3D {8:'=3DQ', - 4:'=3DL', - 2:'=3DH', - 1:'=3DB', - 0:'=3DB', - 16:""} +PACK_CODE_BY_SIZE =3D {8: '=3DQ', + 4: '=3DL', + 2: '=3DH', + 1: '=3DB', + 0: '=3DB', + 16: ""} =20 TAB_COMPILER_MSFT =3D 'MSFT' diff --git a/BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.p= y b/BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.py index ddc142c39ef2..c3dd899c85ae 100644 --- a/BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.py +++ b/BaseTools/Source/Python/Common/Edk2/Capsule/FmpPayloadHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # Module that encodes and decodes a FMP_PAYLOAD_HEADER with a payload. # The FMP_PAYLOAD_HEADER is processed by the FmpPayloadHeaderLib in the # FmpDevicePkg. @@ -13,11 +13,14 @@ FmpPayloadHeader =20 import struct =20 -def _SIGNATURE_32 (A, B, C, D): - return struct.unpack ('=3DI',bytearray (A + B + C + D, 'ascii'))[0] =20 -def _SIGNATURE_32_TO_STRING (Signature): - return struct.pack (" @@ -22,11 +22,13 @@ # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # This copyright is for QueueHandler. =20 -## Import modules +# Import modules from __future__ import absolute_import -import Common.LongFilePathOs as os, sys, logging +import Common.LongFilePathOs as os +import sys +import logging import traceback -from .BuildToolError import * +from .BuildToolError import * try: from logging.handlers import QueueHandler except: @@ -95,10 +97,14 @@ except: self.enqueue(self.prepare(record)) except Exception: self.handleError(record) + + class BlockQueueHandler(QueueHandler): def enqueue(self, record): - self.queue.put(record,True) -## Log level constants + self.queue.put(record, True) + + +# Log level constants DEBUG_0 =3D 1 DEBUG_1 =3D 2 DEBUG_2 =3D 3 @@ -110,11 +116,11 @@ DEBUG_7 =3D 8 DEBUG_8 =3D 9 DEBUG_9 =3D 10 VERBOSE =3D 15 -INFO =3D 20 -WARN =3D 30 -QUIET =3D 40 -ERROR =3D 50 -SILENT =3D 99 +INFO =3D 20 +WARN =3D 30 +QUIET =3D 40 +ERROR =3D 50 +SILENT =3D 99 =20 IsRaiseError =3D True =20 @@ -128,7 +134,8 @@ _LogLevels =3D [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEB= UG_4, DEBUG_5, =20 # For DEBUG level (All DEBUG_0~9 are applicable) _DebugLogger =3D logging.getLogger("tool_debug") -_DebugFormatter =3D logging.Formatter("[%(asctime)s.%(msecs)d]: %(message)= s", datefmt=3D"%H:%M:%S") +_DebugFormatter =3D logging.Formatter( + "[%(asctime)s.%(msecs)d]: %(message)s", datefmt=3D"%H:%M:%S") =20 # For VERBOSE, INFO, WARN level _InfoLogger =3D logging.getLogger("tool_info") @@ -151,12 +158,14 @@ _DebugMessageTemplate =3D '%(file)s(%(line)s): debug:= \n %(msg)s' # _WarningAsError =3D False =20 -## Log debug message +# Log debug message # # @param Level DEBUG level (DEBUG0~9) # @param Message Debug information # @param ExtraData More information associated with "Message" # + + def debug(Level, Message, ExtraData=3DNone): if _DebugLogger.level > Level: return @@ -166,9 +175,9 @@ def debug(Level, Message, ExtraData=3DNone): # Find out the caller method information CallerStack =3D traceback.extract_stack()[-2] TemplateDict =3D { - "file" : CallerStack[0], - "line" : CallerStack[1], - "msg" : Message, + "file": CallerStack[0], + "line": CallerStack[1], + "msg": Message, } =20 if ExtraData is not None: @@ -178,14 +187,16 @@ def debug(Level, Message, ExtraData=3DNone): =20 _DebugLogger.log(Level, LogText) =20 -## Log verbose message +# Log verbose message # # @param Message Verbose information # + + def verbose(Message): return _InfoLogger.log(VERBOSE, Message) =20 -## Log warning message +# Log warning message # # Warning messages are those which might be wrong but won't fail the too= l. # @@ -196,6 +207,8 @@ def verbose(Message): # @param Line The line number in the "File" which caused the war= ning. # @param ExtraData More information associated with "Message" # + + def warn(ToolName, Message, File=3DNone, Line=3DNone, ExtraData=3DNone): if _InfoLogger.level > WARN: return @@ -210,10 +223,10 @@ def warn(ToolName, Message, File=3DNone, Line=3DNone,= ExtraData=3DNone): Line =3D "%d" % Line =20 TemplateDict =3D { - "tool" : ToolName, - "file" : File, - "line" : Line, - "msg" : Message, + "tool": ToolName, + "file": File, + "line": Line, + "msg": Message, } =20 if File is not None: @@ -230,10 +243,11 @@ def warn(ToolName, Message, File=3DNone, Line=3DNone,= ExtraData=3DNone): if _WarningAsError =3D=3D True: raise FatalError(WARNING_AS_ERROR) =20 -## Log INFO message -info =3D _InfoLogger.info =20 -## Log ERROR message +# Log INFO message +info =3D _InfoLogger.info + +# Log ERROR message # # Once an error messages is logged, the tool's execution will be broken = by raising # an exception. If you don't want to break the execution later, you can gi= ve @@ -249,6 +263,8 @@ info =3D _InfoLogger.info # @param RaiseError Raise an exception to break the tool's execution if # it's True. This is the default behavior. # + + def error(ToolName, ErrorCode, Message=3DNone, File=3DNone, Line=3DNone, E= xtraData=3DNone, RaiseError=3DIsRaiseError): if Line is None: Line =3D "..." @@ -265,16 +281,16 @@ def error(ToolName, ErrorCode, Message=3DNone, File= =3DNone, Line=3DNone, ExtraData=3DNon ExtraData =3D "" =20 TemplateDict =3D { - "tool" : _ToolName, - "file" : File, - "line" : Line, - "errorcode" : ErrorCode, - "msg" : Message, - "extra" : ExtraData + "tool": _ToolName, + "file": File, + "line": Line, + "errorcode": ErrorCode, + "msg": Message, + "extra": ExtraData } =20 if File is not None: - LogText =3D _ErrorMessageTemplate % TemplateDict + LogText =3D _ErrorMessageTemplate % TemplateDict else: LogText =3D _ErrorMessageTemplateWithoutFile % TemplateDict =20 @@ -283,10 +299,13 @@ def error(ToolName, ErrorCode, Message=3DNone, File= =3DNone, Line=3DNone, ExtraData=3DNon if RaiseError and IsRaiseError: raise FatalError(ErrorCode) =20 + # Log information which should be always put out -quiet =3D _ErrorLogger.error +quiet =3D _ErrorLogger.error + +# Initialize log system + =20 -## Initialize log system def LogClientInitialize(log_q): # # Since we use different format to log different levels of message int= o different @@ -310,9 +329,11 @@ def LogClientInitialize(log_q): _ErrorCh.setFormatter(_ErrorFormatter) _ErrorLogger.addHandler(_ErrorCh) =20 -## Set log level +# Set log level # # @param Level One of log level in _LogLevel + + def SetLevel(Level): if Level not in _LogLevels: info("Not supported log level (%d). Use default level instead." % = Level) @@ -321,7 +342,9 @@ def SetLevel(Level): _InfoLogger.setLevel(Level) _ErrorLogger.setLevel(Level) =20 -## Initialize log system +# Initialize log system + + def Initialize(): # # Since we use different format to log different levels of message int= o different @@ -345,23 +368,30 @@ def Initialize(): _ErrorCh.setFormatter(_ErrorFormatter) _ErrorLogger.addHandler(_ErrorCh) =20 + def InitializeForUnitTest(): Initialize() SetLevel(SILENT) =20 -## Get current log level +# Get current log level + + def GetLevel(): return _InfoLogger.getEffectiveLevel() =20 -## Raise up warning as error +# Raise up warning as error + + def SetWarningAsError(): global _WarningAsError _WarningAsError =3D True =20 -## Specify a file to store the log message as well as put on console +# Specify a file to store the log message as well as put on console # # @param LogFile The file path used to store the log message # + + def SetLogFile(LogFile): if os.path.exists(LogFile): os.remove(LogFile) @@ -370,7 +400,7 @@ def SetLogFile(LogFile): _Ch.setFormatter(_DebugFormatter) _DebugLogger.addHandler(_Ch) =20 - _Ch=3D logging.FileHandler(LogFile) + _Ch =3D logging.FileHandler(LogFile) _Ch.setFormatter(_InfoFormatter) _InfoLogger.addHandler(_Ch) =20 @@ -378,6 +408,6 @@ def SetLogFile(LogFile): _Ch.setFormatter(_ErrorFormatter) _ErrorLogger.addHandler(_Ch) =20 + if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 31bf0e4b6cf7..ac9c767f213e 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -1,17 +1,17 @@ -## @file +# @file # This file is used to parse and evaluate expression in directive or PCD v= alue. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent =20 -## Import Modules +# Import Modules # from __future__ import print_function from __future__ import absolute_import from Common.GlobalData import * from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression -from .Misc import GuidStringToGuidStructureString, ParseFieldValue,CopyDict +from .Misc import GuidStringToGuidStructureString, ParseFieldValue, CopyDi= ct import Common.EdkLogger as EdkLogger import copy from Common.DataType import * @@ -19,36 +19,38 @@ import sys from random import sample import string =20 -ERR_STRING_EXPR =3D 'This operator cannot be used in string expres= sion: [%s].' -ERR_SNYTAX =3D 'Syntax error, the rest of expression cannot b= e evaluated: [%s].' -ERR_MATCH =3D 'No matching right parenthesis.' -ERR_STRING_TOKEN =3D 'Bad string token: [%s].' -ERR_MACRO_TOKEN =3D 'Bad macro token: [%s].' -ERR_EMPTY_TOKEN =3D 'Empty token is not allowed.' -ERR_PCD_RESOLVE =3D 'The PCD should be FeatureFlag type or FixedAt= Build type: [%s].' -ERR_VALID_TOKEN =3D 'No more valid token found from rest of string= : [%s].' -ERR_EXPR_TYPE =3D 'Different types found in expression.' -ERR_OPERATOR_UNSUPPORT =3D 'Unsupported operator: [%s]' -ERR_REL_NOT_IN =3D 'Expect "IN" after "not" operator.' -WRN_BOOL_EXPR =3D 'Operand of boolean type cannot be used in ari= thmetic expression.' -WRN_EQCMP_STR_OTHERS =3D '=3D=3D Comparison between Operand of string t= ype and Boolean/Number Type always return False.' -WRN_NECMP_STR_OTHERS =3D '!=3D Comparison between Operand of string typ= e and Boolean/Number Type always return True.' -ERR_RELCMP_STR_OTHERS =3D 'Operator taking Operand of string type and Bo= olean/Number Type is not allowed: [%s].' -ERR_STRING_CMP =3D 'Unicode string and general string cannot be c= ompared: [%s %s %s]' -ERR_ARRAY_TOKEN =3D 'Bad C array or C format GUID token: [%s].' -ERR_ARRAY_ELE =3D 'This must be HEX value for NList or Array: [%= s].' -ERR_EMPTY_EXPR =3D 'Empty expression is not allowed.' -ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY= ), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' +ERR_STRING_EXPR =3D 'This operator cannot be used in string expression: [%= s].' +ERR_SNYTAX =3D 'Syntax error, the rest of expression cannot be evaluated: = [%s].' +ERR_MATCH =3D 'No matching right parenthesis.' +ERR_STRING_TOKEN =3D 'Bad string token: [%s].' +ERR_MACRO_TOKEN =3D 'Bad macro token: [%s].' +ERR_EMPTY_TOKEN =3D 'Empty token is not allowed.' +ERR_PCD_RESOLVE =3D 'The PCD should be FeatureFlag type or FixedAtBuild ty= pe: [%s].' +ERR_VALID_TOKEN =3D 'No more valid token found from rest of string: [%s].' +ERR_EXPR_TYPE =3D 'Different types found in expression.' +ERR_OPERATOR_UNSUPPORT =3D 'Unsupported operator: [%s]' +ERR_REL_NOT_IN =3D 'Expect "IN" after "not" operator.' +WRN_BOOL_EXPR =3D 'Operand of boolean type cannot be used in arithmetic ex= pression.' +WRN_EQCMP_STR_OTHERS =3D '=3D=3D Comparison between Operand of string type= and Boolean/Number Type always return False.' +WRN_NECMP_STR_OTHERS =3D '!=3D Comparison between Operand of string type a= nd Boolean/Number Type always return True.' +ERR_RELCMP_STR_OTHERS =3D 'Operator taking Operand of string type and Bool= ean/Number Type is not allowed: [%s].' +ERR_STRING_CMP =3D 'Unicode string and general string cannot be compared: = [%s %s %s]' +ERR_ARRAY_TOKEN =3D 'Bad C array or C format GUID token: [%s].' +ERR_ARRAY_ELE =3D 'This must be HEX value for NList or Array: [%s].' +ERR_EMPTY_EXPR =3D 'Empty expression is not allowed.' +ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY), $(ARCH= ), $(TOOL_CHAIN_TAG) and $(TARGET).' =20 __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') _ReLabel =3D re.compile('LABEL\((\w+)\)') _ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') PcdPattern =3D re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]= *$') =20 -## SplitString +# SplitString # Split string to list according double quote # For example: abc"de\"f"ghi"jkl"mn will be: ['abc', '"de\"f"', 'ghi', '"= jkl"', 'mn'] # + + def SplitString(String): # There might be escaped quote: "abc\"def\\\"ghi", 'abc\'def\\\'ghi' RanStr =3D ''.join(sample(string.ascii_letters + string.digits, 8)) @@ -87,9 +89,10 @@ def SplitString(String): RetList.append(Item) for i, ch in enumerate(RetList): if RanStr in ch: - RetList[i] =3D ch.replace(RanStr,'\\\\') + RetList[i] =3D ch.replace(RanStr, '\\\\') return RetList =20 + def SplitPcdValueString(String): # There might be escaped comma in GUID() or DEVICE_PATH() or " " # or ' ' or L' ' or L" " @@ -129,12 +132,14 @@ def SplitPcdValueString(String): RetList.append(Item) for i, ch in enumerate(RetList): if RanStr in ch: - RetList[i] =3D ch.replace(RanStr,'\\\\') + RetList[i] =3D ch.replace(RanStr, '\\\\') return RetList =20 + def IsValidCName(Str): return True if __ValidString.match(Str) else False =20 + def BuildOptionValue(PcdValue, GuidDict): if PcdValue.startswith('H'): InputValue =3D PcdValue[1:] @@ -151,9 +156,11 @@ def BuildOptionValue(PcdValue, GuidDict): =20 return PcdValue =20 -## ReplaceExprMacro +# ReplaceExprMacro # -def ReplaceExprMacro(String, Macros, ExceptionList =3D None): + + +def ReplaceExprMacro(String, Macros, ExceptionList=3DNone): StrList =3D SplitString(String) for i, String in enumerate(StrList): InQuote =3D False @@ -200,6 +207,8 @@ def ReplaceExprMacro(String, Macros, ExceptionList =3D = None): return ''.join(StrList) =20 # transfer int to string for in/not in expression + + def IntToStr(Value): StrList =3D [] while Value > 0: @@ -208,8 +217,10 @@ def IntToStr(Value): Value =3D '"' + ''.join(StrList) + '"' return Value =20 + SupportedInMacroList =3D ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH', 'FAMILY'] =20 + class BaseExpression(object): def __init__(self, *args, **kwargs): super(BaseExpression, self).__init__() @@ -225,35 +236,36 @@ class BaseExpression(object): self._Idx =3D Idx return False =20 + class ValueExpression(BaseExpression): # Logical operator mapping LogicalOperators =3D { - '&&' : 'and', '||' : 'or', - '!' : 'not', 'AND': 'and', - 'OR' : 'or' , 'NOT': 'not', - 'XOR': '^' , 'xor': '^', - 'EQ' : '=3D=3D' , 'NE' : '!=3D', - 'GT' : '>' , 'LT' : '<', - 'GE' : '>=3D' , 'LE' : '<=3D', - 'IN' : 'in' + '&&': 'and', '||': 'or', + '!': 'not', 'AND': 'and', + 'OR': 'or', 'NOT': 'not', + 'XOR': '^', 'xor': '^', + 'EQ': '=3D=3D', 'NE': '!=3D', + 'GT': '>', 'LT': '<', + 'GE': '>=3D', 'LE': '<=3D', + 'IN': 'in' } =20 - NonLetterOpLst =3D ['+', '-', TAB_STAR, '/', '%', '&', '|', '^', '~', = '<<', '>>', '!', '=3D', '>', '<', '?', ':'] - + NonLetterOpLst =3D ['+', '-', TAB_STAR, '/', '%', '&', '|', + '^', '~', '<<', '>>', '!', '=3D', '>', '<', '?', ':'] =20 SymbolPattern =3D re.compile("(" - "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+= \.\w+|" - "&&|\|\||!(?!=3D)|" - "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)= |(?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|" - "(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|= (?<=3D\W)GT(?=3D\W)|(?<=3D\W)LT(?=3D\W)|(?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?= =3D\W)" + "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.= \w+|" + "&&|\|\||!(?!=3D)|" + "(?<=3D\W)AND(?=3D\W)|(?<=3D\W)OR(?=3D\W)|(= ?<=3D\W)NOT(?=3D\W)|(?<=3D\W)XOR(?=3D\W)|" + "(?<=3D\W)EQ(?=3D\W)|(?<=3D\W)NE(?=3D\W)|(?= <=3D\W)GT(?=3D\W)|(?<=3D\W)LT(?=3D\W)|(?<=3D\W)GE(?=3D\W)|(?<=3D\W)LE(?=3D\= W)" ")") =20 @staticmethod - def Eval(Operator, Oprand1, Oprand2 =3D None): + def Eval(Operator, Oprand1, Oprand2=3DNone): WrnExp =3D None =20 if Operator not in {"=3D=3D", "!=3D", ">=3D", "<=3D", ">", "<", "i= n", "not in"} and \ - (isinstance(Oprand1, type('')) or isinstance(Oprand2, type('')= )): + (isinstance(Oprand1, type('')) or isinstance(Oprand2, type= (''))): raise BadExpression(ERR_STRING_EXPR % Operator) if Operator in {'in', 'not in'}: if not isinstance(Oprand1, type('')): @@ -261,11 +273,11 @@ class ValueExpression(BaseExpression): if not isinstance(Oprand2, type('')): Oprand2 =3D IntToStr(Oprand2) TypeDict =3D { - type(0) : 0, + type(0): 0, # For python2 long type - type(sys.maxsize + 1) : 0, - type('') : 1, - type(True) : 2 + type(sys.maxsize + 1): 0, + type(''): 1, + type(True): 2 } =20 EvalStr =3D '' @@ -305,15 +317,16 @@ class ValueExpression(BaseExpression): if isinstance(Oprand1, type('')) and isinstance(Oprand2, type(= '')): if ((Oprand1.startswith('L"') or Oprand1.startswith("L'"))= and (not Oprand2.startswith('L"')) and (not Oprand2.startswith("L'"))) or \ (((not Oprand1.startswith('L"')) and (not Oprand1.= startswith("L'"))) and (Oprand2.startswith('L"') or Oprand2.startswith("L'"= ))): - raise BadExpression(ERR_STRING_CMP % (Oprand1, Operato= r, Oprand2)) + raise BadExpression(ERR_STRING_CMP % + (Oprand1, Operator, Oprand2)) if 'in' in Operator and isinstance(Oprand2, type('')): Oprand2 =3D Oprand2.split() EvalStr =3D 'Oprand1 ' + Operator + ' Oprand2' =20 # Local symbols used by built in eval function Dict =3D { - 'Oprand1' : Oprand1, - 'Oprand2' : Oprand2 + 'Oprand1': Oprand1, + 'Oprand2': Oprand2 } try: Val =3D eval(EvalStr, {}, Dict) @@ -340,8 +353,8 @@ class ValueExpression(BaseExpression): return =20 self._Expr =3D ReplaceExprMacro(Expression.strip(), - SymbolTable, - SupportedInMacroList) + SymbolTable, + SupportedInMacroList) =20 if not self._Expr.strip(): raise BadExpression(ERR_EMPTY_EXPR) @@ -447,6 +460,7 @@ class ValueExpression(BaseExpression): Val =3D Warn.result return Val # A [? B]* + def _ConExpr(self): return self._ExprFuncTemplate(self._OrExpr, {'?', ':'}) =20 @@ -584,11 +598,11 @@ class ValueExpression(BaseExpression): # All whitespace and tabs in array are already stripped. IsArray =3D IsGuid =3D False if len(Token.split(',')) =3D=3D 11 and len(Token.split(',{')) =3D= =3D 2 \ - and len(Token.split('},')) =3D=3D 1: + and len(Token.split('},')) =3D=3D 1: HexLen =3D [11, 6, 6, 5, 4, 4, 4, 4, 4, 4, 6] - HexList=3D Token.split(',') + HexList =3D Token.split(',') if HexList[3].startswith('{') and \ - not [Index for Index, Hex in enumerate(HexList) if len(Hex= ) > HexLen[Index]]: + not [Index for Index, Hex in enumerate(HexList) if len= (Hex) > HexLen[Index]]: IsGuid =3D True if Token.lstrip('{').rstrip('}').find('{') =3D=3D -1: if not [Hex for Hex in Token.lstrip('{').rstrip('}').split(','= ) if len(Hex) > 4]: @@ -608,7 +622,8 @@ class ValueExpression(BaseExpression): =20 # Replace escape \\\", \" if self._Expr[Idx] =3D=3D '"': - Expr =3D self._Expr[self._Idx:].replace('\\\\', '//').replace(= '\\\"', '\\\'') + Expr =3D self._Expr[self._Idx:].replace( + '\\\\', '//').replace('\\\"', '\\\'') for Ch in Expr: self._Idx +=3D 1 if Ch =3D=3D '"': @@ -616,9 +631,10 @@ class ValueExpression(BaseExpression): self._Token =3D self._LiteralToken =3D self._Expr[Idx:self._Id= x] if not self._Token.endswith('"'): raise BadExpression(ERR_STRING_TOKEN % self._Token) - #Replace escape \\\', \' + # Replace escape \\\', \' elif self._Expr[Idx] =3D=3D "'": - Expr =3D self._Expr[self._Idx:].replace('\\\\', '//').replace(= "\\\'", "\\\"") + Expr =3D self._Expr[self._Idx:].replace( + '\\\\', '//').replace("\\\'", "\\\"") for Ch in Expr: self._Idx +=3D 1 if Ch =3D=3D "'": @@ -631,7 +647,7 @@ class ValueExpression(BaseExpression): =20 # Get token that is comprised by alphanumeric, underscore or dot(used = by PCD) # @param IsAlphaOp: Indicate if parsing general token or script operat= or(EQ, NE...) - def __GetIdToken(self, IsAlphaOp =3D False): + def __GetIdToken(self, IsAlphaOp=3DFalse): IdToken =3D '' for Ch in self._Expr[self._Idx:]: if not self.__IsIdChar(Ch) or ('?' in self._Expr and Ch =3D=3D= ':'): @@ -655,7 +671,8 @@ class ValueExpression(BaseExpression): Ex =3D BadExpression(ERR_PCD_RESOLVE % self._Token) Ex.Pcd =3D self._Token raise Ex - self._Token =3D ValueExpression(self._Symb[self._Token], self.= _Symb)(True, self._Depth+1) + self._Token =3D ValueExpression( + self._Symb[self._Token], self._Symb)(True, self._Depth+1) if not isinstance(self._Token, type('')): self._LiteralToken =3D hex(self._Token) return @@ -697,7 +714,7 @@ class ValueExpression(BaseExpression): =20 def __IsHexLiteral(self): if self._LiteralToken.startswith('{') and \ - self._LiteralToken.endswith('}'): + self._LiteralToken.endswith('}'): return True =20 if gHexPattern.match(self._LiteralToken): @@ -741,7 +758,7 @@ class ValueExpression(BaseExpression): try: RetValue =3D Re.search(Expr).group(1) except: - raise BadExpression('Invalid Expression %s' % Expr) + raise BadExpression('Invalid Expression %s' % Expr) Idx =3D self._Idx for Ch in Expr: self._Idx +=3D 1 @@ -749,21 +766,23 @@ class ValueExpression(BaseExpression): Prefix =3D self._Expr[Idx:self._Idx - 1] Idx =3D self._Idx if Ch =3D=3D ')': - TmpValue =3D self._Expr[Idx :self._Idx - 1] + TmpValue =3D self._Expr[Idx:self._Idx - 1] TmpValue =3D ValueExpression(TmpValue)(True) - TmpValue =3D '0x%x' % int(TmpValue) if not isinstance(= TmpValue, type('')) else TmpValue + TmpValue =3D '0x%x' % int(TmpValue) if not isinstance( + TmpValue, type('')) else TmpValue break self._Token, Size =3D ParseFieldValue(Prefix + '(' + TmpValue = + ')') - return self._Token + return self._Token =20 self._Token =3D '' if Expr: Ch =3D Expr[0] Match =3D gGuidPattern.match(Expr) if Match and not Expr[Match.end():Match.end()+1].isalnum() \ - and Expr[Match.end():Match.end()+1] !=3D '_': + and Expr[Match.end():Match.end()+1] !=3D '_': self._Idx +=3D Match.end() - self._Token =3D ValueExpression(GuidStringToGuidStructureS= tring(Expr[0:Match.end()]))(True, self._Depth+1) + self._Token =3D ValueExpression(GuidStringToGuidStructureS= tring( + Expr[0:Match.end()]))(True, self._Depth+1) return self._Token elif self.__IsIdChar(Ch): return self.__GetIdToken() @@ -781,7 +800,8 @@ class ValueExpression(BaseExpression): # Parse operator def _GetOperator(self): self.__SkipWS() - LegalOpLst =3D ['&&', '||', '!=3D', '=3D=3D', '>=3D', '<=3D'] + se= lf.NonLetterOpLst + ['?', ':'] + LegalOpLst =3D ['&&', '||', '!=3D', '=3D=3D', '>=3D', '<=3D'] + \ + self.NonLetterOpLst + ['?', ':'] =20 self._Token =3D '' Expr =3D self._Expr[self._Idx:] @@ -813,6 +833,7 @@ class ValueExpression(BaseExpression): self._Token =3D OpToken return OpToken =20 + class ValueExpressionEx(ValueExpression): def __init__(self, PcdValue, PcdType, SymbolTable=3D{}): ValueExpression.__init__(self, PcdValue, SymbolTable) @@ -828,11 +849,11 @@ class ValueExpressionEx(ValueExpression): PcdValue, Size =3D ParseFieldValue(PcdValue) PcdValueList =3D [] for I in range(Size): - PcdValueList.append('0x%02X'%(PcdValue & 0xff)) + PcdValueList.append('0x%02X' % (PcdValue & 0xff)) PcdValue =3D PcdValue >> 8 PcdValue =3D '{' + ','.join(PcdValueList) + '}' - elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.s= tartswith("'") or \ - PcdValue.startswith('"') or PcdValue.startswith(= "L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): + elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.s= tartswith("'") or + PcdValue.s= tartswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or= PcdValue.startswith('{')): raise BadExpression except WrnExpression as Value: PcdValue =3D Value.result @@ -865,12 +886,14 @@ class ValueExpressionEx(ValueExpression): else: ItemSize =3D 0 ValueType =3D TAB_UINT8 - Item =3D ValueExpressionEx(Item, ValueType, se= lf._Symb)(True) + Item =3D ValueExpressionEx( + Item, ValueType, self._Symb)(True) if ItemSize =3D=3D 0: try: tmpValue =3D int(Item, 0) if tmpValue > 255: - raise BadExpression("Byte array n= umber %s should less than 0xFF." % Item) + raise BadExpression( + "Byte array number %s should = less than 0xFF." % Item) except BadExpression as Value: raise BadExpression(Value) except ValueError: @@ -888,24 +911,30 @@ class ValueExpressionEx(ValueExpression): try: TmpValue, Size =3D ParseFieldValue(PcdValue) except BadExpression as Value: - raise BadExpression("Type: %s, Value: %s, %s" = % (self.PcdType, PcdValue, Value)) + raise BadExpression("Type: %s, Value: %s, %s" = % ( + self.PcdType, PcdValue, Value)) if isinstance(TmpValue, type('')): try: TmpValue =3D int(TmpValue) except: - raise BadExpression(Value) + raise BadExpression(Value) else: PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) if TmpValue < 0: - raise BadExpression('Type %s PCD Value is negativ= e' % self.PcdType) + raise BadExpression( + 'Type %s PCD Value is negative' % self.PcdType) if self.PcdType =3D=3D TAB_UINT8 and Size > 1: - raise BadExpression('Type %s PCD Value Size is Lar= ger than 1 byte' % self.PcdType) + raise BadExpression( + 'Type %s PCD Value Size is Larger than 1 byte'= % self.PcdType) if self.PcdType =3D=3D TAB_UINT16 and Size > 2: - raise BadExpression('Type %s PCD Value Size is Lar= ger than 2 byte' % self.PcdType) + raise BadExpression( + 'Type %s PCD Value Size is Larger than 2 byte'= % self.PcdType) if self.PcdType =3D=3D TAB_UINT32 and Size > 4: - raise BadExpression('Type %s PCD Value Size is Lar= ger than 4 byte' % self.PcdType) + raise BadExpression( + 'Type %s PCD Value Size is Larger than 4 byte'= % self.PcdType) if self.PcdType =3D=3D TAB_UINT64 and Size > 8: - raise BadExpression('Type %s PCD Value Size is Lar= ger than 8 byte' % self.PcdType) + raise BadExpression( + 'Type %s PCD Value Size is Larger than 8 byte'= % self.PcdType) else: try: TmpValue =3D int(PcdValue) @@ -914,11 +943,13 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D '{0x00}' else: for I in range((TmpValue.bit_length() + 7) // = 8): - TmpList.append('0x%02x' % ((TmpValue >> I = * 8) & 0xff)) + TmpList.append('0x%02x' % + ((TmpValue >> I * 8) & 0xff= )) PcdValue =3D '{' + ', '.join(TmpList) + '}' except: if PcdValue.strip().startswith('{'): - PcdValueList =3D SplitPcdValueString(PcdValue.= strip()[1:-1]) + PcdValueList =3D SplitPcdValueString( + PcdValue.strip()[1:-1]) LabelDict =3D {} NewPcdValueList =3D [] LabelOffset =3D 0 @@ -930,7 +961,8 @@ class ValueExpressionEx(ValueExpression): if LabelList: for Label in LabelList: if not IsValidCName(Label): - raise BadExpression('%s is not= a valid c variable name' % Label) + raise BadExpression( + '%s is not a valid c varia= ble name' % Label) if Label not in LabelDict: LabelDict[Label] =3D str(Label= Offset) if Item.startswith(TAB_UINT8): @@ -943,7 +975,8 @@ class ValueExpressionEx(ValueExpression): LabelOffset =3D LabelOffset + 8 else: try: - ItemValue, ItemSize =3D ParseField= Value(Item) + ItemValue, ItemSize =3D ParseField= Value( + Item) LabelOffset =3D LabelOffset + Item= Size except: LabelOffset =3D LabelOffset + 1 @@ -962,9 +995,11 @@ class ValueExpressionEx(ValueExpression): # replace each offset, except errors for Offset in OffsetList: try: - Item =3D Item.replace('OFFSET_OF({= })'.format(Offset), LabelDict[Offset]) + Item =3D Item.replace('OFFSET_OF({= })'.format( + Offset), LabelDict[Offset]) except: - raise BadExpression('%s not define= d' % Offset) + raise BadExpression( + '%s not defined' % Offset) =20 NewPcdValueList.append(Item) =20 @@ -975,13 +1010,16 @@ class ValueExpressionEx(ValueExpression): TokenSpaceGuidName =3D '' if Item.startswith(TAB_GUID) and Item.ends= with(')'): try: - TokenSpaceGuidName =3D re.search('= GUID\((\w+)\)', Item).group(1) + TokenSpaceGuidName =3D re.search( + 'GUID\((\w+)\)', Item).group(1) except: pass if TokenSpaceGuidName and TokenSpaceGu= idName in self._Symb: - Item =3D 'GUID(' + self._Symb[Toke= nSpaceGuidName] + ')' + Item =3D 'GUID(' + \ + self._Symb[TokenSpaceGuidName]= + ')' elif TokenSpaceGuidName: - raise BadExpression('%s not found = in DEC file' % TokenSpaceGuidName) + raise BadExpression( + '%s not found in DEC file' % T= okenSpaceGuidName) Item, Size =3D ParseFieldValue(Item) for Index in range(0, Size): ValueStr =3D '0x%02X' % (int(Item)= & 255) @@ -1009,26 +1047,34 @@ class ValueExpressionEx(ValueExpression): else: ItemSize =3D 0 if ValueType: - TmpValue =3D ValueExpressionEx(Ite= m, ValueType, self._Symb)(True) + TmpValue =3D ValueExpressionEx( + Item, ValueType, self._Symb)(T= rue) else: - TmpValue =3D ValueExpressionEx(Ite= m, self.PcdType, self._Symb)(True) - Item =3D '0x%x' % TmpValue if not isin= stance(TmpValue, type('')) else TmpValue + TmpValue =3D ValueExpressionEx( + Item, self.PcdType, self._Symb= )(True) + Item =3D '0x%x' % TmpValue if not isin= stance( + TmpValue, type('')) else TmpValue if ItemSize =3D=3D 0: - ItemValue, ItemSize =3D ParseField= Value(Item) + ItemValue, ItemSize =3D ParseField= Value( + Item) if Item[0] not in {'"', 'L', '{'} = and ItemSize > 1: - raise BadExpression("Byte arr= ay number %s should less than 0xFF." % Item) + raise BadExpression( + "Byte array number %s sho= uld less than 0xFF." % Item) else: ItemValue =3D ParseFieldValue(Item= )[0] for I in range(0, ItemSize): - ValueStr =3D '0x%02X' % (int(ItemV= alue) & 255) + ValueStr =3D '0x%02X' % ( + int(ItemValue) & 255) ItemValue >>=3D 8 AllPcdValueList.append(ValueStr) Size +=3D ItemSize =20 if Size > 0: - PcdValue =3D '{' + ','.join(AllPcdValueLis= t) + '}' + PcdValue =3D '{' + \ + ','.join(AllPcdValueList) + '}' else: - raise BadExpression("Type: %s, Value: %s, %s"= %(self.PcdType, PcdValue, Value)) + raise BadExpression("Type: %s, Value: %s, %s" = % ( + self.PcdType, PcdValue, Value)) =20 if PcdValue =3D=3D 'True': PcdValue =3D '1' @@ -1038,6 +1084,7 @@ class ValueExpressionEx(ValueExpression): if RealValue: return PcdValue =20 + if __name__ =3D=3D '__main__': pass while True: diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index 197bd8366682..34cd90987566 100755 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common static strings used by INF/DEC/DSC fi= les # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -35,32 +35,35 @@ gGuidDict =3D {} # definition for a MACRO name. used to create regular expressions below. _MacroNamePattern =3D "[A-Z][A-Z0-9_]*" =20 -## Regular expression for matching macro used in DSC/DEC/INF file inclusion -gMacroRefPattern =3D re.compile("\$\(({})\)".format(_MacroNamePattern), re= .UNICODE) +# Regular expression for matching macro used in DSC/DEC/INF file inclusion +gMacroRefPattern =3D re.compile( + "\$\(({})\)".format(_MacroNamePattern), re.UNICODE) gMacroDefPattern =3D re.compile("^(DEFINE|EDK_GLOBAL)[ \t]+") gMacroNamePattern =3D re.compile("^{}$".format(_MacroNamePattern)) =20 # definition for a GUID. used to create regular expressions below. _HexChar =3D r"[0-9a-fA-F]" -_GuidPattern =3D r"{Hex}{{8}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{12}}= ".format(Hex=3D_HexChar) +_GuidPattern =3D r"{Hex}{{8}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{4}}-{Hex}{{12}}= ".format( + Hex=3D_HexChar) =20 -## Regular expressions for GUID matching +# Regular expressions for GUID matching gGuidPattern =3D re.compile(r'{}'.format(_GuidPattern)) gGuidPatternEnd =3D re.compile(r'{}$'.format(_GuidPattern)) =20 -## Regular expressions for HEX matching +# Regular expressions for HEX matching g4HexChar =3D re.compile(r'{}{{4}}'.format(_HexChar)) gHexPattern =3D re.compile(r'0[xX]{}+'.format(_HexChar)) gHexPatternAll =3D re.compile(r'0[xX]{}+$'.format(_HexChar)) =20 -## Regular expressions for string identifier checking +# Regular expressions for string identifier checking gIdentifierPattern =3D re.compile('^[a-zA-Z][a-zA-Z0-9_]*$', re.UNICODE) -## Regular expression for GUID c structure format +# Regular expression for GUID c structure format _GuidCFormatPattern =3D r"{{\s*0[xX]{Hex}{{1,8}}\s*,\s*0[xX]{Hex}{{1,4}}\s= *,\s*0[xX]{Hex}{{1,4}}" \ r"\s*,\s*{{\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,= 2}}" \ r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \ r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}" \ - r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}\s= *}}\s*}}".format(Hex=3D_HexChar) + r"\s*,\s*0[xX]{Hex}{{1,2}}\s*,\s*0[xX]{Hex}{{1,2}}\s= *}}\s*}}".format( + Hex=3D_HexChar) gGuidCFormatPattern =3D re.compile(r"{}".format(_GuidCFormatPattern)) =20 # @@ -98,7 +101,7 @@ MixedPcd =3D {} =20 # Structure Pcd dict gStructurePcd =3D {} -gPcdSkuOverrides=3D{} +gPcdSkuOverrides =3D {} # Pcd name for the Pcd which used in the Conditional directives gConditionalPcds =3D [] =20 @@ -122,4 +125,3 @@ gEnableGenfdsMultiThread =3D True gSikpAutoGenCache =3D set() # Common lock for the file access in multiple process AutoGens file_lock =3D None - diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/S= ource/Python/Common/LongFilePathOs.py index 190f36d7ec15..1f205ce14231 100644 --- a/BaseTools/Source/Python/Common/LongFilePathOs.py +++ b/BaseTools/Source/Python/Common/LongFilePathOs.py @@ -1,4 +1,4 @@ -## @file +# @file # Override built in module os to provide support for long file path # # Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
        @@ -13,46 +13,58 @@ import time =20 path =3D LongFilePathOsPath =20 + def access(path, mode): return os.access(LongFilePath(path), mode) =20 + def remove(path): - Timeout =3D 0.0 - while Timeout < 5.0: - try: - return os.remove(LongFilePath(path)) - except: - time.sleep(0.1) - Timeout =3D Timeout + 0.1 - return os.remove(LongFilePath(path)) + Timeout =3D 0.0 + while Timeout < 5.0: + try: + return os.remove(LongFilePath(path)) + except: + time.sleep(0.1) + Timeout =3D Timeout + 0.1 + return os.remove(LongFilePath(path)) + =20 def removedirs(name): return os.removedirs(LongFilePath(name)) =20 + def rmdir(path): return os.rmdir(LongFilePath(path)) =20 + def mkdir(path): return os.mkdir(LongFilePath(path)) =20 + def makedirs(name, mode=3D0o777): return os.makedirs(LongFilePath(name), mode) =20 + def rename(old, new): return os.rename(LongFilePath(old), LongFilePath(new)) =20 + def chdir(path): return os.chdir(LongFilePath(path)) =20 + def chmod(path, mode): return os.chmod(LongFilePath(path), mode) =20 + def stat(path): return os.stat(LongFilePath(path)) =20 + def utime(path, times): return os.utime(LongFilePath(path), times) =20 + def listdir(path): List =3D [] uList =3D os.listdir(u"%s" % LongFilePath(path)) @@ -60,6 +72,7 @@ def listdir(path): List.append(Item) return List =20 + if hasattr(os, 'replace'): def replace(src, dst): return os.replace(LongFilePath(src), LongFilePath(dst)) diff --git a/BaseTools/Source/Python/Common/LongFilePathOsPath.py b/BaseToo= ls/Source/Python/Common/LongFilePathOsPath.py index 60a053652550..543ecb1b7bcd 100644 --- a/BaseTools/Source/Python/Common/LongFilePathOsPath.py +++ b/BaseTools/Source/Python/Common/LongFilePathOsPath.py @@ -1,4 +1,4 @@ -## @file +# @file # Override built in module os.path to provide support for long file path # # Copyright (c) 2014, Intel Corporation. All rights reserved.
        @@ -8,27 +8,35 @@ import os from Common.LongFilePathSupport import LongFilePath =20 + def isfile(path): return os.path.isfile(LongFilePath(path)) =20 + def isdir(path): return os.path.isdir(LongFilePath(path)) =20 + def exists(path): return os.path.exists(LongFilePath(path)) =20 + def getsize(filename): return os.path.getsize(LongFilePath(filename)) =20 + def getmtime(filename): return os.path.getmtime(LongFilePath(filename)) =20 + def getatime(filename): return os.path.getatime(LongFilePath(filename)) =20 + def getctime(filename): return os.path.getctime(LongFilePath(filename)) =20 + join =3D os.path.join splitext =3D os.path.splitext splitdrive =3D os.path.splitdrive diff --git a/BaseTools/Source/Python/Common/LongFilePathSupport.py b/BaseTo= ols/Source/Python/Common/LongFilePathSupport.py index 38c4396544cc..ca6962e0a177 100644 --- a/BaseTools/Source/Python/Common/LongFilePathSupport.py +++ b/BaseTools/Source/Python/Common/LongFilePathSupport.py @@ -1,4 +1,4 @@ -## @file +# @file # Override built in function file.open to provide support for long file pa= th # # Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
        @@ -14,6 +14,8 @@ import codecs # OpenLongPath # Convert a file path to a long file path # + + def LongFilePath(FileName): FileName =3D os.path.normpath(FileName) if platform.system() =3D=3D 'Windows': @@ -29,9 +31,12 @@ def LongFilePath(FileName): # OpenLongFilePath # wrap open to support opening a long file path # -def OpenLongFilePath(FileName, Mode=3D'r', Buffer=3D -1): + + +def OpenLongFilePath(FileName, Mode=3D'r', Buffer=3D-1): return open(LongFilePath(FileName), Mode, Buffer) =20 + def CodecOpenLongFilePath(Filename, Mode=3D'rb', Encoding=3DNone, Errors= =3D'strict', Buffering=3D1): return codecs.open(LongFilePath(Filename), Mode, Encoding, Errors, Buf= fering) =20 @@ -39,6 +44,8 @@ def CodecOpenLongFilePath(Filename, Mode=3D'rb', Encoding= =3DNone, Errors=3D'strict', B # CopyLongFilePath # wrap copyfile to support copy a long file path # + + def CopyLongFilePath(src, dst): with open(LongFilePath(src), 'rb') as fsrc: with open(LongFilePath(dst), 'wb') as fdst: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 4be7957138a5..4dcf72d37e28 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1,4 +1,4 @@ -## @file +# @file # Common routines used by all tools # # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
        @@ -42,19 +42,22 @@ from Common.caching import cached_property import struct =20 ArrayIndex =3D re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") -## Regular expression used to find out place holders in string template -gPlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.= UNICODE) +# Regular expression used to find out place holders in string template +gPlaceholderPattern =3D re.compile( + "\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE) =20 -## regular expressions for map file processing +# regular expressions for map file processing startPatternGeneral =3D re.compile("^Start[' ']+Length[' ']+Name[' ']+Clas= s") -addressPatternGeneral =3D re.compile("^Address[' ']+Publics by Value[' ']+= Rva\+Base") +addressPatternGeneral =3D re.compile( + "^Address[' ']+Publics by Value[' ']+Rva\+Base") valuePatternGcc =3D re.compile('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+= )$') pcdPatternGcc =3D re.compile('^([\da-fA-Fx]+) +([\da-fA-Fx]+)') -secReGeneral =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[H= h]? +([.\w\$]+) +(\w+)', re.UNICODE) +secReGeneral =3D re.compile( + '^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)',= re.UNICODE) =20 StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$') =20 -## Dictionary used to store dependencies of files +# Dictionary used to store dependencies of files gDependencyDatabase =3D {} # arch : {file path : [dependent files list]} =20 # @@ -64,6 +67,7 @@ gDependencyDatabase =3D {} # arch : {file path : [depe= ndent files list]} # _TempInfs =3D [] =20 + def GetVariableOffset(mapfilepath, efifilepath, varnames): """ Parse map file to get variable offset in current EFI file @param mapfilepath Map file absolution path @@ -80,35 +84,39 @@ def GetVariableOffset(mapfilepath, efifilepath, varname= s): except: return None =20 - if len(lines) =3D=3D 0: return None + if len(lines) =3D=3D 0: + return None firstline =3D lines[0].strip() if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firs= tline): return _parseForXcodeAndClang9(lines, efifilepath, varnames) if (firstline.startswith("Archive member included ") and - firstline.endswith(" file (symbol)")): + firstline.endswith(" file (symbol)")): return _parseForGCC(lines, efifilepath, varnames) if firstline.startswith("# Path:"): return _parseForXcodeAndClang9(lines, efifilepath, varnames) return _parseGeneral(lines, efifilepath, varnames) =20 + def _parseForXcodeAndClang9(lines, efifilepath, varnames): status =3D 0 ret =3D [] for line in lines: line =3D line.strip() - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) \ - or line =3D=3D "# Symbols:"): + if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) + or line =3D=3D "# Symbols:"): status =3D 1 continue if status =3D=3D 1 and len(line) !=3D 0: for varname in varnames: if varname in line: # cannot pregenerate this RegEx since it uses varname = from varnames. - m =3D re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % = varname, line) + m =3D re.match( + '^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, li= ne) if m is not None: ret.append((varname, m.group(1))) return ret =20 + def _parseForGCC(lines, efifilepath, varnames): """ Parse map file generated by GCC linker """ status =3D 0 @@ -123,7 +131,7 @@ def _parseForGCC(lines, efifilepath, varnames): elif status =3D=3D 1 and line =3D=3D 'Linker script and memory map= ': status =3D 2 continue - elif status =3D=3D2 and line =3D=3D 'START GROUP': + elif status =3D=3D 2 and line =3D=3D 'START GROUP': status =3D 3 continue =20 @@ -144,7 +152,8 @@ def _parseForGCC(lines, efifilepath, varnames): if Str: m =3D pcdPatternGcc.match(Str.strip()) if m is not None: - varoffset.append((varname, int(m.groups(0)[0],= 16), int(sections[-1][1], 16), sections[-1][0])) + varoffset.append((varname, int(m.groups(0)[0],= 16), int( + sections[-1][1], 16), sections[-1][0])) =20 if not varoffset: return [] @@ -152,7 +161,7 @@ def _parseForGCC(lines, efifilepath, varnames): efisecs =3D PeImageClass(efifilepath).SectionHeaderList if efisecs is None or len(efisecs) =3D=3D 0: return [] - #redirection + # redirection redirection =3D 0 for efisec in efisecs: for section in sections: @@ -163,14 +172,17 @@ def _parseForGCC(lines, efifilepath, varnames): for var in varoffset: for efisec in efisecs: if var[1] >=3D efisec[1] and var[1] < efisec[1]+efisec[3]: - ret.append((var[0], hex(efisec[2] + var[1] - efisec[1] - r= edirection))) + ret.append( + (var[0], hex(efisec[2] + var[1] - efisec[1] - redirect= ion))) return ret =20 + def _parseGeneral(lines, efifilepath, varnames): - status =3D 0 #0 - beginning of file; 1 - PE section definition; 2 -= symbol table - secs =3D [] # key =3D section name + status =3D 0 # 0 - beginning of file; 1 - PE section definition; 2 - = symbol table + secs =3D [] # key =3D section name varoffset =3D [] - symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]= +) +([\da-fA-F]+)', re.UNICODE) + symRe =3D re.compile( + '^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$-]+) +([\da-fA-F]+)= ', re.UNICODE) =20 for line in lines: line =3D line.strip() @@ -184,27 +196,30 @@ def _parseGeneral(lines, efifilepath, varnames): status =3D 3 continue if status =3D=3D 1 and len(line) !=3D 0: - m =3D secReGeneral.match(line) + m =3D secReGeneral.match(line) assert m is not None, "Fail to parse the section in map file ,= line is %s" % line sec_no, sec_start, sec_length, sec_name, sec_class =3D m.group= s(0) - secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_leng= th, 16), sec_name, sec_class]) + secs.append([int(sec_no, 16), int(sec_start, 16), + int(sec_length, 16), sec_name, sec_class]) if status =3D=3D 2 and len(line) !=3D 0: for varname in varnames: m =3D symRe.match(line) assert m is not None, "Fail to parse the symbol in map fil= e, line is %s" % line sec_no, sym_offset, sym_name, vir_addr =3D m.groups(0) - sec_no =3D int(sec_no, 16) + sec_no =3D int(sec_no, 16) sym_offset =3D int(sym_offset, 16) - vir_addr =3D int(vir_addr, 16) + vir_addr =3D int(vir_addr, 16) # cannot pregenerate this RegEx since it uses varname from= varnames. m2 =3D re.match('^[_]*(%s)' % varname, sym_name) if m2 is not None: # fond a binary pcd entry in map file for sec in secs: if sec[0] =3D=3D sec_no and (sym_offset >=3D sec[1= ] and sym_offset < sec[1] + sec[2]): - varoffset.append([varname, sec[3], sym_offset,= vir_addr, sec_no]) + varoffset.append( + [varname, sec[3], sym_offset, vir_addr, se= c_no]) =20 - if not varoffset: return [] + if not varoffset: + return [] =20 # get section information from efi file efisecs =3D PeImageClass(efifilepath).SectionHeaderList @@ -223,7 +238,7 @@ def _parseGeneral(lines, efifilepath, varnames): =20 return ret =20 -## Routine to process duplicated INF +# Routine to process duplicated INF # # This function is called by following two cases: # Case 1 in DSC: @@ -245,6 +260,8 @@ def _parseGeneral(lines, efifilepath, varnames): # # @retval return the new PathClass object # + + def ProcessDuplicatedInf(Path, BaseName, Workspace): Filename =3D os.path.split(Path.File)[1] if '.' in Filename: @@ -295,20 +312,24 @@ def ProcessDuplicatedInf(Path, BaseName, Workspace): shutil.copy2(str(Path), TempFullPath) return RtPath =20 -## Remove temporary created INFs whose paths were saved in _TempInfs +# Remove temporary created INFs whose paths were saved in _TempInfs # + + def ClearDuplicatedInf(): while _TempInfs: File =3D _TempInfs.pop() if os.path.exists(File): os.remove(File) =20 -## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C = structure style +# Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C s= tructure style # # @param Guid The GUID string # # @retval string The GUID string in C structure style # + + def GuidStringToGuidStructureString(Guid): GuidList =3D Guid.split('-') Result =3D '{' @@ -320,100 +341,112 @@ def GuidStringToGuidStructureString(Guid): Result +=3D '}}' return Result =20 -## Convert GUID structure in byte array to xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxx= xxxxx +# Convert GUID structure in byte array to xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx= xxxx # # @param GuidValue The GUID value in byte array # # @retval string The GUID value in xxxxxxxx-xxxx-xxxx-xxxx-xxxx= xxxxxxxx format # + + def GuidStructureByteArrayToGuidString(GuidValue): - guidValueString =3D GuidValue.lower().replace("{", "").replace("}", ""= ).replace(" ", "").replace(";", "") + guidValueString =3D GuidValue.lower().replace( + "{", "").replace("}", "").replace(" ", "").replace(";", "") guidValueList =3D guidValueString.split(",") if len(guidValueList) !=3D 16: return '' #EdkLogger.error(None, None, "Invalid GUID value string %s" % Guid= Value) try: return "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%0= 2x%02x%02x" % ( - int(guidValueList[3], 16), - int(guidValueList[2], 16), - int(guidValueList[1], 16), - int(guidValueList[0], 16), - int(guidValueList[5], 16), - int(guidValueList[4], 16), - int(guidValueList[7], 16), - int(guidValueList[6], 16), - int(guidValueList[8], 16), - int(guidValueList[9], 16), - int(guidValueList[10], 16), - int(guidValueList[11], 16), - int(guidValueList[12], 16), - int(guidValueList[13], 16), - int(guidValueList[14], 16), - int(guidValueList[15], 16) - ) + int(guidValueList[3], 16), + int(guidValueList[2], 16), + int(guidValueList[1], 16), + int(guidValueList[0], 16), + int(guidValueList[5], 16), + int(guidValueList[4], 16), + int(guidValueList[7], 16), + int(guidValueList[6], 16), + int(guidValueList[8], 16), + int(guidValueList[9], 16), + int(guidValueList[10], 16), + int(guidValueList[11], 16), + int(guidValueList[12], 16), + int(guidValueList[13], 16), + int(guidValueList[14], 16), + int(guidValueList[15], 16) + ) except: return '' =20 -## Convert GUID string in C structure style to xxxxxxxx-xxxx-xxxx-xxxx-xxx= xxxxxxxxx +# Convert GUID string in C structure style to xxxxxxxx-xxxx-xxxx-xxxx-xxxx= xxxxxxxx # # @param GuidValue The GUID value in C structure format # # @retval string The GUID value in xxxxxxxx-xxxx-xxxx-xxxx-xxxx= xxxxxxxx format # + + def GuidStructureStringToGuidString(GuidValue): if not GlobalData.gGuidCFormatPattern.match(GuidValue): return '' - guidValueString =3D GuidValue.lower().replace("{", "").replace("}", ""= ).replace(" ", "").replace(";", "") + guidValueString =3D GuidValue.lower().replace( + "{", "").replace("}", "").replace(" ", "").replace(";", "") guidValueList =3D guidValueString.split(",") if len(guidValueList) !=3D 11: return '' #EdkLogger.error(None, None, "Invalid GUID value string %s" % Guid= Value) try: return "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % ( - int(guidValueList[0], 16), - int(guidValueList[1], 16), - int(guidValueList[2], 16), - int(guidValueList[3], 16), - int(guidValueList[4], 16), - int(guidValueList[5], 16), - int(guidValueList[6], 16), - int(guidValueList[7], 16), - int(guidValueList[8], 16), - int(guidValueList[9], 16), - int(guidValueList[10], 16) - ) + int(guidValueList[0], 16), + int(guidValueList[1], 16), + int(guidValueList[2], 16), + int(guidValueList[3], 16), + int(guidValueList[4], 16), + int(guidValueList[5], 16), + int(guidValueList[6], 16), + int(guidValueList[7], 16), + int(guidValueList[8], 16), + int(guidValueList[9], 16), + int(guidValueList[10], 16) + ) except: return '' =20 -## Convert GUID string in C structure style to xxxxxxxx_xxxx_xxxx_xxxx_xxx= xxxxxxxxx +# Convert GUID string in C structure style to xxxxxxxx_xxxx_xxxx_xxxx_xxxx= xxxxxxxx # # @param GuidValue The GUID value in C structure format # # @retval string The GUID value in xxxxxxxx_xxxx_xxxx_xxxx_xxxx= xxxxxxxx format # + + def GuidStructureStringToGuidValueName(GuidValue): - guidValueString =3D GuidValue.lower().replace("{", "").replace("}", ""= ).replace(" ", "") + guidValueString =3D GuidValue.lower().replace( + "{", "").replace("}", "").replace(" ", "") guidValueList =3D guidValueString.split(",") if len(guidValueList) !=3D 11: - EdkLogger.error(None, FORMAT_INVALID, "Invalid GUID value string [= %s]" % GuidValue) + EdkLogger.error(None, FORMAT_INVALID, + "Invalid GUID value string [%s]" % GuidValue) return "%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x" % ( - int(guidValueList[0], 16), - int(guidValueList[1], 16), - int(guidValueList[2], 16), - int(guidValueList[3], 16), - int(guidValueList[4], 16), - int(guidValueList[5], 16), - int(guidValueList[6], 16), - int(guidValueList[7], 16), - int(guidValueList[8], 16), - int(guidValueList[9], 16), - int(guidValueList[10], 16) - ) + int(guidValueList[0], 16), + int(guidValueList[1], 16), + int(guidValueList[2], 16), + int(guidValueList[3], 16), + int(guidValueList[4], 16), + int(guidValueList[5], 16), + int(guidValueList[6], 16), + int(guidValueList[7], 16), + int(guidValueList[8], 16), + int(guidValueList[9], 16), + int(guidValueList[10], 16) + ) =20 -## Create directories +# Create directories # # @param Directory The directory name # + + def CreateDirectory(Directory): if Directory is None or Directory.strip() =3D=3D "": return True @@ -424,10 +457,12 @@ def CreateDirectory(Directory): return False return True =20 -## Remove directories, including files and sub-directories in it +# Remove directories, including files and sub-directories in it # # @param Directory The directory name # + + def RemoveDirectory(Directory, Recursively=3DFalse): if Directory is None or Directory.strip() =3D=3D "" or not os.path.exi= sts(Directory): return @@ -442,7 +477,7 @@ def RemoveDirectory(Directory, Recursively=3DFalse): os.chdir(CurrentDirectory) os.rmdir(Directory) =20 -## Store content in file +# Store content in file # # This method is used to save file only when its content is changed. This= is # quite useful for "make" system to decide what will be re-built and what= won't. @@ -454,6 +489,8 @@ def RemoveDirectory(Directory, Recursively=3DFalse): # @retval True If the file content is changed and the fil= e is renewed # @retval False If the file content is the same # + + def SaveFileOnChange(File, Content, IsBinaryFile=3DTrue, FileLock=3DNone): =20 # Convert to long file path format @@ -477,12 +514,14 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTr= ue, FileLock=3DNone): =20 DirName =3D os.path.dirname(File) if not CreateDirectory(DirName): - EdkLogger.error(None, FILE_CREATE_FAILURE, "Could not create direc= tory %s" % DirName) + EdkLogger.error(None, FILE_CREATE_FAILURE, + "Could not create directory %s" % DirName) else: if DirName =3D=3D '': DirName =3D os.getcwd() if not os.access(DirName, os.W_OK): - EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write p= ermission on directory %s" % DirName) + EdkLogger.error(None, PERMISSION_FAILURE, + "Do not have write permission on directory %s"= % DirName) =20 OpenMode =3D "w" if IsBinaryFile: @@ -494,16 +533,17 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTr= ue, FileLock=3DNone): if FileLock: FileLock.acquire() =20 - if GlobalData.gIsWindows and not os.path.exists(File): try: with open(File, OpenMode) as tf: tf.write(Content) except IOError as X: if GlobalData.gBinCacheSource: - EdkLogger.quiet("[cache error]:fails to save file with err= or: %s" % (X)) + EdkLogger.quiet( + "[cache error]:fails to save file with error: %s" % (X= )) else: - EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=3D'IO= Error %s' % X) + EdkLogger.error(None, FILE_CREATE_FAILURE, + ExtraData=3D'IOError %s' % X) finally: if FileLock: FileLock.release() @@ -513,16 +553,18 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTr= ue, FileLock=3DNone): Fd.write(Content) except IOError as X: if GlobalData.gBinCacheSource: - EdkLogger.quiet("[cache error]:fails to save file with err= or: %s" % (X)) + EdkLogger.quiet( + "[cache error]:fails to save file with error: %s" % (X= )) else: - EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=3D'IO= Error %s' % X) + EdkLogger.error(None, FILE_CREATE_FAILURE, + ExtraData=3D'IOError %s' % X) finally: if FileLock: FileLock.release() =20 return True =20 -## Copy source file only if it is different from the destination file +# Copy source file only if it is different from the destination file # # This method is used to copy file only if the source file and destination # file content are different. This is quite useful to avoid duplicated @@ -534,6 +576,8 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTrue= , FileLock=3DNone): # @retval True The two files content are different and the file= is copied # @retval False No copy really happen # + + def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): =20 # Convert to long file path format @@ -541,7 +585,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): Dst =3D LongFilePath(Dst) =20 if os.path.isdir(SrcFile): - EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData=3D'CopyFileOnCh= ange SrcFile is a dir, not a file: %s' % SrcFile) + EdkLogger.error(None, FILE_COPY_FAILURE, + ExtraData=3D'CopyFileOnChange SrcFile is a dir, no= t a file: %s' % SrcFile) return False =20 if os.path.isdir(Dst): @@ -554,12 +599,14 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): =20 DirName =3D os.path.dirname(DstFile) if not CreateDirectory(DirName): - EdkLogger.error(None, FILE_CREATE_FAILURE, "Could not create direc= tory %s" % DirName) + EdkLogger.error(None, FILE_CREATE_FAILURE, + "Could not create directory %s" % DirName) else: if DirName =3D=3D '': DirName =3D os.getcwd() if not os.access(DirName, os.W_OK): - EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write p= ermission on directory %s" % DirName) + EdkLogger.error(None, PERMISSION_FAILURE, + "Do not have write permission on directory %s"= % DirName) =20 # use default file_lock if no input new lock if not FileLock: @@ -571,22 +618,26 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=3DNone): CopyLong(SrcFile, DstFile) except IOError as X: if GlobalData.gBinCacheSource: - EdkLogger.quiet("[cache error]:fails to copy file with error: = %s" % (X)) + EdkLogger.quiet( + "[cache error]:fails to copy file with error: %s" % (X)) else: - EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData=3D'IOError = %s' % X) + EdkLogger.error(None, FILE_COPY_FAILURE, + ExtraData=3D'IOError %s' % X) finally: if FileLock: FileLock.release() =20 return True =20 -## Retrieve and cache the real path name in file system +# Retrieve and cache the real path name in file system # # @param Root The root directory of path relative to # # @retval str The path string if the path exists # @retval None If path doesn't exist # + + class DirCache: _CACHE_ =3D set() _UPPER_CACHE_ =3D {} @@ -651,6 +702,7 @@ class DirCache: return os.path.join(self._Root, self._UPPER_CACHE_[UpperPath]) return None =20 + def RealPath(File, Dir=3D'', OverrideDir=3D''): NewFile =3D os.path.normpath(os.path.join(Dir, File)) NewFile =3D GlobalData.gAllFiles[NewFile] @@ -659,7 +711,7 @@ def RealPath(File, Dir=3D'', OverrideDir=3D''): NewFile =3D GlobalData.gAllFiles[NewFile] return NewFile =20 -## Get GUID value from given packages +# Get GUID value from given packages # # @param CName The CName of the GUID # @param PackageList List of packages looking-up in @@ -668,7 +720,9 @@ def RealPath(File, Dir=3D'', OverrideDir=3D''): # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # -def GuidValue(CName, PackageList, Inffile =3D None): + + +def GuidValue(CName, PackageList, Inffile=3DNone): for P in PackageList: GuidKeys =3D list(P.Guids.keys()) if Inffile and P._PrivateGuids: @@ -678,7 +732,7 @@ def GuidValue(CName, PackageList, Inffile =3D None): return P.Guids[CName] return None =20 -## A string template class +# A string template class # # This class implements a template for string replacement. A string templ= ate # looks like following @@ -691,6 +745,8 @@ def GuidValue(CName, PackageList, Inffile =3D None): # be not used and, in this case, the "placeholder_name" must not a list a= nd it # will just be replaced once. # + + class TemplateString(object): _REPEAT_START_FLAG =3D "BEGIN" _REPEAT_END_FLAG =3D "END" @@ -712,12 +768,14 @@ class TemplateString(object): # PlaceHolderName, PlaceHolderStartPoint, PlaceHolderEnd= Point # for PlaceHolder, Start, End in PlaceHolderList: - self._SubSectionList.append(TemplateSection[SubSection= Start:Start]) + self._SubSectionList.append( + TemplateSection[SubSectionStart:Start]) self._SubSectionList.append(TemplateSection[Start:End]) self._PlaceHolderList.append(PlaceHolder) SubSectionStart =3D End if SubSectionStart < len(TemplateSection): - self._SubSectionList.append(TemplateSection[SubSection= Start:]) + self._SubSectionList.append( + TemplateSection[SubSectionStart:]) else: self._SubSectionList =3D [TemplateSection] =20 @@ -738,11 +796,11 @@ class TemplateString(object): RepeatTime =3D len(Value) elif RepeatTime !=3D len(Value): EdkLogger.error( - "TemplateString", - PARAMETER_INVALID, - "${%s} has different repeat time from = others!" % PlaceHolder, - ExtraData=3Dstr(self._Template) - ) + "TemplateString", + PARAMETER_INVALID, + "${%s} has different repeat time from others!"= % PlaceHolder, + ExtraData=3Dstr(self._Template) + ) RepeatPlaceHolders["${%s}" % PlaceHolder] =3D Value else: NonRepeatPlaceHolders["${%s}" % PlaceHolder] =3D Value @@ -764,26 +822,27 @@ class TemplateString(object): if S not in RepeatPlaceHolders: TempStringList.append(S) else: - TempStringList.append(str(RepeatPlaceHolders[S= ][Index])) + TempStringList.append( + str(RepeatPlaceHolders[S][Index])) StringList =3D TempStringList =20 return "".join(StringList) =20 - ## Constructor + # Constructor def __init__(self, Template=3DNone): self.String =3D [] self.IsBinary =3D False self._Template =3D Template self._TemplateSectionList =3D self._Parse(Template) =20 - ## str() operator + # str() operator # # @retval string The string replaced # def __str__(self): return "".join(self.String) =20 - ## Split the template string into fragments per the ${BEGIN} and ${END= } flags + # Split the template string into fragments per the ${BEGIN} and ${END}= flags # # @retval list A list of TemplateString.Section objects # @@ -797,7 +856,8 @@ class TemplateString(object): MatchObj =3D gPlaceholderPattern.search(Template, SearchFrom) if not MatchObj: if MatchEnd <=3D len(Template): - TemplateSection =3D TemplateString.Section(Template[Se= ctionStart:], PlaceHolderList) + TemplateSection =3D TemplateString.Section( + Template[SectionStart:], PlaceHolderList) TemplateSectionList.append(TemplateSection) break =20 @@ -807,21 +867,24 @@ class TemplateString(object): =20 if MatchString =3D=3D self._REPEAT_START_FLAG: if MatchStart > SectionStart: - TemplateSection =3D TemplateString.Section(Template[Se= ctionStart:MatchStart], PlaceHolderList) + TemplateSection =3D TemplateString.Section( + Template[SectionStart:MatchStart], PlaceHolderList) TemplateSectionList.append(TemplateSection) SectionStart =3D MatchEnd PlaceHolderList =3D [] elif MatchString =3D=3D self._REPEAT_END_FLAG: - TemplateSection =3D TemplateString.Section(Template[Sectio= nStart:MatchStart], PlaceHolderList) + TemplateSection =3D TemplateString.Section( + Template[SectionStart:MatchStart], PlaceHolderList) TemplateSectionList.append(TemplateSection) SectionStart =3D MatchEnd PlaceHolderList =3D [] else: - PlaceHolderList.append((MatchString, MatchStart - SectionS= tart, MatchEnd - SectionStart)) + PlaceHolderList.append( + (MatchString, MatchStart - SectionStart, MatchEnd - Se= ctionStart)) SearchFrom =3D MatchEnd return TemplateSectionList =20 - ## Replace the string template with dictionary of placeholders and app= end it to previous one + # Replace the string template with dictionary of placeholders and appe= nd it to previous one # # @param AppendString The string template to append # @param Dictionary The placeholder dictionaries @@ -829,14 +892,15 @@ class TemplateString(object): def Append(self, AppendString, Dictionary=3DNone): if Dictionary: SectionList =3D self._Parse(AppendString) - self.String.append( "".join(S.Instantiate(Dictionary) for S in= SectionList)) + self.String.append("".join(S.Instantiate(Dictionary) + for S in SectionList)) else: - if isinstance(AppendString,list): + if isinstance(AppendString, list): self.String.extend(AppendString) else: self.String.append(AppendString) =20 - ## Replace the string template with dictionary of placeholders + # Replace the string template with dictionary of placeholders # # @param Dictionary The placeholder dictionaries # @@ -845,17 +909,19 @@ class TemplateString(object): def Replace(self, Dictionary=3DNone): return "".join(S.Instantiate(Dictionary) for S in self._TemplateSe= ctionList) =20 -## Progress indicator class +# Progress indicator class # # This class makes use of thread to print progress on console. # + + class Progressor: # for avoiding deadloop _StopFlag =3D None _ProgressThread =3D None _CheckInterval =3D 0.25 =20 - ## Constructor + # Constructor # # @param OpenMessage The string printed before progress cha= racters # @param CloseMessage The string printed after progress char= acters @@ -870,7 +936,7 @@ class Progressor: if Progressor._StopFlag is None: Progressor._StopFlag =3D threading.Event() =20 - ## Start to print progress character + # Start to print progress character # # @param OpenMessage The string printed before progress cha= racters # @@ -879,11 +945,12 @@ class Progressor: self.PromptMessage =3D OpenMessage Progressor._StopFlag.clear() if Progressor._ProgressThread is None: - Progressor._ProgressThread =3D threading.Thread(target=3Dself.= _ProgressThreadEntry) + Progressor._ProgressThread =3D threading.Thread( + target=3Dself._ProgressThreadEntry) Progressor._ProgressThread.setDaemon(False) Progressor._ProgressThread.start() =20 - ## Stop printing progress character + # Stop printing progress character # # @param CloseMessage The string printed after progress char= acters # @@ -894,7 +961,7 @@ class Progressor: self.Abort() self.CodaMessage =3D OriginalCodaMessage =20 - ## Thread entry method + # Thread entry method def _ProgressThreadEntry(self): sys.stdout.write(self.PromptMessage + " ") sys.stdout.flush() @@ -909,7 +976,7 @@ class Progressor: sys.stdout.write(" " + self.CodaMessage + "\n") sys.stdout.flush() =20 - ## Abort the progress display + # Abort the progress display @staticmethod def Abort(): if Progressor._StopFlag is not None: @@ -919,7 +986,7 @@ class Progressor: Progressor._ProgressThread =3D None =20 =20 -## Dictionary using prioritized list as key +# Dictionary using prioritized list as key # class tdict: _ListType =3D type([]) @@ -957,7 +1024,7 @@ class tdict: =20 def _GetSingleValue(self, FirstKey, RestKeys): Value =3D None - #print "%s-%s" % (FirstKey, self._Level_) , + # print "%s-%s" % (FirstKey, self._Level_) , if self._Level_ > 1: if FirstKey =3D=3D self._Wildcard: if FirstKey in self.data: @@ -965,12 +1032,13 @@ class tdict: if Value is None: for Key in self.data: Value =3D self.data[Key][RestKeys] - if Value is not None: break + if Value is not None: + break else: if FirstKey in self.data: Value =3D self.data[FirstKey][RestKeys] if Value is None and self._Wildcard in self.data: - #print "Value=3DNone" + # print "Value=3DNone" Value =3D self.data[self._Wildcard][RestKeys] else: if FirstKey =3D=3D self._Wildcard: @@ -979,7 +1047,8 @@ class tdict: if Value is None: for Key in self.data: Value =3D self.data[Key] - if Value is not None: break + if Value is not None: + break else: if FirstKey in self.data: Value =3D self.data[FirstKey] @@ -1057,6 +1126,7 @@ class tdict: keys |=3D self.data[Key].GetKeys(KeyIndex - 1) return keys =20 + def AnalyzePcdExpression(Setting): RanStr =3D ''.join(sample(string.ascii_letters + string.digits, 8)) Setting =3D Setting.replace('\\\\', RanStr).strip() @@ -1094,20 +1164,22 @@ def AnalyzePcdExpression(Setting): StartPos =3D Pos + 1 for i, ch in enumerate(FieldList): if RanStr in ch: - FieldList[i] =3D ch.replace(RanStr,'\\\\') + FieldList[i] =3D ch.replace(RanStr, '\\\\') return FieldList =20 -def ParseFieldValue (Value): - def ParseDevPathValue (Value): + +def ParseFieldValue(Value): + def ParseDevPathValue(Value): if '\\' in Value: Value.replace('\\', '/').replace(' ', '') =20 Cmd =3D 'DevicePath ' + '"' + Value + '"' try: - p =3D subprocess.Popen(Cmd, stdout=3Dsubprocess.PIPE, stderr= =3Dsubprocess.PIPE, shell=3DTrue) + p =3D subprocess.Popen(Cmd, stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.PIPE, shell=3DTrue) out, err =3D p.communicate() except Exception as X: - raise BadExpression("DevicePath: %s" % (str(X)) ) + raise BadExpression("DevicePath: %s" % (str(X))) finally: subprocess._cleanup() p.stdout.close() @@ -1124,27 +1196,31 @@ def ParseFieldValue (Value): if isinstance(Value, type(0)): return Value, (Value.bit_length() + 7) // 8 if not isinstance(Value, type('')): - raise BadExpression('Type %s is %s' %(Value, type(Value))) + raise BadExpression('Type %s is %s' % (Value, type(Value))) Value =3D Value.strip() if Value.startswith(TAB_UINT8) and Value.endswith(')'): Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 1: - raise BadExpression('Value (%s) Size larger than %d' %(Value, = Size)) + raise BadExpression( + 'Value (%s) Size larger than %d' % (Value, Size)) return Value, 1 if Value.startswith(TAB_UINT16) and Value.endswith(')'): Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 2: - raise BadExpression('Value (%s) Size larger than %d' %(Value, = Size)) + raise BadExpression( + 'Value (%s) Size larger than %d' % (Value, Size)) return Value, 2 if Value.startswith(TAB_UINT32) and Value.endswith(')'): Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 4: - raise BadExpression('Value (%s) Size larger than %d' %(Value, = Size)) + raise BadExpression( + 'Value (%s) Size larger than %d' % (Value, Size)) return Value, 4 if Value.startswith(TAB_UINT64) and Value.endswith(')'): Value, Size =3D ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 8: - raise BadExpression('Value (%s) Size larger than %d' % (Value,= Size)) + raise BadExpression( + 'Value (%s) Size larger than %d' % (Value, Size)) return Value, 8 if Value.startswith(TAB_GUID) and Value.endswith(')'): Value =3D Value.split('(', 1)[1][:-1].strip() @@ -1158,7 +1234,7 @@ def ParseFieldValue (Value): try: Value =3D uuid.UUID(Value).bytes_le ValueL, ValueH =3D struct.unpack('2Q', Value) - Value =3D (ValueH << 64 ) | ValueL + Value =3D (ValueH << 64) | ValueL =20 except ValueError as Message: raise BadExpression(Message) @@ -1257,7 +1333,7 @@ def ParseFieldValue (Value): return 0, 1 return Value, 1 =20 -## AnalyzeDscPcd +# AnalyzeDscPcd # # Analyze DSC PCD value, since there is no data type info in DSC # This function is used to match functions (AnalyzePcdData) used for retr= ieving PCD value from database @@ -1282,6 +1358,8 @@ def ParseFieldValue (Value): # IsValid: True if conforming EBNF, otherwise False # Index: The index where PcdValue is in ValueList # + + def AnalyzeDscPcd(Setting, PcdType, DataType=3D''): FieldList =3D AnalyzePcdExpression(Setting) =20 @@ -1350,7 +1428,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=3D''): return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3 return [], False, 0 =20 -## AnalyzePcdData +# AnalyzePcdData # # Analyze the pcd Value, Datum type and TokenNumber. # Used to avoid split issue while the value string contain "|" character @@ -1359,6 +1437,8 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=3D''): # # @retval ValueList: A List contain value, datum type and toke number. # + + def AnalyzePcdData(Setting): ValueList =3D ['', '', ''] =20 @@ -1379,18 +1459,21 @@ def AnalyzePcdData(Setting): =20 return ValueList =20 -## check format of PCD value against its the datum type +# check format of PCD value against its the datum type # # For PCD value setting # + + def CheckPcdDatum(Type, Value): if Type =3D=3D TAB_VOID: ValueRe =3D re.compile(r'\s*L?\".*\"\s*$') if not (((Value.startswith('L"') or Value.startswith('"')) and Val= ue.endswith('"')) or (Value.startswith('{') and Value.endswith('}')) or (Val= ue.startswith("L'") or Value.startswith("'") and Value.endswith("'")) - ): + ): return False, "Invalid value [%s] of type [%s]; must be in the= form of {...} for array"\ - ", \"...\" or \'...\' for string, L\"...\" or L\= '...\' for unicode string" % (Value, Type) + ", \"...\" or \'...\' for string, L\"...\" or L\= '...\' for unicode string" % ( + Value, Type) elif ValueRe.match(Value): # Check the chars in UnicodeString or CString is printable if Value.startswith("L"): @@ -1419,12 +1502,14 @@ def CheckPcdDatum(Type, Value): return False, "Too large PCD value[%s] for datum type [%s]= " % (Value, Type) except: return False, "Invalid value [%s] of type [%s];"\ - " must be a hexadecimal, decimal or octal in C l= anguage format." % (Value, Type) + " must be a hexadecimal, decimal or octal in C l= anguage format." % ( + Value, Type) else: return True, "StructurePcd" =20 return True, "" =20 + def CommonPath(PathList): P1 =3D min(PathList).split(os.path.sep) P2 =3D max(PathList).split(os.path.sep) @@ -1433,6 +1518,7 @@ def CommonPath(PathList): return os.path.sep.join(P1[:Index]) return os.path.sep.join(P1) =20 + class PathClass(object): def __init__(self, File=3D'', Root=3D'', AlterRoot=3D'', Type=3D'', Is= Binary=3DFalse, Arch=3D'COMMON', ToolChainFamily=3D'', Target=3D'', TagNa= me=3D'', ToolCode=3D''): @@ -1484,7 +1570,7 @@ class PathClass(object): self.ToolChainFamily =3D ToolChainFamily self.OriginalPath =3D self =20 - ## Convert the object of this class to a string + # Convert the object of this class to a string # # Convert member Path of the class to a string # @@ -1493,7 +1579,7 @@ class PathClass(object): def __str__(self): return self.Path =20 - ## Override __eq__ function + # Override __eq__ function # # Check whether PathClass are the same # @@ -1503,7 +1589,7 @@ class PathClass(object): def __eq__(self, Other): return self.Path =3D=3D str(Other) =20 - ## Override __cmp__ function + # Override __cmp__ function # # Customize the comparison operation of two PathClass # @@ -1521,7 +1607,7 @@ class PathClass(object): else: return -1 =20 - ## Override __hash__ function + # Override __hash__ function # # Use Path as key in hash table # @@ -1542,14 +1628,16 @@ class PathClass(object): def RealPath2(File, Dir=3D'', OverrideDir=3D''): NewFile =3D None if OverrideDir: - NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.= join(OverrideDir, File))] + NewFile =3D GlobalData.gAllFiles[os.path.normpath( + os.path.join(OverrideDir, File))] if NewFile: if OverrideDir[-1] =3D=3D os.path.sep: return NewFile[len(OverrideDir):], NewFile[0:len(O= verrideDir)] else: return NewFile[len(OverrideDir) + 1:], NewFile[0:l= en(OverrideDir)] if GlobalData.gAllFiles: - NewFile =3D GlobalData.gAllFiles[os.path.normpath(os.path.= join(Dir, File))] + NewFile =3D GlobalData.gAllFiles[os.path.normpath( + os.path.join(Dir, File))] if not NewFile: NewFile =3D os.path.normpath(os.path.join(Dir, File)) if not os.path.exists(NewFile): @@ -1577,7 +1665,7 @@ class PathClass(object): RealFile =3D os.path.join(self.AlterRoot, self.File) elif self.Root: RealFile =3D os.path.join(self.Root, self.File) - if len (mws.getPkgPath()) =3D=3D 0: + if len(mws.getPkgPath()) =3D=3D 0: return FILE_NOT_FOUND, os.path.join(self.AlterRoot, RealFi= le) else: return FILE_NOT_FOUND, "%s is not found in packages path:\= n\t%s" % (self.File, '\n\t'.join(mws.getPkgPath())) @@ -1600,19 +1688,21 @@ class PathClass(object): self.Path =3D os.path.join(RealRoot, RealFile) return ErrorCode, ErrorInfo =20 -## Parse PE image to get the required PE information. +# Parse PE image to get the required PE information. # + + class PeImageClass(): - ## Constructor + # Constructor # # @param File FilePath of PeImage # def __init__(self, PeFile): - self.FileName =3D PeFile - self.IsValid =3D False - self.Size =3D 0 + self.FileName =3D PeFile + self.IsValid =3D False + self.Size =3D 0 self.EntryPoint =3D 0 - self.SectionAlignment =3D 0 + self.SectionAlignment =3D 0 self.SectionHeaderList =3D [] self.ErrorInfo =3D '' try: @@ -1625,7 +1715,7 @@ class PeImageClass(): ByteArray.fromfile(PeObject, 0x3E) ByteList =3D ByteArray.tolist() # DOS signature should be 'MZ' - if self._ByteListToStr (ByteList[0x0:0x2]) !=3D 'MZ': + if self._ByteListToStr(ByteList[0x0:0x2]) !=3D 'MZ': self.ErrorInfo =3D self.FileName + ' has no valid DOS signatur= e MZ' return =20 @@ -1653,20 +1743,21 @@ class PeImageClass(): ByteArray =3D array.array('B') ByteArray.fromfile(PeObject, OptionalHeaderSize) ByteList =3D ByteArray.tolist() - self.EntryPoint =3D self._ByteListToInt(ByteList[0x10:0x14]) + self.EntryPoint =3D self._ByteListToInt(ByteList[0x10:0x14]) self.SectionAlignment =3D self._ByteListToInt(ByteList[0x20:0x24]) - self.Size =3D self._ByteListToInt(ByteList[0x38:0x3C]) + self.Size =3D self._ByteListToInt(ByteList[0x38:0x3C]) =20 # Read each Section Header for Index in range(SecNumber): ByteArray =3D array.array('B') ByteArray.fromfile(PeObject, 0x28) ByteList =3D ByteArray.tolist() - SecName =3D self._ByteListToStr(ByteList[0:8]) + SecName =3D self._ByteListToStr(ByteList[0:8]) SecVirtualSize =3D self._ByteListToInt(ByteList[8:12]) - SecRawAddress =3D self._ByteListToInt(ByteList[20:24]) + SecRawAddress =3D self._ByteListToInt(ByteList[20:24]) SecVirtualAddress =3D self._ByteListToInt(ByteList[12:16]) - self.SectionHeaderList.append((SecName, SecVirtualAddress, Sec= RawAddress, SecVirtualSize)) + self.SectionHeaderList.append( + (SecName, SecVirtualAddress, SecRawAddress, SecVirtualSize= )) self.IsValid =3D True PeObject.close() =20 @@ -1684,48 +1775,55 @@ class PeImageClass(): Value =3D (Value << 8) | int(ByteList[index]) return Value =20 + class DefaultStore(): - def __init__(self, DefaultStores ): + def __init__(self, DefaultStores): =20 self.DefaultStores =3D DefaultStores + def DefaultStoreID(self, DefaultStoreName): for key, value in self.DefaultStores.items(): if value =3D=3D DefaultStoreName: return key return None + def GetDefaultDefault(self): if not self.DefaultStores or "0" in self.DefaultStores: return "0", TAB_DEFAULT_STORES_DEFAULT else: minvalue =3D min(int(value_str) for value_str in self.DefaultS= tores) return (str(minvalue), self.DefaultStores[str(minvalue)]) + def GetMin(self, DefaultSIdList): if not DefaultSIdList: return TAB_DEFAULT_STORES_DEFAULT - storeidset =3D {storeid for storeid, storename in self.DefaultStor= es.values() if storename in DefaultSIdList} + storeidset =3D {storeid for storeid, storename in self.DefaultStor= es.values( + ) if storename in DefaultSIdList} if not storeidset: return "" - minid =3D min(storeidset ) + minid =3D min(storeidset) for sid, name in self.DefaultStores.values(): if sid =3D=3D minid: return name =20 + class SkuClass(): DEFAULT =3D 0 SINGLE =3D 1 - MULTIPLE =3D2 + MULTIPLE =3D 2 =20 - def __init__(self,SkuIdentifier=3D'', SkuIds=3DNone): + def __init__(self, SkuIdentifier=3D'', SkuIds=3DNone): if SkuIds is None: SkuIds =3D {} =20 for SkuName in SkuIds: SkuId =3D SkuIds[SkuName][0] - skuid_num =3D int(SkuId, 16) if SkuId.upper().startswith("0X")= else int(SkuId) + skuid_num =3D int(SkuId, 16) if SkuId.upper( + ).startswith("0X") else int(SkuId) if skuid_num > 0xFFFFFFFFFFFFFFFF: EdkLogger.error("build", PARAMETER_INVALID, - ExtraData =3D "SKU-ID [%s] value %s exceeds th= e max value of UINT64" - % (SkuName, SkuId)) + ExtraData=3D"SKU-ID [%s] value %s exceeds = the max value of UINT64" + % (SkuName, SkuId)) =20 self.AvailableSkuIds =3D OrderedDict() self.SkuIdSet =3D [] @@ -1738,26 +1836,28 @@ class SkuClass(): self.SkuIdNumberSet =3D ['0U'] elif SkuIdentifier =3D=3D 'ALL': self.SkuIdSet =3D list(SkuIds.keys()) - self.SkuIdNumberSet =3D [num[0].strip() + 'U' for num in SkuId= s.values()] + self.SkuIdNumberSet =3D [ + num[0].strip() + 'U' for num in SkuIds.values()] else: r =3D SkuIdentifier.split('|') - self.SkuIdSet=3D[(r[k].strip()).upper() for k in range(len(r))] + self.SkuIdSet =3D [(r[k].strip()).upper() for k in range(len(r= ))] k =3D None try: - self.SkuIdNumberSet =3D [SkuIds[k][0].strip() + 'U' for k = in self.SkuIdSet] + self.SkuIdNumberSet =3D [ + SkuIds[k][0].strip() + 'U' for k in self.SkuIdSet] except Exception: EdkLogger.error("build", PARAMETER_INVALID, - ExtraData =3D "SKU-ID [%s] is not supported by= the platform. [Valid SKU-ID: %s]" - % (k, " | ".join(SkuIds.keys()))) + ExtraData=3D"SKU-ID [%s] is not supported = by the platform. [Valid SKU-ID: %s]" + % (k, " | ".join(SkuIds.keys()))) for each in self.SkuIdSet: if each in SkuIds: self.AvailableSkuIds[each] =3D SkuIds[each][0] else: EdkLogger.error("build", PARAMETER_INVALID, - ExtraData=3D"SKU-ID [%s] is not supported by t= he platform. [Valid SKU-ID: %s]" - % (each, " | ".join(SkuIds.keys()))) + ExtraData=3D"SKU-ID [%s] is not supported = by the platform. [Valid SKU-ID: %s]" + % (each, " | ".join(SkuIds.keys()))) if self.SkuUsageType !=3D SkuClass.SINGLE: - self.AvailableSkuIds.update({'DEFAULT':0, 'COMMON':0}) + self.AvailableSkuIds.update({'DEFAULT': 0, 'COMMON': 0}) if self.SkuIdSet: GlobalData.gSkuids =3D (self.SkuIdSet) if 'COMMON' in GlobalData.gSkuids: @@ -1773,7 +1873,7 @@ class SkuClass(): if not self._SkuInherit: self._SkuInherit =3D {} for item in self.SkuData.values(): - self._SkuInherit[item[1]]=3Ditem[2] if item[2] else "DEFAU= LT" + self._SkuInherit[item[1]] =3D item[2] if item[2] else "DEF= AULT" return self._SkuInherit.get(skuname, "DEFAULT") =20 def GetSkuChain(self, sku): @@ -1788,6 +1888,7 @@ class SkuClass(): break skulist.reverse() return skulist + def SkuOverrideOrder(self): skuorderset =3D [] for skuname in self.SkuIdSet: @@ -1844,12 +1945,14 @@ class SkuClass(): else: return 'DEFAULT' =20 -## Get the integer value from string like "14U" or integer like 2 +# Get the integer value from string like "14U" or integer like 2 # # @param Input The object that may be either a integer value or a= string # # @retval Value The integer value that the input represents # + + def GetIntegerValue(Input): if not isinstance(Input, str): return Input @@ -1871,6 +1974,8 @@ def GetIntegerValue(Input): # # Pack a GUID (registry format) list into a buffer and return it # + + def PackGUID(Guid): return pack(PACK_PATTERN_GUID, int(Guid[0], 16), @@ -1889,6 +1994,8 @@ def PackGUID(Guid): # # Pack a GUID (byte) list into a buffer and return it # + + def PackByteFormatGUID(Guid): return pack(PACK_PATTERN_GUID, Guid[0], @@ -1904,19 +2011,21 @@ def PackByteFormatGUID(Guid): Guid[10], ) =20 -## DeepCopy dict/OrderedDict recusively +# DeepCopy dict/OrderedDict recusively # # @param ori_dict a nested dict or ordereddict # # @retval new dict or orderdict # + + def CopyDict(ori_dict): dict_type =3D ori_dict.__class__ - if dict_type not in (dict,OrderedDict): + if dict_type not in (dict, OrderedDict): return ori_dict new_dict =3D dict_type() for key in ori_dict: - if isinstance(ori_dict[key],(dict,OrderedDict)): + if isinstance(ori_dict[key], (dict, OrderedDict)): new_dict[key] =3D CopyDict(ori_dict[key]) else: new_dict[key] =3D ori_dict[key] @@ -1925,5 +2034,7 @@ def CopyDict(ori_dict): # # Remove the c/c++ comments: // and /* */ # + + def RemoveCComments(ctext): return re.sub('//.*?\n|/\*.*?\*/', '\n', ctext, flags=3Dre.S) diff --git a/BaseTools/Source/Python/Common/MultipleWorkspace.py b/BaseTool= s/Source/Python/Common/MultipleWorkspace.py index ad5d48588b48..598ea311a724 100644 --- a/BaseTools/Source/Python/Common/MultipleWorkspace.py +++ b/BaseTools/Source/Python/Common/MultipleWorkspace.py @@ -1,4 +1,4 @@ -## @file +# @file # manage multiple workspace file. # # This file is required to make Python interpreter treat the directory @@ -11,7 +11,7 @@ import Common.LongFilePathOs as os from Common.DataType import TAB_WORKSPACE =20 -## MultipleWorkspace +# MultipleWorkspace # # This class manage multiple workspace behavior # @@ -20,11 +20,13 @@ from Common.DataType import TAB_WORKSPACE # @var WORKSPACE: defined the current WORKSPACE # @var PACKAGES_PATH: defined the other WORKSPACE, if current WORKSPACE i= s invalid, search valid WORKSPACE from PACKAGES_PATH # + + class MultipleWorkspace(object): WORKSPACE =3D '' PACKAGES_PATH =3D None =20 - ## convertPackagePath() + # convertPackagePath() # # Convert path to match workspace. # @@ -34,11 +36,11 @@ class MultipleWorkspace(object): # @classmethod def convertPackagePath(cls, Ws, Path): - if str(os.path.normcase (Path)).startswith(Ws): + if str(os.path.normcase(Path)).startswith(Ws): return os.path.join(Ws, os.path.relpath(Path, Ws)) return Path =20 - ## setWs() + # setWs() # # set WORKSPACE and PACKAGES_PATH environment # @@ -50,11 +52,12 @@ class MultipleWorkspace(object): def setWs(cls, Ws, PackagesPath=3DNone): cls.WORKSPACE =3D Ws if PackagesPath: - cls.PACKAGES_PATH =3D [cls.convertPackagePath (Ws, os.path.nor= mpath(Path.strip())) for Path in PackagesPath.split(os.pathsep)] + cls.PACKAGES_PATH =3D [cls.convertPackagePath(Ws, os.path.norm= path( + Path.strip())) for Path in PackagesPath.split(os.pathsep)] else: cls.PACKAGES_PATH =3D [] =20 - ## join() + # join() # # rewrite os.path.join function # @@ -74,7 +77,7 @@ class MultipleWorkspace(object): Path =3D os.path.join(Ws, *p) return Path =20 - ## relpath() + # relpath() # # rewrite os.path.relpath function # @@ -93,7 +96,7 @@ class MultipleWorkspace(object): Path =3D os.path.relpath(Path, Ws) return Path =20 - ## getWs() + # getWs() # # get valid workspace for the path # @@ -112,7 +115,7 @@ class MultipleWorkspace(object): return Pkg return Ws =20 - ## handleWsMacro() + # handleWsMacro() # # handle the $(WORKSPACE) tag, if current workspace is invalid path = relative the tool, replace it. # @@ -128,17 +131,19 @@ class MultipleWorkspace(object): MacroStartPos =3D str.find(TAB_WORKSPACE) if MacroStartPos !=3D -1: Substr =3D str[MacroStartPos:] - Path =3D Substr.replace(TAB_WORKSPACE, cls.WORKSPA= CE).strip() + Path =3D Substr.replace( + TAB_WORKSPACE, cls.WORKSPACE).strip() if not os.path.exists(Path): for Pkg in cls.PACKAGES_PATH: - Path =3D Substr.replace(TAB_WORKSPACE, Pkg= ).strip() + Path =3D Substr.replace( + TAB_WORKSPACE, Pkg).strip() if os.path.exists(Path): break PathList[i] =3D str[0:MacroStartPos] + Path PathStr =3D ' '.join(PathList) return PathStr =20 - ## getPkgPath() + # getPkgPath() # # get all package paths. # @@ -147,4 +152,3 @@ class MultipleWorkspace(object): @classmethod def getPkgPath(cls): return cls.PACKAGES_PATH - diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/P= ython/Common/Parsing.py index 740283a04d85..22015fa00c12 100644 --- a/BaseTools/Source/Python/Common/Parsing.py +++ b/BaseTools/Source/Python/Common/Parsing.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common parsing related functions used in par= sing INF/DEC/DSC process # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -13,10 +13,12 @@ from .StringUtils import * from CommonDataClass.DataClass import * from .DataType import * =20 -## ParseDefineMacro +# ParseDefineMacro # # Search whole table to find all defined Macro and replaced them with the = real values # + + def ParseDefineMacro2(Table, RecordSets, GlobalMacro): Macros =3D {} # @@ -41,10 +43,12 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro): for Item in Value: Item[0] =3D ReplaceMacro(Item[0], Macros) =20 -## ParseDefineMacro +# ParseDefineMacro # # Search whole table to find all defined Macro and replaced them with the = real values # + + def ParseDefineMacro(Table, GlobalMacro): Macros =3D {} # @@ -55,18 +59,18 @@ def ParseDefineMacro(Table, GlobalMacro): and Enabled > -1""" % (Table.Table, MODEL_META_DATA_DE= FINE) RecordSet =3D Table.Exec(SqlCommand) for Record in RecordSet: -#*************************************************************************= ************************************************************************** -# The follow SqlCommand (expr replace) is not supported in Sqli= te 3.3.4 which is used in Python 2.5 * -# Reserved Only = * -# SqlCommand =3D """update %s set Value1 =3D replace(Value1, '%= s', '%s') = * -# where ID in (select ID from %s = * -# where Model =3D %s = * -# and Value1 like '%%%s%%' = * -# and StartLine > %s = * -# and Enabled > -1 = * -# and Arch =3D '%s')""" % \ = * -# (self.TblDsc.Table, Record[0], R= ecord[1], self.TblDsc.Table, Record[2], Record[1], Record[3], Record[4]) * -#*************************************************************************= ************************************************************************** + # ****************************************************************= ***************************************************************************= ******** + # The follow SqlCommand (expr replace) is not supported= in Sqlite 3.3.4 which is used in Python 2.5 = * + # Reserved Only = = * + # SqlCommand =3D """update %s set Value1 =3D replace(Va= lue1, '%s', '%s') = * + # where ID in (select ID from %s = = * + # where Model =3D %s = = * + # and Value1 like '%%%s%%'= = * + # and StartLine > %s = = * + # and Enabled > -1 = = * + # and Arch =3D '%s')""" % = \ = * + # (self.TblDsc.Table, Reco= rd[0], Record[1], self.TblDsc.Table, Record[2], Record[1], Record[3], Recor= d[4]) * + # ****************************************************************= ***************************************************************************= ******** Macros[Record[0]] =3D Record[1] =20 # @@ -80,7 +84,7 @@ def ParseDefineMacro(Table, GlobalMacro): SqlCommand =3D """select ID, Value1 from %s where Model !=3D %s and Value1 like '%%$(%%' and Value1 like '%%)%%' - and Enabled > -1""" % (Table.Table, MODEL_META_DATA_D= EFINE) + and Enabled > -1""" % (Table.Table, MODEL_META_DATA_DE= FINE) FoundRecords =3D Table.Exec(SqlCommand) for FoundRecord in FoundRecords: NewValue =3D ReplaceMacro(FoundRecord[1], Macros) @@ -88,7 +92,7 @@ def ParseDefineMacro(Table, GlobalMacro): where ID =3D %s""" % (Table.Table, ConvertToSqlStr= ing2(NewValue), FoundRecord[0]) Table.Exec(SqlCommand) =20 -##QueryDefinesItem +# QueryDefinesItem # # Search item of section [Defines] by name, return its values # @@ -98,6 +102,8 @@ def ParseDefineMacro(Table, GlobalMacro): # # @retval RecordSet: A list of all matched records # + + def QueryDefinesItem(Table, Name, Arch, BelongsToFile): SqlCommand =3D """select Value2 from %s where Model =3D %s @@ -132,7 +138,7 @@ def QueryDefinesItem(Table, Name, Arch, BelongsToFile): RetVal.append(Item) return RetVal =20 -##QueryDefinesItem +# QueryDefinesItem # # Search item of section [Defines] by name, return its values # @@ -142,6 +148,8 @@ def QueryDefinesItem(Table, Name, Arch, BelongsToFile): # # @retval RecordSet: A list of all matched records # + + def QueryDefinesItem2(Table, Arch, BelongsToFile): SqlCommand =3D """select Value1, Value2, StartLine from %s where Model =3D %s @@ -159,7 +167,7 @@ def QueryDefinesItem2(Table, Arch, BelongsToFile): =20 return RecordSet =20 -##QueryDscItem +# QueryDscItem # # Search all dsc item for a specific section # @@ -168,6 +176,8 @@ def QueryDefinesItem2(Table, Arch, BelongsToFile): # # @retval RecordSet: A list of all matched records # + + def QueryDscItem(Table, Model, BelongsToItem, BelongsToFile): SqlCommand =3D """select Value1, Arch, StartLine, ID, Value2 from %s where Model =3D %s @@ -176,7 +186,7 @@ def QueryDscItem(Table, Model, BelongsToItem, BelongsTo= File): and Enabled > -1""" % (Table.Table, Model, BelongsToIt= em, BelongsToFile) return Table.Exec(SqlCommand) =20 -##QueryDecItem +# QueryDecItem # # Search all dec item for a specific section # @@ -185,6 +195,8 @@ def QueryDscItem(Table, Model, BelongsToItem, BelongsTo= File): # # @retval RecordSet: A list of all matched records # + + def QueryDecItem(Table, Model, BelongsToItem): SqlCommand =3D """select Value1, Arch, StartLine, ID, Value2 from %s where Model =3D %s @@ -192,7 +204,7 @@ def QueryDecItem(Table, Model, BelongsToItem): and Enabled > -1""" % (Table.Table, Model, BelongsToIt= em) return Table.Exec(SqlCommand) =20 -##QueryInfItem +# QueryInfItem # # Search all dec item for a specific section # @@ -201,6 +213,8 @@ def QueryDecItem(Table, Model, BelongsToItem): # # @retval RecordSet: A list of all matched records # + + def QueryInfItem(Table, Model, BelongsToItem): SqlCommand =3D """select Value1, Arch, StartLine, ID, Value2 from %s where Model =3D %s @@ -208,7 +222,7 @@ def QueryInfItem(Table, Model, BelongsToItem): and Enabled > -1""" % (Table.Table, Model, BelongsToIt= em) return Table.Exec(SqlCommand) =20 -## GetBuildOption +# GetBuildOption # # Parse a string with format "[:]=3DFlag" # Return (Family, ToolFlag, Flag) @@ -218,21 +232,24 @@ def QueryInfItem(Table, Model, BelongsToItem): # # @retval truple() A truple structure as (Family, ToolChain, Flag) # -def GetBuildOption(String, File, LineNo =3D -1): + + +def GetBuildOption(String, File, LineNo=3D-1): (Family, ToolChain, Flag) =3D ('', '', '') if String.find(TAB_EQUAL_SPLIT) < 0: - RaiseParserError(String, 'BuildOptions', File, '[:]=3DFlag', LineNo) + RaiseParserError(String, 'BuildOptions', File, + '[:]=3DFlag', LineNo) else: - List =3D GetSplitValueList(String, TAB_EQUAL_SPLIT, MaxSplit =3D 1) + List =3D GetSplitValueList(String, TAB_EQUAL_SPLIT, MaxSplit=3D1) if List[0].find(':') > -1: - Family =3D List[0][ : List[0].find(':')].strip() - ToolChain =3D List[0][List[0].find(':') + 1 : ].strip() + Family =3D List[0][: List[0].find(':')].strip() + ToolChain =3D List[0][List[0].find(':') + 1:].strip() else: ToolChain =3D List[0].strip() Flag =3D List[1].strip() return (Family, ToolChain, Flag) =20 -## Get Library Class +# Get Library Class # # Get Library of Dsc as | # @@ -241,20 +258,25 @@ def GetBuildOption(String, File, LineNo =3D -1): # # @retval (LibraryClassKeyWord, LibraryInstance, [SUP_MODULE_LIST]) Format= ted Library Item # -def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo =3D -1): + + +def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo=3D-1): List =3D GetSplitValueList(Item[0]) SupMod =3D SUP_MODULE_LIST_STRING if len(List) !=3D 2: - RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, '|') + RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, + '|') else: - CheckFileType(List[1], '.Inf', ContainerFile, 'library class insta= nce', Item[0], LineNo) - CheckFileExist(WorkspaceDir, List[1], ContainerFile, 'LibraryClass= es', Item[0], LineNo) + CheckFileType(List[1], '.Inf', ContainerFile, + 'library class instance', Item[0], LineNo) + CheckFileExist( + WorkspaceDir, List[1], ContainerFile, 'LibraryClasses', Item[0= ], LineNo) if Item[1] !=3D '': SupMod =3D Item[1] =20 return (List[0], List[1], SupMod) =20 -## Get Library Class +# Get Library Class # # Get Library of Dsc as [|][|.] # @@ -263,23 +285,29 @@ def GetLibraryClass(Item, ContainerFile, WorkspaceDir= , LineNo =3D -1): # # @retval (LibraryClassKeyWord, LibraryInstance, [SUP_MODULE_LIST]) Format= ted Library Item # -def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo =3D -1): + + +def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo=3D-1): ItemList =3D GetSplitValueList((Item[0] + DataType.TAB_VALUE_SPLIT * 2= )) SupMod =3D SUP_MODULE_LIST_STRING =20 if len(ItemList) > 5: - RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, '[|][|.]') + RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, + '[|][|.]') else: - CheckFileType(ItemList[1], '.Inf', ContainerFile, 'LibraryClasses'= , Item[0], LineNo) - CheckFileExist(WorkspaceDir, ItemList[1], ContainerFile, 'LibraryC= lasses', Item[0], LineNo) + CheckFileType(ItemList[1], '.Inf', ContainerFile, + 'LibraryClasses', Item[0], LineNo) + CheckFileExist( + WorkspaceDir, ItemList[1], ContainerFile, 'LibraryClasses', It= em[0], LineNo) if ItemList[2] !=3D '': - CheckPcdTokenInfo(ItemList[2], 'LibraryClasses', ContainerFile= , LineNo) + CheckPcdTokenInfo( + ItemList[2], 'LibraryClasses', ContainerFile, LineNo) if Item[1] !=3D '': SupMod =3D Item[1] =20 return (ItemList[0], ItemList[1], ItemList[2], SupMod) =20 -## CheckPcdTokenInfo +# CheckPcdTokenInfo # # Check if PcdTokenInfo is following . # @@ -289,7 +317,9 @@ def GetLibraryClassOfInf(Item, ContainerFile, Workspace= Dir, LineNo =3D -1): # # @retval True PcdTokenInfo is in correct format # -def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo =3D -1): + + +def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo=3D-1): Format =3D '.' if TokenInfoString !=3D '' and TokenInfoString is not None: TokenInfoList =3D GetSplitValueList(TokenInfoString, TAB_SPLIT) @@ -298,7 +328,7 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, L= ineNo =3D -1): =20 RaiseParserError(TokenInfoString, Section, File, Format, LineNo) =20 -## Get Pcd +# Get Pcd # # Get Pcd of Dsc as .|[||= ] # @@ -307,12 +337,15 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File,= LineNo =3D -1): # # @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type) # -def GetPcd(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value, MaximumDatumSize, Token =3D '', '', '', '= ', '' List =3D GetSplitValueList(Item + TAB_VALUE_SPLIT * 2) =20 if len(List) < 4 or len(List) > 6: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|[||]', LineNo) + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.|[|<= Type>|]', LineNo) else: Value =3D List[1] MaximumDatumSize =3D List[2] @@ -323,7 +356,7 @@ def GetPcd(Item, Type, ContainerFile, LineNo =3D -1): =20 return (TokenName, TokenGuid, Value, MaximumDatumSize, Token, Type) =20 -## Get FeatureFlagPcd +# Get FeatureFlagPcd # # Get FeatureFlagPcd of Dsc as .|TRUE/= FALSE # @@ -332,11 +365,14 @@ def GetPcd(Item, Type, ContainerFile, LineNo =3D -1): # # @retval (TokenInfo[1], TokenInfo[0], List[1], Type) # -def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value =3D '', '', '' List =3D GetSplitValueList(Item) if len(List) !=3D 2: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|TRUE/FALSE', LineNo) + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.|TRUE/FALSE= ', LineNo) else: Value =3D List[1] if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo): @@ -344,7 +380,7 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo= =3D -1): =20 return (TokenName, TokenGuid, Value, Type) =20 -## Get DynamicDefaultPcd +# Get DynamicDefaultPcd # # Get DynamicDefaultPcd of Dsc as .|[|[|]] # @@ -353,11 +389,14 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, Line= No =3D -1): # # @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], Type) # -def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value, DatumTyp, MaxDatumSize =3D '', '', '', ''= , '' List =3D GetSplitValueList(Item + TAB_VALUE_SPLIT * 2) if len(List) < 4 or len(List) > 8: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|[|[|]]', LineNo) + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.|[|<= DatumTyp>[|]]', LineNo) else: Value =3D List[1] DatumTyp =3D List[2] @@ -367,7 +406,7 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, Lin= eNo =3D -1): =20 return (TokenName, TokenGuid, Value, DatumTyp, MaxDatumSize, Type) =20 -## Get DynamicHiiPcd +# Get DynamicHiiPcd # # Get DynamicHiiPcd of Dsc as .|||[|[|= ]] # @@ -376,11 +415,14 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, L= ineNo =3D -1): # # @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], List[3], List[4],= List[5], Type) # -def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, L1, L2, L3, L4, L5 =3D '', '', '', '', '', '', '' List =3D GetSplitValueList(Item + TAB_VALUE_SPLIT * 2) if len(List) < 6 or len(List) > 8: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|||[|[|]]', LineNo) + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.||<= VariableGuidCName>|[|[|]]',= LineNo) else: L1, L2, L3, L4, L5 =3D List[1], List[2], List[3], List[4], List[5] if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo): @@ -388,7 +430,7 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo = =3D -1): =20 return (TokenName, TokenGuid, L1, L2, L3, L4, L5, Type) =20 -## Get DynamicVpdPcd +# Get DynamicVpdPcd # # Get DynamicVpdPcd of Dsc as .|[|] # @@ -397,11 +439,14 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineN= o =3D -1): # # @retval (TokenInfo[1], TokenInfo[0], List[1], List[2], Type) # -def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, L1, L2 =3D '', '', '', '' List =3D GetSplitValueList(Item + TAB_VALUE_SPLIT) if len(List) < 3 or len(List) > 4: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|[|]', LineNo) + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.|[|]', LineNo) else: L1, L2 =3D List[1], List[2] if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo): @@ -409,7 +454,7 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo = =3D -1): =20 return (TokenName, TokenGuid, L1, L2, Type) =20 -## GetComponent +# GetComponent # # Parse block of the components defined in dsc file # Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3= ], [pcd1, pcd2, pcd3]], ...] @@ -419,8 +464,11 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo= =3D -1): # # @retval True Get component successfully # + + def GetComponent(Lines, KeyValues): - (findBlock, findLibraryClass, findBuildOption, findPcdsFeatureFlag, fi= ndPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDyn= amicEx) =3D (False, False, False, False, False, False, False, False) + (findBlock, findLibraryClass, findBuildOption, findPcdsFeatureFlag, fi= ndPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, False, False, = False, False, False, False) ListItem =3D None LibraryClassItem =3D [] BuildOption =3D [] @@ -442,39 +490,49 @@ def GetComponent(Lines, KeyValues): # if Line.endswith('{'): findBlock =3D True - ListItem =3D CleanString(Line.rsplit('{', 1)[0], DataType.= TAB_COMMENT_SPLIT) + ListItem =3D CleanString(Line.rsplit( + '{', 1)[0], DataType.TAB_COMMENT_SPLIT) =20 # # Parse a block content # if findBlock: if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (True, False, False, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (True, False, Fal= se, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, True, False, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, True, Fal= se, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, True, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Tr= ue, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, True, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, True, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, True, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, True, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, False, True, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, True, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, False, False, True) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # - KeyValues.append([ListItem, LibraryClassItem, BuildOption,= Pcd]) - (findBlock, findLibraryClass, findBuildOption, findPcdsFea= tureFlag, findPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic,= findPcdsDynamicEx) =3D (False, False, False, False, False, False, False, F= alse) + KeyValues.append( + [ListItem, LibraryClassItem, BuildOption, Pcd]) + (findBlock, findLibraryClass, findBuildOption, findPcdsFea= tureFlag, findPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, False, False, False) LibraryClassItem, BuildOption, Pcd =3D [], [], [] continue =20 @@ -498,7 +556,7 @@ def GetComponent(Lines, KeyValues): =20 return True =20 -## GetExec +# GetExec # # Parse a string with format "InfFilename [EXEC =3D ExecFilename]" # Return (InfFilename, ExecFilename) @@ -507,18 +565,20 @@ def GetComponent(Lines, KeyValues): # # @retval truple() A pair as (InfFilename, ExecFilename) # + + def GetExec(String): InfFilename =3D '' ExecFilename =3D '' if String.find('EXEC') > -1: - InfFilename =3D String[ : String.find('EXEC')].strip() - ExecFilename =3D String[String.find('EXEC') + len('EXEC') : ].stri= p() + InfFilename =3D String[: String.find('EXEC')].strip() + ExecFilename =3D String[String.find('EXEC') + len('EXEC'):].strip() else: InfFilename =3D String.strip() =20 return (InfFilename, ExecFilename) =20 -## GetComponents +# GetComponents # # Parse block of the components defined in dsc file # Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3= ], [pcd1, pcd2, pcd3]], ...] @@ -530,10 +590,13 @@ def GetExec(String): # # @retval True Get component successfully # + + def GetComponents(Lines, Key, KeyValues, CommentCharacter): if Lines.find(DataType.TAB_SECTION_END) > -1: Lines =3D Lines.split(DataType.TAB_SECTION_END, 1)[1] - (findBlock, findLibraryClass, findBuildOption, findPcdsFeatureFlag, fi= ndPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDyn= amicEx) =3D (False, False, False, False, False, False, False, False) + (findBlock, findLibraryClass, findBuildOption, findPcdsFeatureFlag, fi= ndPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, False, False, = False, False, False, False) ListItem =3D None LibraryClassItem =3D [] BuildOption =3D [] @@ -552,39 +615,49 @@ def GetComponents(Lines, Key, KeyValues, CommentChara= cter): # if Line.endswith('{'): findBlock =3D True - ListItem =3D CleanString(Line.rsplit('{', 1)[0], CommentCh= aracter) + ListItem =3D CleanString(Line.rsplit('{', 1)[ + 0], CommentCharacter) =20 # # Parse a block content # if findBlock: if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (True, False, False, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (True, False, Fal= se, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, True, False, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, True, Fal= se, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, True, False, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Tr= ue, False, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, True, False, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, True, False, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, True, False, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, True, False, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, False, True, False) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, True, False) continue if Line.find('') !=3D -1: - (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic, findPcdsDy= namicEx) =3D (False, False, False, False, False, False, True) + (findLibraryClass, findBuildOption, findPcdsFeatureFlag, f= indPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # - KeyValues.append([ListItem, LibraryClassItem, BuildOption,= Pcd]) - (findBlock, findLibraryClass, findBuildOption, findPcdsFea= tureFlag, findPcdsPatchableInModule, findPcdsFixedAtBuild, findPcdsDynamic,= findPcdsDynamicEx) =3D (False, False, False, False, False, False, False, F= alse) + KeyValues.append( + [ListItem, LibraryClassItem, BuildOption, Pcd]) + (findBlock, findLibraryClass, findBuildOption, findPcdsFea= tureFlag, findPcdsPatchableInModule, findPcdsFixedAtBuild, + findPcdsDynamic, findPcdsDynamicEx) =3D (False, False, Fa= lse, False, False, False, False, False) LibraryClassItem, BuildOption, Pcd =3D [], [], [] continue =20 @@ -608,7 +681,7 @@ def GetComponents(Lines, Key, KeyValues, CommentCharact= er): =20 return True =20 -## Get Source +# Get Source # # Get Source of Inf as [|[|[|[|]]]] # @@ -617,19 +690,23 @@ def GetComponents(Lines, Key, KeyValues, CommentChara= cter): # # @retval (List[0], List[1], List[2], List[3], List[4]) # -def GetSource(Item, ContainerFile, FileRelativePath, LineNo =3D -1): + + +def GetSource(Item, ContainerFile, FileRelativePath, LineNo=3D-1): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT * 4 List =3D GetSplitValueList(ItemNew) if len(List) < 5 or len(List) > 9: - RaiseParserError(Item, 'Sources', ContainerFile, '[|[|[|[|]]]]', LineNo) + RaiseParserError(Item, 'Sources', ContainerFile, + '[|[|[|[|]]]]', LineNo) List[0] =3D NormPath(List[0]) - CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Sources', It= em, LineNo) + CheckFileExist(FileRelativePath, List[0], + ContainerFile, 'Sources', Item, LineNo) if List[4] !=3D '': CheckPcdTokenInfo(List[4], 'Sources', ContainerFile, LineNo) =20 return (List[0], List[1], List[2], List[3], List[4]) =20 -## Get Binary +# Get Binary # # Get Binary of Inf as [|[|[|[|]]]] # @@ -639,11 +716,14 @@ def GetSource(Item, ContainerFile, FileRelativePath, = LineNo =3D -1): # @retval (List[0], List[1], List[2], List[3]) # @retval List # -def GetBinary(Item, ContainerFile, FileRelativePath, LineNo =3D -1): + + +def GetBinary(Item, ContainerFile, FileRelativePath, LineNo=3D-1): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) if len(List) !=3D 4 and len(List) !=3D 5: - RaiseParserError(Item, 'Binaries', ContainerFile, "||[|.]", LineNo) + RaiseParserError(Item, 'Binaries', ContainerFile, + "||[|.]", LineNo) else: if List[3] !=3D '': CheckPcdTokenInfo(List[3], 'Binaries', ContainerFile, LineNo) @@ -657,7 +737,7 @@ def GetBinary(Item, ContainerFile, FileRelativePath, Li= neNo =3D -1): elif len(List) =3D=3D 1: return (List[0], '', '', '') =20 -## Get Guids/Protocols/Ppis +# Get Guids/Protocols/Ppis # # Get Guids/Protocols/Ppis of Inf as [|] # @@ -667,7 +747,9 @@ def GetBinary(Item, ContainerFile, FileRelativePath, Li= neNo =3D -1): # # @retval (List[0], List[1]) # -def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerFile, LineNo=3D-1): ItemNew =3D Item + TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) if List[1] !=3D '': @@ -675,7 +757,7 @@ def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerFil= e, LineNo =3D -1): =20 return (List[0], List[1]) =20 -## Get Guids/Protocols/Ppis +# Get Guids/Protocols/Ppis # # Get Guids/Protocols/Ppis of Dec as =3D # @@ -685,14 +767,17 @@ def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerF= ile, LineNo =3D -1): # # @retval (List[0], List[1]) # -def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo =3D -1): + + +def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo=3D-1): List =3D GetSplitValueList(Item, DataType.TAB_EQUAL_SPLIT) if len(List) !=3D 2: - RaiseParserError(Item, Type, ContainerFile, '=3D= ', LineNo) + RaiseParserError(Item, Type, ContainerFile, + '=3D', LineNo) =20 return (List[0], List[1]) =20 -## GetPackage +# GetPackage # # Get Package of Inf as [|] # @@ -702,18 +787,21 @@ def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerF= ile, LineNo =3D -1): # # @retval (List[0], List[1]) # -def GetPackage(Item, ContainerFile, FileRelativePath, LineNo =3D -1): + + +def GetPackage(Item, ContainerFile, FileRelativePath, LineNo=3D-1): ItemNew =3D Item + TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) CheckFileType(List[0], '.Dec', ContainerFile, 'package', List[0], Line= No) - CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Packages', L= ist[0], LineNo) + CheckFileExist(FileRelativePath, + List[0], ContainerFile, 'Packages', List[0], LineNo) =20 if List[1] !=3D '': CheckPcdTokenInfo(List[1], 'Packages', ContainerFile, LineNo) =20 return (List[0], List[1]) =20 -## Get Pcd Values of Inf +# Get Pcd Values of Inf # # Get Pcd of Inf as .[|] # @@ -723,6 +811,8 @@ def GetPackage(Item, ContainerFile, FileRelativePath, L= ineNo =3D -1): # # @retval (TokenSpcCName, TokenCName, Value, ItemType) Formatted Pcd Item # + + def GetPcdOfInf(Item, Type, File, LineNo): Format =3D '.[|]' TokenGuid, TokenName, Value, InfType =3D '', '', '', '' @@ -752,12 +842,12 @@ def GetPcdOfInf(Item, Type, File, LineNo): return (TokenGuid, TokenName, Value, Type) =20 =20 -## Get Pcd Values of Dec +# Get Pcd Values of Dec # # Get Pcd of Dec as .||| # @retval (TokenSpcCName, TokenCName, Value, DatumType, Token, ItemType) F= ormatted Pcd Item # -def GetPcdOfDec(Item, Type, File, LineNo =3D -1): +def GetPcdOfDec(Item, Type, File, LineNo=3D-1): Format =3D '.|||' TokenGuid, TokenName, Value, DatumType, Token =3D '', '', '', '', '' List =3D GetSplitValueList(Item) @@ -776,7 +866,7 @@ def GetPcdOfDec(Item, Type, File, LineNo =3D -1): =20 return (TokenGuid, TokenName, Value, DatumType, Token, Type) =20 -## Parse DEFINE statement +# Parse DEFINE statement # # Get DEFINE macros # @@ -784,15 +874,22 @@ def GetPcdOfDec(Item, Type, File, LineNo =3D -1): # Value1: Macro Name # Value2: Macro Value # + + def ParseDefine(LineValue, StartLine, Table, FileID, Filename, SectionName= , SectionModel, Arch): - EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in sec= tion %s" % (LineValue, SectionName)) - Define =3D GetSplitValueList(CleanString(LineValue[LineValue.upper().f= ind(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]= ), TAB_EQUAL_SPLIT, 1) - Table.Insert(MODEL_META_DATA_DEFINE, Define[0], Define[1], '', '', '',= Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0) + EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in sec= tion %s" % ( + LineValue, SectionName)) + Define =3D GetSplitValueList(CleanString(LineValue[LineValue.upper().f= ind( + DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' '= ):]), TAB_EQUAL_SPLIT, 1) + Table.Insert(MODEL_META_DATA_DEFINE, Define[0], Define[1], '', '', + '', Arch, SectionModel, FileID, StartLine, -1, StartLine,= -1, 0) =20 -## InsertSectionItems +# InsertSectionItems # # Insert item data of a section to a dict # + + def InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, T= hirdList, RecordSet): # Insert each item data of a section for Index in range(0, len(ArchList)): @@ -804,9 +901,10 @@ def InsertSectionItems(Model, CurrentSection, SectionI= temList, ArchList, ThirdLi Records =3D RecordSet[Model] for SectionItem in SectionItemList: BelongsToItem, EndLine, EndColumn =3D -1, -1, -1 - LineValue, StartLine, EndLine, Comment =3D SectionItem[0], Sec= tionItem[1], SectionItem[1], SectionItem[2] + LineValue, StartLine, EndLine, Comment =3D SectionItem[ + 0], SectionItem[1], SectionItem[1], SectionItem[2] =20 - EdkLogger.debug(4, "Parsing %s ..." %LineValue) + EdkLogger.debug(4, "Parsing %s ..." % LineValue) # And then parse DEFINE statement if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') >= -1: continue @@ -818,7 +916,7 @@ def InsertSectionItems(Model, CurrentSection, SectionIt= emList, ArchList, ThirdLi if RecordSet !=3D {}: RecordSet[Model] =3D Records =20 -## Insert records to database +# Insert records to database # # Insert item data of a section to database # @param Table: The Table to be inserted @@ -831,6 +929,8 @@ def InsertSectionItems(Model, CurrentSection, SectionIt= emList, ArchList, ThirdLi # @param IfDefList: A list of all conditional statements # @param RecordSet: A dict of all parsed records # + + def InsertSectionItemsIntoDatabase(Table, FileID, Filename, Model, Current= Section, SectionItemList, ArchList, ThirdList, IfDefList, RecordSet): # # Insert each item data of a section @@ -846,31 +946,35 @@ def InsertSectionItemsIntoDatabase(Table, FileID, Fil= ename, Model, CurrentSectio BelongsToItem, EndLine, EndColumn =3D -1, -1, -1 LineValue, StartLine, EndLine =3D SectionItem[0], SectionItem[= 1], SectionItem[1] =20 - EdkLogger.debug(4, "Parsing %s ..." %LineValue) + EdkLogger.debug(4, "Parsing %s ..." % LineValue) # # And then parse DEFINE statement # if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') >= -1: - ParseDefine(LineValue, StartLine, Table, FileID, Filename,= CurrentSection, Model, Arch) + ParseDefine(LineValue, StartLine, Table, FileID, + Filename, CurrentSection, Model, Arch) continue =20 # # At last parse other sections # - ID =3D Table.Insert(Model, LineValue, Third, Third, '', '', Ar= ch, -1, FileID, StartLine, -1, StartLine, -1, 0) + ID =3D Table.Insert(Model, LineValue, Third, Third, '', + '', Arch, -1, FileID, StartLine, -1, StartLi= ne, -1, 0) Records.append([LineValue, Arch, StartLine, ID, Third]) =20 if RecordSet !=3D {}: RecordSet[Model] =3D Records =20 -## GenMetaDatSectionItem +# GenMetaDatSectionItem + + def GenMetaDatSectionItem(Key, Value, List): if Key not in List: List[Key] =3D [Value] else: List[Key].append(Value) =20 -## IsValidWord +# IsValidWord # # Check whether the word is valid. # ::=3D (a-zA-Z0-9_)(a-zA-Z0-9_-){0,} Alphanumeric characters wi= th @@ -880,6 +984,8 @@ def GenMetaDatSectionItem(Key, Value, List): # # @param Word: The word string need to be checked. # + + def IsValidWord(Word): if not Word: return False diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/= Source/Python/Common/RangeExpression.py index 039d2814670f..5820806e4ccb 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -36,8 +36,9 @@ ERR_ARRAY_ELE =3D 'This must be HEX value for NList or Ar= ray: [%s].' ERR_EMPTY_EXPR =3D 'Empty expression is not allowed.' ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY), $(ARCH= ), $(TOOL_CHAIN_TAG) and $(TARGET).' =20 + class RangeObject(object): - def __init__(self, start, end, empty =3D False): + def __init__(self, start, end, empty=3DFalse): =20 if int(start) < int(end): self.start =3D int(start) @@ -47,13 +48,15 @@ class RangeObject(object): self.end =3D int(start) self.empty =3D empty =20 + class RangeContainer(object): def __init__(self): self.rangelist =3D [] =20 def push(self, RangeObject): self.rangelist.append(RangeObject) - self.rangelist =3D sorted(self.rangelist, key =3D lambda rangeobj = : rangeobj.start) + self.rangelist =3D sorted( + self.rangelist, key=3Dlambda rangeobj: rangeobj.start) self.merge() =20 def pop(self): @@ -68,6 +71,7 @@ class RangeContainer(object): else: newrangelist.append(rangeobj) self.rangelist =3D newrangelist + def merge(self): self.__clean__() for i in range(0, len(self.rangelist) - 1): @@ -75,7 +79,8 @@ class RangeContainer(object): continue else: self.rangelist[i + 1].start =3D self.rangelist[i].start - self.rangelist[i + 1].end =3D self.rangelist[i + 1].end > = self.rangelist[i].end and self.rangelist[i + 1].end or self.rangelist[i].end + self.rangelist[i + 1].end =3D self.rangelist[i + + 1].end > self.r= angelist[i].end and self.rangelist[i + 1].end or self.rangelist[i].end self.rangelist[i].empty =3D True =20 self.__clean__() @@ -91,6 +96,7 @@ class RangeContainer(object): class XOROperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "XOR ..." @@ -98,13 +104,16 @@ class XOROperatorObject(object): rangeId =3D str(uuid.uuid1()) rangeContainer =3D RangeContainer() rangeContainer.push(RangeObject(0, int(Operand) - 1)) - rangeContainer.push(RangeObject(int(Operand) + 1, MAX_VAL_TYPE[Dat= aType])) + rangeContainer.push(RangeObject( + int(Operand) + 1, MAX_VAL_TYPE[DataType])) SymbolTable[rangeId] =3D rangeContainer return rangeId =20 + class LEOperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "LE ..." @@ -114,9 +123,12 @@ class LEOperatorObject(object): rangeContainer.push(RangeObject(0, int(Operand))) SymbolTable[rangeId1] =3D rangeContainer return rangeId1 + + class LTOperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "LT ..." @@ -127,9 +139,11 @@ class LTOperatorObject(object): SymbolTable[rangeId1] =3D rangeContainer return rangeId1 =20 + class GEOperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "GE ..." @@ -140,22 +154,27 @@ class GEOperatorObject(object): SymbolTable[rangeId1] =3D rangeContainer return rangeId1 =20 + class GTOperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "GT ..." raise BadExpression(ERR_SNYTAX % Expr) rangeId1 =3D str(uuid.uuid1()) rangeContainer =3D RangeContainer() - rangeContainer.push(RangeObject(int(Operand) + 1, MAX_VAL_TYPE[Dat= aType])) + rangeContainer.push(RangeObject( + int(Operand) + 1, MAX_VAL_TYPE[DataType])) SymbolTable[rangeId1] =3D rangeContainer return rangeId1 =20 + class EQOperatorObject(object): def __init__(self): pass + def Calculate(self, Operand, DataType, SymbolTable): if isinstance(Operand, type('')) and not Operand.isalnum(): Expr =3D "EQ ..." @@ -166,6 +185,7 @@ class EQOperatorObject(object): SymbolTable[rangeId1] =3D rangeContainer return rangeId1 =20 + def GetOperatorObject(Operator): if Operator =3D=3D '>': return GTOperatorObject() @@ -182,17 +202,18 @@ def GetOperatorObject(Operator): else: raise BadExpression("Bad Operator") =20 + class RangeExpression(BaseExpression): # Logical operator mapping LogicalOperators =3D { - '&&' : 'and', '||' : 'or', - '!' : 'not', 'AND': 'and', - 'OR' : 'or' , 'NOT': 'not', - 'XOR': '^' , 'xor': '^', - 'EQ' : '=3D=3D' , 'NE' : '!=3D', - 'GT' : '>' , 'LT' : '<', - 'GE' : '>=3D' , 'LE' : '<=3D', - 'IN' : 'in' + '&&': 'and', '||': 'or', + '!': 'not', 'AND': 'and', + 'OR': 'or', 'NOT': 'not', + 'XOR': '^', 'xor': '^', + 'EQ': '=3D=3D', 'NE': '!=3D', + 'GT': '>', 'LT': '<', + 'GE': '>=3D', 'LE': '<=3D', + 'IN': 'in' } =20 NonLetterOpLst =3D ['+', '-', '&', '|', '^', '!', '=3D', '>', '<'] @@ -227,7 +248,6 @@ class RangeExpression(BaseExpression): self._Expr =3D expr return expr =20 - def EvalRange(self, Operator, Oprand): =20 operatorobj =3D GetOperatorObject(Operator) @@ -283,23 +303,23 @@ class RangeExpression(BaseExpression): # rangeContainer.dump() return rangeid =20 - def NegativeRange(self, Oprand1): rangeContainer1 =3D self.operanddict[Oprand1] =20 - rangeids =3D [] =20 for rangeobj in rangeContainer1.pop(): rangeContainer =3D RangeContainer() rangeid =3D str(uuid.uuid1()) if rangeobj.empty: - rangeContainer.push(RangeObject(0, MAX_VAL_TYPE[self.PcdDa= taType])) + rangeContainer.push(RangeObject( + 0, MAX_VAL_TYPE[self.PcdDataType])) else: if rangeobj.start > 0: rangeContainer.push(RangeObject(0, rangeobj.start - 1)) if rangeobj.end < MAX_VAL_TYPE[self.PcdDataType]: - rangeContainer.push(RangeObject(rangeobj.end + 1, MAX_= VAL_TYPE[self.PcdDataType])) + rangeContainer.push(RangeObject( + rangeobj.end + 1, MAX_VAL_TYPE[self.PcdDataType])) self.operanddict[rangeid] =3D rangeContainer rangeids.append(rangeid) =20 @@ -321,7 +341,7 @@ class RangeExpression(BaseExpression): self.operanddict[rangeid2] =3D self.operanddict[re] return rangeid2 =20 - def Eval(self, Operator, Oprand1, Oprand2 =3D None): + def Eval(self, Operator, Oprand1, Oprand2=3DNone): =20 if Operator in ["!", "NOT", "not"]: if not gGuidPattern.match(Oprand1.strip()): @@ -330,7 +350,7 @@ class RangeExpression(BaseExpression): else: if Operator in ["=3D=3D", ">=3D", "<=3D", ">", "<", '^']: return self.EvalRange(Operator, Oprand1) - elif Operator =3D=3D 'and' : + elif Operator =3D=3D 'and': if not gGuidPatternEnd.match(Oprand1.strip()) or not gGuid= PatternEnd.match(Oprand2.strip()): raise BadExpression(ERR_STRING_EXPR % Operator) return self.Rangeintersection(Oprand1, Oprand2) @@ -341,11 +361,11 @@ class RangeExpression(BaseExpression): else: raise BadExpression(ERR_STRING_EXPR % Operator) =20 - - def __init__(self, Expression, PcdDataType, SymbolTable =3D None): + def __init__(self, Expression, PcdDataType, SymbolTable=3DNone): if SymbolTable is None: SymbolTable =3D {} - super(RangeExpression, self).__init__(self, Expression, PcdDataTyp= e, SymbolTable) + super(RangeExpression, self).__init__( + self, Expression, PcdDataType, SymbolTable) self._NoProcess =3D False if not isinstance(Expression, type('')): self._Expr =3D Expression @@ -367,7 +387,6 @@ class RangeExpression(BaseExpression): self._Token =3D '' self._WarnExcept =3D None =20 - # Literal token without any conversion self._LiteralToken =3D '' =20 @@ -383,7 +402,7 @@ class RangeExpression(BaseExpression): # @return: True or False if RealValue is False # Evaluated value of string format if RealValue is True # - def __call__(self, RealValue =3D False, Depth =3D 0): + def __call__(self, RealValue=3DFalse, Depth=3D0): if self._NoProcess: return self._Expr =20 @@ -397,7 +416,7 @@ class RangeExpression(BaseExpression): if RealValue and Depth =3D=3D 0: self._Token =3D self._Expr if gGuidPatternEnd.match(self._Expr): - return [self.operanddict[self._Expr] ] + return [self.operanddict[self._Expr]] =20 self._Idx =3D 0 self._Token =3D '' @@ -507,11 +526,11 @@ class RangeExpression(BaseExpression): # All whitespace and tabs in array are already stripped. IsArray =3D IsGuid =3D False if len(Token.split(',')) =3D=3D 11 and len(Token.split(',{')) =3D= =3D 2 \ - and len(Token.split('},')) =3D=3D 1: + and len(Token.split('},')) =3D=3D 1: HexLen =3D [11, 6, 6, 5, 4, 4, 4, 4, 4, 4, 6] HexList =3D Token.split(',') if HexList[3].startswith('{') and \ - not [Index for Index, Hex in enumerate(HexList) if len(Hex= ) > HexLen[Index]]: + not [Index for Index, Hex in enumerate(HexList) if len= (Hex) > HexLen[Index]]: IsGuid =3D True if Token.lstrip('{').rstrip('}').find('{') =3D=3D -1: if not [Hex for Hex in Token.lstrip('{').rstrip('}').split(','= ) if len(Hex) > 4]: @@ -530,7 +549,8 @@ class RangeExpression(BaseExpression): self._Idx +=3D 1 =20 # Replace escape \\\", \" - Expr =3D self._Expr[self._Idx:].replace('\\\\', '//').replace('\\\= "', '\\\'') + Expr =3D self._Expr[self._Idx:].replace( + '\\\\', '//').replace('\\\"', '\\\'') for Ch in Expr: self._Idx +=3D 1 if Ch =3D=3D '"': @@ -543,7 +563,7 @@ class RangeExpression(BaseExpression): =20 # Get token that is comprised by alphanumeric, underscore or dot(used = by PCD) # @param IsAlphaOp: Indicate if parsing general token or script operat= or(EQ, NE...) - def __GetIdToken(self, IsAlphaOp =3D False): + def __GetIdToken(self, IsAlphaOp=3DFalse): IdToken =3D '' for Ch in self._Expr[self._Idx:]: if not self.__IsIdChar(Ch): @@ -567,7 +587,8 @@ class RangeExpression(BaseExpression): Ex =3D BadExpression(ERR_PCD_RESOLVE % self._Token) Ex.Pcd =3D self._Token raise Ex - self._Token =3D RangeExpression(self._Symb[self._Token], self.= _Symb)(True, self._Depth + 1) + self._Token =3D RangeExpression( + self._Symb[self._Token], self._Symb)(True, self._Depth + 1) if not isinstance(self._Token, type('')): self._LiteralToken =3D hex(self._Token) return @@ -581,7 +602,7 @@ class RangeExpression(BaseExpression): else: self.__IsNumberToken() =20 - def __GetNList(self, InArray =3D False): + def __GetNList(self, InArray=3DFalse): self._GetSingleToken() if not self.__IsHexLiteral(): if InArray: @@ -609,7 +630,7 @@ class RangeExpression(BaseExpression): =20 def __IsHexLiteral(self): if self._LiteralToken.startswith('{') and \ - self._LiteralToken.endswith('}'): + self._LiteralToken.endswith('}'): return True =20 if gHexPattern.match(self._LiteralToken): @@ -645,7 +666,7 @@ class RangeExpression(BaseExpression): Ch =3D Expr[0] Match =3D gGuidPattern.match(Expr) if Match and not Expr[Match.end():Match.end() + 1].isalnum() \ - and Expr[Match.end():Match.end() + 1] !=3D '_': + and Expr[Match.end():Match.end() + 1] !=3D '_': self._Idx +=3D Match.end() self._Token =3D Expr[0:Match.end()] return self._Token diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Sour= ce/Python/Common/StringUtils.py index 73dafa797a52..370ce7147681 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common string related functions used in pars= ing process # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -24,7 +24,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as= mws gHexVerPatt =3D re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$', re.IGNORECASE) gHumanReadableVerPatt =3D re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$') =20 -## GetSplitValueList +# GetSplitValueList # # Get a value list from a string with multiple values split with SplitTag # The default SplitTag is DataType.TAB_VALUE_SPLIT @@ -36,7 +36,9 @@ gHumanReadableVerPatt =3D re.compile(r'([1-9][0-9]*|0)\.[= 0-9]{1,2}$') # # @retval list() A list for splitted string # -def GetSplitValueList(String, SplitTag=3DDataType.TAB_VALUE_SPLIT, MaxSpli= t=3D -1): + + +def GetSplitValueList(String, SplitTag=3DDataType.TAB_VALUE_SPLIT, MaxSpli= t=3D-1): ValueList =3D [] Last =3D 0 Escaped =3D False @@ -80,7 +82,7 @@ def GetSplitValueList(String, SplitTag=3DDataType.TAB_VAL= UE_SPLIT, MaxSplit=3D -1): =20 return ValueList =20 -## GetSplitList +# GetSplitList # # Get a value list from a string with multiple values split with SplitStri= ng # The default SplitTag is DataType.TAB_VALUE_SPLIT @@ -92,10 +94,12 @@ def GetSplitValueList(String, SplitTag=3DDataType.TAB_V= ALUE_SPLIT, MaxSplit=3D -1): # # @retval list() A list for splitted string # -def GetSplitList(String, SplitStr=3DDataType.TAB_VALUE_SPLIT, MaxSplit=3D = -1): + + +def GetSplitList(String, SplitStr=3DDataType.TAB_VALUE_SPLIT, MaxSplit=3D-= 1): return list(map(lambda l: l.strip(), String.split(SplitStr, MaxSplit))) =20 -## MergeArches +# MergeArches # # Find a key's all arches in dict, add the new arch to the list # If not exist any arch, set the arch directly @@ -104,13 +108,15 @@ def GetSplitList(String, SplitStr=3DDataType.TAB_VALU= E_SPLIT, MaxSplit=3D -1): # @param Key: The input value for Key # @param Arch: The Arch to be added or merged # + + def MergeArches(Dict, Key, Arch): if Key in Dict: Dict[Key].append(Arch) else: Dict[Key] =3D Arch.split() =20 -## GenDefines +# GenDefines # # Parse a string with format "DEFINE =3D " # Generate a map Defines[VarName] =3D PATH @@ -124,9 +130,12 @@ def MergeArches(Dict, Key, Arch): # @retval 1 DEFINE statement found, but not valid # @retval -1 DEFINE statement not found # + + def GenDefines(String, Arch, Defines): if String.find(DataType.TAB_DEFINE + ' ') > -1: - List =3D String.replace(DataType.TAB_DEFINE + ' ', '').split(DataT= ype.TAB_EQUAL_SPLIT) + List =3D String.replace(DataType.TAB_DEFINE + ' ', + '').split(DataType.TAB_EQUAL_SPLIT) if len(List) =3D=3D 2: Defines[(CleanString(List[0]), Arch)] =3D CleanString(List[1]) return 0 @@ -135,7 +144,7 @@ def GenDefines(String, Arch, Defines): =20 return 1 =20 -## GenInclude +# GenInclude # # Parse a string with format "!include " # Return the file path @@ -148,15 +157,18 @@ def GenDefines(String, Arch, Defines): # @retval True # @retval False # + + def GenInclude(String, IncludeFiles, Arch): if String.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1: - IncludeFile =3D CleanString(String[String.upper().find(DataType.TA= B_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ]) + IncludeFile =3D CleanString(String[String.upper().find( + DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE= + ' '):]) MergeArches(IncludeFiles, IncludeFile, Arch) return True else: return False =20 -## GetLibraryClassesWithModuleType +# GetLibraryClassesWithModuleType # # Get Library Class definition when no module type defined # @@ -167,6 +179,8 @@ def GenInclude(String, IncludeFiles, Arch): # # @retval True Get library classes successfully # + + def GetLibraryClassesWithModuleType(Lines, Key, KeyValues, CommentCharacte= r): newKey =3D SplitModuleType(Key) Lines =3D Lines.split(DataType.TAB_SECTION_END, 1)[1] @@ -178,7 +192,7 @@ def GetLibraryClassesWithModuleType(Lines, Key, KeyValu= es, CommentCharacter): =20 return True =20 -## GetDynamics +# GetDynamics # # Get Dynamic Pcds # @@ -189,6 +203,8 @@ def GetLibraryClassesWithModuleType(Lines, Key, KeyValu= es, CommentCharacter): # # @retval True Get Dynamic Pcds successfully # + + def GetDynamics(Lines, Key, KeyValues, CommentCharacter): # # Get SkuId Name List @@ -200,11 +216,12 @@ def GetDynamics(Lines, Key, KeyValues, CommentCharact= er): for Line in LineList: Line =3D CleanString(Line, CommentCharacter) if Line !=3D '' and Line[0] !=3D CommentCharacter: - KeyValues.append([CleanString(Line, CommentCharacter), SkuIdNa= meList[1]]) + KeyValues.append( + [CleanString(Line, CommentCharacter), SkuIdNameList[1]]) =20 return True =20 -## SplitModuleType +# SplitModuleType # # Split ModuleType out of section defien to get key # [LibraryClass.Arch.ModuleType|ModuleType|ModuleType] -> [ 'LibraryClass.= Arch', ['ModuleType', 'ModuleType', 'ModuleType'] ] @@ -213,6 +230,8 @@ def GetDynamics(Lines, Key, KeyValues, CommentCharacter= ): # # @retval ReturnValue A list for module types # + + def SplitModuleType(Key): KeyList =3D Key.split(DataType.TAB_SPLIT) # @@ -232,7 +251,7 @@ def SplitModuleType(Key): =20 return ReturnValue =20 -## Replace macro in strings list +# Replace macro in strings list # # This method replace macros used in a given string list. The macros are # given in a dictionary. @@ -243,19 +262,22 @@ def SplitModuleType(Key): # # @retval NewList A new string list whose macros are replaced # + + def ReplaceMacros(StringList, MacroDefinitions=3DNone, SelfReplacement=3DF= alse): NewList =3D [] if MacroDefinitions is None: MacroDefinitions =3D {} for String in StringList: if isinstance(String, type('')): - NewList.append(ReplaceMacro(String, MacroDefinitions, SelfRepl= acement)) + NewList.append(ReplaceMacro( + String, MacroDefinitions, SelfReplacement)) else: NewList.append(String) =20 return NewList =20 -## Replace macro in string +# Replace macro in string # # This method replace macros used in given string. The macros are given in= a # dictionary. @@ -266,6 +288,8 @@ def ReplaceMacros(StringList, MacroDefinitions=3DNone, = SelfReplacement=3DFalse): # # @retval string The string whose macros are replaced # + + def ReplaceMacro(String, MacroDefinitions=3DNone, SelfReplacement=3DFalse,= RaiseError=3DFalse): LastString =3D String if MacroDefinitions is None: @@ -284,7 +308,8 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, SelfR= eplacement=3DFalse, RaiseErro String =3D String.replace("$(%s)" % Macro, '') continue if "$(%s)" % Macro not in MacroDefinitions[Macro]: - String =3D String.replace("$(%s)" % Macro, MacroDefinition= s[Macro]) + String =3D String.replace( + "$(%s)" % Macro, MacroDefinitions[Macro]) # in case there's macro not defined if String =3D=3D LastString: break @@ -292,7 +317,7 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, SelfR= eplacement=3DFalse, RaiseErro =20 return String =20 -## NormPath +# NormPath # # Create a normal path # And replace DEFINE in the path @@ -302,6 +327,8 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, SelfR= eplacement=3DFalse, RaiseErro # # @retval Path Formatted path # + + def NormPath(Path, Defines=3DNone): IsRelativePath =3D False if Path: @@ -317,7 +344,7 @@ def NormPath(Path, Defines=3DNone): # Path =3D os.path.normpath(Path) if Path.startswith(GlobalData.gWorkspace) and not Path.startswith(= GlobalData.gBuildDirectory) and not os.path.exists(Path): - Path =3D Path[len (GlobalData.gWorkspace):] + Path =3D Path[len(GlobalData.gWorkspace):] if Path[0] =3D=3D os.path.sep: Path =3D Path[1:] Path =3D mws.join(GlobalData.gWorkspace, Path) @@ -327,7 +354,7 @@ def NormPath(Path, Defines=3DNone): =20 return Path =20 -## CleanString +# CleanString # # Remove comments in a string # Remove spaces @@ -337,11 +364,13 @@ def NormPath(Path, Defines=3DNone): # # @retval Path Formatted path # + + def CleanString(Line, CommentCharacter=3DDataType.TAB_COMMENT_SPLIT, Allow= CppStyleComment=3DFalse, BuildOption=3DFalse): # # remove whitespace # - Line =3D Line.strip(); + Line =3D Line.strip() # # Replace Edk's comment character # @@ -383,11 +412,11 @@ def CleanString(Line, CommentCharacter=3DDataType.TAB= _COMMENT_SPLIT, AllowCppStyle # # remove whitespace again # - Line =3D Line.strip(); + Line =3D Line.strip() =20 return Line =20 -## CleanString2 +# CleanString2 # # Split statement with comments in a string # Remove spaces @@ -397,11 +426,13 @@ def CleanString(Line, CommentCharacter=3DDataType.TAB= _COMMENT_SPLIT, AllowCppStyle # # @retval Path Formatted path # + + def CleanString2(Line, CommentCharacter=3DDataType.TAB_COMMENT_SPLIT, Allo= wCppStyleComment=3DFalse): # # remove whitespace # - Line =3D Line.strip(); + Line =3D Line.strip() # # Replace Edk's comment character # @@ -428,7 +459,7 @@ def CleanString2(Line, CommentCharacter=3DDataType.TAB_= COMMENT_SPLIT, AllowCppStyl =20 return Line, Comment =20 -## GetMultipleValuesOfKeyFromLines +# GetMultipleValuesOfKeyFromLines # # Parse multiple strings to clean comment and spaces # The result is saved to KeyValues @@ -440,6 +471,8 @@ def CleanString2(Line, CommentCharacter=3DDataType.TAB_= COMMENT_SPLIT, AllowCppStyl # # @retval True Successfully executed # + + def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValues, CommentCharacte= r): Lines =3D Lines.split(DataType.TAB_SECTION_END, 1)[1] LineList =3D Lines.split('\n') @@ -450,7 +483,7 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValu= es, CommentCharacter): =20 return True =20 -## GetDefineValue +# GetDefineValue # # Parse a DEFINE statement to get defined value # DEFINE Key Value @@ -461,11 +494,13 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyVa= lues, CommentCharacter): # # @retval string The defined value # + + def GetDefineValue(String, Key, CommentCharacter): String =3D CleanString(String) - return String[String.find(Key + ' ') + len(Key + ' ') : ] + return String[String.find(Key + ' ') + len(Key + ' '):] =20 -## GetHexVerValue +# GetHexVerValue # # Get a Hex Version Value # @@ -476,6 +511,8 @@ def GetDefineValue(String, Key, CommentCharacter): # If VerString is correctly formatted, return a Hex value of= the Version Number (0xmmmmnnnn) # where mmmm is the major number and nnnn is the adjuste= d minor number. # + + def GetHexVerValue(VerString): VerString =3D CleanString(VerString) =20 @@ -485,7 +522,7 @@ def GetHexVerValue(VerString): Minor =3D ValueList[1] if len(Minor) =3D=3D 1: Minor +=3D '0' - DeciValue =3D (int(Major) << 16) + int(Minor); + DeciValue =3D (int(Major) << 16) + int(Minor) return "0x%08x" % DeciValue elif gHexVerPatt.match(VerString): return VerString @@ -493,7 +530,7 @@ def GetHexVerValue(VerString): return None =20 =20 -## GetSingleValueOfKeyFromLines +# GetSingleValueOfKeyFromLines # # Parse multiple strings as below to get value of each definition line # Key1 =3D Value1 @@ -523,12 +560,14 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, C= ommentCharacter, KeySplitCh if Line.find(DataType.TAB_INF_DEFINES_DEFINE + ' ') > -1: if '' in DefineValues: DefineValues.remove('') - DefineValues.append(GetDefineValue(Line, DataType.TAB_INF_DEFI= NES_DEFINE, CommentCharacter)) + DefineValues.append(GetDefineValue( + Line, DataType.TAB_INF_DEFINES_DEFINE, CommentCharacter)) continue if Line.find(DataType.TAB_INF_DEFINES_SPEC + ' ') > -1: if '' in SpecValues: SpecValues.remove('') - SpecValues.append(GetDefineValue(Line, DataType.TAB_INF_DEFINE= S_SPEC, CommentCharacter)) + SpecValues.append(GetDefineValue( + Line, DataType.TAB_INF_DEFINES_SPEC, CommentCharacter)) continue =20 # @@ -543,9 +582,11 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Co= mmentCharacter, KeySplitCh # LineList[1] =3D CleanString(LineList[1], CommentCharacter) if ValueSplitFlag: - Value =3D list(map(string.strip, LineList[1].split(Val= ueSplitCharacter))) + Value =3D list( + map(string.strip, LineList[1].split(ValueSplitChar= acter))) else: - Value =3D CleanString(LineList[1], CommentCharacter).s= plitlines() + Value =3D CleanString( + LineList[1], CommentCharacter).splitlines() =20 if Key[0] in Dictionary: if Key[0] not in Keys: @@ -565,7 +606,7 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Com= mentCharacter, KeySplitCh =20 return True =20 -## The content to be parsed +# The content to be parsed # # Do pre-check for a file before it is parsed # Check $() @@ -575,6 +616,8 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Com= mentCharacter, KeySplitCh # @param FileContent: File content to be parsed # @param SupSectionTag: Used for error report # + + def PreCheck(FileName, FileContent, SupSectionTag): LineNo =3D 0 IsFailed =3D False @@ -596,7 +639,8 @@ def PreCheck(FileName, FileContent, SupSectionTag): # if Line.find('$') > -1: if Line.find('$(') < 0 or Line.find(')') < 0: - EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, F= ile=3DFileName, RaiseError=3DEdkLogger.IsRaiseError) + EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DEdkLogger.Is= RaiseError) =20 # # Check [] @@ -606,7 +650,8 @@ def PreCheck(FileName, FileContent, SupSectionTag): # Only get one '[' or one ']' # if not (Line.find('[') > -1 and Line.find(']') > -1): - EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, F= ile=3DFileName, RaiseError=3DEdkLogger.IsRaiseError) + EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DEdkLogger.Is= RaiseError) =20 # # Regenerate FileContent @@ -614,11 +659,12 @@ def PreCheck(FileName, FileContent, SupSectionTag): NewFileContent =3D NewFileContent + Line + '\r\n' =20 if IsFailed: - EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, File=3DFil= eName, RaiseError=3DEdkLogger.IsRaiseError) + EdkLogger.error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DEdkLogger.IsRaiseErr= or) =20 return NewFileContent =20 -## CheckFileType +# CheckFileType # # Check if the Filename is including ExtName # Return True if it exists @@ -632,20 +678,23 @@ def PreCheck(FileName, FileContent, SupSectionTag): # # @retval True The file type is correct # -def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, = Line, LineNo=3D -1): + + +def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, = Line, LineNo=3D-1): if CheckFilename !=3D '' and CheckFilename is not None: (Root, Ext) =3D os.path.splitext(CheckFilename) if Ext.upper() !=3D ExtName.upper(): ContainerFile =3D open(ContainerFilename, 'r').read() if LineNo =3D=3D -1: LineNo =3D GetLineNo(ContainerFile, Line) - ErrorMsg =3D "Invalid %s. '%s' is found, but '%s' file is need= ed" % (SectionName, CheckFilename, ExtName) + ErrorMsg =3D "Invalid %s. '%s' is found, but '%s' file is need= ed" % ( + SectionName, CheckFilename, ExtName) EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, Line=3DLineN= o, File=3DContainerFilename, RaiseError=3DEdkLogg= er.IsRaiseError) =20 return True =20 -## CheckFileExist +# CheckFileExist # # Check if the file exists # Return True if it exists @@ -659,7 +708,9 @@ def CheckFileType(CheckFilename, ExtName, ContainerFile= name, SectionName, Line, # # @retval The file full path if the file exists # -def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, Section= Name, Line, LineNo=3D -1): + + +def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, Section= Name, Line, LineNo=3D-1): CheckFile =3D '' if CheckFilename !=3D '' and CheckFilename is not None: CheckFile =3D WorkspaceFile(WorkspaceDir, CheckFilename) @@ -667,13 +718,14 @@ def CheckFileExist(WorkspaceDir, CheckFilename, Conta= inerFilename, SectionName, ContainerFile =3D open(ContainerFilename, 'r').read() if LineNo =3D=3D -1: LineNo =3D GetLineNo(ContainerFile, Line) - ErrorMsg =3D "Can't find file '%s' defined in section '%s'" % = (CheckFile, SectionName) + ErrorMsg =3D "Can't find file '%s' defined in section '%s'" % ( + CheckFile, SectionName) EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DContainerFilename, Line=3DLineNo, Raise= Error=3DEdkLogger.IsRaiseError) =20 return CheckFile =20 -## GetLineNo +# GetLineNo # # Find the index of a line in a file # @@ -683,6 +735,8 @@ def CheckFileExist(WorkspaceDir, CheckFilename, Contain= erFilename, SectionName, # @retval int Index of the line # @retval -1 The line is not found # + + def GetLineNo(FileContent, Line, IsIgnoreComment=3DTrue): LineList =3D FileContent.splitlines() for Index in range(len(LineList)): @@ -697,7 +751,7 @@ def GetLineNo(FileContent, Line, IsIgnoreComment=3DTrue= ): =20 return -1 =20 -## RaiseParserError +# RaiseParserError # # Raise a parser error # @@ -706,15 +760,19 @@ def GetLineNo(FileContent, Line, IsIgnoreComment=3DTr= ue): # @param File: File which has the string # @param Format: Correct format # -def RaiseParserError(Line, Section, File, Format=3D'', LineNo=3D -1): + + +def RaiseParserError(Line, Section, File, Format=3D'', LineNo=3D-1): if LineNo =3D=3D -1: LineNo =3D GetLineNo(open(os.path.normpath(File), 'r').read(), Lin= e) - ErrorMsg =3D "Invalid statement '%s' is found in section '%s'" % (Line= , Section) + ErrorMsg =3D "Invalid statement '%s' is found in section '%s'" % ( + Line, Section) if Format !=3D '': Format =3D "Correct format is " + Format - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DFile, Line=3D= LineNo, ExtraData=3DFormat, RaiseError=3DEdkLogger.IsRaiseError) + EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DFile, + Line=3DLineNo, ExtraData=3DFormat, RaiseError=3DEdkLog= ger.IsRaiseError) =20 -## WorkspaceFile +# WorkspaceFile # # Return a full path with workspace dir # @@ -723,10 +781,12 @@ def RaiseParserError(Line, Section, File, Format=3D''= , LineNo=3D -1): # # @retval string A full path # + + def WorkspaceFile(WorkspaceDir, Filename): return mws.join(NormPath(WorkspaceDir), NormPath(Filename)) =20 -## Split string +# Split string # # Remove '"' which startswith and endswith string # @@ -734,6 +794,8 @@ def WorkspaceFile(WorkspaceDir, Filename): # # @retval String: The string after removed '""' # + + def SplitString(String): if String.startswith('\"'): String =3D String[1:] @@ -742,27 +804,33 @@ def SplitString(String): =20 return String =20 -## Convert To Sql String +# Convert To Sql String # # 1. Replace "'" with "''" in each item of StringList # # @param StringList: A list for strings to be converted # + + def ConvertToSqlString(StringList): return list(map(lambda s: s.replace("'", "''"), StringList)) =20 -## Convert To Sql String +# Convert To Sql String # # 1. Replace "'" with "''" in the String # # @param String: A String to be converted # + + def ConvertToSqlString2(String): return String.replace("'", "''") =20 # # Remove comment block # + + def RemoveBlockComment(Lines): IsFindBlockComment =3D False IsFindBlockCode =3D False @@ -775,10 +843,12 @@ def RemoveBlockComment(Lines): # Remove comment block # if Line.find(DataType.TAB_COMMENT_EDK_START) > -1: - ReservedLine =3D GetSplitList(Line, DataType.TAB_COMMENT_EDK_S= TART, 1)[0] + ReservedLine =3D GetSplitList( + Line, DataType.TAB_COMMENT_EDK_START, 1)[0] IsFindBlockComment =3D True if Line.find(DataType.TAB_COMMENT_EDK_END) > -1: - Line =3D ReservedLine + GetSplitList(Line, DataType.TAB_COMMEN= T_EDK_END, 1)[1] + Line =3D ReservedLine + \ + GetSplitList(Line, DataType.TAB_COMMENT_EDK_END, 1)[1] ReservedLine =3D '' IsFindBlockComment =3D False if IsFindBlockComment: @@ -791,6 +861,8 @@ def RemoveBlockComment(Lines): # # Get String of a List # + + def GetStringOfList(List, Split=3D' '): if not isinstance(List, type([])): return List @@ -803,16 +875,20 @@ def GetStringOfList(List, Split=3D' '): # # Get HelpTextList from HelpTextClassList # + + def GetHelpTextList(HelpTextClassList): List =3D [] if HelpTextClassList: for HelpText in HelpTextClassList: if HelpText.String.endswith('\n'): - HelpText.String =3D HelpText.String[0: len(HelpText.String= ) - len('\n')] + HelpText.String =3D HelpText.String[0: len( + HelpText.String) - len('\n')] List.extend(HelpText.String.split('\n')) =20 return List =20 + def StringToArray(String): if String.startswith('L"'): if String =3D=3D "L\"\"": @@ -836,6 +912,7 @@ def StringToArray(String): else: return '{%s,0,0}' % ','.join(String.split()) =20 + def StringArrayLength(String): if String.startswith('L"'): return (len(String) - 3 + 1) * 2 @@ -844,6 +921,7 @@ def StringArrayLength(String): else: return len(String.split()) + 1 =20 + def RemoveDupOption(OptionString, Which=3D"/I", Against=3DNone): OptionList =3D OptionString.split() ValueList =3D [] @@ -863,6 +941,7 @@ def RemoveDupOption(OptionString, Which=3D"/I", Against= =3DNone): ValueList.append(Val) return " ".join(OptionList) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -870,4 +949,3 @@ def RemoveDupOption(OptionString, Which=3D"/I", Against= =3DNone): # if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseT= ools/Source/Python/Common/TargetTxtClassObject.py index 363c38302b8e..77f3098f801e 100644 --- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py +++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define each component of Target.txt file # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
        @@ -22,7 +22,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as= mws =20 gDefaultTargetTxtFile =3D "target.txt" =20 -## TargetTxtClassObject +# TargetTxtClassObject # # This class defined content used in file target.txt # @@ -31,23 +31,25 @@ gDefaultTargetTxtFile =3D "target.txt" # # @var TargetTxtDictionary: To store keys and values defined in target.txt # + + class TargetTxtClassObject(object): - def __init__(self, Filename =3D None): + def __init__(self, Filename=3DNone): self.TargetTxtDictionary =3D { - DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM = : '', - DataType.TAB_TAT_DEFINES_ACTIVE_MODULE = : '', - DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF = : '', - DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER = : '', - DataType.TAB_TAT_DEFINES_TARGET = : [], - DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG = : [], - DataType.TAB_TAT_DEFINES_TARGET_ARCH = : [], - DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF = : '', + DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM: '', + DataType.TAB_TAT_DEFINES_ACTIVE_MODULE: '', + DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF: '', + DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER: '', + DataType.TAB_TAT_DEFINES_TARGET: [], + DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG: [], + DataType.TAB_TAT_DEFINES_TARGET_ARCH: [], + DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF: '', } self.ConfDirectoryPath =3D "" if Filename is not None: self.LoadTargetTxtFile(Filename) =20 - ## LoadTargetTxtFile + # LoadTargetTxtFile # # Load target.txt file and parse it, return a set structure to store k= eys and values # @@ -58,12 +60,13 @@ class TargetTxtClassObject(object): # def LoadTargetTxtFile(self, Filename): if os.path.exists(Filename) and os.path.isfile(Filename): - return self.ConvertTextFileToDict(Filename, '#', '=3D') + return self.ConvertTextFileToDict(Filename, '#', '=3D') else: - EdkLogger.error("Target.txt Parser", FILE_NOT_FOUND, ExtraData= =3DFilename) + EdkLogger.error("Target.txt Parser", + FILE_NOT_FOUND, ExtraData=3DFilename) return 1 =20 - ## ConvertTextFileToDict + # ConvertTextFileToDict # # Convert a text file to a dictionary of (name:value) pairs. # The data is saved to self.TargetTxtDictionary @@ -97,30 +100,36 @@ class TargetTxtClassObject(object): else: Value =3D "" =20 - if Key in [DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM, DataType.= TAB_TAT_DEFINES_TOOL_CHAIN_CONF, \ + if Key in [DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM, DataType.= TAB_TAT_DEFINES_TOOL_CHAIN_CONF, DataType.TAB_TAT_DEFINES_ACTIVE_MODULE, DataType.TA= B_TAT_DEFINES_BUILD_RULE_CONF]: self.TargetTxtDictionary[Key] =3D Value.replace('\\', '/') if Key =3D=3D DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF and= self.TargetTxtDictionary[Key]: if self.TargetTxtDictionary[Key].startswith("Conf/"): - Tools_Def =3D os.path.join(self.ConfDirectoryPath,= self.TargetTxtDictionary[Key].strip()) + Tools_Def =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDictiona= ry[Key].strip()) if not os.path.exists(Tools_Def) or not os.path.is= file(Tools_Def): # If Conf/Conf does not exist, try just the Co= nf/ directory - Tools_Def =3D os.path.join(self.ConfDirectoryP= ath, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip()) + Tools_Def =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDict= ionary[Key].replace("Conf/", "", 1).strip()) else: # The File pointed to by TOOL_CHAIN_CONF is not in= a Conf/ directory - Tools_Def =3D os.path.join(self.ConfDirectoryPath,= self.TargetTxtDictionary[Key].strip()) + Tools_Def =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDictiona= ry[Key].strip()) self.TargetTxtDictionary[Key] =3D Tools_Def if Key =3D=3D DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF and= self.TargetTxtDictionary[Key]: if self.TargetTxtDictionary[Key].startswith("Conf/"): - Build_Rule =3D os.path.join(self.ConfDirectoryPath= , self.TargetTxtDictionary[Key].strip()) + Build_Rule =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDictiona= ry[Key].strip()) if not os.path.exists(Build_Rule) or not os.path.i= sfile(Build_Rule): # If Conf/Conf does not exist, try just the Co= nf/ directory - Build_Rule =3D os.path.join(self.ConfDirectory= Path, self.TargetTxtDictionary[Key].replace("Conf/", "", 1).strip()) + Build_Rule =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDict= ionary[Key].replace("Conf/", "", 1).strip()) else: # The File pointed to by BUILD_RULE_CONF is not in= a Conf/ directory - Build_Rule =3D os.path.join(self.ConfDirectoryPath= , self.TargetTxtDictionary[Key].strip()) + Build_Rule =3D os.path.join( + self.ConfDirectoryPath, self.TargetTxtDictiona= ry[Key].strip()) self.TargetTxtDictionary[Key] =3D Build_Rule - elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT= _DEFINES_TARGET_ARCH, \ + elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT= _DEFINES_TARGET_ARCH, DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]: self.TargetTxtDictionary[Key] =3D Value.split() elif Key =3D=3D DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD= _NUMBER: @@ -130,13 +139,13 @@ class TargetTxtClassObject(object): EdkLogger.error("build", FORMAT_INVALID, "Invalid numb= er of [%s]: %s." % (Key, Value), File=3DFileName) self.TargetTxtDictionary[Key] =3D Value - #elif Key not in GlobalData.gGlobalDefines: + # elif Key not in GlobalData.gGlobalDefines: # GlobalData.gGlobalDefines[Key] =3D Value =20 F.close() return 0 =20 -## TargetTxtDict +# TargetTxtDict # # Load target.txt in input Conf dir # @@ -145,6 +154,7 @@ class TargetTxtClassObject(object): # @retval Target An instance of TargetTxtClassObject() with loaded target.= txt # =20 + class TargetTxtDict(): =20 def __new__(cls, *args, **kw): @@ -173,19 +183,23 @@ class TargetTxtDict(): if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alte= rnate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory = in the workspace. Using --conf=3DConf - ConfDirectoryPath =3D mws.join(os.environ["WORKSPACE"], Co= nfDirectoryPath) + ConfDirectoryPath =3D mws.join( + os.environ["WORKSPACE"], ConfDirectoryPath) else: if "CONF_PATH" in os.environ: - ConfDirectoryPath =3D os.path.normcase(os.path.normpath(os= .environ["CONF_PATH"])) + ConfDirectoryPath =3D os.path.normcase( + os.path.normpath(os.environ["CONF_PATH"])) else: # Get standard WORKSPACE/Conf use the absolute path to the= WORKSPACE/Conf ConfDirectoryPath =3D mws.join(os.environ["WORKSPACE"], 'C= onf') GlobalData.gConfDirectory =3D ConfDirectoryPath - targettxt =3D os.path.normpath(os.path.join(ConfDirectoryPath, gDe= faultTargetTxtFile)) + targettxt =3D os.path.normpath(os.path.join( + ConfDirectoryPath, gDefaultTargetTxtFile)) if os.path.exists(targettxt): Target.LoadTargetTxtFile(targettxt) self.TxtTarget =3D Target =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -194,6 +208,7 @@ class TargetTxtDict(): if __name__ =3D=3D '__main__': pass Target =3D TargetTxtDict(os.getenv("WORKSPACE")) - print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRE= NT_THREAD_NUMBER]) + print( + Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT= _THREAD_NUMBER]) print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]) print(Target.TargetTxtDictionary) diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseToo= ls/Source/Python/Common/ToolDefClassObject.py index 2b4b23849196..bad836722407 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define each component of tools_def.txt file # # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
        @@ -22,9 +22,8 @@ import Common.GlobalData as GlobalData from Common import GlobalData from Common.MultipleWorkspace import MultipleWorkspace as mws from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_T= AG,\ - TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_= TYPE\ - , TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFA= MILY,\ - TAB_STAR, TAB_TAT_DEFINES_TOOL_CHAIN_CONF + TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE, TAB_TOD_DEF= INES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY,\ + TAB_STAR, TAB_TAT_DEFINES_TOOL_CHAIN_CONF =20 =20 ## @@ -35,7 +34,7 @@ gEnvRefPattern =3D re.compile('(ENV\([^\(\)]+\))') gMacroDefPattern =3D re.compile("DEFINE\s+([^\s]+)") gDefaultToolsDefFile =3D "tools_def.txt" =20 -## ToolDefClassObject +# ToolDefClassObject # # This class defined content used in file tools_def.txt # @@ -45,6 +44,8 @@ gDefaultToolsDefFile =3D "tools_def.txt" # @var ToolsDefTxtDictionary: To store keys and values defined in target.= txt # @var MacroDictionary: To store keys and values defined in DEFINE = statement # + + class ToolDefClassObject(object): def __init__(self, FileName=3DNone): self.ToolsDefTxtDictionary =3D {} @@ -55,7 +56,7 @@ class ToolDefClassObject(object): if FileName is not None: self.LoadToolDefFile(FileName) =20 - ## LoadToolDefFile + # LoadToolDefFile # # Load target.txt file and parse it # @@ -67,26 +68,30 @@ class ToolDefClassObject(object): mws.setWs(GlobalData.gWorkspace, PackagesPath) =20 self.ToolsDefTxtDatabase =3D { - TAB_TOD_DEFINES_TARGET : [], - TAB_TOD_DEFINES_TOOL_CHAIN_TAG : [], - TAB_TOD_DEFINES_TARGET_ARCH : [], - TAB_TOD_DEFINES_COMMAND_TYPE : [] + TAB_TOD_DEFINES_TARGET: [], + TAB_TOD_DEFINES_TOOL_CHAIN_TAG: [], + TAB_TOD_DEFINES_TARGET_ARCH: [], + TAB_TOD_DEFINES_COMMAND_TYPE: [] } =20 self.IncludeToolDefFile(FileName) =20 - self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET] =3D list(set(self= .ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET])) - self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] =3D list(= set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG])) - self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH] =3D list(set= (self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH])) + self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET] =3D list( + set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET])) + self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG] =3D list( + set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG])) + self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH] =3D list( + set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH])) =20 - self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE] =3D list(se= t(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE])) + self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE] =3D list( + set(self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE])) =20 self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET].sort() self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG].sort() self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH].sort() self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE].sort() =20 - ## IncludeToolDefFile + # IncludeToolDefFile # # Load target.txt file and parse it as if its contents were inside the= main file # @@ -99,9 +104,11 @@ class ToolDefClassObject(object): F =3D open(FileName, 'r') FileContent =3D F.readlines() except: - EdkLogger.error("tools_def.txt parser", FILE_OPEN_FAILURE,= ExtraData=3DFileName) + EdkLogger.error("tools_def.txt parser", + FILE_OPEN_FAILURE, ExtraData=3DFileName) else: - EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraD= ata=3DFileName) + EdkLogger.error("tools_def.txt parser", + FILE_NOT_FOUND, ExtraData=3DFileName) =20 for Index in range(len(FileContent)): Line =3D FileContent[Index].strip() @@ -114,7 +121,7 @@ class ToolDefClassObject(object): if not Done: EdkLogger.error("tools_def.txt parser", ATTRIBUTE_NOT_= AVAILABLE, "Macro or Environment has not been def= ined", - ExtraData=3DIncFile[4:-1], File=3DFileName= , Line=3DIndex+1) + ExtraData=3DIncFile[4:-1], File=3DFile= Name, Line=3DIndex+1) IncFile =3D NormPath(IncFile) =20 if not os.path.isabs(IncFile): @@ -132,10 +139,12 @@ class ToolDefClassObject(object): # # try directory of current file # - IncFileTmp =3D PathClass(IncFile, os.path.dirn= ame(FileName)) + IncFileTmp =3D PathClass( + IncFile, os.path.dirname(FileName)) ErrorCode =3D IncFileTmp.Validate()[0] if ErrorCode !=3D 0: - EdkLogger.error("tools_def.txt parser", FI= LE_NOT_FOUND, ExtraData=3DIncFile) + EdkLogger.error( + "tools_def.txt parser", FILE_NOT_FOUND= , ExtraData=3DIncFile) =20 if isinstance(IncFileTmp, PathClass): IncFile =3D IncFileTmp.Path @@ -147,14 +156,16 @@ class ToolDefClassObject(object): =20 NameValuePair =3D Line.split("=3D", 1) if len(NameValuePair) !=3D 2: - EdkLogger.warn("tools_def.txt parser", "Line %d: not corre= ct assignment statement, skipped" % (Index + 1)) + EdkLogger.warn( + "tools_def.txt parser", "Line %d: not correct assignme= nt statement, skipped" % (Index + 1)) continue =20 Name =3D NameValuePair[0].strip() Value =3D NameValuePair[1].strip() =20 if Name =3D=3D "IDENTIFIER": - EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found identif= ier statement, skipped: %s" % ((Index + 1), Value)) + EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found identif= ier statement, skipped: %s" % ( + (Index + 1), Value)) continue =20 MacroDefinition =3D gMacroDefPattern.findall(Name) @@ -163,11 +174,12 @@ class ToolDefClassObject(object): if not Done: EdkLogger.error("tools_def.txt parser", ATTRIBUTE_NOT_= AVAILABLE, "Macro or Environment has not been def= ined", - ExtraData=3DValue[4:-1], File=3DFileName, = Line=3DIndex+1) + ExtraData=3DValue[4:-1], File=3DFileNa= me, Line=3DIndex+1) =20 MacroName =3D MacroDefinition[0].strip() self.MacroDictionary["DEF(%s)" % MacroName] =3D Value - EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found macro: = %s =3D %s" % ((Index + 1), MacroName, Value)) + EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found macro: = %s =3D %s" % ( + (Index + 1), MacroName, Value)) continue =20 Done, Value =3D self.ExpandMacros(Value) @@ -178,10 +190,12 @@ class ToolDefClassObject(object): =20 List =3D Name.split('_') if len(List) !=3D 5: - EdkLogger.verbose("Line %d: Not a valid name of definition= : %s" % ((Index + 1), Name)) + EdkLogger.verbose( + "Line %d: Not a valid name of definition: %s" % ((Inde= x + 1), Name)) continue elif List[4] =3D=3D TAB_STAR: - EdkLogger.verbose("Line %d: '*' is not allowed in last fie= ld: %s" % ((Index + 1), Name)) + EdkLogger.verbose( + "Line %d: '*' is not allowed in last field: %s" % ((In= dex + 1), Name)) continue else: self.ToolsDefTxtDictionary[Name] =3D Value @@ -197,20 +211,23 @@ class ToolDefClassObject(object): if TAB_TOD_DEFINES_FAMILY not in self.ToolsDefTxtDatab= ase: self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY] = =3D {} self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][L= ist[1]] =3D Value - self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULE= FAMILY] =3D {} + self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULE= FAMILY] =3D { + } self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULE= FAMILY][List[1]] =3D Value elif List[1] not in self.ToolsDefTxtDatabase[TAB_TOD_D= EFINES_FAMILY]: self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][L= ist[1]] =3D Value self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULE= FAMILY][List[1]] =3D Value elif self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_FAMILY][= List[1]] !=3D Value: - EdkLogger.verbose("Line %d: No override allowed fo= r the family of a tool chain: %s" % ((Index + 1), Name)) + EdkLogger.verbose( + "Line %d: No override allowed for the family o= f a tool chain: %s" % ((Index + 1), Name)) if List[4] =3D=3D TAB_TOD_DEFINES_BUILDRULEFAMILY and List= [2] =3D=3D TAB_STAR and List[3] =3D=3D TAB_STAR: if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.ToolsDe= fTxtDatabase \ or List[1] not in self.ToolsDefTxtDatabase[TAB_TOD_= DEFINES_FAMILY]: - EdkLogger.verbose("Line %d: The family is not spec= ified, but BuildRuleFamily is specified for the tool chain: %s" % ((Index += 1), Name)) + EdkLogger.verbose( + "Line %d: The family is not specified, but Bui= ldRuleFamily is specified for the tool chain: %s" % ((Index + 1), Name)) self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_BUILDRULEFAMI= LY][List[1]] =3D Value =20 - ## ExpandMacros + # ExpandMacros # # Replace defined macros with real value # @@ -228,7 +245,8 @@ class ToolDefClassObject(object): if Ref in self.MacroDictionary: Value =3D Value.replace(Ref, self.MacroDictionary[Ref]) else: - Value =3D Value.replace(Ref, self.MacroDictionary[Ref.= upper()]) + Value =3D Value.replace( + Ref, self.MacroDictionary[Ref.upper()]) MacroReference =3D gMacroRefPattern.findall(Value) for Ref in MacroReference: if Ref not in self.MacroDictionary: @@ -237,7 +255,7 @@ class ToolDefClassObject(object): =20 return True, Value =20 -## ToolDefDict +# ToolDefDict # # Load tools_def.txt in input Conf dir # @@ -275,11 +293,14 @@ class ToolDefDict(): if ToolsDefFile: ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile)) else: - ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self= .ConfDir, gDefaultToolsDefFile))) + ToolDef.LoadToolDefFile(os.path.normpath( + os.path.join(self.ConfDir, gDefaultToolsDefFile))) else: - ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self.Con= fDir, gDefaultToolsDefFile))) + ToolDef.LoadToolDefFile(os.path.normpath( + os.path.join(self.ConfDir, gDefaultToolsDefFile))) self._ToolDef =3D ToolDef =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.= py b/BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.py index 74004857a737..c132a073d093 100644 --- a/BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.py +++ b/BaseTools/Source/Python/Common/Uefi/Capsule/CapsuleDependency.py @@ -1,4 +1,4 @@ -## @file +# @file # Module that encodes and decodes a capsule dependency. # # Copyright (c) 2019, Intel Corporation. All rights reserved.
        @@ -14,95 +14,103 @@ import re CapsuleDependency ''' =20 + class OpConvert (object): - def __init__ (self): + def __init__(self): # Opcode: (OperandSize, PackSize, PackFmt, EncodeConvert, DecodeCo= nvert) self._DepexOperations =3D {0x00: (16, 16, 's', self.Str2Guid, s= elf.Guid2Str), 0x01: (4, 1, 'I', self.Str2Uint, sel= f.Uint2Str), 0x02: (1, 0, 's', self.Str2Utf8, sel= f.Byte2Str), } =20 - def Str2Uint (self, Data): + def Str2Uint(self, Data): try: - Value =3D int (Data, 16) + Value =3D int(Data, 16) except: - Message =3D '{Data} is not a valid integer value.'.format (Dat= a =3D Data) - raise ValueError (Message) + Message =3D '{Data} is not a valid integer value.'.format(Data= =3DData) + raise ValueError(Message) if Value < 0 or Value > 0xFFFFFFFF: - Message =3D '{Data} is not an UINT32.'.format (Data =3D Data) - raise ValueError (Message) + Message =3D '{Data} is not an UINT32.'.format(Data=3DData) + raise ValueError(Message) return Value =20 - def Uint2Str (self, Data): + def Uint2Str(self, Data): if Data < 0 or Data > 0xFFFFFFFF: - Message =3D '{Data} is not an UINT32.'.format (Data =3D Data) - raise ValueError (Message) - return "0x{Data:08x}".format (Data =3D Data) + Message =3D '{Data} is not an UINT32.'.format(Data=3DData) + raise ValueError(Message) + return "0x{Data:08x}".format(Data=3DData) =20 - def Str2Guid (self, Data): + def Str2Guid(self, Data): try: - Guid =3D uuid.UUID (Data) + Guid =3D uuid.UUID(Data) except: - Message =3D '{Data} is not a valid registry format GUID value.= '.format (Data =3D Data) - raise ValueError (Message) + Message =3D '{Data} is not a valid registry format GUID value.= '.format( + Data=3DData) + raise ValueError(Message) return Guid.bytes_le =20 - def Guid2Str (self, Data): + def Guid2Str(self, Data): try: - Guid =3D uuid.UUID (bytes_le =3D Data) + Guid =3D uuid.UUID(bytes_le=3DData) except: - Message =3D '{Data} is not a valid binary format GUID value.'.= format (Data =3D Data) - raise ValueError (Message) - return str (Guid).upper () + Message =3D '{Data} is not a valid binary format GUID value.'.= format( + Data=3DData) + raise ValueError(Message) + return str(Guid).upper() =20 - def Str2Utf8 (self, Data): - if isinstance (Data, str): - return Data.encode ('utf-8') + def Str2Utf8(self, Data): + if isinstance(Data, str): + return Data.encode('utf-8') else: - Message =3D '{Data} is not a valid string.'.format (Data =3D D= ata) - raise ValueError (Message) + Message =3D '{Data} is not a valid string.'.format(Data=3DData) + raise ValueError(Message) =20 - def Byte2Str (self, Data): - if isinstance (Data, bytes): + def Byte2Str(self, Data): + if isinstance(Data, bytes): if Data[-1:] =3D=3D b'\x00': - return str (Data[:-1], 'utf-8') + return str(Data[:-1], 'utf-8') else: - return str (Data, 'utf-8') + return str(Data, 'utf-8') else: - Message =3D '{Data} is not a valid binary string.'.format (Dat= a =3D Data) - raise ValueError (Message) + Message =3D '{Data} is not a valid binary string.'.format(Data= =3DData) + raise ValueError(Message) =20 - def OpEncode (self, Opcode, Operand =3D None): - BinTemp =3D struct.pack (' 0xFFFFFFFF: return False except: return False return True =20 - def IsValidBoolean (self, operand): + def IsValidBoolean(self, operand): try: - return operand.upper () in ['TRUE', 'FALSE'] + return operand.upper() in ['TRUE', 'FALSE'] except: return False =20 - def IsValidOperand (self, operand): - return self.IsValidVersion (operand) or self.IsValidGuid (operand)= or self.IsValidBoolean (operand) + def IsValidOperand(self, operand): + return self.IsValidVersion(operand) or self.IsValidGuid(operand) o= r self.IsValidBoolean(operand) =20 - def IsValidString (self, operand): + def IsValidString(self, operand): return operand[0] =3D=3D "\"" and operand[-1] =3D=3D "\"" and len(= operand) >=3D 2 =20 # Check if priority of current operater is greater than pervious op - def PriorityNotGreater (self, prevOp, currOp): + def PriorityNotGreater(self, prevOp, currOp): return self._opReference[currOp][0] <=3D self._opReference[prevOp]= [0] =20 - def ValidateDepex (self): + def ValidateDepex(self): OpList =3D self._DepexList =20 i =3D 0 - while i < len (OpList): + while i < len(OpList): Op =3D OpList[i] =20 if Op =3D=3D 'DECLARE': i +=3D 1 - if i >=3D len (OpList): - Msg =3D 'No more Operand after {Op}.'.format (Op =3D O= pList[i-1]) - raise IndexError (Msg) + if i >=3D len(OpList): + Msg =3D 'No more Operand after {Op}.'.format(Op=3DOpLi= st[i-1]) + raise IndexError(Msg) # Check valid string if not self.IsValidString(OpList[i]): - Msg =3D '{Operand} after {Op} is not a valid expressio= n input.'.format (Operand =3D OpList[i], Op =3D OpList[i-1]) - raise ValueError (Msg) + Msg =3D '{Operand} after {Op} is not a valid expressio= n input.'.format( + Operand=3DOpList[i], Op=3DOpList[i-1]) + raise ValueError(Msg) =20 elif Op =3D=3D '(': # Expression cannot end with ( - if i =3D=3D len (OpList) - 1: + if i =3D=3D len(OpList) - 1: Msg =3D 'Expression cannot end with \'(\'' - raise ValueError (Msg) + raise ValueError(Msg) # The previous op after '(' cannot be a binocular operator - if self.IsValidBinocularOperator (OpList[i+1]) : - Msg =3D '{Op} after \'(\' is not a valid expression in= put.'.format (Op =3D OpList[i+1]) - raise ValueError (Msg) + if self.IsValidBinocularOperator(OpList[i+1]): + Msg =3D '{Op} after \'(\' is not a valid expression in= put.'.format( + Op=3DOpList[i+1]) + raise ValueError(Msg) =20 elif Op =3D=3D ')': # Expression cannot start with ) if i =3D=3D 0: Msg =3D 'Expression cannot start with \')\'' - raise ValueError (Msg) + raise ValueError(Msg) # The previous op before ')' cannot be an operator - if self.IsValidOperator (OpList[i-1]): - Msg =3D '{Op} before \')\' is not a valid expression i= nput.'.format (Op =3D OpList[i-1]) - raise ValueError (Msg) + if self.IsValidOperator(OpList[i-1]): + Msg =3D '{Op} before \')\' is not a valid expression i= nput.'.format( + Op=3DOpList[i-1]) + raise ValueError(Msg) # The next op after ')' cannot be operand or unary operator - if (i + 1) < len (OpList) and (self.IsValidOperand (OpList= [i+1]) or self.IsValidUnaryOperator (OpList[i+1])): - Msg =3D '{Op} after \')\' is not a valid expression in= put.'.format (Op =3D OpList[i+1]) - raise ValueError (Msg) + if (i + 1) < len(OpList) and (self.IsValidOperand(OpList[i= +1]) or self.IsValidUnaryOperator(OpList[i+1])): + Msg =3D '{Op} after \')\' is not a valid expression in= put.'.format( + Op=3DOpList[i+1]) + raise ValueError(Msg) =20 - elif self.IsValidOperand (Op): + elif self.IsValidOperand(Op): # The next expression of operand cannot be operand or unar= y operator - if (i + 1) < len (OpList) and (self.IsValidOperand (OpList= [i+1]) or self.IsValidUnaryOperator (OpList[i+1])): - Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format (Op =3D OpList[i+1], PrevOp =3D Op) - raise ValueError (Msg) + if (i + 1) < len(OpList) and (self.IsValidOperand(OpList[i= +1]) or self.IsValidUnaryOperator(OpList[i+1])): + Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format( + Op=3DOpList[i+1], PrevOp=3DOp) + raise ValueError(Msg) =20 - elif self.IsValidOperator (Op): + elif self.IsValidOperator(Op): # The next op of operator cannot binocular operator - if (i + 1) < len (OpList) and self.IsValidBinocularOperato= r (OpList[i+1]): - Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format (Op =3D OpList[i+1], PrevOp =3D Op) - raise ValueError (Msg) + if (i + 1) < len(OpList) and self.IsValidBinocularOperator= (OpList[i+1]): + Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format( + Op=3DOpList[i+1], PrevOp=3DOp) + raise ValueError(Msg) # The first op can not be binocular operator - if i =3D=3D 0 and self.IsValidBinocularOperator (Op): - Msg =3D 'Expression cannot start with an operator {Op}= .'.format (Op =3D Op) - raise ValueError (Msg) + if i =3D=3D 0 and self.IsValidBinocularOperator(Op): + Msg =3D 'Expression cannot start with an operator {Op}= .'.format( + Op=3DOp) + raise ValueError(Msg) # The last op can not be operator - if i =3D=3D len (OpList) - 1: - Msg =3D 'Expression cannot ended with an operator {Op}= .'.format (Op =3D Op) - raise ValueError (Msg) + if i =3D=3D len(OpList) - 1: + Msg =3D 'Expression cannot ended with an operator {Op}= .'.format( + Op=3DOp) + raise ValueError(Msg) # The next op of unary operator cannot be guid / version - if self.IsValidUnaryOperator (Op) and (self.IsValidGuid (O= pList[i+1]) or self.IsValidVersion (OpList[i+1])): - Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format (Op =3D OpList[i+1], PrevOp =3D Op) - raise ValueError (Msg) + if self.IsValidUnaryOperator(Op) and (self.IsValidGuid(OpL= ist[i+1]) or self.IsValidVersion(OpList[i+1])): + Msg =3D '{Op} after {PrevOp} is not a valid expression= input.'.format( + Op=3DOpList[i+1], PrevOp=3DOp) + raise ValueError(Msg) =20 else: - Msg =3D '{Op} is not a valid expression input.'.format (Op= =3D Op) - raise ValueError (Msg) + Msg =3D '{Op} is not a valid expression input.'.format(Op= =3DOp) + raise ValueError(Msg) i +=3D 1 =20 - def Encode (self): + def Encode(self): # initialize self.Depex =3D b'' self._DepexDump =3D [] @@ -270,80 +289,84 @@ class CapsuleDependencyClass (object): OpeartorStack =3D [] OpList =3D self._DepexList =20 - self.ValidateDepex () + self.ValidateDepex() =20 # convert i =3D 0 - while i < len (OpList): + while i < len(OpList): Op =3D OpList[i] if Op =3D=3D 'DECLARE': # This declare next expression value is a VERSION_STRING i +=3D 1 - self.Depex +=3D self.OpConverter.OpEncode (0x02, OpList[i]= [1:-1]) + self.Depex +=3D self.OpConverter.OpEncode(0x02, OpList[i][= 1:-1]) =20 elif Op =3D=3D '(': - OpeartorStack.append (Op) + OpeartorStack.append(Op) =20 elif Op =3D=3D ')': while (OpeartorStack and OpeartorStack[-1] !=3D '('): - Operator =3D OpeartorStack.pop () - self.Depex +=3D self.OpConverter.OpEncode (self._opRef= erence[Operator][1]) + Operator =3D OpeartorStack.pop() + self.Depex +=3D self.OpConverter.OpEncode( + self._opReference[Operator][1]) try: - OpeartorStack.pop () # pop out '(' + OpeartorStack.pop() # pop out '(' except: Msg =3D 'Pop out \'(\' failed, too many \')\'' - raise ValueError (Msg) + raise ValueError(Msg) =20 - elif self.IsValidGuid (Op): + elif self.IsValidGuid(Op): if not OperandStack: - OperandStack.append (self.OpConverter.OpEncode (0x00, = Op)) + OperandStack.append(self.OpConverter.OpEncode(0x00, Op= )) else: # accroding to uefi spec 2.8, the guid/version operand= s is a reversed order in firmware comparison. - self.Depex +=3D self.OpConverter.OpEncode (0x00, Op) - self.Depex +=3D OperandStack.pop () + self.Depex +=3D self.OpConverter.OpEncode(0x00, Op) + self.Depex +=3D OperandStack.pop() =20 - elif self.IsValidVersion (Op): + elif self.IsValidVersion(Op): if not OperandStack: - OperandStack.append (self.OpConverter.OpEncode (0x01, = Op)) + OperandStack.append(self.OpConverter.OpEncode(0x01, Op= )) else: # accroding to uefi spec 2.8, the guid/version operand= s is a reversed order in firmware comparison. - self.Depex +=3D self.OpConverter.OpEncode (0x01, Op) - self.Depex +=3D OperandStack.pop () + self.Depex +=3D self.OpConverter.OpEncode(0x01, Op) + self.Depex +=3D OperandStack.pop() =20 - elif self.IsValidBoolean (Op): - if Op.upper () =3D=3D 'FALSE': - self.Depex +=3D self.OpConverter.OpEncode (0x07) - elif Op.upper () =3D=3D 'TRUE': - self.Depex +=3D self.OpConverter.OpEncode (0x06) + elif self.IsValidBoolean(Op): + if Op.upper() =3D=3D 'FALSE': + self.Depex +=3D self.OpConverter.OpEncode(0x07) + elif Op.upper() =3D=3D 'TRUE': + self.Depex +=3D self.OpConverter.OpEncode(0x06) =20 - elif self.IsValidOperator (Op): - while (OpeartorStack and OpeartorStack[-1] !=3D '(' and se= lf.PriorityNotGreater (OpeartorStack[-1], Op)): - Operator =3D OpeartorStack.pop () - self.Depex +=3D self.OpConverter.OpEncode (self._opRef= erence[Operator][1]) - OpeartorStack.append (Op) + elif self.IsValidOperator(Op): + while (OpeartorStack and OpeartorStack[-1] !=3D '(' and se= lf.PriorityNotGreater(OpeartorStack[-1], Op)): + Operator =3D OpeartorStack.pop() + self.Depex +=3D self.OpConverter.OpEncode( + self._opReference[Operator][1]) + OpeartorStack.append(Op) =20 i +=3D 1 =20 while OpeartorStack: - Operator =3D OpeartorStack.pop () + Operator =3D OpeartorStack.pop() if Operator =3D=3D '(': Msg =3D 'Too many \'(\'.' - raise ValueError (Msg) - self.Depex +=3D self.OpConverter.OpEncode (self._opReference[O= perator][1]) - self.Depex +=3D self.OpConverter.OpEncode (0x0D) + raise ValueError(Msg) + self.Depex +=3D self.OpConverter.OpEncode( + self._opReference[Operator][1]) + self.Depex +=3D self.OpConverter.OpEncode(0x0D) =20 self._Valid =3D True - self._DepexSize =3D len (self.Depex) + self._DepexSize =3D len(self.Depex) return self.Depex + self.Payload =20 - def Decode (self, Buffer): + def Decode(self, Buffer): # initialize self.Depex =3D Buffer OperandStack =3D [] DepexLen =3D 0 =20 while True: - Opcode, Operand, OperandSize =3D self.OpConverter.OpDecode (Bu= ffer[DepexLen:]) + Opcode, Operand, OperandSize =3D self.OpConverter.OpDecode( + Buffer[DepexLen:]) DepexLen +=3D OperandSize + 1 =20 if Opcode =3D=3D 0x0D: @@ -351,59 +374,68 @@ class CapsuleDependencyClass (object): =20 elif Opcode =3D=3D 0x02: if not OperandStack: - OperandStack.append ('DECLARE \"{String}\"'.format (St= ring =3D Operand)) + OperandStack.append( + 'DECLARE \"{String}\"'.format(String=3DOperand)) else: - PrevOperand =3D OperandStack.pop () - OperandStack.append ('{Operand} DECLARE \"{String}\"'.= format (Operand =3D PrevOperand, String =3D Operand)) + PrevOperand =3D OperandStack.pop() + OperandStack.append('{Operand} DECLARE \"{String}\"'.f= ormat( + Operand=3DPrevOperand, String=3DOperand)) =20 elif Opcode in [0x00, 0x01]: - OperandStack.append (Operand) + OperandStack.append(Operand) =20 elif Opcode =3D=3D 0x06: - OperandStack.append ('TRUE') + OperandStack.append('TRUE') =20 elif Opcode =3D=3D 0x07: - OperandStack.append ('FALSE') + OperandStack.append('FALSE') =20 - elif self.IsValidOperator (self._opReferenceReverse[Opcode]): + elif self.IsValidOperator(self._opReferenceReverse[Opcode]): Operator =3D self._opReferenceReverse[Opcode] - if self.IsValidUnaryOperator (self._opReferenceReverse[Opc= ode]) and len (OperandStack) >=3D 1: - Oprand =3D OperandStack.pop () - OperandStack.append (' ( {Operator} {Oprand} )'.format= (Operator =3D Operator, Oprand =3D Oprand)) - elif self.IsValidBinocularOperator (self._opReferenceRever= se[Opcode]) and len (OperandStack) >=3D 2: - Oprand1 =3D OperandStack.pop () - Oprand2 =3D OperandStack.pop () - OperandStack.append (' ( {Oprand1} {Operator} {Oprand2= } )'.format (Operator =3D Operator, Oprand1 =3D Oprand1, Oprand2 =3D Oprand= 2)) + if self.IsValidUnaryOperator(self._opReferenceReverse[Opco= de]) and len(OperandStack) >=3D 1: + Oprand =3D OperandStack.pop() + OperandStack.append(' ( {Operator} {Oprand} )'.format( + Operator=3DOperator, Oprand=3DOprand)) + elif self.IsValidBinocularOperator(self._opReferenceRevers= e[Opcode]) and len(OperandStack) >=3D 2: + Oprand1 =3D OperandStack.pop() + Oprand2 =3D OperandStack.pop() + OperandStack.append(' ( {Oprand1} {Operator} {Oprand2}= )'.format( + Operator=3DOperator, Oprand1=3DOprand1, Oprand2=3D= Oprand2)) else: - Msg =3D 'No enough Operands for {Opcode:02X}.'.format = (Opcode =3D Opcode) - raise ValueError (Msg) + Msg =3D 'No enough Operands for {Opcode:02X}.'.format( + Opcode=3DOpcode) + raise ValueError(Msg) =20 else: - Msg =3D '{Opcode:02X} is not a valid OpCode.'.format (Opco= de =3D Opcode) - raise ValueError (Msg) + Msg =3D '{Opcode:02X} is not a valid OpCode.'.format( + Opcode=3DOpcode) + raise ValueError(Msg) =20 - self.DepexExp =3D OperandStack[0].strip (' ') + self.DepexExp =3D OperandStack[0].strip(' ') self.Payload =3D Buffer[DepexLen:] self._Valid =3D True self._DepexSize =3D DepexLen return self.Payload =20 - - def DumpInfo (self): + def DumpInfo(self): DepexLen =3D 0 Opcode =3D None Buffer =3D self.Depex =20 if self._Valid =3D=3D True: - print ('EFI_FIRMWARE_IMAGE_DEP.Dependencies =3D {') + print('EFI_FIRMWARE_IMAGE_DEP.Dependencies =3D {') while Opcode !=3D 0x0D: - Opcode, Operand, OperandSize =3D self.OpConverter.OpDecode= (Buffer[DepexLen:]) + Opcode, Operand, OperandSize =3D self.OpConverter.OpDecode( + Buffer[DepexLen:]) DepexLen +=3D OperandSize + 1 if Operand: - print (' {Opcode:02X}, {Operand},'.format (Opcode = =3D Opcode, Operand =3D Operand)) + print(' {Opcode:02X}, {Operand},'.format( + Opcode=3DOpcode, Operand=3DOperand)) else: - print (' {Opcode:02X},'.format (Opcode =3D Opcode)) - print ('}') + print(' {Opcode:02X},'.format(Opcode=3DOpcode)) + print('}') =20 - print ('sizeof (EFI_FIRMWARE_IMAGE_DEP.Dependencies) =3D {S= ize:08X}'.format (Size =3D self._DepexSize)) - print ('sizeof (Payload) =3D {S= ize:08X}'.format (Size =3D len (self.Payload))) + print('sizeof (EFI_FIRMWARE_IMAGE_DEP.Dependencies) =3D {Si= ze:08X}'.format( + Size=3Dself._DepexSize)) + print('sizeof (Payload) =3D {Si= ze:08X}'.format( + Size=3Dlen(self.Payload))) diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py b= /BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py index 48c605faa8dd..75539a3e32ad 100644 --- a/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py +++ b/BaseTools/Source/Python/Common/Uefi/Capsule/FmpAuthHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # Module that encodes and decodes a EFI_FIRMWARE_IMAGE_AUTHENTICATION with # certificate data and payload data. # @@ -13,6 +13,7 @@ FmpAuthHeader import struct import uuid =20 + class FmpAuthHeaderClass (object): # /// # /// Image Attribute -Authentication Required @@ -96,58 +97,58 @@ class FmpAuthHeaderClass (object): # } =20 _StructFormat =3D ' len (self._EmbeddedDriverList): + def GetEmbeddedDriver(self, Index): + if Index > len(self._EmbeddedDriverList): raise ValueError return self._EmbeddedDriverList[Index] =20 - def AddPayload (self, UpdateImageTypeId, Payload =3D b'', VendorCodeBy= tes =3D b'', HardwareInstance =3D 0, UpdateImageIndex =3D 1, CapsuleSupport= =3D 0): - self._PayloadList.append ((UpdateImageTypeId, Payload, VendorCodeB= ytes, HardwareInstance, UpdateImageIndex, CapsuleSupport)) + def AddPayload(self, UpdateImageTypeId, Payload=3Db'', VendorCodeBytes= =3Db'', HardwareInstance=3D0, UpdateImageIndex=3D1, CapsuleSupport=3D0): + self._PayloadList.append((UpdateImageTypeId, Payload, VendorCodeBy= tes, + HardwareInstance, UpdateImageIndex, Capsu= leSupport)) =20 - def GetFmpCapsuleImageHeader (self, Index): - if Index >=3D len (self._FmpCapsuleImageHeaderList): + def GetFmpCapsuleImageHeader(self, Index): + if Index >=3D len(self._FmpCapsuleImageHeaderList): raise ValueError return self._FmpCapsuleImageHeaderList[Index] =20 - def Encode (self): - self.EmbeddedDriverCount =3D len (self._EmbeddedDriverList) - self.PayloadItemCount =3D len (self._PayloadList) + def Encode(self): + self.EmbeddedDriverCount =3D len(self._EmbeddedDriverList) + self.PayloadItemCount =3D len(self._PayloadList) =20 - FmpCapsuleHeader =3D struct.pack ( - self._StructFormat, - self.Version, - self.EmbeddedDriverCount, - self.PayloadItemCount - ) + FmpCapsuleHeader =3D struct.pack( + self._StructFormat, + self.Version, + self.EmbeddedDriverCount, + self.PayloadItemCount + ) =20 FmpCapsuleData =3D b'' - Offset =3D self._StructSize + (self.EmbeddedDriverCount + self.Pay= loadItemCount) * self._ItemOffsetSize + Offset =3D self._StructSize + \ + (self.EmbeddedDriverCount + self.PayloadItemCount) * self._Ite= mOffsetSize for EmbeddedDriver in self._EmbeddedDriverList: FmpCapsuleData =3D FmpCapsuleData + EmbeddedDriver - self._ItemOffsetList.append (Offset) - Offset =3D Offset + len (EmbeddedDriver) + self._ItemOffsetList.append(Offset) + Offset =3D Offset + len(EmbeddedDriver) Index =3D 1 for (UpdateImageTypeId, Payload, VendorCodeBytes, HardwareInstance= , UpdateImageIndex, CapsuleSupport) in self._PayloadList: - FmpCapsuleImageHeader =3D FmpCapsuleImageHeaderClass () - FmpCapsuleImageHeader.UpdateImageTypeId =3D UpdateImageTy= peId - FmpCapsuleImageHeader.UpdateImageIndex =3D UpdateImageIn= dex - FmpCapsuleImageHeader.Payload =3D Payload - FmpCapsuleImageHeader.VendorCodeBytes =3D VendorCodeByt= es + FmpCapsuleImageHeader =3D FmpCapsuleImageHeaderClass() + FmpCapsuleImageHeader.UpdateImageTypeId =3D UpdateImageTypeId + FmpCapsuleImageHeader.UpdateImageIndex =3D UpdateImageIndex + FmpCapsuleImageHeader.Payload =3D Payload + FmpCapsuleImageHeader.VendorCodeBytes =3D VendorCodeBytes FmpCapsuleImageHeader.UpdateHardwareInstance =3D HardwareInsta= nce - FmpCapsuleImageHeader.ImageCapsuleSupport =3D CapsuleSupport - FmpCapsuleImage =3D FmpCapsuleImageHeader.Encode () + FmpCapsuleImageHeader.ImageCapsuleSupport =3D CapsuleSupport + FmpCapsuleImage =3D FmpCapsuleImageHeader.Encode() FmpCapsuleData =3D FmpCapsuleData + FmpCapsuleImage =20 - self._ItemOffsetList.append (Offset) - self._FmpCapsuleImageHeaderList.append (FmpCapsuleImageHeader) + self._ItemOffsetList.append(Offset) + self._FmpCapsuleImageHeaderList.append(FmpCapsuleImageHeader) =20 - Offset =3D Offset + len (FmpCapsuleImage) + Offset =3D Offset + len(FmpCapsuleImage) Index =3D Index + 1 =20 for Offset in self._ItemOffsetList: - FmpCapsuleHeader =3D FmpCapsuleHeader + struct.pack (self._ItemO= ffsetFormat, Offset) + FmpCapsuleHeader =3D FmpCapsuleHeader + \ + struct.pack(self._ItemOffsetFormat, Offset) =20 self._Valid =3D True return FmpCapsuleHeader + FmpCapsuleData =20 - def Decode (self, Buffer): - if len (Buffer) < self._StructSize: + def Decode(self, Buffer): + if len(Buffer) < self._StructSize: raise ValueError (Version, EmbeddedDriverCount, PayloadItemCount) =3D \ - struct.unpack ( - self._StructFormat, - Buffer[0:self._StructSize] - ) + struct.unpack( + self._StructFormat, + Buffer[0:self._StructSize] + ) if Version < self.EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERS= ION: raise ValueError =20 - self.Version =3D Version - self.EmbeddedDriverCount =3D EmbeddedDriverCount - self.PayloadItemCount =3D PayloadItemCount - self._ItemOffsetList =3D [] - self._EmbeddedDriverList =3D [] - self._PayloadList =3D [] + self.Version =3D Version + self.EmbeddedDriverCount =3D EmbeddedDriverCount + self.PayloadItemCount =3D PayloadItemCount + self._ItemOffsetList =3D [] + self._EmbeddedDriverList =3D [] + self._PayloadList =3D [] self._FmpCapsuleImageHeaderList =3D [] =20 # # Parse the ItemOffsetList values # Offset =3D self._StructSize - for Index in range (0, EmbeddedDriverCount + PayloadItemCount): - ItemOffset =3D struct.unpack (self._ItemOffsetFormat, Buffer[O= ffset:Offset + self._ItemOffsetSize])[0] - if ItemOffset >=3D len (Buffer): + for Index in range(0, EmbeddedDriverCount + PayloadItemCount): + ItemOffset =3D struct.unpack( + self._ItemOffsetFormat, Buffer[Offset:Offset + self._ItemO= ffsetSize])[0] + if ItemOffset >=3D len(Buffer): raise ValueError - self._ItemOffsetList.append (ItemOffset) + self._ItemOffsetList.append(ItemOffset) Offset =3D Offset + self._ItemOffsetSize Result =3D Buffer[Offset:] =20 # # Parse the EmbeddedDrivers # - for Index in range (0, EmbeddedDriverCount): + for Index in range(0, EmbeddedDriverCount): Offset =3D self._ItemOffsetList[Index] - if Index < (len (self._ItemOffsetList) - 1): + if Index < (len(self._ItemOffsetList) - 1): Length =3D self._ItemOffsetList[Index + 1] - Offset else: - Length =3D len (Buffer) - Offset - self.AddEmbeddedDriver (Buffer[Offset:Offset + Length]) + Length =3D len(Buffer) - Offset + self.AddEmbeddedDriver(Buffer[Offset:Offset + Length]) =20 # # Parse the Payloads that are FMP Capsule Images # - for Index in range (EmbeddedDriverCount, EmbeddedDriverCount + Pay= loadItemCount): + for Index in range(EmbeddedDriverCount, EmbeddedDriverCount + Payl= oadItemCount): Offset =3D self._ItemOffsetList[Index] - if Index < (len (self._ItemOffsetList) - 1): + if Index < (len(self._ItemOffsetList) - 1): Length =3D self._ItemOffsetList[Index + 1] - Offset else: - Length =3D len (Buffer) - Offset - FmpCapsuleImageHeader =3D FmpCapsuleImageHeaderClass () - FmpCapsuleImageHeader.Decode (Buffer[Offset:Offset + Length]) - self.AddPayload ( - FmpCapsuleImageHeader.UpdateImageTypeId, - FmpCapsuleImageHeader.Payload, - FmpCapsuleImageHeader.VendorCodeBytes - ) - self._FmpCapsuleImageHeaderList.append (FmpCapsuleImageHeader) + Length =3D len(Buffer) - Offset + FmpCapsuleImageHeader =3D FmpCapsuleImageHeaderClass() + FmpCapsuleImageHeader.Decode(Buffer[Offset:Offset + Length]) + self.AddPayload( + FmpCapsuleImageHeader.UpdateImageTypeId, + FmpCapsuleImageHeader.Payload, + FmpCapsuleImageHeader.VendorCodeBytes + ) + self._FmpCapsuleImageHeaderList.append(FmpCapsuleImageHeader) =20 self._Valid =3D True return Result =20 - def DumpInfo (self): + def DumpInfo(self): if not self._Valid: raise ValueError - print ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.Version = =3D {Version:08X}'.format (Version =3D self.Version)) - print ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.EmbeddedDriverCount= =3D {EmbeddedDriverCount:08X}'.format (EmbeddedDriverCount =3D self.Embedd= edDriverCount)) + print('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.Version = =3D {Version:08X}'.format( + Version=3Dself.Version)) + print('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.EmbeddedDriverCount = =3D {EmbeddedDriverCount:08X}'.format( + EmbeddedDriverCount=3Dself.EmbeddedDriverCount)) for EmbeddedDriver in self._EmbeddedDriverList: - print (' sizeof (EmbeddedDriver) = =3D {Size:08X}'.format (Size =3D len (EmbeddedDriver))) - print ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.PayloadItemCount = =3D {PayloadItemCount:08X}'.format (PayloadItemCount =3D self.PayloadItemC= ount)) - print ('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.ItemOffsetList = =3D ') + print(' sizeof (EmbeddedDriver) = =3D {Size:08X}'.format( + Size=3Dlen(EmbeddedDriver))) + print('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.PayloadItemCount = =3D {PayloadItemCount:08X}'.format( + PayloadItemCount=3Dself.PayloadItemCount)) + print('EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER.ItemOffsetList = =3D ') for Offset in self._ItemOffsetList: - print (' {Offset:016X}'.format (Offset =3D Offset)) + print(' {Offset:016X}'.format(Offset=3DOffset)) for FmpCapsuleImageHeader in self._FmpCapsuleImageHeaderList: - FmpCapsuleImageHeader.DumpInfo () + FmpCapsuleImageHeader.DumpInfo() diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/UefiCapsuleHeader.= py b/BaseTools/Source/Python/Common/Uefi/Capsule/UefiCapsuleHeader.py index 0e59028697ed..0ed4cbf5f73a 100644 --- a/BaseTools/Source/Python/Common/Uefi/Capsule/UefiCapsuleHeader.py +++ b/BaseTools/Source/Python/Common/Uefi/Capsule/UefiCapsuleHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # Module that encodes and decodes a EFI_CAPSULE_HEADER with a payload # # Copyright (c) 2018, Intel Corporation. All rights reserved.
        @@ -12,6 +12,7 @@ UefiCapsuleHeader import struct import uuid =20 + class UefiCapsuleHeaderClass (object): # typedef struct { # /// @@ -41,26 +42,27 @@ class UefiCapsuleHeaderClass (object): # #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 # _StructFormat =3D '<16sIIII' - _StructSize =3D struct.calcsize (_StructFormat) + _StructSize =3D struct.calcsize(_StructFormat) =20 - EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID =3D uuid.UUID ('6DCBD5ED-E82D-= 4C44-BDA1-7194199AD92A') + EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID =3D uuid.UUID( + '6DCBD5ED-E82D-4C44-BDA1-7194199AD92A') =20 - _CAPSULE_FLAGS_PERSIST_ACROSS_RESET =3D 0x00010000 + _CAPSULE_FLAGS_PERSIST_ACROSS_RESET =3D 0x00010000 _CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE =3D 0x00020000 - _CAPSULE_FLAGS_INITIATE_RESET =3D 0x00040000 + _CAPSULE_FLAGS_INITIATE_RESET =3D 0x00040000 =20 - def __init__ (self): - self._Valid =3D False - self.CapsuleGuid =3D self.EFI_FIRMWARE_MANAGEMENT_CAPSULE_= ID_GUID - self.HeaderSize =3D self._StructSize - self.OemFlags =3D 0x0000 - self.PersistAcrossReset =3D False + def __init__(self): + self._Valid =3D False + self.CapsuleGuid =3D self.EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID + self.HeaderSize =3D self._StructSize + self.OemFlags =3D 0x0000 + self.PersistAcrossReset =3D False self.PopulateSystemTable =3D False - self.InitiateReset =3D False - self.CapsuleImageSize =3D self.HeaderSize - self.Payload =3D b'' + self.InitiateReset =3D False + self.CapsuleImageSize =3D self.HeaderSize + self.Payload =3D b'' =20 - def Encode (self): + def Encode(self): Flags =3D self.OemFlags if self.PersistAcrossReset: Flags =3D Flags | self._CAPSULE_FLAGS_PERSIST_ACROSS_RESET @@ -69,44 +71,46 @@ class UefiCapsuleHeaderClass (object): if self.InitiateReset: Flags =3D Flags | self._CAPSULE_FLAGS_INITIATE_RESET =20 - self.CapsuleImageSize =3D self.HeaderSize + len (self.Payload) + self.CapsuleImageSize =3D self.HeaderSize + len(self.Payload) =20 - UefiCapsuleHeader =3D struct.pack ( - self._StructFormat, - self.CapsuleGuid.bytes_le, - self.HeaderSize, - Flags, - self.CapsuleImageSize, - 0 - ) + UefiCapsuleHeader =3D struct.pack( + self._StructFormat, + self.CapsuleGuid.bytes_le, + self.HeaderSize, + Flags, + self.CapsuleImageSize, + 0 + ) self._Valid =3D True return UefiCapsuleHeader + self.Payload =20 - def Decode (self, Buffer): - if len (Buffer) < self._StructSize: + def Decode(self, Buffer): + if len(Buffer) < self._StructSize: raise ValueError (CapsuleGuid, HeaderSize, Flags, CapsuleImageSize, Reserved) =3D \ - struct.unpack ( - self._StructFormat, - Buffer[0:self._StructSize] - ) + struct.unpack( + self._StructFormat, + Buffer[0:self._StructSize] + ) if HeaderSize < self._StructSize: raise ValueError - if CapsuleImageSize !=3D len (Buffer): + if CapsuleImageSize !=3D len(Buffer): raise ValueError - self.CapsuleGuid =3D uuid.UUID (bytes_le =3D CapsuleGuid) - self.HeaderSize =3D HeaderSize - self.OemFlags =3D Flags & 0xffff - self.PersistAcrossReset =3D (Flags & self._CAPSULE_FLAGS_PERSIST_= ACROSS_RESET) !=3D 0 - self.PopulateSystemTable =3D (Flags & self._CAPSULE_FLAGS_POPULATE= _SYSTEM_TABLE) !=3D 0 - self.InitiateReset =3D (Flags & self._CAPSULE_FLAGS_INITIATE= _RESET) !=3D 0 - self.CapsuleImageSize =3D CapsuleImageSize - self.Payload =3D Buffer[self.HeaderSize:] + self.CapsuleGuid =3D uuid.UUID(bytes_le=3DCapsuleGuid) + self.HeaderSize =3D HeaderSize + self.OemFlags =3D Flags & 0xffff + self.PersistAcrossReset =3D ( + Flags & self._CAPSULE_FLAGS_PERSIST_ACROSS_RESET) !=3D 0 + self.PopulateSystemTable =3D ( + Flags & self._CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) !=3D 0 + self.InitiateReset =3D (Flags & self._CAPSULE_FLAGS_INITIATE_RESET= ) !=3D 0 + self.CapsuleImageSize =3D CapsuleImageSize + self.Payload =3D Buffer[self.HeaderSize:] =20 - self._Valid =3D True + self._Valid =3D True return self.Payload =20 - def DumpInfo (self): + def DumpInfo(self): if not self._Valid: raise ValueError Flags =3D self.OemFlags @@ -116,15 +120,21 @@ class UefiCapsuleHeaderClass (object): Flags =3D Flags | self._CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE if self.InitiateReset: Flags =3D Flags | self._CAPSULE_FLAGS_INITIATE_RESET - print ('EFI_CAPSULE_HEADER.CapsuleGuid =3D {Guid}'.format (Gu= id =3D str(self.CapsuleGuid).upper())) - print ('EFI_CAPSULE_HEADER.HeaderSize =3D {Size:08X}'.format= (Size =3D self.HeaderSize)) - print ('EFI_CAPSULE_HEADER.Flags =3D {Flags:08X}'.forma= t (Flags =3D Flags)) - print (' OEM Flags =3D {Flags:04X}'.forma= t (Flags =3D self.OemFlags)) + print('EFI_CAPSULE_HEADER.CapsuleGuid =3D {Guid}'.format( + Guid=3Dstr(self.CapsuleGuid).upper())) + print('EFI_CAPSULE_HEADER.HeaderSize =3D {Size:08X}'.format( + Size=3Dself.HeaderSize)) + print('EFI_CAPSULE_HEADER.Flags =3D {Flags:08X}'.format( + Flags=3DFlags)) + print(' OEM Flags =3D {Flags:04X}'.format( + Flags=3Dself.OemFlags)) if self.PersistAcrossReset: - print (' CAPSULE_FLAGS_PERSIST_ACROSS_RESET') + print(' CAPSULE_FLAGS_PERSIST_ACROSS_RESET') if self.PopulateSystemTable: - print (' CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE') + print(' CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE') if self.InitiateReset: - print (' CAPSULE_FLAGS_INITIATE_RESET') - print ('EFI_CAPSULE_HEADER.CapsuleImageSize =3D {Size:08X}'.format= (Size =3D self.CapsuleImageSize)) - print ('sizeof (Payload) =3D {Size:08X}'.format= (Size =3D len (self.Payload))) + print(' CAPSULE_FLAGS_INITIATE_RESET') + print('EFI_CAPSULE_HEADER.CapsuleImageSize =3D {Size:08X}'.format( + Size=3Dself.CapsuleImageSize)) + print('sizeof (Payload) =3D {Size:08X}'.format( + Size=3Dlen(self.Payload))) diff --git a/BaseTools/Source/Python/Common/Uefi/Capsule/__init__.py b/Base= Tools/Source/Python/Common/Uefi/Capsule/__init__.py index 329adcd51216..0420c953aa1f 100644 --- a/BaseTools/Source/Python/Common/Uefi/Capsule/__init__.py +++ b/BaseTools/Source/Python/Common/Uefi/Capsule/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Common.Uefi.Capsule' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Common/Uefi/__init__.py b/BaseTools/So= urce/Python/Common/Uefi/__init__.py index 213883d04833..1a49d89e5970 100644 --- a/BaseTools/Source/Python/Common/Uefi/__init__.py +++ b/BaseTools/Source/Python/Common/Uefi/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Common.Uefi' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Common/VariableAttributes.py b/BaseToo= ls/Source/Python/Common/VariableAttributes.py index 90c43f87d171..4477e747cc9e 100644 --- a/BaseTools/Source/Python/Common/VariableAttributes.py +++ b/BaseTools/Source/Python/Common/VariableAttributes.py @@ -13,11 +13,11 @@ class VariableAttributes(object): EFI_VARIABLE_RUNTIME_ACCESS =3D 0x00000004 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY =3D 0x00000001 VarAttributesMap =3D { - "NV":EFI_VARIABLE_NON_VOLATILE, - "BS":EFI_VARIABLE_BOOTSERVICE_ACCESS, - "RT":EFI_VARIABLE_RUNTIME_ACCESS, - "RO":VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY - } + "NV": EFI_VARIABLE_NON_VOLATILE, + "BS": EFI_VARIABLE_BOOTSERVICE_ACCESS, + "RT": EFI_VARIABLE_RUNTIME_ACCESS, + "RO": VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY + } =20 def __init__(self): pass @@ -33,8 +33,10 @@ class VariableAttributes(object): if attr =3D=3D 'RO': VarProp =3D VariableAttributes.VAR_CHECK_VARIABLE_PROPERTY= _READ_ONLY else: - VarAttr =3D VarAttr | VariableAttributes.VarAttributesMap.= get(attr, 0x00000000) + VarAttr =3D VarAttr | VariableAttributes.VarAttributesMap.= get( + attr, 0x00000000) return VarAttr, VarProp + @staticmethod def ValidateVarAttributes(var_attr_str): if not var_attr_str: diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/Python/Common/VpdInfoFile.py index 4249b9f899e7..5886cb772e42 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -1,4 +1,4 @@ -## @file +# @file # # This package manage the VPD PCD information file which will be generated # by build tool's autogen. @@ -21,7 +21,7 @@ from Common.Misc import SaveFileOnChange from Common.DataType import * =20 FILE_COMMENT_TEMPLATE =3D \ -""" + """ ## @file # # THIS IS AUTO-GENERATED FILE BY BUILD TOOLS AND PLEASE DO NOT MAKE MODIF= ICATION. @@ -40,7 +40,7 @@ FILE_COMMENT_TEMPLATE =3D \ =20 """ =20 -## The class manage VpdInfoFile. +# The class manage VpdInfoFile. # # This file contains an ordered (based on position in the DSC file) list = of the PCDs specified in the platform description file (DSC). The Value fie= ld that will be assigned to the PCD comes from the DSC file, INF file (if n= ot defined in the DSC file) or the DEC file (if not defined in the INF file= ). This file is used as an input to the BPDG tool. # Format for this file (using EBNF notation) is: @@ -62,12 +62,15 @@ FILE_COMMENT_TEMPLATE =3D \ # ::=3D "{" ["," ]* "}" # ::=3D ["," ]* # + + class VpdInfoFile: =20 _rVpdPcdLine =3D None - ## Constructor + # Constructor + def __init__(self): - ## Dictionary for VPD in following format + # Dictionary for VPD in following format # # Key : PcdClassObject instance. # @see BuildClassObject.PcdClassObject @@ -75,7 +78,7 @@ class VpdInfoFile: self._VpdArray =3D {} self._VpdInfo =3D {} =20 - ## Add a VPD PCD collected from platform's autogen when building. + # Add a VPD PCD collected from platform's autogen when building. # # @param vpds The list of VPD PCD collected for a platform. # @see BuildClassObject.PcdClassObject @@ -84,10 +87,12 @@ class VpdInfoFile: # def Add(self, Vpd, skuname, Offset): if (Vpd is None): - EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOW= N_ERROR, "Invalid VPD PCD entry.") + EdkLogger.error( + "VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "In= valid VPD PCD entry.") =20 if not (Offset >=3D "0" or Offset =3D=3D TAB_STAR): - EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALI= D, "Invalid offset parameter: %s." % Offset) + EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALI= D, + "Invalid offset parameter: %s." % Offset) =20 if Vpd.DatumType =3D=3D TAB_VOID: if Vpd.MaxDatumSize <=3D "0": @@ -107,14 +112,14 @@ class VpdInfoFile: # self._VpdArray[Vpd] =3D {} =20 - self._VpdArray[Vpd].update({skuname:Offset}) + self._VpdArray[Vpd].update({skuname: Offset}) =20 - - ## Generate VPD PCD information into a text file + # Generate VPD PCD information into a text file # # If parameter FilePath is invalid, then assert. # If # @param FilePath The given file path which would hold VPD inf= ormation + def Write(self, FilePath): if not (FilePath is not None or len(FilePath) !=3D 0): EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALI= D, @@ -130,15 +135,16 @@ class VpdInfoFile: PcdTokenCName =3D PcdItem[0] for skuname in self._VpdArray[Pcd]: PcdValue =3D str(Pcd.SkuInfoList[skuname].DefaultValue).st= rip() - if PcdValue =3D=3D "" : - PcdValue =3D Pcd.DefaultValue + if PcdValue =3D=3D "": + PcdValue =3D Pcd.DefaultValue =20 - Content +=3D "%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuid= CName, PcdTokenCName, skuname, str(self._VpdArray[Pcd][skuname]).strip(), s= tr(Pcd.MaxDatumSize).strip(), PcdValue) + Content +=3D "%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuid= CName, PcdTokenCName, skuname, str( + self._VpdArray[Pcd][skuname]).strip(), str(Pcd.MaxDatu= mSize).strip(), PcdValue) i +=3D 1 =20 return SaveFileOnChange(FilePath, Content, False) =20 - ## Read an existing VPD PCD info file. + # Read an existing VPD PCD info file. # # This routine will read VPD PCD information from existing file and c= onstruct # internal PcdClassObject array. @@ -162,17 +168,21 @@ class VpdInfoFile: # the line must follow output format defined in BPDG spec. # try: - PcdName, SkuId, Offset, Size, Value =3D Line.split("#")[0]= .split("|") - PcdName, SkuId, Offset, Size, Value =3D PcdName.strip(), S= kuId.strip(), Offset.strip(), Size.strip(), Value.strip() + PcdName, SkuId, Offset, Size, Value =3D Line.split("#")[ + 0].split("|") + PcdName, SkuId, Offset, Size, Value =3D PcdName.strip( + ), SkuId.strip(), Offset.strip(), Size.strip(), Value.stri= p() TokenSpaceName, PcdTokenName =3D PcdName.split(".") except: - EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail= to parse VPD information file %s" % FilePath) + EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, + "Fail to parse VPD information file %s" % = FilePath) =20 Found =3D False =20 if (TokenSpaceName, PcdTokenName) not in self._VpdInfo: self._VpdInfo[(TokenSpaceName, PcdTokenName)] =3D {} - self._VpdInfo[(TokenSpaceName, PcdTokenName)][(SkuId, Offset)]= =3D Value + self._VpdInfo[(TokenSpaceName, PcdTokenName) + ][(SkuId, Offset)] =3D Value for VpdObject in self._VpdArray: VpdObjectTokenCName =3D VpdObject.TokenCName for PcdItem in GlobalData.MixedPcd: @@ -182,13 +192,15 @@ class VpdInfoFile: if VpdObject.TokenSpaceGuidCName =3D=3D TokenSpaceName= and VpdObjectTokenCName =3D=3D PcdTokenName.strip() and sku =3D=3D SkuId: if self._VpdArray[VpdObject][sku] =3D=3D TAB_STAR: if Offset =3D=3D TAB_STAR: - EdkLogger.error("BPDG", BuildToolError.FOR= MAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG to= ol." % PcdName) + EdkLogger.error("BPDG", BuildToolError.FOR= MAT_INVALID, + "The offset of %s has not = been fixed up by third-party BPDG tool." % PcdName) self._VpdArray[VpdObject][sku] =3D Offset Found =3D True if not Found: - EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can = not find PCD defined in VPD guid file.") + EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, + "Can not find PCD defined in VPD guid file= .") =20 - ## Get count of VPD PCD collected from platform's autogen when buildin= g. + # Get count of VPD PCD collected from platform's autogen when building. # # @return The integer count value def GetCount(self): @@ -198,7 +210,7 @@ class VpdInfoFile: =20 return Count =20 - ## Get an offset value for a given VPD PCD + # Get an offset value for a given VPD PCD # # Because BPDG only support one Sku, so only return offset for SKU de= fault. # @@ -211,18 +223,22 @@ class VpdInfoFile: return None =20 return self._VpdArray[vpd] + def GetVpdInfo(self, arg): (PcdTokenName, TokenSpaceName) =3D arg - return [(sku,offset,value) for (sku,offset),value in self._VpdInfo= .get((TokenSpaceName, PcdTokenName)).items()] + return [(sku, offset, value) for (sku, offset), value in self._Vpd= Info.get((TokenSpaceName, PcdTokenName)).items()] =20 -## Call external BPDG tool to process VPD file +# Call external BPDG tool to process VPD file # # @param ToolPath The string path name for BPDG tool # @param VpdFileName The string path name for VPD information guid.txt # + + def CallExtenalBPDGTool(ToolPath, VpdFileName): assert ToolPath is not None, "Invalid parameter ToolPath" - assert VpdFileName is not None and os.path.exists(VpdFileName), "Inval= id parameter VpdFileName" + assert VpdFileName is not None and os.path.exists( + VpdFileName), "Invalid parameter VpdFileName" =20 OutputDir =3D os.path.dirname(VpdFileName) FileName =3D os.path.basename(VpdFileName) @@ -232,24 +248,26 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName): =20 try: PopenObject =3D subprocess.Popen(' '.join([ToolPath, - '-o', OutputBinFileName, - '-m', OutputMapFileName, - '-q', - '-f', - VpdFileName]), - stdout=3Dsubprocess.PIPE, - stderr=3D subprocess.PIPE, - shell=3DTrue) + '-o', OutputBinFileName, + '-m', OutputMapFileName, + '-q', + '-f', + VpdFileName]), + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.PIPE, + shell=3DTrue) except Exception as X: - EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData= =3Dstr(X)) + EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, + ExtraData=3Dstr(X)) (out, error) =3D PopenObject.communicate() print(out.decode()) - while PopenObject.returncode is None : + while PopenObject.returncode is None: PopenObject.wait() =20 if PopenObject.returncode !=3D 0: - EdkLogger.debug(EdkLogger.DEBUG_1, "Fail to call BPDG tool", str(e= rror)) - EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to e= xecute BPDG tool with exit code: %d, the error message is: \n %s" % \ - (PopenObject.returncode, str(error))) + EdkLogger.debug(EdkLogger.DEBUG_1, + "Fail to call BPDG tool", str(error)) + EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, "Fail to e= xecute BPDG tool with exit code: %d, the error message is: \n %s" % + (PopenObject.returncode, str(error))) =20 return PopenObject.returncode diff --git a/BaseTools/Source/Python/Common/__init__.py b/BaseTools/Source/= Python/Common/__init__.py index 7aaef6ae318c..b53b69b3d15d 100644 --- a/BaseTools/Source/Python/Common/__init__.py +++ b/BaseTools/Source/Python/Common/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Common' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Common/caching.py b/BaseTools/Source/P= ython/Common/caching.py index fda30f7321ef..1c2375026433 100644 --- a/BaseTools/Source/Python/Common/caching.py +++ b/BaseTools/Source/Python/Common/caching.py @@ -1,4 +1,4 @@ -## @file +# @file # help with caching in BaseTools # # Copyright (c) 2018, Intel Corporation. All rights reserved.
        @@ -6,36 +6,45 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # =20 # for class function class cached_class_function(object): def __init__(self, function): self._function =3D function + def __get__(self, obj, cls): - def CallMeHere(*args,**kwargs): - Value =3D self._function(obj, *args,**kwargs) - obj.__dict__[self._function.__name__] =3D lambda *args,**kwarg= s:Value + def CallMeHere(*args, **kwargs): + Value =3D self._function(obj, *args, **kwargs) + obj.__dict__[ + self._function.__name__] =3D lambda *args, **kwargs: Value return Value return CallMeHere =20 # for class property + + class cached_property(object): def __init__(self, function): self._function =3D function + def __get__(self, obj, cls): Value =3D obj.__dict__[self._function.__name__] =3D self._function= (obj) return Value =20 # for non-class function + + class cached_basic_function(object): def __init__(self, function): self._function =3D function # wrapper to call _do since .__dict__ doesn't support changing = __call__ - def __call__(self,*args,**kwargs): - return self._do(*args,**kwargs) - def _do(self,*args,**kwargs): - Value =3D self._function(*args,**kwargs) - self.__dict__['_do'] =3D lambda self,*args,**kwargs:Value + + def __call__(self, *args, **kwargs): + return self._do(*args, **kwargs) + + def _do(self, *args, **kwargs): + Value =3D self._function(*args, **kwargs) + self.__dict__['_do'] =3D lambda self, *args, **kwargs: Value return Value diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseT= ools/Source/Python/CommonDataClass/CommonClass.py index bcf52c7b75dd..920703b783a5 100644 --- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py +++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py @@ -1,11 +1,11 @@ -## @file +# @file # This file is used to define common items of class object # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent =20 =20 -## SkuInfoClass +# SkuInfoClass # # This class defined SkuInfo item used in Module/Platform/Package files # @@ -29,8 +29,8 @@ # @var DefaultValue: To store value for DefaultValue # class SkuInfoClass(object): - def __init__(self, SkuIdName =3D '', SkuId =3D '', VariableName =3D ''= , VariableGuid =3D '', VariableOffset =3D '', - HiiDefaultValue =3D '', VpdOffset =3D '', DefaultValue = =3D '', VariableGuidValue =3D '', VariableAttribute =3D '', DefaultStore = =3D None): + def __init__(self, SkuIdName=3D'', SkuId=3D'', VariableName=3D'', Vari= ableGuid=3D'', VariableOffset=3D'', + HiiDefaultValue=3D'', VpdOffset=3D'', DefaultValue=3D'', = VariableGuidValue=3D'', VariableAttribute=3D'', DefaultStore=3DNone): self.SkuIdName =3D SkuIdName self.SkuId =3D SkuId =20 @@ -57,7 +57,7 @@ class SkuInfoClass(object): # self.DefaultValue =3D DefaultValue =20 - ## Convert the class to a string + # Convert the class to a string # # Convert each member of the class to string # Organize to a single line format string @@ -66,16 +66,16 @@ class SkuInfoClass(object): # def __str__(self): Rtn =3D 'SkuId =3D ' + str(self.SkuId) + "," + \ - 'SkuIdName =3D ' + str(self.SkuIdName) + "," + \ - 'VariableName =3D ' + str(self.VariableName) + "," + \ - 'VariableGuid =3D ' + str(self.VariableGuid) + "," + \ - 'VariableOffset =3D ' + str(self.VariableOffset) + ","= + \ - 'HiiDefaultValue =3D ' + str(self.HiiDefaultValue) + "= ," + \ - 'VpdOffset =3D ' + str(self.VpdOffset) + "," + \ - 'DefaultValue =3D ' + str(self.DefaultValue) + "," + 'SkuIdName =3D ' + str(self.SkuIdName) + "," + \ + 'VariableName =3D ' + str(self.VariableName) + "," + \ + 'VariableGuid =3D ' + str(self.VariableGuid) + "," + \ + 'VariableOffset =3D ' + str(self.VariableOffset) + "," + \ + 'HiiDefaultValue =3D ' + str(self.HiiDefaultValue) + "," + \ + 'VpdOffset =3D ' + str(self.VpdOffset) + "," + \ + 'DefaultValue =3D ' + str(self.DefaultValue) + "," return Rtn =20 - def __deepcopy__(self,memo): + def __deepcopy__(self, memo): new_sku =3D SkuInfoClass() new_sku.SkuIdName =3D self.SkuIdName new_sku.SkuId =3D self.SkuId @@ -85,7 +85,8 @@ class SkuInfoClass(object): new_sku.VariableOffset =3D self.VariableOffset new_sku.HiiDefaultValue =3D self.HiiDefaultValue new_sku.VariableAttribute =3D self.VariableAttribute - new_sku.DefaultStoreDict =3D {key:value for key,value in self.Defa= ultStoreDict.items()} + new_sku.DefaultStoreDict =3D { + key: value for key, value in self.DefaultStoreDict.items()} new_sku.VpdOffset =3D self.VpdOffset new_sku.DefaultValue =3D self.DefaultValue return new_sku diff --git a/BaseTools/Source/Python/CommonDataClass/DataClass.py b/BaseToo= ls/Source/Python/CommonDataClass/DataClass.py index 6f35bd4c8e8f..54b42f2806be 100644 --- a/BaseTools/Source/Python/CommonDataClass/DataClass.py +++ b/BaseTools/Source/Python/CommonDataClass/DataClass.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class for data structure used in ECC # # Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
        @@ -73,14 +73,14 @@ MODEL_PCD_DYNAMIC_DEFAULT =3D 4009 MODEL_PCD_DYNAMIC_VPD =3D 4010 MODEL_PCD_DYNAMIC_HII =3D 4011 MODEL_PCD_TYPE_LIST =3D [MODEL_PCD_FIXED_AT_BUILD, - MODEL_PCD_PATCHABLE_IN_MODULE, - MODEL_PCD_FEATURE_FLAG, - MODEL_PCD_DYNAMIC_DEFAULT, - MODEL_PCD_DYNAMIC_HII, - MODEL_PCD_DYNAMIC_VPD, - MODEL_PCD_DYNAMIC_EX_DEFAULT, - MODEL_PCD_DYNAMIC_EX_HII, - MODEL_PCD_DYNAMIC_EX_VPD + MODEL_PCD_PATCHABLE_IN_MODULE, + MODEL_PCD_FEATURE_FLAG, + MODEL_PCD_DYNAMIC_DEFAULT, + MODEL_PCD_DYNAMIC_HII, + MODEL_PCD_DYNAMIC_VPD, + MODEL_PCD_DYNAMIC_EX_DEFAULT, + MODEL_PCD_DYNAMIC_EX_HII, + MODEL_PCD_DYNAMIC_EX_VPD ] =20 MODEL_META_DATA_HEADER_COMMENT =3D 5000 @@ -119,13 +119,15 @@ MODEL_LIST =3D [('MODEL_UNKNOWN', MODEL_UNKNOWN), ('MODEL_FILE_CIF', MODEL_FILE_CIF), ('MODEL_FILE_OTHERS', MODEL_FILE_OTHERS), ('MODEL_IDENTIFIER_FILE_HEADER', MODEL_IDENTIFIER_FILE_HEADE= R), - ('MODEL_IDENTIFIER_FUNCTION_HEADER', MODEL_IDENTIFIER_FUNCTI= ON_HEADER), + ('MODEL_IDENTIFIER_FUNCTION_HEADER', + MODEL_IDENTIFIER_FUNCTION_HEADER), ('MODEL_IDENTIFIER_COMMENT', MODEL_IDENTIFIER_COMMENT), ('MODEL_IDENTIFIER_PARAMETER', MODEL_IDENTIFIER_PARAMETER), ('MODEL_IDENTIFIER_STRUCTURE', MODEL_IDENTIFIER_STRUCTURE), ('MODEL_IDENTIFIER_VARIABLE', MODEL_IDENTIFIER_VARIABLE), ('MODEL_IDENTIFIER_INCLUDE', MODEL_IDENTIFIER_INCLUDE), - ('MODEL_IDENTIFIER_PREDICATE_EXPRESSION', MODEL_IDENTIFIER_P= REDICATE_EXPRESSION), + ('MODEL_IDENTIFIER_PREDICATE_EXPRESSION', + MODEL_IDENTIFIER_PREDICATE_EXPRESSION), ('MODEL_IDENTIFIER_ENUMERATE', MODEL_IDENTIFIER_ENUMERATE), ('MODEL_IDENTIFIER_PCD', MODEL_IDENTIFIER_PCD), ('MODEL_IDENTIFIER_UNION', MODEL_IDENTIFIER_UNION), @@ -134,10 +136,13 @@ MODEL_LIST =3D [('MODEL_UNKNOWN', MODEL_UNKNOWN), ('MODEL_IDENTIFIER_MACRO_DEFINE', MODEL_IDENTIFIER_MACRO_DEF= INE), ('MODEL_IDENTIFIER_MACRO_ENDIF', MODEL_IDENTIFIER_MACRO_ENDI= F), ('MODEL_IDENTIFIER_MACRO_PROGMA', MODEL_IDENTIFIER_MACRO_PRO= GMA), - ('MODEL_IDENTIFIER_FUNCTION_CALLING', MODEL_IDENTIFIER_FUNCT= ION_CALLING), + ('MODEL_IDENTIFIER_FUNCTION_CALLING', + MODEL_IDENTIFIER_FUNCTION_CALLING), ('MODEL_IDENTIFIER_TYPEDEF', MODEL_IDENTIFIER_TYPEDEF), - ('MODEL_IDENTIFIER_FUNCTION_DECLARATION', MODEL_IDENTIFIER_F= UNCTION_DECLARATION), - ('MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION', MODEL_IDENTIFIER_= ASSIGNMENT_EXPRESSION), + ('MODEL_IDENTIFIER_FUNCTION_DECLARATION', + MODEL_IDENTIFIER_FUNCTION_DECLARATION), + ('MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION', + MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION), ('MODEL_EFI_PROTOCOL', MODEL_EFI_PROTOCOL), ('MODEL_EFI_PPI', MODEL_EFI_PPI), ('MODEL_EFI_GUID', MODEL_EFI_GUID), @@ -165,20 +170,25 @@ MODEL_LIST =3D [('MODEL_UNKNOWN', MODEL_UNKNOWN), ("MODEL_META_DATA_HEADER", MODEL_META_DATA_HEADER), ("MODEL_META_DATA_INCLUDE", MODEL_META_DATA_INCLUDE), ("MODEL_META_DATA_DEFINE", MODEL_META_DATA_DEFINE), - ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IF", MODEL_META_DATA= _CONDITIONAL_STATEMENT_IF), - ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", MODEL_META_DA= TA_CONDITIONAL_STATEMENT_ELSE), - ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", MODEL_META_D= ATA_CONDITIONAL_STATEMENT_IFDEF), - ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", MODEL_META_= DATA_CONDITIONAL_STATEMENT_IFNDEF), - ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR", MODEL_META_D= ATA_CONDITIONAL_STATEMENT_ERROR), + ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IF", + MODEL_META_DATA_CONDITIONAL_STATEMENT_IF), + ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", + MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE), + ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF), + ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF), + ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR", + MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR), ("MODEL_META_DATA_BUILD_OPTION", MODEL_META_DATA_BUILD_OPTIO= N), ("MODEL_META_DATA_COMPONENT", MODEL_META_DATA_COMPONENT), ('MODEL_META_DATA_USER_EXTENSION', MODEL_META_DATA_USER_EXTE= NSION), ('MODEL_META_DATA_PACKAGE', MODEL_META_DATA_PACKAGE), ('MODEL_META_DATA_NMAKE', MODEL_META_DATA_NMAKE), ('MODEL_META_DATA_COMMENT', MODEL_META_DATA_COMMENT) - ] + ] =20 -## FunctionClass +# FunctionClass # # This class defines a structure of a function # @@ -212,12 +222,14 @@ MODEL_LIST =3D [('MODEL_UNKNOWN', MODEL_UNKNOWN), # @var IdentifierList: IdentifierList of a File # @var PcdList: PcdList of a File # + + class FunctionClass(object): - def __init__(self, ID =3D -1, Header =3D '', Modifier =3D '', Name =3D= '', ReturnStatement =3D '', \ - StartLine =3D -1, StartColumn =3D -1, EndLine =3D -1, End= Column =3D -1, \ - BodyStartLine =3D -1, BodyStartColumn =3D -1, BelongsToFi= le =3D -1, \ - IdentifierList =3D [], PcdList =3D [], \ - FunNameStartLine =3D -1, FunNameStartColumn =3D -1): + def __init__(self, ID=3D-1, Header=3D'', Modifier=3D'', Name=3D'', Ret= urnStatement=3D'', + StartLine=3D-1, StartColumn=3D-1, EndLine=3D-1, EndColumn= =3D-1, + BodyStartLine=3D-1, BodyStartColumn=3D-1, BelongsToFile= =3D-1, + IdentifierList=3D[], PcdList=3D[], + FunNameStartLine=3D-1, FunNameStartColumn=3D-1): self.ID =3D ID self.Header =3D Header self.Modifier =3D Modifier @@ -236,7 +248,7 @@ class FunctionClass(object): self.IdentifierList =3D IdentifierList self.PcdList =3D PcdList =20 -## IdentifierClass +# IdentifierClass # # This class defines a structure of a variable # @@ -266,9 +278,11 @@ class FunctionClass(object): # @var EndLine: EndLine of a Identifier # @var EndColumn: EndColumn of a Identifier # + + class IdentifierClass(object): - def __init__(self, ID =3D -1, Modifier =3D '', Type =3D '', Name =3D '= ', Value =3D '', Model =3D MODEL_UNKNOWN, \ - BelongsToFile =3D -1, BelongsToFunction =3D -1, StartLine= =3D -1, StartColumn =3D -1, EndLine =3D -1, EndColumn =3D -1): + def __init__(self, ID=3D-1, Modifier=3D'', Type=3D'', Name=3D'', Value= =3D'', Model=3DMODEL_UNKNOWN, + BelongsToFile=3D-1, BelongsToFunction=3D-1, StartLine=3D-= 1, StartColumn=3D-1, EndLine=3D-1, EndColumn=3D-1): self.ID =3D ID self.Modifier =3D Modifier self.Type =3D Type @@ -282,7 +296,7 @@ class IdentifierClass(object): self.EndLine =3D EndLine self.EndColumn =3D EndColumn =20 -## PcdClass +# PcdClass # # This class defines a structure of a Pcd # @@ -312,9 +326,11 @@ class IdentifierClass(object): # @var EndLine: EndLine of a Pcd # @var EndColumn: EndColumn of a Pcd # + + class PcdDataClass(object): - def __init__(self, ID =3D -1, CName =3D '', TokenSpaceGuidCName =3D ''= , Token =3D '', DatumType =3D '', Model =3D MODEL_UNKNOWN, \ - BelongsToFile =3D -1, BelongsToFunction =3D -1, StartLine= =3D -1, StartColumn =3D -1, EndLine =3D -1, EndColumn =3D -1): + def __init__(self, ID=3D-1, CName=3D'', TokenSpaceGuidCName=3D'', Toke= n=3D'', DatumType=3D'', Model=3DMODEL_UNKNOWN, + BelongsToFile=3D-1, BelongsToFunction=3D-1, StartLine=3D-= 1, StartColumn=3D-1, EndLine=3D-1, EndColumn=3D-1): self.ID =3D ID self.CName =3D CName self.TokenSpaceGuidCName =3D TokenSpaceGuidCName @@ -327,7 +343,7 @@ class PcdDataClass(object): self.EndLine =3D EndLine self.EndColumn =3D EndColumn =20 -## FileClass +# FileClass # # This class defines a structure of a file # @@ -353,9 +369,11 @@ class PcdDataClass(object): # @var IdentifierList: IdentifierList of a File # @var PcdList: PcdList of a File # + + class FileClass(object): - def __init__(self, ID =3D -1, Name =3D '', ExtName =3D '', Path =3D ''= , FullPath =3D '', Model =3D MODEL_UNKNOWN, TimeStamp =3D '', \ - FunctionList =3D [], IdentifierList =3D [], PcdList =3D [= ]): + def __init__(self, ID=3D-1, Name=3D'', ExtName=3D'', Path=3D'', FullPa= th=3D'', Model=3DMODEL_UNKNOWN, TimeStamp=3D'', + FunctionList=3D[], IdentifierList=3D[], PcdList=3D[]): self.ID =3D ID self.Name =3D Name self.ExtName =3D ExtName diff --git a/BaseTools/Source/Python/CommonDataClass/Exceptions.py b/BaseTo= ols/Source/Python/CommonDataClass/Exceptions.py index 4489b757e881..3d31d7b074ea 100644 --- a/BaseTools/Source/Python/CommonDataClass/Exceptions.py +++ b/BaseTools/Source/Python/CommonDataClass/Exceptions.py @@ -1,23 +1,27 @@ -## @file +# @file # This file is used to define common Exceptions class used in python tools # # Copyright (c) 2011, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent =20 -## Exceptions used in Expression +# Exceptions used in Expression class EvaluationException(Exception): pass =20 + class BadExpression(EvaluationException): pass =20 + class WrnExpression(Exception): pass =20 -## Exceptions used in macro replacements +# Exceptions used in macro replacements + + class MacroException(Exception): pass =20 + class SymbolNotFound(MacroException): pass - diff --git a/BaseTools/Source/Python/CommonDataClass/FdfClass.py b/BaseTool= s/Source/Python/CommonDataClass/FdfClass.py index 2fbb7b436a9b..de1edb6f04fe 100644 --- a/BaseTools/Source/Python/CommonDataClass/FdfClass.py +++ b/BaseTools/Source/Python/CommonDataClass/FdfClass.py @@ -1,4 +1,4 @@ -## @file +# @file # classes represent data in FDF # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -6,11 +6,11 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## FD data in FDF +# FD data in FDF # # class FDClassObject: - ## The constructor + # The constructor # # @param self The object pointer # @@ -30,11 +30,13 @@ class FDClassObject: self.SetVarDict =3D {} self.RegionList =3D [] =20 -## FFS data in FDF +# FFS data in FDF # # + + class FfsClassObject: - ## The constructor + # The constructor # # @param self The object pointer # @@ -45,11 +47,13 @@ class FfsClassObject: self.Alignment =3D None self.SectionList =3D [] =20 -## FILE statement data in FDF +# FILE statement data in FDF # # -class FileStatementClassObject (FfsClassObject) : - ## The constructor + + +class FileStatementClassObject (FfsClassObject): + # The constructor # # @param self The object pointer # @@ -63,11 +67,13 @@ class FileStatementClassObject (FfsClassObject) : self.DefineVarDict =3D {} self.KeepReloc =3D None =20 -## INF statement data in FDF +# INF statement data in FDF # # + + class FfsInfStatementClassObject(FfsClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -82,22 +88,26 @@ class FfsInfStatementClassObject(FfsClassObject): self.KeepReloc =3D None self.UseArch =3D None =20 -## section data in FDF +# section data in FDF # # + + class SectionClassObject: - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): self.Alignment =3D None =20 -## Depex expression section in FDF +# Depex expression section in FDF # # + + class DepexSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -106,11 +116,13 @@ class DepexSectionClassObject (SectionClassObject): self.Expression =3D None self.ExpressionProcessed =3D False =20 -## Compress section data in FDF +# Compress section data in FDF # # -class CompressSectionClassObject (SectionClassObject) : - ## The constructor + + +class CompressSectionClassObject (SectionClassObject): + # The constructor # # @param self The object pointer # @@ -119,11 +131,13 @@ class CompressSectionClassObject (SectionClassObject)= : self.CompType =3D None self.SectionList =3D [] =20 -## Data section data in FDF +# Data section data in FDF # # + + class DataSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -134,11 +148,13 @@ class DataSectionClassObject (SectionClassObject): self.SectionList =3D [] self.KeepReloc =3D True =20 -## Rule section data in FDF +# Rule section data in FDF # # + + class EfiSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -153,11 +169,13 @@ class EfiSectionClassObject (SectionClassObject): self.BuildNum =3D None self.KeepReloc =3D None =20 -## FV image section data in FDF +# FV image section data in FDF # # + + class FvImageSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -170,11 +188,13 @@ class FvImageSectionClassObject (SectionClassObject): self.FvFileExtension =3D None self.FvAddr =3D None =20 -## GUIDed section data in FDF +# GUIDed section data in FDF # # -class GuidSectionClassObject (SectionClassObject) : - ## The constructor + + +class GuidSectionClassObject (SectionClassObject): + # The constructor # # @param self The object pointer # @@ -190,11 +210,13 @@ class GuidSectionClassObject (SectionClassObject) : self.FvParentAddr =3D None self.IncludeFvSection =3D False =20 -## UI section data in FDF +# UI section data in FDF # # + + class UiSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -203,11 +225,13 @@ class UiSectionClassObject (SectionClassObject): self.StringData =3D None self.FileName =3D None =20 -## Version section data in FDF +# Version section data in FDF # # + + class VerSectionClassObject (SectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -217,11 +241,13 @@ class VerSectionClassObject (SectionClassObject): self.StringData =3D None self.FileName =3D None =20 -## Rule data in FDF +# Rule data in FDF # # -class RuleClassObject : - ## The constructor + + +class RuleClassObject: + # The constructor # # @param self The object pointer # @@ -238,11 +264,13 @@ class RuleClassObject : self.KeyStringList =3D [] self.KeepReloc =3D None =20 -## Complex rule data in FDF +# Complex rule data in FDF # # -class RuleComplexFileClassObject(RuleClassObject) : - ## The constructor + + +class RuleComplexFileClassObject(RuleClassObject): + # The constructor # # @param self The object pointer # @@ -250,11 +278,13 @@ class RuleComplexFileClassObject(RuleClassObject) : RuleClassObject.__init__(self) self.SectionList =3D [] =20 -## Simple rule data in FDF +# Simple rule data in FDF # # -class RuleSimpleFileClassObject(RuleClassObject) : - ## The constructor + + +class RuleSimpleFileClassObject(RuleClassObject): + # The constructor # # @param self The object pointer # @@ -264,11 +294,13 @@ class RuleSimpleFileClassObject(RuleClassObject) : self.SectionType =3D '' self.FileExtension =3D None =20 -## File extension rule data in FDF +# File extension rule data in FDF # # + + class RuleFileExtensionClassObject(RuleClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -276,11 +308,13 @@ class RuleFileExtensionClassObject(RuleClassObject): RuleClassObject.__init__(self) self.FileExtension =3D None =20 -## Capsule data in FDF +# Capsule data in FDF # # -class CapsuleClassObject : - ## The constructor + + +class CapsuleClassObject: + # The constructor # # @param self The object pointer # @@ -298,15 +332,16 @@ class CapsuleClassObject : self.CapsuleDataList =3D [] self.FmpPayloadList =3D [] =20 -## OptionROM data in FDF +# OptionROM data in FDF # # + + class OptionRomClassObject: - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): self.DriverName =3D None self.FfsList =3D [] - diff --git a/BaseTools/Source/Python/CommonDataClass/__init__.py b/BaseTool= s/Source/Python/CommonDataClass/__init__.py index 81af4c07a36e..b56969e90fe2 100644 --- a/BaseTools/Source/Python/CommonDataClass/__init__.py +++ b/BaseTools/Source/Python/CommonDataClass/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'CommonDataClass' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Ecc/CParser3/CLexer.py b/BaseTools/Sou= rce/Python/Ecc/CParser3/CLexer.py index ca03adea7a65..c48cb2404bf0 100644 --- a/BaseTools/Source/Python/Ecc/CParser3/CLexer.py +++ b/BaseTools/Source/Python/Ecc/CParser3/CLexer.py @@ -3,7 +3,7 @@ from antlr3 import * from antlr3.compat import set, frozenset =20 -## @file +# @file # The file defines the Lexer for C source files. # # THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY THIS FILE. @@ -17,127 +17,127 @@ from antlr3.compat import set, frozenset ## =20 =20 - # for convenience in actions HIDDEN =3D BaseRecognizer.HIDDEN =20 # token types -T114=3D114 -T115=3D115 -T116=3D116 -T117=3D117 -FloatTypeSuffix=3D16 -LETTER=3D11 -T29=3D29 -T28=3D28 -T27=3D27 -T26=3D26 -T25=3D25 -EOF=3D-1 -STRING_LITERAL=3D9 -FLOATING_POINT_LITERAL=3D10 -T38=3D38 -T37=3D37 -T39=3D39 -T34=3D34 -COMMENT=3D22 -T33=3D33 -T36=3D36 -T35=3D35 -T30=3D30 -T32=3D32 -T31=3D31 -LINE_COMMENT=3D23 -IntegerTypeSuffix=3D14 -CHARACTER_LITERAL=3D8 -T49=3D49 -T48=3D48 -T100=3D100 -T43=3D43 -T42=3D42 -T102=3D102 -T41=3D41 -T101=3D101 -T40=3D40 -T47=3D47 -T46=3D46 -T45=3D45 -T44=3D44 -T109=3D109 -T107=3D107 -T108=3D108 -T105=3D105 -WS=3D19 -T106=3D106 -T103=3D103 -T104=3D104 -T50=3D50 -LINE_COMMAND=3D24 -T59=3D59 -T113=3D113 -T52=3D52 -T112=3D112 -T51=3D51 -T111=3D111 -T54=3D54 -T110=3D110 -EscapeSequence=3D12 -DECIMAL_LITERAL=3D7 -T53=3D53 -T56=3D56 -T55=3D55 -T58=3D58 -T57=3D57 -T75=3D75 -T76=3D76 -T73=3D73 -T74=3D74 -T79=3D79 -T77=3D77 -T78=3D78 -Exponent=3D15 -HexDigit=3D13 -T72=3D72 -T71=3D71 -T70=3D70 -T62=3D62 -T63=3D63 -T64=3D64 -T65=3D65 -T66=3D66 -T67=3D67 -T68=3D68 -T69=3D69 -IDENTIFIER=3D4 -UnicodeVocabulary=3D21 -HEX_LITERAL=3D5 -T61=3D61 -T60=3D60 -T99=3D99 -T97=3D97 -BS=3D20 -T98=3D98 -T95=3D95 -T96=3D96 -OCTAL_LITERAL=3D6 -T94=3D94 -Tokens=3D118 -T93=3D93 -T92=3D92 -T91=3D91 -T90=3D90 -T88=3D88 -T89=3D89 -T84=3D84 -T85=3D85 -T86=3D86 -T87=3D87 -UnicodeEscape=3D18 -T81=3D81 -T80=3D80 -T83=3D83 -OctalEscape=3D17 -T82=3D82 +T114 =3D 114 +T115 =3D 115 +T116 =3D 116 +T117 =3D 117 +FloatTypeSuffix =3D 16 +LETTER =3D 11 +T29 =3D 29 +T28 =3D 28 +T27 =3D 27 +T26 =3D 26 +T25 =3D 25 +EOF =3D -1 +STRING_LITERAL =3D 9 +FLOATING_POINT_LITERAL =3D 10 +T38 =3D 38 +T37 =3D 37 +T39 =3D 39 +T34 =3D 34 +COMMENT =3D 22 +T33 =3D 33 +T36 =3D 36 +T35 =3D 35 +T30 =3D 30 +T32 =3D 32 +T31 =3D 31 +LINE_COMMENT =3D 23 +IntegerTypeSuffix =3D 14 +CHARACTER_LITERAL =3D 8 +T49 =3D 49 +T48 =3D 48 +T100 =3D 100 +T43 =3D 43 +T42 =3D 42 +T102 =3D 102 +T41 =3D 41 +T101 =3D 101 +T40 =3D 40 +T47 =3D 47 +T46 =3D 46 +T45 =3D 45 +T44 =3D 44 +T109 =3D 109 +T107 =3D 107 +T108 =3D 108 +T105 =3D 105 +WS =3D 19 +T106 =3D 106 +T103 =3D 103 +T104 =3D 104 +T50 =3D 50 +LINE_COMMAND =3D 24 +T59 =3D 59 +T113 =3D 113 +T52 =3D 52 +T112 =3D 112 +T51 =3D 51 +T111 =3D 111 +T54 =3D 54 +T110 =3D 110 +EscapeSequence =3D 12 +DECIMAL_LITERAL =3D 7 +T53 =3D 53 +T56 =3D 56 +T55 =3D 55 +T58 =3D 58 +T57 =3D 57 +T75 =3D 75 +T76 =3D 76 +T73 =3D 73 +T74 =3D 74 +T79 =3D 79 +T77 =3D 77 +T78 =3D 78 +Exponent =3D 15 +HexDigit =3D 13 +T72 =3D 72 +T71 =3D 71 +T70 =3D 70 +T62 =3D 62 +T63 =3D 63 +T64 =3D 64 +T65 =3D 65 +T66 =3D 66 +T67 =3D 67 +T68 =3D 68 +T69 =3D 69 +IDENTIFIER =3D 4 +UnicodeVocabulary =3D 21 +HEX_LITERAL =3D 5 +T61 =3D 61 +T60 =3D 60 +T99 =3D 99 +T97 =3D 97 +BS =3D 20 +T98 =3D 98 +T95 =3D 95 +T96 =3D 96 +OCTAL_LITERAL =3D 6 +T94 =3D 94 +Tokens =3D 118 +T93 =3D 93 +T92 =3D 92 +T91 =3D 91 +T90 =3D 90 +T88 =3D 88 +T89 =3D 89 +T84 =3D 84 +T85 =3D 85 +T86 =3D 86 +T87 =3D 87 +UnicodeEscape =3D 18 +T81 =3D 81 +T80 =3D 80 +T83 =3D 83 +OctalEscape =3D 17 +T82 =3D 82 + =20 class CLexer(Lexer): =20 @@ -147,31 +147,27 @@ class CLexer(Lexer): Lexer.__init__(self, input) self.dfa25 =3D self.DFA25( self, 25, - eot =3D self.DFA25_eot, - eof =3D self.DFA25_eof, - min =3D self.DFA25_min, - max =3D self.DFA25_max, - accept =3D self.DFA25_accept, - special =3D self.DFA25_special, - transition =3D self.DFA25_transition - ) + eot=3Dself.DFA25_eot, + eof=3Dself.DFA25_eof, + min=3Dself.DFA25_min, + max=3Dself.DFA25_max, + accept=3Dself.DFA25_accept, + special=3Dself.DFA25_special, + transition=3Dself.DFA25_transition + ) self.dfa35 =3D self.DFA35( self, 35, - eot =3D self.DFA35_eot, - eof =3D self.DFA35_eof, - min =3D self.DFA35_min, - max =3D self.DFA35_max, - accept =3D self.DFA35_accept, - special =3D self.DFA35_special, - transition =3D self.DFA35_transition - ) - - - - - + eot=3Dself.DFA35_eot, + eof=3Dself.DFA35_eof, + min=3Dself.DFA35_min, + max=3Dself.DFA35_max, + accept=3Dself.DFA35_accept, + special=3Dself.DFA35_special, + transition=3Dself.DFA35_transition + ) =20 # $ANTLR start T25 + def mT25(self, ): =20 try: @@ -181,19 +177,14 @@ class CLexer(Lexer): # C.g:27:7: ';' self.match(u';') =20 - - - - finally: =20 pass =20 # $ANTLR end T25 =20 - - # $ANTLR start T26 + def mT26(self, ): =20 try: @@ -203,20 +194,14 @@ class CLexer(Lexer): # C.g:28:7: 'typedef' self.match("typedef") =20 - - - - - finally: =20 pass =20 # $ANTLR end T26 =20 - - # $ANTLR start T27 + def mT27(self, ): =20 try: @@ -226,19 +211,14 @@ class CLexer(Lexer): # C.g:29:7: ',' self.match(u',') =20 - - - - finally: =20 pass =20 # $ANTLR end T27 =20 - - # $ANTLR start T28 + def mT28(self, ): =20 try: @@ -248,19 +228,14 @@ class CLexer(Lexer): # C.g:30:7: '=3D' self.match(u'=3D') =20 - - - - finally: =20 pass =20 # $ANTLR end T28 =20 - - # $ANTLR start T29 + def mT29(self, ): =20 try: @@ -270,20 +245,14 @@ class CLexer(Lexer): # C.g:31:7: 'extern' self.match("extern") =20 - - - - - finally: =20 pass =20 # $ANTLR end T29 =20 - - # $ANTLR start T30 + def mT30(self, ): =20 try: @@ -293,20 +262,14 @@ class CLexer(Lexer): # C.g:32:7: 'static' self.match("static") =20 - - - - - finally: =20 pass =20 # $ANTLR end T30 =20 - - # $ANTLR start T31 + def mT31(self, ): =20 try: @@ -316,20 +279,14 @@ class CLexer(Lexer): # C.g:33:7: 'auto' self.match("auto") =20 - - - - - finally: =20 pass =20 # $ANTLR end T31 =20 - - # $ANTLR start T32 + def mT32(self, ): =20 try: @@ -339,20 +296,14 @@ class CLexer(Lexer): # C.g:34:7: 'register' self.match("register") =20 - - - - - finally: =20 pass =20 # $ANTLR end T32 =20 - - # $ANTLR start T33 + def mT33(self, ): =20 try: @@ -362,20 +313,14 @@ class CLexer(Lexer): # C.g:35:7: 'STATIC' self.match("STATIC") =20 - - - - - finally: =20 pass =20 # $ANTLR end T33 =20 - - # $ANTLR start T34 + def mT34(self, ): =20 try: @@ -385,20 +330,14 @@ class CLexer(Lexer): # C.g:36:7: 'void' self.match("void") =20 - - - - - finally: =20 pass =20 # $ANTLR end T34 =20 - - # $ANTLR start T35 + def mT35(self, ): =20 try: @@ -408,20 +347,14 @@ class CLexer(Lexer): # C.g:37:7: 'char' self.match("char") =20 - - - - - finally: =20 pass =20 # $ANTLR end T35 =20 - - # $ANTLR start T36 + def mT36(self, ): =20 try: @@ -431,20 +364,14 @@ class CLexer(Lexer): # C.g:38:7: 'short' self.match("short") =20 - - - - - finally: =20 pass =20 # $ANTLR end T36 =20 - - # $ANTLR start T37 + def mT37(self, ): =20 try: @@ -454,20 +381,14 @@ class CLexer(Lexer): # C.g:39:7: 'int' self.match("int") =20 - - - - - finally: =20 pass =20 # $ANTLR end T37 =20 - - # $ANTLR start T38 + def mT38(self, ): =20 try: @@ -477,20 +398,14 @@ class CLexer(Lexer): # C.g:40:7: 'long' self.match("long") =20 - - - - - finally: =20 pass =20 # $ANTLR end T38 =20 - - # $ANTLR start T39 + def mT39(self, ): =20 try: @@ -500,20 +415,14 @@ class CLexer(Lexer): # C.g:41:7: 'float' self.match("float") =20 - - - - - finally: =20 pass =20 # $ANTLR end T39 =20 - - # $ANTLR start T40 + def mT40(self, ): =20 try: @@ -523,20 +432,14 @@ class CLexer(Lexer): # C.g:42:7: 'double' self.match("double") =20 - - - - - finally: =20 pass =20 # $ANTLR end T40 =20 - - # $ANTLR start T41 + def mT41(self, ): =20 try: @@ -546,20 +449,14 @@ class CLexer(Lexer): # C.g:43:7: 'signed' self.match("signed") =20 - - - - - finally: =20 pass =20 # $ANTLR end T41 =20 - - # $ANTLR start T42 + def mT42(self, ): =20 try: @@ -569,20 +466,14 @@ class CLexer(Lexer): # C.g:44:7: 'unsigned' self.match("unsigned") =20 - - - - - finally: =20 pass =20 # $ANTLR end T42 =20 - - # $ANTLR start T43 + def mT43(self, ): =20 try: @@ -592,19 +483,14 @@ class CLexer(Lexer): # C.g:45:7: '{' self.match(u'{') =20 - - - - finally: =20 pass =20 # $ANTLR end T43 =20 - - # $ANTLR start T44 + def mT44(self, ): =20 try: @@ -614,19 +500,14 @@ class CLexer(Lexer): # C.g:46:7: '}' self.match(u'}') =20 - - - - finally: =20 pass =20 # $ANTLR end T44 =20 - - # $ANTLR start T45 + def mT45(self, ): =20 try: @@ -636,20 +517,14 @@ class CLexer(Lexer): # C.g:47:7: 'struct' self.match("struct") =20 - - - - - finally: =20 pass =20 # $ANTLR end T45 =20 - - # $ANTLR start T46 + def mT46(self, ): =20 try: @@ -659,20 +534,14 @@ class CLexer(Lexer): # C.g:48:7: 'union' self.match("union") =20 - - - - - finally: =20 pass =20 # $ANTLR end T46 =20 - - # $ANTLR start T47 + def mT47(self, ): =20 try: @@ -682,19 +551,14 @@ class CLexer(Lexer): # C.g:49:7: ':' self.match(u':') =20 - - - - finally: =20 pass =20 # $ANTLR end T47 =20 - - # $ANTLR start T48 + def mT48(self, ): =20 try: @@ -704,20 +568,14 @@ class CLexer(Lexer): # C.g:50:7: 'enum' self.match("enum") =20 - - - - - finally: =20 pass =20 # $ANTLR end T48 =20 - - # $ANTLR start T49 + def mT49(self, ): =20 try: @@ -727,20 +585,14 @@ class CLexer(Lexer): # C.g:51:7: 'const' self.match("const") =20 - - - - - finally: =20 pass =20 # $ANTLR end T49 =20 - - # $ANTLR start T50 + def mT50(self, ): =20 try: @@ -750,20 +602,14 @@ class CLexer(Lexer): # C.g:52:7: 'volatile' self.match("volatile") =20 - - - - - finally: =20 pass =20 # $ANTLR end T50 =20 - - # $ANTLR start T51 + def mT51(self, ): =20 try: @@ -773,20 +619,14 @@ class CLexer(Lexer): # C.g:53:7: 'IN' self.match("IN") =20 - - - - - finally: =20 pass =20 # $ANTLR end T51 =20 - - # $ANTLR start T52 + def mT52(self, ): =20 try: @@ -796,20 +636,14 @@ class CLexer(Lexer): # C.g:54:7: 'OUT' self.match("OUT") =20 - - - - - finally: =20 pass =20 # $ANTLR end T52 =20 - - # $ANTLR start T53 + def mT53(self, ): =20 try: @@ -819,20 +653,14 @@ class CLexer(Lexer): # C.g:55:7: 'OPTIONAL' self.match("OPTIONAL") =20 - - - - - finally: =20 pass =20 # $ANTLR end T53 =20 - - # $ANTLR start T54 + def mT54(self, ): =20 try: @@ -842,20 +670,14 @@ class CLexer(Lexer): # C.g:56:7: 'CONST' self.match("CONST") =20 - - - - - finally: =20 pass =20 # $ANTLR end T54 =20 - - # $ANTLR start T55 + def mT55(self, ): =20 try: @@ -865,20 +687,14 @@ class CLexer(Lexer): # C.g:57:7: 'UNALIGNED' self.match("UNALIGNED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T55 =20 - - # $ANTLR start T56 + def mT56(self, ): =20 try: @@ -888,20 +704,14 @@ class CLexer(Lexer): # C.g:58:7: 'VOLATILE' self.match("VOLATILE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T56 =20 - - # $ANTLR start T57 + def mT57(self, ): =20 try: @@ -911,20 +721,14 @@ class CLexer(Lexer): # C.g:59:7: 'GLOBAL_REMOVE_IF_UNREFERENCED' self.match("GLOBAL_REMOVE_IF_UNREFERENCED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T57 =20 - - # $ANTLR start T58 + def mT58(self, ): =20 try: @@ -934,20 +738,14 @@ class CLexer(Lexer): # C.g:60:7: 'EFIAPI' self.match("EFIAPI") =20 - - - - - finally: =20 pass =20 # $ANTLR end T58 =20 - - # $ANTLR start T59 + def mT59(self, ): =20 try: @@ -957,20 +755,14 @@ class CLexer(Lexer): # C.g:61:7: 'EFI_BOOTSERVICE' self.match("EFI_BOOTSERVICE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T59 =20 - - # $ANTLR start T60 + def mT60(self, ): =20 try: @@ -980,20 +772,14 @@ class CLexer(Lexer): # C.g:62:7: 'EFI_RUNTIMESERVICE' self.match("EFI_RUNTIMESERVICE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T60 =20 - - # $ANTLR start T61 + def mT61(self, ): =20 try: @@ -1003,20 +789,14 @@ class CLexer(Lexer): # C.g:63:7: 'PACKED' self.match("PACKED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T61 =20 - - # $ANTLR start T62 + def mT62(self, ): =20 try: @@ -1026,19 +806,14 @@ class CLexer(Lexer): # C.g:64:7: '(' self.match(u'(') =20 - - - - finally: =20 pass =20 # $ANTLR end T62 =20 - - # $ANTLR start T63 + def mT63(self, ): =20 try: @@ -1048,19 +823,14 @@ class CLexer(Lexer): # C.g:65:7: ')' self.match(u')') =20 - - - - finally: =20 pass =20 # $ANTLR end T63 =20 - - # $ANTLR start T64 + def mT64(self, ): =20 try: @@ -1070,19 +840,14 @@ class CLexer(Lexer): # C.g:66:7: '[' self.match(u'[') =20 - - - - finally: =20 pass =20 # $ANTLR end T64 =20 - - # $ANTLR start T65 + def mT65(self, ): =20 try: @@ -1092,19 +857,14 @@ class CLexer(Lexer): # C.g:67:7: ']' self.match(u']') =20 - - - - finally: =20 pass =20 # $ANTLR end T65 =20 - - # $ANTLR start T66 + def mT66(self, ): =20 try: @@ -1114,19 +874,14 @@ class CLexer(Lexer): # C.g:68:7: '*' self.match(u'*') =20 - - - - finally: =20 pass =20 # $ANTLR end T66 =20 - - # $ANTLR start T67 + def mT67(self, ): =20 try: @@ -1136,20 +891,14 @@ class CLexer(Lexer): # C.g:69:7: '...' self.match("...") =20 - - - - - finally: =20 pass =20 # $ANTLR end T67 =20 - - # $ANTLR start T68 + def mT68(self, ): =20 try: @@ -1159,19 +908,14 @@ class CLexer(Lexer): # C.g:70:7: '+' self.match(u'+') =20 - - - - finally: =20 pass =20 # $ANTLR end T68 =20 - - # $ANTLR start T69 + def mT69(self, ): =20 try: @@ -1181,19 +925,14 @@ class CLexer(Lexer): # C.g:71:7: '-' self.match(u'-') =20 - - - - finally: =20 pass =20 # $ANTLR end T69 =20 - - # $ANTLR start T70 + def mT70(self, ): =20 try: @@ -1203,19 +942,14 @@ class CLexer(Lexer): # C.g:72:7: '/' self.match(u'/') =20 - - - - finally: =20 pass =20 # $ANTLR end T70 =20 - - # $ANTLR start T71 + def mT71(self, ): =20 try: @@ -1225,19 +959,14 @@ class CLexer(Lexer): # C.g:73:7: '%' self.match(u'%') =20 - - - - finally: =20 pass =20 # $ANTLR end T71 =20 - - # $ANTLR start T72 + def mT72(self, ): =20 try: @@ -1247,20 +976,14 @@ class CLexer(Lexer): # C.g:74:7: '++' self.match("++") =20 - - - - - finally: =20 pass =20 # $ANTLR end T72 =20 - - # $ANTLR start T73 + def mT73(self, ): =20 try: @@ -1270,20 +993,14 @@ class CLexer(Lexer): # C.g:75:7: '--' self.match("--") =20 - - - - - finally: =20 pass =20 # $ANTLR end T73 =20 - - # $ANTLR start T74 + def mT74(self, ): =20 try: @@ -1293,20 +1010,14 @@ class CLexer(Lexer): # C.g:76:7: 'sizeof' self.match("sizeof") =20 - - - - - finally: =20 pass =20 # $ANTLR end T74 =20 - - # $ANTLR start T75 + def mT75(self, ): =20 try: @@ -1316,19 +1027,14 @@ class CLexer(Lexer): # C.g:77:7: '.' self.match(u'.') =20 - - - - finally: =20 pass =20 # $ANTLR end T75 =20 - - # $ANTLR start T76 + def mT76(self, ): =20 try: @@ -1338,20 +1044,14 @@ class CLexer(Lexer): # C.g:78:7: '->' self.match("->") =20 - - - - - finally: =20 pass =20 # $ANTLR end T76 =20 - - # $ANTLR start T77 + def mT77(self, ): =20 try: @@ -1361,19 +1061,14 @@ class CLexer(Lexer): # C.g:79:7: '&' self.match(u'&') =20 - - - - finally: =20 pass =20 # $ANTLR end T77 =20 - - # $ANTLR start T78 + def mT78(self, ): =20 try: @@ -1383,19 +1078,14 @@ class CLexer(Lexer): # C.g:80:7: '~' self.match(u'~') =20 - - - - finally: =20 pass =20 # $ANTLR end T78 =20 - - # $ANTLR start T79 + def mT79(self, ): =20 try: @@ -1405,19 +1095,14 @@ class CLexer(Lexer): # C.g:81:7: '!' self.match(u'!') =20 - - - - finally: =20 pass =20 # $ANTLR end T79 =20 - - # $ANTLR start T80 + def mT80(self, ): =20 try: @@ -1427,20 +1112,14 @@ class CLexer(Lexer): # C.g:82:7: '*=3D' self.match("*=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T80 =20 - - # $ANTLR start T81 + def mT81(self, ): =20 try: @@ -1450,20 +1129,14 @@ class CLexer(Lexer): # C.g:83:7: '/=3D' self.match("/=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T81 =20 - - # $ANTLR start T82 + def mT82(self, ): =20 try: @@ -1473,20 +1146,14 @@ class CLexer(Lexer): # C.g:84:7: '%=3D' self.match("%=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T82 =20 - - # $ANTLR start T83 + def mT83(self, ): =20 try: @@ -1496,20 +1163,14 @@ class CLexer(Lexer): # C.g:85:7: '+=3D' self.match("+=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T83 =20 - - # $ANTLR start T84 + def mT84(self, ): =20 try: @@ -1519,20 +1180,14 @@ class CLexer(Lexer): # C.g:86:7: '-=3D' self.match("-=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T84 =20 - - # $ANTLR start T85 + def mT85(self, ): =20 try: @@ -1542,20 +1197,14 @@ class CLexer(Lexer): # C.g:87:7: '<<=3D' self.match("<<=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T85 =20 - - # $ANTLR start T86 + def mT86(self, ): =20 try: @@ -1565,20 +1214,14 @@ class CLexer(Lexer): # C.g:88:7: '>>=3D' self.match(">>=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T86 =20 - - # $ANTLR start T87 + def mT87(self, ): =20 try: @@ -1588,20 +1231,14 @@ class CLexer(Lexer): # C.g:89:7: '&=3D' self.match("&=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T87 =20 - - # $ANTLR start T88 + def mT88(self, ): =20 try: @@ -1611,20 +1248,14 @@ class CLexer(Lexer): # C.g:90:7: '^=3D' self.match("^=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T88 =20 - - # $ANTLR start T89 + def mT89(self, ): =20 try: @@ -1634,20 +1265,14 @@ class CLexer(Lexer): # C.g:91:7: '|=3D' self.match("|=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T89 =20 - - # $ANTLR start T90 + def mT90(self, ): =20 try: @@ -1657,19 +1282,14 @@ class CLexer(Lexer): # C.g:92:7: '?' self.match(u'?') =20 - - - - finally: =20 pass =20 # $ANTLR end T90 =20 - - # $ANTLR start T91 + def mT91(self, ): =20 try: @@ -1679,20 +1299,14 @@ class CLexer(Lexer): # C.g:93:7: '||' self.match("||") =20 - - - - - finally: =20 pass =20 # $ANTLR end T91 =20 - - # $ANTLR start T92 + def mT92(self, ): =20 try: @@ -1702,20 +1316,14 @@ class CLexer(Lexer): # C.g:94:7: '&&' self.match("&&") =20 - - - - - finally: =20 pass =20 # $ANTLR end T92 =20 - - # $ANTLR start T93 + def mT93(self, ): =20 try: @@ -1725,19 +1333,14 @@ class CLexer(Lexer): # C.g:95:7: '|' self.match(u'|') =20 - - - - finally: =20 pass =20 # $ANTLR end T93 =20 - - # $ANTLR start T94 + def mT94(self, ): =20 try: @@ -1747,19 +1350,14 @@ class CLexer(Lexer): # C.g:96:7: '^' self.match(u'^') =20 - - - - finally: =20 pass =20 # $ANTLR end T94 =20 - - # $ANTLR start T95 + def mT95(self, ): =20 try: @@ -1769,20 +1367,14 @@ class CLexer(Lexer): # C.g:97:7: '=3D=3D' self.match("=3D=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T95 =20 - - # $ANTLR start T96 + def mT96(self, ): =20 try: @@ -1792,20 +1384,14 @@ class CLexer(Lexer): # C.g:98:7: '!=3D' self.match("!=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T96 =20 - - # $ANTLR start T97 + def mT97(self, ): =20 try: @@ -1815,19 +1401,14 @@ class CLexer(Lexer): # C.g:99:7: '<' self.match(u'<') =20 - - - - finally: =20 pass =20 # $ANTLR end T97 =20 - - # $ANTLR start T98 + def mT98(self, ): =20 try: @@ -1837,19 +1418,14 @@ class CLexer(Lexer): # C.g:100:7: '>' self.match(u'>') =20 - - - - finally: =20 pass =20 # $ANTLR end T98 =20 - - # $ANTLR start T99 + def mT99(self, ): =20 try: @@ -1859,20 +1435,14 @@ class CLexer(Lexer): # C.g:101:7: '<=3D' self.match("<=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T99 =20 - - # $ANTLR start T100 + def mT100(self, ): =20 try: @@ -1882,20 +1452,14 @@ class CLexer(Lexer): # C.g:102:8: '>=3D' self.match(">=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T100 =20 - - # $ANTLR start T101 + def mT101(self, ): =20 try: @@ -1905,20 +1469,14 @@ class CLexer(Lexer): # C.g:103:8: '<<' self.match("<<") =20 - - - - - finally: =20 pass =20 # $ANTLR end T101 =20 - - # $ANTLR start T102 + def mT102(self, ): =20 try: @@ -1928,20 +1486,14 @@ class CLexer(Lexer): # C.g:104:8: '>>' self.match(">>") =20 - - - - - finally: =20 pass =20 # $ANTLR end T102 =20 - - # $ANTLR start T103 + def mT103(self, ): =20 try: @@ -1951,20 +1503,14 @@ class CLexer(Lexer): # C.g:105:8: '__asm__' self.match("__asm__") =20 - - - - - finally: =20 pass =20 # $ANTLR end T103 =20 - - # $ANTLR start T104 + def mT104(self, ): =20 try: @@ -1974,20 +1520,14 @@ class CLexer(Lexer): # C.g:106:8: '_asm' self.match("_asm") =20 - - - - - finally: =20 pass =20 # $ANTLR end T104 =20 - - # $ANTLR start T105 + def mT105(self, ): =20 try: @@ -1997,20 +1537,14 @@ class CLexer(Lexer): # C.g:107:8: '__asm' self.match("__asm") =20 - - - - - finally: =20 pass =20 # $ANTLR end T105 =20 - - # $ANTLR start T106 + def mT106(self, ): =20 try: @@ -2020,20 +1554,14 @@ class CLexer(Lexer): # C.g:108:8: 'case' self.match("case") =20 - - - - - finally: =20 pass =20 # $ANTLR end T106 =20 - - # $ANTLR start T107 + def mT107(self, ): =20 try: @@ -2043,20 +1571,14 @@ class CLexer(Lexer): # C.g:109:8: 'default' self.match("default") =20 - - - - - finally: =20 pass =20 # $ANTLR end T107 =20 - - # $ANTLR start T108 + def mT108(self, ): =20 try: @@ -2066,20 +1588,14 @@ class CLexer(Lexer): # C.g:110:8: 'if' self.match("if") =20 - - - - - finally: =20 pass =20 # $ANTLR end T108 =20 - - # $ANTLR start T109 + def mT109(self, ): =20 try: @@ -2089,20 +1605,14 @@ class CLexer(Lexer): # C.g:111:8: 'else' self.match("else") =20 - - - - - finally: =20 pass =20 # $ANTLR end T109 =20 - - # $ANTLR start T110 + def mT110(self, ): =20 try: @@ -2112,20 +1622,14 @@ class CLexer(Lexer): # C.g:112:8: 'switch' self.match("switch") =20 - - - - - finally: =20 pass =20 # $ANTLR end T110 =20 - - # $ANTLR start T111 + def mT111(self, ): =20 try: @@ -2135,20 +1639,14 @@ class CLexer(Lexer): # C.g:113:8: 'while' self.match("while") =20 - - - - - finally: =20 pass =20 # $ANTLR end T111 =20 - - # $ANTLR start T112 + def mT112(self, ): =20 try: @@ -2158,20 +1656,14 @@ class CLexer(Lexer): # C.g:114:8: 'do' self.match("do") =20 - - - - - finally: =20 pass =20 # $ANTLR end T112 =20 - - # $ANTLR start T113 + def mT113(self, ): =20 try: @@ -2181,20 +1673,14 @@ class CLexer(Lexer): # C.g:115:8: 'for' self.match("for") =20 - - - - - finally: =20 pass =20 # $ANTLR end T113 =20 - - # $ANTLR start T114 + def mT114(self, ): =20 try: @@ -2204,20 +1690,14 @@ class CLexer(Lexer): # C.g:116:8: 'goto' self.match("goto") =20 - - - - - finally: =20 pass =20 # $ANTLR end T114 =20 - - # $ANTLR start T115 + def mT115(self, ): =20 try: @@ -2227,20 +1707,14 @@ class CLexer(Lexer): # C.g:117:8: 'continue' self.match("continue") =20 - - - - - finally: =20 pass =20 # $ANTLR end T115 =20 - - # $ANTLR start T116 + def mT116(self, ): =20 try: @@ -2250,20 +1724,14 @@ class CLexer(Lexer): # C.g:118:8: 'break' self.match("break") =20 - - - - - finally: =20 pass =20 # $ANTLR end T116 =20 - - # $ANTLR start T117 + def mT117(self, ): =20 try: @@ -2273,20 +1741,14 @@ class CLexer(Lexer): # C.g:119:8: 'return' self.match("return") =20 - - - - - finally: =20 pass =20 # $ANTLR end T117 =20 - - # $ANTLR start IDENTIFIER + def mIDENTIFIER(self, ): =20 try: @@ -2297,34 +1759,25 @@ class CLexer(Lexer): self.mLETTER() =20 # C.g:586:11: ( LETTER | '0' .. '9' )* - while True: #loop1 + while True: # loop1 alt1 =3D 2 LA1_0 =3D self.input.LA(1) =20 - if (LA1_0 =3D=3D u'$' or (u'0' <=3D LA1_0 <=3D u'9') or (u= 'A' <=3D LA1_0 <=3D u'Z') or LA1_0 =3D=3D u'_' or (u'a' <=3D LA1_0 <=3D u'z= ')) : + if (LA1_0 =3D=3D u'$' or (u'0' <=3D LA1_0 <=3D u'9') or (u= 'A' <=3D LA1_0 <=3D u'Z') or LA1_0 =3D=3D u'_' or (u'a' <=3D LA1_0 <=3D u'z= ')): alt1 =3D 1 =20 - if alt1 =3D=3D 1: # C.g: if self.input.LA(1) =3D=3D u'$' or (u'0' <=3D self.inp= ut.LA(1) <=3D u'9') or (u'A' <=3D self.input.LA(1) <=3D u'Z') or self.input= .LA(1) =3D=3D u'_' or (u'a' <=3D self.input.LA(1) <=3D u'z'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop1 - - - - - + break # loop1 =20 finally: =20 @@ -2332,36 +1785,29 @@ class CLexer(Lexer): =20 # $ANTLR end IDENTIFIER =20 - - # $ANTLR start LETTER + def mLETTER(self, ): =20 try: # C.g:591:2: ( '$' | 'A' .. 'Z' | 'a' .. 'z' | '_' ) # C.g: if self.input.LA(1) =3D=3D u'$' or (u'A' <=3D self.input.LA(1)= <=3D u'Z') or self.input.LA(1) =3D=3D u'_' or (u'a' <=3D self.input.LA(1) = <=3D u'z'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end LETTER =20 - - # $ANTLR start CHARACTER_LITERAL + def mCHARACTER_LITERAL(self, ): =20 try: @@ -2373,27 +1819,25 @@ class CLexer(Lexer): alt2 =3D 2 LA2_0 =3D self.input.LA(1) =20 - if (LA2_0 =3D=3D u'L') : + if (LA2_0 =3D=3D u'L'): alt2 =3D 1 if alt2 =3D=3D 1: # C.g:598:10: 'L' self.match(u'L') =20 - - - self.match(u'\'') =20 # C.g:598:21: ( EscapeSequence | ~ ( '\\'' | '\\\\' ) ) alt3 =3D 2 LA3_0 =3D self.input.LA(1) =20 - if (LA3_0 =3D=3D u'\\') : + if (LA3_0 =3D=3D u'\\'): alt3 =3D 1 - elif ((u'\u0000' <=3D LA3_0 <=3D u'&') or (u'(' <=3D LA3_0 <= =3D u'[') or (u']' <=3D LA3_0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA3_0 <=3D u'&') or (u'(' <=3D LA3_0 <= =3D u'[') or (u']' <=3D LA3_0 <=3D u'\uFFFE')): alt3 =3D 2 else: - nvae =3D NoViableAltException("598:21: ( EscapeSequence | = ~ ( '\\'' | '\\\\' ) )", 3, 0, self.input) + nvae =3D NoViableAltException( + "598:21: ( EscapeSequence | ~ ( '\\'' | '\\\\' ) )", 3= , 0, self.input) =20 raise nvae =20 @@ -2401,37 +1845,26 @@ class CLexer(Lexer): # C.g:598:23: EscapeSequence self.mEscapeSequence() =20 - - elif alt3 =3D=3D 2: # C.g:598:40: ~ ( '\\'' | '\\\\' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'&') or (u'(' <= =3D self.input.LA(1) <=3D u'[') or (u']' <=3D self.input.LA(1) <=3D u'\uFFF= E'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - self.match(u'\'') =20 - - - - finally: =20 pass =20 # $ANTLR end CHARACTER_LITERAL =20 - - # $ANTLR start STRING_LITERAL + def mSTRING_LITERAL(self, ): =20 try: @@ -2443,66 +1876,51 @@ class CLexer(Lexer): alt4 =3D 2 LA4_0 =3D self.input.LA(1) =20 - if (LA4_0 =3D=3D u'L') : + if (LA4_0 =3D=3D u'L'): alt4 =3D 1 if alt4 =3D=3D 1: # C.g:602:9: 'L' self.match(u'L') =20 - - - self.match(u'"') =20 # C.g:602:19: ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* - while True: #loop5 + while True: # loop5 alt5 =3D 3 LA5_0 =3D self.input.LA(1) =20 - if (LA5_0 =3D=3D u'\\') : + if (LA5_0 =3D=3D u'\\'): alt5 =3D 1 - elif ((u'\u0000' <=3D LA5_0 <=3D u'!') or (u'#' <=3D LA5_0= <=3D u'[') or (u']' <=3D LA5_0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA5_0 <=3D u'!') or (u'#' <=3D LA5_0= <=3D u'[') or (u']' <=3D LA5_0 <=3D u'\uFFFE')): alt5 =3D 2 =20 - if alt5 =3D=3D 1: # C.g:602:21: EscapeSequence self.mEscapeSequence() =20 - - elif alt5 =3D=3D 2: # C.g:602:38: ~ ( '\\\\' | '\"' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'!') or (u'#= ' <=3D self.input.LA(1) <=3D u'[') or (u']' <=3D self.input.LA(1) <=3D u'\u= FFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop5 - + break # loop5 =20 self.match(u'"') =20 - - - - finally: =20 pass =20 # $ANTLR end STRING_LITERAL =20 - - # $ANTLR start HEX_LITERAL + def mHEX_LITERAL(self, ): =20 try: @@ -2513,66 +1931,53 @@ class CLexer(Lexer): self.match(u'0') =20 if self.input.LA(1) =3D=3D u'X' or self.input.LA(1) =3D=3D u'x= ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - # C.g:605:29: ( HexDigit )+ cnt6 =3D 0 - while True: #loop6 + while True: # loop6 alt6 =3D 2 LA6_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA6_0 <=3D u'9') or (u'A' <=3D LA6_0 <=3D u= 'F') or (u'a' <=3D LA6_0 <=3D u'f')) : + if ((u'0' <=3D LA6_0 <=3D u'9') or (u'A' <=3D LA6_0 <=3D u= 'F') or (u'a' <=3D LA6_0 <=3D u'f')): alt6 =3D 1 =20 - if alt6 =3D=3D 1: # C.g:605:29: HexDigit self.mHexDigit() =20 - - else: if cnt6 >=3D 1: - break #loop6 + break # loop6 =20 eee =3D EarlyExitException(6, self.input) raise eee =20 cnt6 +=3D 1 =20 - # C.g:605:39: ( IntegerTypeSuffix )? alt7 =3D 2 LA7_0 =3D self.input.LA(1) =20 - if (LA7_0 =3D=3D u'L' or LA7_0 =3D=3D u'U' or LA7_0 =3D=3D u'l= ' or LA7_0 =3D=3D u'u') : + if (LA7_0 =3D=3D u'L' or LA7_0 =3D=3D u'U' or LA7_0 =3D=3D u'l= ' or LA7_0 =3D=3D u'u'): alt7 =3D 1 if alt7 =3D=3D 1: # C.g:605:39: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end HEX_LITERAL =20 - - # $ANTLR start DECIMAL_LITERAL + def mDECIMAL_LITERAL(self, ): =20 try: @@ -2584,12 +1989,13 @@ class CLexer(Lexer): alt9 =3D 2 LA9_0 =3D self.input.LA(1) =20 - if (LA9_0 =3D=3D u'0') : + if (LA9_0 =3D=3D u'0'): alt9 =3D 1 - elif ((u'1' <=3D LA9_0 <=3D u'9')) : + elif ((u'1' <=3D LA9_0 <=3D u'9')): alt9 =3D 2 else: - nvae =3D NoViableAltException("607:19: ( '0' | '1' .. '9' = ( '0' .. '9' )* )", 9, 0, self.input) + nvae =3D NoViableAltException( + "607:19: ( '0' | '1' .. '9' ( '0' .. '9' )* )", 9, 0, = self.input) =20 raise nvae =20 @@ -2597,60 +2003,43 @@ class CLexer(Lexer): # C.g:607:20: '0' self.match(u'0') =20 - - elif alt9 =3D=3D 2: # C.g:607:26: '1' .. '9' ( '0' .. '9' )* self.matchRange(u'1', u'9') =20 # C.g:607:35: ( '0' .. '9' )* - while True: #loop8 + while True: # loop8 alt8 =3D 2 LA8_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA8_0 <=3D u'9')) : + if ((u'0' <=3D LA8_0 <=3D u'9')): alt8 =3D 1 =20 - if alt8 =3D=3D 1: # C.g:607:35: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: - break #loop8 - - - - + break # loop8 =20 # C.g:607:46: ( IntegerTypeSuffix )? alt10 =3D 2 LA10_0 =3D self.input.LA(1) =20 - if (LA10_0 =3D=3D u'L' or LA10_0 =3D=3D u'U' or LA10_0 =3D=3D = u'l' or LA10_0 =3D=3D u'u') : + if (LA10_0 =3D=3D u'L' or LA10_0 =3D=3D u'U' or LA10_0 =3D=3D = u'l' or LA10_0 =3D=3D u'u'): alt10 =3D 1 if alt10 =3D=3D 1: # C.g:607:46: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end DECIMAL_LITERAL =20 - - # $ANTLR start OCTAL_LITERAL + def mOCTAL_LITERAL(self, ): =20 try: @@ -2662,83 +2051,65 @@ class CLexer(Lexer): =20 # C.g:609:21: ( '0' .. '7' )+ cnt11 =3D 0 - while True: #loop11 + while True: # loop11 alt11 =3D 2 LA11_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA11_0 <=3D u'7')) : + if ((u'0' <=3D LA11_0 <=3D u'7')): alt11 =3D 1 =20 - if alt11 =3D=3D 1: # C.g:609:22: '0' .. '7' self.matchRange(u'0', u'7') =20 - - else: if cnt11 >=3D 1: - break #loop11 + break # loop11 =20 eee =3D EarlyExitException(11, self.input) raise eee =20 cnt11 +=3D 1 =20 - # C.g:609:33: ( IntegerTypeSuffix )? alt12 =3D 2 LA12_0 =3D self.input.LA(1) =20 - if (LA12_0 =3D=3D u'L' or LA12_0 =3D=3D u'U' or LA12_0 =3D=3D = u'l' or LA12_0 =3D=3D u'u') : + if (LA12_0 =3D=3D u'L' or LA12_0 =3D=3D u'U' or LA12_0 =3D=3D = u'l' or LA12_0 =3D=3D u'u'): alt12 =3D 1 if alt12 =3D=3D 1: # C.g:609:33: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end OCTAL_LITERAL =20 - - # $ANTLR start HexDigit + def mHexDigit(self, ): =20 try: # C.g:612:10: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) ) # C.g:612:12: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) if (u'0' <=3D self.input.LA(1) <=3D u'9') or (u'A' <=3D self.i= nput.LA(1) <=3D u'F') or (u'a' <=3D self.input.LA(1) <=3D u'f'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end HexDigit =20 - - # $ANTLR start IntegerTypeSuffix + def mIntegerTypeSuffix(self, ): =20 try: @@ -2746,114 +2117,98 @@ class CLexer(Lexer): alt13 =3D 4 LA13_0 =3D self.input.LA(1) =20 - if (LA13_0 =3D=3D u'U' or LA13_0 =3D=3D u'u') : + if (LA13_0 =3D=3D u'U' or LA13_0 =3D=3D u'u'): LA13_1 =3D self.input.LA(2) =20 - if (LA13_1 =3D=3D u'L' or LA13_1 =3D=3D u'l') : + if (LA13_1 =3D=3D u'L' or LA13_1 =3D=3D u'l'): LA13_3 =3D self.input.LA(3) =20 - if (LA13_3 =3D=3D u'L' or LA13_3 =3D=3D u'l') : + if (LA13_3 =3D=3D u'L' or LA13_3 =3D=3D u'l'): alt13 =3D 4 else: alt13 =3D 3 else: alt13 =3D 1 - elif (LA13_0 =3D=3D u'L' or LA13_0 =3D=3D u'l') : + elif (LA13_0 =3D=3D u'L' or LA13_0 =3D=3D u'l'): alt13 =3D 2 else: - nvae =3D NoViableAltException("614:1: fragment IntegerType= Suffix : ( ( 'u' | 'U' ) | ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) | ( = 'u' | 'U' ) ( 'l' | 'L' ) ( 'l' | 'L' ) );", 13, 0, self.input) + nvae =3D NoViableAltException( + "614:1: fragment IntegerTypeSuffix : ( ( 'u' | 'U' ) |= ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) = ( 'l' | 'L' ) );", 13, 0, self.input) =20 raise nvae =20 if alt13 =3D=3D 1: # C.g:616:4: ( 'u' | 'U' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 2: # C.g:617:4: ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 3: # C.g:618:4: ( 'u' | 'U' ) ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 4: # C.g:619:4: ( 'u' | 'U' ) ( 'l' | 'L' ) ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - finally: =20 pass =20 # $ANTLR end IntegerTypeSuffix =20 - - # $ANTLR start FLOATING_POINT_LITERAL + def mFLOATING_POINT_LITERAL(self, ): =20 try: @@ -2866,337 +2221,269 @@ class CLexer(Lexer): # C.g:623:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( Exponen= t )? ( FloatTypeSuffix )? # C.g:623:9: ( '0' .. '9' )+ cnt14 =3D 0 - while True: #loop14 + while True: # loop14 alt14 =3D 2 LA14_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA14_0 <=3D u'9')) : + if ((u'0' <=3D LA14_0 <=3D u'9')): alt14 =3D 1 =20 - if alt14 =3D=3D 1: # C.g:623:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt14 >=3D 1: - break #loop14 + break # loop14 =20 eee =3D EarlyExitException(14, self.input) raise eee =20 cnt14 +=3D 1 =20 - self.match(u'.') =20 # C.g:623:25: ( '0' .. '9' )* - while True: #loop15 + while True: # loop15 alt15 =3D 2 LA15_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA15_0 <=3D u'9')) : + if ((u'0' <=3D LA15_0 <=3D u'9')): alt15 =3D 1 =20 - if alt15 =3D=3D 1: # C.g:623:26: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: - break #loop15 - + break # loop15 =20 # C.g:623:37: ( Exponent )? alt16 =3D 2 LA16_0 =3D self.input.LA(1) =20 - if (LA16_0 =3D=3D u'E' or LA16_0 =3D=3D u'e') : + if (LA16_0 =3D=3D u'E' or LA16_0 =3D=3D u'e'): alt16 =3D 1 if alt16 =3D=3D 1: # C.g:623:37: Exponent self.mExponent() =20 - - - # C.g:623:47: ( FloatTypeSuffix )? alt17 =3D 2 LA17_0 =3D self.input.LA(1) =20 - if (LA17_0 =3D=3D u'D' or LA17_0 =3D=3D u'F' or LA17_0 =3D= =3D u'd' or LA17_0 =3D=3D u'f') : + if (LA17_0 =3D=3D u'D' or LA17_0 =3D=3D u'F' or LA17_0 =3D= =3D u'd' or LA17_0 =3D=3D u'f'): alt17 =3D 1 if alt17 =3D=3D 1: # C.g:623:47: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 2: # C.g:624:9: '.' ( '0' .. '9' )+ ( Exponent )? ( FloatType= Suffix )? self.match(u'.') =20 # C.g:624:13: ( '0' .. '9' )+ cnt18 =3D 0 - while True: #loop18 + while True: # loop18 alt18 =3D 2 LA18_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA18_0 <=3D u'9')) : + if ((u'0' <=3D LA18_0 <=3D u'9')): alt18 =3D 1 =20 - if alt18 =3D=3D 1: # C.g:624:14: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt18 >=3D 1: - break #loop18 + break # loop18 =20 eee =3D EarlyExitException(18, self.input) raise eee =20 cnt18 +=3D 1 =20 - # C.g:624:25: ( Exponent )? alt19 =3D 2 LA19_0 =3D self.input.LA(1) =20 - if (LA19_0 =3D=3D u'E' or LA19_0 =3D=3D u'e') : + if (LA19_0 =3D=3D u'E' or LA19_0 =3D=3D u'e'): alt19 =3D 1 if alt19 =3D=3D 1: # C.g:624:25: Exponent self.mExponent() =20 - - - # C.g:624:35: ( FloatTypeSuffix )? alt20 =3D 2 LA20_0 =3D self.input.LA(1) =20 - if (LA20_0 =3D=3D u'D' or LA20_0 =3D=3D u'F' or LA20_0 =3D= =3D u'd' or LA20_0 =3D=3D u'f') : + if (LA20_0 =3D=3D u'D' or LA20_0 =3D=3D u'F' or LA20_0 =3D= =3D u'd' or LA20_0 =3D=3D u'f'): alt20 =3D 1 if alt20 =3D=3D 1: # C.g:624:35: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 3: # C.g:625:9: ( '0' .. '9' )+ Exponent ( FloatTypeSuffix )? # C.g:625:9: ( '0' .. '9' )+ cnt21 =3D 0 - while True: #loop21 + while True: # loop21 alt21 =3D 2 LA21_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA21_0 <=3D u'9')) : + if ((u'0' <=3D LA21_0 <=3D u'9')): alt21 =3D 1 =20 - if alt21 =3D=3D 1: # C.g:625:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt21 >=3D 1: - break #loop21 + break # loop21 =20 eee =3D EarlyExitException(21, self.input) raise eee =20 cnt21 +=3D 1 =20 - self.mExponent() =20 # C.g:625:30: ( FloatTypeSuffix )? alt22 =3D 2 LA22_0 =3D self.input.LA(1) =20 - if (LA22_0 =3D=3D u'D' or LA22_0 =3D=3D u'F' or LA22_0 =3D= =3D u'd' or LA22_0 =3D=3D u'f') : + if (LA22_0 =3D=3D u'D' or LA22_0 =3D=3D u'F' or LA22_0 =3D= =3D u'd' or LA22_0 =3D=3D u'f'): alt22 =3D 1 if alt22 =3D=3D 1: # C.g:625:30: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 4: # C.g:626:9: ( '0' .. '9' )+ ( Exponent )? FloatTypeSuffix # C.g:626:9: ( '0' .. '9' )+ cnt23 =3D 0 - while True: #loop23 + while True: # loop23 alt23 =3D 2 LA23_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA23_0 <=3D u'9')) : + if ((u'0' <=3D LA23_0 <=3D u'9')): alt23 =3D 1 =20 - if alt23 =3D=3D 1: # C.g:626:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt23 >=3D 1: - break #loop23 + break # loop23 =20 eee =3D EarlyExitException(23, self.input) raise eee =20 cnt23 +=3D 1 =20 - # C.g:626:21: ( Exponent )? alt24 =3D 2 LA24_0 =3D self.input.LA(1) =20 - if (LA24_0 =3D=3D u'E' or LA24_0 =3D=3D u'e') : + if (LA24_0 =3D=3D u'E' or LA24_0 =3D=3D u'e'): alt24 =3D 1 if alt24 =3D=3D 1: # C.g:626:21: Exponent self.mExponent() =20 - - - self.mFloatTypeSuffix() =20 - - - finally: =20 pass =20 # $ANTLR end FLOATING_POINT_LITERAL =20 - - # $ANTLR start Exponent + def mExponent(self, ): =20 try: # C.g:630:10: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ ) # C.g:630:12: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ if self.input.LA(1) =3D=3D u'E' or self.input.LA(1) =3D=3D u'e= ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - # C.g:630:22: ( '+' | '-' )? alt26 =3D 2 LA26_0 =3D self.input.LA(1) =20 - if (LA26_0 =3D=3D u'+' or LA26_0 =3D=3D u'-') : + if (LA26_0 =3D=3D u'+' or LA26_0 =3D=3D u'-'): alt26 =3D 1 if alt26 =3D=3D 1: # C.g: if self.input.LA(1) =3D=3D u'+' or self.input.LA(1) =3D=3D= u'-': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - # C.g:630:33: ( '0' .. '9' )+ cnt27 =3D 0 - while True: #loop27 + while True: # loop27 alt27 =3D 2 LA27_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA27_0 <=3D u'9')) : + if ((u'0' <=3D LA27_0 <=3D u'9')): alt27 =3D 1 =20 - if alt27 =3D=3D 1: # C.g:630:34: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt27 >=3D 1: - break #loop27 + break # loop27 =20 eee =3D EarlyExitException(27, self.input) raise eee =20 cnt27 +=3D 1 =20 - - - - - finally: =20 pass =20 # $ANTLR end Exponent =20 - - # $ANTLR start FloatTypeSuffix + def mFloatTypeSuffix(self, ): =20 try: # C.g:633:17: ( ( 'f' | 'F' | 'd' | 'D' ) ) # C.g:633:19: ( 'f' | 'F' | 'd' | 'D' ) if self.input.LA(1) =3D=3D u'D' or self.input.LA(1) =3D=3D u'F= ' or self.input.LA(1) =3D=3D u'd' or self.input.LA(1) =3D=3D u'f': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end FloatTypeSuffix =20 - - # $ANTLR start EscapeSequence + def mEscapeSequence(self, ): =20 try: @@ -3204,20 +2491,22 @@ class CLexer(Lexer): alt28 =3D 2 LA28_0 =3D self.input.LA(1) =20 - if (LA28_0 =3D=3D u'\\') : + if (LA28_0 =3D=3D u'\\'): LA28_1 =3D self.input.LA(2) =20 - if (LA28_1 =3D=3D u'"' or LA28_1 =3D=3D u'\'' or LA28_1 = =3D=3D u'\\' or LA28_1 =3D=3D u'b' or LA28_1 =3D=3D u'f' or LA28_1 =3D=3D u= 'n' or LA28_1 =3D=3D u'r' or LA28_1 =3D=3D u't') : + if (LA28_1 =3D=3D u'"' or LA28_1 =3D=3D u'\'' or LA28_1 = =3D=3D u'\\' or LA28_1 =3D=3D u'b' or LA28_1 =3D=3D u'f' or LA28_1 =3D=3D u= 'n' or LA28_1 =3D=3D u'r' or LA28_1 =3D=3D u't'): alt28 =3D 1 - elif ((u'0' <=3D LA28_1 <=3D u'7')) : + elif ((u'0' <=3D LA28_1 <=3D u'7')): alt28 =3D 2 else: - nvae =3D NoViableAltException("635:1: fragment EscapeS= equence : ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' = ) | OctalEscape );", 28, 1, self.input) + nvae =3D NoViableAltException( + "635:1: fragment EscapeSequence : ( '\\\\' ( 'b' |= 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | OctalEscape );", 28, 1= , self.input) =20 raise nvae =20 else: - nvae =3D NoViableAltException("635:1: fragment EscapeSeque= nce : ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | = OctalEscape );", 28, 0, self.input) + nvae =3D NoViableAltException( + "635:1: fragment EscapeSequence : ( '\\\\' ( 'b' | 't'= | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | OctalEscape );", 28, 0, se= lf.input) =20 raise nvae =20 @@ -3226,32 +2515,25 @@ class CLexer(Lexer): self.match(u'\\') =20 if self.input.LA(1) =3D=3D u'"' or self.input.LA(1) =3D=3D= u'\'' or self.input.LA(1) =3D=3D u'\\' or self.input.LA(1) =3D=3D u'b' or = self.input.LA(1) =3D=3D u'f' or self.input.LA(1) =3D=3D u'n' or self.input.= LA(1) =3D=3D u'r' or self.input.LA(1) =3D=3D u't': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt28 =3D=3D 2: # C.g:638:9: OctalEscape self.mOctalEscape() =20 - - - finally: =20 pass =20 # $ANTLR end EscapeSequence =20 - - # $ANTLR start OctalEscape + def mOctalEscape(self, ): =20 try: @@ -3259,35 +2541,37 @@ class CLexer(Lexer): alt29 =3D 3 LA29_0 =3D self.input.LA(1) =20 - if (LA29_0 =3D=3D u'\\') : + if (LA29_0 =3D=3D u'\\'): LA29_1 =3D self.input.LA(2) =20 - if ((u'0' <=3D LA29_1 <=3D u'3')) : + if ((u'0' <=3D LA29_1 <=3D u'3')): LA29_2 =3D self.input.LA(3) =20 - if ((u'0' <=3D LA29_2 <=3D u'7')) : + if ((u'0' <=3D LA29_2 <=3D u'7')): LA29_4 =3D self.input.LA(4) =20 - if ((u'0' <=3D LA29_4 <=3D u'7')) : + if ((u'0' <=3D LA29_4 <=3D u'7')): alt29 =3D 1 else: alt29 =3D 2 else: alt29 =3D 3 - elif ((u'4' <=3D LA29_1 <=3D u'7')) : + elif ((u'4' <=3D LA29_1 <=3D u'7')): LA29_3 =3D self.input.LA(3) =20 - if ((u'0' <=3D LA29_3 <=3D u'7')) : + if ((u'0' <=3D LA29_3 <=3D u'7')): alt29 =3D 2 else: alt29 =3D 3 else: - nvae =3D NoViableAltException("641:1: fragment OctalEs= cape : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0'= .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );", 29, 1, self.input) + nvae =3D NoViableAltException( + "641:1: fragment OctalEscape : ( '\\\\' ( '0' .. '= 3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) |= '\\\\' ( '0' .. '7' ) );", 29, 1, self.input) =20 raise nvae =20 else: - nvae =3D NoViableAltException("641:1: fragment OctalEscape= : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. = '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );", 29, 0, self.input) + nvae =3D NoViableAltException( + "641:1: fragment OctalEscape : ( '\\\\' ( '0' .. '3' )= ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\= \\' ( '0' .. '7' ) );", 29, 0, self.input) =20 raise nvae =20 @@ -3299,25 +2583,14 @@ class CLexer(Lexer): # C.g:643:15: '0' .. '3' self.matchRange(u'0', u'3') =20 - - - # C.g:643:25: ( '0' .. '7' ) # C.g:643:26: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - # C.g:643:36: ( '0' .. '7' ) # C.g:643:37: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - elif alt29 =3D=3D 2: # C.g:644:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) self.match(u'\\') @@ -3326,18 +2599,10 @@ class CLexer(Lexer): # C.g:644:15: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - # C.g:644:25: ( '0' .. '7' ) # C.g:644:26: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - elif alt29 =3D=3D 3: # C.g:645:9: '\\\\' ( '0' .. '7' ) self.match(u'\\') @@ -3346,21 +2611,14 @@ class CLexer(Lexer): # C.g:645:15: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - - finally: =20 pass =20 # $ANTLR end OctalEscape =20 - - # $ANTLR start UnicodeEscape + def mUnicodeEscape(self, ): =20 try: @@ -3378,19 +2636,14 @@ class CLexer(Lexer): =20 self.mHexDigit() =20 - - - - finally: =20 pass =20 # $ANTLR end UnicodeEscape =20 - - # $ANTLR start WS + def mWS(self, ): =20 try: @@ -3399,20 +2652,16 @@ class CLexer(Lexer): # C.g:653:5: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) # C.g:653:8: ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) if (u'\t' <=3D self.input.LA(1) <=3D u'\n') or (u'\f' <=3D sel= f.input.LA(1) <=3D u'\r') or self.input.LA(1) =3D=3D u' ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3420,9 +2669,8 @@ class CLexer(Lexer): =20 # $ANTLR end WS =20 - - # $ANTLR start BS + def mBS(self, ): =20 try: @@ -3434,15 +2682,9 @@ class CLexer(Lexer): # C.g:657:8: '\\\\' self.match(u'\\') =20 - - - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3450,9 +2692,8 @@ class CLexer(Lexer): =20 # $ANTLR end BS =20 - - # $ANTLR start UnicodeVocabulary + def mUnicodeVocabulary(self, ): =20 try: @@ -3462,19 +2703,14 @@ class CLexer(Lexer): # C.g:665:7: '\\u0003' .. '\\uFFFE' self.matchRange(u'\u0003', u'\uFFFE') =20 - - - - finally: =20 pass =20 # $ANTLR end UnicodeVocabulary =20 - - # $ANTLR start COMMENT + def mCOMMENT(self, ): =20 try: @@ -3484,44 +2720,34 @@ class CLexer(Lexer): # C.g:668:9: '/*' ( options {greedy=3Dfalse; } : . )* '*/' self.match("/*") =20 - # C.g:668:14: ( options {greedy=3Dfalse; } : . )* - while True: #loop30 + while True: # loop30 alt30 =3D 2 LA30_0 =3D self.input.LA(1) =20 - if (LA30_0 =3D=3D u'*') : + if (LA30_0 =3D=3D u'*'): LA30_1 =3D self.input.LA(2) =20 - if (LA30_1 =3D=3D u'/') : + if (LA30_1 =3D=3D u'/'): alt30 =3D 2 - elif ((u'\u0000' <=3D LA30_1 <=3D u'.') or (u'0' <=3D = LA30_1 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA30_1 <=3D u'.') or (u'0' <=3D = LA30_1 <=3D u'\uFFFE')): alt30 =3D 1 =20 - - elif ((u'\u0000' <=3D LA30_0 <=3D u')') or (u'+' <=3D LA30= _0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA30_0 <=3D u')') or (u'+' <=3D LA30= _0 <=3D u'\uFFFE')): alt30 =3D 1 =20 - if alt30 =3D=3D 1: # C.g:668:42: . self.matchAny() =20 - - else: - break #loop30 - + break # loop30 =20 self.match("*/") =20 - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3529,9 +2755,8 @@ class CLexer(Lexer): =20 # $ANTLR end COMMENT =20 - - # $ANTLR start LINE_COMMENT + def mLINE_COMMENT(self, ): =20 try: @@ -3541,54 +2766,42 @@ class CLexer(Lexer): # C.g:673:7: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' self.match("//") =20 - # C.g:673:12: (~ ( '\\n' | '\\r' ) )* - while True: #loop31 + while True: # loop31 alt31 =3D 2 LA31_0 =3D self.input.LA(1) =20 - if ((u'\u0000' <=3D LA31_0 <=3D u'\t') or (u'\u000B' <=3D = LA31_0 <=3D u'\f') or (u'\u000E' <=3D LA31_0 <=3D u'\uFFFE')) : + if ((u'\u0000' <=3D LA31_0 <=3D u'\t') or (u'\u000B' <=3D = LA31_0 <=3D u'\f') or (u'\u000E' <=3D LA31_0 <=3D u'\uFFFE')): alt31 =3D 1 =20 - if alt31 =3D=3D 1: # C.g:673:12: ~ ( '\\n' | '\\r' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'\t') or (u'= \u000B' <=3D self.input.LA(1) <=3D u'\f') or (u'\u000E' <=3D self.input.LA(= 1) <=3D u'\uFFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop31 - + break # loop31 =20 # C.g:673:26: ( '\\r' )? alt32 =3D 2 LA32_0 =3D self.input.LA(1) =20 - if (LA32_0 =3D=3D u'\r') : + if (LA32_0 =3D=3D u'\r'): alt32 =3D 1 if alt32 =3D=3D 1: # C.g:673:26: '\\r' self.match(u'\r') =20 - - - self.match(u'\n') =20 - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3596,9 +2809,8 @@ class CLexer(Lexer): =20 # $ANTLR end LINE_COMMENT =20 - - # $ANTLR start LINE_COMMAND + def mLINE_COMMAND(self, ): =20 try: @@ -3609,52 +2821,41 @@ class CLexer(Lexer): self.match(u'#') =20 # C.g:678:11: (~ ( '\\n' | '\\r' ) )* - while True: #loop33 + while True: # loop33 alt33 =3D 2 LA33_0 =3D self.input.LA(1) =20 - if ((u'\u0000' <=3D LA33_0 <=3D u'\t') or (u'\u000B' <=3D = LA33_0 <=3D u'\f') or (u'\u000E' <=3D LA33_0 <=3D u'\uFFFE')) : + if ((u'\u0000' <=3D LA33_0 <=3D u'\t') or (u'\u000B' <=3D = LA33_0 <=3D u'\f') or (u'\u000E' <=3D LA33_0 <=3D u'\uFFFE')): alt33 =3D 1 =20 - if alt33 =3D=3D 1: # C.g:678:11: ~ ( '\\n' | '\\r' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'\t') or (u'= \u000B' <=3D self.input.LA(1) <=3D u'\f') or (u'\u000E' <=3D self.input.LA(= 1) <=3D u'\uFFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop33 - + break # loop33 =20 # C.g:678:25: ( '\\r' )? alt34 =3D 2 LA34_0 =3D self.input.LA(1) =20 - if (LA34_0 =3D=3D u'\r') : + if (LA34_0 =3D=3D u'\r'): alt34 =3D 1 if alt34 =3D=3D 1: # C.g:678:25: '\\r' self.match(u'\r') =20 - - - self.match(u'\n') =20 - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3662,8 +2863,6 @@ class CLexer(Lexer): =20 # $ANTLR end LINE_COMMAND =20 - - def mTokens(self): # C.g:1:8: ( T25 | T26 | T27 | T28 | T29 | T30 | T31 | T32 | T33 |= T34 | T35 | T36 | T37 | T38 | T39 | T40 | T41 | T42 | T43 | T44 | T45 | T4= 6 | T47 | T48 | T49 | T50 | T51 | T52 | T53 | T54 | T55 | T56 | T57 | T58 |= T59 | T60 | T61 | T62 | T63 | T64 | T65 | T66 | T67 | T68 | T69 | T70 | T7= 1 | T72 | T73 | T74 | T75 | T76 | T77 | T78 | T79 | T80 | T81 | T82 | T83 |= T84 | T85 | T86 | T87 | T88 | T89 | T90 | T91 | T92 | T93 | T94 | T95 | T9= 6 | T97 | T98 | T99 | T100 | T101 | T102 | T103 | T104 | T105 | T106 | T107= | T108 | T109 | T110 | T111 | T112 | T113 | T114 | T115 | T116 | T117 | ID= ENTIFIER | CHARACTER_LITERAL | STRING_LITERAL | HEX_LITERAL | DECIMAL_LITER= AL | OCTAL_LITERAL | FLOATING_POINT_LITERAL | WS | BS | UnicodeVocabulary |= COMMENT | LINE_COMMENT | LINE_COMMAND ) alt35 =3D 106 @@ -3672,681 +2871,463 @@ class CLexer(Lexer): # C.g:1:10: T25 self.mT25() =20 - - elif alt35 =3D=3D 2: # C.g:1:14: T26 self.mT26() =20 - - elif alt35 =3D=3D 3: # C.g:1:18: T27 self.mT27() =20 - - elif alt35 =3D=3D 4: # C.g:1:22: T28 self.mT28() =20 - - elif alt35 =3D=3D 5: # C.g:1:26: T29 self.mT29() =20 - - elif alt35 =3D=3D 6: # C.g:1:30: T30 self.mT30() =20 - - elif alt35 =3D=3D 7: # C.g:1:34: T31 self.mT31() =20 - - elif alt35 =3D=3D 8: # C.g:1:38: T32 self.mT32() =20 - - elif alt35 =3D=3D 9: # C.g:1:42: T33 self.mT33() =20 - - elif alt35 =3D=3D 10: # C.g:1:46: T34 self.mT34() =20 - - elif alt35 =3D=3D 11: # C.g:1:50: T35 self.mT35() =20 - - elif alt35 =3D=3D 12: # C.g:1:54: T36 self.mT36() =20 - - elif alt35 =3D=3D 13: # C.g:1:58: T37 self.mT37() =20 - - elif alt35 =3D=3D 14: # C.g:1:62: T38 self.mT38() =20 - - elif alt35 =3D=3D 15: # C.g:1:66: T39 self.mT39() =20 - - elif alt35 =3D=3D 16: # C.g:1:70: T40 self.mT40() =20 - - elif alt35 =3D=3D 17: # C.g:1:74: T41 self.mT41() =20 - - elif alt35 =3D=3D 18: # C.g:1:78: T42 self.mT42() =20 - - elif alt35 =3D=3D 19: # C.g:1:82: T43 self.mT43() =20 - - elif alt35 =3D=3D 20: # C.g:1:86: T44 self.mT44() =20 - - elif alt35 =3D=3D 21: # C.g:1:90: T45 self.mT45() =20 - - elif alt35 =3D=3D 22: # C.g:1:94: T46 self.mT46() =20 - - elif alt35 =3D=3D 23: # C.g:1:98: T47 self.mT47() =20 - - elif alt35 =3D=3D 24: # C.g:1:102: T48 self.mT48() =20 - - elif alt35 =3D=3D 25: # C.g:1:106: T49 self.mT49() =20 - - elif alt35 =3D=3D 26: # C.g:1:110: T50 self.mT50() =20 - - elif alt35 =3D=3D 27: # C.g:1:114: T51 self.mT51() =20 - - elif alt35 =3D=3D 28: # C.g:1:118: T52 self.mT52() =20 - - elif alt35 =3D=3D 29: # C.g:1:122: T53 self.mT53() =20 - - elif alt35 =3D=3D 30: # C.g:1:126: T54 self.mT54() =20 - - elif alt35 =3D=3D 31: # C.g:1:130: T55 self.mT55() =20 - - elif alt35 =3D=3D 32: # C.g:1:134: T56 self.mT56() =20 - - elif alt35 =3D=3D 33: # C.g:1:138: T57 self.mT57() =20 - - elif alt35 =3D=3D 34: # C.g:1:142: T58 self.mT58() =20 - - elif alt35 =3D=3D 35: # C.g:1:146: T59 self.mT59() =20 - - elif alt35 =3D=3D 36: # C.g:1:150: T60 self.mT60() =20 - - elif alt35 =3D=3D 37: # C.g:1:154: T61 self.mT61() =20 - - elif alt35 =3D=3D 38: # C.g:1:158: T62 self.mT62() =20 - - elif alt35 =3D=3D 39: # C.g:1:162: T63 self.mT63() =20 - - elif alt35 =3D=3D 40: # C.g:1:166: T64 self.mT64() =20 - - elif alt35 =3D=3D 41: # C.g:1:170: T65 self.mT65() =20 - - elif alt35 =3D=3D 42: # C.g:1:174: T66 self.mT66() =20 - - elif alt35 =3D=3D 43: # C.g:1:178: T67 self.mT67() =20 - - elif alt35 =3D=3D 44: # C.g:1:182: T68 self.mT68() =20 - - elif alt35 =3D=3D 45: # C.g:1:186: T69 self.mT69() =20 - - elif alt35 =3D=3D 46: # C.g:1:190: T70 self.mT70() =20 - - elif alt35 =3D=3D 47: # C.g:1:194: T71 self.mT71() =20 - - elif alt35 =3D=3D 48: # C.g:1:198: T72 self.mT72() =20 - - elif alt35 =3D=3D 49: # C.g:1:202: T73 self.mT73() =20 - - elif alt35 =3D=3D 50: # C.g:1:206: T74 self.mT74() =20 - - elif alt35 =3D=3D 51: # C.g:1:210: T75 self.mT75() =20 - - elif alt35 =3D=3D 52: # C.g:1:214: T76 self.mT76() =20 - - elif alt35 =3D=3D 53: # C.g:1:218: T77 self.mT77() =20 - - elif alt35 =3D=3D 54: # C.g:1:222: T78 self.mT78() =20 - - elif alt35 =3D=3D 55: # C.g:1:226: T79 self.mT79() =20 - - elif alt35 =3D=3D 56: # C.g:1:230: T80 self.mT80() =20 - - elif alt35 =3D=3D 57: # C.g:1:234: T81 self.mT81() =20 - - elif alt35 =3D=3D 58: # C.g:1:238: T82 self.mT82() =20 - - elif alt35 =3D=3D 59: # C.g:1:242: T83 self.mT83() =20 - - elif alt35 =3D=3D 60: # C.g:1:246: T84 self.mT84() =20 - - elif alt35 =3D=3D 61: # C.g:1:250: T85 self.mT85() =20 - - elif alt35 =3D=3D 62: # C.g:1:254: T86 self.mT86() =20 - - elif alt35 =3D=3D 63: # C.g:1:258: T87 self.mT87() =20 - - elif alt35 =3D=3D 64: # C.g:1:262: T88 self.mT88() =20 - - elif alt35 =3D=3D 65: # C.g:1:266: T89 self.mT89() =20 - - elif alt35 =3D=3D 66: # C.g:1:270: T90 self.mT90() =20 - - elif alt35 =3D=3D 67: # C.g:1:274: T91 self.mT91() =20 - - elif alt35 =3D=3D 68: # C.g:1:278: T92 self.mT92() =20 - - elif alt35 =3D=3D 69: # C.g:1:282: T93 self.mT93() =20 - - elif alt35 =3D=3D 70: # C.g:1:286: T94 self.mT94() =20 - - elif alt35 =3D=3D 71: # C.g:1:290: T95 self.mT95() =20 - - elif alt35 =3D=3D 72: # C.g:1:294: T96 self.mT96() =20 - - elif alt35 =3D=3D 73: # C.g:1:298: T97 self.mT97() =20 - - elif alt35 =3D=3D 74: # C.g:1:302: T98 self.mT98() =20 - - elif alt35 =3D=3D 75: # C.g:1:306: T99 self.mT99() =20 - - elif alt35 =3D=3D 76: # C.g:1:310: T100 self.mT100() =20 - - elif alt35 =3D=3D 77: # C.g:1:315: T101 self.mT101() =20 - - elif alt35 =3D=3D 78: # C.g:1:320: T102 self.mT102() =20 - - elif alt35 =3D=3D 79: # C.g:1:325: T103 self.mT103() =20 - - elif alt35 =3D=3D 80: # C.g:1:330: T104 self.mT104() =20 - - elif alt35 =3D=3D 81: # C.g:1:335: T105 self.mT105() =20 - - elif alt35 =3D=3D 82: # C.g:1:340: T106 self.mT106() =20 - - elif alt35 =3D=3D 83: # C.g:1:345: T107 self.mT107() =20 - - elif alt35 =3D=3D 84: # C.g:1:350: T108 self.mT108() =20 - - elif alt35 =3D=3D 85: # C.g:1:355: T109 self.mT109() =20 - - elif alt35 =3D=3D 86: # C.g:1:360: T110 self.mT110() =20 - - elif alt35 =3D=3D 87: # C.g:1:365: T111 self.mT111() =20 - - elif alt35 =3D=3D 88: # C.g:1:370: T112 self.mT112() =20 - - elif alt35 =3D=3D 89: # C.g:1:375: T113 self.mT113() =20 - - elif alt35 =3D=3D 90: # C.g:1:380: T114 self.mT114() =20 - - elif alt35 =3D=3D 91: # C.g:1:385: T115 self.mT115() =20 - - elif alt35 =3D=3D 92: # C.g:1:390: T116 self.mT116() =20 - - elif alt35 =3D=3D 93: # C.g:1:395: T117 self.mT117() =20 - - elif alt35 =3D=3D 94: # C.g:1:400: IDENTIFIER self.mIDENTIFIER() =20 - - elif alt35 =3D=3D 95: # C.g:1:411: CHARACTER_LITERAL self.mCHARACTER_LITERAL() =20 - - elif alt35 =3D=3D 96: # C.g:1:429: STRING_LITERAL self.mSTRING_LITERAL() =20 - - elif alt35 =3D=3D 97: # C.g:1:444: HEX_LITERAL self.mHEX_LITERAL() =20 - - elif alt35 =3D=3D 98: # C.g:1:456: DECIMAL_LITERAL self.mDECIMAL_LITERAL() =20 - - elif alt35 =3D=3D 99: # C.g:1:472: OCTAL_LITERAL self.mOCTAL_LITERAL() =20 - - elif alt35 =3D=3D 100: # C.g:1:486: FLOATING_POINT_LITERAL self.mFLOATING_POINT_LITERAL() =20 - - elif alt35 =3D=3D 101: # C.g:1:509: WS self.mWS() =20 - - elif alt35 =3D=3D 102: # C.g:1:512: BS self.mBS() =20 - - elif alt35 =3D=3D 103: # C.g:1:515: UnicodeVocabulary self.mUnicodeVocabulary() =20 - - elif alt35 =3D=3D 104: # C.g:1:533: COMMENT self.mCOMMENT() =20 - - elif alt35 =3D=3D 105: # C.g:1:541: LINE_COMMENT self.mLINE_COMMENT() =20 - - elif alt35 =3D=3D 106: # C.g:1:554: LINE_COMMAND self.mLINE_COMMAND() =20 - - - - - - - # lookup tables for DFA #25 =20 DFA25_eot =3D DFA.unpack( u"\7\uffff\1\10\2\uffff" - ) + ) =20 DFA25_eof =3D DFA.unpack( u"\12\uffff" - ) + ) =20 DFA25_min =3D DFA.unpack( u"\2\56\2\uffff\1\53\1\uffff\2\60\2\uffff" - ) + ) =20 DFA25_max =3D DFA.unpack( u"\1\71\1\146\2\uffff\1\71\1\uffff\1\71\1\146\2\uffff" - ) + ) =20 DFA25_accept =3D DFA.unpack( u"\2\uffff\1\2\1\1\1\uffff\1\4\2\uffff\2\3" - ) + ) =20 DFA25_special =3D DFA.unpack( u"\12\uffff" - ) - + ) =20 DFA25_transition =3D [ DFA.unpack(u"\1\2\1\uffff\12\1"), DFA.unpack(u"\1\3\1\uffff\12\1\12\uffff\1\5\1\4\1\5\35\uffff\1\5" - u"\1\4\1\5"), + u"\1\4\1\5"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\6\1\uffff\1\6\2\uffff\12\7"), DFA.unpack(u""), DFA.unpack(u"\12\7"), DFA.unpack(u"\12\7\12\uffff\1\11\1\uffff\1\11\35\uffff\1\11\1\ufff= f" - u"\1\11"), + u"\1\11"), DFA.unpack(u""), DFA.unpack(u"") ] @@ -4376,11 +3357,11 @@ class CLexer(Lexer): u"\uffff\1\u0164\1\u0165\1\76\1\u0167\3\76\6\uffff\1\u016b\1\uffff" u"\3\76\1\uffff\21\76\1\u0180\2\76\1\uffff\3\76\1\u0186\1\76\1\uff= ff" u"\11\76\1\u0191\1\uffff" - ) + ) =20 DFA35_eof =3D DFA.unpack( u"\u0192\uffff" - ) + ) =20 DFA35_min =3D DFA.unpack( u"\1\3\1\uffff\1\171\1\uffff\1\75\1\154\1\150\1\165\1\145\1\124\1" @@ -4413,7 +3394,7 @@ class CLexer(Lexer): u"\1\111\1\137\1\122\1\103\1\111\1\126\1\105\1\106\1\111\1\44\1\13= 7" u"\1\103\1\uffff\1\125\1\105\1\116\1\44\1\122\1\uffff\1\105\1\106" u"\1\105\1\122\1\105\1\116\1\103\1\105\1\104\1\44\1\uffff" - ) + ) =20 DFA35_max =3D DFA.unpack( u"\1\ufffe\1\uffff\1\171\1\uffff\1\75\1\170\1\167\1\165\1\145\1\12= 4" @@ -4447,7 +3428,7 @@ class CLexer(Lexer): u"\1\106\1\111\1\172\1\137\1\103\1\uffff\1\125\1\105\1\116\1\172" u"\1\122\1\uffff\1\105\1\106\1\105\1\122\1\105\1\116\1\103\1\105" u"\1\104\1\172\1\uffff" - ) + ) =20 DFA35_accept =3D DFA.unpack( u"\1\uffff\1\1\1\uffff\1\3\15\uffff\1\23\1\24\1\27\10\uffff\1\46" @@ -4467,21 +3448,20 @@ class CLexer(Lexer): u"\uffff\1\42\1\45\1\uffff\1\2\3\uffff\1\123\7\uffff\1\117\1\10\1" u"\32\1\133\1\22\1\35\1\uffff\1\40\3\uffff\1\37\24\uffff\1\43\5\uf= fff" u"\1\44\12\uffff\1\41" - ) + ) =20 DFA35_special =3D DFA.unpack( u"\u0192\uffff" - ) - + ) =20 DFA35_transition =3D [ DFA.unpack(u"\6\73\2\70\1\73\2\70\22\73\1\70\1\50\1\65\1\72\1\63" - u"\1\45\1\46\1\64\1\34\1\35\1\40\1\42\1\3\1\43\1\41\1\44\1\66\11" - u"\67\1\23\1\1\1\51\1\4\1\52\1\55\1\73\2\63\1\26\1\63\1\32\1\63\1" - u"\31\1\63\1\24\2\63\1\62\2\63\1\25\1\33\2\63\1\11\1\63\1\27\1\30" - u"\4\63\1\36\1\71\1\37\1\53\1\56\1\73\1\7\1\61\1\13\1\17\1\5\1\16" - u"\1\60\1\63\1\14\2\63\1\15\5\63\1\10\1\6\1\2\1\20\1\12\1\57\3\63" - u"\1\21\1\54\1\22\1\47\uff80\73"), + u"\1\45\1\46\1\64\1\34\1\35\1\40\1\42\1\3\1\43\1\41\1\4= 4\1\66\11" + u"\67\1\23\1\1\1\51\1\4\1\52\1\55\1\73\2\63\1\26\1\63\1= \32\1\63\1" + u"\31\1\63\1\24\2\63\1\62\2\63\1\25\1\33\2\63\1\11\1\63= \1\27\1\30" + u"\4\63\1\36\1\71\1\37\1\53\1\56\1\73\1\7\1\61\1\13\1\1= 7\1\5\1\16" + u"\1\60\1\63\1\14\2\63\1\15\5\63\1\10\1\6\1\2\1\20\1\12= \1\57\3\63" + u"\1\21\1\54\1\22\1\47\uff80\73"), DFA.unpack(u""), DFA.unpack(u"\1\75"), DFA.unpack(u""), @@ -4536,7 +3516,7 @@ class CLexer(Lexer): DFA.unpack(u"\47\u0092\1\uffff\uffd7\u0092"), DFA.unpack(u"\uffff\u0091"), DFA.unpack(u"\1\154\1\uffff\10\u0094\2\154\12\uffff\3\154\21\uffff" - u"\1\u0093\13\uffff\3\154\21\uffff\1\u0093"), + u"\1\u0093\13\uffff\3\154\21\uffff\1\u0093"), DFA.unpack(u"\1\154\1\uffff\12\u0096\12\uffff\3\154\35\uffff\3\154= "), DFA.unpack(u""), DFA.unpack(u""), @@ -4563,20 +3543,20 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00ab"), DFA.unpack(u"\1\u00ac"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00ae"), DFA.unpack(u"\1\u00af"), DFA.unpack(u"\1\u00b0"), DFA.unpack(u"\1\u00b1"), DFA.unpack(u"\1\u00b2"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\24\76\1\u00b3\5\76"), + u"\24\76\1\u00b3\5\76"), DFA.unpack(u"\1\u00b6\11\uffff\1\u00b5"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00b8"), DFA.unpack(u"\1\u00b9"), DFA.unpack(u"\1\u00ba"), @@ -4634,7 +3614,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\154\1\uffff\10\u0094\2\154\12\uffff\3\154\35\uffff" - u"\3\154"), + u"\3\154"), DFA.unpack(u""), DFA.unpack(u"\1\154\1\uffff\12\u0096\12\uffff\3\154\35\uffff\3\154= "), DFA.unpack(u""), @@ -4661,10 +3641,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00dd"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00df"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00e1"), DFA.unpack(u"\1\u00e2"), DFA.unpack(u"\1\u00e3"), @@ -4674,7 +3654,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u00e6"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00e8"), DFA.unpack(u"\1\u00e9"), DFA.unpack(u"\1\u00ea"), @@ -4693,10 +3673,10 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u00f4"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00f6"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00f8"), DFA.unpack(u"\1\u00f9"), DFA.unpack(u"\1\u00fa"), @@ -4704,22 +3684,22 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00fc"), DFA.unpack(u"\1\u00fd"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00ff"), DFA.unpack(u"\1\u0100"), DFA.unpack(u"\1\u0101"), DFA.unpack(u"\1\u0102"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0105"), DFA.unpack(u"\1\u0106"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0109"), DFA.unpack(u"\1\u010a"), @@ -4737,10 +3717,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0116"), DFA.unpack(u"\1\u0117"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0119"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u011b"), DFA.unpack(u"\1\u011c"), DFA.unpack(u""), @@ -4752,7 +3732,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0121"), DFA.unpack(u"\1\u0122"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0124"), DFA.unpack(u"\1\u0125"), @@ -4762,19 +3742,19 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u0128"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u012b"), DFA.unpack(u"\1\u012c"), DFA.unpack(u"\1\u012d"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u012f"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0131"), DFA.unpack(u"\1\u0132"), DFA.unpack(u"\1\u0133"), @@ -4783,39 +3763,39 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0136"), DFA.unpack(u"\1\u0137"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\u0138\1" - u"\uffff\32\76"), + u"\uffff\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u013c"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0143"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0146"), DFA.unpack(u"\1\u0147"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\u0148"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u014a"), DFA.unpack(u""), DFA.unpack(u"\1\u014b"), @@ -4826,15 +3806,15 @@ class CLexer(Lexer): DFA.unpack(u"\1\u014f"), DFA.unpack(u"\1\u0150"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0153"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), @@ -4847,7 +3827,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0156"), DFA.unpack(u"\1\u0157"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0159"), DFA.unpack(u"\1\u015a"), @@ -4859,22 +3839,22 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0166"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0168"), DFA.unpack(u"\1\u0169"), DFA.unpack(u"\1\u016a"), @@ -4885,7 +3865,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u016c"), DFA.unpack(u"\1\u016d"), @@ -4909,7 +3889,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u017e"), DFA.unpack(u"\1\u017f"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0181"), DFA.unpack(u"\1\u0182"), DFA.unpack(u""), @@ -4917,7 +3897,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0184"), DFA.unpack(u"\1\u0185"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0187"), DFA.unpack(u""), DFA.unpack(u"\1\u0188"), @@ -4930,12 +3910,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u018f"), DFA.unpack(u"\1\u0190"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"") ] =20 # class definition for DFA #35 =20 DFA35 =3D DFA - - diff --git a/BaseTools/Source/Python/Ecc/CParser3/CParser.py b/BaseTools/So= urce/Python/Ecc/CParser3/CParser.py index b078397969f9..aaba24b977ea 100644 --- a/BaseTools/Source/Python/Ecc/CParser3/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser3/CParser.py @@ -5,7 +5,7 @@ from __future__ import absolute_import from antlr3 import * from antlr3.compat import set, frozenset =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY THIS FILE. @@ -22,33 +22,32 @@ from Ecc import CodeFragment from Ecc import FileProfile =20 =20 - # for convenience in actions HIDDEN =3D BaseRecognizer.HIDDEN =20 # token types -BS=3D20 -LINE_COMMENT=3D23 -FloatTypeSuffix=3D16 -IntegerTypeSuffix=3D14 -LETTER=3D11 -OCTAL_LITERAL=3D6 -CHARACTER_LITERAL=3D8 -Exponent=3D15 -EOF=3D-1 -HexDigit=3D13 -STRING_LITERAL=3D9 -WS=3D19 -FLOATING_POINT_LITERAL=3D10 -IDENTIFIER=3D4 -UnicodeEscape=3D18 -LINE_COMMAND=3D24 -UnicodeVocabulary=3D21 -HEX_LITERAL=3D5 -COMMENT=3D22 -DECIMAL_LITERAL=3D7 -EscapeSequence=3D12 -OctalEscape=3D17 +BS =3D 20 +LINE_COMMENT =3D 23 +FloatTypeSuffix =3D 16 +IntegerTypeSuffix =3D 14 +LETTER =3D 11 +OCTAL_LITERAL =3D 6 +CHARACTER_LITERAL =3D 8 +Exponent =3D 15 +EOF =3D -1 +HexDigit =3D 13 +STRING_LITERAL =3D 9 +WS =3D 19 +FLOATING_POINT_LITERAL =3D 10 +IDENTIFIER =3D 4 +UnicodeEscape =3D 18 +LINE_COMMAND =3D 24 +UnicodeVocabulary =3D 21 +HEX_LITERAL =3D 5 +COMMENT =3D 22 +DECIMAL_LITERAL =3D 7 +EscapeSequence =3D 12 +OctalEscape =3D 17 =20 # token names tokenNames =3D [ @@ -81,6 +80,8 @@ class function_definition_scope(object): self.LBOffset =3D None self.DeclLine =3D None self.DeclOffset =3D None + + class postfix_expression_scope(object): def __init__(self): self.FuncCallText =3D None @@ -98,41 +99,46 @@ class CParser(Parser): self.postfix_expression_stack =3D [] =20 def printTokenInfo(self, line, offset, tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Start= Offset), (EndLine, EndOffset)) - FileProfile.PredicateExpressionList.append(PredExp) + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.PredicateExpressionList.append(PredExp) =20 def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) - FileProfile.EnumerationDefinitionList.append(EnumDef) + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.EnumerationDefinitionList.append(EnumDef) =20 def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Start= Offset), (EndLine, EndOffset)) - FileProfile.StructUnionDefinitionList.append(SUDef) + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.StructUnionDefinitionList.append(SUDef) =20 def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLine= , StartOffset), (EndLine, EndOffset)) - FileProfile.TypedefDefinitionList.append(Tdef) + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) + FileProfile.TypedefDefinitionList.append(Tdef) =20 def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText, = (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBraceOf= fset), (DeclLine, DeclOffset)) - FileProfile.FunctionDefinitionList.append(FuncDef) + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) + FileProfile.FunctionDefinitionList.append(FuncDef) =20 def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclText,= (StartLine, StartOffset), (EndLine, EndOffset)) - FileProfile.VariableDeclarationList.append(VarDecl) + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) + FileProfile.VariableDeclarationList.append(VarDecl) =20 def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (Star= tLine, StartOffset), (EndLine, EndOffset)) - FileProfile.FunctionCallingList.append(FuncCall) - - - + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) + FileProfile.FunctionCallingList.append(FuncCall) =20 # $ANTLR start translation_unit # C.g:102:1: translation_unit : ( external_declaration )* ; + def translation_unit(self, ): =20 translation_unit_StartIndex =3D self.input.index() @@ -144,30 +150,24 @@ class CParser(Parser): # C.g:103:2: ( ( external_declaration )* ) # C.g:103:4: ( external_declaration )* # C.g:103:4: ( external_declaration )* - while True: #loop1 + while True: # loop1 alt1 =3D 2 LA1_0 =3D self.input.LA(1) =20 - if (LA1_0 =3D=3D IDENTIFIER or LA1_0 =3D=3D 26 or (29 = <=3D LA1_0 <=3D 42) or (45 <=3D LA1_0 <=3D 46) or (48 <=3D LA1_0 <=3D 62) o= r LA1_0 =3D=3D 66) : + if (LA1_0 =3D=3D IDENTIFIER or LA1_0 =3D=3D 26 or (29 = <=3D LA1_0 <=3D 42) or (45 <=3D LA1_0 <=3D 46) or (48 <=3D LA1_0 <=3D 62) o= r LA1_0 =3D=3D 66): alt1 =3D 1 =20 - if alt1 =3D=3D 1: # C.g:0:0: external_declaration - self.following.append(self.FOLLOW_external_declara= tion_in_translation_unit74) + self.following.append( + self.FOLLOW_external_declaration_in_translatio= n_unit74) self.external_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop1 - - - - - + break # loop1 =20 except RecognitionException as re: self.reportError(re) @@ -182,9 +182,9 @@ class CParser(Parser): =20 # $ANTLR end translation_unit =20 - # $ANTLR start external_declaration # C.g:114:1: external_declaration options {k=3D1; } : ( ( ( declaratio= n_specifiers )? declarator ( declaration )* '{' )=3D> function_definition |= declaration | macro_statement ( ';' )? ); + def external_declaration(self, ): =20 external_declaration_StartIndex =3D self.input.index() @@ -197,316 +197,335 @@ class CParser(Parser): alt3 =3D 3 LA3_0 =3D self.input.LA(1) =20 - if ((29 <=3D LA3_0 <=3D 33)) : + if ((29 <=3D LA3_0 <=3D 33)): LA3_1 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 1, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 1, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 34) : + elif (LA3_0 =3D=3D 34): LA3_2 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 2, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 2, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 35) : + elif (LA3_0 =3D=3D 35): LA3_3 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 3, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 3, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 36) : + elif (LA3_0 =3D=3D 36): LA3_4 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 4, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 4, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 37) : + elif (LA3_0 =3D=3D 37): LA3_5 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 5, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 5, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 38) : + elif (LA3_0 =3D=3D 38): LA3_6 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 6, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 6, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 39) : + elif (LA3_0 =3D=3D 39): LA3_7 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 7, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 7, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 40) : + elif (LA3_0 =3D=3D 40): LA3_8 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 8, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 8, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 41) : + elif (LA3_0 =3D=3D 41): LA3_9 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 9, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 9, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 42) : + elif (LA3_0 =3D=3D 42): LA3_10 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 10, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 10, self= .input) =20 raise nvae =20 - elif ((45 <=3D LA3_0 <=3D 46)) : + elif ((45 <=3D LA3_0 <=3D 46)): LA3_11 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 11, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 11, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 48) : + elif (LA3_0 =3D=3D 48): LA3_12 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 12, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 12, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D IDENTIFIER) : + elif (LA3_0 =3D=3D IDENTIFIER): LA3_13 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 - elif (True) : + elif (True): alt3 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 13, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 13, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 58) : + elif (LA3_0 =3D=3D 58): LA3_14 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 14, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 14, self= .input) =20 raise nvae =20 elif (LA3_0 =3D=3D 66) and (self.synpred4()): alt3 =3D 1 - elif (LA3_0 =3D=3D 59) : + elif (LA3_0 =3D=3D 59): LA3_16 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 16, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 16, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 60) : + elif (LA3_0 =3D=3D 60): LA3_17 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 17, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 17, self= .input) =20 raise nvae =20 - elif ((49 <=3D LA3_0 <=3D 57) or LA3_0 =3D=3D 61) : + elif ((49 <=3D LA3_0 <=3D 57) or LA3_0 =3D=3D 61): LA3_18 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 18, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 18, self= .input) =20 raise nvae =20 elif (LA3_0 =3D=3D 62) and (self.synpred4()): alt3 =3D 1 - elif (LA3_0 =3D=3D 26) : + elif (LA3_0 =3D=3D 26): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_declara= tion options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( decla= ration )* '{' )=3D> function_definition | declaration | macro_statement ( '= ;' )? );", 3, 0, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; } : (= ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> functi= on_definition | declaration | macro_statement ( ';' )? );", 3, 0, self.inpu= t) =20 raise nvae =20 if alt3 =3D=3D 1: # C.g:119:4: ( ( declaration_specifiers )? declarator = ( declaration )* '{' )=3D> function_definition - self.following.append(self.FOLLOW_function_definition_= in_external_declaration113) + self.following.append( + self.FOLLOW_function_definition_in_external_declar= ation113) self.function_definition() self.following.pop() if self.failed: return =20 - elif alt3 =3D=3D 2: # C.g:120:4: declaration - self.following.append(self.FOLLOW_declaration_in_exter= nal_declaration118) + self.following.append( + self.FOLLOW_declaration_in_external_declaration118) self.declaration() self.following.pop() if self.failed: return =20 - elif alt3 =3D=3D 3: # C.g:121:4: macro_statement ( ';' )? - self.following.append(self.FOLLOW_macro_statement_in_e= xternal_declaration123) + self.following.append( + self.FOLLOW_macro_statement_in_external_declaratio= n123) self.macro_statement() self.following.pop() if self.failed: @@ -515,19 +534,15 @@ class CParser(Parser): alt2 =3D 2 LA2_0 =3D self.input.LA(1) =20 - if (LA2_0 =3D=3D 25) : + if (LA2_0 =3D=3D 25): alt2 =3D 1 if alt2 =3D=3D 1: # C.g:121:21: ';' - self.match(self.input, 25, self.FOLLOW_25_in_exter= nal_declaration126) + self.match(self.input, 25, + self.FOLLOW_25_in_external_declaration1= 26) if self.failed: return =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -546,10 +561,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start function_definition # C.g:126:1: function_definition : (d=3D declaration_specifiers )? dec= larator ( ( declaration )+ a=3D compound_statement | b=3D compound_statemen= t ) ; + def function_definition(self, ): self.function_definition_stack.append(function_definition_scope()) retval =3D self.function_definition_return() @@ -563,14 +577,12 @@ class CParser(Parser): =20 declarator1 =3D None =20 - - - self.function_definition_stack[-1].ModifierText =3D '' - self.function_definition_stack[-1].DeclText =3D '' - self.function_definition_stack[-1].LBLine =3D 0 - self.function_definition_stack[-1].LBOffset =3D 0 - self.function_definition_stack[-1].DeclLine =3D 0 - self.function_definition_stack[-1].DeclOffset =3D 0 + self.function_definition_stack[-1].ModifierText =3D '' + self.function_definition_stack[-1].DeclText =3D '' + self.function_definition_stack[-1].LBLine =3D 0 + self.function_definition_stack[-1].LBOffset =3D 0 + self.function_definition_stack[-1].DeclLine =3D 0 + self.function_definition_stack[-1].DeclOffset =3D 0 =20 try: try: @@ -591,119 +603,119 @@ class CParser(Parser): elif LA4 =3D=3D 58: LA4_21 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 59: LA4_22 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 60: LA4_23 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D IDENTIFIER: LA4_24 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 62: LA4_25 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 29 or LA4 =3D=3D 30 or LA4 =3D=3D 31 o= r LA4 =3D=3D 32 or LA4 =3D=3D 33: LA4_26 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 34: LA4_27 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 35: LA4_28 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 36: LA4_29 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 37: LA4_30 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 38: LA4_31 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 39: LA4_32 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 40: LA4_33 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 41: LA4_34 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 42: LA4_35 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 45 or LA4 =3D=3D 46: LA4_36 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 48: LA4_37 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 49 or LA4 =3D=3D 50 or LA4 =3D=3D 51 o= r LA4 =3D=3D 52 or LA4 =3D=3D 53 or LA4 =3D=3D 54 or LA4 =3D=3D 55 or LA4 = =3D=3D 56 or LA4 =3D=3D 57 or LA4 =3D=3D 61: LA4_38 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 58: LA4_14 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 59: LA4_16 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 60: LA4_17 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 if alt4 =3D=3D 1: # C.g:0:0: d=3D declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifie= rs_in_function_definition157) + self.following.append( + self.FOLLOW_declaration_specifiers_in_function_def= inition157) d =3D self.declaration_specifiers() self.following.pop() if self.failed: return retval =20 - - - self.following.append(self.FOLLOW_declarator_in_function_d= efinition160) + self.following.append( + self.FOLLOW_declarator_in_function_definition160) declarator1 =3D self.declarator() self.following.pop() if self.failed: @@ -712,16 +724,17 @@ class CParser(Parser): alt6 =3D 2 LA6_0 =3D self.input.LA(1) =20 - if (LA6_0 =3D=3D IDENTIFIER or LA6_0 =3D=3D 26 or (29 <=3D= LA6_0 <=3D 42) or (45 <=3D LA6_0 <=3D 46) or (48 <=3D LA6_0 <=3D 61)) : + if (LA6_0 =3D=3D IDENTIFIER or LA6_0 =3D=3D 26 or (29 <=3D= LA6_0 <=3D 42) or (45 <=3D LA6_0 <=3D 46) or (48 <=3D LA6_0 <=3D 61)): alt6 =3D 1 - elif (LA6_0 =3D=3D 43) : + elif (LA6_0 =3D=3D 43): alt6 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("147:3: ( ( declaration = )+ a=3D compound_statement | b=3D compound_statement )", 6, 0, self.input) + nvae =3D NoViableAltException( + "147:3: ( ( declaration )+ a=3D compound_statement= | b=3D compound_statement )", 6, 0, self.input) =20 raise nvae =20 @@ -729,26 +742,25 @@ class CParser(Parser): # C.g:147:5: ( declaration )+ a=3D compound_statement # C.g:147:5: ( declaration )+ cnt5 =3D 0 - while True: #loop5 + while True: # loop5 alt5 =3D 2 LA5_0 =3D self.input.LA(1) =20 - if (LA5_0 =3D=3D IDENTIFIER or LA5_0 =3D=3D 26 or = (29 <=3D LA5_0 <=3D 42) or (45 <=3D LA5_0 <=3D 46) or (48 <=3D LA5_0 <=3D 6= 1)) : + if (LA5_0 =3D=3D IDENTIFIER or LA5_0 =3D=3D 26 or = (29 <=3D LA5_0 <=3D 42) or (45 <=3D LA5_0 <=3D 46) or (48 <=3D LA5_0 <=3D 6= 1)): alt5 =3D 1 =20 - if alt5 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_= in_function_definition166) + self.following.append( + self.FOLLOW_declaration_in_function_defini= tion166) self.declaration() self.following.pop() if self.failed: return retval =20 - else: if cnt5 >=3D 1: - break #loop5 + break # loop5 =20 if self.backtracking > 0: self.failed =3D True @@ -759,51 +771,46 @@ class CParser(Parser): =20 cnt5 +=3D 1 =20 - - self.following.append(self.FOLLOW_compound_statement_i= n_function_definition171) + self.following.append( + self.FOLLOW_compound_statement_in_function_definit= ion171) a =3D self.compound_statement() self.following.pop() if self.failed: return retval =20 - elif alt6 =3D=3D 2: # C.g:148:5: b=3D compound_statement - self.following.append(self.FOLLOW_compound_statement_i= n_function_definition180) + self.following.append( + self.FOLLOW_compound_statement_in_function_definit= ion180) b =3D self.compound_statement() self.following.pop() if self.failed: return retval =20 - - if self.backtracking =3D=3D 0: =20 if d is not None: - self.function_definition_stack[-1].ModifierText =3D = self.input.toString(d.start, d.stop) + self.function_definition_stack[-1].ModifierText = =3D self.input.toString( + d.start, d.stop) else: - self.function_definition_stack[-1].ModifierText =3D = '' - self.function_definition_stack[-1].DeclText =3D self.i= nput.toString(declarator1.start, declarator1.stop) + self.function_definition_stack[-1].ModifierText = =3D '' + self.function_definition_stack[-1].DeclText =3D self.i= nput.toString( + declarator1.start, declarator1.stop) self.function_definition_stack[-1].DeclLine =3D declar= ator1.start.line self.function_definition_stack[-1].DeclOffset =3D decl= arator1.start.charPositionInLine if a is not None: - self.function_definition_stack[-1].LBLine =3D a.star= t.line - self.function_definition_stack[-1].LBOffset =3D a.st= art.charPositionInLine + self.function_definition_stack[-1].LBLine =3D a.st= art.line + self.function_definition_stack[-1].LBOffset =3D a.= start.charPositionInLine else: - self.function_definition_stack[-1].LBLine =3D b.star= t.line - self.function_definition_stack[-1].LBOffset =3D b.st= art.charPositionInLine - - - - + self.function_definition_stack[-1].LBLine =3D b.st= art.line + self.function_definition_stack[-1].LBOffset =3D b.= start.charPositionInLine =20 retval.stop =3D self.input.LT(-1) =20 if self.backtracking =3D=3D 0: =20 - self.StoreFunctionDefinition(retval.start.line, retval= .start.charPositionInLine, retval.stop.line, retval.stop.charPositionInLine= , self.function_definition_stack[-1].ModifierText, self.function_definition= _stack[-1].DeclText, self.function_definition_stack[-1].LBLine, self.functi= on_definition_stack[-1].LBOffset, self.function_definition_stack[-1].DeclLi= ne, self.function_definition_stack[-1].DeclOffset) - - + self.StoreFunctionDefinition(retval.start.line, retval= .start.charPositionInLine, retval.stop.line, retval.stop.charPositionInLine= , self.function_definition_stack[-1].ModifierText, self.function_definition= _stack[ + -1].DeclText, self.functi= on_definition_stack[-1].LBLine, self.function_definition_stack[-1].LBOffset= , self.function_definition_stack[-1].DeclLine, self.function_definition_sta= ck[-1].DeclOffset) =20 except RecognitionException as re: self.reportError(re) @@ -819,9 +826,9 @@ class CParser(Parser): =20 # $ANTLR end function_definition =20 - # $ANTLR start declaration # C.g:166:1: declaration : (a=3D 'typedef' (b=3D declaration_specifier= s )? c=3D init_declarator_list d=3D ';' | s=3D declaration_specifiers (t=3D= init_declarator_list )? e=3D ';' ); + def declaration(self, ): =20 declaration_StartIndex =3D self.input.index() @@ -836,7 +843,6 @@ class CParser(Parser): =20 t =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 4): @@ -846,23 +852,25 @@ class CParser(Parser): alt9 =3D 2 LA9_0 =3D self.input.LA(1) =20 - if (LA9_0 =3D=3D 26) : + if (LA9_0 =3D=3D 26): alt9 =3D 1 - elif (LA9_0 =3D=3D IDENTIFIER or (29 <=3D LA9_0 <=3D 42) o= r (45 <=3D LA9_0 <=3D 46) or (48 <=3D LA9_0 <=3D 61)) : + elif (LA9_0 =3D=3D IDENTIFIER or (29 <=3D LA9_0 <=3D 42) o= r (45 <=3D LA9_0 <=3D 46) or (48 <=3D LA9_0 <=3D 61)): alt9 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("166:1: declaration : (a= =3D 'typedef' (b=3D declaration_specifiers )? c=3D init_declarator_list d= =3D ';' | s=3D declaration_specifiers (t=3D init_declarator_list )? e=3D ';= ' );", 9, 0, self.input) + nvae =3D NoViableAltException( + "166:1: declaration : (a=3D 'typedef' (b=3D declar= ation_specifiers )? c=3D init_declarator_list d=3D ';' | s=3D declaration_s= pecifiers (t=3D init_declarator_list )? e=3D ';' );", 9, 0, self.input) =20 raise nvae =20 if alt9 =3D=3D 1: # C.g:167:4: a=3D 'typedef' (b=3D declaration_specifie= rs )? c=3D init_declarator_list d=3D ';' a =3D self.input.LT(1) - self.match(self.input, 26, self.FOLLOW_26_in_declarati= on203) + self.match(self.input, 26, + self.FOLLOW_26_in_declaration203) if self.failed: return # C.g:167:17: (b=3D declaration_specifiers )? @@ -873,60 +881,61 @@ class CParser(Parser): elif LA7 =3D=3D IDENTIFIER: LA7_13 =3D self.input.LA(2) =20 - if (LA7_13 =3D=3D 62) : + if (LA7_13 =3D=3D 62): LA7_21 =3D self.input.LA(3) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 - elif (LA7_13 =3D=3D IDENTIFIER or (29 <=3D LA7_13 = <=3D 42) or (45 <=3D LA7_13 <=3D 46) or (48 <=3D LA7_13 <=3D 61) or LA7_13 = =3D=3D 66) : + elif (LA7_13 =3D=3D IDENTIFIER or (29 <=3D LA7_13 = <=3D 42) or (45 <=3D LA7_13 <=3D 46) or (48 <=3D LA7_13 <=3D 61) or LA7_13 = =3D=3D 66): alt7 =3D 1 elif LA7 =3D=3D 58: LA7_14 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 elif LA7 =3D=3D 59: LA7_16 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 elif LA7 =3D=3D 60: LA7_17 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 if alt7 =3D=3D 1: # C.g:0:0: b=3D declaration_specifiers - self.following.append(self.FOLLOW_declaration_spec= ifiers_in_declaration207) + self.following.append( + self.FOLLOW_declaration_specifiers_in_declarat= ion207) b =3D self.declaration_specifiers() self.following.pop() if self.failed: return =20 - - - self.following.append(self.FOLLOW_init_declarator_list= _in_declaration216) + self.following.append( + self.FOLLOW_init_declarator_list_in_declaration216) c =3D self.init_declarator_list() self.following.pop() if self.failed: return d =3D self.input.LT(1) - self.match(self.input, 25, self.FOLLOW_25_in_declarati= on220) + self.match(self.input, 25, + self.FOLLOW_25_in_declaration220) if self.failed: return if self.backtracking =3D=3D 0: =20 if b is not None: - self.StoreTypedefDefinition(a.line, a.charPositi= onInLine, d.line, d.charPositionInLine, self.input.toString(b.start, b.stop= ), self.input.toString(c.start, c.stop)) + self.StoreTypedefDefinition(a.line, a.charPosi= tionInLine, d.line, d.charPositionInLine, self.input.toString( + b.start, b.stop), self.input.toString(c.st= art, c.stop)) else: - self.StoreTypedefDefinition(a.line, a.charPositi= onInLine, d.line, d.charPositionInLine, '', self.input.toString(c.start, c.= stop)) - - - + self.StoreTypedefDefinition( + a.line, a.charPositionInLine, d.line, d.ch= arPositionInLine, '', self.input.toString(c.start, c.stop)) =20 elif alt9 =3D=3D 2: # C.g:175:4: s=3D declaration_specifiers (t=3D init_de= clarator_list )? e=3D ';' - self.following.append(self.FOLLOW_declaration_specifie= rs_in_declaration234) + self.following.append( + self.FOLLOW_declaration_specifiers_in_declaration2= 34) s =3D self.declaration_specifiers() self.following.pop() if self.failed: @@ -935,30 +944,27 @@ class CParser(Parser): alt8 =3D 2 LA8_0 =3D self.input.LA(1) =20 - if (LA8_0 =3D=3D IDENTIFIER or (58 <=3D LA8_0 <=3D 60)= or LA8_0 =3D=3D 62 or LA8_0 =3D=3D 66) : + if (LA8_0 =3D=3D IDENTIFIER or (58 <=3D LA8_0 <=3D 60)= or LA8_0 =3D=3D 62 or LA8_0 =3D=3D 66): alt8 =3D 1 if alt8 =3D=3D 1: # C.g:0:0: t=3D init_declarator_list - self.following.append(self.FOLLOW_init_declarator_= list_in_declaration238) + self.following.append( + self.FOLLOW_init_declarator_list_in_declaratio= n238) t =3D self.init_declarator_list() self.following.pop() if self.failed: return =20 - - e =3D self.input.LT(1) - self.match(self.input, 25, self.FOLLOW_25_in_declarati= on243) + self.match(self.input, 25, + self.FOLLOW_25_in_declaration243) if self.failed: return if self.backtracking =3D=3D 0: =20 if t is not None: - self.StoreVariableDeclaration(s.start.line, s.st= art.charPositionInLine, t.start.line, t.start.charPositionInLine, self.inpu= t.toString(s.start, s.stop), self.input.toString(t.start, t.stop)) - - - - + self.StoreVariableDeclaration(s.start.line, s.= start.charPositionInLine, t.start.line, t.start.charPositionInLine, self.in= put.toString( + s.start, s.stop), self.input.toString(t.st= art, t.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -978,10 +984,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start declaration_specifiers # C.g:182:1: declaration_specifiers : ( storage_class_specifier | type= _specifier | type_qualifier )+ ; + def declaration_specifiers(self, ): =20 retval =3D self.declaration_specifiers_return() @@ -996,44 +1001,39 @@ class CParser(Parser): # C.g:183:6: ( storage_class_specifier | type_specifier | = type_qualifier )+ # C.g:183:6: ( storage_class_specifier | type_specifier | = type_qualifier )+ cnt10 =3D 0 - while True: #loop10 + while True: # loop10 alt10 =3D 4 LA10 =3D self.input.LA(1) if LA10 =3D=3D 58: LA10_2 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 59: LA10_3 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 60: LA10_4 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D IDENTIFIER: LA10_5 =3D self.input.LA(2) =20 - if (self.synpred14()) : + if (self.synpred14()): alt10 =3D 2 =20 - elif LA10 =3D=3D 53: LA10_9 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 29 or LA10 =3D=3D 30 or LA10 =3D=3D 3= 1 or LA10 =3D=3D 32 or LA10 =3D=3D 33: alt10 =3D 1 elif LA10 =3D=3D 34 or LA10 =3D=3D 35 or LA10 =3D=3D 3= 6 or LA10 =3D=3D 37 or LA10 =3D=3D 38 or LA10 =3D=3D 39 or LA10 =3D=3D 40 o= r LA10 =3D=3D 41 or LA10 =3D=3D 42 or LA10 =3D=3D 45 or LA10 =3D=3D 46 or L= A10 =3D=3D 48: @@ -1043,34 +1043,34 @@ class CParser(Parser): =20 if alt10 =3D=3D 1: # C.g:183:10: storage_class_specifier - self.following.append(self.FOLLOW_storage_class_sp= ecifier_in_declaration_specifiers264) + self.following.append( + self.FOLLOW_storage_class_specifier_in_declara= tion_specifiers264) self.storage_class_specifier() self.following.pop() if self.failed: return retval =20 - elif alt10 =3D=3D 2: # C.g:184:7: type_specifier - self.following.append(self.FOLLOW_type_specifier_i= n_declaration_specifiers272) + self.following.append( + self.FOLLOW_type_specifier_in_declaration_spec= ifiers272) self.type_specifier() self.following.pop() if self.failed: return retval =20 - elif alt10 =3D=3D 3: # C.g:185:13: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_i= n_declaration_specifiers286) + self.following.append( + self.FOLLOW_type_qualifier_in_declaration_spec= ifiers286) self.type_qualifier() self.following.pop() if self.failed: return retval =20 - else: if cnt10 >=3D 1: - break #loop10 + break # loop10 =20 if self.backtracking > 0: self.failed =3D True @@ -1081,13 +1081,8 @@ class CParser(Parser): =20 cnt10 +=3D 1 =20 - - - - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1106,10 +1101,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start init_declarator_list # C.g:189:1: init_declarator_list : init_declarator ( ',' init_declara= tor )* ; + def init_declarator_list(self, ): =20 retval =3D self.init_declarator_list_return() @@ -1122,42 +1116,38 @@ class CParser(Parser): =20 # C.g:190:2: ( init_declarator ( ',' init_declarator )* ) # C.g:190:4: init_declarator ( ',' init_declarator )* - self.following.append(self.FOLLOW_init_declarator_in_init_= declarator_list308) + self.following.append( + self.FOLLOW_init_declarator_in_init_declarator_list308) self.init_declarator() self.following.pop() if self.failed: return retval # C.g:190:20: ( ',' init_declarator )* - while True: #loop11 + while True: # loop11 alt11 =3D 2 LA11_0 =3D self.input.LA(1) =20 - if (LA11_0 =3D=3D 27) : + if (LA11_0 =3D=3D 27): alt11 =3D 1 =20 - if alt11 =3D=3D 1: # C.g:190:21: ',' init_declarator - self.match(self.input, 27, self.FOLLOW_27_in_init_= declarator_list311) + self.match(self.input, 27, + self.FOLLOW_27_in_init_declarator_list3= 11) if self.failed: return retval - self.following.append(self.FOLLOW_init_declarator_= in_init_declarator_list313) + self.following.append( + self.FOLLOW_init_declarator_in_init_declarator= _list313) self.init_declarator() self.following.pop() if self.failed: return retval =20 - else: - break #loop11 - - - - + break # loop11 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1171,9 +1161,9 @@ class CParser(Parser): =20 # $ANTLR end init_declarator_list =20 - # $ANTLR start init_declarator # C.g:193:1: init_declarator : declarator ( '=3D' initializer )? ; + def init_declarator(self, ): =20 init_declarator_StartIndex =3D self.input.index() @@ -1184,7 +1174,8 @@ class CParser(Parser): =20 # C.g:194:2: ( declarator ( '=3D' initializer )? ) # C.g:194:4: declarator ( '=3D' initializer )? - self.following.append(self.FOLLOW_declarator_in_init_decla= rator326) + self.following.append( + self.FOLLOW_declarator_in_init_declarator326) self.declarator() self.following.pop() if self.failed: @@ -1193,25 +1184,21 @@ class CParser(Parser): alt12 =3D 2 LA12_0 =3D self.input.LA(1) =20 - if (LA12_0 =3D=3D 28) : + if (LA12_0 =3D=3D 28): alt12 =3D 1 if alt12 =3D=3D 1: # C.g:194:16: '=3D' initializer - self.match(self.input, 28, self.FOLLOW_28_in_init_decl= arator329) + self.match(self.input, 28, + self.FOLLOW_28_in_init_declarator329) if self.failed: return - self.following.append(self.FOLLOW_initializer_in_init_= declarator331) + self.following.append( + self.FOLLOW_initializer_in_init_declarator331) self.initializer() self.following.pop() if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1225,9 +1212,9 @@ class CParser(Parser): =20 # $ANTLR end init_declarator =20 - # $ANTLR start storage_class_specifier # C.g:197:1: storage_class_specifier : ( 'extern' | 'static' | 'auto' = | 'register' | 'STATIC' ); + def storage_class_specifier(self, ): =20 storage_class_specifier_StartIndex =3D self.input.index() @@ -1239,7 +1226,7 @@ class CParser(Parser): # C.g:198:2: ( 'extern' | 'static' | 'auto' | 'register' |= 'STATIC' ) # C.g: if (29 <=3D self.input.LA(1) <=3D 33): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -1251,14 +1238,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_storage_class_= specifier0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1272,9 +1254,9 @@ class CParser(Parser): =20 # $ANTLR end storage_class_specifier =20 - # $ANTLR start type_specifier # C.g:205:1: type_specifier : ( 'void' | 'char' | 'short' | 'int' | 'l= ong' | 'float' | 'double' | 'signed' | 'unsigned' | s=3D struct_or_union_sp= ecifier | e=3D enum_specifier | ( IDENTIFIER ( type_qualifier )* declarator= )=3D> type_id ); + def type_specifier(self, ): =20 type_specifier_StartIndex =3D self.input.index() @@ -1282,7 +1264,6 @@ class CParser(Parser): =20 e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 9): @@ -1292,27 +1273,27 @@ class CParser(Parser): alt13 =3D 12 LA13_0 =3D self.input.LA(1) =20 - if (LA13_0 =3D=3D 34) : + if (LA13_0 =3D=3D 34): alt13 =3D 1 - elif (LA13_0 =3D=3D 35) : + elif (LA13_0 =3D=3D 35): alt13 =3D 2 - elif (LA13_0 =3D=3D 36) : + elif (LA13_0 =3D=3D 36): alt13 =3D 3 - elif (LA13_0 =3D=3D 37) : + elif (LA13_0 =3D=3D 37): alt13 =3D 4 - elif (LA13_0 =3D=3D 38) : + elif (LA13_0 =3D=3D 38): alt13 =3D 5 - elif (LA13_0 =3D=3D 39) : + elif (LA13_0 =3D=3D 39): alt13 =3D 6 - elif (LA13_0 =3D=3D 40) : + elif (LA13_0 =3D=3D 40): alt13 =3D 7 - elif (LA13_0 =3D=3D 41) : + elif (LA13_0 =3D=3D 41): alt13 =3D 8 - elif (LA13_0 =3D=3D 42) : + elif (LA13_0 =3D=3D 42): alt13 =3D 9 - elif ((45 <=3D LA13_0 <=3D 46)) : + elif ((45 <=3D LA13_0 <=3D 46)): alt13 =3D 10 - elif (LA13_0 =3D=3D 48) : + elif (LA13_0 =3D=3D 48): alt13 =3D 11 elif (LA13_0 =3D=3D IDENTIFIER) and (self.synpred34()): alt13 =3D 12 @@ -1321,76 +1302,78 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("205:1: type_specifier := ( 'void' | 'char' | 'short' | 'int' | 'long' | 'float' | 'double' | 'signe= d' | 'unsigned' | s=3D struct_or_union_specifier | e=3D enum_specifier | ( = IDENTIFIER ( type_qualifier )* declarator )=3D> type_id );", 13, 0, self.in= put) + nvae =3D NoViableAltException( + "205:1: type_specifier : ( 'void' | 'char' | 'shor= t' | 'int' | 'long' | 'float' | 'double' | 'signed' | 'unsigned' | s=3D str= uct_or_union_specifier | e=3D enum_specifier | ( IDENTIFIER ( type_qualifie= r )* declarator )=3D> type_id );", 13, 0, self.input) =20 raise nvae =20 if alt13 =3D=3D 1: # C.g:206:4: 'void' - self.match(self.input, 34, self.FOLLOW_34_in_type_spec= ifier376) + self.match(self.input, 34, + self.FOLLOW_34_in_type_specifier376) if self.failed: return =20 - elif alt13 =3D=3D 2: # C.g:207:4: 'char' - self.match(self.input, 35, self.FOLLOW_35_in_type_spec= ifier381) + self.match(self.input, 35, + self.FOLLOW_35_in_type_specifier381) if self.failed: return =20 - elif alt13 =3D=3D 3: # C.g:208:4: 'short' - self.match(self.input, 36, self.FOLLOW_36_in_type_spec= ifier386) + self.match(self.input, 36, + self.FOLLOW_36_in_type_specifier386) if self.failed: return =20 - elif alt13 =3D=3D 4: # C.g:209:4: 'int' - self.match(self.input, 37, self.FOLLOW_37_in_type_spec= ifier391) + self.match(self.input, 37, + self.FOLLOW_37_in_type_specifier391) if self.failed: return =20 - elif alt13 =3D=3D 5: # C.g:210:4: 'long' - self.match(self.input, 38, self.FOLLOW_38_in_type_spec= ifier396) + self.match(self.input, 38, + self.FOLLOW_38_in_type_specifier396) if self.failed: return =20 - elif alt13 =3D=3D 6: # C.g:211:4: 'float' - self.match(self.input, 39, self.FOLLOW_39_in_type_spec= ifier401) + self.match(self.input, 39, + self.FOLLOW_39_in_type_specifier401) if self.failed: return =20 - elif alt13 =3D=3D 7: # C.g:212:4: 'double' - self.match(self.input, 40, self.FOLLOW_40_in_type_spec= ifier406) + self.match(self.input, 40, + self.FOLLOW_40_in_type_specifier406) if self.failed: return =20 - elif alt13 =3D=3D 8: # C.g:213:4: 'signed' - self.match(self.input, 41, self.FOLLOW_41_in_type_spec= ifier411) + self.match(self.input, 41, + self.FOLLOW_41_in_type_specifier411) if self.failed: return =20 - elif alt13 =3D=3D 9: # C.g:214:4: 'unsigned' - self.match(self.input, 42, self.FOLLOW_42_in_type_spec= ifier416) + self.match(self.input, 42, + self.FOLLOW_42_in_type_specifier416) if self.failed: return =20 - elif alt13 =3D=3D 10: # C.g:215:4: s=3D struct_or_union_specifier - self.following.append(self.FOLLOW_struct_or_union_spec= ifier_in_type_specifier423) + self.following.append( + self.FOLLOW_struct_or_union_specifier_in_type_spec= ifier423) s =3D self.struct_or_union_specifier() self.following.pop() if self.failed: @@ -1398,14 +1381,13 @@ class CParser(Parser): if self.backtracking =3D=3D 0: =20 if s.stop is not None: - self.StoreStructUnionDefinition(s.start.line, s.= start.charPositionInLine, s.stop.line, s.stop.charPositionInLine, self.inpu= t.toString(s.start, s.stop)) - - - + self.StoreStructUnionDefinition( + s.start.line, s.start.charPositionInLine, = s.stop.line, s.stop.charPositionInLine, self.input.toString(s.start, s.stop= )) =20 elif alt13 =3D=3D 11: # C.g:220:4: e=3D enum_specifier - self.following.append(self.FOLLOW_enum_specifier_in_ty= pe_specifier433) + self.following.append( + self.FOLLOW_enum_specifier_in_type_specifier433) e =3D self.enum_specifier() self.following.pop() if self.failed: @@ -1413,21 +1395,18 @@ class CParser(Parser): if self.backtracking =3D=3D 0: =20 if e.stop is not None: - self.StoreEnumerationDefinition(e.start.line, e.= start.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.inpu= t.toString(e.start, e.stop)) - - - + self.StoreEnumerationDefinition( + e.start.line, e.start.charPositionInLine, = e.stop.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop= )) =20 elif alt13 =3D=3D 12: # C.g:225:4: ( IDENTIFIER ( type_qualifier )* declarat= or )=3D> type_id - self.following.append(self.FOLLOW_type_id_in_type_spec= ifier451) + self.following.append( + self.FOLLOW_type_id_in_type_specifier451) self.type_id() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1441,9 +1420,9 @@ class CParser(Parser): =20 # $ANTLR end type_specifier =20 - # $ANTLR start type_id # C.g:228:1: type_id : IDENTIFIER ; + def type_id(self, ): =20 type_id_StartIndex =3D self.input.index() @@ -1454,13 +1433,11 @@ class CParser(Parser): =20 # C.g:229:5: ( IDENTIFIER ) # C.g:229:9: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_type_id467) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_type_id467) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1479,10 +1456,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start struct_or_union_specifier # C.g:233:1: struct_or_union_specifier options {k=3D3; } : ( struct_or= _union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union ID= ENTIFIER ); + def struct_or_union_specifier(self, ): =20 retval =3D self.struct_or_union_specifier_return() @@ -1497,33 +1473,35 @@ class CParser(Parser): alt15 =3D 2 LA15_0 =3D self.input.LA(1) =20 - if ((45 <=3D LA15_0 <=3D 46)) : + if ((45 <=3D LA15_0 <=3D 46)): LA15_1 =3D self.input.LA(2) =20 - if (LA15_1 =3D=3D IDENTIFIER) : + if (LA15_1 =3D=3D IDENTIFIER): LA15_2 =3D self.input.LA(3) =20 - if (LA15_2 =3D=3D 43) : + if (LA15_2 =3D=3D 43): alt15 =3D 1 - elif (LA15_2 =3D=3D EOF or LA15_2 =3D=3D IDENTIFIE= R or LA15_2 =3D=3D 25 or LA15_2 =3D=3D 27 or (29 <=3D LA15_2 <=3D 42) or (4= 5 <=3D LA15_2 <=3D 64) or LA15_2 =3D=3D 66) : + elif (LA15_2 =3D=3D EOF or LA15_2 =3D=3D IDENTIFIE= R or LA15_2 =3D=3D 25 or LA15_2 =3D=3D 27 or (29 <=3D LA15_2 <=3D 42) or (4= 5 <=3D LA15_2 <=3D 64) or LA15_2 =3D=3D 66): alt15 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_o= r_union_specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{'= struct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 2, self.= input) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options = {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '= }' | struct_or_union IDENTIFIER );", 15, 2, self.input) =20 raise nvae =20 - elif (LA15_1 =3D=3D 43) : + elif (LA15_1 =3D=3D 43): alt15 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_or_un= ion_specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' str= uct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 1, self.inpu= t) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options {k= =3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}'= | struct_or_union IDENTIFIER );", 15, 1, self.input) =20 raise nvae =20 @@ -1532,13 +1510,15 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_or_union_= specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_= declaration_list '}' | struct_or_union IDENTIFIER );", 15, 0, self.input) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options {k=3D3; = } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | str= uct_or_union IDENTIFIER );", 15, 0, self.input) =20 raise nvae =20 if alt15 =3D=3D 1: # C.g:235:4: struct_or_union ( IDENTIFIER )? '{' struc= t_declaration_list '}' - self.following.append(self.FOLLOW_struct_or_union_in_s= truct_or_union_specifier494) + self.following.append( + self.FOLLOW_struct_or_union_in_struct_or_union_spe= cifier494) self.struct_or_union() self.following.pop() if self.failed: @@ -1547,50 +1527,52 @@ class CParser(Parser): alt14 =3D 2 LA14_0 =3D self.input.LA(1) =20 - if (LA14_0 =3D=3D IDENTIFIER) : + if (LA14_0 =3D=3D IDENTIFIER): alt14 =3D 1 if alt14 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_struct_or_union_specifier496) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_struct_or_union_specifier496) if self.failed: return retval =20 - - - self.match(self.input, 43, self.FOLLOW_43_in_struct_or= _union_specifier499) + self.match(self.input, 43, + self.FOLLOW_43_in_struct_or_union_specifier= 499) if self.failed: return retval - self.following.append(self.FOLLOW_struct_declaration_l= ist_in_struct_or_union_specifier501) + self.following.append( + self.FOLLOW_struct_declaration_list_in_struct_or_u= nion_specifier501) self.struct_declaration_list() self.following.pop() if self.failed: return retval - self.match(self.input, 44, self.FOLLOW_44_in_struct_or= _union_specifier503) + self.match(self.input, 44, + self.FOLLOW_44_in_struct_or_union_specifier= 503) if self.failed: return retval =20 - elif alt15 =3D=3D 2: # C.g:236:4: struct_or_union IDENTIFIER - self.following.append(self.FOLLOW_struct_or_union_in_s= truct_or_union_specifier508) + self.following.append( + self.FOLLOW_struct_or_union_in_struct_or_union_spe= cifier508) self.struct_or_union() self.following.pop() if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_struct_or_union_specifier510) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_= struct_or_union_specifier510) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 11, struct_or_union_specifier_Sta= rtIndex) + self.memoize(self.input, 11, + struct_or_union_specifier_StartIndex) =20 pass =20 @@ -1598,9 +1580,9 @@ class CParser(Parser): =20 # $ANTLR end struct_or_union_specifier =20 - # $ANTLR start struct_or_union # C.g:239:1: struct_or_union : ( 'struct' | 'union' ); + def struct_or_union(self, ): =20 struct_or_union_StartIndex =3D self.input.index() @@ -1612,7 +1594,7 @@ class CParser(Parser): # C.g:240:2: ( 'struct' | 'union' ) # C.g: if (45 <=3D self.input.LA(1) <=3D 46): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -1624,14 +1606,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_struct_or_unio= n0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1645,9 +1622,9 @@ class CParser(Parser): =20 # $ANTLR end struct_or_union =20 - # $ANTLR start struct_declaration_list # C.g:244:1: struct_declaration_list : ( struct_declaration )+ ; + def struct_declaration_list(self, ): =20 struct_declaration_list_StartIndex =3D self.input.index() @@ -1660,26 +1637,25 @@ class CParser(Parser): # C.g:245:4: ( struct_declaration )+ # C.g:245:4: ( struct_declaration )+ cnt16 =3D 0 - while True: #loop16 + while True: # loop16 alt16 =3D 2 LA16_0 =3D self.input.LA(1) =20 - if (LA16_0 =3D=3D IDENTIFIER or (34 <=3D LA16_0 <=3D 4= 2) or (45 <=3D LA16_0 <=3D 46) or (48 <=3D LA16_0 <=3D 61)) : + if (LA16_0 =3D=3D IDENTIFIER or (34 <=3D LA16_0 <=3D 4= 2) or (45 <=3D LA16_0 <=3D 46) or (48 <=3D LA16_0 <=3D 61)): alt16 =3D 1 =20 - if alt16 =3D=3D 1: # C.g:0:0: struct_declaration - self.following.append(self.FOLLOW_struct_declarati= on_in_struct_declaration_list537) + self.following.append( + self.FOLLOW_struct_declaration_in_struct_decla= ration_list537) self.struct_declaration() self.following.pop() if self.failed: return =20 - else: if cnt16 >=3D 1: - break #loop16 + break # loop16 =20 if self.backtracking > 0: self.failed =3D True @@ -1690,17 +1666,13 @@ class CParser(Parser): =20 cnt16 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 13, struct_declaration_list_Start= Index) + self.memoize(self.input, 13, + struct_declaration_list_StartIndex) =20 pass =20 @@ -1708,9 +1680,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declaration_list =20 - # $ANTLR start struct_declaration # C.g:248:1: struct_declaration : specifier_qualifier_list struct_decl= arator_list ';' ; + def struct_declaration(self, ): =20 struct_declaration_StartIndex =3D self.input.index() @@ -1721,23 +1693,23 @@ class CParser(Parser): =20 # C.g:249:2: ( specifier_qualifier_list struct_declarator_= list ';' ) # C.g:249:4: specifier_qualifier_list struct_declarator_li= st ';' - self.following.append(self.FOLLOW_specifier_qualifier_list= _in_struct_declaration549) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_struct_declara= tion549) self.specifier_qualifier_list() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_struct_declarator_list_i= n_struct_declaration551) + self.following.append( + self.FOLLOW_struct_declarator_list_in_struct_declarati= on551) self.struct_declarator_list() self.following.pop() if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_struct_declar= ation553) + self.match(self.input, 25, + self.FOLLOW_25_in_struct_declaration553) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1751,9 +1723,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declaration =20 - # $ANTLR start specifier_qualifier_list # C.g:252:1: specifier_qualifier_list : ( type_qualifier | type_specif= ier )+ ; + def specifier_qualifier_list(self, ): =20 specifier_qualifier_list_StartIndex =3D self.input.index() @@ -1766,30 +1738,27 @@ class CParser(Parser): # C.g:253:4: ( type_qualifier | type_specifier )+ # C.g:253:4: ( type_qualifier | type_specifier )+ cnt17 =3D 0 - while True: #loop17 + while True: # loop17 alt17 =3D 3 LA17 =3D self.input.LA(1) if LA17 =3D=3D 58: LA17_2 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D 59: LA17_3 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D 60: LA17_4 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D IDENTIFIER: LA17 =3D self.input.LA(2) if LA17 =3D=3D EOF or LA17 =3D=3D IDENTIFIER or LA= 17 =3D=3D 34 or LA17 =3D=3D 35 or LA17 =3D=3D 36 or LA17 =3D=3D 37 or LA17 = =3D=3D 38 or LA17 =3D=3D 39 or LA17 =3D=3D 40 or LA17 =3D=3D 41 or LA17 =3D= =3D 42 or LA17 =3D=3D 45 or LA17 =3D=3D 46 or LA17 =3D=3D 48 or LA17 =3D=3D= 49 or LA17 =3D=3D 50 or LA17 =3D=3D 51 or LA17 =3D=3D 52 or LA17 =3D=3D 53= or LA17 =3D=3D 54 or LA17 =3D=3D 55 or LA17 =3D=3D 56 or LA17 =3D=3D 57 or= LA17 =3D=3D 58 or LA17 =3D=3D 59 or LA17 =3D=3D 60 or LA17 =3D=3D 61 or LA= 17 =3D=3D 63 or LA17 =3D=3D 66: @@ -1797,25 +1766,21 @@ class CParser(Parser): elif LA17 =3D=3D 62: LA17_94 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - elif LA17 =3D=3D 47: LA17_95 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - elif LA17 =3D=3D 64: LA17_96 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - - elif LA17 =3D=3D 49 or LA17 =3D=3D 50 or LA17 =3D=3D 5= 1 or LA17 =3D=3D 52 or LA17 =3D=3D 53 or LA17 =3D=3D 54 or LA17 =3D=3D 55 o= r LA17 =3D=3D 56 or LA17 =3D=3D 57 or LA17 =3D=3D 61: alt17 =3D 1 elif LA17 =3D=3D 34 or LA17 =3D=3D 35 or LA17 =3D=3D 3= 6 or LA17 =3D=3D 37 or LA17 =3D=3D 38 or LA17 =3D=3D 39 or LA17 =3D=3D 40 o= r LA17 =3D=3D 41 or LA17 =3D=3D 42 or LA17 =3D=3D 45 or LA17 =3D=3D 46 or L= A17 =3D=3D 48: @@ -1823,25 +1788,25 @@ class CParser(Parser): =20 if alt17 =3D=3D 1: # C.g:253:6: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_i= n_specifier_qualifier_list566) + self.following.append( + self.FOLLOW_type_qualifier_in_specifier_qualif= ier_list566) self.type_qualifier() self.following.pop() if self.failed: return =20 - elif alt17 =3D=3D 2: # C.g:253:23: type_specifier - self.following.append(self.FOLLOW_type_specifier_i= n_specifier_qualifier_list570) + self.following.append( + self.FOLLOW_type_specifier_in_specifier_qualif= ier_list570) self.type_specifier() self.following.pop() if self.failed: return =20 - else: if cnt17 >=3D 1: - break #loop17 + break # loop17 =20 if self.backtracking > 0: self.failed =3D True @@ -1852,17 +1817,13 @@ class CParser(Parser): =20 cnt17 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 15, specifier_qualifier_list_Star= tIndex) + self.memoize(self.input, 15, + specifier_qualifier_list_StartIndex) =20 pass =20 @@ -1870,9 +1831,9 @@ class CParser(Parser): =20 # $ANTLR end specifier_qualifier_list =20 - # $ANTLR start struct_declarator_list # C.g:256:1: struct_declarator_list : struct_declarator ( ',' struct_d= eclarator )* ; + def struct_declarator_list(self, ): =20 struct_declarator_list_StartIndex =3D self.input.index() @@ -1883,39 +1844,35 @@ class CParser(Parser): =20 # C.g:257:2: ( struct_declarator ( ',' struct_declarator )= * ) # C.g:257:4: struct_declarator ( ',' struct_declarator )* - self.following.append(self.FOLLOW_struct_declarator_in_str= uct_declarator_list584) + self.following.append( + self.FOLLOW_struct_declarator_in_struct_declarator_lis= t584) self.struct_declarator() self.following.pop() if self.failed: return # C.g:257:22: ( ',' struct_declarator )* - while True: #loop18 + while True: # loop18 alt18 =3D 2 LA18_0 =3D self.input.LA(1) =20 - if (LA18_0 =3D=3D 27) : + if (LA18_0 =3D=3D 27): alt18 =3D 1 =20 - if alt18 =3D=3D 1: # C.g:257:23: ',' struct_declarator - self.match(self.input, 27, self.FOLLOW_27_in_struc= t_declarator_list587) + self.match(self.input, 27, + self.FOLLOW_27_in_struct_declarator_lis= t587) if self.failed: return - self.following.append(self.FOLLOW_struct_declarato= r_in_struct_declarator_list589) + self.following.append( + self.FOLLOW_struct_declarator_in_struct_declar= ator_list589) self.struct_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop18 - - - - - + break # loop18 =20 except RecognitionException as re: self.reportError(re) @@ -1930,9 +1887,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declarator_list =20 - # $ANTLR start struct_declarator # C.g:260:1: struct_declarator : ( declarator ( ':' constant_expressio= n )? | ':' constant_expression ); + def struct_declarator(self, ): =20 struct_declarator_StartIndex =3D self.input.index() @@ -1945,22 +1902,24 @@ class CParser(Parser): alt20 =3D 2 LA20_0 =3D self.input.LA(1) =20 - if (LA20_0 =3D=3D IDENTIFIER or (58 <=3D LA20_0 <=3D 60) o= r LA20_0 =3D=3D 62 or LA20_0 =3D=3D 66) : + if (LA20_0 =3D=3D IDENTIFIER or (58 <=3D LA20_0 <=3D 60) o= r LA20_0 =3D=3D 62 or LA20_0 =3D=3D 66): alt20 =3D 1 - elif (LA20_0 =3D=3D 47) : + elif (LA20_0 =3D=3D 47): alt20 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("260:1: struct_declarato= r : ( declarator ( ':' constant_expression )? | ':' constant_expression );"= , 20, 0, self.input) + nvae =3D NoViableAltException( + "260:1: struct_declarator : ( declarator ( ':' con= stant_expression )? | ':' constant_expression );", 20, 0, self.input) =20 raise nvae =20 if alt20 =3D=3D 1: # C.g:261:4: declarator ( ':' constant_expression )? - self.following.append(self.FOLLOW_declarator_in_struct= _declarator602) + self.following.append( + self.FOLLOW_declarator_in_struct_declarator602) self.declarator() self.following.pop() if self.failed: @@ -1969,36 +1928,34 @@ class CParser(Parser): alt19 =3D 2 LA19_0 =3D self.input.LA(1) =20 - if (LA19_0 =3D=3D 47) : + if (LA19_0 =3D=3D 47): alt19 =3D 1 if alt19 =3D=3D 1: # C.g:261:16: ':' constant_expression - self.match(self.input, 47, self.FOLLOW_47_in_struc= t_declarator605) + self.match(self.input, 47, + self.FOLLOW_47_in_struct_declarator605) if self.failed: return - self.following.append(self.FOLLOW_constant_express= ion_in_struct_declarator607) + self.following.append( + self.FOLLOW_constant_expression_in_struct_decl= arator607) self.constant_expression() self.following.pop() if self.failed: return =20 - - - - elif alt20 =3D=3D 2: # C.g:262:4: ':' constant_expression - self.match(self.input, 47, self.FOLLOW_47_in_struct_de= clarator614) + self.match(self.input, 47, + self.FOLLOW_47_in_struct_declarator614) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_struct_declarator616) + self.following.append( + self.FOLLOW_constant_expression_in_struct_declarat= or616) self.constant_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2017,10 +1974,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start enum_specifier # C.g:265:1: enum_specifier options {k=3D3; } : ( 'enum' '{' enumerato= r_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | = 'enum' IDENTIFIER ); + def enum_specifier(self, ): =20 retval =3D self.enum_specifier_return() @@ -2035,33 +1991,35 @@ class CParser(Parser): alt23 =3D 3 LA23_0 =3D self.input.LA(1) =20 - if (LA23_0 =3D=3D 48) : + if (LA23_0 =3D=3D 48): LA23_1 =3D self.input.LA(2) =20 - if (LA23_1 =3D=3D IDENTIFIER) : + if (LA23_1 =3D=3D IDENTIFIER): LA23_2 =3D self.input.LA(3) =20 - if (LA23_2 =3D=3D 43) : + if (LA23_2 =3D=3D 43): alt23 =3D 2 - elif (LA23_2 =3D=3D EOF or LA23_2 =3D=3D IDENTIFIE= R or LA23_2 =3D=3D 25 or LA23_2 =3D=3D 27 or (29 <=3D LA23_2 <=3D 42) or (4= 5 <=3D LA23_2 <=3D 64) or LA23_2 =3D=3D 66) : + elif (LA23_2 =3D=3D EOF or LA23_2 =3D=3D IDENTIFIE= R or LA23_2 =3D=3D 25 or LA23_2 =3D=3D 27 or (29 <=3D LA23_2 <=3D 42) or (4= 5 <=3D LA23_2 <=3D 64) or LA23_2 =3D=3D 66): alt23 =3D 3 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_spe= cifier options {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enu= m' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23,= 2, self.input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } := ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerat= or_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 2, self.input) =20 raise nvae =20 - elif (LA23_1 =3D=3D 43) : + elif (LA23_1 =3D=3D 43): alt23 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_specifi= er options {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' I= DENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 1, = self.input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } : ( '= enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_l= ist ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 1, self.input) =20 raise nvae =20 @@ -2070,19 +2028,23 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_specifier o= ptions {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENT= IFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 0, self= .input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } : ( 'enum= ' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list = ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 0, self.input) =20 raise nvae =20 if alt23 =3D=3D 1: # C.g:267:4: 'enum' '{' enumerator_list ( ',' )? '}' - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier634) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier634) if self.failed: return retval - self.match(self.input, 43, self.FOLLOW_43_in_enum_spec= ifier636) + self.match(self.input, 43, + self.FOLLOW_43_in_enum_specifier636) if self.failed: return retval - self.following.append(self.FOLLOW_enumerator_list_in_e= num_specifier638) + self.following.append( + self.FOLLOW_enumerator_list_in_enum_specifier638) self.enumerator_list() self.following.pop() if self.failed: @@ -2091,33 +2053,36 @@ class CParser(Parser): alt21 =3D 2 LA21_0 =3D self.input.LA(1) =20 - if (LA21_0 =3D=3D 27) : + if (LA21_0 =3D=3D 27): alt21 =3D 1 if alt21 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_enum_= specifier640) + self.match(self.input, 27, + self.FOLLOW_27_in_enum_specifier640) if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_enum_spec= ifier643) + self.match(self.input, 44, + self.FOLLOW_44_in_enum_specifier643) if self.failed: return retval =20 - elif alt23 =3D=3D 2: # C.g:268:4: 'enum' IDENTIFIER '{' enumerator_list ( '= ,' )? '}' - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier648) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier648) if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_enum_specifier650) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enum_specifier650) if self.failed: return retval - self.match(self.input, 43, self.FOLLOW_43_in_enum_spec= ifier652) + self.match(self.input, 43, + self.FOLLOW_43_in_enum_specifier652) if self.failed: return retval - self.following.append(self.FOLLOW_enumerator_list_in_e= num_specifier654) + self.following.append( + self.FOLLOW_enumerator_list_in_enum_specifier654) self.enumerator_list() self.following.pop() if self.failed: @@ -2126,34 +2091,33 @@ class CParser(Parser): alt22 =3D 2 LA22_0 =3D self.input.LA(1) =20 - if (LA22_0 =3D=3D 27) : + if (LA22_0 =3D=3D 27): alt22 =3D 1 if alt22 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_enum_= specifier656) + self.match(self.input, 27, + self.FOLLOW_27_in_enum_specifier656) if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_enum_spec= ifier659) + self.match(self.input, 44, + self.FOLLOW_44_in_enum_specifier659) if self.failed: return retval =20 - elif alt23 =3D=3D 3: # C.g:269:4: 'enum' IDENTIFIER - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier664) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier664) if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_enum_specifier666) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enum_specifier666) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2167,9 +2131,9 @@ class CParser(Parser): =20 # $ANTLR end enum_specifier =20 - # $ANTLR start enumerator_list # C.g:272:1: enumerator_list : enumerator ( ',' enumerator )* ; + def enumerator_list(self, ): =20 enumerator_list_StartIndex =3D self.input.index() @@ -2180,44 +2144,38 @@ class CParser(Parser): =20 # C.g:273:2: ( enumerator ( ',' enumerator )* ) # C.g:273:4: enumerator ( ',' enumerator )* - self.following.append(self.FOLLOW_enumerator_in_enumerator= _list677) + self.following.append( + self.FOLLOW_enumerator_in_enumerator_list677) self.enumerator() self.following.pop() if self.failed: return # C.g:273:15: ( ',' enumerator )* - while True: #loop24 + while True: # loop24 alt24 =3D 2 LA24_0 =3D self.input.LA(1) =20 - if (LA24_0 =3D=3D 27) : + if (LA24_0 =3D=3D 27): LA24_1 =3D self.input.LA(2) =20 - if (LA24_1 =3D=3D IDENTIFIER) : + if (LA24_1 =3D=3D IDENTIFIER): alt24 =3D 1 =20 - - - if alt24 =3D=3D 1: # C.g:273:16: ',' enumerator - self.match(self.input, 27, self.FOLLOW_27_in_enume= rator_list680) + self.match(self.input, 27, + self.FOLLOW_27_in_enumerator_list680) if self.failed: return - self.following.append(self.FOLLOW_enumerator_in_en= umerator_list682) + self.following.append( + self.FOLLOW_enumerator_in_enumerator_list682) self.enumerator() self.following.pop() if self.failed: return =20 - else: - break #loop24 - - - - - + break # loop24 =20 except RecognitionException as re: self.reportError(re) @@ -2232,9 +2190,9 @@ class CParser(Parser): =20 # $ANTLR end enumerator_list =20 - # $ANTLR start enumerator # C.g:276:1: enumerator : IDENTIFIER ( '=3D' constant_expression )? ; + def enumerator(self, ): =20 enumerator_StartIndex =3D self.input.index() @@ -2245,32 +2203,28 @@ class CParser(Parser): =20 # C.g:277:2: ( IDENTIFIER ( '=3D' constant_expression )? ) # C.g:277:4: IDENTIFIER ( '=3D' constant_expression )? - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_enumerator695) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enumerator695) if self.failed: return # C.g:277:15: ( '=3D' constant_expression )? alt25 =3D 2 LA25_0 =3D self.input.LA(1) =20 - if (LA25_0 =3D=3D 28) : + if (LA25_0 =3D=3D 28): alt25 =3D 1 if alt25 =3D=3D 1: # C.g:277:16: '=3D' constant_expression self.match(self.input, 28, self.FOLLOW_28_in_enumerato= r698) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_enumerator700) + self.following.append( + self.FOLLOW_constant_expression_in_enumerator700) self.constant_expression() self.following.pop() if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2284,9 +2238,9 @@ class CParser(Parser): =20 # $ANTLR end enumerator =20 - # $ANTLR start type_qualifier # C.g:280:1: type_qualifier : ( 'const' | 'volatile' | 'IN' | 'OUT' | = 'OPTIONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFER= ENCED' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' ); + def type_qualifier(self, ): =20 type_qualifier_StartIndex =3D self.input.index() @@ -2298,7 +2252,7 @@ class CParser(Parser): # C.g:281:2: ( 'const' | 'volatile' | 'IN' | 'OUT' | 'OPTI= ONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFERENCED= ' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' ) # C.g: if (49 <=3D self.input.LA(1) <=3D 61): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -2310,14 +2264,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_type_qualifier0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2336,10 +2285,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start declarator # C.g:296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERV= ICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer ); + def declarator(self, ): =20 retval =3D self.declarator_return() @@ -2354,30 +2302,32 @@ class CParser(Parser): alt30 =3D 2 LA30_0 =3D self.input.LA(1) =20 - if (LA30_0 =3D=3D 66) : + if (LA30_0 =3D=3D 66): LA30_1 =3D self.input.LA(2) =20 - if (self.synpred66()) : + if (self.synpred66()): alt30 =3D 1 - elif (True) : + elif (True): alt30 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("296:1: declarator := ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE'= )? direct_declarator | pointer );", 30, 1, self.input) + nvae =3D NoViableAltException( + "296:1: declarator : ( ( pointer )? ( 'EFIAPI'= )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | po= inter );", 30, 1, self.input) =20 raise nvae =20 - elif (LA30_0 =3D=3D IDENTIFIER or (58 <=3D LA30_0 <=3D 60)= or LA30_0 =3D=3D 62) : + elif (LA30_0 =3D=3D IDENTIFIER or (58 <=3D LA30_0 <=3D 60)= or LA30_0 =3D=3D 62): alt30 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("296:1: declarator : ( (= pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? = direct_declarator | pointer );", 30, 0, self.input) + nvae =3D NoViableAltException( + "296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? = ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointe= r );", 30, 0, self.input) =20 raise nvae =20 @@ -2387,67 +2337,63 @@ class CParser(Parser): alt26 =3D 2 LA26_0 =3D self.input.LA(1) =20 - if (LA26_0 =3D=3D 66) : + if (LA26_0 =3D=3D 66): alt26 =3D 1 if alt26 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_decla= rator784) + self.following.append( + self.FOLLOW_pointer_in_declarator784) self.pointer() self.following.pop() if self.failed: return retval =20 - - # C.g:297:13: ( 'EFIAPI' )? alt27 =3D 2 LA27_0 =3D self.input.LA(1) =20 - if (LA27_0 =3D=3D 58) : + if (LA27_0 =3D=3D 58): alt27 =3D 1 if alt27 =3D=3D 1: # C.g:297:14: 'EFIAPI' - self.match(self.input, 58, self.FOLLOW_58_in_decla= rator788) + self.match(self.input, 58, + self.FOLLOW_58_in_declarator788) if self.failed: return retval =20 - - # C.g:297:25: ( 'EFI_BOOTSERVICE' )? alt28 =3D 2 LA28_0 =3D self.input.LA(1) =20 - if (LA28_0 =3D=3D 59) : + if (LA28_0 =3D=3D 59): alt28 =3D 1 if alt28 =3D=3D 1: # C.g:297:26: 'EFI_BOOTSERVICE' - self.match(self.input, 59, self.FOLLOW_59_in_decla= rator793) + self.match(self.input, 59, + self.FOLLOW_59_in_declarator793) if self.failed: return retval =20 - - # C.g:297:46: ( 'EFI_RUNTIMESERVICE' )? alt29 =3D 2 LA29_0 =3D self.input.LA(1) =20 - if (LA29_0 =3D=3D 60) : + if (LA29_0 =3D=3D 60): alt29 =3D 1 if alt29 =3D=3D 1: # C.g:297:47: 'EFI_RUNTIMESERVICE' - self.match(self.input, 60, self.FOLLOW_60_in_decla= rator798) + self.match(self.input, 60, + self.FOLLOW_60_in_declarator798) if self.failed: return retval =20 - - - self.following.append(self.FOLLOW_direct_declarator_in= _declarator802) + self.following.append( + self.FOLLOW_direct_declarator_in_declarator802) self.direct_declarator() self.following.pop() if self.failed: return retval =20 - elif alt30 =3D=3D 2: # C.g:299:4: pointer self.following.append(self.FOLLOW_pointer_in_declarato= r808) @@ -2456,10 +2402,8 @@ class CParser(Parser): if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2473,9 +2417,9 @@ class CParser(Parser): =20 # $ANTLR end declarator =20 - # $ANTLR start direct_declarator # C.g:302:1: direct_declarator : ( IDENTIFIER ( declarator_suffix )* |= '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ ); + def direct_declarator(self, ): =20 direct_declarator_StartIndex =3D self.input.index() @@ -2488,556 +2432,485 @@ class CParser(Parser): alt34 =3D 2 LA34_0 =3D self.input.LA(1) =20 - if (LA34_0 =3D=3D IDENTIFIER) : + if (LA34_0 =3D=3D IDENTIFIER): alt34 =3D 1 - elif (LA34_0 =3D=3D 62) : + elif (LA34_0 =3D=3D 62): alt34 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("302:1: direct_declarato= r : ( IDENTIFIER ( declarator_suffix )* | '(' ( 'EFIAPI' )? declarator ')' = ( declarator_suffix )+ );", 34, 0, self.input) + nvae =3D NoViableAltException( + "302:1: direct_declarator : ( IDENTIFIER ( declara= tor_suffix )* | '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ );"= , 34, 0, self.input) =20 raise nvae =20 if alt34 =3D=3D 1: # C.g:303:4: IDENTIFIER ( declarator_suffix )* - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_direct_declarator819) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_direct_declarator= 819) if self.failed: return # C.g:303:15: ( declarator_suffix )* - while True: #loop31 + while True: # loop31 alt31 =3D 2 LA31_0 =3D self.input.LA(1) =20 - if (LA31_0 =3D=3D 62) : + if (LA31_0 =3D=3D 62): LA31 =3D self.input.LA(2) if LA31 =3D=3D 63: LA31_30 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 58: LA31_31 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 66: LA31_32 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 59: LA31_33 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 60: LA31_34 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D IDENTIFIER: LA31_35 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 29 or LA31 =3D=3D 30 or LA31 = =3D=3D 31 or LA31 =3D=3D 32 or LA31 =3D=3D 33: LA31_37 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 34: LA31_38 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 35: LA31_39 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 36: LA31_40 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 37: LA31_41 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 38: LA31_42 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 39: LA31_43 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 40: LA31_44 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 41: LA31_45 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 42: LA31_46 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 45 or LA31 =3D=3D 46: LA31_47 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 48: LA31_48 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 49 or LA31 =3D=3D 50 or LA31 = =3D=3D 51 or LA31 =3D=3D 52 or LA31 =3D=3D 53 or LA31 =3D=3D 54 or LA31 =3D= =3D 55 or LA31 =3D=3D 56 or LA31 =3D=3D 57 or LA31 =3D=3D 61: LA31_49 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - - - elif (LA31_0 =3D=3D 64) : + elif (LA31_0 =3D=3D 64): LA31 =3D self.input.LA(2) if LA31 =3D=3D 65: LA31_51 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 62: LA31_52 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D IDENTIFIER: LA31_53 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D HEX_LITERAL: LA31_54 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D OCTAL_LITERAL: LA31_55 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D DECIMAL_LITERAL: LA31_56 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D CHARACTER_LITERAL: LA31_57 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D STRING_LITERAL: LA31_58 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D FLOATING_POINT_LITERAL: LA31_59 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 72: LA31_60 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 73: LA31_61 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 66 or LA31 =3D=3D 68 or LA31 = =3D=3D 69 or LA31 =3D=3D 77 or LA31 =3D=3D 78 or LA31 =3D=3D 79: LA31_62 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 74: LA31_63 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - - - - if alt31 =3D=3D 1: # C.g:0:0: declarator_suffix - self.following.append(self.FOLLOW_declarator_s= uffix_in_direct_declarator821) + self.following.append( + self.FOLLOW_declarator_suffix_in_direct_de= clarator821) self.declarator_suffix() self.following.pop() if self.failed: return =20 - else: - break #loop31 - - - + break # loop31 =20 elif alt34 =3D=3D 2: # C.g:304:4: '(' ( 'EFIAPI' )? declarator ')' ( declar= ator_suffix )+ - self.match(self.input, 62, self.FOLLOW_62_in_direct_de= clarator827) + self.match(self.input, 62, + self.FOLLOW_62_in_direct_declarator827) if self.failed: return # C.g:304:8: ( 'EFIAPI' )? alt32 =3D 2 LA32_0 =3D self.input.LA(1) =20 - if (LA32_0 =3D=3D 58) : + if (LA32_0 =3D=3D 58): LA32_1 =3D self.input.LA(2) =20 - if (self.synpred69()) : + if (self.synpred69()): alt32 =3D 1 if alt32 =3D=3D 1: # C.g:304:9: 'EFIAPI' - self.match(self.input, 58, self.FOLLOW_58_in_direc= t_declarator830) + self.match(self.input, 58, + self.FOLLOW_58_in_direct_declarator830) if self.failed: return =20 - - - self.following.append(self.FOLLOW_declarator_in_direct= _declarator834) + self.following.append( + self.FOLLOW_declarator_in_direct_declarator834) self.declarator() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_direct_de= clarator836) + self.match(self.input, 63, + self.FOLLOW_63_in_direct_declarator836) if self.failed: return # C.g:304:35: ( declarator_suffix )+ cnt33 =3D 0 - while True: #loop33 + while True: # loop33 alt33 =3D 2 LA33_0 =3D self.input.LA(1) =20 - if (LA33_0 =3D=3D 62) : + if (LA33_0 =3D=3D 62): LA33 =3D self.input.LA(2) if LA33 =3D=3D 63: LA33_30 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 58: LA33_31 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 66: LA33_32 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 59: LA33_33 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 60: LA33_34 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D IDENTIFIER: LA33_35 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 29 or LA33 =3D=3D 30 or LA33 = =3D=3D 31 or LA33 =3D=3D 32 or LA33 =3D=3D 33: LA33_37 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 34: LA33_38 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 35: LA33_39 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 36: LA33_40 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 37: LA33_41 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 38: LA33_42 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 39: LA33_43 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 40: LA33_44 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 41: LA33_45 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 42: LA33_46 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 45 or LA33 =3D=3D 46: LA33_47 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 48: LA33_48 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 49 or LA33 =3D=3D 50 or LA33 = =3D=3D 51 or LA33 =3D=3D 52 or LA33 =3D=3D 53 or LA33 =3D=3D 54 or LA33 =3D= =3D 55 or LA33 =3D=3D 56 or LA33 =3D=3D 57 or LA33 =3D=3D 61: LA33_49 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - - - elif (LA33_0 =3D=3D 64) : + elif (LA33_0 =3D=3D 64): LA33 =3D self.input.LA(2) if LA33 =3D=3D 65: LA33_51 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 62: LA33_52 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D IDENTIFIER: LA33_53 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D HEX_LITERAL: LA33_54 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D OCTAL_LITERAL: LA33_55 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D DECIMAL_LITERAL: LA33_56 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D CHARACTER_LITERAL: LA33_57 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D STRING_LITERAL: LA33_58 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D FLOATING_POINT_LITERAL: LA33_59 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 72: LA33_60 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 73: LA33_61 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 66 or LA33 =3D=3D 68 or LA33 = =3D=3D 69 or LA33 =3D=3D 77 or LA33 =3D=3D 78 or LA33 =3D=3D 79: LA33_62 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 74: LA33_63 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - - - - if alt33 =3D=3D 1: # C.g:0:0: declarator_suffix - self.following.append(self.FOLLOW_declarator_s= uffix_in_direct_declarator838) + self.following.append( + self.FOLLOW_declarator_suffix_in_direct_de= clarator838) self.declarator_suffix() self.following.pop() if self.failed: return =20 - else: if cnt33 >=3D 1: - break #loop33 + break # loop33 =20 if self.backtracking > 0: self.failed =3D True @@ -3048,10 +2921,6 @@ class CParser(Parser): =20 cnt33 +=3D 1 =20 - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3065,9 +2934,9 @@ class CParser(Parser): =20 # $ANTLR end direct_declarator =20 - # $ANTLR start declarator_suffix # C.g:307:1: declarator_suffix : ( '[' constant_expression ']' | '[' '= ]' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' ); + def declarator_suffix(self, ): =20 declarator_suffix_StartIndex =3D self.input.index() @@ -3080,23 +2949,24 @@ class CParser(Parser): alt35 =3D 5 LA35_0 =3D self.input.LA(1) =20 - if (LA35_0 =3D=3D 64) : + if (LA35_0 =3D=3D 64): LA35_1 =3D self.input.LA(2) =20 - if (LA35_1 =3D=3D 65) : + if (LA35_1 =3D=3D 65): alt35 =3D 2 - elif ((IDENTIFIER <=3D LA35_1 <=3D FLOATING_POINT_LITE= RAL) or LA35_1 =3D=3D 62 or LA35_1 =3D=3D 66 or (68 <=3D LA35_1 <=3D 69) or= (72 <=3D LA35_1 <=3D 74) or (77 <=3D LA35_1 <=3D 79)) : + elif ((IDENTIFIER <=3D LA35_1 <=3D FLOATING_POINT_LITE= RAL) or LA35_1 =3D=3D 62 or LA35_1 =3D=3D 66 or (68 <=3D LA35_1 <=3D 69) or= (72 <=3D LA35_1 <=3D 74) or (77 <=3D LA35_1 <=3D 79)): alt35 =3D 1 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_s= uffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list '= )' | '(' identifier_list ')' | '(' ')' );", 35, 1, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_exp= ression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list '= )' | '(' ')' );", 35, 1, self.input) =20 raise nvae =20 - elif (LA35_0 =3D=3D 62) : + elif (LA35_0 =3D=3D 62): LA35 =3D self.input.LA(2) if LA35 =3D=3D 63: alt35 =3D 5 @@ -3105,16 +2975,17 @@ class CParser(Parser): elif LA35 =3D=3D IDENTIFIER: LA35_29 =3D self.input.LA(3) =20 - if (self.synpred73()) : + if (self.synpred73()): alt35 =3D 3 - elif (self.synpred74()) : + elif (self.synpred74()): alt35 =3D 4 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarat= or_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_li= st ')' | '(' identifier_list ')' | '(' ')' );", 35, 29, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant= _expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_li= st ')' | '(' ')' );", 35, 29, self.input) =20 raise nvae =20 @@ -3123,7 +2994,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_s= uffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list '= )' | '(' identifier_list ')' | '(' ')' );", 35, 2, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_exp= ression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list '= )' | '(' ')' );", 35, 2, self.input) =20 raise nvae =20 @@ -3132,76 +3004,84 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_suffi= x : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' |= '(' identifier_list ')' | '(' ')' );", 35, 0, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_express= ion ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' |= '(' ')' );", 35, 0, self.input) =20 raise nvae =20 if alt35 =3D=3D 1: # C.g:308:6: '[' constant_expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_declarato= r_suffix852) + self.match(self.input, 64, + self.FOLLOW_64_in_declarator_suffix852) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_declarator_suffix854) + self.following.append( + self.FOLLOW_constant_expression_in_declarator_suff= ix854) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_declarato= r_suffix856) + self.match(self.input, 65, + self.FOLLOW_65_in_declarator_suffix856) if self.failed: return =20 - elif alt35 =3D=3D 2: # C.g:309:9: '[' ']' - self.match(self.input, 64, self.FOLLOW_64_in_declarato= r_suffix866) + self.match(self.input, 64, + self.FOLLOW_64_in_declarator_suffix866) if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_declarato= r_suffix868) + self.match(self.input, 65, + self.FOLLOW_65_in_declarator_suffix868) if self.failed: return =20 - elif alt35 =3D=3D 3: # C.g:310:9: '(' parameter_type_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix878) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix878) if self.failed: return - self.following.append(self.FOLLOW_parameter_type_list_= in_declarator_suffix880) + self.following.append( + self.FOLLOW_parameter_type_list_in_declarator_suff= ix880) self.parameter_type_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix882) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix882) if self.failed: return =20 - elif alt35 =3D=3D 4: # C.g:311:9: '(' identifier_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix892) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix892) if self.failed: return - self.following.append(self.FOLLOW_identifier_list_in_d= eclarator_suffix894) + self.following.append( + self.FOLLOW_identifier_list_in_declarator_suffix89= 4) self.identifier_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix896) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix896) if self.failed: return =20 - elif alt35 =3D=3D 5: # C.g:312:9: '(' ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix906) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix906) if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix908) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix908) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3215,9 +3095,9 @@ class CParser(Parser): =20 # $ANTLR end declarator_suffix =20 - # $ANTLR start pointer # C.g:315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' po= inter | '*' ); + def pointer(self, ): =20 pointer_StartIndex =3D self.input.index() @@ -3230,69 +3110,73 @@ class CParser(Parser): alt38 =3D 3 LA38_0 =3D self.input.LA(1) =20 - if (LA38_0 =3D=3D 66) : + if (LA38_0 =3D=3D 66): LA38 =3D self.input.LA(2) if LA38 =3D=3D 66: LA38_2 =3D self.input.LA(3) =20 - if (self.synpred78()) : + if (self.synpred78()): alt38 =3D 2 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 2, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 2, self.input) =20 raise nvae =20 elif LA38 =3D=3D 58: LA38_3 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 3, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 3, self.input) =20 raise nvae =20 elif LA38 =3D=3D 59: LA38_4 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 4, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 4, self.input) =20 raise nvae =20 elif LA38 =3D=3D 60: LA38_5 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 5, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 5, self.input) =20 raise nvae =20 @@ -3301,32 +3185,34 @@ class CParser(Parser): elif LA38 =3D=3D 53: LA38_21 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 21, s= elf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 21, self.input) =20 raise nvae =20 elif LA38 =3D=3D 49 or LA38 =3D=3D 50 or LA38 =3D=3D 5= 1 or LA38 =3D=3D 52 or LA38 =3D=3D 54 or LA38 =3D=3D 55 or LA38 =3D=3D 56 o= r LA38 =3D=3D 57 or LA38 =3D=3D 61: LA38_29 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 29, s= elf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 29, self.input) =20 raise nvae =20 @@ -3335,7 +3221,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer : ( = '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 1, self.i= nput) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )+ ( = pointer )? | '*' pointer | '*' );", 38, 1, self.input) =20 raise nvae =20 @@ -3344,7 +3231,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer : ( '*' = ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 0, self.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )+ ( poin= ter )? | '*' pointer | '*' );", 38, 0, self.input) =20 raise nvae =20 @@ -3355,57 +3243,51 @@ class CParser(Parser): return # C.g:316:8: ( type_qualifier )+ cnt36 =3D 0 - while True: #loop36 + while True: # loop36 alt36 =3D 2 LA36 =3D self.input.LA(1) if LA36 =3D=3D 58: LA36_2 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 59: LA36_3 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 60: LA36_4 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 53: LA36_20 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 49 or LA36 =3D=3D 50 or LA36 =3D= =3D 51 or LA36 =3D=3D 52 or LA36 =3D=3D 54 or LA36 =3D=3D 55 or LA36 =3D=3D= 56 or LA36 =3D=3D 57 or LA36 =3D=3D 61: LA36_28 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - - if alt36 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifi= er_in_pointer921) + self.following.append( + self.FOLLOW_type_qualifier_in_pointer921) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: if cnt36 >=3D 1: - break #loop36 + break # loop36 =20 if self.backtracking > 0: self.failed =3D True @@ -3416,28 +3298,24 @@ class CParser(Parser): =20 cnt36 +=3D 1 =20 - # C.g:316:24: ( pointer )? alt37 =3D 2 LA37_0 =3D self.input.LA(1) =20 - if (LA37_0 =3D=3D 66) : + if (LA37_0 =3D=3D 66): LA37_1 =3D self.input.LA(2) =20 - if (self.synpred76()) : + if (self.synpred76()): alt37 =3D 1 if alt37 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_point= er924) + self.following.append( + self.FOLLOW_pointer_in_pointer924) self.pointer() self.following.pop() if self.failed: return =20 - - - - elif alt38 =3D=3D 2: # C.g:317:4: '*' pointer self.match(self.input, 66, self.FOLLOW_66_in_pointer93= 0) @@ -3449,15 +3327,12 @@ class CParser(Parser): if self.failed: return =20 - elif alt38 =3D=3D 3: # C.g:318:4: '*' self.match(self.input, 66, self.FOLLOW_66_in_pointer93= 7) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3471,9 +3346,9 @@ class CParser(Parser): =20 # $ANTLR end pointer =20 - # $ANTLR start parameter_type_list # C.g:321:1: parameter_type_list : parameter_list ( ',' ( 'OPTIONAL' )= ? '...' )? ; + def parameter_type_list(self, ): =20 parameter_type_list_StartIndex =3D self.input.index() @@ -3484,7 +3359,8 @@ class CParser(Parser): =20 # C.g:322:2: ( parameter_list ( ',' ( 'OPTIONAL' )? '...' = )? ) # C.g:322:4: parameter_list ( ',' ( 'OPTIONAL' )? '...' )? - self.following.append(self.FOLLOW_parameter_list_in_parame= ter_type_list948) + self.following.append( + self.FOLLOW_parameter_list_in_parameter_type_list948) self.parameter_list() self.following.pop() if self.failed: @@ -3493,37 +3369,32 @@ class CParser(Parser): alt40 =3D 2 LA40_0 =3D self.input.LA(1) =20 - if (LA40_0 =3D=3D 27) : + if (LA40_0 =3D=3D 27): alt40 =3D 1 if alt40 =3D=3D 1: # C.g:322:20: ',' ( 'OPTIONAL' )? '...' - self.match(self.input, 27, self.FOLLOW_27_in_parameter= _type_list951) + self.match(self.input, 27, + self.FOLLOW_27_in_parameter_type_list951) if self.failed: return # C.g:322:24: ( 'OPTIONAL' )? alt39 =3D 2 LA39_0 =3D self.input.LA(1) =20 - if (LA39_0 =3D=3D 53) : + if (LA39_0 =3D=3D 53): alt39 =3D 1 if alt39 =3D=3D 1: # C.g:322:25: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_param= eter_type_list954) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_type_list95= 4) if self.failed: return =20 - - - self.match(self.input, 67, self.FOLLOW_67_in_parameter= _type_list958) + self.match(self.input, 67, + self.FOLLOW_67_in_parameter_type_list958) if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3537,9 +3408,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_type_list =20 - # $ANTLR start parameter_list # C.g:325:1: parameter_list : parameter_declaration ( ',' ( 'OPTIONAL'= )? parameter_declaration )* ; + def parameter_list(self, ): =20 parameter_list_StartIndex =3D self.input.index() @@ -3550,68 +3421,60 @@ class CParser(Parser): =20 # C.g:326:2: ( parameter_declaration ( ',' ( 'OPTIONAL' )?= parameter_declaration )* ) # C.g:326:4: parameter_declaration ( ',' ( 'OPTIONAL' )? p= arameter_declaration )* - self.following.append(self.FOLLOW_parameter_declaration_in= _parameter_list971) + self.following.append( + self.FOLLOW_parameter_declaration_in_parameter_list971) self.parameter_declaration() self.following.pop() if self.failed: return # C.g:326:26: ( ',' ( 'OPTIONAL' )? parameter_declaration = )* - while True: #loop42 + while True: # loop42 alt42 =3D 2 LA42_0 =3D self.input.LA(1) =20 - if (LA42_0 =3D=3D 27) : + if (LA42_0 =3D=3D 27): LA42_1 =3D self.input.LA(2) =20 - if (LA42_1 =3D=3D 53) : + if (LA42_1 =3D=3D 53): LA42_3 =3D self.input.LA(3) =20 - if (self.synpred82()) : + if (self.synpred82()): alt42 =3D 1 =20 - - elif (LA42_1 =3D=3D IDENTIFIER or (29 <=3D LA42_1 = <=3D 42) or (45 <=3D LA42_1 <=3D 46) or (48 <=3D LA42_1 <=3D 52) or (54 <= =3D LA42_1 <=3D 61) or LA42_1 =3D=3D 66) : + elif (LA42_1 =3D=3D IDENTIFIER or (29 <=3D LA42_1 = <=3D 42) or (45 <=3D LA42_1 <=3D 46) or (48 <=3D LA42_1 <=3D 52) or (54 <= =3D LA42_1 <=3D 61) or LA42_1 =3D=3D 66): alt42 =3D 1 =20 - - - if alt42 =3D=3D 1: # C.g:326:27: ',' ( 'OPTIONAL' )? parameter_declar= ation - self.match(self.input, 27, self.FOLLOW_27_in_param= eter_list974) + self.match(self.input, 27, + self.FOLLOW_27_in_parameter_list974) if self.failed: return # C.g:326:31: ( 'OPTIONAL' )? alt41 =3D 2 LA41_0 =3D self.input.LA(1) =20 - if (LA41_0 =3D=3D 53) : + if (LA41_0 =3D=3D 53): LA41_1 =3D self.input.LA(2) =20 - if (self.synpred81()) : + if (self.synpred81()): alt41 =3D 1 if alt41 =3D=3D 1: # C.g:326:32: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_p= arameter_list977) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_list977) if self.failed: return =20 - - - self.following.append(self.FOLLOW_parameter_declar= ation_in_parameter_list981) + self.following.append( + self.FOLLOW_parameter_declaration_in_parameter= _list981) self.parameter_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop42 - - - - - + break # loop42 =20 except RecognitionException as re: self.reportError(re) @@ -3626,9 +3489,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_list =20 - # $ANTLR start parameter_declaration # C.g:329:1: parameter_declaration : ( declaration_specifiers ( declar= ator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointer )* IDENTIFIER ); + def parameter_declaration(self, ): =20 parameter_declaration_StartIndex =3D self.input.index() @@ -3645,16 +3508,17 @@ class CParser(Parser): elif LA46 =3D=3D IDENTIFIER: LA46_13 =3D self.input.LA(2) =20 - if (self.synpred86()) : + if (self.synpred86()): alt46 =3D 1 - elif (True) : + elif (True): alt46 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("329:1: parameter_de= claration : ( declaration_specifiers ( declarator | abstract_declarator )* = ( 'OPTIONAL' )? | ( pointer )* IDENTIFIER );", 46, 13, self.input) + nvae =3D NoViableAltException( + "329:1: parameter_declaration : ( declaration_= specifiers ( declarator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointe= r )* IDENTIFIER );", 46, 13, self.input) =20 raise nvae =20 @@ -3665,30 +3529,31 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("329:1: parameter_declar= ation : ( declaration_specifiers ( declarator | abstract_declarator )* ( 'O= PTIONAL' )? | ( pointer )* IDENTIFIER );", 46, 0, self.input) + nvae =3D NoViableAltException( + "329:1: parameter_declaration : ( declaration_spec= ifiers ( declarator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointer )*= IDENTIFIER );", 46, 0, self.input) =20 raise nvae =20 if alt46 =3D=3D 1: # C.g:330:4: declaration_specifiers ( declarator | abs= tract_declarator )* ( 'OPTIONAL' )? - self.following.append(self.FOLLOW_declaration_specifie= rs_in_parameter_declaration994) + self.following.append( + self.FOLLOW_declaration_specifiers_in_parameter_de= claration994) self.declaration_specifiers() self.following.pop() if self.failed: return # C.g:330:27: ( declarator | abstract_declarator )* - while True: #loop43 + while True: # loop43 alt43 =3D 3 LA43 =3D self.input.LA(1) if LA43 =3D=3D 66: LA43_5 =3D self.input.LA(2) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D IDENTIFIER or LA43 =3D=3D 58 or L= A43 =3D=3D 59 or LA43 =3D=3D 60: alt43 =3D 1 elif LA43 =3D=3D 62: @@ -3698,129 +3563,115 @@ class CParser(Parser): elif LA43 =3D=3D IDENTIFIER: LA43_37 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 58: LA43_38 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 66: LA43_39 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 59: LA43_40 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 60: LA43_41 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 62: LA43_43 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - - elif LA43 =3D=3D 64: alt43 =3D 2 =20 if alt43 =3D=3D 1: # C.g:330:28: declarator - self.following.append(self.FOLLOW_declarator_i= n_parameter_declaration997) + self.following.append( + self.FOLLOW_declarator_in_parameter_declar= ation997) self.declarator() self.following.pop() if self.failed: return =20 - elif alt43 =3D=3D 2: # C.g:330:39: abstract_declarator - self.following.append(self.FOLLOW_abstract_dec= larator_in_parameter_declaration999) + self.following.append( + self.FOLLOW_abstract_declarator_in_paramet= er_declaration999) self.abstract_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop43 - + break # loop43 =20 # C.g:330:61: ( 'OPTIONAL' )? alt44 =3D 2 LA44_0 =3D self.input.LA(1) =20 - if (LA44_0 =3D=3D 53) : + if (LA44_0 =3D=3D 53): alt44 =3D 1 if alt44 =3D=3D 1: # C.g:330:62: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_param= eter_declaration1004) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_declaration= 1004) if self.failed: return =20 - - - - elif alt46 =3D=3D 2: # C.g:332:4: ( pointer )* IDENTIFIER # C.g:332:4: ( pointer )* - while True: #loop45 + while True: # loop45 alt45 =3D 2 LA45_0 =3D self.input.LA(1) =20 - if (LA45_0 =3D=3D 66) : + if (LA45_0 =3D=3D 66): alt45 =3D 1 =20 - if alt45 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_p= arameter_declaration1013) + self.following.append( + self.FOLLOW_pointer_in_parameter_declarati= on1013) self.pointer() self.following.pop() if self.failed: return =20 - else: - break #loop45 + break # loop45 =20 - - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_parameter_declaration1016) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_parameter_declara= tion1016) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3834,9 +3685,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_declaration =20 - # $ANTLR start identifier_list # C.g:335:1: identifier_list : IDENTIFIER ( ',' IDENTIFIER )* ; + def identifier_list(self, ): =20 identifier_list_StartIndex =3D self.input.index() @@ -3847,35 +3698,31 @@ class CParser(Parser): =20 # C.g:336:2: ( IDENTIFIER ( ',' IDENTIFIER )* ) # C.g:336:4: IDENTIFIER ( ',' IDENTIFIER )* - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_identifier_list1027) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_identifier_list1027) if self.failed: return # C.g:337:2: ( ',' IDENTIFIER )* - while True: #loop47 + while True: # loop47 alt47 =3D 2 LA47_0 =3D self.input.LA(1) =20 - if (LA47_0 =3D=3D 27) : + if (LA47_0 =3D=3D 27): alt47 =3D 1 =20 - if alt47 =3D=3D 1: # C.g:337:3: ',' IDENTIFIER - self.match(self.input, 27, self.FOLLOW_27_in_ident= ifier_list1031) + self.match(self.input, 27, + self.FOLLOW_27_in_identifier_list1031) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_identifier_list1033) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_identifier_li= st1033) if self.failed: return =20 - else: - break #loop47 - - - - - + break # loop47 =20 except RecognitionException as re: self.reportError(re) @@ -3890,9 +3737,9 @@ class CParser(Parser): =20 # $ANTLR end identifier_list =20 - # $ANTLR start type_name # C.g:340:1: type_name : ( specifier_qualifier_list ( abstract_declara= tor )? | type_id ); + def type_name(self, ): =20 type_name_StartIndex =3D self.input.index() @@ -3905,21 +3752,22 @@ class CParser(Parser): alt49 =3D 2 LA49_0 =3D self.input.LA(1) =20 - if ((34 <=3D LA49_0 <=3D 42) or (45 <=3D LA49_0 <=3D 46) o= r (48 <=3D LA49_0 <=3D 61)) : + if ((34 <=3D LA49_0 <=3D 42) or (45 <=3D LA49_0 <=3D 46) o= r (48 <=3D LA49_0 <=3D 61)): alt49 =3D 1 - elif (LA49_0 =3D=3D IDENTIFIER) : + elif (LA49_0 =3D=3D IDENTIFIER): LA49_13 =3D self.input.LA(2) =20 - if (self.synpred90()) : + if (self.synpred90()): alt49 =3D 1 - elif (True) : + elif (True): alt49 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("340:1: type_name : = ( specifier_qualifier_list ( abstract_declarator )? | type_id );", 49, 13, = self.input) + nvae =3D NoViableAltException( + "340:1: type_name : ( specifier_qualifier_list= ( abstract_declarator )? | type_id );", 49, 13, self.input) =20 raise nvae =20 @@ -3928,13 +3776,15 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("340:1: type_name : ( sp= ecifier_qualifier_list ( abstract_declarator )? | type_id );", 49, 0, self.= input) + nvae =3D NoViableAltException( + "340:1: type_name : ( specifier_qualifier_list ( a= bstract_declarator )? | type_id );", 49, 0, self.input) =20 raise nvae =20 if alt49 =3D=3D 1: # C.g:341:4: specifier_qualifier_list ( abstract_decla= rator )? - self.following.append(self.FOLLOW_specifier_qualifier_= list_in_type_name1046) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_type_name1= 046) self.specifier_qualifier_list() self.following.pop() if self.failed: @@ -3943,20 +3793,17 @@ class CParser(Parser): alt48 =3D 2 LA48_0 =3D self.input.LA(1) =20 - if (LA48_0 =3D=3D 62 or LA48_0 =3D=3D 64 or LA48_0 =3D= =3D 66) : + if (LA48_0 =3D=3D 62 or LA48_0 =3D=3D 64 or LA48_0 =3D= =3D 66): alt48 =3D 1 if alt48 =3D=3D 1: # C.g:0:0: abstract_declarator - self.following.append(self.FOLLOW_abstract_declara= tor_in_type_name1048) + self.following.append( + self.FOLLOW_abstract_declarator_in_type_name10= 48) self.abstract_declarator() self.following.pop() if self.failed: return =20 - - - - elif alt49 =3D=3D 2: # C.g:342:4: type_id self.following.append(self.FOLLOW_type_id_in_type_name= 1054) @@ -3965,8 +3812,6 @@ class CParser(Parser): if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3980,9 +3825,9 @@ class CParser(Parser): =20 # $ANTLR end type_name =20 - # $ANTLR start abstract_declarator # C.g:345:1: abstract_declarator : ( pointer ( direct_abstract_declara= tor )? | direct_abstract_declarator ); + def abstract_declarator(self, ): =20 abstract_declarator_StartIndex =3D self.input.index() @@ -3995,22 +3840,24 @@ class CParser(Parser): alt51 =3D 2 LA51_0 =3D self.input.LA(1) =20 - if (LA51_0 =3D=3D 66) : + if (LA51_0 =3D=3D 66): alt51 =3D 1 - elif (LA51_0 =3D=3D 62 or LA51_0 =3D=3D 64) : + elif (LA51_0 =3D=3D 62 or LA51_0 =3D=3D 64): alt51 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("345:1: abstract_declara= tor : ( pointer ( direct_abstract_declarator )? | direct_abstract_declarato= r );", 51, 0, self.input) + nvae =3D NoViableAltException( + "345:1: abstract_declarator : ( pointer ( direct_a= bstract_declarator )? | direct_abstract_declarator );", 51, 0, self.input) =20 raise nvae =20 if alt51 =3D=3D 1: # C.g:346:4: pointer ( direct_abstract_declarator )? - self.following.append(self.FOLLOW_pointer_in_abstract_= declarator1065) + self.following.append( + self.FOLLOW_pointer_in_abstract_declarator1065) self.pointer() self.following.pop() if self.failed: @@ -4019,202 +3866,198 @@ class CParser(Parser): alt50 =3D 2 LA50_0 =3D self.input.LA(1) =20 - if (LA50_0 =3D=3D 62) : + if (LA50_0 =3D=3D 62): LA50 =3D self.input.LA(2) if LA50 =3D=3D 63: LA50_12 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 58: LA50_13 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 66: LA50_14 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 59: LA50_15 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 60: LA50_16 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D IDENTIFIER: LA50_17 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 62: LA50_18 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 64: LA50_19 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 29 or LA50 =3D=3D 30 or LA50 =3D= =3D 31 or LA50 =3D=3D 32 or LA50 =3D=3D 33: LA50_20 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 34: LA50_21 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 35: LA50_22 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 36: LA50_23 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 37: LA50_24 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 38: LA50_25 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 39: LA50_26 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 40: LA50_27 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 41: LA50_28 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 42: LA50_29 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 45 or LA50 =3D=3D 46: LA50_30 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 48: LA50_31 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 49 or LA50 =3D=3D 50 or LA50 =3D= =3D 51 or LA50 =3D=3D 52 or LA50 =3D=3D 53 or LA50 =3D=3D 54 or LA50 =3D=3D= 55 or LA50 =3D=3D 56 or LA50 =3D=3D 57 or LA50 =3D=3D 61: LA50_32 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 - elif (LA50_0 =3D=3D 64) : + elif (LA50_0 =3D=3D 64): LA50 =3D self.input.LA(2) if LA50 =3D=3D 65: LA50_33 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 62: LA50_34 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D IDENTIFIER: LA50_35 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D HEX_LITERAL: LA50_36 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D OCTAL_LITERAL: LA50_37 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D DECIMAL_LITERAL: LA50_38 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D CHARACTER_LITERAL: LA50_39 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D STRING_LITERAL: LA50_40 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D FLOATING_POINT_LITERAL: LA50_41 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 72: LA50_42 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 73: LA50_43 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 66 or LA50 =3D=3D 68 or LA50 =3D= =3D 69 or LA50 =3D=3D 77 or LA50 =3D=3D 78 or LA50 =3D=3D 79: LA50_44 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 74: LA50_45 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 if alt50 =3D=3D 1: # C.g:0:0: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_= declarator_in_abstract_declarator1067) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_abst= ract_declarator1067) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - - - - elif alt51 =3D=3D 2: # C.g:347:4: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_decl= arator_in_abstract_declarator1073) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_abstract= _declarator1073) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -4228,9 +4071,9 @@ class CParser(Parser): =20 # $ANTLR end abstract_declarator =20 - # $ANTLR start direct_abstract_declarator # C.g:350:1: direct_abstract_declarator : ( '(' abstract_declarator ')= ' | abstract_declarator_suffix ) ( abstract_declarator_suffix )* ; + def direct_abstract_declarator(self, ): =20 direct_abstract_declarator_StartIndex =3D self.input.index() @@ -4245,23 +4088,24 @@ class CParser(Parser): alt52 =3D 2 LA52_0 =3D self.input.LA(1) =20 - if (LA52_0 =3D=3D 62) : + if (LA52_0 =3D=3D 62): LA52 =3D self.input.LA(2) if LA52 =3D=3D IDENTIFIER or LA52 =3D=3D 29 or LA52 = =3D=3D 30 or LA52 =3D=3D 31 or LA52 =3D=3D 32 or LA52 =3D=3D 33 or LA52 =3D= =3D 34 or LA52 =3D=3D 35 or LA52 =3D=3D 36 or LA52 =3D=3D 37 or LA52 =3D=3D= 38 or LA52 =3D=3D 39 or LA52 =3D=3D 40 or LA52 =3D=3D 41 or LA52 =3D=3D 42= or LA52 =3D=3D 45 or LA52 =3D=3D 46 or LA52 =3D=3D 48 or LA52 =3D=3D 49 or= LA52 =3D=3D 50 or LA52 =3D=3D 51 or LA52 =3D=3D 52 or LA52 =3D=3D 53 or LA= 52 =3D=3D 54 or LA52 =3D=3D 55 or LA52 =3D=3D 56 or LA52 =3D=3D 57 or LA52 = =3D=3D 58 or LA52 =3D=3D 59 or LA52 =3D=3D 60 or LA52 =3D=3D 61 or LA52 =3D= =3D 63: alt52 =3D 2 elif LA52 =3D=3D 66: LA52_18 =3D self.input.LA(3) =20 - if (self.synpred93()) : + if (self.synpred93()): alt52 =3D 1 - elif (True) : + elif (True): alt52 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' ab= stract_declarator ')' | abstract_declarator_suffix )", 52, 18, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | ab= stract_declarator_suffix )", 52, 18, self.input) =20 raise nvae =20 @@ -4272,306 +4116,269 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' abstra= ct_declarator ')' | abstract_declarator_suffix )", 52, 1, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | abstra= ct_declarator_suffix )", 52, 1, self.input) =20 raise nvae =20 - elif (LA52_0 =3D=3D 64) : + elif (LA52_0 =3D=3D 64): alt52 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' abstract_d= eclarator ')' | abstract_declarator_suffix )", 52, 0, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | abstract_d= eclarator_suffix )", 52, 0, self.input) =20 raise nvae =20 if alt52 =3D=3D 1: # C.g:351:6: '(' abstract_declarator ')' - self.match(self.input, 62, self.FOLLOW_62_in_direct_ab= stract_declarator1086) + self.match( + self.input, 62, self.FOLLOW_62_in_direct_abstract_= declarator1086) if self.failed: return - self.following.append(self.FOLLOW_abstract_declarator_= in_direct_abstract_declarator1088) + self.following.append( + self.FOLLOW_abstract_declarator_in_direct_abstract= _declarator1088) self.abstract_declarator() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_direct_ab= stract_declarator1090) + self.match( + self.input, 63, self.FOLLOW_63_in_direct_abstract_= declarator1090) if self.failed: return =20 - elif alt52 =3D=3D 2: # C.g:351:36: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declarator_= suffix_in_direct_abstract_declarator1094) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_direct_a= bstract_declarator1094) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - - # C.g:351:65: ( abstract_declarator_suffix )* - while True: #loop53 + while True: # loop53 alt53 =3D 2 LA53_0 =3D self.input.LA(1) =20 - if (LA53_0 =3D=3D 62) : + if (LA53_0 =3D=3D 62): LA53 =3D self.input.LA(2) if LA53 =3D=3D 63: LA53_12 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 58: LA53_13 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 66: LA53_14 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 59: LA53_15 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 60: LA53_16 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D IDENTIFIER: LA53_17 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 29 or LA53 =3D=3D 30 or LA53 =3D= =3D 31 or LA53 =3D=3D 32 or LA53 =3D=3D 33: LA53_19 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 34: LA53_20 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 35: LA53_21 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 36: LA53_22 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 37: LA53_23 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 38: LA53_24 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 39: LA53_25 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 40: LA53_26 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 41: LA53_27 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 42: LA53_28 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 45 or LA53 =3D=3D 46: LA53_29 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 48: LA53_30 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 49 or LA53 =3D=3D 50 or LA53 =3D= =3D 51 or LA53 =3D=3D 52 or LA53 =3D=3D 53 or LA53 =3D=3D 54 or LA53 =3D=3D= 55 or LA53 =3D=3D 56 or LA53 =3D=3D 57 or LA53 =3D=3D 61: LA53_31 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - - - elif (LA53_0 =3D=3D 64) : + elif (LA53_0 =3D=3D 64): LA53 =3D self.input.LA(2) if LA53 =3D=3D 65: LA53_33 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 62: LA53_34 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D IDENTIFIER: LA53_35 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D HEX_LITERAL: LA53_36 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D OCTAL_LITERAL: LA53_37 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D DECIMAL_LITERAL: LA53_38 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D CHARACTER_LITERAL: LA53_39 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D STRING_LITERAL: LA53_40 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D FLOATING_POINT_LITERAL: LA53_41 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 72: LA53_42 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 73: LA53_43 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 66 or LA53 =3D=3D 68 or LA53 =3D= =3D 69 or LA53 =3D=3D 77 or LA53 =3D=3D 78 or LA53 =3D=3D 79: LA53_44 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 74: LA53_45 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - - - - if alt53 =3D=3D 1: # C.g:0:0: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declara= tor_suffix_in_direct_abstract_declarator1098) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_dire= ct_abstract_declarator1098) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - else: - break #loop53 - - - - - + break # loop53 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 32, direct_abstract_declarator_St= artIndex) + self.memoize(self.input, 32, + direct_abstract_declarator_StartIndex) =20 pass =20 @@ -4579,9 +4386,9 @@ class CParser(Parser): =20 # $ANTLR end direct_abstract_declarator =20 - # $ANTLR start abstract_declarator_suffix # C.g:354:1: abstract_declarator_suffix : ( '[' ']' | '[' constant_exp= ression ']' | '(' ')' | '(' parameter_type_list ')' ); + def abstract_declarator_suffix(self, ): =20 abstract_declarator_suffix_StartIndex =3D self.input.index() @@ -4594,35 +4401,37 @@ class CParser(Parser): alt54 =3D 4 LA54_0 =3D self.input.LA(1) =20 - if (LA54_0 =3D=3D 64) : + if (LA54_0 =3D=3D 64): LA54_1 =3D self.input.LA(2) =20 - if (LA54_1 =3D=3D 65) : + if (LA54_1 =3D=3D 65): alt54 =3D 1 - elif ((IDENTIFIER <=3D LA54_1 <=3D FLOATING_POINT_LITE= RAL) or LA54_1 =3D=3D 62 or LA54_1 =3D=3D 66 or (68 <=3D LA54_1 <=3D 69) or= (72 <=3D LA54_1 <=3D 74) or (77 <=3D LA54_1 <=3D 79)) : + elif ((IDENTIFIER <=3D LA54_1 <=3D FLOATING_POINT_LITE= RAL) or LA54_1 =3D=3D 62 or LA54_1 =3D=3D 66 or (68 <=3D LA54_1 <=3D 69) or= (72 <=3D LA54_1 <=3D 74) or (77 <=3D LA54_1 <=3D 79)): alt54 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_dec= larator_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' pa= rameter_type_list ')' );", 54, 1, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']'= | '[' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );",= 54, 1, self.input) =20 raise nvae =20 - elif (LA54_0 =3D=3D 62) : + elif (LA54_0 =3D=3D 62): LA54_2 =3D self.input.LA(2) =20 - if (LA54_2 =3D=3D 63) : + if (LA54_2 =3D=3D 63): alt54 =3D 3 - elif (LA54_2 =3D=3D IDENTIFIER or (29 <=3D LA54_2 <=3D= 42) or (45 <=3D LA54_2 <=3D 46) or (48 <=3D LA54_2 <=3D 61) or LA54_2 =3D= =3D 66) : + elif (LA54_2 =3D=3D IDENTIFIER or (29 <=3D LA54_2 <=3D= 42) or (45 <=3D LA54_2 <=3D 46) or (48 <=3D LA54_2 <=3D 61) or LA54_2 =3D= =3D 66): alt54 =3D 4 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_dec= larator_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' pa= rameter_type_list ')' );", 54, 2, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']'= | '[' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );",= 54, 2, self.input) =20 raise nvae =20 @@ -4631,67 +4440,74 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_declara= tor_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' parame= ter_type_list ')' );", 54, 0, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']' | '= [' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );", 54,= 0, self.input) =20 raise nvae =20 if alt54 =3D=3D 1: # C.g:355:4: '[' ']' - self.match(self.input, 64, self.FOLLOW_64_in_abstract_= declarator_suffix1110) + self.match( + self.input, 64, self.FOLLOW_64_in_abstract_declara= tor_suffix1110) if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_abstract_= declarator_suffix1112) + self.match( + self.input, 65, self.FOLLOW_65_in_abstract_declara= tor_suffix1112) if self.failed: return =20 - elif alt54 =3D=3D 2: # C.g:356:4: '[' constant_expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_abstract_= declarator_suffix1117) + self.match( + self.input, 64, self.FOLLOW_64_in_abstract_declara= tor_suffix1117) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_abstract_declarator_suffix1119) + self.following.append( + self.FOLLOW_constant_expression_in_abstract_declar= ator_suffix1119) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_abstract_= declarator_suffix1121) + self.match( + self.input, 65, self.FOLLOW_65_in_abstract_declara= tor_suffix1121) if self.failed: return =20 - elif alt54 =3D=3D 3: # C.g:357:4: '(' ')' - self.match(self.input, 62, self.FOLLOW_62_in_abstract_= declarator_suffix1126) + self.match( + self.input, 62, self.FOLLOW_62_in_abstract_declara= tor_suffix1126) if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_abstract_= declarator_suffix1128) + self.match( + self.input, 63, self.FOLLOW_63_in_abstract_declara= tor_suffix1128) if self.failed: return =20 - elif alt54 =3D=3D 4: # C.g:358:4: '(' parameter_type_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_abstract_= declarator_suffix1133) + self.match( + self.input, 62, self.FOLLOW_62_in_abstract_declara= tor_suffix1133) if self.failed: return - self.following.append(self.FOLLOW_parameter_type_list_= in_abstract_declarator_suffix1135) + self.following.append( + self.FOLLOW_parameter_type_list_in_abstract_declar= ator_suffix1135) self.parameter_type_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_abstract_= declarator_suffix1137) + self.match( + self.input, 63, self.FOLLOW_63_in_abstract_declara= tor_suffix1137) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 33, abstract_declarator_suffix_St= artIndex) + self.memoize(self.input, 33, + abstract_declarator_suffix_StartIndex) =20 pass =20 @@ -4699,9 +4515,9 @@ class CParser(Parser): =20 # $ANTLR end abstract_declarator_suffix =20 - # $ANTLR start initializer # C.g:361:1: initializer : ( assignment_expression | '{' initializer_l= ist ( ',' )? '}' ); + def initializer(self, ): =20 initializer_StartIndex =3D self.input.index() @@ -4714,34 +4530,37 @@ class CParser(Parser): alt56 =3D 2 LA56_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA56_0 <=3D FLOATING_POINT_LITERAL) o= r LA56_0 =3D=3D 62 or LA56_0 =3D=3D 66 or (68 <=3D LA56_0 <=3D 69) or (72 <= =3D LA56_0 <=3D 74) or (77 <=3D LA56_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA56_0 <=3D FLOATING_POINT_LITERAL) o= r LA56_0 =3D=3D 62 or LA56_0 =3D=3D 66 or (68 <=3D LA56_0 <=3D 69) or (72 <= =3D LA56_0 <=3D 74) or (77 <=3D LA56_0 <=3D 79)): alt56 =3D 1 - elif (LA56_0 =3D=3D 43) : + elif (LA56_0 =3D=3D 43): alt56 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("361:1: initializer : ( = assignment_expression | '{' initializer_list ( ',' )? '}' );", 56, 0, self.= input) + nvae =3D NoViableAltException( + "361:1: initializer : ( assignment_expression | '{= ' initializer_list ( ',' )? '}' );", 56, 0, self.input) =20 raise nvae =20 if alt56 =3D=3D 1: # C.g:363:4: assignment_expression - self.following.append(self.FOLLOW_assignment_expressio= n_in_initializer1150) + self.following.append( + self.FOLLOW_assignment_expression_in_initializer11= 50) self.assignment_expression() self.following.pop() if self.failed: return =20 - elif alt56 =3D=3D 2: # C.g:364:4: '{' initializer_list ( ',' )? '}' - self.match(self.input, 43, self.FOLLOW_43_in_initializ= er1155) + self.match(self.input, 43, + self.FOLLOW_43_in_initializer1155) if self.failed: return - self.following.append(self.FOLLOW_initializer_list_in_= initializer1157) + self.following.append( + self.FOLLOW_initializer_list_in_initializer1157) self.initializer_list() self.following.pop() if self.failed: @@ -4750,22 +4569,20 @@ class CParser(Parser): alt55 =3D 2 LA55_0 =3D self.input.LA(1) =20 - if (LA55_0 =3D=3D 27) : + if (LA55_0 =3D=3D 27): alt55 =3D 1 if alt55 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_initi= alizer1159) + self.match(self.input, 27, + self.FOLLOW_27_in_initializer1159) if self.failed: return =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_initializ= er1162) + self.match(self.input, 44, + self.FOLLOW_44_in_initializer1162) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -4779,9 +4596,9 @@ class CParser(Parser): =20 # $ANTLR end initializer =20 - # $ANTLR start initializer_list # C.g:367:1: initializer_list : initializer ( ',' initializer )* ; + def initializer_list(self, ): =20 initializer_list_StartIndex =3D self.input.index() @@ -4792,44 +4609,38 @@ class CParser(Parser): =20 # C.g:368:2: ( initializer ( ',' initializer )* ) # C.g:368:4: initializer ( ',' initializer )* - self.following.append(self.FOLLOW_initializer_in_initializ= er_list1173) + self.following.append( + self.FOLLOW_initializer_in_initializer_list1173) self.initializer() self.following.pop() if self.failed: return # C.g:368:16: ( ',' initializer )* - while True: #loop57 + while True: # loop57 alt57 =3D 2 LA57_0 =3D self.input.LA(1) =20 - if (LA57_0 =3D=3D 27) : + if (LA57_0 =3D=3D 27): LA57_1 =3D self.input.LA(2) =20 - if ((IDENTIFIER <=3D LA57_1 <=3D FLOATING_POINT_LI= TERAL) or LA57_1 =3D=3D 43 or LA57_1 =3D=3D 62 or LA57_1 =3D=3D 66 or (68 <= =3D LA57_1 <=3D 69) or (72 <=3D LA57_1 <=3D 74) or (77 <=3D LA57_1 <=3D 79)= ) : + if ((IDENTIFIER <=3D LA57_1 <=3D FLOATING_POINT_LI= TERAL) or LA57_1 =3D=3D 43 or LA57_1 =3D=3D 62 or LA57_1 =3D=3D 66 or (68 <= =3D LA57_1 <=3D 69) or (72 <=3D LA57_1 <=3D 74) or (77 <=3D LA57_1 <=3D 79)= ): alt57 =3D 1 =20 - - - if alt57 =3D=3D 1: # C.g:368:17: ',' initializer - self.match(self.input, 27, self.FOLLOW_27_in_initi= alizer_list1176) + self.match(self.input, 27, + self.FOLLOW_27_in_initializer_list1176) if self.failed: return - self.following.append(self.FOLLOW_initializer_in_i= nitializer_list1178) + self.following.append( + self.FOLLOW_initializer_in_initializer_list117= 8) self.initializer() self.following.pop() if self.failed: return =20 - else: - break #loop57 - - - - - + break # loop57 =20 except RecognitionException as re: self.reportError(re) @@ -4849,10 +4660,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start argument_expression_list # C.g:373:1: argument_expression_list : assignment_expression ( 'OPTIO= NAL' )? ( ',' assignment_expression ( 'OPTIONAL' )? )* ; + def argument_expression_list(self, ): =20 retval =3D self.argument_expression_list_return() @@ -4865,7 +4675,8 @@ class CParser(Parser): =20 # C.g:374:2: ( assignment_expression ( 'OPTIONAL' )? ( ','= assignment_expression ( 'OPTIONAL' )? )* ) # C.g:374:6: assignment_expression ( 'OPTIONAL' )? ( ',' a= ssignment_expression ( 'OPTIONAL' )? )* - self.following.append(self.FOLLOW_assignment_expression_in= _argument_expression_list1196) + self.following.append( + self.FOLLOW_assignment_expression_in_argument_expressi= on_list1196) self.assignment_expression() self.following.pop() if self.failed: @@ -4874,31 +4685,31 @@ class CParser(Parser): alt58 =3D 2 LA58_0 =3D self.input.LA(1) =20 - if (LA58_0 =3D=3D 53) : + if (LA58_0 =3D=3D 53): alt58 =3D 1 if alt58 =3D=3D 1: # C.g:374:29: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_argument_= expression_list1199) + self.match(self.input, 53, + self.FOLLOW_53_in_argument_expression_list1= 199) if self.failed: return retval =20 - - # C.g:374:42: ( ',' assignment_expression ( 'OPTIONAL' )? = )* - while True: #loop60 + while True: # loop60 alt60 =3D 2 LA60_0 =3D self.input.LA(1) =20 - if (LA60_0 =3D=3D 27) : + if (LA60_0 =3D=3D 27): alt60 =3D 1 =20 - if alt60 =3D=3D 1: # C.g:374:43: ',' assignment_expression ( 'OPTIONA= L' )? - self.match(self.input, 27, self.FOLLOW_27_in_argum= ent_expression_list1204) + self.match( + self.input, 27, self.FOLLOW_27_in_argument_exp= ression_list1204) if self.failed: return retval - self.following.append(self.FOLLOW_assignment_expre= ssion_in_argument_expression_list1206) + self.following.append( + self.FOLLOW_assignment_expression_in_argument_= expression_list1206) self.assignment_expression() self.following.pop() if self.failed: @@ -4907,34 +4718,27 @@ class CParser(Parser): alt59 =3D 2 LA59_0 =3D self.input.LA(1) =20 - if (LA59_0 =3D=3D 53) : + if (LA59_0 =3D=3D 53): alt59 =3D 1 if alt59 =3D=3D 1: # C.g:374:70: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_a= rgument_expression_list1209) + self.match( + self.input, 53, self.FOLLOW_53_in_argument= _expression_list1209) if self.failed: return retval =20 - - - - else: - break #loop60 - - - - + break # loop60 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 36, argument_expression_list_Star= tIndex) + self.memoize(self.input, 36, + argument_expression_list_StartIndex) =20 pass =20 @@ -4942,9 +4746,9 @@ class CParser(Parser): =20 # $ANTLR end argument_expression_list =20 - # $ANTLR start additive_expression # C.g:377:1: additive_expression : ( multiplicative_expression ) ( '+'= multiplicative_expression | '-' multiplicative_expression )* ; + def additive_expression(self, ): =20 additive_expression_StartIndex =3D self.input.index() @@ -4957,56 +4761,51 @@ class CParser(Parser): # C.g:378:4: ( multiplicative_expression ) ( '+' multiplic= ative_expression | '-' multiplicative_expression )* # C.g:378:4: ( multiplicative_expression ) # C.g:378:5: multiplicative_expression - self.following.append(self.FOLLOW_multiplicative_expressio= n_in_additive_expression1225) + self.following.append( + self.FOLLOW_multiplicative_expression_in_additive_expr= ession1225) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - - # C.g:378:32: ( '+' multiplicative_expression | '-' multip= licative_expression )* - while True: #loop61 + while True: # loop61 alt61 =3D 3 LA61_0 =3D self.input.LA(1) =20 - if (LA61_0 =3D=3D 68) : + if (LA61_0 =3D=3D 68): alt61 =3D 1 - elif (LA61_0 =3D=3D 69) : + elif (LA61_0 =3D=3D 69): alt61 =3D 2 =20 - if alt61 =3D=3D 1: # C.g:378:33: '+' multiplicative_expression - self.match(self.input, 68, self.FOLLOW_68_in_addit= ive_expression1229) + self.match(self.input, 68, + self.FOLLOW_68_in_additive_expression12= 29) if self.failed: return - self.following.append(self.FOLLOW_multiplicative_e= xpression_in_additive_expression1231) + self.following.append( + self.FOLLOW_multiplicative_expression_in_addit= ive_expression1231) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - elif alt61 =3D=3D 2: # C.g:378:65: '-' multiplicative_expression - self.match(self.input, 69, self.FOLLOW_69_in_addit= ive_expression1235) + self.match(self.input, 69, + self.FOLLOW_69_in_additive_expression12= 35) if self.failed: return - self.following.append(self.FOLLOW_multiplicative_e= xpression_in_additive_expression1237) + self.following.append( + self.FOLLOW_multiplicative_expression_in_addit= ive_expression1237) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - else: - break #loop61 - - - - - + break # loop61 =20 except RecognitionException as re: self.reportError(re) @@ -5021,9 +4820,9 @@ class CParser(Parser): =20 # $ANTLR end additive_expression =20 - # $ANTLR start multiplicative_expression # C.g:381:1: multiplicative_expression : ( cast_expression ) ( '*' cas= t_expression | '/' cast_expression | '%' cast_expression )* ; + def multiplicative_expression(self, ): =20 multiplicative_expression_StartIndex =3D self.input.index() @@ -5036,16 +4835,15 @@ class CParser(Parser): # C.g:382:4: ( cast_expression ) ( '*' cast_expression | '= /' cast_expression | '%' cast_expression )* # C.g:382:4: ( cast_expression ) # C.g:382:5: cast_expression - self.following.append(self.FOLLOW_cast_expression_in_multi= plicative_expression1251) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_expressi= on1251) self.cast_expression() self.following.pop() if self.failed: return =20 - - # C.g:382:22: ( '*' cast_expression | '/' cast_expression = | '%' cast_expression )* - while True: #loop62 + while True: # loop62 alt62 =3D 4 LA62 =3D self.input.LA(1) if LA62 =3D=3D 66: @@ -5057,54 +4855,53 @@ class CParser(Parser): =20 if alt62 =3D=3D 1: # C.g:382:23: '*' cast_expression - self.match(self.input, 66, self.FOLLOW_66_in_multi= plicative_expression1255) + self.match( + self.input, 66, self.FOLLOW_66_in_multiplicati= ve_expression1255) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1257) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1257) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt62 =3D=3D 2: # C.g:382:45: '/' cast_expression - self.match(self.input, 70, self.FOLLOW_70_in_multi= plicative_expression1261) + self.match( + self.input, 70, self.FOLLOW_70_in_multiplicati= ve_expression1261) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1263) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1263) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt62 =3D=3D 3: # C.g:382:67: '%' cast_expression - self.match(self.input, 71, self.FOLLOW_71_in_multi= plicative_expression1267) + self.match( + self.input, 71, self.FOLLOW_71_in_multiplicati= ve_expression1267) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1269) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1269) self.cast_expression() self.following.pop() if self.failed: return =20 - else: - break #loop62 - - - - - + break # loop62 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 38, multiplicative_expression_Sta= rtIndex) + self.memoize(self.input, 38, + multiplicative_expression_StartIndex) =20 pass =20 @@ -5112,9 +4909,9 @@ class CParser(Parser): =20 # $ANTLR end multiplicative_expression =20 - # $ANTLR start cast_expression # C.g:385:1: cast_expression : ( '(' type_name ')' cast_expression | u= nary_expression ); + def cast_expression(self, ): =20 cast_expression_StartIndex =3D self.input.index() @@ -5127,23 +4924,24 @@ class CParser(Parser): alt63 =3D 2 LA63_0 =3D self.input.LA(1) =20 - if (LA63_0 =3D=3D 62) : + if (LA63_0 =3D=3D 62): LA63 =3D self.input.LA(2) if LA63 =3D=3D 34 or LA63 =3D=3D 35 or LA63 =3D=3D 36 = or LA63 =3D=3D 37 or LA63 =3D=3D 38 or LA63 =3D=3D 39 or LA63 =3D=3D 40 or = LA63 =3D=3D 41 or LA63 =3D=3D 42 or LA63 =3D=3D 45 or LA63 =3D=3D 46 or LA6= 3 =3D=3D 48 or LA63 =3D=3D 49 or LA63 =3D=3D 50 or LA63 =3D=3D 51 or LA63 = =3D=3D 52 or LA63 =3D=3D 53 or LA63 =3D=3D 54 or LA63 =3D=3D 55 or LA63 =3D= =3D 56 or LA63 =3D=3D 57 or LA63 =3D=3D 58 or LA63 =3D=3D 59 or LA63 =3D=3D= 60 or LA63 =3D=3D 61: alt63 =3D 1 elif LA63 =3D=3D IDENTIFIER: LA63_25 =3D self.input.LA(3) =20 - if (self.synpred109()) : + if (self.synpred109()): alt63 =3D 1 - elif (True) : + elif (True): alt63 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_exp= ression : ( '(' type_name ')' cast_expression | unary_expression );", 63, 2= 5, self.input) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name = ')' cast_expression | unary_expression );", 63, 25, self.input) =20 raise nvae =20 @@ -5154,51 +4952,55 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_express= ion : ( '(' type_name ')' cast_expression | unary_expression );", 63, 1, se= lf.input) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name ')' = cast_expression | unary_expression );", 63, 1, self.input) =20 raise nvae =20 - elif ((IDENTIFIER <=3D LA63_0 <=3D FLOATING_POINT_LITERAL)= or LA63_0 =3D=3D 66 or (68 <=3D LA63_0 <=3D 69) or (72 <=3D LA63_0 <=3D 74= ) or (77 <=3D LA63_0 <=3D 79)) : + elif ((IDENTIFIER <=3D LA63_0 <=3D FLOATING_POINT_LITERAL)= or LA63_0 =3D=3D 66 or (68 <=3D LA63_0 <=3D 69) or (72 <=3D LA63_0 <=3D 74= ) or (77 <=3D LA63_0 <=3D 79)): alt63 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_expression = : ( '(' type_name ')' cast_expression | unary_expression );", 63, 0, self.i= nput) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name ')' cast= _expression | unary_expression );", 63, 0, self.input) =20 raise nvae =20 if alt63 =3D=3D 1: # C.g:386:4: '(' type_name ')' cast_expression - self.match(self.input, 62, self.FOLLOW_62_in_cast_expr= ession1282) + self.match(self.input, 62, + self.FOLLOW_62_in_cast_expression1282) if self.failed: return - self.following.append(self.FOLLOW_type_name_in_cast_ex= pression1284) + self.following.append( + self.FOLLOW_type_name_in_cast_expression1284) self.type_name() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_cast_expr= ession1286) + self.match(self.input, 63, + self.FOLLOW_63_in_cast_expression1286) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_in_c= ast_expression1288) + self.following.append( + self.FOLLOW_cast_expression_in_cast_expression1288) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt63 =3D=3D 2: # C.g:387:4: unary_expression - self.following.append(self.FOLLOW_unary_expression_in_= cast_expression1293) + self.following.append( + self.FOLLOW_unary_expression_in_cast_expression129= 3) self.unary_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5212,9 +5014,9 @@ class CParser(Parser): =20 # $ANTLR end cast_expression =20 - # $ANTLR start unary_expression # C.g:390:1: unary_expression : ( postfix_expression | '++' unary_expr= ession | '--' unary_expression | unary_operator cast_expression | 'sizeof' = unary_expression | 'sizeof' '(' type_name ')' ); + def unary_expression(self, ): =20 unary_expression_StartIndex =3D self.input.index() @@ -5237,30 +5039,32 @@ class CParser(Parser): elif LA64 =3D=3D 74: LA64_12 =3D self.input.LA(2) =20 - if (LA64_12 =3D=3D 62) : + if (LA64_12 =3D=3D 62): LA64_13 =3D self.input.LA(3) =20 - if (self.synpred114()) : + if (self.synpred114()): alt64 =3D 5 - elif (True) : + elif (True): alt64 =3D 6 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_ex= pression : ( postfix_expression | '++' unary_expression | '--' unary_expres= sion | unary_operator cast_expression | 'sizeof' unary_expression | 'sizeof= ' '(' type_name ')' );", 64, 13, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expre= ssion | '++' unary_expression | '--' unary_expression | unary_operator cast= _expression | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 6= 4, 13, self.input) =20 raise nvae =20 - elif ((IDENTIFIER <=3D LA64_12 <=3D FLOATING_POINT_LIT= ERAL) or LA64_12 =3D=3D 66 or (68 <=3D LA64_12 <=3D 69) or (72 <=3D LA64_12= <=3D 74) or (77 <=3D LA64_12 <=3D 79)) : + elif ((IDENTIFIER <=3D LA64_12 <=3D FLOATING_POINT_LIT= ERAL) or LA64_12 =3D=3D 66 or (68 <=3D LA64_12 <=3D 69) or (72 <=3D LA64_12= <=3D 74) or (77 <=3D LA64_12 <=3D 79)): alt64 =3D 5 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_expres= sion : ( postfix_expression | '++' unary_expression | '--' unary_expression= | unary_operator cast_expression | 'sizeof' unary_expression | 'sizeof' '(= ' type_name ')' );", 64, 12, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expressio= n | '++' unary_expression | '--' unary_expression | unary_operator cast_exp= ression | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 64, 1= 2, self.input) =20 raise nvae =20 @@ -5269,88 +5073,95 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_expression= : ( postfix_expression | '++' unary_expression | '--' unary_expression | u= nary_operator cast_expression | 'sizeof' unary_expression | 'sizeof' '(' ty= pe_name ')' );", 64, 0, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expression | = '++' unary_expression | '--' unary_expression | unary_operator cast_express= ion | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 64, 0, se= lf.input) =20 raise nvae =20 if alt64 =3D=3D 1: # C.g:391:4: postfix_expression - self.following.append(self.FOLLOW_postfix_expression_i= n_unary_expression1304) + self.following.append( + self.FOLLOW_postfix_expression_in_unary_expression= 1304) self.postfix_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 2: # C.g:392:4: '++' unary_expression - self.match(self.input, 72, self.FOLLOW_72_in_unary_exp= ression1309) + self.match(self.input, 72, + self.FOLLOW_72_in_unary_expression1309) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1311) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 11) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 3: # C.g:393:4: '--' unary_expression - self.match(self.input, 73, self.FOLLOW_73_in_unary_exp= ression1316) + self.match(self.input, 73, + self.FOLLOW_73_in_unary_expression1316) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1318) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 18) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 4: # C.g:394:4: unary_operator cast_expression - self.following.append(self.FOLLOW_unary_operator_in_un= ary_expression1323) + self.following.append( + self.FOLLOW_unary_operator_in_unary_expression1323) self.unary_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_cast_expression_in_u= nary_expression1325) + self.following.append( + self.FOLLOW_cast_expression_in_unary_expression132= 5) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 5: # C.g:395:4: 'sizeof' unary_expression - self.match(self.input, 74, self.FOLLOW_74_in_unary_exp= ression1330) + self.match(self.input, 74, + self.FOLLOW_74_in_unary_expression1330) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1332) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 32) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 6: # C.g:396:4: 'sizeof' '(' type_name ')' - self.match(self.input, 74, self.FOLLOW_74_in_unary_exp= ression1337) + self.match(self.input, 74, + self.FOLLOW_74_in_unary_expression1337) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_unary_exp= ression1339) + self.match(self.input, 62, + self.FOLLOW_62_in_unary_expression1339) if self.failed: return - self.following.append(self.FOLLOW_type_name_in_unary_e= xpression1341) + self.following.append( + self.FOLLOW_type_name_in_unary_expression1341) self.type_name() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_unary_exp= ression1343) + self.match(self.input, 63, + self.FOLLOW_63_in_unary_expression1343) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5364,9 +5175,9 @@ class CParser(Parser): =20 # $ANTLR end unary_expression =20 - # $ANTLR start postfix_expression # C.g:399:1: postfix_expression : p=3D primary_expression ( '[' expres= sion ']' | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' = macro_parameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->'= z=3D IDENTIFIER | '++' | '--' )* ; + def postfix_expression(self, ): self.postfix_expression_stack.append(postfix_expression_scope()) postfix_expression_StartIndex =3D self.input.index() @@ -5379,9 +5190,7 @@ class CParser(Parser): =20 c =3D None =20 - - - self.postfix_expression_stack[-1].FuncCallText =3D '' + self.postfix_expression_stack[-1].FuncCallText =3D '' =20 try: try: @@ -5390,30 +5199,29 @@ class CParser(Parser): =20 # C.g:406:2: (p=3D primary_expression ( '[' expression ']'= | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' macro_pa= rameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D ID= ENTIFIER | '++' | '--' )* ) # C.g:406:6: p=3D primary_expression ( '[' expression ']' = | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' macro_par= ameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D IDE= NTIFIER | '++' | '--' )* - self.following.append(self.FOLLOW_primary_expression_in_po= stfix_expression1367) + self.following.append( + self.FOLLOW_primary_expression_in_postfix_expression13= 67) p =3D self.primary_expression() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.postfix_expression_stack[-1].FuncCallText +=3D se= lf.input.toString(p.start, p.stop) + self.postfix_expression_stack[-1].FuncCallText +=3D se= lf.input.toString( + p.start, p.stop) =20 # C.g:407:9: ( '[' expression ']' | '(' a=3D ')' | '(' c= =3D argument_expression_list b=3D ')' | '(' macro_parameter_list ')' | '.' = x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D IDENTIFIER | '++' | '--' = )* - while True: #loop65 + while True: # loop65 alt65 =3D 10 LA65 =3D self.input.LA(1) if LA65 =3D=3D 66: LA65_1 =3D self.input.LA(2) =20 - if (LA65_1 =3D=3D IDENTIFIER) : + if (LA65_1 =3D=3D IDENTIFIER): LA65_30 =3D self.input.LA(3) =20 - if (self.synpred120()) : + if (self.synpred120()): alt65 =3D 6 =20 - - - elif LA65 =3D=3D 64: alt65 =3D 1 elif LA65 =3D=3D 62: @@ -5425,21 +5233,19 @@ class CParser(Parser): elif LA65 =3D=3D IDENTIFIER: LA65_55 =3D self.input.LA(3) =20 - if (self.synpred117()) : + if (self.synpred117()): alt65 =3D 3 - elif (self.synpred118()) : + elif (self.synpred118()): alt65 =3D 4 =20 - elif LA65 =3D=3D 66: LA65_57 =3D self.input.LA(3) =20 - if (self.synpred117()) : + if (self.synpred117()): alt65 =3D 3 - elif (self.synpred118()) : + elif (self.synpred118()): alt65 =3D 4 =20 - elif LA65 =3D=3D HEX_LITERAL or LA65 =3D=3D OCTAL_= LITERAL or LA65 =3D=3D DECIMAL_LITERAL or LA65 =3D=3D CHARACTER_LITERAL or = LA65 =3D=3D STRING_LITERAL or LA65 =3D=3D FLOATING_POINT_LITERAL or LA65 = =3D=3D 62 or LA65 =3D=3D 68 or LA65 =3D=3D 69 or LA65 =3D=3D 72 or LA65 =3D= =3D 73 or LA65 =3D=3D 74 or LA65 =3D=3D 77 or LA65 =3D=3D 78 or LA65 =3D=3D= 79: alt65 =3D 3 =20 @@ -5454,130 +5260,132 @@ class CParser(Parser): =20 if alt65 =3D=3D 1: # C.g:407:13: '[' expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_postf= ix_expression1383) + self.match(self.input, 64, + self.FOLLOW_64_in_postfix_expression138= 3) if self.failed: return - self.following.append(self.FOLLOW_expression_in_po= stfix_expression1385) + self.following.append( + self.FOLLOW_expression_in_postfix_expression13= 85) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_postf= ix_expression1387) + self.match(self.input, 65, + self.FOLLOW_65_in_postfix_expression138= 7) if self.failed: return =20 - elif alt65 =3D=3D 2: # C.g:408:13: '(' a=3D ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1401) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression140= 1) if self.failed: return a =3D self.input.LT(1) - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1405) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression140= 5) if self.failed: return if self.backtracking =3D=3D 0: - self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, a.line, a.charPositionInLine, self.postfix_expression= _stack[-1].FuncCallText, '') - - + self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, a.line, + a.charPositionInLine= , self.postfix_expression_stack[-1].FuncCallText, '') =20 elif alt65 =3D=3D 3: # C.g:409:13: '(' c=3D argument_expression_list b= =3D ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1420) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression142= 0) if self.failed: return - self.following.append(self.FOLLOW_argument_express= ion_list_in_postfix_expression1424) + self.following.append( + self.FOLLOW_argument_expression_list_in_postfi= x_expression1424) c =3D self.argument_expression_list() self.following.pop() if self.failed: return b =3D self.input.LT(1) - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1428) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression142= 8) if self.failed: return if self.backtracking =3D=3D 0: - self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, b.line, b.charPositionInLine, self.postfix_expression= _stack[-1].FuncCallText, self.input.toString(c.start, c.stop)) - - + self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, b.line, b.charPositionInLine, + self.postfix_express= ion_stack[-1].FuncCallText, self.input.toString(c.start, c.stop)) =20 elif alt65 =3D=3D 4: # C.g:410:13: '(' macro_parameter_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1444) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression144= 4) if self.failed: return - self.following.append(self.FOLLOW_macro_parameter_= list_in_postfix_expression1446) + self.following.append( + self.FOLLOW_macro_parameter_list_in_postfix_ex= pression1446) self.macro_parameter_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1448) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression144= 8) if self.failed: return =20 - elif alt65 =3D=3D 5: # C.g:411:13: '.' x=3D IDENTIFIER - self.match(self.input, 75, self.FOLLOW_75_in_postf= ix_expression1462) + self.match(self.input, 75, + self.FOLLOW_75_in_postfix_expression146= 2) if self.failed: return x =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1466) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1466) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= +=3D '.' + x.text =20 - - elif alt65 =3D=3D 6: # C.g:412:13: '*' y=3D IDENTIFIER - self.match(self.input, 66, self.FOLLOW_66_in_postf= ix_expression1482) + self.match(self.input, 66, + self.FOLLOW_66_in_postfix_expression148= 2) if self.failed: return y =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1486) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1486) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= =3D y.text =20 - - elif alt65 =3D=3D 7: # C.g:413:13: '->' z=3D IDENTIFIER - self.match(self.input, 76, self.FOLLOW_76_in_postf= ix_expression1502) + self.match(self.input, 76, + self.FOLLOW_76_in_postfix_expression150= 2) if self.failed: return z =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1506) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1506) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= +=3D '->' + z.text =20 - - elif alt65 =3D=3D 8: # C.g:414:13: '++' - self.match(self.input, 72, self.FOLLOW_72_in_postf= ix_expression1522) + self.match(self.input, 72, + self.FOLLOW_72_in_postfix_expression152= 2) if self.failed: return =20 - elif alt65 =3D=3D 9: # C.g:415:13: '--' - self.match(self.input, 73, self.FOLLOW_73_in_postf= ix_expression1536) + self.match(self.input, 73, + self.FOLLOW_73_in_postfix_expression153= 6) if self.failed: return =20 - else: - break #loop65 - - - - - + break # loop65 =20 except RecognitionException as re: self.reportError(re) @@ -5593,9 +5401,9 @@ class CParser(Parser): =20 # $ANTLR end postfix_expression =20 - # $ANTLR start macro_parameter_list # C.g:419:1: macro_parameter_list : parameter_declaration ( ',' parame= ter_declaration )* ; + def macro_parameter_list(self, ): =20 macro_parameter_list_StartIndex =3D self.input.index() @@ -5606,39 +5414,35 @@ class CParser(Parser): =20 # C.g:420:2: ( parameter_declaration ( ',' parameter_decla= ration )* ) # C.g:420:4: parameter_declaration ( ',' parameter_declara= tion )* - self.following.append(self.FOLLOW_parameter_declaration_in= _macro_parameter_list1559) + self.following.append( + self.FOLLOW_parameter_declaration_in_macro_parameter_l= ist1559) self.parameter_declaration() self.following.pop() if self.failed: return # C.g:420:26: ( ',' parameter_declaration )* - while True: #loop66 + while True: # loop66 alt66 =3D 2 LA66_0 =3D self.input.LA(1) =20 - if (LA66_0 =3D=3D 27) : + if (LA66_0 =3D=3D 27): alt66 =3D 1 =20 - if alt66 =3D=3D 1: # C.g:420:27: ',' parameter_declaration - self.match(self.input, 27, self.FOLLOW_27_in_macro= _parameter_list1562) + self.match(self.input, 27, + self.FOLLOW_27_in_macro_parameter_list1= 562) if self.failed: return - self.following.append(self.FOLLOW_parameter_declar= ation_in_macro_parameter_list1564) + self.following.append( + self.FOLLOW_parameter_declaration_in_macro_par= ameter_list1564) self.parameter_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop66 - - - - - + break # loop66 =20 except RecognitionException as re: self.reportError(re) @@ -5653,9 +5457,9 @@ class CParser(Parser): =20 # $ANTLR end macro_parameter_list =20 - # $ANTLR start unary_operator # C.g:423:1: unary_operator : ( '&' | '*' | '+' | '-' | '~' | '!' ); + def unary_operator(self, ): =20 unary_operator_StartIndex =3D self.input.index() @@ -5667,7 +5471,7 @@ class CParser(Parser): # C.g:424:2: ( '&' | '*' | '+' | '-' | '~' | '!' ) # C.g: if self.input.LA(1) =3D=3D 66 or (68 <=3D self.input.LA(1)= <=3D 69) or (77 <=3D self.input.LA(1) <=3D 79): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -5679,14 +5483,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_unary_operator0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5705,10 +5504,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start primary_expression # C.g:432:1: primary_expression : ( IDENTIFIER | constant | '(' expres= sion ')' ); + def primary_expression(self, ): =20 retval =3D self.primary_expression_return() @@ -5725,16 +5523,17 @@ class CParser(Parser): if LA67 =3D=3D IDENTIFIER: LA67_1 =3D self.input.LA(2) =20 - if (LA67_1 =3D=3D EOF or LA67_1 =3D=3D 25 or (27 <=3D = LA67_1 <=3D 28) or LA67_1 =3D=3D 44 or LA67_1 =3D=3D 47 or LA67_1 =3D=3D 53= or (62 <=3D LA67_1 <=3D 66) or (68 <=3D LA67_1 <=3D 73) or (75 <=3D LA67_1= <=3D 77) or (80 <=3D LA67_1 <=3D 102)) : + if (LA67_1 =3D=3D EOF or LA67_1 =3D=3D 25 or (27 <=3D = LA67_1 <=3D 28) or LA67_1 =3D=3D 44 or LA67_1 =3D=3D 47 or LA67_1 =3D=3D 53= or (62 <=3D LA67_1 <=3D 66) or (68 <=3D LA67_1 <=3D 73) or (75 <=3D LA67_1= <=3D 77) or (80 <=3D LA67_1 <=3D 102)): alt67 =3D 1 - elif (LA67_1 =3D=3D IDENTIFIER or LA67_1 =3D=3D STRING= _LITERAL) : + elif (LA67_1 =3D=3D IDENTIFIER or LA67_1 =3D=3D STRING= _LITERAL): alt67 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("432:1: primary_expr= ession : ( IDENTIFIER | constant | '(' expression ')' );", 67, 1, self.inpu= t) + nvae =3D NoViableAltException( + "432:1: primary_expression : ( IDENTIFIER | co= nstant | '(' expression ')' );", 67, 1, self.input) =20 raise nvae =20 @@ -5747,44 +5546,46 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("432:1: primary_expressi= on : ( IDENTIFIER | constant | '(' expression ')' );", 67, 0, self.input) + nvae =3D NoViableAltException( + "432:1: primary_expression : ( IDENTIFIER | consta= nt | '(' expression ')' );", 67, 0, self.input) =20 raise nvae =20 if alt67 =3D=3D 1: # C.g:433:4: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_primary_expression1613) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_primary_expressio= n1613) if self.failed: return retval =20 - elif alt67 =3D=3D 2: # C.g:434:4: constant - self.following.append(self.FOLLOW_constant_in_primary_= expression1618) + self.following.append( + self.FOLLOW_constant_in_primary_expression1618) self.constant() self.following.pop() if self.failed: return retval =20 - elif alt67 =3D=3D 3: # C.g:435:4: '(' expression ')' - self.match(self.input, 62, self.FOLLOW_62_in_primary_e= xpression1623) + self.match(self.input, 62, + self.FOLLOW_62_in_primary_expression1623) if self.failed: return retval - self.following.append(self.FOLLOW_expression_in_primar= y_expression1625) + self.following.append( + self.FOLLOW_expression_in_primary_expression1625) self.expression() self.following.pop() if self.failed: return retval - self.match(self.input, 63, self.FOLLOW_63_in_primary_e= xpression1627) + self.match(self.input, 63, + self.FOLLOW_63_in_primary_expression1627) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5798,9 +5599,9 @@ class CParser(Parser): =20 # $ANTLR end primary_expression =20 - # $ANTLR start constant # C.g:438:1: constant : ( HEX_LITERAL | OCTAL_LITERAL | DECIMAL_LITERA= L | CHARACTER_LITERAL | ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ ( IDENTIFI= ER )* | FLOATING_POINT_LITERAL ); + def constant(self, ): =20 constant_StartIndex =3D self.input.index() @@ -5829,111 +5630,103 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("438:1: constant : ( HEX= _LITERAL | OCTAL_LITERAL | DECIMAL_LITERAL | CHARACTER_LITERAL | ( ( IDENTI= FIER )* ( STRING_LITERAL )+ )+ ( IDENTIFIER )* | FLOATING_POINT_LITERAL );"= , 72, 0, self.input) + nvae =3D NoViableAltException( + "438:1: constant : ( HEX_LITERAL | OCTAL_LITERAL |= DECIMAL_LITERAL | CHARACTER_LITERAL | ( ( IDENTIFIER )* ( STRING_LITERAL )= + )+ ( IDENTIFIER )* | FLOATING_POINT_LITERAL );", 72, 0, self.input) =20 raise nvae =20 if alt72 =3D=3D 1: # C.g:439:9: HEX_LITERAL - self.match(self.input, HEX_LITERAL, self.FOLLOW_HEX_LI= TERAL_in_constant1643) + self.match(self.input, HEX_LITERAL, + self.FOLLOW_HEX_LITERAL_in_constant1643) if self.failed: return =20 - elif alt72 =3D=3D 2: # C.g:440:9: OCTAL_LITERAL - self.match(self.input, OCTAL_LITERAL, self.FOLLOW_OCTA= L_LITERAL_in_constant1653) + self.match(self.input, OCTAL_LITERAL, + self.FOLLOW_OCTAL_LITERAL_in_constant1653) if self.failed: return =20 - elif alt72 =3D=3D 3: # C.g:441:9: DECIMAL_LITERAL - self.match(self.input, DECIMAL_LITERAL, self.FOLLOW_DE= CIMAL_LITERAL_in_constant1663) + self.match(self.input, DECIMAL_LITERAL, + self.FOLLOW_DECIMAL_LITERAL_in_constant1663) if self.failed: return =20 - elif alt72 =3D=3D 4: # C.g:442:7: CHARACTER_LITERAL - self.match(self.input, CHARACTER_LITERAL, self.FOLLOW_= CHARACTER_LITERAL_in_constant1671) + self.match(self.input, CHARACTER_LITERAL, + self.FOLLOW_CHARACTER_LITERAL_in_constant16= 71) if self.failed: return =20 - elif alt72 =3D=3D 5: # C.g:443:7: ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ = ( IDENTIFIER )* # C.g:443:7: ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ cnt70 =3D 0 - while True: #loop70 + while True: # loop70 alt70 =3D 2 LA70_0 =3D self.input.LA(1) =20 - if (LA70_0 =3D=3D IDENTIFIER) : + if (LA70_0 =3D=3D IDENTIFIER): LA70_1 =3D self.input.LA(2) =20 - if (LA70_1 =3D=3D STRING_LITERAL) : + if (LA70_1 =3D=3D STRING_LITERAL): alt70 =3D 1 - elif (LA70_1 =3D=3D IDENTIFIER) : + elif (LA70_1 =3D=3D IDENTIFIER): LA70_33 =3D self.input.LA(3) =20 - if (self.synpred138()) : + if (self.synpred138()): alt70 =3D 1 =20 - - - - elif (LA70_0 =3D=3D STRING_LITERAL) : + elif (LA70_0 =3D=3D STRING_LITERAL): alt70 =3D 1 =20 - if alt70 =3D=3D 1: # C.g:443:8: ( IDENTIFIER )* ( STRING_LITERAL = )+ # C.g:443:8: ( IDENTIFIER )* - while True: #loop68 + while True: # loop68 alt68 =3D 2 LA68_0 =3D self.input.LA(1) =20 - if (LA68_0 =3D=3D IDENTIFIER) : + if (LA68_0 =3D=3D IDENTIFIER): alt68 =3D 1 =20 - if alt68 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, sel= f.FOLLOW_IDENTIFIER_in_constant1680) + self.match( + self.input, IDENTIFIER, self.FOLLO= W_IDENTIFIER_in_constant1680) if self.failed: return =20 - else: - break #loop68 - + break # loop68 =20 # C.g:443:20: ( STRING_LITERAL )+ cnt69 =3D 0 - while True: #loop69 + while True: # loop69 alt69 =3D 2 LA69_0 =3D self.input.LA(1) =20 - if (LA69_0 =3D=3D STRING_LITERAL) : + if (LA69_0 =3D=3D STRING_LITERAL): LA69_31 =3D self.input.LA(2) =20 - if (self.synpred137()) : + if (self.synpred137()): alt69 =3D 1 =20 - - - if alt69 =3D=3D 1: # C.g:0:0: STRING_LITERAL - self.match(self.input, STRING_LITERAL,= self.FOLLOW_STRING_LITERAL_in_constant1683) + self.match( + self.input, STRING_LITERAL, self.F= OLLOW_STRING_LITERAL_in_constant1683) if self.failed: return =20 - else: if cnt69 >=3D 1: - break #loop69 + break # loop69 =20 if self.backtracking > 0: self.failed =3D True @@ -5944,12 +5737,9 @@ class CParser(Parser): =20 cnt69 +=3D 1 =20 - - - else: if cnt70 >=3D 1: - break #loop70 + break # loop70 =20 if self.backtracking > 0: self.failed =3D True @@ -5960,37 +5750,31 @@ class CParser(Parser): =20 cnt70 +=3D 1 =20 - # C.g:443:38: ( IDENTIFIER )* - while True: #loop71 + while True: # loop71 alt71 =3D 2 LA71_0 =3D self.input.LA(1) =20 - if (LA71_0 =3D=3D IDENTIFIER) : + if (LA71_0 =3D=3D IDENTIFIER): alt71 =3D 1 =20 - if alt71 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW= _IDENTIFIER_in_constant1688) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_constant1= 688) if self.failed: return =20 - else: - break #loop71 - - - + break # loop71 =20 elif alt72 =3D=3D 6: # C.g:444:9: FLOATING_POINT_LITERAL - self.match(self.input, FLOATING_POINT_LITERAL, self.FO= LLOW_FLOATING_POINT_LITERAL_in_constant1699) + self.match(self.input, FLOATING_POINT_LITERAL, + self.FOLLOW_FLOATING_POINT_LITERAL_in_const= ant1699) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6009,10 +5793,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start expression # C.g:449:1: expression : assignment_expression ( ',' assignment_expre= ssion )* ; + def expression(self, ): =20 retval =3D self.expression_return() @@ -6025,42 +5808,38 @@ class CParser(Parser): =20 # C.g:450:2: ( assignment_expression ( ',' assignment_expr= ession )* ) # C.g:450:4: assignment_expression ( ',' assignment_expres= sion )* - self.following.append(self.FOLLOW_assignment_expression_in= _expression1715) + self.following.append( + self.FOLLOW_assignment_expression_in_expression1715) self.assignment_expression() self.following.pop() if self.failed: return retval # C.g:450:26: ( ',' assignment_expression )* - while True: #loop73 + while True: # loop73 alt73 =3D 2 LA73_0 =3D self.input.LA(1) =20 - if (LA73_0 =3D=3D 27) : + if (LA73_0 =3D=3D 27): alt73 =3D 1 =20 - if alt73 =3D=3D 1: # C.g:450:27: ',' assignment_expression - self.match(self.input, 27, self.FOLLOW_27_in_expre= ssion1718) + self.match(self.input, 27, + self.FOLLOW_27_in_expression1718) if self.failed: return retval - self.following.append(self.FOLLOW_assignment_expre= ssion_in_expression1720) + self.following.append( + self.FOLLOW_assignment_expression_in_expressio= n1720) self.assignment_expression() self.following.pop() if self.failed: return retval =20 - else: - break #loop73 - - - - + break # loop73 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6074,9 +5853,9 @@ class CParser(Parser): =20 # $ANTLR end expression =20 - # $ANTLR start constant_expression # C.g:453:1: constant_expression : conditional_expression ; + def constant_expression(self, ): =20 constant_expression_StartIndex =3D self.input.index() @@ -6087,15 +5866,13 @@ class CParser(Parser): =20 # C.g:454:2: ( conditional_expression ) # C.g:454:4: conditional_expression - self.following.append(self.FOLLOW_conditional_expression_i= n_constant_expression1733) + self.following.append( + self.FOLLOW_conditional_expression_in_constant_express= ion1733) self.conditional_expression() self.following.pop() if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6109,9 +5886,9 @@ class CParser(Parser): =20 # $ANTLR end constant_expression =20 - # $ANTLR start assignment_expression # C.g:457:1: assignment_expression : ( lvalue assignment_operator assi= gnment_expression | conditional_expression ); + def assignment_expression(self, ): =20 assignment_expression_StartIndex =3D self.input.index() @@ -6128,112 +5905,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_13 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 13, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 13, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_14 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 14, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 14, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_15 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 15, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 15, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_16 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 16, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 16, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_17 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 17, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 17, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_18 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 18, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 18, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_19 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 19, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 19, self.input) =20 raise nvae =20 @@ -6242,32 +6026,34 @@ class CParser(Parser): elif LA74 =3D=3D STRING_LITERAL: LA74_21 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 21, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 21, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_22 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 22, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 22, self.input) =20 raise nvae =20 @@ -6278,7 +6064,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 1, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 1, s= elf.input) =20 raise nvae =20 @@ -6287,112 +6074,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_44 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 44, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 44, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_45 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 45, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 45, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_46 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 46, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 46, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_47 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 47, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 47, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_48 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 48, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 48, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_49 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 49, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 49, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_50 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 50, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 50, self.input) =20 raise nvae =20 @@ -6405,7 +6199,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 2, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 2, s= elf.input) =20 raise nvae =20 @@ -6414,112 +6209,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_73 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 73, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 73, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_74 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 74, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 74, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_75 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 75, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 75, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_76 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 76, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 76, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_77 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 77, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 77, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_78 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 78, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 78, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_79 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 79, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 79, self.input) =20 raise nvae =20 @@ -6532,7 +6334,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 3, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 3, s= elf.input) =20 raise nvae =20 @@ -6541,112 +6344,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_102 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 102, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 102, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_103 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 103, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 103, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_104 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 104, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 104, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_105 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 105, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 105, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_106 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 106, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 106, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_107 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 107, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 107, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_108 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 108, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 108, self.input) =20 raise nvae =20 @@ -6659,7 +6469,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 4, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 4, s= elf.input) =20 raise nvae =20 @@ -6668,112 +6479,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_131 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 131, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 131, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_132 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 132, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 132, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_133 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 133, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 133, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_134 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 134, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 134, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_135 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 135, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 135, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_136 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 136, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 136, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_137 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 137, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 137, self.input) =20 raise nvae =20 @@ -6786,7 +6604,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 5, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 5, s= elf.input) =20 raise nvae =20 @@ -6795,128 +6614,136 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_160 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 160, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 160, self.input) =20 raise nvae =20 elif LA74 =3D=3D 64: LA74_161 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 161, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 161, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_162 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 162, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 162, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_163 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 163, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 163, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_164 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 164, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 164, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_165 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 165, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 165, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_166 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 166, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 166, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_167 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 167, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 167, self.input) =20 raise nvae =20 @@ -6925,16 +6752,17 @@ class CParser(Parser): elif LA74 =3D=3D STRING_LITERAL: LA74_189 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 189, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 189, self.input) =20 raise nvae =20 @@ -6945,7 +6773,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 6, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 6, s= elf.input) =20 raise nvae =20 @@ -6954,112 +6783,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_191 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 191, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 191, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_192 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 192, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 192, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_193 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 193, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 193, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_194 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 194, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 194, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_195 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 195, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 195, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_196 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 196, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 196, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_197 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 197, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 197, self.input) =20 raise nvae =20 @@ -7072,7 +6908,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 7, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 7, s= elf.input) =20 raise nvae =20 @@ -7081,192 +6918,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_220 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 220, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 220, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_221 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 221, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 221, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_222 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 222, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 222, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_223 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 223, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 223, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_224 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 224, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 224, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_225 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 225, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 225, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_226 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 226, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 226, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_227 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 227, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 227, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_228 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 228, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 228, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_229 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 229, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 229, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_230 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 230, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 230, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_231 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 231, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 231, self.input) =20 raise nvae =20 @@ -7277,7 +7126,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 8, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 8, s= elf.input) =20 raise nvae =20 @@ -7286,192 +7136,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_244 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 244, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 244, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_245 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 245, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 245, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_246 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 246, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 246, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_247 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 247, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 247, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_248 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 248, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 248, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_249 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 249, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 249, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_250 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 250, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 250, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_251 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 251, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 251, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_252 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 252, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 252, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_253 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 253, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 253, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_254 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 254, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 254, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_255 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 255, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 255, self.input) =20 raise nvae =20 @@ -7480,7 +7342,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 9, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 9, s= elf.input) =20 raise nvae =20 @@ -7489,192 +7352,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_256 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 256, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 256, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_257 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 257, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 257, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_258 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 258, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 258, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_259 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 259, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 259, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_260 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 260, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 260, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_261 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 261, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 261, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_262 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 262, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 262, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_263 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 263, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 263, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_264 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 264, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 264, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_265 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 265, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 265, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_266 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 266, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 266, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_267 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 267, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 267, self.input) =20 raise nvae =20 @@ -7683,7 +7558,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 10, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 10, = self.input) =20 raise nvae =20 @@ -7692,192 +7568,204 @@ class CParser(Parser): if LA74 =3D=3D 62: LA74_268 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 268, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 268, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_269 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 269, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 269, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_270 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 270, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 270, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_271 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 271, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 271, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_272 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 272, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 272, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_273 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 273, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 273, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_274 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 274, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 274, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_275 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 275, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 275, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_276 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 276, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 276, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_277 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 277, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 277, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_278 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 278, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 278, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_279 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 279, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 279, self.input) =20 raise nvae =20 @@ -7886,7 +7774,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 11, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 11, = self.input) =20 raise nvae =20 @@ -7895,192 +7784,204 @@ class CParser(Parser): if LA74 =3D=3D 62: LA74_280 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 280, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 280, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_281 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 281, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 281, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_282 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 282, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 282, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_283 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 283, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 283, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_284 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 284, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 284, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_285 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 285, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 285, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_286 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 286, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 286, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_287 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 287, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 287, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_288 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 288, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 288, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_289 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 289, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 289, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_290 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 290, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 290, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_291 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 291, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 291, self.input) =20 raise nvae =20 @@ -8089,7 +7990,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 12, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 12, = self.input) =20 raise nvae =20 @@ -8098,39 +8000,41 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_expre= ssion : ( lvalue assignment_operator assignment_expression | conditional_ex= pression );", 74, 0, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assignmen= t_operator assignment_expression | conditional_expression );", 74, 0, self.= input) =20 raise nvae =20 if alt74 =3D=3D 1: # C.g:458:4: lvalue assignment_operator assignment_exp= ression - self.following.append(self.FOLLOW_lvalue_in_assignment= _expression1744) + self.following.append( + self.FOLLOW_lvalue_in_assignment_expression1744) self.lvalue() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_operator_= in_assignment_expression1746) + self.following.append( + self.FOLLOW_assignment_operator_in_assignment_expr= ession1746) self.assignment_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_expressio= n_in_assignment_expression1748) + self.following.append( + self.FOLLOW_assignment_expression_in_assignment_ex= pression1748) self.assignment_expression() self.following.pop() if self.failed: return =20 - elif alt74 =3D=3D 2: # C.g:459:4: conditional_expression - self.following.append(self.FOLLOW_conditional_expressi= on_in_assignment_expression1753) + self.following.append( + self.FOLLOW_conditional_expression_in_assignment_e= xpression1753) self.conditional_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8144,9 +8048,9 @@ class CParser(Parser): =20 # $ANTLR end assignment_expression =20 - # $ANTLR start lvalue # C.g:462:1: lvalue : unary_expression ; + def lvalue(self, ): =20 lvalue_StartIndex =3D self.input.index() @@ -8157,15 +8061,13 @@ class CParser(Parser): =20 # C.g:463:2: ( unary_expression ) # C.g:463:4: unary_expression - self.following.append(self.FOLLOW_unary_expression_in_lval= ue1765) + self.following.append( + self.FOLLOW_unary_expression_in_lvalue1765) self.unary_expression() self.following.pop() if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8179,9 +8081,9 @@ class CParser(Parser): =20 # $ANTLR end lvalue =20 - # $ANTLR start assignment_operator # C.g:466:1: assignment_operator : ( '=3D' | '*=3D' | '/=3D' | '%=3D' = | '+=3D' | '-=3D' | '<<=3D' | '>>=3D' | '&=3D' | '^=3D' | '|=3D' ); + def assignment_operator(self, ): =20 assignment_operator_StartIndex =3D self.input.index() @@ -8193,7 +8095,7 @@ class CParser(Parser): # C.g:467:2: ( '=3D' | '*=3D' | '/=3D' | '%=3D' | '+=3D' |= '-=3D' | '<<=3D' | '>>=3D' | '&=3D' | '^=3D' | '|=3D' ) # C.g: if self.input.LA(1) =3D=3D 28 or (80 <=3D self.input.LA(1)= <=3D 89): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8205,14 +8107,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_assignment_ope= rator0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8226,15 +8123,14 @@ class CParser(Parser): =20 # $ANTLR end assignment_operator =20 - # $ANTLR start conditional_expression # C.g:480:1: conditional_expression : e=3D logical_or_expression ( '?'= expression ':' conditional_expression )? ; + def conditional_expression(self, ): =20 conditional_expression_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 51): @@ -8242,7 +8138,8 @@ class CParser(Parser): =20 # C.g:481:2: (e=3D logical_or_expression ( '?' expression = ':' conditional_expression )? ) # C.g:481:4: e=3D logical_or_expression ( '?' expression '= :' conditional_expression )? - self.following.append(self.FOLLOW_logical_or_expression_in= _conditional_expression1839) + self.following.append( + self.FOLLOW_logical_or_expression_in_conditional_expre= ssion1839) e =3D self.logical_or_expression() self.following.pop() if self.failed: @@ -8251,35 +8148,33 @@ class CParser(Parser): alt75 =3D 2 LA75_0 =3D self.input.LA(1) =20 - if (LA75_0 =3D=3D 90) : + if (LA75_0 =3D=3D 90): alt75 =3D 1 if alt75 =3D=3D 1: # C.g:481:29: '?' expression ':' conditional_expression - self.match(self.input, 90, self.FOLLOW_90_in_condition= al_expression1842) + self.match(self.input, 90, + self.FOLLOW_90_in_conditional_expression184= 2) if self.failed: return - self.following.append(self.FOLLOW_expression_in_condit= ional_expression1844) + self.following.append( + self.FOLLOW_expression_in_conditional_expression18= 44) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_condition= al_expression1846) + self.match(self.input, 47, + self.FOLLOW_47_in_conditional_expression184= 6) if self.failed: return - self.following.append(self.FOLLOW_conditional_expressi= on_in_conditional_expression1848) + self.following.append( + self.FOLLOW_conditional_expression_in_conditional_= expression1848) self.conditional_expression() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - - - - - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -8299,10 +8194,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start logical_or_expression # C.g:484:1: logical_or_expression : logical_and_expression ( '||' log= ical_and_expression )* ; + def logical_or_expression(self, ): =20 retval =3D self.logical_or_expression_return() @@ -8315,42 +8209,38 @@ class CParser(Parser): =20 # C.g:485:2: ( logical_and_expression ( '||' logical_and_e= xpression )* ) # C.g:485:4: logical_and_expression ( '||' logical_and_exp= ression )* - self.following.append(self.FOLLOW_logical_and_expression_i= n_logical_or_expression1863) + self.following.append( + self.FOLLOW_logical_and_expression_in_logical_or_expre= ssion1863) self.logical_and_expression() self.following.pop() if self.failed: return retval # C.g:485:27: ( '||' logical_and_expression )* - while True: #loop76 + while True: # loop76 alt76 =3D 2 LA76_0 =3D self.input.LA(1) =20 - if (LA76_0 =3D=3D 91) : + if (LA76_0 =3D=3D 91): alt76 =3D 1 =20 - if alt76 =3D=3D 1: # C.g:485:28: '||' logical_and_expression - self.match(self.input, 91, self.FOLLOW_91_in_logic= al_or_expression1866) + self.match(self.input, 91, + self.FOLLOW_91_in_logical_or_expression= 1866) if self.failed: return retval - self.following.append(self.FOLLOW_logical_and_expr= ession_in_logical_or_expression1868) + self.following.append( + self.FOLLOW_logical_and_expression_in_logical_= or_expression1868) self.logical_and_expression() self.following.pop() if self.failed: return retval =20 - else: - break #loop76 - - - - + break # loop76 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8364,9 +8254,9 @@ class CParser(Parser): =20 # $ANTLR end logical_or_expression =20 - # $ANTLR start logical_and_expression # C.g:488:1: logical_and_expression : inclusive_or_expression ( '&&' i= nclusive_or_expression )* ; + def logical_and_expression(self, ): =20 logical_and_expression_StartIndex =3D self.input.index() @@ -8377,39 +8267,35 @@ class CParser(Parser): =20 # C.g:489:2: ( inclusive_or_expression ( '&&' inclusive_or= _expression )* ) # C.g:489:4: inclusive_or_expression ( '&&' inclusive_or_e= xpression )* - self.following.append(self.FOLLOW_inclusive_or_expression_= in_logical_and_expression1881) + self.following.append( + self.FOLLOW_inclusive_or_expression_in_logical_and_exp= ression1881) self.inclusive_or_expression() self.following.pop() if self.failed: return # C.g:489:28: ( '&&' inclusive_or_expression )* - while True: #loop77 + while True: # loop77 alt77 =3D 2 LA77_0 =3D self.input.LA(1) =20 - if (LA77_0 =3D=3D 92) : + if (LA77_0 =3D=3D 92): alt77 =3D 1 =20 - if alt77 =3D=3D 1: # C.g:489:29: '&&' inclusive_or_expression - self.match(self.input, 92, self.FOLLOW_92_in_logic= al_and_expression1884) + self.match( + self.input, 92, self.FOLLOW_92_in_logical_and_= expression1884) if self.failed: return - self.following.append(self.FOLLOW_inclusive_or_exp= ression_in_logical_and_expression1886) + self.following.append( + self.FOLLOW_inclusive_or_expression_in_logical= _and_expression1886) self.inclusive_or_expression() self.following.pop() if self.failed: return =20 - else: - break #loop77 - - - - - + break # loop77 =20 except RecognitionException as re: self.reportError(re) @@ -8424,9 +8310,9 @@ class CParser(Parser): =20 # $ANTLR end logical_and_expression =20 - # $ANTLR start inclusive_or_expression # C.g:492:1: inclusive_or_expression : exclusive_or_expression ( '|' e= xclusive_or_expression )* ; + def inclusive_or_expression(self, ): =20 inclusive_or_expression_StartIndex =3D self.input.index() @@ -8437,46 +8323,43 @@ class CParser(Parser): =20 # C.g:493:2: ( exclusive_or_expression ( '|' exclusive_or_= expression )* ) # C.g:493:4: exclusive_or_expression ( '|' exclusive_or_ex= pression )* - self.following.append(self.FOLLOW_exclusive_or_expression_= in_inclusive_or_expression1899) + self.following.append( + self.FOLLOW_exclusive_or_expression_in_inclusive_or_ex= pression1899) self.exclusive_or_expression() self.following.pop() if self.failed: return # C.g:493:28: ( '|' exclusive_or_expression )* - while True: #loop78 + while True: # loop78 alt78 =3D 2 LA78_0 =3D self.input.LA(1) =20 - if (LA78_0 =3D=3D 93) : + if (LA78_0 =3D=3D 93): alt78 =3D 1 =20 - if alt78 =3D=3D 1: # C.g:493:29: '|' exclusive_or_expression - self.match(self.input, 93, self.FOLLOW_93_in_inclu= sive_or_expression1902) + self.match( + self.input, 93, self.FOLLOW_93_in_inclusive_or= _expression1902) if self.failed: return - self.following.append(self.FOLLOW_exclusive_or_exp= ression_in_inclusive_or_expression1904) + self.following.append( + self.FOLLOW_exclusive_or_expression_in_inclusi= ve_or_expression1904) self.exclusive_or_expression() self.following.pop() if self.failed: return =20 - else: - break #loop78 - - - - - + break # loop78 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 54, inclusive_or_expression_Start= Index) + self.memoize(self.input, 54, + inclusive_or_expression_StartIndex) =20 pass =20 @@ -8484,9 +8367,9 @@ class CParser(Parser): =20 # $ANTLR end inclusive_or_expression =20 - # $ANTLR start exclusive_or_expression # C.g:496:1: exclusive_or_expression : and_expression ( '^' and_expres= sion )* ; + def exclusive_or_expression(self, ): =20 exclusive_or_expression_StartIndex =3D self.input.index() @@ -8497,46 +8380,43 @@ class CParser(Parser): =20 # C.g:497:2: ( and_expression ( '^' and_expression )* ) # C.g:497:4: and_expression ( '^' and_expression )* - self.following.append(self.FOLLOW_and_expression_in_exclus= ive_or_expression1917) + self.following.append( + self.FOLLOW_and_expression_in_exclusive_or_expression1= 917) self.and_expression() self.following.pop() if self.failed: return # C.g:497:19: ( '^' and_expression )* - while True: #loop79 + while True: # loop79 alt79 =3D 2 LA79_0 =3D self.input.LA(1) =20 - if (LA79_0 =3D=3D 94) : + if (LA79_0 =3D=3D 94): alt79 =3D 1 =20 - if alt79 =3D=3D 1: # C.g:497:20: '^' and_expression - self.match(self.input, 94, self.FOLLOW_94_in_exclu= sive_or_expression1920) + self.match( + self.input, 94, self.FOLLOW_94_in_exclusive_or= _expression1920) if self.failed: return - self.following.append(self.FOLLOW_and_expression_i= n_exclusive_or_expression1922) + self.following.append( + self.FOLLOW_and_expression_in_exclusive_or_exp= ression1922) self.and_expression() self.following.pop() if self.failed: return =20 - else: - break #loop79 - - - - - + break # loop79 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 55, exclusive_or_expression_Start= Index) + self.memoize(self.input, 55, + exclusive_or_expression_StartIndex) =20 pass =20 @@ -8544,9 +8424,9 @@ class CParser(Parser): =20 # $ANTLR end exclusive_or_expression =20 - # $ANTLR start and_expression # C.g:500:1: and_expression : equality_expression ( '&' equality_expre= ssion )* ; + def and_expression(self, ): =20 and_expression_StartIndex =3D self.input.index() @@ -8557,39 +8437,35 @@ class CParser(Parser): =20 # C.g:501:2: ( equality_expression ( '&' equality_expressi= on )* ) # C.g:501:4: equality_expression ( '&' equality_expression= )* - self.following.append(self.FOLLOW_equality_expression_in_a= nd_expression1935) + self.following.append( + self.FOLLOW_equality_expression_in_and_expression1935) self.equality_expression() self.following.pop() if self.failed: return # C.g:501:24: ( '&' equality_expression )* - while True: #loop80 + while True: # loop80 alt80 =3D 2 LA80_0 =3D self.input.LA(1) =20 - if (LA80_0 =3D=3D 77) : + if (LA80_0 =3D=3D 77): alt80 =3D 1 =20 - if alt80 =3D=3D 1: # C.g:501:25: '&' equality_expression - self.match(self.input, 77, self.FOLLOW_77_in_and_e= xpression1938) + self.match(self.input, 77, + self.FOLLOW_77_in_and_expression1938) if self.failed: return - self.following.append(self.FOLLOW_equality_express= ion_in_and_expression1940) + self.following.append( + self.FOLLOW_equality_expression_in_and_express= ion1940) self.equality_expression() self.following.pop() if self.failed: return =20 - else: - break #loop80 - - - - - + break # loop80 =20 except RecognitionException as re: self.reportError(re) @@ -8604,9 +8480,9 @@ class CParser(Parser): =20 # $ANTLR end and_expression =20 - # $ANTLR start equality_expression # C.g:503:1: equality_expression : relational_expression ( ( '=3D=3D' = | '!=3D' ) relational_expression )* ; + def equality_expression(self, ): =20 equality_expression_StartIndex =3D self.input.index() @@ -8617,24 +8493,24 @@ class CParser(Parser): =20 # C.g:504:2: ( relational_expression ( ( '=3D=3D' | '!=3D'= ) relational_expression )* ) # C.g:504:4: relational_expression ( ( '=3D=3D' | '!=3D' )= relational_expression )* - self.following.append(self.FOLLOW_relational_expression_in= _equality_expression1952) + self.following.append( + self.FOLLOW_relational_expression_in_equality_expressi= on1952) self.relational_expression() self.following.pop() if self.failed: return # C.g:504:26: ( ( '=3D=3D' | '!=3D' ) relational_expressio= n )* - while True: #loop81 + while True: # loop81 alt81 =3D 2 LA81_0 =3D self.input.LA(1) =20 - if ((95 <=3D LA81_0 <=3D 96)) : + if ((95 <=3D LA81_0 <=3D 96)): alt81 =3D 1 =20 - if alt81 =3D=3D 1: # C.g:504:27: ( '=3D=3D' | '!=3D' ) relational_exp= ression if (95 <=3D self.input.LA(1) <=3D 96): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8646,24 +8522,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_equali= ty_expression1955 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_relational_expre= ssion_in_equality_expression1961) + self.following.append( + self.FOLLOW_relational_expression_in_equality_= expression1961) self.relational_expression() self.following.pop() if self.failed: return =20 - else: - break #loop81 - - - - - + break # loop81 =20 except RecognitionException as re: self.reportError(re) @@ -8678,9 +8548,9 @@ class CParser(Parser): =20 # $ANTLR end equality_expression =20 - # $ANTLR start relational_expression # C.g:507:1: relational_expression : shift_expression ( ( '<' | '>' | = '<=3D' | '>=3D' ) shift_expression )* ; + def relational_expression(self, ): =20 relational_expression_StartIndex =3D self.input.index() @@ -8691,24 +8561,24 @@ class CParser(Parser): =20 # C.g:508:2: ( shift_expression ( ( '<' | '>' | '<=3D' | '= >=3D' ) shift_expression )* ) # C.g:508:4: shift_expression ( ( '<' | '>' | '<=3D' | '>= =3D' ) shift_expression )* - self.following.append(self.FOLLOW_shift_expression_in_rela= tional_expression1975) + self.following.append( + self.FOLLOW_shift_expression_in_relational_expression1= 975) self.shift_expression() self.following.pop() if self.failed: return # C.g:508:21: ( ( '<' | '>' | '<=3D' | '>=3D' ) shift_expr= ession )* - while True: #loop82 + while True: # loop82 alt82 =3D 2 LA82_0 =3D self.input.LA(1) =20 - if ((97 <=3D LA82_0 <=3D 100)) : + if ((97 <=3D LA82_0 <=3D 100)): alt82 =3D 1 =20 - if alt82 =3D=3D 1: # C.g:508:22: ( '<' | '>' | '<=3D' | '>=3D' ) shif= t_expression if (97 <=3D self.input.LA(1) <=3D 100): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8720,24 +8590,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_relati= onal_expression1978 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_shift_expression= _in_relational_expression1988) + self.following.append( + self.FOLLOW_shift_expression_in_relational_exp= ression1988) self.shift_expression() self.following.pop() if self.failed: return =20 - else: - break #loop82 - - - - - + break # loop82 =20 except RecognitionException as re: self.reportError(re) @@ -8752,9 +8616,9 @@ class CParser(Parser): =20 # $ANTLR end relational_expression =20 - # $ANTLR start shift_expression # C.g:511:1: shift_expression : additive_expression ( ( '<<' | '>>' ) = additive_expression )* ; + def shift_expression(self, ): =20 shift_expression_StartIndex =3D self.input.index() @@ -8765,24 +8629,24 @@ class CParser(Parser): =20 # C.g:512:2: ( additive_expression ( ( '<<' | '>>' ) addit= ive_expression )* ) # C.g:512:4: additive_expression ( ( '<<' | '>>' ) additiv= e_expression )* - self.following.append(self.FOLLOW_additive_expression_in_s= hift_expression2001) + self.following.append( + self.FOLLOW_additive_expression_in_shift_expression200= 1) self.additive_expression() self.following.pop() if self.failed: return # C.g:512:24: ( ( '<<' | '>>' ) additive_expression )* - while True: #loop83 + while True: # loop83 alt83 =3D 2 LA83_0 =3D self.input.LA(1) =20 - if ((101 <=3D LA83_0 <=3D 102)) : + if ((101 <=3D LA83_0 <=3D 102)): alt83 =3D 1 =20 - if alt83 =3D=3D 1: # C.g:512:25: ( '<<' | '>>' ) additive_expression if (101 <=3D self.input.LA(1) <=3D 102): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8794,24 +8658,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_shift_= expression2004 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_additive_express= ion_in_shift_expression2010) + self.following.append( + self.FOLLOW_additive_expression_in_shift_expre= ssion2010) self.additive_expression() self.following.pop() if self.failed: return =20 - else: - break #loop83 - - - - - + break # loop83 =20 except RecognitionException as re: self.reportError(re) @@ -8826,9 +8684,9 @@ class CParser(Parser): =20 # $ANTLR end shift_expression =20 - # $ANTLR start statement # C.g:517:1: statement : ( labeled_statement | compound_statement | ex= pression_statement | selection_statement | iteration_statement | jump_state= ment | macro_statement | asm2_statement | asm1_statement | asm_statement | = declaration ); + def statement(self, ): =20 statement_StartIndex =3D self.input.index() @@ -8845,20 +8703,21 @@ class CParser(Parser): if LA84 =3D=3D 62: LA84_43 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (self.synpred173()) : + elif (self.synpred173()): alt84 =3D 7 - elif (self.synpred174()) : + elif (self.synpred174()): alt84 =3D 8 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 43, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 43, self.input) =20 raise nvae =20 @@ -8869,48 +8728,51 @@ class CParser(Parser): elif LA84 =3D=3D 66: LA84_47 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 47, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 47, self.input) =20 raise nvae =20 elif LA84 =3D=3D IDENTIFIER: LA84_53 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 53, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 53, self.input) =20 raise nvae =20 elif LA84 =3D=3D 25: LA84_68 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 68, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 68, self.input) =20 raise nvae =20 @@ -8921,7 +8783,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statement : = ( labeled_statement | compound_statement | expression_statement | selection= _statement | iteration_statement | jump_statement | macro_statement | asm2_= statement | asm1_statement | asm_statement | declaration );", 84, 1, self.i= nput) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | comp= ound_statement | expression_statement | selection_statement | iteration_sta= tement | jump_statement | macro_statement | asm2_statement | asm1_statement= | asm_statement | declaration );", 84, 1, self.input) =20 raise nvae =20 @@ -8950,110 +8813,110 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statement : ( la= beled_statement | compound_statement | expression_statement | selection_sta= tement | iteration_statement | jump_statement | macro_statement | asm2_stat= ement | asm1_statement | asm_statement | declaration );", 84, 0, self.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | compound= _statement | expression_statement | selection_statement | iteration_stateme= nt | jump_statement | macro_statement | asm2_statement | asm1_statement | a= sm_statement | declaration );", 84, 0, self.input) =20 raise nvae =20 if alt84 =3D=3D 1: # C.g:518:4: labeled_statement - self.following.append(self.FOLLOW_labeled_statement_in= _statement2025) + self.following.append( + self.FOLLOW_labeled_statement_in_statement2025) self.labeled_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 2: # C.g:519:4: compound_statement - self.following.append(self.FOLLOW_compound_statement_i= n_statement2030) + self.following.append( + self.FOLLOW_compound_statement_in_statement2030) self.compound_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 3: # C.g:520:4: expression_statement - self.following.append(self.FOLLOW_expression_statement= _in_statement2035) + self.following.append( + self.FOLLOW_expression_statement_in_statement2035) self.expression_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 4: # C.g:521:4: selection_statement - self.following.append(self.FOLLOW_selection_statement_= in_statement2040) + self.following.append( + self.FOLLOW_selection_statement_in_statement2040) self.selection_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 5: # C.g:522:4: iteration_statement - self.following.append(self.FOLLOW_iteration_statement_= in_statement2045) + self.following.append( + self.FOLLOW_iteration_statement_in_statement2045) self.iteration_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 6: # C.g:523:4: jump_statement - self.following.append(self.FOLLOW_jump_statement_in_st= atement2050) + self.following.append( + self.FOLLOW_jump_statement_in_statement2050) self.jump_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 7: # C.g:524:4: macro_statement - self.following.append(self.FOLLOW_macro_statement_in_s= tatement2055) + self.following.append( + self.FOLLOW_macro_statement_in_statement2055) self.macro_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 8: # C.g:525:4: asm2_statement - self.following.append(self.FOLLOW_asm2_statement_in_st= atement2060) + self.following.append( + self.FOLLOW_asm2_statement_in_statement2060) self.asm2_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 9: # C.g:526:4: asm1_statement - self.following.append(self.FOLLOW_asm1_statement_in_st= atement2065) + self.following.append( + self.FOLLOW_asm1_statement_in_statement2065) self.asm1_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 10: # C.g:527:4: asm_statement - self.following.append(self.FOLLOW_asm_statement_in_sta= tement2070) + self.following.append( + self.FOLLOW_asm_statement_in_statement2070) self.asm_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 11: # C.g:528:4: declaration - self.following.append(self.FOLLOW_declaration_in_state= ment2075) + self.following.append( + self.FOLLOW_declaration_in_statement2075) self.declaration() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9067,9 +8930,9 @@ class CParser(Parser): =20 # $ANTLR end statement =20 - # $ANTLR start asm2_statement # C.g:531:1: asm2_statement : ( '__asm__' )? IDENTIFIER '(' (~ ( ';' )= )* ')' ';' ; + def asm2_statement(self, ): =20 asm2_statement_StartIndex =3D self.input.index() @@ -9084,42 +8947,41 @@ class CParser(Parser): alt85 =3D 2 LA85_0 =3D self.input.LA(1) =20 - if (LA85_0 =3D=3D 103) : + if (LA85_0 =3D=3D 103): alt85 =3D 1 if alt85 =3D=3D 1: # C.g:0:0: '__asm__' - self.match(self.input, 103, self.FOLLOW_103_in_asm2_st= atement2086) + self.match(self.input, 103, + self.FOLLOW_103_in_asm2_statement2086) if self.failed: return =20 - - - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_asm2_statement2089) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_asm2_statement2089) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_asm2_statemen= t2091) + self.match(self.input, 62, + self.FOLLOW_62_in_asm2_statement2091) if self.failed: return # C.g:532:30: (~ ( ';' ) )* - while True: #loop86 + while True: # loop86 alt86 =3D 2 LA86_0 =3D self.input.LA(1) =20 - if (LA86_0 =3D=3D 63) : + if (LA86_0 =3D=3D 63): LA86_1 =3D self.input.LA(2) =20 - if ((IDENTIFIER <=3D LA86_1 <=3D LINE_COMMAND) or = (26 <=3D LA86_1 <=3D 117)) : + if ((IDENTIFIER <=3D LA86_1 <=3D LINE_COMMAND) or = (26 <=3D LA86_1 <=3D 117)): alt86 =3D 1 =20 - - elif ((IDENTIFIER <=3D LA86_0 <=3D LINE_COMMAND) or (2= 6 <=3D LA86_0 <=3D 62) or (64 <=3D LA86_0 <=3D 117)) : + elif ((IDENTIFIER <=3D LA86_0 <=3D LINE_COMMAND) or (2= 6 <=3D LA86_0 <=3D 62) or (64 <=3D LA86_0 <=3D 117)): alt86 =3D 1 =20 - if alt86 =3D=3D 1: # C.g:532:31: ~ ( ';' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D LINE_COM= MAND) or (26 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9131,26 +8993,21 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm2_s= tatement2094 - ) + ) raise mse =20 - - - else: - break #loop86 + break # loop86 =20 - - self.match(self.input, 63, self.FOLLOW_63_in_asm2_statemen= t2101) + self.match(self.input, 63, + self.FOLLOW_63_in_asm2_statement2101) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_asm2_statemen= t2103) + self.match(self.input, 25, + self.FOLLOW_25_in_asm2_statement2103) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9164,9 +9021,9 @@ class CParser(Parser): =20 # $ANTLR end asm2_statement =20 - # $ANTLR start asm1_statement # C.g:535:1: asm1_statement : '_asm' '{' (~ ( '}' ) )* '}' ; + def asm1_statement(self, ): =20 asm1_statement_StartIndex =3D self.input.index() @@ -9177,25 +9034,26 @@ class CParser(Parser): =20 # C.g:536:2: ( '_asm' '{' (~ ( '}' ) )* '}' ) # C.g:536:4: '_asm' '{' (~ ( '}' ) )* '}' - self.match(self.input, 104, self.FOLLOW_104_in_asm1_statem= ent2115) + self.match(self.input, 104, + self.FOLLOW_104_in_asm1_statement2115) if self.failed: return - self.match(self.input, 43, self.FOLLOW_43_in_asm1_statemen= t2117) + self.match(self.input, 43, + self.FOLLOW_43_in_asm1_statement2117) if self.failed: return # C.g:536:15: (~ ( '}' ) )* - while True: #loop87 + while True: # loop87 alt87 =3D 2 LA87_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA87_0 <=3D 43) or (45 <=3D LA87_= 0 <=3D 117)) : + if ((IDENTIFIER <=3D LA87_0 <=3D 43) or (45 <=3D LA87_= 0 <=3D 117)): alt87 =3D 1 =20 - if alt87 =3D=3D 1: # C.g:536:16: ~ ( '}' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D 43) or (= 45 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9207,23 +9065,17 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm1_s= tatement2120 - ) + ) raise mse =20 - - - else: - break #loop87 + break # loop87 =20 - - self.match(self.input, 44, self.FOLLOW_44_in_asm1_statemen= t2127) + self.match(self.input, 44, + self.FOLLOW_44_in_asm1_statement2127) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9237,9 +9089,9 @@ class CParser(Parser): =20 # $ANTLR end asm1_statement =20 - # $ANTLR start asm_statement # C.g:539:1: asm_statement : '__asm' '{' (~ ( '}' ) )* '}' ; + def asm_statement(self, ): =20 asm_statement_StartIndex =3D self.input.index() @@ -9250,25 +9102,25 @@ class CParser(Parser): =20 # C.g:540:2: ( '__asm' '{' (~ ( '}' ) )* '}' ) # C.g:540:4: '__asm' '{' (~ ( '}' ) )* '}' - self.match(self.input, 105, self.FOLLOW_105_in_asm_stateme= nt2138) + self.match(self.input, 105, + self.FOLLOW_105_in_asm_statement2138) if self.failed: return self.match(self.input, 43, self.FOLLOW_43_in_asm_statement= 2140) if self.failed: return # C.g:540:16: (~ ( '}' ) )* - while True: #loop88 + while True: # loop88 alt88 =3D 2 LA88_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA88_0 <=3D 43) or (45 <=3D LA88_= 0 <=3D 117)) : + if ((IDENTIFIER <=3D LA88_0 <=3D 43) or (45 <=3D LA88_= 0 <=3D 117)): alt88 =3D 1 =20 - if alt88 =3D=3D 1: # C.g:540:17: ~ ( '}' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D 43) or (= 45 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9280,23 +9132,16 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm_st= atement2143 - ) + ) raise mse =20 - - - else: - break #loop88 - + break # loop88 =20 self.match(self.input, 44, self.FOLLOW_44_in_asm_statement= 2150) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9310,9 +9155,9 @@ class CParser(Parser): =20 # $ANTLR end asm_statement =20 - # $ANTLR start macro_statement # C.g:543:1: macro_statement : IDENTIFIER '(' ( declaration )* ( state= ment_list )? ( expression )? ')' ; + def macro_statement(self, ): =20 macro_statement_StartIndex =3D self.input.index() @@ -9323,14 +9168,16 @@ class CParser(Parser): =20 # C.g:544:2: ( IDENTIFIER '(' ( declaration )* ( statement= _list )? ( expression )? ')' ) # C.g:544:4: IDENTIFIER '(' ( declaration )* ( statement_l= ist )? ( expression )? ')' - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_macro_statement2162) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_macro_statement2162) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_macro_stateme= nt2164) + self.match(self.input, 62, + self.FOLLOW_62_in_macro_statement2164) if self.failed: return # C.g:544:19: ( declaration )* - while True: #loop89 + while True: # loop89 alt89 =3D 2 LA89 =3D self.input.LA(1) if LA89 =3D=3D IDENTIFIER: @@ -9338,1904 +9185,1622 @@ class CParser(Parser): if LA89 =3D=3D 62: LA89_45 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_47 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 66: LA89_50 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_68 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_71 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_72 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_73 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_74 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_75 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_76 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_77 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_78 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_79 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_80 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_81 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_82 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_83 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_84 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_85 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_86 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 26: LA89 =3D self.input.LA(2) if LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D=3D= 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_87 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_88 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_89 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_90 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_91 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_92 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_93 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_94 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_95 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_96 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_97 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_98 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_99 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_100 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 66: LA89_101 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_102 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_103 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_104 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_105 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D=3D 3= 1 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_106 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_107 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_108 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_109 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_110 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_111 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_112 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_113 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_114 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_115 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_116 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_117 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_118 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_119 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_120 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_121 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_122 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_123 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_124 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_125 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 34: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_126 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_127 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_128 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_129 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_130 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_131 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_132 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_133 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_134 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_135 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_136 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_137 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_138 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_139 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_140 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_141 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_142 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_143 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_144 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_145 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 35: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_146 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_147 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_148 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_149 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_150 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_151 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_152 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_153 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_154 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_155 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_156 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_157 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_158 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_159 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_160 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_161 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_162 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_163 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_164 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_165 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 36: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_166 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_167 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_168 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_169 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_170 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_171 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_172 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_173 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_174 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_175 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_176 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_177 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_178 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_179 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_180 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_181 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_182 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_183 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_184 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_185 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 37: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_186 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_187 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_188 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_189 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_190 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_191 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_192 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_193 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_194 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_195 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_196 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_197 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_198 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_199 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_200 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_201 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_202 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_203 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_204 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_205 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 38: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_206 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_207 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_208 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_209 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_210 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_211 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_212 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_213 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_214 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_215 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_216 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_217 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_218 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_219 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_220 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_221 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_222 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_223 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_224 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_225 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 39: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_226 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_227 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_228 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_229 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_230 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_231 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_232 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_233 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_234 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_235 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_236 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_237 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_238 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_239 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_240 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_241 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_242 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_243 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_244 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_245 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 40: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_246 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_247 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_248 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_249 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_250 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_251 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_252 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_253 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_254 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_255 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_256 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_257 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_258 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_259 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_260 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_261 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_262 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_263 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_264 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_265 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 41: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_266 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_267 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_268 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_269 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_270 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_271 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_272 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_273 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_274 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_275 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_276 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_277 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_278 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_279 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_280 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_281 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_282 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_283 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_284 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_285 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 42: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_286 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_287 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_288 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_289 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_290 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_291 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_292 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_293 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_294 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_295 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_296 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_297 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_298 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_299 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_300 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_301 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_302 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_303 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_304 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_305 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_40 =3D self.input.LA(2) =20 - if (LA89_40 =3D=3D IDENTIFIER) : + if (LA89_40 =3D=3D IDENTIFIER): LA89_306 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif (LA89_40 =3D=3D 43) : + elif (LA89_40 =3D=3D 43): LA89_307 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - elif LA89 =3D=3D 48: LA89_41 =3D self.input.LA(2) =20 - if (LA89_41 =3D=3D 43) : + if (LA89_41 =3D=3D 43): LA89_308 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif (LA89_41 =3D=3D IDENTIFIER) : + elif (LA89_41 =3D=3D IDENTIFIER): LA89_309 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D=3D 5= 1 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D 55 o= r LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 58 or LA89 =3D=3D 59 or L= A89 =3D=3D 60 or LA89 =3D=3D 61: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_310 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_311 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_312 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_313 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_314 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_315 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_316 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_317 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_318 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_319 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_320 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_321 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_322 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_323 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_324 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_325 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_326 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_327 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_328 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_329 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - if alt89 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_in_m= acro_statement2166) + self.following.append( + self.FOLLOW_declaration_in_macro_statement2166) self.declaration() self.following.pop() if self.failed: return =20 - else: - break #loop89 - + break # loop89 =20 # C.g:544:33: ( statement_list )? alt90 =3D 2 @@ -11247,122 +10812,122 @@ class CParser(Parser): elif LA90 =3D=3D 62: LA90_45 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_46 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_47 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 64: LA90_48 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_49 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_50 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_51 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_52 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_53 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_54 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_55 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_56 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_57 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_58 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_59 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_60 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_61 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_62 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_63 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_64 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_65 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_66 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_67 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_70 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25 or LA90 =3D=3D 26 or LA90 =3D=3D 29 or= LA90 =3D=3D 30 or LA90 =3D=3D 31 or LA90 =3D=3D 32 or LA90 =3D=3D 33 or LA= 90 =3D=3D 34 or LA90 =3D=3D 35 or LA90 =3D=3D 36 or LA90 =3D=3D 37 or LA90 = =3D=3D 38 or LA90 =3D=3D 39 or LA90 =3D=3D 40 or LA90 =3D=3D 41 or LA90 =3D= =3D 42 or LA90 =3D=3D 43 or LA90 =3D=3D 45 or LA90 =3D=3D 46 or LA90 =3D=3D= 48 or LA90 =3D=3D 49 or LA90 =3D=3D 50 or LA90 =3D=3D 51 or LA90 =3D=3D 52= or LA90 =3D=3D 53 or LA90 =3D=3D 54 or LA90 =3D=3D 55 or LA90 =3D=3D 56 or= LA90 =3D=3D 57 or LA90 =3D=3D 58 or LA90 =3D=3D 59 or LA90 =3D=3D 60 or LA= 90 =3D=3D 61 or LA90 =3D=3D 103 or LA90 =3D=3D 104 or LA90 =3D=3D 105 or LA= 90 =3D=3D 106 or LA90 =3D=3D 107 or LA90 =3D=3D 108 or LA90 =3D=3D 110 or L= A90 =3D=3D 111 or LA90 =3D=3D 112 or LA90 =3D=3D 113 or LA90 =3D=3D 114 or = LA90 =3D=3D 115 or LA90 =3D=3D 116 or LA90 =3D=3D 117: alt90 =3D 1 @@ -11371,112 +10936,112 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_87 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_88 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_89 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_90 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_91 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_92 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_93 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_94 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_95 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_96 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_97 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_98 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_99 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_100 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_101 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_102 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_103 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_104 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_105 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_106 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_107 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_108 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11485,226 +11050,226 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_111 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_112 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_113 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_114 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_115 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_116 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_117 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_118 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_119 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_120 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_121 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_122 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_123 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_124 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_125 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_126 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_127 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_128 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_129 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_130 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_131 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_134 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90 =3D self.input.LA(2) if LA90 =3D=3D 64: LA90_135 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_136 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_137 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_138 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_139 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_140 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_141 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_142 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_143 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_144 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_145 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_146 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_147 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_148 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_149 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_150 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_151 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_152 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_153 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_154 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_155 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_156 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11713,236 +11278,236 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_159 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_160 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_161 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_162 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_163 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_164 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_165 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_166 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_167 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_168 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_169 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_170 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_171 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_172 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_173 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_174 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_175 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_176 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_177 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_178 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_179 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_181 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_183 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 64: LA90_184 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_185 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_186 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_187 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_188 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_189 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_190 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_191 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_192 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_193 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_194 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_195 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_196 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_197 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_198 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_199 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_200 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_201 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_202 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_203 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_204 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_205 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_206 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11951,112 +11516,112 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_209 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_210 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_211 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_212 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_213 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_214 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_215 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_216 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_217 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_218 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_219 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_220 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_221 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_222 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_223 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_224 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_225 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_226 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_227 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_228 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_229 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_230 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -12065,404 +11630,400 @@ class CParser(Parser): if LA90 =3D=3D IDENTIFIER: LA90_233 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_234 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_235 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_236 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_237 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_238 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_239 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_240 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_241 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_242 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_243 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_244 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 49 or LA90 =3D=3D 50 or LA90 =3D=3D 5= 1 or LA90 =3D=3D 52 or LA90 =3D=3D 53 or LA90 =3D=3D 54 or LA90 =3D=3D 55 o= r LA90 =3D=3D 56 or LA90 =3D=3D 57 or LA90 =3D=3D 58 or LA90 =3D=3D 59 or L= A90 =3D=3D 60 or LA90 =3D=3D 61: LA90_245 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 34: LA90_246 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 35: LA90_247 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 36: LA90_248 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 37: LA90_249 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 38: LA90_250 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 39: LA90_251 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 40: LA90_252 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 41: LA90_253 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 42: LA90_254 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 45 or LA90 =3D=3D 46: LA90_255 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 48: LA90_256 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_257 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_258 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_259 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_260 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_261 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_262 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_263 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_264 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_265 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_266 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_267 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_268 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_269 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_270 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_271 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_272 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_273 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_274 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_275 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_276 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_277 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_278 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_279 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_280 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 69 or= LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90 =3D self.input.LA(2) if LA90 =3D=3D 62: LA90_281 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_282 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_283 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_284 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_285 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_286 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_287 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_288 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_289 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_290 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_291 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_292 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90 =3D self.input.LA(2) if LA90 =3D=3D 62: LA90_293 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_294 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_295 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_296 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_297 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_298 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_299 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_300 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_301 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_302 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_303 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_304 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 if alt90 =3D=3D 1: # C.g:0:0: statement_list - self.following.append(self.FOLLOW_statement_list_in_ma= cro_statement2170) + self.following.append( + self.FOLLOW_statement_list_in_macro_statement2170) self.statement_list() self.following.pop() if self.failed: return =20 - - # C.g:544:49: ( expression )? alt91 =3D 2 LA91_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA91_0 <=3D FLOATING_POINT_LITERAL) o= r LA91_0 =3D=3D 62 or LA91_0 =3D=3D 66 or (68 <=3D LA91_0 <=3D 69) or (72 <= =3D LA91_0 <=3D 74) or (77 <=3D LA91_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA91_0 <=3D FLOATING_POINT_LITERAL) o= r LA91_0 =3D=3D 62 or LA91_0 =3D=3D 66 or (68 <=3D LA91_0 <=3D 69) or (72 <= =3D LA91_0 <=3D 74) or (77 <=3D LA91_0 <=3D 79)): alt91 =3D 1 if alt91 =3D=3D 1: # C.g:0:0: expression - self.following.append(self.FOLLOW_expression_in_macro_= statement2173) + self.following.append( + self.FOLLOW_expression_in_macro_statement2173) self.expression() self.following.pop() if self.failed: return =20 - - - self.match(self.input, 63, self.FOLLOW_63_in_macro_stateme= nt2176) + self.match(self.input, 63, + self.FOLLOW_63_in_macro_statement2176) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -12476,9 +12037,9 @@ class CParser(Parser): =20 # $ANTLR end macro_statement =20 - # $ANTLR start labeled_statement # C.g:547:1: labeled_statement : ( IDENTIFIER ':' statement | 'case' c= onstant_expression ':' statement | 'default' ':' statement ); + def labeled_statement(self, ): =20 labeled_statement_StartIndex =3D self.input.index() @@ -12501,61 +12062,68 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("547:1: labeled_statemen= t : ( IDENTIFIER ':' statement | 'case' constant_expression ':' statement |= 'default' ':' statement );", 92, 0, self.input) + nvae =3D NoViableAltException( + "547:1: labeled_statement : ( IDENTIFIER ':' state= ment | 'case' constant_expression ':' statement | 'default' ':' statement )= ;", 92, 0, self.input) =20 raise nvae =20 if alt92 =3D=3D 1: # C.g:548:4: IDENTIFIER ':' statement - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_labeled_statement2188) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_labeled_statement= 2188) if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2190) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2190) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2192) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2192) self.statement() self.following.pop() if self.failed: return =20 - elif alt92 =3D=3D 2: # C.g:549:4: 'case' constant_expression ':' statement - self.match(self.input, 106, self.FOLLOW_106_in_labeled= _statement2197) + self.match(self.input, 106, + self.FOLLOW_106_in_labeled_statement2197) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_labeled_statement2199) + self.following.append( + self.FOLLOW_constant_expression_in_labeled_stateme= nt2199) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2201) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2201) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2203) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2203) self.statement() self.following.pop() if self.failed: return =20 - elif alt92 =3D=3D 3: # C.g:550:4: 'default' ':' statement - self.match(self.input, 107, self.FOLLOW_107_in_labeled= _statement2208) + self.match(self.input, 107, + self.FOLLOW_107_in_labeled_statement2208) if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2210) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2210) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2212) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2212) self.statement() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -12574,10 +12142,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start compound_statement # C.g:553:1: compound_statement : '{' ( declaration )* ( statement_lis= t )? '}' ; + def compound_statement(self, ): =20 retval =3D self.compound_statement_return() @@ -12590,11 +12157,12 @@ class CParser(Parser): =20 # C.g:554:2: ( '{' ( declaration )* ( statement_list )? '}= ' ) # C.g:554:4: '{' ( declaration )* ( statement_list )? '}' - self.match(self.input, 43, self.FOLLOW_43_in_compound_stat= ement2223) + self.match(self.input, 43, + self.FOLLOW_43_in_compound_statement2223) if self.failed: return retval # C.g:554:8: ( declaration )* - while True: #loop93 + while True: # loop93 alt93 =3D 2 LA93 =3D self.input.LA(1) if LA93 =3D=3D IDENTIFIER: @@ -12602,1930 +12170,1645 @@ class CParser(Parser): if LA93 =3D=3D 62: LA93_44 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_47 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 66: LA93_48 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_49 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_50 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_51 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_52 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_53 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_54 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_55 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_56 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_57 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_58 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_59 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_60 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_61 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_62 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_63 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_64 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_65 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 26: LA93 =3D self.input.LA(2) if LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D=3D= 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_86 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_87 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_88 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_89 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_90 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_91 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_92 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_93 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_94 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_95 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_96 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_97 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_98 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_99 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 66: LA93_100 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_101 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_102 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_103 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_104 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D=3D 3= 1 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_105 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_106 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_107 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_108 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_109 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_110 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_111 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_112 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_113 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_114 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_115 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_116 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_117 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_118 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_119 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_120 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_121 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_122 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_123 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_124 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 34: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_125 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_126 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_127 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_128 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_129 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_130 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_131 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_132 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_133 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_134 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_135 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_136 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_137 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_138 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_139 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_140 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_141 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_142 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_143 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_144 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 35: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_145 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_146 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_147 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_148 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_149 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_150 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_151 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_152 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_153 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_154 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_155 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_156 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_157 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_158 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_159 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_160 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_161 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_162 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_163 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_164 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 36: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_165 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_166 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_167 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_168 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_169 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_170 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_171 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_172 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_173 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_174 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_175 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_176 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_177 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_178 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_179 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_180 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_181 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_182 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_183 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_184 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 37: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_185 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_186 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_187 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_188 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_189 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_190 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_191 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_192 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_193 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_194 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_195 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_196 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_197 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_198 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_199 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_200 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_201 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_202 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_203 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_204 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 38: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_205 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_206 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_207 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_208 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_209 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_210 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_211 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_212 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_213 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_214 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_215 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_216 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_217 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_218 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_219 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_220 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_221 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_222 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_223 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_224 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 39: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_225 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_226 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_227 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_228 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_229 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_230 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_231 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_232 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_233 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_234 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_235 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_236 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_237 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_238 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_239 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_240 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_241 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_242 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_243 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_244 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 40: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_245 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_246 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_247 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_248 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_249 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_250 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_251 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_252 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_253 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_254 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_255 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_256 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_257 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_258 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_259 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_260 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_261 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_262 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_263 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_264 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 41: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_265 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_266 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_267 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_268 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_269 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_270 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_271 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_272 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_273 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_274 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_275 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_276 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_277 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_278 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_279 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_280 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_281 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_282 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_283 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_284 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 42: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_285 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_286 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_287 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_288 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_289 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_290 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_291 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_292 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_293 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_294 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_295 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_296 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_297 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_298 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_299 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_300 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_301 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_302 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_303 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_304 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_40 =3D self.input.LA(2) =20 - if (LA93_40 =3D=3D IDENTIFIER) : + if (LA93_40 =3D=3D IDENTIFIER): LA93_305 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif (LA93_40 =3D=3D 43) : + elif (LA93_40 =3D=3D 43): LA93_306 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - elif LA93 =3D=3D 48: LA93_41 =3D self.input.LA(2) =20 - if (LA93_41 =3D=3D 43) : + if (LA93_41 =3D=3D 43): LA93_307 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif (LA93_41 =3D=3D IDENTIFIER) : + elif (LA93_41 =3D=3D IDENTIFIER): LA93_308 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D=3D 5= 1 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D 55 o= r LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 58 or LA93 =3D=3D 59 or L= A93 =3D=3D 60 or LA93 =3D=3D 61: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_309 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_310 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_311 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_312 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_313 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_314 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_315 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_316 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_317 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_318 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_319 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_320 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_321 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_322 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_323 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_324 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_325 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_326 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_327 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_328 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - if alt93 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_in_c= ompound_statement2225) + self.following.append( + self.FOLLOW_declaration_in_compound_statement2= 225) self.declaration() self.following.pop() if self.failed: return retval =20 - else: - break #loop93 - + break # loop93 =20 # C.g:554:21: ( statement_list )? alt94 =3D 2 LA94_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA94_0 <=3D FLOATING_POINT_LITERAL) o= r (25 <=3D LA94_0 <=3D 26) or (29 <=3D LA94_0 <=3D 43) or (45 <=3D LA94_0 <= =3D 46) or (48 <=3D LA94_0 <=3D 62) or LA94_0 =3D=3D 66 or (68 <=3D LA94_0 = <=3D 69) or (72 <=3D LA94_0 <=3D 74) or (77 <=3D LA94_0 <=3D 79) or (103 <= =3D LA94_0 <=3D 108) or (110 <=3D LA94_0 <=3D 117)) : + if ((IDENTIFIER <=3D LA94_0 <=3D FLOATING_POINT_LITERAL) o= r (25 <=3D LA94_0 <=3D 26) or (29 <=3D LA94_0 <=3D 43) or (45 <=3D LA94_0 <= =3D 46) or (48 <=3D LA94_0 <=3D 62) or LA94_0 =3D=3D 66 or (68 <=3D LA94_0 = <=3D 69) or (72 <=3D LA94_0 <=3D 74) or (77 <=3D LA94_0 <=3D 79) or (103 <= =3D LA94_0 <=3D 108) or (110 <=3D LA94_0 <=3D 117)): alt94 =3D 1 if alt94 =3D=3D 1: # C.g:0:0: statement_list - self.following.append(self.FOLLOW_statement_list_in_co= mpound_statement2228) + self.following.append( + self.FOLLOW_statement_list_in_compound_statement22= 28) self.statement_list() self.following.pop() if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_compound_stat= ement2231) + self.match(self.input, 44, + self.FOLLOW_44_in_compound_statement2231) if self.failed: return retval =20 - - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -14539,9 +13822,9 @@ class CParser(Parser): =20 # $ANTLR end compound_statement =20 - # $ANTLR start statement_list # C.g:557:1: statement_list : ( statement )+ ; + def statement_list(self, ): =20 statement_list_StartIndex =3D self.input.index() @@ -14554,7 +13837,7 @@ class CParser(Parser): # C.g:558:4: ( statement )+ # C.g:558:4: ( statement )+ cnt95 =3D 0 - while True: #loop95 + while True: # loop95 alt95 =3D 2 LA95 =3D self.input.LA(1) if LA95 =3D=3D IDENTIFIER: @@ -14562,330 +13845,283 @@ class CParser(Parser): if LA95 =3D=3D 62: LA95_46 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25 or LA95 =3D=3D 29 or LA95 =3D= =3D 30 or LA95 =3D=3D 31 or LA95 =3D=3D 32 or LA95 =3D=3D 33 or LA95 =3D=3D= 34 or LA95 =3D=3D 35 or LA95 =3D=3D 36 or LA95 =3D=3D 37 or LA95 =3D=3D 38= or LA95 =3D=3D 39 or LA95 =3D=3D 40 or LA95 =3D=3D 41 or LA95 =3D=3D 42 or= LA95 =3D=3D 45 or LA95 =3D=3D 46 or LA95 =3D=3D 47 or LA95 =3D=3D 48 or LA= 95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D=3D 51 or LA95 =3D=3D 52 or LA95 = =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D 55 or LA95 =3D=3D 56 or LA95 =3D= =3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59 or LA95 =3D=3D 60 or LA95 =3D=3D= 61: alt95 =3D 1 elif LA95 =3D=3D STRING_LITERAL: LA95_48 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_49 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 64: LA95_50 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_51 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_52 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_53 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_54 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_55 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_56 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_57 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_58 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_59 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_60 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_61 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_62 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_63 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_64 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_65 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_66 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_67 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_68 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_69 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_88 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D HEX_LITERAL: LA95 =3D self.input.LA(2) if LA95 =3D=3D 64: LA95_89 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_90 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_91 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_92 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_93 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_94 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_95 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_96 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_97 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_98 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_99 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_100 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_101 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_102 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_103 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_104 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_105 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_106 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_107 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_108 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_109 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_110 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -14894,157 +14130,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_113 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_114 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_115 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_116 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_117 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_118 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_119 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_120 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_121 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_122 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_123 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_124 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_125 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_126 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_127 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_128 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_129 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_130 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_131 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_132 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_133 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_135 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15053,157 +14267,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_137 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_138 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_139 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_140 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_141 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_142 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_143 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_144 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_145 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_146 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_147 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_148 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_149 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_150 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_151 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_152 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_153 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_154 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_155 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_156 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_157 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_158 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15212,157 +14404,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_161 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_162 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_163 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_164 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_165 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_166 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_167 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_168 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_169 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_170 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_171 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_172 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_173 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_174 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_175 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_176 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_177 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_178 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_179 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_180 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_181 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_182 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15371,867 +14541,742 @@ class CParser(Parser): if LA95 =3D=3D IDENTIFIER: LA95_185 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 64: LA95_186 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_187 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_188 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_189 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_190 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_191 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_192 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_193 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_194 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_195 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_196 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_197 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_198 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_199 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_200 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_201 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_202 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_203 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_204 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_205 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_206 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 elif LA95 =3D=3D STRING_LITERAL: LA95_208 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_209 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95 =3D self.input.LA(2) if LA95 =3D=3D 64: LA95_211 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_212 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_213 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_214 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_215 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_216 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_217 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_218 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_219 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_220 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_221 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_222 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_223 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_224 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_225 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_226 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_227 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_228 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_229 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_230 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_231 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_234 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 62: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_235 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_236 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_237 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_238 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_239 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_240 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_241 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_242 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_243 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_244 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_245 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_246 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D= =3D 51 or LA95 =3D=3D 52 or LA95 =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D= 55 or LA95 =3D=3D 56 or LA95 =3D=3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59= or LA95 =3D=3D 60 or LA95 =3D=3D 61: LA95_247 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 34: LA95_248 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 35: LA95_249 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 36: LA95_250 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 37: LA95_251 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 38: LA95_252 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 39: LA95_253 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 40: LA95_254 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 41: LA95_255 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 42: LA95_256 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 45 or LA95 =3D=3D 46: LA95_257 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 48: LA95_258 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 72: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_259 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_260 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_261 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_262 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_263 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_264 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_265 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_266 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_267 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_268 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_269 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_270 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 73: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_271 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_272 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_273 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_274 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_275 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_276 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_277 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_278 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_279 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_280 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_281 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_282 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D=3D 6= 9 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95 =3D self.input.LA(2) if LA95 =3D=3D 62: LA95_283 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_284 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_285 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_286 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_287 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_288 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_289 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_290 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_291 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_292 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_293 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_294 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 74: LA95 =3D self.input.LA(2) if LA95 =3D=3D 62: LA95_295 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_296 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_297 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_298 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_299 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_300 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_301 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_302 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_303 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_304 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_305 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_306 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 25 or LA95 =3D=3D 26 or LA95 =3D=3D 2= 9 or LA95 =3D=3D 30 or LA95 =3D=3D 31 or LA95 =3D=3D 32 or LA95 =3D=3D 33 o= r LA95 =3D=3D 34 or LA95 =3D=3D 35 or LA95 =3D=3D 36 or LA95 =3D=3D 37 or L= A95 =3D=3D 38 or LA95 =3D=3D 39 or LA95 =3D=3D 40 or LA95 =3D=3D 41 or LA95= =3D=3D 42 or LA95 =3D=3D 43 or LA95 =3D=3D 45 or LA95 =3D=3D 46 or LA95 = =3D=3D 48 or LA95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D=3D 51 or LA95 =3D= =3D 52 or LA95 =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D 55 or LA95 =3D=3D= 56 or LA95 =3D=3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59 or LA95 =3D=3D 60= or LA95 =3D=3D 61 or LA95 =3D=3D 103 or LA95 =3D=3D 104 or LA95 =3D=3D 105= or LA95 =3D=3D 106 or LA95 =3D=3D 107 or LA95 =3D=3D 108 or LA95 =3D=3D 11= 0 or LA95 =3D=3D 111 or LA95 =3D=3D 112 or LA95 =3D=3D 113 or LA95 =3D=3D 1= 14 or LA95 =3D=3D 115 or LA95 =3D=3D 116 or LA95 =3D=3D 117: alt95 =3D 1 =20 if alt95 =3D=3D 1: # C.g:0:0: statement - self.following.append(self.FOLLOW_statement_in_sta= tement_list2242) + self.following.append( + self.FOLLOW_statement_in_statement_list2242) self.statement() self.following.pop() if self.failed: return =20 - else: if cnt95 >=3D 1: - break #loop95 + break # loop95 =20 if self.backtracking > 0: self.failed =3D True @@ -16242,11 +15287,6 @@ class CParser(Parser): =20 cnt95 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16265,10 +15305,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start expression_statement # C.g:561:1: expression_statement : ( ';' | expression ';' ); + def expression_statement(self, ): =20 retval =3D self.expression_statement_return() @@ -16283,41 +15322,42 @@ class CParser(Parser): alt96 =3D 2 LA96_0 =3D self.input.LA(1) =20 - if (LA96_0 =3D=3D 25) : + if (LA96_0 =3D=3D 25): alt96 =3D 1 - elif ((IDENTIFIER <=3D LA96_0 <=3D FLOATING_POINT_LITERAL)= or LA96_0 =3D=3D 62 or LA96_0 =3D=3D 66 or (68 <=3D LA96_0 <=3D 69) or (72= <=3D LA96_0 <=3D 74) or (77 <=3D LA96_0 <=3D 79)) : + elif ((IDENTIFIER <=3D LA96_0 <=3D FLOATING_POINT_LITERAL)= or LA96_0 =3D=3D 62 or LA96_0 =3D=3D 66 or (68 <=3D LA96_0 <=3D 69) or (72= <=3D LA96_0 <=3D 74) or (77 <=3D LA96_0 <=3D 79)): alt96 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("561:1: expression_state= ment : ( ';' | expression ';' );", 96, 0, self.input) + nvae =3D NoViableAltException( + "561:1: expression_statement : ( ';' | expression = ';' );", 96, 0, self.input) =20 raise nvae =20 if alt96 =3D=3D 1: # C.g:562:4: ';' - self.match(self.input, 25, self.FOLLOW_25_in_expressio= n_statement2254) + self.match(self.input, 25, + self.FOLLOW_25_in_expression_statement2254) if self.failed: return retval =20 - elif alt96 =3D=3D 2: # C.g:563:4: expression ';' - self.following.append(self.FOLLOW_expression_in_expres= sion_statement2259) + self.following.append( + self.FOLLOW_expression_in_expression_statement2259) self.expression() self.following.pop() if self.failed: return retval - self.match(self.input, 25, self.FOLLOW_25_in_expressio= n_statement2261) + self.match(self.input, 25, + self.FOLLOW_25_in_expression_statement2261) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16331,15 +15371,14 @@ class CParser(Parser): =20 # $ANTLR end expression_statement =20 - # $ANTLR start selection_statement # C.g:566:1: selection_statement : ( 'if' '(' e=3D expression ')' stat= ement ( options {k=3D1; backtrack=3Dfalse; } : 'else' statement )? | 'switc= h' '(' expression ')' statement ); + def selection_statement(self, ): =20 selection_statement_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 69): @@ -16349,39 +15388,46 @@ class CParser(Parser): alt98 =3D 2 LA98_0 =3D self.input.LA(1) =20 - if (LA98_0 =3D=3D 108) : + if (LA98_0 =3D=3D 108): alt98 =3D 1 - elif (LA98_0 =3D=3D 110) : + elif (LA98_0 =3D=3D 110): alt98 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("566:1: selection_statem= ent : ( 'if' '(' e=3D expression ')' statement ( options {k=3D1; backtrack= =3Dfalse; } : 'else' statement )? | 'switch' '(' expression ')' statement )= ;", 98, 0, self.input) + nvae =3D NoViableAltException( + "566:1: selection_statement : ( 'if' '(' e=3D expr= ession ')' statement ( options {k=3D1; backtrack=3Dfalse; } : 'else' statem= ent )? | 'switch' '(' expression ')' statement );", 98, 0, self.input) =20 raise nvae =20 if alt98 =3D=3D 1: # C.g:567:4: 'if' '(' e=3D expression ')' statement ( = options {k=3D1; backtrack=3Dfalse; } : 'else' statement )? - self.match(self.input, 108, self.FOLLOW_108_in_selecti= on_statement2272) + self.match(self.input, 108, + self.FOLLOW_108_in_selection_statement2272) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_selection= _statement2274) + self.match(self.input, 62, + self.FOLLOW_62_in_selection_statement2274) if self.failed: return - self.following.append(self.FOLLOW_expression_in_select= ion_statement2278) + self.following.append( + self.FOLLOW_expression_in_selection_statement2278) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_selection= _statement2280) + self.match(self.input, 63, + self.FOLLOW_63_in_selection_statement2280) if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 - self.following.append(self.FOLLOW_statement_in_selecti= on_statement2284) + self.following.append( + self.FOLLOW_statement_in_selection_statement2284) self.statement() self.following.pop() if self.failed: @@ -16390,47 +15436,48 @@ class CParser(Parser): alt97 =3D 2 LA97_0 =3D self.input.LA(1) =20 - if (LA97_0 =3D=3D 109) : + if (LA97_0 =3D=3D 109): alt97 =3D 1 if alt97 =3D=3D 1: # C.g:567:200: 'else' statement - self.match(self.input, 109, self.FOLLOW_109_in_sel= ection_statement2299) + self.match(self.input, 109, + self.FOLLOW_109_in_selection_statement2= 299) if self.failed: return - self.following.append(self.FOLLOW_statement_in_sel= ection_statement2301) + self.following.append( + self.FOLLOW_statement_in_selection_statement23= 01) self.statement() self.following.pop() if self.failed: return =20 - - - - elif alt98 =3D=3D 2: # C.g:568:4: 'switch' '(' expression ')' statement - self.match(self.input, 110, self.FOLLOW_110_in_selecti= on_statement2308) + self.match(self.input, 110, + self.FOLLOW_110_in_selection_statement2308) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_selection= _statement2310) + self.match(self.input, 62, + self.FOLLOW_62_in_selection_statement2310) if self.failed: return - self.following.append(self.FOLLOW_expression_in_select= ion_statement2312) + self.following.append( + self.FOLLOW_expression_in_selection_statement2312) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_selection= _statement2314) + self.match(self.input, 63, + self.FOLLOW_63_in_selection_statement2314) if self.failed: return - self.following.append(self.FOLLOW_statement_in_selecti= on_statement2316) + self.following.append( + self.FOLLOW_statement_in_selection_statement2316) self.statement() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16444,15 +15491,14 @@ class CParser(Parser): =20 # $ANTLR end selection_statement =20 - # $ANTLR start iteration_statement # C.g:571:1: iteration_statement : ( 'while' '(' e=3D expression ')' s= tatement | 'do' statement 'while' '(' e=3D expression ')' ';' | 'for' '(' e= xpression_statement e=3D expression_statement ( expression )? ')' statement= ); + def iteration_statement(self, ): =20 iteration_statement_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 70): @@ -16472,82 +15518,97 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("571:1: iteration_statem= ent : ( 'while' '(' e=3D expression ')' statement | 'do' statement 'while' = '(' e=3D expression ')' ';' | 'for' '(' expression_statement e=3D expressio= n_statement ( expression )? ')' statement );", 100, 0, self.input) + nvae =3D NoViableAltException( + "571:1: iteration_statement : ( 'while' '(' e=3D e= xpression ')' statement | 'do' statement 'while' '(' e=3D expression ')' ';= ' | 'for' '(' expression_statement e=3D expression_statement ( expression )= ? ')' statement );", 100, 0, self.input) =20 raise nvae =20 if alt100 =3D=3D 1: # C.g:572:4: 'while' '(' e=3D expression ')' statement - self.match(self.input, 111, self.FOLLOW_111_in_iterati= on_statement2327) + self.match(self.input, 111, + self.FOLLOW_111_in_iteration_statement2327) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2329) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2329) if self.failed: return - self.following.append(self.FOLLOW_expression_in_iterat= ion_statement2333) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2333) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2335) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2335) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2337) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2337) self.statement() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 elif alt100 =3D=3D 2: # C.g:573:4: 'do' statement 'while' '(' e=3D expressio= n ')' ';' - self.match(self.input, 112, self.FOLLOW_112_in_iterati= on_statement2344) + self.match(self.input, 112, + self.FOLLOW_112_in_iteration_statement2344) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2346) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2346) self.statement() self.following.pop() if self.failed: return - self.match(self.input, 111, self.FOLLOW_111_in_iterati= on_statement2348) + self.match(self.input, 111, + self.FOLLOW_111_in_iteration_statement2348) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2350) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2350) if self.failed: return - self.following.append(self.FOLLOW_expression_in_iterat= ion_statement2354) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2354) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2356) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2356) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_iteration= _statement2358) + self.match(self.input, 25, + self.FOLLOW_25_in_iteration_statement2358) if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 elif alt100 =3D=3D 3: # C.g:574:4: 'for' '(' expression_statement e=3D expre= ssion_statement ( expression )? ')' statement - self.match(self.input, 113, self.FOLLOW_113_in_iterati= on_statement2365) + self.match(self.input, 113, + self.FOLLOW_113_in_iteration_statement2365) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2367) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2367) if self.failed: return - self.following.append(self.FOLLOW_expression_statement= _in_iteration_statement2369) + self.following.append( + self.FOLLOW_expression_statement_in_iteration_stat= ement2369) self.expression_statement() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_expression_statement= _in_iteration_statement2373) + self.following.append( + self.FOLLOW_expression_statement_in_iteration_stat= ement2373) e =3D self.expression_statement() self.following.pop() if self.failed: @@ -16556,31 +15617,30 @@ class CParser(Parser): alt99 =3D 2 LA99_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA99_0 <=3D FLOATING_POINT_LITERA= L) or LA99_0 =3D=3D 62 or LA99_0 =3D=3D 66 or (68 <=3D LA99_0 <=3D 69) or (= 72 <=3D LA99_0 <=3D 74) or (77 <=3D LA99_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA99_0 <=3D FLOATING_POINT_LITERA= L) or LA99_0 =3D=3D 62 or LA99_0 =3D=3D 66 or (68 <=3D LA99_0 <=3D 69) or (= 72 <=3D LA99_0 <=3D 74) or (77 <=3D LA99_0 <=3D 79)): alt99 =3D 1 if alt99 =3D=3D 1: # C.g:0:0: expression - self.following.append(self.FOLLOW_expression_in_it= eration_statement2375) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2= 375) self.expression() self.following.pop() if self.failed: return =20 - - - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2378) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2378) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2380) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2380) self.statement() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -16595,9 +15655,9 @@ class CParser(Parser): =20 # $ANTLR end iteration_statement =20 - # $ANTLR start jump_statement # C.g:577:1: jump_statement : ( 'goto' IDENTIFIER ';' | 'continue' ';'= | 'break' ';' | 'return' ';' | 'return' expression ';' ); + def jump_statement(self, ): =20 jump_statement_StartIndex =3D self.input.index() @@ -16618,16 +15678,17 @@ class CParser(Parser): elif LA101 =3D=3D 117: LA101_4 =3D self.input.LA(2) =20 - if (LA101_4 =3D=3D 25) : + if (LA101_4 =3D=3D 25): alt101 =3D 4 - elif ((IDENTIFIER <=3D LA101_4 <=3D FLOATING_POINT_LIT= ERAL) or LA101_4 =3D=3D 62 or LA101_4 =3D=3D 66 or (68 <=3D LA101_4 <=3D 69= ) or (72 <=3D LA101_4 <=3D 74) or (77 <=3D LA101_4 <=3D 79)) : + elif ((IDENTIFIER <=3D LA101_4 <=3D FLOATING_POINT_LIT= ERAL) or LA101_4 =3D=3D 62 or LA101_4 =3D=3D 66 or (68 <=3D LA101_4 <=3D 69= ) or (72 <=3D LA101_4 <=3D 74) or (77 <=3D LA101_4 <=3D 79)): alt101 =3D 5 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("577:1: jump_stateme= nt : ( 'goto' IDENTIFIER ';' | 'continue' ';' | 'break' ';' | 'return' ';' = | 'return' expression ';' );", 101, 4, self.input) + nvae =3D NoViableAltException( + "577:1: jump_statement : ( 'goto' IDENTIFIER '= ;' | 'continue' ';' | 'break' ';' | 'return' ';' | 'return' expression ';' = );", 101, 4, self.input) =20 raise nvae =20 @@ -16636,69 +15697,76 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("577:1: jump_statement := ( 'goto' IDENTIFIER ';' | 'continue' ';' | 'break' ';' | 'return' ';' | 'r= eturn' expression ';' );", 101, 0, self.input) + nvae =3D NoViableAltException( + "577:1: jump_statement : ( 'goto' IDENTIFIER ';' |= 'continue' ';' | 'break' ';' | 'return' ';' | 'return' expression ';' );",= 101, 0, self.input) =20 raise nvae =20 if alt101 =3D=3D 1: # C.g:578:4: 'goto' IDENTIFIER ';' - self.match(self.input, 114, self.FOLLOW_114_in_jump_st= atement2393) + self.match(self.input, 114, + self.FOLLOW_114_in_jump_statement2393) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_jump_statement2395) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_jump_statement239= 5) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2397) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2397) if self.failed: return =20 - elif alt101 =3D=3D 2: # C.g:579:4: 'continue' ';' - self.match(self.input, 115, self.FOLLOW_115_in_jump_st= atement2402) + self.match(self.input, 115, + self.FOLLOW_115_in_jump_statement2402) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2404) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2404) if self.failed: return =20 - elif alt101 =3D=3D 3: # C.g:580:4: 'break' ';' - self.match(self.input, 116, self.FOLLOW_116_in_jump_st= atement2409) + self.match(self.input, 116, + self.FOLLOW_116_in_jump_statement2409) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2411) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2411) if self.failed: return =20 - elif alt101 =3D=3D 4: # C.g:581:4: 'return' ';' - self.match(self.input, 117, self.FOLLOW_117_in_jump_st= atement2416) + self.match(self.input, 117, + self.FOLLOW_117_in_jump_statement2416) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2418) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2418) if self.failed: return =20 - elif alt101 =3D=3D 5: # C.g:582:4: 'return' expression ';' - self.match(self.input, 117, self.FOLLOW_117_in_jump_st= atement2423) + self.match(self.input, 117, + self.FOLLOW_117_in_jump_statement2423) if self.failed: return - self.following.append(self.FOLLOW_expression_in_jump_s= tatement2425) + self.following.append( + self.FOLLOW_expression_in_jump_statement2425) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2427) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2427) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16716,18 +15784,17 @@ class CParser(Parser): def synpred2_fragment(self, ): # C.g:119:6: ( declaration_specifiers ) # C.g:119:6: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d2100) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred2100) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred2 =20 - - # $ANTLR start synpred4 + def synpred4_fragment(self, ): # C.g:119:4: ( ( declaration_specifiers )? declarator ( declaratio= n )* '{' ) # C.g:119:6: ( declaration_specifiers )? declarator ( declaration = )* '{' @@ -16741,134 +15808,132 @@ class CParser(Parser): if LA102 =3D=3D 62: LA102_21 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 29 or LA102 =3D=3D 30 or LA102 =3D=3D 31 or = LA102 =3D=3D 32 or LA102 =3D=3D 33: LA102_23 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 34: LA102_24 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 35: LA102_25 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 36: LA102_26 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 37: LA102_27 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 38: LA102_28 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 39: LA102_29 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 40: LA102_30 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 41: LA102_31 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 42: LA102_32 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 45 or LA102 =3D=3D 46: LA102_33 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 48: LA102_34 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D IDENTIFIER: LA102_35 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 58: LA102_36 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 66: alt102 =3D 1 elif LA102 =3D=3D 59: LA102_39 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 60: LA102_40 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 49 or LA102 =3D=3D 50 or LA102 =3D=3D 51 or = LA102 =3D=3D 52 or LA102 =3D=3D 53 or LA102 =3D=3D 54 or LA102 =3D=3D 55 or= LA102 =3D=3D 56 or LA102 =3D=3D 57 or LA102 =3D=3D 61: LA102_41 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 58: LA102_14 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 59: LA102_16 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 60: LA102_17 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 if alt102 =3D=3D 1: # C.g:0:0: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_sy= npred4100) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred4100) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - - self.following.append(self.FOLLOW_declarator_in_synpred4103) self.declarator() self.following.pop() if self.failed: return # C.g:119:41: ( declaration )* - while True: #loop103 + while True: # loop103 alt103 =3D 2 LA103_0 =3D self.input.LA(1) =20 - if (LA103_0 =3D=3D IDENTIFIER or LA103_0 =3D=3D 26 or (29 <=3D= LA103_0 <=3D 42) or (45 <=3D LA103_0 <=3D 46) or (48 <=3D LA103_0 <=3D 61)= ) : + if (LA103_0 =3D=3D IDENTIFIER or LA103_0 =3D=3D 26 or (29 <=3D= LA103_0 <=3D 42) or (45 <=3D LA103_0 <=3D 46) or (48 <=3D LA103_0 <=3D 61)= ): alt103 =3D 1 =20 - if alt103 =3D=3D 1: # C.g:0:0: declaration self.following.append(self.FOLLOW_declaration_in_synpred41= 05) @@ -16877,21 +15942,17 @@ class CParser(Parser): if self.failed: return =20 - else: - break #loop103 - + break # loop103 =20 self.match(self.input, 43, self.FOLLOW_43_in_synpred4108) if self.failed: return =20 - # $ANTLR end synpred4 =20 - - # $ANTLR start synpred5 + def synpred5_fragment(self, ): # C.g:120:4: ( declaration ) # C.g:120:4: declaration @@ -16901,42 +15962,38 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred5 =20 - - # $ANTLR start synpred7 + def synpred7_fragment(self, ): # C.g:146:6: ( declaration_specifiers ) # C.g:146:6: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d7157) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred7157) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred7 =20 - - # $ANTLR start synpred10 + def synpred10_fragment(self, ): # C.g:167:18: ( declaration_specifiers ) # C.g:167:18: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d10207) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred10207) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred10 =20 - - # $ANTLR start synpred14 + def synpred14_fragment(self, ): # C.g:184:7: ( type_specifier ) # C.g:184:7: type_specifier @@ -16946,12 +16003,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred14 =20 - - # $ANTLR start synpred15 + def synpred15_fragment(self, ): # C.g:185:13: ( type_qualifier ) # C.g:185:13: type_qualifier @@ -16961,12 +16016,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred15 =20 - - # $ANTLR start synpred33 + def synpred33_fragment(self, ): # C.g:225:16: ( type_qualifier ) # C.g:225:16: type_qualifier @@ -16976,58 +16029,53 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred33 =20 - - # $ANTLR start synpred34 + def synpred34_fragment(self, ): # C.g:225:4: ( IDENTIFIER ( type_qualifier )* declarator ) # C.g:225:5: IDENTIFIER ( type_qualifier )* declarator - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_synpr= ed34442) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred34442) if self.failed: return # C.g:225:16: ( type_qualifier )* - while True: #loop106 + while True: # loop106 alt106 =3D 2 LA106 =3D self.input.LA(1) if LA106 =3D=3D 58: LA106_2 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 59: LA106_3 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 60: LA106_4 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 49 or LA106 =3D=3D 50 or LA106 =3D=3D 51 or = LA106 =3D=3D 52 or LA106 =3D=3D 53 or LA106 =3D=3D 54 or LA106 =3D=3D 55 or= LA106 =3D=3D 56 or LA106 =3D=3D 57 or LA106 =3D=3D 61: alt106 =3D 1 =20 if alt106 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_in_synpre= d34444) + self.following.append( + self.FOLLOW_type_qualifier_in_synpred34444) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: - break #loop106 - + break # loop106 =20 self.following.append(self.FOLLOW_declarator_in_synpred34447) self.declarator() @@ -17035,12 +16083,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred34 =20 - - # $ANTLR start synpred39 + def synpred39_fragment(self, ): # C.g:253:6: ( type_qualifier ) # C.g:253:6: type_qualifier @@ -17050,12 +16096,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred39 =20 - - # $ANTLR start synpred40 + def synpred40_fragment(self, ): # C.g:253:23: ( type_specifier ) # C.g:253:23: type_specifier @@ -17065,12 +16109,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred40 =20 - - # $ANTLR start synpred66 + def synpred66_fragment(self, ): # C.g:297:4: ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? (= 'EFI_RUNTIMESERVICE' )? direct_declarator ) # C.g:297:4: ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( '= EFI_RUNTIMESERVICE' )? direct_declarator @@ -17078,7 +16120,7 @@ class CParser(Parser): alt111 =3D 2 LA111_0 =3D self.input.LA(1) =20 - if (LA111_0 =3D=3D 66) : + if (LA111_0 =3D=3D 66): alt111 =3D 1 if alt111 =3D=3D 1: # C.g:0:0: pointer @@ -17088,13 +16130,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:13: ( 'EFIAPI' )? alt112 =3D 2 LA112_0 =3D self.input.LA(1) =20 - if (LA112_0 =3D=3D 58) : + if (LA112_0 =3D=3D 58): alt112 =3D 1 if alt112 =3D=3D 1: # C.g:297:14: 'EFIAPI' @@ -17102,13 +16142,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:25: ( 'EFI_BOOTSERVICE' )? alt113 =3D 2 LA113_0 =3D self.input.LA(1) =20 - if (LA113_0 =3D=3D 59) : + if (LA113_0 =3D=3D 59): alt113 =3D 1 if alt113 =3D=3D 1: # C.g:297:26: 'EFI_BOOTSERVICE' @@ -17116,13 +16154,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:46: ( 'EFI_RUNTIMESERVICE' )? alt114 =3D 2 LA114_0 =3D self.input.LA(1) =20 - if (LA114_0 =3D=3D 60) : + if (LA114_0 =3D=3D 60): alt114 =3D 1 if alt114 =3D=3D 1: # C.g:297:47: 'EFI_RUNTIMESERVICE' @@ -17130,20 +16166,16 @@ class CParser(Parser): if self.failed: return =20 - - self.following.append(self.FOLLOW_direct_declarator_in_synpred6680= 2) self.direct_declarator() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred66 =20 - - # $ANTLR start synpred67 + def synpred67_fragment(self, ): # C.g:303:15: ( declarator_suffix ) # C.g:303:15: declarator_suffix @@ -17153,12 +16185,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred67 =20 - - # $ANTLR start synpred69 + def synpred69_fragment(self, ): # C.g:304:9: ( 'EFIAPI' ) # C.g:304:9: 'EFIAPI' @@ -17166,12 +16196,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred69 =20 - - # $ANTLR start synpred70 + def synpred70_fragment(self, ): # C.g:304:35: ( declarator_suffix ) # C.g:304:35: declarator_suffix @@ -17181,12 +16209,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred70 =20 - - # $ANTLR start synpred73 + def synpred73_fragment(self, ): # C.g:310:9: ( '(' parameter_type_list ')' ) # C.g:310:9: '(' parameter_type_list ')' @@ -17202,12 +16228,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred73 =20 - - # $ANTLR start synpred74 + def synpred74_fragment(self, ): # C.g:311:9: ( '(' identifier_list ')' ) # C.g:311:9: '(' identifier_list ')' @@ -17223,12 +16247,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred74 =20 - - # $ANTLR start synpred75 + def synpred75_fragment(self, ): # C.g:316:8: ( type_qualifier ) # C.g:316:8: type_qualifier @@ -17238,12 +16260,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred75 =20 - - # $ANTLR start synpred76 + def synpred76_fragment(self, ): # C.g:316:24: ( pointer ) # C.g:316:24: pointer @@ -17253,12 +16273,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred76 =20 - - # $ANTLR start synpred77 + def synpred77_fragment(self, ): # C.g:316:4: ( '*' ( type_qualifier )+ ( pointer )? ) # C.g:316:4: '*' ( type_qualifier )+ ( pointer )? @@ -17267,26 +16285,25 @@ class CParser(Parser): return # C.g:316:8: ( type_qualifier )+ cnt116 =3D 0 - while True: #loop116 + while True: # loop116 alt116 =3D 2 LA116_0 =3D self.input.LA(1) =20 - if ((49 <=3D LA116_0 <=3D 61)) : + if ((49 <=3D LA116_0 <=3D 61)): alt116 =3D 1 =20 - if alt116 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_in_synpre= d77921) + self.following.append( + self.FOLLOW_type_qualifier_in_synpred77921) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: if cnt116 >=3D 1: - break #loop116 + break # loop116 =20 if self.backtracking > 0: self.failed =3D True @@ -17297,12 +16314,11 @@ class CParser(Parser): =20 cnt116 +=3D 1 =20 - # C.g:316:24: ( pointer )? alt117 =3D 2 LA117_0 =3D self.input.LA(1) =20 - if (LA117_0 =3D=3D 66) : + if (LA117_0 =3D=3D 66): alt117 =3D 1 if alt117 =3D=3D 1: # C.g:0:0: pointer @@ -17312,15 +16328,10 @@ class CParser(Parser): if self.failed: return =20 - - - - # $ANTLR end synpred77 =20 - - # $ANTLR start synpred78 + def synpred78_fragment(self, ): # C.g:317:4: ( '*' pointer ) # C.g:317:4: '*' pointer @@ -17333,12 +16344,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred78 =20 - - # $ANTLR start synpred81 + def synpred81_fragment(self, ): # C.g:326:32: ( 'OPTIONAL' ) # C.g:326:32: 'OPTIONAL' @@ -17346,12 +16355,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred81 =20 - - # $ANTLR start synpred82 + def synpred82_fragment(self, ): # C.g:326:27: ( ',' ( 'OPTIONAL' )? parameter_declaration ) # C.g:326:27: ',' ( 'OPTIONAL' )? parameter_declaration @@ -17362,10 +16369,10 @@ class CParser(Parser): alt119 =3D 2 LA119_0 =3D self.input.LA(1) =20 - if (LA119_0 =3D=3D 53) : + if (LA119_0 =3D=3D 53): LA119_1 =3D self.input.LA(2) =20 - if (self.synpred81()) : + if (self.synpred81()): alt119 =3D 1 if alt119 =3D=3D 1: # C.g:326:32: 'OPTIONAL' @@ -17373,20 +16380,17 @@ class CParser(Parser): if self.failed: return =20 - - - self.following.append(self.FOLLOW_parameter_declaration_in_synpred= 82981) + self.following.append( + self.FOLLOW_parameter_declaration_in_synpred82981) self.parameter_declaration() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred82 =20 - - # $ANTLR start synpred83 + def synpred83_fragment(self, ): # C.g:330:28: ( declarator ) # C.g:330:28: declarator @@ -17396,12 +16400,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred83 =20 - - # $ANTLR start synpred84 + def synpred84_fragment(self, ): # C.g:330:39: ( abstract_declarator ) # C.g:330:39: abstract_declarator @@ -17411,33 +16413,31 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred84 =20 - - # $ANTLR start synpred86 + def synpred86_fragment(self, ): # C.g:330:4: ( declaration_specifiers ( declarator | abstract_decl= arator )* ( 'OPTIONAL' )? ) # C.g:330:4: declaration_specifiers ( declarator | abstract_declar= ator )* ( 'OPTIONAL' )? - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d86994) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred86994) self.declaration_specifiers() self.following.pop() if self.failed: return # C.g:330:27: ( declarator | abstract_declarator )* - while True: #loop120 + while True: # loop120 alt120 =3D 3 LA120 =3D self.input.LA(1) if LA120 =3D=3D 66: LA120_3 =3D self.input.LA(2) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D IDENTIFIER or LA120 =3D=3D 58 or LA120 =3D= =3D 59 or LA120 =3D=3D 60: alt120 =3D 1 elif LA120 =3D=3D 62: @@ -17447,58 +16447,51 @@ class CParser(Parser): elif LA120 =3D=3D 58: LA120_21 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 66: LA120_22 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 59: LA120_23 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 60: LA120_24 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D IDENTIFIER: LA120_25 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 62: LA120_26 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - - elif LA120 =3D=3D 64: alt120 =3D 2 =20 @@ -17510,25 +16503,23 @@ class CParser(Parser): if self.failed: return =20 - elif alt120 =3D=3D 2: # C.g:330:39: abstract_declarator - self.following.append(self.FOLLOW_abstract_declarator_in_s= ynpred86999) + self.following.append( + self.FOLLOW_abstract_declarator_in_synpred86999) self.abstract_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop120 - + break # loop120 =20 # C.g:330:61: ( 'OPTIONAL' )? alt121 =3D 2 LA121_0 =3D self.input.LA(1) =20 - if (LA121_0 =3D=3D 53) : + if (LA121_0 =3D=3D 53): alt121 =3D 1 if alt121 =3D=3D 1: # C.g:330:62: 'OPTIONAL' @@ -17536,19 +16527,15 @@ class CParser(Parser): if self.failed: return =20 - - - - # $ANTLR end synpred86 =20 - - # $ANTLR start synpred90 + def synpred90_fragment(self, ): # C.g:341:4: ( specifier_qualifier_list ( abstract_declarator )? ) # C.g:341:4: specifier_qualifier_list ( abstract_declarator )? - self.following.append(self.FOLLOW_specifier_qualifier_list_in_synp= red901046) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_synpred901046) self.specifier_qualifier_list() self.following.pop() if self.failed: @@ -17557,40 +16544,35 @@ class CParser(Parser): alt122 =3D 2 LA122_0 =3D self.input.LA(1) =20 - if (LA122_0 =3D=3D 62 or LA122_0 =3D=3D 64 or LA122_0 =3D=3D 66) : + if (LA122_0 =3D=3D 62 or LA122_0 =3D=3D 64 or LA122_0 =3D=3D 66): alt122 =3D 1 if alt122 =3D=3D 1: # C.g:0:0: abstract_declarator - self.following.append(self.FOLLOW_abstract_declarator_in_synpr= ed901048) + self.following.append( + self.FOLLOW_abstract_declarator_in_synpred901048) self.abstract_declarator() self.following.pop() if self.failed: return =20 - - - - # $ANTLR end synpred90 =20 - - # $ANTLR start synpred91 + def synpred91_fragment(self, ): # C.g:346:12: ( direct_abstract_declarator ) # C.g:346:12: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_declarator_in_sy= npred911067) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_synpred911067) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred91 =20 - - # $ANTLR start synpred93 + def synpred93_fragment(self, ): # C.g:351:6: ( '(' abstract_declarator ')' ) # C.g:351:6: '(' abstract_declarator ')' @@ -17606,27 +16588,24 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred93 =20 - - # $ANTLR start synpred94 + def synpred94_fragment(self, ): # C.g:351:65: ( abstract_declarator_suffix ) # C.g:351:65: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declarator_suffix_in_sy= npred941098) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_synpred941098) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred94 =20 - - # $ANTLR start synpred109 + def synpred109_fragment(self, ): # C.g:386:4: ( '(' type_name ')' cast_expression ) # C.g:386:4: '(' type_name ')' cast_expression @@ -17647,12 +16626,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred109 =20 - - # $ANTLR start synpred114 + def synpred114_fragment(self, ): # C.g:395:4: ( 'sizeof' unary_expression ) # C.g:395:4: 'sizeof' unary_expression @@ -17665,19 +16642,18 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred114 =20 - - # $ANTLR start synpred117 + def synpred117_fragment(self, ): # C.g:409:13: ( '(' argument_expression_list ')' ) # C.g:409:13: '(' argument_expression_list ')' self.match(self.input, 62, self.FOLLOW_62_in_synpred1171420) if self.failed: return - self.following.append(self.FOLLOW_argument_expression_list_in_synp= red1171424) + self.following.append( + self.FOLLOW_argument_expression_list_in_synpred1171424) self.argument_expression_list() self.following.pop() if self.failed: @@ -17686,19 +16662,18 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred117 =20 - - # $ANTLR start synpred118 + def synpred118_fragment(self, ): # C.g:410:13: ( '(' macro_parameter_list ')' ) # C.g:410:13: '(' macro_parameter_list ')' self.match(self.input, 62, self.FOLLOW_62_in_synpred1181444) if self.failed: return - self.following.append(self.FOLLOW_macro_parameter_list_in_synpred1= 181446) + self.following.append( + self.FOLLOW_macro_parameter_list_in_synpred1181446) self.macro_parameter_list() self.following.pop() if self.failed: @@ -17707,84 +16682,77 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred118 =20 - - # $ANTLR start synpred120 + def synpred120_fragment(self, ): # C.g:412:13: ( '*' IDENTIFIER ) # C.g:412:13: '*' IDENTIFIER self.match(self.input, 66, self.FOLLOW_66_in_synpred1201482) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_synpr= ed1201486) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred1201486) if self.failed: return =20 - # $ANTLR end synpred120 =20 - - # $ANTLR start synpred137 + def synpred137_fragment(self, ): # C.g:443:20: ( STRING_LITERAL ) # C.g:443:20: STRING_LITERAL - self.match(self.input, STRING_LITERAL, self.FOLLOW_STRING_LITERAL_= in_synpred1371683) + self.match(self.input, STRING_LITERAL, + self.FOLLOW_STRING_LITERAL_in_synpred1371683) if self.failed: return =20 - # $ANTLR end synpred137 =20 - - # $ANTLR start synpred138 + def synpred138_fragment(self, ): # C.g:443:8: ( ( IDENTIFIER )* ( STRING_LITERAL )+ ) # C.g:443:8: ( IDENTIFIER )* ( STRING_LITERAL )+ # C.g:443:8: ( IDENTIFIER )* - while True: #loop125 + while True: # loop125 alt125 =3D 2 LA125_0 =3D self.input.LA(1) =20 - if (LA125_0 =3D=3D IDENTIFIER) : + if (LA125_0 =3D=3D IDENTIFIER): alt125 =3D 1 =20 - if alt125 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_synpred1381680) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred1381680) if self.failed: return =20 - else: - break #loop125 - + break # loop125 =20 # C.g:443:20: ( STRING_LITERAL )+ cnt126 =3D 0 - while True: #loop126 + while True: # loop126 alt126 =3D 2 LA126_0 =3D self.input.LA(1) =20 - if (LA126_0 =3D=3D STRING_LITERAL) : + if (LA126_0 =3D=3D STRING_LITERAL): alt126 =3D 1 =20 - if alt126 =3D=3D 1: # C.g:0:0: STRING_LITERAL - self.match(self.input, STRING_LITERAL, self.FOLLOW_STRING_= LITERAL_in_synpred1381683) + self.match(self.input, STRING_LITERAL, + self.FOLLOW_STRING_LITERAL_in_synpred1381683) if self.failed: return =20 - else: if cnt126 >=3D 1: - break #loop126 + break # loop126 =20 if self.backtracking > 0: self.failed =3D True @@ -17795,14 +16763,10 @@ class CParser(Parser): =20 cnt126 +=3D 1 =20 - - - # $ANTLR end synpred138 =20 - - # $ANTLR start synpred142 + def synpred142_fragment(self, ): # C.g:458:4: ( lvalue assignment_operator assignment_expression ) # C.g:458:4: lvalue assignment_operator assignment_expression @@ -17811,38 +16775,37 @@ class CParser(Parser): self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_operator_in_synpred14= 21746) + self.following.append( + self.FOLLOW_assignment_operator_in_synpred1421746) self.assignment_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_expression_in_synpred= 1421748) + self.following.append( + self.FOLLOW_assignment_expression_in_synpred1421748) self.assignment_expression() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred142 =20 - - # $ANTLR start synpred169 + def synpred169_fragment(self, ): # C.g:520:4: ( expression_statement ) # C.g:520:4: expression_statement - self.following.append(self.FOLLOW_expression_statement_in_synpred1= 692035) + self.following.append( + self.FOLLOW_expression_statement_in_synpred1692035) self.expression_statement() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred169 =20 - - # $ANTLR start synpred173 + def synpred173_fragment(self, ): # C.g:524:4: ( macro_statement ) # C.g:524:4: macro_statement @@ -17852,12 +16815,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred173 =20 - - # $ANTLR start synpred174 + def synpred174_fragment(self, ): # C.g:525:4: ( asm2_statement ) # C.g:525:4: asm2_statement @@ -17867,12 +16828,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred174 =20 - - # $ANTLR start synpred181 + def synpred181_fragment(self, ): # C.g:544:19: ( declaration ) # C.g:544:19: declaration @@ -17882,12 +16841,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred181 =20 - - # $ANTLR start synpred182 + def synpred182_fragment(self, ): # C.g:544:33: ( statement_list ) # C.g:544:33: statement_list @@ -17897,12 +16854,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred182 =20 - - # $ANTLR start synpred186 + def synpred186_fragment(self, ): # C.g:554:8: ( declaration ) # C.g:554:8: declaration @@ -17912,12 +16867,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred186 =20 - - # $ANTLR start synpred188 + def synpred188_fragment(self, ): # C.g:558:4: ( statement ) # C.g:558:4: statement @@ -17927,11 +16880,8 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred188 =20 - - def synpred69(self): self.backtracking +=3D 1 start =3D self.input.mark() @@ -18382,35 +17332,42 @@ class CParser(Parser): self.failed =3D False return success =20 - - - - - FOLLOW_external_declaration_in_translation_unit74 =3D frozenset([1, 4,= 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_external_declaration_in_translation_unit74 =3D frozenset( + [1, 4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) FOLLOW_function_definition_in_external_declaration113 =3D frozenset([1= ]) FOLLOW_declaration_in_external_declaration118 =3D frozenset([1]) FOLLOW_macro_statement_in_external_declaration123 =3D frozenset([1, 25= ]) FOLLOW_25_in_external_declaration126 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_function_definition157 =3D frozenset(= [4, 58, 59, 60, 62, 66]) - FOLLOW_declarator_in_function_definition160 =3D frozenset([4, 26, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50,= 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_declaration_in_function_definition166 =3D frozenset([4, 26, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50= , 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_specifiers_in_function_definition157 =3D frozenset( + [4, 58, 59, 60, 62, 66]) + FOLLOW_declarator_in_function_definition160 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_in_function_definition166 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_compound_statement_in_function_definition171 =3D frozenset([1]) FOLLOW_compound_statement_in_function_definition180 =3D frozenset([1]) - FOLLOW_26_in_declaration203 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66]) - FOLLOW_declaration_specifiers_in_declaration207 =3D frozenset([4, 58, = 59, 60, 62, 66]) + FOLLOW_26_in_declaration203 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50= , 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_declaration_specifiers_in_declaration207 =3D frozenset( + [4, 58, 59, 60, 62, 66]) FOLLOW_init_declarator_list_in_declaration216 =3D frozenset([25]) FOLLOW_25_in_declaration220 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_declaration234 =3D frozenset([4, 25, = 58, 59, 60, 62, 66]) + FOLLOW_declaration_specifiers_in_declaration234 =3D frozenset( + [4, 25, 58, 59, 60, 62, 66]) FOLLOW_init_declarator_list_in_declaration238 =3D frozenset([25]) FOLLOW_25_in_declaration243 =3D frozenset([1]) - FOLLOW_storage_class_specifier_in_declaration_specifiers264 =3D frozen= set([1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, = 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_specifier_in_declaration_specifiers272 =3D frozenset([1, 4= , 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 5= 0, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_declaration_specifiers286 =3D frozenset([1, 4= , 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 5= 0, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_storage_class_specifier_in_declaration_specifiers264 =3D frozen= set( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_specifier_in_declaration_specifiers272 =3D frozenset( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_declaration_specifiers286 =3D frozenset( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_init_declarator_in_init_declarator_list308 =3D frozenset([1, 27= ]) FOLLOW_27_in_init_declarator_list311 =3D frozenset([4, 58, 59, 60, 62,= 66]) FOLLOW_init_declarator_in_init_declarator_list313 =3D frozenset([1, 27= ]) FOLLOW_declarator_in_init_declarator326 =3D frozenset([1, 28]) - FOLLOW_28_in_init_declarator329 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 4= 3, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_28_in_init_declarator329 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_in_init_declarator331 =3D frozenset([1]) FOLLOW_set_in_storage_class_specifier0 =3D frozenset([1]) FOLLOW_34_in_type_specifier376 =3D frozenset([1]) @@ -18428,25 +17385,34 @@ class CParser(Parser): FOLLOW_IDENTIFIER_in_type_id467 =3D frozenset([1]) FOLLOW_struct_or_union_in_struct_or_union_specifier494 =3D frozenset([= 4, 43]) FOLLOW_IDENTIFIER_in_struct_or_union_specifier496 =3D frozenset([43]) - FOLLOW_43_in_struct_or_union_specifier499 =3D frozenset([4, 34, 35, 36= , 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 5= 8, 59, 60, 61]) - FOLLOW_struct_declaration_list_in_struct_or_union_specifier501 =3D fro= zenset([44]) + FOLLOW_43_in_struct_or_union_specifier499 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_struct_declaration_list_in_struct_or_union_specifier501 =3D fro= zenset([ + = 44]) FOLLOW_44_in_struct_or_union_specifier503 =3D frozenset([1]) FOLLOW_struct_or_union_in_struct_or_union_specifier508 =3D frozenset([= 4]) FOLLOW_IDENTIFIER_in_struct_or_union_specifier510 =3D frozenset([1]) FOLLOW_set_in_struct_or_union0 =3D frozenset([1]) - FOLLOW_struct_declaration_in_struct_declaration_list537 =3D frozenset(= [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, = 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_specifier_qualifier_list_in_struct_declaration549 =3D frozenset= ([4, 47, 58, 59, 60, 62, 66]) + FOLLOW_struct_declaration_in_struct_declaration_list537 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_specifier_qualifier_list_in_struct_declaration549 =3D frozenset( + [4, 47, 58, 59, 60, 62, 66]) FOLLOW_struct_declarator_list_in_struct_declaration551 =3D frozenset([= 25]) FOLLOW_25_in_struct_declaration553 =3D frozenset([1]) - FOLLOW_type_qualifier_in_specifier_qualifier_list566 =3D frozenset([1,= 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_specifier_in_specifier_qualifier_list570 =3D frozenset([1,= 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_specifier_qualifier_list566 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_specifier_in_specifier_qualifier_list570 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_struct_declarator_in_struct_declarator_list584 =3D frozenset([1= , 27]) - FOLLOW_27_in_struct_declarator_list587 =3D frozenset([4, 47, 58, 59, 6= 0, 62, 66]) + FOLLOW_27_in_struct_declarator_list587 =3D frozenset( + [4, 47, 58, 59, 60, 62, 66]) FOLLOW_struct_declarator_in_struct_declarator_list589 =3D frozenset([1= , 27]) FOLLOW_declarator_in_struct_declarator602 =3D frozenset([1, 47]) - FOLLOW_47_in_struct_declarator605 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_47_in_struct_declarator605 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_struct_declarator607 =3D frozenset([1]) - FOLLOW_47_in_struct_declarator614 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_47_in_struct_declarator614 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_struct_declarator616 =3D frozenset([1]) FOLLOW_48_in_enum_specifier634 =3D frozenset([43]) FOLLOW_43_in_enum_specifier636 =3D frozenset([4]) @@ -18465,7 +17431,8 @@ class CParser(Parser): FOLLOW_27_in_enumerator_list680 =3D frozenset([4]) FOLLOW_enumerator_in_enumerator_list682 =3D frozenset([1, 27]) FOLLOW_IDENTIFIER_in_enumerator695 =3D frozenset([1, 28]) - FOLLOW_28_in_enumerator698 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 66= , 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_28_in_enumerator698 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_enumerator700 =3D frozenset([1]) FOLLOW_set_in_type_qualifier0 =3D frozenset([1]) FOLLOW_pointer_in_declarator784 =3D frozenset([4, 58, 59, 60, 62]) @@ -18481,12 +17448,14 @@ class CParser(Parser): FOLLOW_declarator_in_direct_declarator834 =3D frozenset([63]) FOLLOW_63_in_direct_declarator836 =3D frozenset([62, 64]) FOLLOW_declarator_suffix_in_direct_declarator838 =3D frozenset([1, 62,= 64]) - FOLLOW_64_in_declarator_suffix852 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_64_in_declarator_suffix852 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_declarator_suffix854 =3D frozenset([65]) FOLLOW_65_in_declarator_suffix856 =3D frozenset([1]) FOLLOW_64_in_declarator_suffix866 =3D frozenset([65]) FOLLOW_65_in_declarator_suffix868 =3D frozenset([1]) - FOLLOW_62_in_declarator_suffix878 =3D frozenset([4, 29, 30, 31, 32, 33= , 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 5= 5, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_62_in_declarator_suffix878 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_type_list_in_declarator_suffix880 =3D frozenset([63]) FOLLOW_63_in_declarator_suffix882 =3D frozenset([1]) FOLLOW_62_in_declarator_suffix892 =3D frozenset([4]) @@ -18494,8 +17463,10 @@ class CParser(Parser): FOLLOW_63_in_declarator_suffix896 =3D frozenset([1]) FOLLOW_62_in_declarator_suffix906 =3D frozenset([63]) FOLLOW_63_in_declarator_suffix908 =3D frozenset([1]) - FOLLOW_66_in_pointer919 =3D frozenset([49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_pointer921 =3D frozenset([1, 49, 50, 51, 52, = 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_66_in_pointer919 =3D frozenset( + [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_pointer921 =3D frozenset( + [1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_pointer_in_pointer924 =3D frozenset([1]) FOLLOW_66_in_pointer930 =3D frozenset([66]) FOLLOW_pointer_in_pointer932 =3D frozenset([1]) @@ -18505,109 +17476,165 @@ class CParser(Parser): FOLLOW_53_in_parameter_type_list954 =3D frozenset([67]) FOLLOW_67_in_parameter_type_list958 =3D frozenset([1]) FOLLOW_parameter_declaration_in_parameter_list971 =3D frozenset([1, 27= ]) - FOLLOW_27_in_parameter_list974 =3D frozenset([4, 29, 30, 31, 32, 33, 3= 4, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, = 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_53_in_parameter_list977 =3D frozenset([4, 29, 30, 31, 32, 33, 3= 4, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, = 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_27_in_parameter_list974 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_53_in_parameter_list977 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_declaration_in_parameter_list981 =3D frozenset([1, 27= ]) - FOLLOW_declaration_specifiers_in_parameter_declaration994 =3D frozense= t([1, 4, 53, 58, 59, 60, 62, 64, 66]) - FOLLOW_declarator_in_parameter_declaration997 =3D frozenset([1, 4, 53,= 58, 59, 60, 62, 64, 66]) - FOLLOW_abstract_declarator_in_parameter_declaration999 =3D frozenset([= 1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declaration_specifiers_in_parameter_declaration994 =3D frozense= t( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declarator_in_parameter_declaration997 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_abstract_declarator_in_parameter_declaration999 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) FOLLOW_53_in_parameter_declaration1004 =3D frozenset([1]) FOLLOW_pointer_in_parameter_declaration1013 =3D frozenset([4, 66]) FOLLOW_IDENTIFIER_in_parameter_declaration1016 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_identifier_list1027 =3D frozenset([1, 27]) FOLLOW_27_in_identifier_list1031 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_identifier_list1033 =3D frozenset([1, 27]) - FOLLOW_specifier_qualifier_list_in_type_name1046 =3D frozenset([1, 62,= 64, 66]) + FOLLOW_specifier_qualifier_list_in_type_name1046 =3D frozenset([ + 1, 62, 64= , 66]) FOLLOW_abstract_declarator_in_type_name1048 =3D frozenset([1]) FOLLOW_type_id_in_type_name1054 =3D frozenset([1]) FOLLOW_pointer_in_abstract_declarator1065 =3D frozenset([1, 62, 64]) - FOLLOW_direct_abstract_declarator_in_abstract_declarator1067 =3D froze= nset([1]) - FOLLOW_direct_abstract_declarator_in_abstract_declarator1073 =3D froze= nset([1]) + FOLLOW_direct_abstract_declarator_in_abstract_declarator1067 =3D froze= nset([ + = 1]) + FOLLOW_direct_abstract_declarator_in_abstract_declarator1073 =3D froze= nset([ + = 1]) FOLLOW_62_in_direct_abstract_declarator1086 =3D frozenset([62, 64, 66]) - FOLLOW_abstract_declarator_in_direct_abstract_declarator1088 =3D froze= nset([63]) + FOLLOW_abstract_declarator_in_direct_abstract_declarator1088 =3D froze= nset([ + = 63]) FOLLOW_63_in_direct_abstract_declarator1090 =3D frozenset([1, 62, 64]) - FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1094 = =3D frozenset([1, 62, 64]) - FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1098 = =3D frozenset([1, 62, 64]) + FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1094 = =3D frozenset([ + = 1, 62, 64]) + FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1098 = =3D frozenset([ + = 1, 62, 64]) FOLLOW_64_in_abstract_declarator_suffix1110 =3D frozenset([65]) FOLLOW_65_in_abstract_declarator_suffix1112 =3D frozenset([1]) - FOLLOW_64_in_abstract_declarator_suffix1117 =3D frozenset([4, 5, 6, 7,= 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_constant_expression_in_abstract_declarator_suffix1119 =3D froze= nset([65]) + FOLLOW_64_in_abstract_declarator_suffix1117 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_constant_expression_in_abstract_declarator_suffix1119 =3D froze= nset([ + = 65]) FOLLOW_65_in_abstract_declarator_suffix1121 =3D frozenset([1]) FOLLOW_62_in_abstract_declarator_suffix1126 =3D frozenset([63]) FOLLOW_63_in_abstract_declarator_suffix1128 =3D frozenset([1]) - FOLLOW_62_in_abstract_declarator_suffix1133 =3D frozenset([4, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52,= 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_parameter_type_list_in_abstract_declarator_suffix1135 =3D froze= nset([63]) + FOLLOW_62_in_abstract_declarator_suffix1133 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_parameter_type_list_in_abstract_declarator_suffix1135 =3D froze= nset([ + = 63]) FOLLOW_63_in_abstract_declarator_suffix1137 =3D frozenset([1]) FOLLOW_assignment_expression_in_initializer1150 =3D frozenset([1]) - FOLLOW_43_in_initializer1155 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 43, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_43_in_initializer1155 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_list_in_initializer1157 =3D frozenset([27, 44]) FOLLOW_27_in_initializer1159 =3D frozenset([44]) FOLLOW_44_in_initializer1162 =3D frozenset([1]) FOLLOW_initializer_in_initializer_list1173 =3D frozenset([1, 27]) - FOLLOW_27_in_initializer_list1176 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_27_in_initializer_list1176 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_in_initializer_list1178 =3D frozenset([1, 27]) - FOLLOW_assignment_expression_in_argument_expression_list1196 =3D froze= nset([1, 27, 53]) + FOLLOW_assignment_expression_in_argument_expression_list1196 =3D froze= nset([ + = 1, 27, 53]) FOLLOW_53_in_argument_expression_list1199 =3D frozenset([1, 27]) - FOLLOW_27_in_argument_expression_list1204 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_assignment_expression_in_argument_expression_list1206 =3D froze= nset([1, 27, 53]) + FOLLOW_27_in_argument_expression_list1204 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_assignment_expression_in_argument_expression_list1206 =3D froze= nset([ + = 1, 27, 53]) FOLLOW_53_in_argument_expression_list1209 =3D frozenset([1, 27]) - FOLLOW_multiplicative_expression_in_additive_expression1225 =3D frozen= set([1, 68, 69]) - FOLLOW_68_in_additive_expression1229 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_multiplicative_expression_in_additive_expression1231 =3D frozen= set([1, 68, 69]) - FOLLOW_69_in_additive_expression1235 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_multiplicative_expression_in_additive_expression1237 =3D frozen= set([1, 68, 69]) - FOLLOW_cast_expression_in_multiplicative_expression1251 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_66_in_multiplicative_expression1255 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1257 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_70_in_multiplicative_expression1261 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1263 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_71_in_multiplicative_expression1267 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1269 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_62_in_cast_expression1282 =3D frozenset([4, 34, 35, 36, 37, 38,= 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60= , 61]) + FOLLOW_multiplicative_expression_in_additive_expression1225 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_68_in_additive_expression1229 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_multiplicative_expression_in_additive_expression1231 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_69_in_additive_expression1235 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_multiplicative_expression_in_additive_expression1237 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_cast_expression_in_multiplicative_expression1251 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_66_in_multiplicative_expression1255 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1257 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_70_in_multiplicative_expression1261 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1263 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_71_in_multiplicative_expression1267 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1269 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_62_in_cast_expression1282 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_cast_expression1284 =3D frozenset([63]) - FOLLOW_63_in_cast_expression1286 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_cast_expression1286 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_cast_expression1288 =3D frozenset([1]) FOLLOW_unary_expression_in_cast_expression1293 =3D frozenset([1]) FOLLOW_postfix_expression_in_unary_expression1304 =3D frozenset([1]) - FOLLOW_72_in_unary_expression1309 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_72_in_unary_expression1309 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1311 =3D frozenset([1]) - FOLLOW_73_in_unary_expression1316 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_73_in_unary_expression1316 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1318 =3D frozenset([1]) - FOLLOW_unary_operator_in_unary_expression1323 =3D frozenset([4, 5, 6, = 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_unary_operator_in_unary_expression1323 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_unary_expression1325 =3D frozenset([1]) - FOLLOW_74_in_unary_expression1330 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_74_in_unary_expression1330 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1332 =3D frozenset([1]) FOLLOW_74_in_unary_expression1337 =3D frozenset([62]) - FOLLOW_62_in_unary_expression1339 =3D frozenset([4, 34, 35, 36, 37, 38= , 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6= 0, 61]) + FOLLOW_62_in_unary_expression1339 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_unary_expression1341 =3D frozenset([63]) FOLLOW_63_in_unary_expression1343 =3D frozenset([1]) - FOLLOW_primary_expression_in_postfix_expression1367 =3D frozenset([1, = 62, 64, 66, 72, 73, 75, 76]) - FOLLOW_64_in_postfix_expression1383 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_primary_expression_in_postfix_expression1367 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_64_in_postfix_expression1383 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_postfix_expression1385 =3D frozenset([65]) - FOLLOW_65_in_postfix_expression1387 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) + FOLLOW_65_in_postfix_expression1387 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_62_in_postfix_expression1401 =3D frozenset([63]) - FOLLOW_63_in_postfix_expression1405 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_62_in_postfix_expression1420 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_postfix_expression1405 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_62_in_postfix_expression1420 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_argument_expression_list_in_postfix_expression1424 =3D frozense= t([63]) - FOLLOW_63_in_postfix_expression1428 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_62_in_postfix_expression1444 =3D frozenset([4, 29, 30, 31, 32, = 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_63_in_postfix_expression1428 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_62_in_postfix_expression1444 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_macro_parameter_list_in_postfix_expression1446 =3D frozenset([6= 3]) - FOLLOW_63_in_postfix_expression1448 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) + FOLLOW_63_in_postfix_expression1448 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_75_in_postfix_expression1462 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1466 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) + FOLLOW_IDENTIFIER_in_postfix_expression1466 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_66_in_postfix_expression1482 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1486 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) + FOLLOW_IDENTIFIER_in_postfix_expression1486 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_76_in_postfix_expression1502 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1506 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) - FOLLOW_72_in_postfix_expression1522 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_73_in_postfix_expression1536 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_parameter_declaration_in_macro_parameter_list1559 =3D frozenset= ([1, 27]) - FOLLOW_27_in_macro_parameter_list1562 =3D frozenset([4, 29, 30, 31, 32= , 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 5= 4, 55, 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_parameter_declaration_in_macro_parameter_list1564 =3D frozenset= ([1, 27]) + FOLLOW_IDENTIFIER_in_postfix_expression1506 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_72_in_postfix_expression1522 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_73_in_postfix_expression1536 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_parameter_declaration_in_macro_parameter_list1559 =3D frozenset= ([ + 1= , 27]) + FOLLOW_27_in_macro_parameter_list1562 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_parameter_declaration_in_macro_parameter_list1564 =3D frozenset= ([ + 1= , 27]) FOLLOW_set_in_unary_operator0 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_primary_expression1613 =3D frozenset([1]) FOLLOW_constant_in_primary_expression1618 =3D frozenset([1]) - FOLLOW_62_in_primary_expression1623 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_primary_expression1623 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_primary_expression1625 =3D frozenset([63]) FOLLOW_63_in_primary_expression1627 =3D frozenset([1]) FOLLOW_HEX_LITERAL_in_constant1643 =3D frozenset([1]) @@ -18619,44 +17646,71 @@ class CParser(Parser): FOLLOW_IDENTIFIER_in_constant1688 =3D frozenset([1, 4]) FOLLOW_FLOATING_POINT_LITERAL_in_constant1699 =3D frozenset([1]) FOLLOW_assignment_expression_in_expression1715 =3D frozenset([1, 27]) - FOLLOW_27_in_expression1718 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_27_in_expression1718 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_expression1720 =3D frozenset([1, 27]) FOLLOW_conditional_expression_in_constant_expression1733 =3D frozenset= ([1]) - FOLLOW_lvalue_in_assignment_expression1744 =3D frozenset([28, 80, 81, = 82, 83, 84, 85, 86, 87, 88, 89]) - FOLLOW_assignment_operator_in_assignment_expression1746 =3D frozenset(= [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_lvalue_in_assignment_expression1744 =3D frozenset( + [28, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]) + FOLLOW_assignment_operator_in_assignment_expression1746 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_assignment_expression1748 =3D frozense= t([1]) FOLLOW_conditional_expression_in_assignment_expression1753 =3D frozens= et([1]) FOLLOW_unary_expression_in_lvalue1765 =3D frozenset([1]) FOLLOW_set_in_assignment_operator0 =3D frozenset([1]) - FOLLOW_logical_or_expression_in_conditional_expression1839 =3D frozens= et([1, 90]) - FOLLOW_90_in_conditional_expression1842 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_logical_or_expression_in_conditional_expression1839 =3D frozens= et([ + = 1, 90]) + FOLLOW_90_in_conditional_expression1842 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_conditional_expression1844 =3D frozenset([47]) - FOLLOW_47_in_conditional_expression1846 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_conditional_expression_in_conditional_expression1848 =3D frozen= set([1]) - FOLLOW_logical_and_expression_in_logical_or_expression1863 =3D frozens= et([1, 91]) - FOLLOW_91_in_logical_or_expression1866 =3D frozenset([4, 5, 6, 7, 8, 9= , 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_logical_and_expression_in_logical_or_expression1868 =3D frozens= et([1, 91]) - FOLLOW_inclusive_or_expression_in_logical_and_expression1881 =3D froze= nset([1, 92]) - FOLLOW_92_in_logical_and_expression1884 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_inclusive_or_expression_in_logical_and_expression1886 =3D froze= nset([1, 92]) - FOLLOW_exclusive_or_expression_in_inclusive_or_expression1899 =3D froz= enset([1, 93]) - FOLLOW_93_in_inclusive_or_expression1902 =3D frozenset([4, 5, 6, 7, 8,= 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_exclusive_or_expression_in_inclusive_or_expression1904 =3D froz= enset([1, 93]) + FOLLOW_47_in_conditional_expression1846 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_conditional_expression_in_conditional_expression1848 =3D frozen= set([ + = 1]) + FOLLOW_logical_and_expression_in_logical_or_expression1863 =3D frozens= et([ + = 1, 91]) + FOLLOW_91_in_logical_or_expression1866 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_logical_and_expression_in_logical_or_expression1868 =3D frozens= et([ + = 1, 91]) + FOLLOW_inclusive_or_expression_in_logical_and_expression1881 =3D froze= nset([ + = 1, 92]) + FOLLOW_92_in_logical_and_expression1884 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_inclusive_or_expression_in_logical_and_expression1886 =3D froze= nset([ + = 1, 92]) + FOLLOW_exclusive_or_expression_in_inclusive_or_expression1899 =3D froz= enset([ + = 1, 93]) + FOLLOW_93_in_inclusive_or_expression1902 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_exclusive_or_expression_in_inclusive_or_expression1904 =3D froz= enset([ + = 1, 93]) FOLLOW_and_expression_in_exclusive_or_expression1917 =3D frozenset([1,= 94]) - FOLLOW_94_in_exclusive_or_expression1920 =3D frozenset([4, 5, 6, 7, 8,= 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_94_in_exclusive_or_expression1920 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_and_expression_in_exclusive_or_expression1922 =3D frozenset([1,= 94]) FOLLOW_equality_expression_in_and_expression1935 =3D frozenset([1, 77]) - FOLLOW_77_in_and_expression1938 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 6= 2, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_77_in_and_expression1938 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_equality_expression_in_and_expression1940 =3D frozenset([1, 77]) - FOLLOW_relational_expression_in_equality_expression1952 =3D frozenset(= [1, 95, 96]) - FOLLOW_set_in_equality_expression1955 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_relational_expression_in_equality_expression1961 =3D frozenset(= [1, 95, 96]) - FOLLOW_shift_expression_in_relational_expression1975 =3D frozenset([1,= 97, 98, 99, 100]) - FOLLOW_set_in_relational_expression1978 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_shift_expression_in_relational_expression1988 =3D frozenset([1,= 97, 98, 99, 100]) - FOLLOW_additive_expression_in_shift_expression2001 =3D frozenset([1, 1= 01, 102]) - FOLLOW_set_in_shift_expression2004 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_additive_expression_in_shift_expression2010 =3D frozenset([1, 1= 01, 102]) + FOLLOW_relational_expression_in_equality_expression1952 =3D frozenset([ + 1,= 95, 96]) + FOLLOW_set_in_equality_expression1955 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_relational_expression_in_equality_expression1961 =3D frozenset([ + 1,= 95, 96]) + FOLLOW_shift_expression_in_relational_expression1975 =3D frozenset([ + 1, 97= , 98, 99, 100]) + FOLLOW_set_in_relational_expression1978 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_shift_expression_in_relational_expression1988 =3D frozenset([ + 1, 97= , 98, 99, 100]) + FOLLOW_additive_expression_in_shift_expression2001 =3D frozenset([ + 1, 101,= 102]) + FOLLOW_set_in_shift_expression2004 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_additive_expression_in_shift_expression2010 =3D frozenset([ + 1, 101,= 102]) FOLLOW_labeled_statement_in_statement2025 =3D frozenset([1]) FOLLOW_compound_statement_in_statement2030 =3D frozenset([1]) FOLLOW_expression_statement_in_statement2035 =3D frozenset([1]) @@ -18670,72 +17724,101 @@ class CParser(Parser): FOLLOW_declaration_in_statement2075 =3D frozenset([1]) FOLLOW_103_in_asm2_statement2086 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_asm2_statement2089 =3D frozenset([62]) - FOLLOW_62_in_asm2_statement2091 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,= 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68= , 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 8= 7, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,= 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm2_statement2094 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30,= 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 6= 8, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, = 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104= , 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_62_in_asm2_statement2091 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,= 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) + FOLLOW_set_in_asm2_statement2094 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30,= 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 6= 5, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, = 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 1= 02, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 1= 17]) FOLLOW_63_in_asm2_statement2101 =3D frozenset([25]) FOLLOW_25_in_asm2_statement2103 =3D frozenset([1]) FOLLOW_104_in_asm1_statement2115 =3D frozenset([43]) - FOLLOW_43_in_asm1_statement2117 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67= , 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 8= 6, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, = 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm1_statement2120 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48= , 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 6= 7, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, = 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,= 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_asm1_statement2117 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) + FOLLOW_set_in_asm1_statement2120 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48= , 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 6= 5, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, = 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 1= 02, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 1= 17]) FOLLOW_44_in_asm1_statement2127 =3D frozenset([1]) FOLLOW_105_in_asm_statement2138 =3D frozenset([43]) - FOLLOW_43_in_asm_statement2140 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 11= , 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3= 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, = 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,= 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86= , 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 1= 04, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm_statement2143 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67= , 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 8= 6, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, = 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_asm_statement2140 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 11= , 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3= 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, = 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65,= 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84= , 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102= , 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117= ]) + FOLLOW_set_in_asm_statement2143 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) FOLLOW_44_in_asm_statement2150 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_macro_statement2162 =3D frozenset([62]) - FOLLOW_62_in_macro_statement2164 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46,= 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) - FOLLOW_declaration_in_macro_statement2166 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, = 112, 113, 114, 115, 116, 117]) - FOLLOW_statement_list_in_macro_statement2170 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_macro_statement2164 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46,= 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 5= 8, 59, 60, 61, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 1= 06, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_declaration_in_macro_statement2166 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, + 50, 51, 52, 53, = 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79,= 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_statement_list_in_macro_statement2170 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_macro_statement2173 =3D frozenset([63]) FOLLOW_63_in_macro_statement2176 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_labeled_statement2188 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2190 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2190 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2192 =3D frozenset([1]) - FOLLOW_106_in_labeled_statement2197 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_106_in_labeled_statement2197 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_labeled_statement2199 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2201 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2201 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2203 =3D frozenset([1]) FOLLOW_107_in_labeled_statement2208 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2210 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2210 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2212 =3D frozenset([1]) - FOLLOW_43_in_compound_statement2223 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, = 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68,= 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 1= 13, 114, 115, 116, 117]) - FOLLOW_declaration_in_compound_statement2225 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62= , 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 11= 1, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_compound_statement2223 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, = 45, 46, 48, 49, + 50, 51, 52, 53, 54, 55= , 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104,= 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_declaration_in_compound_statement2225 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 43, 44, 45, 46, 48, + 49, 50, 51, 5= 2, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, = 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_list_in_compound_statement2228 =3D frozenset([44]) FOLLOW_44_in_compound_statement2231 =3D frozenset([1]) - FOLLOW_statement_in_statement_list2242 =3D frozenset([1, 4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 6= 8, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112,= 113, 114, 115, 116, 117]) + FOLLOW_statement_in_statement_list2242 =3D frozenset([1, 4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, + 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 1= 04, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_25_in_expression_statement2254 =3D frozenset([1]) FOLLOW_expression_in_expression_statement2259 =3D frozenset([25]) FOLLOW_25_in_expression_statement2261 =3D frozenset([1]) FOLLOW_108_in_selection_statement2272 =3D frozenset([62]) - FOLLOW_62_in_selection_statement2274 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_selection_statement2274 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_selection_statement2278 =3D frozenset([63]) - FOLLOW_63_in_selection_statement2280 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_selection_statement2280 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2284 =3D frozenset([1, 109]) - FOLLOW_109_in_selection_statement2299 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 6= 9, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113= , 114, 115, 116, 117]) + FOLLOW_109_in_selection_statement2299 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, + 50, 51, 52, 53, 54, = 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 10= 4, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2301 =3D frozenset([1]) FOLLOW_110_in_selection_statement2308 =3D frozenset([62]) - FOLLOW_62_in_selection_statement2310 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_selection_statement2310 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_selection_statement2312 =3D frozenset([63]) - FOLLOW_63_in_selection_statement2314 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_selection_statement2314 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2316 =3D frozenset([1]) FOLLOW_111_in_iteration_statement2327 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2329 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2329 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2333 =3D frozenset([63]) - FOLLOW_63_in_iteration_statement2335 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_iteration_statement2335 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2337 =3D frozenset([1]) - FOLLOW_112_in_iteration_statement2344 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 6= 9, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113= , 114, 115, 116, 117]) + FOLLOW_112_in_iteration_statement2344 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, + 50, 51, 52, 53, 54, = 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 10= 4, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2346 =3D frozenset([111]) FOLLOW_111_in_iteration_statement2348 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2350 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2350 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2354 =3D frozenset([63]) FOLLOW_63_in_iteration_statement2356 =3D frozenset([25]) FOLLOW_25_in_iteration_statement2358 =3D frozenset([1]) FOLLOW_113_in_iteration_statement2365 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2367 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_expression_statement_in_iteration_statement2369 =3D frozenset([= 4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_expression_statement_in_iteration_statement2373 =3D frozenset([= 4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2367 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_expression_statement_in_iteration_statement2369 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_expression_statement_in_iteration_statement2373 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2375 =3D frozenset([63]) - FOLLOW_63_in_iteration_statement2378 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_iteration_statement2378 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2380 =3D frozenset([1]) FOLLOW_114_in_jump_statement2393 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_jump_statement2395 =3D frozenset([25]) @@ -18746,13 +17829,17 @@ class CParser(Parser): FOLLOW_25_in_jump_statement2411 =3D frozenset([1]) FOLLOW_117_in_jump_statement2416 =3D frozenset([25]) FOLLOW_25_in_jump_statement2418 =3D frozenset([1]) - FOLLOW_117_in_jump_statement2423 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_117_in_jump_statement2423 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_jump_statement2425 =3D frozenset([25]) FOLLOW_25_in_jump_statement2427 =3D frozenset([1]) FOLLOW_declaration_specifiers_in_synpred2100 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_synpred4100 =3D frozenset([4, 58, 59,= 60, 62, 66]) - FOLLOW_declarator_in_synpred4103 =3D frozenset([4, 26, 29, 30, 31, 32,= 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50, 51, 52, 53= , 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_declaration_in_synpred4105 =3D frozenset([4, 26, 29, 30, 31, 32= , 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50, 51, 52, 5= 3, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_specifiers_in_synpred4100 =3D frozenset( + [4, 58, 59, 60, 62, 66]) + FOLLOW_declarator_in_synpred4103 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_in_synpred4105 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_43_in_synpred4108 =3D frozenset([1]) FOLLOW_declaration_in_synpred5118 =3D frozenset([1]) FOLLOW_declaration_specifiers_in_synpred7157 =3D frozenset([1]) @@ -18760,8 +17847,10 @@ class CParser(Parser): FOLLOW_type_specifier_in_synpred14272 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred15286 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred33444 =3D frozenset([1]) - FOLLOW_IDENTIFIER_in_synpred34442 =3D frozenset([4, 49, 50, 51, 52, 53= , 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) - FOLLOW_type_qualifier_in_synpred34444 =3D frozenset([4, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_IDENTIFIER_in_synpred34442 =3D frozenset( + [4, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_type_qualifier_in_synpred34444 =3D frozenset( + [4, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) FOLLOW_declarator_in_synpred34447 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred39566 =3D frozenset([1]) FOLLOW_type_specifier_in_synpred40570 =3D frozenset([1]) @@ -18773,7 +17862,8 @@ class CParser(Parser): FOLLOW_declarator_suffix_in_synpred67821 =3D frozenset([1]) FOLLOW_58_in_synpred69830 =3D frozenset([1]) FOLLOW_declarator_suffix_in_synpred70838 =3D frozenset([1]) - FOLLOW_62_in_synpred73878 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) + FOLLOW_62_in_synpred73878 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_type_list_in_synpred73880 =3D frozenset([63]) FOLLOW_63_in_synpred73882 =3D frozenset([1]) FOLLOW_62_in_synpred74892 =3D frozenset([4]) @@ -18781,38 +17871,51 @@ class CParser(Parser): FOLLOW_63_in_synpred74896 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred75921 =3D frozenset([1]) FOLLOW_pointer_in_synpred76924 =3D frozenset([1]) - FOLLOW_66_in_synpred77919 =3D frozenset([49, 50, 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_synpred77921 =3D frozenset([1, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_66_in_synpred77919 =3D frozenset( + [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_synpred77921 =3D frozenset( + [1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_pointer_in_synpred77924 =3D frozenset([1]) FOLLOW_66_in_synpred78930 =3D frozenset([66]) FOLLOW_pointer_in_synpred78932 =3D frozenset([1]) FOLLOW_53_in_synpred81977 =3D frozenset([1]) - FOLLOW_27_in_synpred82974 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) - FOLLOW_53_in_synpred82977 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) + FOLLOW_27_in_synpred82974 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_53_in_synpred82977 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_declaration_in_synpred82981 =3D frozenset([1]) FOLLOW_declarator_in_synpred83997 =3D frozenset([1]) FOLLOW_abstract_declarator_in_synpred84999 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_synpred86994 =3D frozenset([1, 4, 53,= 58, 59, 60, 62, 64, 66]) - FOLLOW_declarator_in_synpred86997 =3D frozenset([1, 4, 53, 58, 59, 60,= 62, 64, 66]) - FOLLOW_abstract_declarator_in_synpred86999 =3D frozenset([1, 4, 53, 58= , 59, 60, 62, 64, 66]) + FOLLOW_declaration_specifiers_in_synpred86994 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declarator_in_synpred86997 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_abstract_declarator_in_synpred86999 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) FOLLOW_53_in_synpred861004 =3D frozenset([1]) - FOLLOW_specifier_qualifier_list_in_synpred901046 =3D frozenset([1, 62,= 64, 66]) + FOLLOW_specifier_qualifier_list_in_synpred901046 =3D frozenset([ + 1, 62, 64= , 66]) FOLLOW_abstract_declarator_in_synpred901048 =3D frozenset([1]) FOLLOW_direct_abstract_declarator_in_synpred911067 =3D frozenset([1]) FOLLOW_62_in_synpred931086 =3D frozenset([62, 64, 66]) FOLLOW_abstract_declarator_in_synpred931088 =3D frozenset([63]) FOLLOW_63_in_synpred931090 =3D frozenset([1]) FOLLOW_abstract_declarator_suffix_in_synpred941098 =3D frozenset([1]) - FOLLOW_62_in_synpred1091282 =3D frozenset([4, 34, 35, 36, 37, 38, 39, = 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_62_in_synpred1091282 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_synpred1091284 =3D frozenset([63]) - FOLLOW_63_in_synpred1091286 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_synpred1091286 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_synpred1091288 =3D frozenset([1]) - FOLLOW_74_in_synpred1141330 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_74_in_synpred1141330 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_synpred1141332 =3D frozenset([1]) - FOLLOW_62_in_synpred1171420 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_synpred1171420 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_argument_expression_list_in_synpred1171424 =3D frozenset([63]) FOLLOW_63_in_synpred1171428 =3D frozenset([1]) - FOLLOW_62_in_synpred1181444 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 66]) + FOLLOW_62_in_synpred1181444 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, + 39, 40, 41, 42, 45, 46, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_macro_parameter_list_in_synpred1181446 =3D frozenset([63]) FOLLOW_63_in_synpred1181448 =3D frozenset([1]) FOLLOW_66_in_synpred1201482 =3D frozenset([4]) @@ -18820,8 +17923,10 @@ class CParser(Parser): FOLLOW_STRING_LITERAL_in_synpred1371683 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_synpred1381680 =3D frozenset([4, 9]) FOLLOW_STRING_LITERAL_in_synpred1381683 =3D frozenset([1, 9]) - FOLLOW_lvalue_in_synpred1421744 =3D frozenset([28, 80, 81, 82, 83, 84,= 85, 86, 87, 88, 89]) - FOLLOW_assignment_operator_in_synpred1421746 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_lvalue_in_synpred1421744 =3D frozenset( + [28, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]) + FOLLOW_assignment_operator_in_synpred1421746 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_synpred1421748 =3D frozenset([1]) FOLLOW_expression_statement_in_synpred1692035 =3D frozenset([1]) FOLLOW_macro_statement_in_synpred1732055 =3D frozenset([1]) @@ -18830,4 +17935,3 @@ class CParser(Parser): FOLLOW_statement_list_in_synpred1822170 =3D frozenset([1]) FOLLOW_declaration_in_synpred1862225 =3D frozenset([1]) FOLLOW_statement_in_synpred1882242 =3D frozenset([1]) - diff --git a/BaseTools/Source/Python/Ecc/CParser4/CLexer.py b/BaseTools/Sou= rce/Python/Ecc/CParser4/CLexer.py index a2cc5bf56e66..739152edf0f5 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CLexer.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CLexer.py @@ -5,7 +5,7 @@ from typing.io import TextIO import sys =20 =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -21,6 +21,7 @@ import sys import Ecc.CodeFragment as CodeFragment import Ecc.FileProfile as FileProfile =20 + def serializedATN(): with StringIO() as buf: buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2k") @@ -423,7 +424,7 @@ class CLexer(Lexer): =20 atn =3D ATNDeserializer().deserialize(serializedATN()) =20 - decisionsToDFA =3D [ DFA(ds, i) for i, ds in enumerate(atn.decisionToS= tate) ] + decisionsToDFA =3D [DFA(ds, i) for i, ds in enumerate(atn.decisionToSt= ate)] =20 T__0 =3D 1 T__1 =3D 2 @@ -531,96 +532,99 @@ class CLexer(Lexer): LINE_COMMENT =3D 104 LINE_COMMAND =3D 105 =20 - channelNames =3D [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] + channelNames =3D [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] =20 - modeNames =3D [ "DEFAULT_MODE" ] + modeNames =3D ["DEFAULT_MODE"] =20 - literalNames =3D [ "", - "'{'", "';'", "'typedef'", "','", "'=3D'", "'extern'", "'stati= c'", - "'auto'", "'register'", "'STATIC'", "'void'", "'char'", "'shor= t'", - "'int'", "'long'", "'float'", "'double'", "'signed'", "'unsign= ed'", - "'}'", "'struct'", "'union'", "':'", "'enum'", "'const'", "'vo= latile'", - "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'", "'VOL= ATILE'", - "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFIAPI'", "'EFI_BOOTSERVI= CE'", - "'EFI_RUNTIMESERVICE'", "'PACKED'", "'('", "')'", "'['", "']'", - "'*'", "'...'", "'+'", "'-'", "'/'", "'%'", "'++'", "'--'", - "'sizeof'", "'.'", "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/= =3D'", - "'%=3D'", "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", = "'^=3D'", "'|=3D'", - "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!=3D'", "'<= '", - "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__asm__'", "'_asm= '", - "'__asm'", "'case'", "'default'", "'if'", "'else'", "'switch'", - "'while'", "'do'", "'goto'", "'continue'", "'break'", "'return= '" ] + literalNames =3D ["", + "'{'", "';'", "'typedef'", "','", "'=3D'", "'extern'",= "'static'", + "'auto'", "'register'", "'STATIC'", "'void'", "'char'"= , "'short'", + "'int'", "'long'", "'float'", "'double'", "'signed'", = "'unsigned'", + "'}'", "'struct'", "'union'", "':'", "'enum'", "'const= '", "'volatile'", + "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'= ", "'VOLATILE'", + "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFIAPI'", "'EFI_B= OOTSERVICE'", + "'EFI_RUNTIMESERVICE'", "'PACKED'", "'('", "')'", "'['= ", "']'", + "'*'", "'...'", "'+'", "'-'", "'/'", "'%'", "'++'", "'= --'", + "'sizeof'", "'.'", "'->'", "'&'", "'~'", "'!'", "'*=3D= '", "'/=3D'", + "'%=3D'", "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'= &=3D'", "'^=3D'", "'|=3D'", + "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", "'<'", + "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__asm__'"= , "'_asm'", + "'__asm'", "'case'", "'default'", "'if'", "'else'", "'= switch'", + "'while'", "'do'", "'goto'", "'continue'", "'break'", = "'return'"] =20 - symbolicNames =3D [ "", - "IDENTIFIER", "CHARACTER_LITERAL", "STRING_LITERAL", "HEX_LITE= RAL", - "DECIMAL_LITERAL", "OCTAL_LITERAL", "FLOATING_POINT_LITERAL", - "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMENT", - "LINE_COMMAND" ] + symbolicNames =3D ["", + "IDENTIFIER", "CHARACTER_LITERAL", "STRING_LITERAL", = "HEX_LITERAL", + "DECIMAL_LITERAL", "OCTAL_LITERAL", "FLOATING_POINT_L= ITERAL", + "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COM= MENT", + "LINE_COMMAND"] =20 - ruleNames =3D [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", - "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__1= 3", - "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", - "T__20", "T__21", "T__22", "T__23", "T__24", "T__25", - "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", - "T__32", "T__33", "T__34", "T__35", "T__36", "T__37", - "T__38", "T__39", "T__40", "T__41", "T__42", "T__43", - "T__44", "T__45", "T__46", "T__47", "T__48", "T__49", - "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", - "T__56", "T__57", "T__58", "T__59", "T__60", "T__61", - "T__62", "T__63", "T__64", "T__65", "T__66", "T__67", - "T__68", "T__69", "T__70", "T__71", "T__72", "T__73", - "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", - "T__80", "T__81", "T__82", "T__83", "T__84", "T__85", - "T__86", "T__87", "T__88", "T__89", "T__90", "T__91", - "IDENTIFIER", "LETTER", "CHARACTER_LITERAL", "STRING_LIT= ERAL", - "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", "HexD= igit", - "IntegerTypeSuffix", "FLOATING_POINT_LITERAL", "Exponent= ", - "FloatTypeSuffix", "EscapeSequence", "OctalEscape", "Uni= codeEscape", - "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMEN= T", - "LINE_COMMAND" ] + ruleNames =3D ["T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13= ", + "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", + "T__20", "T__21", "T__22", "T__23", "T__24", "T__25", + "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", + "T__32", "T__33", "T__34", "T__35", "T__36", "T__37", + "T__38", "T__39", "T__40", "T__41", "T__42", "T__43", + "T__44", "T__45", "T__46", "T__47", "T__48", "T__49", + "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", + "T__56", "T__57", "T__58", "T__59", "T__60", "T__61", + "T__62", "T__63", "T__64", "T__65", "T__66", "T__67", + "T__68", "T__69", "T__70", "T__71", "T__72", "T__73", + "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", + "T__80", "T__81", "T__82", "T__83", "T__84", "T__85", + "T__86", "T__87", "T__88", "T__89", "T__90", "T__91", + "IDENTIFIER", "LETTER", "CHARACTER_LITERAL", "STRING_LITE= RAL", + "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", "HexDi= git", + "IntegerTypeSuffix", "FLOATING_POINT_LITERAL", "Exponent", + "FloatTypeSuffix", "EscapeSequence", "OctalEscape", "Unic= odeEscape", + "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMENT= ", + "LINE_COMMAND"] =20 grammarFileName =3D "C.g4" =20 # @param output=3D sys.stdout Type: TextIO - def __init__(self,input=3DNone,output=3D sys.stdout): + def __init__(self, input=3DNone, output=3Dsys.stdout): super().__init__(input, output) self.checkVersion("4.7.1") - self._interp =3D LexerATNSimulator(self, self.atn, self.decisionsT= oDFA, PredictionContextCache()) + self._interp =3D LexerATNSimulator( + self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions =3D None self._predicates =3D None =20 + def printTokenInfo(self, line, offset, tokenText): + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 - - def printTokenInfo(self,line,offset,tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) - - def StorePredicateExpression(self,StartLine,StartOffset,EndLine,EndOff= set,Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.PredicateExpressionList.append(PredExp) =20 - def StoreEnumerationDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, S= tartOffset), (EndLine, EndOffset)) + def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.EnumerationDefinitionList.append(EnumDef) =20 - def StoreStructUnionDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.StructUnionDefinitionList.append(SUDef) =20 - def StoreTypedefDefinition(self,StartLine,StartOffset,EndLine,EndOffse= t,FromText,ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLi= ne, StartOffset), (EndLine, EndOffset)) + def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) FileProfile.TypedefDefinitionList.append(Tdef) =20 - def StoreFunctionDefinition(self,StartLine,StartOffset,EndLine,EndOffs= et,ModifierText,DeclText,LeftBraceLine,LeftBraceOffset,DeclLine,DeclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBrace= Offset), (DeclLine, DeclOffset)) + def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) FileProfile.FunctionDefinitionList.append(FuncDef) =20 - def StoreVariableDeclaration(self,StartLine,StartOffset,EndLine,EndOff= set,ModifierText,DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclTex= t, (StartLine, StartOffset), (EndLine, EndOffset)) + def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) FileProfile.VariableDeclarationList.append(VarDecl) =20 - def StoreFunctionCalling(self,StartLine,StartOffset,EndLine,EndOffset,= FuncName,ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (St= artLine, StartOffset), (EndLine, EndOffset)) + def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) FileProfile.FunctionCallingList.append(FuncCall) - - - diff --git a/BaseTools/Source/Python/Ecc/CParser4/CListener.py b/BaseTools/= Source/Python/Ecc/CParser4/CListener.py index bb4351d9249a..866d5717d42b 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CListener.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CListener.py @@ -5,7 +5,7 @@ if __name__ is not None and "." in __name__: else: from CParser import CParser =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -27,783 +27,710 @@ class CListener(ParseTreeListener): =20 # Enter a parse tree produced by CParser#translation_unit. # @param ctx Type: CParser.Translation_unitContext - def enterTranslation_unit(self,ctx): + def enterTranslation_unit(self, ctx): pass =20 # Exit a parse tree produced by CParser#translation_unit. # @param ctx Type: CParser.Translation_unitContext - def exitTranslation_unit(self,ctx): + def exitTranslation_unit(self, ctx): pass =20 - # Enter a parse tree produced by CParser#external_declaration. # @param ctx Type: CParser.External_declarationContext - def enterExternal_declaration(self,ctx): + def enterExternal_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#external_declaration. # @param ctx Type: CParser.External_declarationContext - def exitExternal_declaration(self,ctx): + def exitExternal_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#function_definition. # @param ctx Type: CParser.Function_definitionContext - def enterFunction_definition(self,ctx): + def enterFunction_definition(self, ctx): pass =20 # Exit a parse tree produced by CParser#function_definition. # @param ctx Type: CParser.Function_definitionContext - def exitFunction_definition(self,ctx): + def exitFunction_definition(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declaration_specifiers. # @param ctx Type: CParser.Declaration_specifiersContext - def enterDeclaration_specifiers(self,ctx): + def enterDeclaration_specifiers(self, ctx): pass =20 # Exit a parse tree produced by CParser#declaration_specifiers. # @param ctx Type: CParser.Declaration_specifiersContext - def exitDeclaration_specifiers(self,ctx): + def exitDeclaration_specifiers(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declaration. # @param ctx Type: CParser.DeclarationContext - def enterDeclaration(self,ctx): + def enterDeclaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#declaration. # @param ctx Type: CParser.DeclarationContext - def exitDeclaration(self,ctx): + def exitDeclaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#init_declarator_list. # @param ctx Type: CParser.Init_declarator_listContext - def enterInit_declarator_list(self,ctx): + def enterInit_declarator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#init_declarator_list. # @param ctx Type: CParser.Init_declarator_listContext - def exitInit_declarator_list(self,ctx): + def exitInit_declarator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#init_declarator. # @param ctx Type: CParser.Init_declaratorContext - def enterInit_declarator(self,ctx): + def enterInit_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#init_declarator. # @param ctx Type: CParser.Init_declaratorContext - def exitInit_declarator(self,ctx): + def exitInit_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#storage_class_specifier. # @param ctx Type: CParser.Storage_class_specifierContext - def enterStorage_class_specifier(self,ctx): + def enterStorage_class_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#storage_class_specifier. # @param ctx Type: CParser.Storage_class_specifierContext - def exitStorage_class_specifier(self,ctx): + def exitStorage_class_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_specifier. # @param ctx Type: CParser.Type_specifierContext - def enterType_specifier(self,ctx): + def enterType_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_specifier. # @param ctx Type: CParser.Type_specifierContext - def exitType_specifier(self,ctx): + def exitType_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_id. # @param ctx Type: CParser.Type_idContext - def enterType_id(self,ctx): + def enterType_id(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_id. # @param ctx Type: CParser.Type_idContext - def exitType_id(self,ctx): + def exitType_id(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_or_union_specifier. # @param ctx Type: CParser.Struct_or_union_specifierContext - def enterStruct_or_union_specifier(self,ctx): + def enterStruct_or_union_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_or_union_specifier. # @param ctx Type: CParser.Struct_or_union_specifierContext - def exitStruct_or_union_specifier(self,ctx): + def exitStruct_or_union_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_or_union. # @param ctx Type: CParser.Struct_or_unionContext - def enterStruct_or_union(self,ctx): + def enterStruct_or_union(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_or_union. # @param ctx Type: CParser.Struct_or_unionContext - def exitStruct_or_union(self,ctx): + def exitStruct_or_union(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declaration_list. # @param ctx Type: CParser.Struct_declaration_listContext - def enterStruct_declaration_list(self,ctx): + def enterStruct_declaration_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declaration_list. # @param ctx Type: CParser.Struct_declaration_listContext - def exitStruct_declaration_list(self,ctx): + def exitStruct_declaration_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declaration. # @param ctx Type: CParser.Struct_declarationContext - def enterStruct_declaration(self,ctx): + def enterStruct_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declaration. # @param ctx Type: CParser.Struct_declarationContext - def exitStruct_declaration(self,ctx): + def exitStruct_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#specifier_qualifier_list. # @param ctx Type: CParser.Specifier_qualifier_listContext - def enterSpecifier_qualifier_list(self,ctx): + def enterSpecifier_qualifier_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#specifier_qualifier_list. # @param ctx Type: CParser.Specifier_qualifier_listContext - def exitSpecifier_qualifier_list(self,ctx): + def exitSpecifier_qualifier_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declarator_list. # @param ctx Type: CParser.Struct_declarator_listContext - def enterStruct_declarator_list(self,ctx): + def enterStruct_declarator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declarator_list. # @param ctx Type: CParser.Struct_declarator_listContext - def exitStruct_declarator_list(self,ctx): + def exitStruct_declarator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declarator. # @param ctx Type: CParser.Struct_declaratorContext - def enterStruct_declarator(self,ctx): + def enterStruct_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declarator. # @param ctx Type: CParser.Struct_declaratorContext - def exitStruct_declarator(self,ctx): + def exitStruct_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enum_specifier. # @param ctx Type: CParser.Enum_specifierContext - def enterEnum_specifier(self,ctx): + def enterEnum_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#enum_specifier. # @param ctx Type: CParser.Enum_specifierContext - def exitEnum_specifier(self,ctx): + def exitEnum_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enumerator_list. # @param ctx Type: CParser.Enumerator_listContext - def enterEnumerator_list(self,ctx): + def enterEnumerator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#enumerator_list. # @param ctx Type: CParser.Enumerator_listContext - def exitEnumerator_list(self,ctx): + def exitEnumerator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enumerator. # @param ctx Type: CParser.EnumeratorContext - def enterEnumerator(self,ctx): + def enterEnumerator(self, ctx): pass =20 # Exit a parse tree produced by CParser#enumerator. # @param ctx Type: CParser.EnumeratorContext - def exitEnumerator(self,ctx): + def exitEnumerator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_qualifier. # @param ctx Type: CParser.Type_qualifierContext - def enterType_qualifier(self,ctx): + def enterType_qualifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_qualifier. # @param ctx Type: CParser.Type_qualifierContext - def exitType_qualifier(self,ctx): + def exitType_qualifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declarator. # @param ctx Type: CParser.DeclaratorContext - def enterDeclarator(self,ctx): + def enterDeclarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#declarator. # @param ctx Type: CParser.DeclaratorContext - def exitDeclarator(self,ctx): + def exitDeclarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#direct_declarator. # @param ctx Type: CParser.Direct_declaratorContext - def enterDirect_declarator(self,ctx): + def enterDirect_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#direct_declarator. # @param ctx Type: CParser.Direct_declaratorContext - def exitDirect_declarator(self,ctx): + def exitDirect_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declarator_suffix. # @param ctx Type: CParser.Declarator_suffixContext - def enterDeclarator_suffix(self,ctx): + def enterDeclarator_suffix(self, ctx): pass =20 # Exit a parse tree produced by CParser#declarator_suffix. # @param ctx Type: CParser.Declarator_suffixContext - def exitDeclarator_suffix(self,ctx): + def exitDeclarator_suffix(self, ctx): pass =20 - # Enter a parse tree produced by CParser#pointer. # @param ctx Type: CParser.PointerContext - def enterPointer(self,ctx): + def enterPointer(self, ctx): pass =20 # Exit a parse tree produced by CParser#pointer. # @param ctx Type: CParser.PointerContext - def exitPointer(self,ctx): + def exitPointer(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_type_list. # @param ctx Type: CParser.Parameter_type_listContext - def enterParameter_type_list(self,ctx): + def enterParameter_type_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_type_list. # @param ctx Type: CParser.Parameter_type_listContext - def exitParameter_type_list(self,ctx): + def exitParameter_type_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_list. # @param ctx Type: CParser.Parameter_listContext - def enterParameter_list(self,ctx): + def enterParameter_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_list. # @param ctx Type: CParser.Parameter_listContext - def exitParameter_list(self,ctx): + def exitParameter_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_declaration. # @param ctx Type: CParser.Parameter_declarationContext - def enterParameter_declaration(self,ctx): + def enterParameter_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_declaration. # @param ctx Type: CParser.Parameter_declarationContext - def exitParameter_declaration(self,ctx): + def exitParameter_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#identifier_list. # @param ctx Type: CParser.Identifier_listContext - def enterIdentifier_list(self,ctx): + def enterIdentifier_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#identifier_list. # @param ctx Type: CParser.Identifier_listContext - def exitIdentifier_list(self,ctx): + def exitIdentifier_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_name. # @param ctx Type: CParser.Type_nameContext - def enterType_name(self,ctx): + def enterType_name(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_name. # @param ctx Type: CParser.Type_nameContext - def exitType_name(self,ctx): + def exitType_name(self, ctx): pass =20 - # Enter a parse tree produced by CParser#abstract_declarator. # @param ctx Type: CParser.Abstract_declaratorContext - def enterAbstract_declarator(self,ctx): + def enterAbstract_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#abstract_declarator. # @param ctx Type: CParser.Abstract_declaratorContext - def exitAbstract_declarator(self,ctx): + def exitAbstract_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#direct_abstract_declarator. # @param ctx Type: CParser.Direct_abstract_declaratorContext - def enterDirect_abstract_declarator(self,ctx): + def enterDirect_abstract_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#direct_abstract_declarator. # @param ctx Type: CParser.Direct_abstract_declaratorContext - def exitDirect_abstract_declarator(self,ctx): + def exitDirect_abstract_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#abstract_declarator_suffix. # @param ctx Type: CParser.Abstract_declarator_suffixContext - def enterAbstract_declarator_suffix(self,ctx): + def enterAbstract_declarator_suffix(self, ctx): pass =20 # Exit a parse tree produced by CParser#abstract_declarator_suffix. # @param ctx Type: CParser.Abstract_declarator_suffixContext - def exitAbstract_declarator_suffix(self,ctx): + def exitAbstract_declarator_suffix(self, ctx): pass =20 - # Enter a parse tree produced by CParser#initializer. # @param ctx Type: CParser.InitializerContext - def enterInitializer(self,ctx): + def enterInitializer(self, ctx): pass =20 # Exit a parse tree produced by CParser#initializer. # @param ctx Type: CParser.InitializerContext - def exitInitializer(self,ctx): + def exitInitializer(self, ctx): pass =20 - # Enter a parse tree produced by CParser#initializer_list. # @param ctx Type: CParser.Initializer_listContext - def enterInitializer_list(self,ctx): + def enterInitializer_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#initializer_list. # @param ctx Type: CParser.Initializer_listContext - def exitInitializer_list(self,ctx): + def exitInitializer_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#argument_expression_list. # @param ctx Type: CParser.Argument_expression_listContext - def enterArgument_expression_list(self,ctx): + def enterArgument_expression_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#argument_expression_list. # @param ctx Type: CParser.Argument_expression_listContext - def exitArgument_expression_list(self,ctx): + def exitArgument_expression_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#additive_expression. # @param ctx Type: CParser.Additive_expressionContext - def enterAdditive_expression(self,ctx): + def enterAdditive_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#additive_expression. # @param ctx Type: CParser.Additive_expressionContext - def exitAdditive_expression(self,ctx): + def exitAdditive_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#multiplicative_expression. # @param ctx Type: CParser.Multiplicative_expressionContext - def enterMultiplicative_expression(self,ctx): + def enterMultiplicative_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#multiplicative_expression. # @param ctx Type: CParser.Multiplicative_expressionContext - def exitMultiplicative_expression(self,ctx): + def exitMultiplicative_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#cast_expression. # @param ctx Type: CParser.Cast_expressionContext - def enterCast_expression(self,ctx): + def enterCast_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#cast_expression. # @param ctx Type: CParser.Cast_expressionContext - def exitCast_expression(self,ctx): + def exitCast_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#unary_expression. # @param ctx Type: CParser.Unary_expressionContext - def enterUnary_expression(self,ctx): + def enterUnary_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#unary_expression. # @param ctx Type: CParser.Unary_expressionContext - def exitUnary_expression(self,ctx): + def exitUnary_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#postfix_expression. # @param ctx Type: CParser.Postfix_expressionContext - def enterPostfix_expression(self,ctx): + def enterPostfix_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#postfix_expression. # @param ctx Type: CParser.Postfix_expressionContext - def exitPostfix_expression(self,ctx): + def exitPostfix_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#macro_parameter_list. # @param ctx Type: CParser.Macro_parameter_listContext - def enterMacro_parameter_list(self,ctx): + def enterMacro_parameter_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#macro_parameter_list. # @param ctx Type: CParser.Macro_parameter_listContext - def exitMacro_parameter_list(self,ctx): + def exitMacro_parameter_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#unary_operator. # @param ctx Type: CParser.Unary_operatorContext - def enterUnary_operator(self,ctx): + def enterUnary_operator(self, ctx): pass =20 # Exit a parse tree produced by CParser#unary_operator. # @param ctx Type: CParser.Unary_operatorContext - def exitUnary_operator(self,ctx): + def exitUnary_operator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#primary_expression. # @param ctx Type: CParser.Primary_expressionContext - def enterPrimary_expression(self,ctx): + def enterPrimary_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#primary_expression. # @param ctx Type: CParser.Primary_expressionContext - def exitPrimary_expression(self,ctx): + def exitPrimary_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#constant. # @param ctx Type: CParser.ConstantContext - def enterConstant(self,ctx): + def enterConstant(self, ctx): pass =20 # Exit a parse tree produced by CParser#constant. # @param ctx Type: CParser.ConstantContext - def exitConstant(self,ctx): + def exitConstant(self, ctx): pass =20 - # Enter a parse tree produced by CParser#expression. # @param ctx Type: CParser.ExpressionContext - def enterExpression(self,ctx): + def enterExpression(self, ctx): pass =20 # Exit a parse tree produced by CParser#expression. # @param ctx Type: CParser.ExpressionContext - def exitExpression(self,ctx): + def exitExpression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#constant_expression. # @param ctx Type: CParser.Constant_expressionContext - def enterConstant_expression(self,ctx): + def enterConstant_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#constant_expression. # @param ctx Type: CParser.Constant_expressionContext - def exitConstant_expression(self,ctx): + def exitConstant_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#assignment_expression. # @param ctx Type: CParser.Assignment_expressionContext - def enterAssignment_expression(self,ctx): + def enterAssignment_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#assignment_expression. # @param ctx Type: CParser.Assignment_expressionContext - def exitAssignment_expression(self,ctx): + def exitAssignment_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#lvalue. # @param ctx Type: CParser.LvalueContext - def enterLvalue(self,ctx): + def enterLvalue(self, ctx): pass =20 # Exit a parse tree produced by CParser#lvalue. # @param ctx Type: CParser.LvalueContext - def exitLvalue(self,ctx): + def exitLvalue(self, ctx): pass =20 - # Enter a parse tree produced by CParser#assignment_operator. # @param ctx Type: CParser.Assignment_operatorContext - def enterAssignment_operator(self,ctx): + def enterAssignment_operator(self, ctx): pass =20 # Exit a parse tree produced by CParser#assignment_operator. # @param ctx Type: CParser.Assignment_operatorContext - def exitAssignment_operator(self,ctx): + def exitAssignment_operator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#conditional_expression. # @param ctx Type: CParser.Conditional_expressionContext - def enterConditional_expression(self,ctx): + def enterConditional_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#conditional_expression. # @param ctx Type: CParser.Conditional_expressionContext - def exitConditional_expression(self,ctx): + def exitConditional_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#logical_or_expression. # @param ctx Type: CParser.Logical_or_expressionContext - def enterLogical_or_expression(self,ctx): + def enterLogical_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#logical_or_expression. # @param ctx Type: CParser.Logical_or_expressionContext - def exitLogical_or_expression(self,ctx): + def exitLogical_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#logical_and_expression. # @param ctx Type: CParser.Logical_and_expressionContext - def enterLogical_and_expression(self,ctx): + def enterLogical_and_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#logical_and_expression. # @param ctx Type: CParser.Logical_and_expressionContext - def exitLogical_and_expression(self,ctx): + def exitLogical_and_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#inclusive_or_expression. # @param ctx Type: CParser.Inclusive_or_expressionContext - def enterInclusive_or_expression(self,ctx): + def enterInclusive_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#inclusive_or_expression. # @param ctx Type: CParser.Inclusive_or_expressionContext - def exitInclusive_or_expression(self,ctx): + def exitInclusive_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#exclusive_or_expression. # @param ctx Type: CParser.Exclusive_or_expressionContext - def enterExclusive_or_expression(self,ctx): + def enterExclusive_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#exclusive_or_expression. # @param ctx Type: CParser.Exclusive_or_expressionContext - def exitExclusive_or_expression(self,ctx): + def exitExclusive_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#and_expression. # @param ctx Type: CParser.And_expressionContext - def enterAnd_expression(self,ctx): + def enterAnd_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#and_expression. # @param ctx Type: CParser.And_expressionContext - def exitAnd_expression(self,ctx): + def exitAnd_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#equality_expression. # @param ctx Type: CParser.Equality_expressionContext - def enterEquality_expression(self,ctx): + def enterEquality_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#equality_expression. # @param ctx Type: CParser.Equality_expressionContext - def exitEquality_expression(self,ctx): + def exitEquality_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#relational_expression. # @param ctx Type: CParser.Relational_expressionContext - def enterRelational_expression(self,ctx): + def enterRelational_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#relational_expression. # @param ctx Type: CParser.Relational_expressionContext - def exitRelational_expression(self,ctx): + def exitRelational_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#shift_expression. # @param ctx Type: CParser.Shift_expressionContext - def enterShift_expression(self,ctx): + def enterShift_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#shift_expression. # @param ctx Type: CParser.Shift_expressionContext - def exitShift_expression(self,ctx): + def exitShift_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#statement. # @param ctx Type: CParser.StatementContext - def enterStatement(self,ctx): + def enterStatement(self, ctx): pass =20 # Exit a parse tree produced by CParser#statement. # @param ctx Type: CParser.StatementContext - def exitStatement(self,ctx): + def exitStatement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm2_statement. # @param ctx Type: CParser.Asm2_statementContext - def enterAsm2_statement(self,ctx): + def enterAsm2_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm2_statement. # @param ctx Type: CParser.Asm2_statementContext - def exitAsm2_statement(self,ctx): + def exitAsm2_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm1_statement. # @param ctx Type: CParser.Asm1_statementContext - def enterAsm1_statement(self,ctx): + def enterAsm1_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm1_statement. # @param ctx Type: CParser.Asm1_statementContext - def exitAsm1_statement(self,ctx): + def exitAsm1_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm_statement. # @param ctx Type: CParser.Asm_statementContext - def enterAsm_statement(self,ctx): + def enterAsm_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm_statement. # @param ctx Type: CParser.Asm_statementContext - def exitAsm_statement(self,ctx): + def exitAsm_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#macro_statement. # @param ctx Type: CParser.Macro_statementContext - def enterMacro_statement(self,ctx): + def enterMacro_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#macro_statement. # @param ctx Type: CParser.Macro_statementContext - def exitMacro_statement(self,ctx): + def exitMacro_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#labeled_statement. # @param ctx Type: CParser.Labeled_statementContext - def enterLabeled_statement(self,ctx): + def enterLabeled_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#labeled_statement. # @param ctx Type: CParser.Labeled_statementContext - def exitLabeled_statement(self,ctx): + def exitLabeled_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#compound_statement. # @param ctx Type: CParser.Compound_statementContext - def enterCompound_statement(self,ctx): + def enterCompound_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#compound_statement. # @param ctx Type: CParser.Compound_statementContext - def exitCompound_statement(self,ctx): + def exitCompound_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#statement_list. # @param ctx Type: CParser.Statement_listContext - def enterStatement_list(self,ctx): + def enterStatement_list(self, ctx): pass =20 - # Exit a parse tree produced by CParser#statement_list. # @param ctx Type: CParser.Statement_listContext - def exitStatement_list(self,ctx): + def exitStatement_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#expression_statement. # @param ctx Type: CParser.Expression_statementContext - def enterExpression_statement(self,ctx): + def enterExpression_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#expression_statement. # @param ctx Type: CParser.Expression_statementContext - def exitExpression_statement(self,ctx): + def exitExpression_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#selection_statement. # @param ctx Type: CParser.Selection_statementContext - def enterSelection_statement(self,ctx): + def enterSelection_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#selection_statement. # @param ctx Type: CParser.Selection_statementContext - def exitSelection_statement(self,ctx): + def exitSelection_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#iteration_statement. # @param ctx Type: CParser.Iteration_statementContext - def enterIteration_statement(self,ctx): + def enterIteration_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#iteration_statement. # @param ctx Type: CParser.Iteration_statementContext - def exitIteration_statement(self,ctx): + def exitIteration_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#jump_statement. # @param ctx Type: CParser.Jump_statementContext - def enterJump_statement(self,ctx): + def enterJump_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#jump_statement. # @param ctx Type: CParser.Jump_statementContext - def exitJump_statement(self,ctx): + def exitJump_statement(self, ctx): pass - - diff --git a/BaseTools/Source/Python/Ecc/CParser4/CParser.py b/BaseTools/So= urce/Python/Ecc/CParser4/CParser.py index 31d23d55aa57..22c17c66680a 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CParser.py @@ -6,7 +6,7 @@ from typing.io import TextIO import sys =20 =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -22,6 +22,7 @@ import sys import Ecc.CodeFragment as CodeFragment import Ecc.FileProfile as FileProfile =20 + def serializedATN(): with StringIO() as buf: buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3k") @@ -475,61 +476,61 @@ def serializedATN(): return buf.getvalue() =20 =20 -class CParser ( Parser ): +class CParser (Parser): =20 grammarFileName =3D "C.g4" =20 atn =3D ATNDeserializer().deserialize(serializedATN()) =20 - decisionsToDFA =3D [ DFA(ds, i) for i, ds in enumerate(atn.decisionToS= tate) ] + decisionsToDFA =3D [DFA(ds, i) for i, ds in enumerate(atn.decisionToSt= ate)] =20 sharedContextCache =3D PredictionContextCache() =20 - literalNames =3D [ "", "'{'", "';'", "'typedef'", "','", "'= =3D'", - "'extern'", "'static'", "'auto'", "'register'", "'STA= TIC'", - "'void'", "'char'", "'short'", "'int'", "'long'", "'f= loat'", - "'double'", "'signed'", "'unsigned'", "'}'", "'struct= '", - "'union'", "':'", "'enum'", "'const'", "'volatile'", - "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED= '", - "'VOLATILE'", "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EF= IAPI'", - "'EFI_BOOTSERVICE'", "'EFI_RUNTIMESERVICE'", "'PACKED= '", - "'('", "')'", "'['", "']'", "'*'", "'...'", "'+'", - "'-'", "'/'", "'%'", "'++'", "'--'", "'sizeof'", "'.'= ", - "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/=3D'", "'%= =3D'", - "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", "= '^=3D'", "'|=3D'", - "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", - "'<'", "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'_= _asm__'", - "'_asm'", "'__asm'", "'case'", "'default'", "'if'", - "'else'", "'switch'", "'while'", "'do'", "'goto'", - "'continue'", "'break'", "'return'" ] + literalNames =3D ["", "'{'", "';'", "'typedef'", "','", "'=3D= '", + "'extern'", "'static'", "'auto'", "'register'", "'STAT= IC'", + "'void'", "'char'", "'short'", "'int'", "'long'", "'fl= oat'", + "'double'", "'signed'", "'unsigned'", "'}'", "'struct'= ", + "'union'", "':'", "'enum'", "'const'", "'volatile'", + "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'= ", + "'VOLATILE'", "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFI= API'", + "'EFI_BOOTSERVICE'", "'EFI_RUNTIMESERVICE'", "'PACKED'= ", + "'('", "')'", "'['", "']'", "'*'", "'...'", "'+'", + "'-'", "'/'", "'%'", "'++'", "'--'", "'sizeof'", "'.'", + "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/=3D'", "'%= =3D'", + "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", "'= ^=3D'", "'|=3D'", + "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", + "'<'", "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__= asm__'", + "'_asm'", "'__asm'", "'case'", "'default'", "'if'", + "'else'", "'switch'", "'while'", "'do'", "'goto'", + "'continue'", "'break'", "'return'"] =20 - symbolicNames =3D [ "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "IDENTIFIER", "CHARACTER_LITERAL", "STR= ING_LITERAL", - "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", - "FLOATING_POINT_LITERAL", "WS", "BS", "UnicodeVocabu= lary", - "COMMENT", "LINE_COMMENT", "LINE_COMMAND" ] + symbolicNames =3D ["", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "IDENTIFIER", "CHARACTER_LITERAL", "STRI= NG_LITERAL", + "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", + "FLOATING_POINT_LITERAL", "WS", "BS", "UnicodeVocabul= ary", + "COMMENT", "LINE_COMMENT", "LINE_COMMAND"] =20 RULE_translation_unit =3D 0 RULE_external_declaration =3D 1 @@ -603,225 +604,224 @@ class CParser ( Parser ): RULE_iteration_statement =3D 69 RULE_jump_statement =3D 70 =20 - ruleNames =3D [ "translation_unit", "external_declaration", "function= _definition", - "declaration_specifiers", "declaration", "init_declarat= or_list", - "init_declarator", "storage_class_specifier", "type_spe= cifier", - "type_id", "struct_or_union_specifier", "struct_or_unio= n", - "struct_declaration_list", "struct_declaration", "speci= fier_qualifier_list", - "struct_declarator_list", "struct_declarator", "enum_sp= ecifier", - "enumerator_list", "enumerator", "type_qualifier", "dec= larator", - "direct_declarator", "declarator_suffix", "pointer", - "parameter_type_list", "parameter_list", "parameter_dec= laration", - "identifier_list", "type_name", "abstract_declarator", - "direct_abstract_declarator", "abstract_declarator_suff= ix", - "initializer", "initializer_list", "argument_expression= _list", - "additive_expression", "multiplicative_expression", "ca= st_expression", - "unary_expression", "postfix_expression", "macro_parame= ter_list", - "unary_operator", "primary_expression", "constant", "ex= pression", - "constant_expression", "assignment_expression", "lvalue= ", - "assignment_operator", "conditional_expression", "logic= al_or_expression", - "logical_and_expression", "inclusive_or_expression", - "exclusive_or_expression", "and_expression", "equality_= expression", - "relational_expression", "shift_expression", "statement= ", - "asm2_statement", "asm1_statement", "asm_statement", - "macro_statement", "labeled_statement", "compound_state= ment", - "statement_list", "expression_statement", "selection_st= atement", - "iteration_statement", "jump_statement" ] + ruleNames =3D ["translation_unit", "external_declaration", "function_d= efinition", + "declaration_specifiers", "declaration", "init_declarator= _list", + "init_declarator", "storage_class_specifier", "type_speci= fier", + "type_id", "struct_or_union_specifier", "struct_or_union", + "struct_declaration_list", "struct_declaration", "specifi= er_qualifier_list", + "struct_declarator_list", "struct_declarator", "enum_spec= ifier", + "enumerator_list", "enumerator", "type_qualifier", "decla= rator", + "direct_declarator", "declarator_suffix", "pointer", + "parameter_type_list", "parameter_list", "parameter_decla= ration", + "identifier_list", "type_name", "abstract_declarator", + "direct_abstract_declarator", "abstract_declarator_suffix= ", + "initializer", "initializer_list", "argument_expression_l= ist", + "additive_expression", "multiplicative_expression", "cast= _expression", + "unary_expression", "postfix_expression", "macro_paramete= r_list", + "unary_operator", "primary_expression", "constant", "expr= ession", + "constant_expression", "assignment_expression", "lvalue", + "assignment_operator", "conditional_expression", "logical= _or_expression", + "logical_and_expression", "inclusive_or_expression", + "exclusive_or_expression", "and_expression", "equality_ex= pression", + "relational_expression", "shift_expression", "statement", + "asm2_statement", "asm1_statement", "asm_statement", + "macro_statement", "labeled_statement", "compound_stateme= nt", + "statement_list", "expression_statement", "selection_stat= ement", + "iteration_statement", "jump_statement"] =20 EOF =3D Token.EOF - T__0=3D1 - T__1=3D2 - T__2=3D3 - T__3=3D4 - T__4=3D5 - T__5=3D6 - T__6=3D7 - T__7=3D8 - T__8=3D9 - T__9=3D10 - T__10=3D11 - T__11=3D12 - T__12=3D13 - T__13=3D14 - T__14=3D15 - T__15=3D16 - T__16=3D17 - T__17=3D18 - T__18=3D19 - T__19=3D20 - T__20=3D21 - T__21=3D22 - T__22=3D23 - T__23=3D24 - T__24=3D25 - T__25=3D26 - T__26=3D27 - T__27=3D28 - T__28=3D29 - T__29=3D30 - T__30=3D31 - T__31=3D32 - T__32=3D33 - T__33=3D34 - T__34=3D35 - T__35=3D36 - T__36=3D37 - T__37=3D38 - T__38=3D39 - T__39=3D40 - T__40=3D41 - T__41=3D42 - T__42=3D43 - T__43=3D44 - T__44=3D45 - T__45=3D46 - T__46=3D47 - T__47=3D48 - T__48=3D49 - T__49=3D50 - T__50=3D51 - T__51=3D52 - T__52=3D53 - T__53=3D54 - T__54=3D55 - T__55=3D56 - T__56=3D57 - T__57=3D58 - T__58=3D59 - T__59=3D60 - T__60=3D61 - T__61=3D62 - T__62=3D63 - T__63=3D64 - T__64=3D65 - T__65=3D66 - T__66=3D67 - T__67=3D68 - T__68=3D69 - T__69=3D70 - T__70=3D71 - T__71=3D72 - T__72=3D73 - T__73=3D74 - T__74=3D75 - T__75=3D76 - T__76=3D77 - T__77=3D78 - T__78=3D79 - T__79=3D80 - T__80=3D81 - T__81=3D82 - T__82=3D83 - T__83=3D84 - T__84=3D85 - T__85=3D86 - T__86=3D87 - T__87=3D88 - T__88=3D89 - T__89=3D90 - T__90=3D91 - T__91=3D92 - IDENTIFIER=3D93 - CHARACTER_LITERAL=3D94 - STRING_LITERAL=3D95 - HEX_LITERAL=3D96 - DECIMAL_LITERAL=3D97 - OCTAL_LITERAL=3D98 - FLOATING_POINT_LITERAL=3D99 - WS=3D100 - BS=3D101 - UnicodeVocabulary=3D102 - COMMENT=3D103 - LINE_COMMENT=3D104 - LINE_COMMAND=3D105 + T__0 =3D 1 + T__1 =3D 2 + T__2 =3D 3 + T__3 =3D 4 + T__4 =3D 5 + T__5 =3D 6 + T__6 =3D 7 + T__7 =3D 8 + T__8 =3D 9 + T__9 =3D 10 + T__10 =3D 11 + T__11 =3D 12 + T__12 =3D 13 + T__13 =3D 14 + T__14 =3D 15 + T__15 =3D 16 + T__16 =3D 17 + T__17 =3D 18 + T__18 =3D 19 + T__19 =3D 20 + T__20 =3D 21 + T__21 =3D 22 + T__22 =3D 23 + T__23 =3D 24 + T__24 =3D 25 + T__25 =3D 26 + T__26 =3D 27 + T__27 =3D 28 + T__28 =3D 29 + T__29 =3D 30 + T__30 =3D 31 + T__31 =3D 32 + T__32 =3D 33 + T__33 =3D 34 + T__34 =3D 35 + T__35 =3D 36 + T__36 =3D 37 + T__37 =3D 38 + T__38 =3D 39 + T__39 =3D 40 + T__40 =3D 41 + T__41 =3D 42 + T__42 =3D 43 + T__43 =3D 44 + T__44 =3D 45 + T__45 =3D 46 + T__46 =3D 47 + T__47 =3D 48 + T__48 =3D 49 + T__49 =3D 50 + T__50 =3D 51 + T__51 =3D 52 + T__52 =3D 53 + T__53 =3D 54 + T__54 =3D 55 + T__55 =3D 56 + T__56 =3D 57 + T__57 =3D 58 + T__58 =3D 59 + T__59 =3D 60 + T__60 =3D 61 + T__61 =3D 62 + T__62 =3D 63 + T__63 =3D 64 + T__64 =3D 65 + T__65 =3D 66 + T__66 =3D 67 + T__67 =3D 68 + T__68 =3D 69 + T__69 =3D 70 + T__70 =3D 71 + T__71 =3D 72 + T__72 =3D 73 + T__73 =3D 74 + T__74 =3D 75 + T__75 =3D 76 + T__76 =3D 77 + T__77 =3D 78 + T__78 =3D 79 + T__79 =3D 80 + T__80 =3D 81 + T__81 =3D 82 + T__82 =3D 83 + T__83 =3D 84 + T__84 =3D 85 + T__85 =3D 86 + T__86 =3D 87 + T__87 =3D 88 + T__88 =3D 89 + T__89 =3D 90 + T__90 =3D 91 + T__91 =3D 92 + IDENTIFIER =3D 93 + CHARACTER_LITERAL =3D 94 + STRING_LITERAL =3D 95 + HEX_LITERAL =3D 96 + DECIMAL_LITERAL =3D 97 + OCTAL_LITERAL =3D 98 + FLOATING_POINT_LITERAL =3D 99 + WS =3D 100 + BS =3D 101 + UnicodeVocabulary =3D 102 + COMMENT =3D 103 + LINE_COMMENT =3D 104 + LINE_COMMAND =3D 105 =20 # @param input Type: TokenStream # @param output=3D sys.stdout Type: TextIO - def __init__(self,input,output=3D sys.stdout): + def __init__(self, input, output=3Dsys.stdout): super().__init__(input, output) self.checkVersion("4.7.1") - self._interp =3D ParserATNSimulator(self, self.atn, self.decisions= ToDFA, self.sharedContextCache) + self._interp =3D ParserATNSimulator( + self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates =3D None =20 + def printTokenInfo(self, line, offset, tokenText): + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 - - - def printTokenInfo(self,line,offset,tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) - - def StorePredicateExpression(self,StartLine,StartOffset,EndLine,EndOff= set,Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.PredicateExpressionList.append(PredExp) =20 - def StoreEnumerationDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, S= tartOffset), (EndLine, EndOffset)) + def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.EnumerationDefinitionList.append(EnumDef) =20 - def StoreStructUnionDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.StructUnionDefinitionList.append(SUDef) =20 - def StoreTypedefDefinition(self,StartLine,StartOffset,EndLine,EndOffse= t,FromText,ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLi= ne, StartOffset), (EndLine, EndOffset)) + def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) FileProfile.TypedefDefinitionList.append(Tdef) =20 - def StoreFunctionDefinition(self,StartLine,StartOffset,EndLine,EndOffs= et,ModifierText,DeclText,LeftBraceLine,LeftBraceOffset,DeclLine,DeclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBrace= Offset), (DeclLine, DeclOffset)) + def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) FileProfile.FunctionDefinitionList.append(FuncDef) =20 - def StoreVariableDeclaration(self,StartLine,StartOffset,EndLine,EndOff= set,ModifierText,DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclTex= t, (StartLine, StartOffset), (EndLine, EndOffset)) + def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) FileProfile.VariableDeclarationList.append(VarDecl) =20 - def StoreFunctionCalling(self,StartLine,StartOffset,EndLine,EndOffset,= FuncName,ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (St= artLine, StartOffset), (EndLine, EndOffset)) + def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) FileProfile.FunctionCallingList.append(FuncCall) =20 - - class Translation_unitContext(ParserRuleContext): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def external_declaration(self,i=3DNone): + def external_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.External_declarat= ionContext) else: - return self.getTypedRuleContext(CParser.External_declarati= onContext,i) - + return self.getTypedRuleContext(CParser.External_declarati= onContext, i) =20 def getRuleIndex(self): return CParser.RULE_translation_unit =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterTranslation_unit" ): + def enterRule(self, listener): + if hasattr(listener, "enterTranslation_unit"): listener.enterTranslation_unit(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitTranslation_unit" ): + def exitRule(self, listener): + if hasattr(listener, "exitTranslation_unit"): listener.exitTranslation_unit(self) =20 - - - def translation_unit(self): =20 localctx =3D CParser.Translation_unitContext(self, self._ctx, self= .state) self.enterRule(localctx, 0, self.RULE_translation_unit) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 145 self._errHandler.sync(self) _la =3D self._input.LA(1) - while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T__7) = | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1 << = CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CParse= r.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.T__1= 7) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21) | (= 1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 << C= Parser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CParser= .T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T__32= ) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) | (1= << CParser.T__36) | (1 << CParser.T__37) | (1 << CParser.T__41))) !=3D 0) = or _la=3D=3DCParser.IDENTIFIER: + while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T__7) = | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1 << = CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CParse= r.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.T__1= 7) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21) | (= 1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 << C= Parser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CParser= .T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T__32= ) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) | (1= << CParser.T__36) | (1 << CParser.T__37) | (1 << CParser.T__41))) !=3D 0) = or _la =3D=3D CParser.IDENTIFIER: self.state =3D 142 self.external_declaration() self.state =3D 147 @@ -840,75 +840,67 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def function_definition(self): - return self.getTypedRuleContext(CParser.Function_definitionCon= text,0) - + return self.getTypedRuleContext(CParser.Function_definitionCon= text, 0) =20 def macro_statement(self): - return self.getTypedRuleContext(CParser.Macro_statementContext= ,0) - + return self.getTypedRuleContext(CParser.Macro_statementContext= , 0) =20 def getRuleIndex(self): return CParser.RULE_external_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExternal_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterExternal_declaration"): listener.enterExternal_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExternal_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitExternal_declaration"): listener.exitExternal_declaration(self) =20 - - - def external_declaration(self): =20 - localctx =3D CParser.External_declarationContext(self, self._ctx, = self.state) + localctx =3D CParser.External_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 2, self.RULE_external_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 166 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,4,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 4, self._ctx) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 149 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,1,self._c= tx) + la_ =3D self._interp.adaptivePredict(self._input, 1, self.= _ctx) if la_ =3D=3D 1: self.state =3D 148 self.declaration_specifiers() =20 - self.state =3D 151 self.declarator() self.state =3D 155 self._errHandler.sync(self) _la =3D self._input.LA(1) - while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << C= Parser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T_= _7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1= << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CP= arser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.= T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21)= | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 = << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CPa= rser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T= __32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) = | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.IDENTIFIER: + while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << C= Parser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T_= _7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1= << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CP= arser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.= T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21)= | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 = << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CPa= rser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T= __32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) = | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.IDENTIFIER: self.state =3D 152 self.declaration() self.state =3D 157 @@ -938,14 +930,12 @@ class CParser ( Parser ): self.state =3D 164 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__1: + if _la =3D=3D CParser.T__1: self.state =3D 163 self.match(CParser.T__1) =20 - pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -958,7 +948,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser self.ModifierText =3D '' @@ -967,71 +957,64 @@ class CParser ( Parser ): self.LBOffset =3D 0 self.DeclLine =3D 0 self.DeclOffset =3D 0 - self.d =3D None # Declaration_specifiersContext - self._declaration_specifiers =3D None # Declaration_specifiers= Context - self._declarator =3D None # DeclaratorContext - self.a =3D None # Compound_statementContext - self.b =3D None # Compound_statementContext + self.d =3D None # Declaration_specifiersContext + self._declaration_specifiers =3D None # Declaration_specifier= sContext + self._declarator =3D None # DeclaratorContext + self.a =3D None # Compound_statementContext + self.b =3D None # Compound_statementContext =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def compound_statement(self): - return self.getTypedRuleContext(CParser.Compound_statementCont= ext,0) - + return self.getTypedRuleContext(CParser.Compound_statementCont= ext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def getRuleIndex(self): return CParser.RULE_function_definition =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterFunction_definition" ): + def enterRule(self, listener): + if hasattr(listener, "enterFunction_definition"): listener.enterFunction_definition(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitFunction_definition" ): + def exitRule(self, listener): + if hasattr(listener, "exitFunction_definition"): listener.exitFunction_definition(self) =20 - - - def function_definition(self): =20 - localctx =3D CParser.Function_definitionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Function_definitionContext( + self, self._ctx, self.state) self.enterRule(localctx, 4, self.RULE_function_definition) =20 - ModifierText =3D ''; - DeclText =3D ''; - LBLine =3D 0; - LBOffset =3D 0; - DeclLine =3D 0; - DeclOffset =3D 0; + ModifierText =3D '' + DeclText =3D '' + LBLine =3D 0 + LBOffset =3D 0 + DeclLine =3D 0 + DeclOffset =3D 0 =20 - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 169 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,5,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 5, self._ctx) if la_ =3D=3D 1: self.state =3D 168 localctx.d =3D localctx._declaration_specifiers =3D self.d= eclaration_specifiers() =20 - self.state =3D 171 localctx._declarator =3D self.declarator() self.state =3D 180 @@ -1047,7 +1030,7 @@ class CParser ( Parser ): self.state =3D 175 self._errHandler.sync(self) _la =3D self._input.LA(1) - if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((= 1 << CParser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CPar= ser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10= ) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1= << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CP= arser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.= T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25)= | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 = << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CPa= rser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T= __35) | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.IDENTIFIER): + if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((= 1 << CParser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CPar= ser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10= ) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1= << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CP= arser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.= T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25)= | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 = << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CPa= rser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T= __35) | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.IDENTIFIER): break =20 self.state =3D 177 @@ -1060,24 +1043,30 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - if localctx.d !=3D None: - ModifierText =3D (None if localctx._declaration_specifiers= is None else self._input.getText((localctx._declaration_specifiers.start,l= ocalctx._declaration_specifiers.stop))) + ModifierText =3D (None if localctx._declaration_specifiers= is None else self._input.getText( + (localctx._declaration_specifiers.start, localctx._dec= laration_specifiers.stop))) else: ModifierText =3D '' - DeclText =3D (None if localctx._declarator is None else self._= input.getText((localctx._declarator.start,localctx._declarator.stop))) - DeclLine =3D (None if localctx._declarator is None else localc= tx._declarator.start).line - DeclOffset =3D (None if localctx._declarator is None else loca= lctx._declarator.start).column + DeclText =3D (None if localctx._declarator is None else self._= input.getText( + (localctx._declarator.start, localctx._declarator.stop))) + DeclLine =3D ( + None if localctx._declarator is None else localctx._declar= ator.start).line + DeclOffset =3D ( + None if localctx._declarator is None else localctx._declar= ator.start).column if localctx.a !=3D None: LBLine =3D (None if localctx.a is None else localctx.a.sta= rt).line - LBOffset =3D (None if localctx.a is None else localctx.a.s= tart).column + LBOffset =3D ( + None if localctx.a is None else localctx.a.start).colu= mn else: LBLine =3D (None if localctx.b is None else localctx.b.sta= rt).line - LBOffset =3D (None if localctx.b is None else localctx.b.s= tart).column + LBOffset =3D ( + None if localctx.b is None else localctx.b.start).colu= mn =20 self._ctx.stop =3D self._input.LT(-1) =20 - self.StoreFunctionDefinition(localctx.start.line, localctx.sta= rt.column, localctx.stop.line, localctx.stop.column, ModifierText, DeclText= , LBLine, LBOffset, DeclLine, DeclOffset) + self.StoreFunctionDefinition(localctx.start.line, localctx.sta= rt.column, localctx.stop.line, + localctx.stop.column, ModifierTex= t, DeclText, LBLine, LBOffset, DeclLine, DeclOffset) =20 except RecognitionException as re: localctx.exception =3D re @@ -1091,60 +1080,55 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def storage_class_specifier(self,i=3DNone): + def storage_class_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Storage_class_spe= cifierContext) else: - return self.getTypedRuleContext(CParser.Storage_class_spec= ifierContext,i) - + return self.getTypedRuleContext(CParser.Storage_class_spec= ifierContext, i) =20 # @param i=3DNone Type: int - def type_specifier(self,i=3DNone): + def type_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_specifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_specifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_specifierCont= ext, i) =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_declaration_specifiers =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclaration_specifiers" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclaration_specifiers"): listener.enterDeclaration_specifiers(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclaration_specifiers" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclaration_specifiers"): listener.exitDeclaration_specifiers(self) =20 - - - def declaration_specifiers(self): =20 - localctx =3D CParser.Declaration_specifiersContext(self, self._ctx= , self.state) + localctx =3D CParser.Declaration_specifiersContext( + self, self._ctx, self.state) self.enterRule(localctx, 6, self.RULE_declaration_specifiers) try: self.enterOuterAlt(localctx, 1) self.state =3D 187 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 187 self._errHandler.sync(self) @@ -1164,12 +1148,11 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - else: raise NoViableAltException(self) self.state =3D 189 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,9,self._= ctx) + _alt =3D self._interp.adaptivePredict(self._input, 9, self= ._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -1183,46 +1166,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.a =3D None # Token - self.b =3D None # Declaration_specifiersContext - self.c =3D None # Init_declarator_listContext - self.d =3D None # Token - self.s =3D None # Declaration_specifiersContext - self.t =3D None # Init_declarator_listContext - self.e =3D None # Token + self.a =3D None # Token + self.b =3D None # Declaration_specifiersContext + self.c =3D None # Init_declarator_listContext + self.d =3D None # Token + self.s =3D None # Declaration_specifiersContext + self.t =3D None # Init_declarator_listContext + self.e =3D None # Token =20 def init_declarator_list(self): - return self.getTypedRuleContext(CParser.Init_declarator_listCo= ntext,0) - + return self.getTypedRuleContext(CParser.Init_declarator_listCo= ntext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclaration"): listener.enterDeclaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclaration"): listener.exitDeclaration(self) =20 - - - def declaration(self): =20 localctx =3D CParser.DeclarationContext(self, self._ctx, self.stat= e) self.enterRule(localctx, 8, self.RULE_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 206 self._errHandler.sync(self) @@ -1233,21 +1211,22 @@ class CParser ( Parser ): localctx.a =3D self.match(CParser.T__2) self.state =3D 193 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,10,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 10, self= ._ctx) if la_ =3D=3D 1: self.state =3D 192 localctx.b =3D self.declaration_specifiers() =20 - self.state =3D 195 localctx.c =3D self.init_declarator_list() self.state =3D 196 localctx.d =3D self.match(CParser.T__1) =20 if localctx.b is not None: - self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , (None if localctx.b is None else self._input.getText((localctx.b.start,lo= calctx.b.stop))), (None if localctx.c is None else self._input.getText((loc= alctx.c.start,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , (None if localctx.b is None else self._input.getText( + (localctx.b.start, localctx.b.stop))), (None if lo= calctx.c is None else self._input.getText((localctx.c.start, localctx.c.sto= p)))) else: - self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , '', (None if localctx.c is None else self._input.getText((localctx.c.star= t,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), + localctx.d.column, '', (No= ne if localctx.c is None else self._input.getText((localctx.c.start, localc= tx.c.stop)))) =20 pass elif token in [CParser.T__5, CParser.T__6, CParser.T__7, CPars= er.T__8, CParser.T__9, CParser.T__10, CParser.T__11, CParser.T__12, CParser= .T__13, CParser.T__14, CParser.T__15, CParser.T__16, CParser.T__17, CParser= .T__18, CParser.T__20, CParser.T__21, CParser.T__23, CParser.T__24, CParser= .T__25, CParser.T__26, CParser.T__27, CParser.T__28, CParser.T__29, CParser= .T__30, CParser.T__31, CParser.T__32, CParser.T__33, CParser.T__34, CParser= .T__35, CParser.T__36, CParser.IDENTIFIER]: @@ -1261,12 +1240,12 @@ class CParser ( Parser ): self.state =3D 200 localctx.t =3D self.init_declarator_list() =20 - self.state =3D 203 localctx.e =3D self.match(CParser.T__1) =20 if localctx.t is not None: - self.StoreVariableDeclaration((None if localctx.s is N= one else localctx.s.start).line, (None if localctx.s is None else localctx.= s.start).column, (None if localctx.t is None else localctx.t.start).line, (= None if localctx.t is None else localctx.t.start).column, (None if localctx= .s is None else self._input.getText((localctx.s.start,localctx.s.stop))), (= None if localctx.t is None else self._input.getText((localctx.t.start,local= ctx.t.stop)))) + self.StoreVariableDeclaration((None if localctx.s is N= one else localctx.s.start).line, (None if localctx.s is None else localctx.= s.start).column, (None if localctx.t is None else localctx.t.start).line, ( + None if localctx.t is None else localctx.t.start).= column, (None if localctx.s is None else self._input.getText((localctx.s.st= art, localctx.s.stop))), (None if localctx.t is None else self._input.getTe= xt((localctx.t.start, localctx.t.stop)))) =20 pass else: @@ -1284,39 +1263,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def init_declarator(self,i=3DNone): + def init_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Init_declaratorCo= ntext) else: - return self.getTypedRuleContext(CParser.Init_declaratorCon= text,i) - + return self.getTypedRuleContext(CParser.Init_declaratorCon= text, i) =20 def getRuleIndex(self): return CParser.RULE_init_declarator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInit_declarator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterInit_declarator_list"): listener.enterInit_declarator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInit_declarator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitInit_declarator_list"): listener.exitInit_declarator_list(self) =20 - - - def init_declarator_list(self): =20 - localctx =3D CParser.Init_declarator_listContext(self, self._ctx, = self.state) + localctx =3D CParser.Init_declarator_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 10, self.RULE_init_declarator_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 208 @@ -1324,7 +1300,7 @@ class CParser ( Parser ): self.state =3D 213 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 209 self.match(CParser.T__3) self.state =3D 210 @@ -1345,39 +1321,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def initializer(self): - return self.getTypedRuleContext(CParser.InitializerContext,0) - + return self.getTypedRuleContext(CParser.InitializerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_init_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInit_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterInit_declarator"): listener.enterInit_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInit_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitInit_declarator"): listener.exitInit_declarator(self) =20 - - - def init_declarator(self): =20 localctx =3D CParser.Init_declaratorContext(self, self._ctx, self.= state) self.enterRule(localctx, 12, self.RULE_init_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 216 @@ -1385,13 +1356,12 @@ class CParser ( Parser ): self.state =3D 219 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__4: + if _la =3D=3D CParser.T__4: self.state =3D 217 self.match(CParser.T__4) self.state =3D 218 self.initializer() =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1404,32 +1374,29 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_storage_class_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStorage_class_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterStorage_class_specifier"): listener.enterStorage_class_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStorage_class_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitStorage_class_specifier"): listener.exitStorage_class_specifier(self) =20 - - - def storage_class_specifier(self): =20 - localctx =3D CParser.Storage_class_specifierContext(self, self._ct= x, self.state) + localctx =3D CParser.Storage_class_specifierContext( + self, self._ctx, self.state) self.enterRule(localctx, 14, self.RULE_storage_class_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 221 @@ -1451,55 +1418,47 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.s =3D None # Struct_or_union_specifierContext - self.e =3D None # Enum_specifierContext + self.s =3D None # Struct_or_union_specifierContext + self.e =3D None # Enum_specifierContext =20 def struct_or_union_specifier(self): - return self.getTypedRuleContext(CParser.Struct_or_union_specif= ierContext,0) - + return self.getTypedRuleContext(CParser.Struct_or_union_specif= ierContext, 0) =20 def enum_specifier(self): - return self.getTypedRuleContext(CParser.Enum_specifierContext,= 0) - + return self.getTypedRuleContext(CParser.Enum_specifierContext,= 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def type_id(self): - return self.getTypedRuleContext(CParser.Type_idContext,0) - + return self.getTypedRuleContext(CParser.Type_idContext, 0) =20 def getRuleIndex(self): return CParser.RULE_type_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_specifier"): listener.enterType_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_specifier"): listener.exitType_specifier(self) =20 - - - def type_specifier(self): =20 localctx =3D CParser.Type_specifierContext(self, self._ctx, self.s= tate) @@ -1507,7 +1466,7 @@ class CParser ( Parser ): try: self.state =3D 247 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,16,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 16, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 223 @@ -1568,7 +1527,8 @@ class CParser ( Parser ): localctx.s =3D self.struct_or_union_specifier() =20 if localctx.s.stop is not None: - self.StoreStructUnionDefinition((None if localctx.s is= None else localctx.s.start).line, (None if localctx.s is None else localct= x.s.start).column, (None if localctx.s is None else localctx.s.stop).line, = (None if localctx.s is None else localctx.s.stop).column, (None if localctx= .s is None else self._input.getText((localctx.s.start,localctx.s.stop)))) + self.StoreStructUnionDefinition((None if localctx.s is= None else localctx.s.start).line, (None if localctx.s is None else localct= x.s.start).column, (None if localctx.s is None else localctx.s.stop).line, ( + None if localctx.s is None else localctx.s.stop).c= olumn, (None if localctx.s is None else self._input.getText((localctx.s.sta= rt, localctx.s.stop)))) =20 pass =20 @@ -1578,7 +1538,8 @@ class CParser ( Parser ): localctx.e =3D self.enum_specifier() =20 if localctx.e.stop is not None: - self.StoreEnumerationDefinition((None if localctx.e is= None else localctx.e.start).line, (None if localctx.e is None else localct= x.e.start).column, (None if localctx.e is None else localctx.e.stop).line, = (None if localctx.e is None else localctx.e.stop).column, (None if localctx= .e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StoreEnumerationDefinition((None if localctx.e is= None else localctx.e.start).line, (None if localctx.e is None else localct= x.e.start).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).c= olumn, (None if localctx.e is None else self._input.getText((localctx.e.sta= rt, localctx.e.stop)))) =20 pass =20 @@ -1588,14 +1549,15 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) self.state =3D 242 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,15,self.= _ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 15, sel= f._ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 239 self.type_qualifier() self.state =3D 244 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,15,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 15, self._ctx) =20 self.state =3D 245 self.declarator() @@ -1607,7 +1569,6 @@ class CParser ( Parser ): self.type_id() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1620,7 +1581,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -1631,18 +1592,15 @@ class CParser ( Parser ): return CParser.RULE_type_id =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_id" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_id"): listener.enterType_id(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_id" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_id"): listener.exitType_id(self) =20 - - - def type_id(self): =20 localctx =3D CParser.Type_idContext(self, self._ctx, self.state) @@ -1663,17 +1621,15 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def struct_or_union(self): - return self.getTypedRuleContext(CParser.Struct_or_unionContext= ,0) - + return self.getTypedRuleContext(CParser.Struct_or_unionContext= , 0) =20 def struct_declaration_list(self): - return self.getTypedRuleContext(CParser.Struct_declaration_lis= tContext,0) - + return self.getTypedRuleContext(CParser.Struct_declaration_lis= tContext, 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) @@ -1682,27 +1638,25 @@ class CParser ( Parser ): return CParser.RULE_struct_or_union_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_or_union_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_or_union_specifier"): listener.enterStruct_or_union_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_or_union_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_or_union_specifier"): listener.exitStruct_or_union_specifier(self) =20 - - - def struct_or_union_specifier(self): =20 - localctx =3D CParser.Struct_or_union_specifierContext(self, self._= ctx, self.state) + localctx =3D CParser.Struct_or_union_specifierContext( + self, self._ctx, self.state) self.enterRule(localctx, 20, self.RULE_struct_or_union_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 262 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,18,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 18, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 251 @@ -1710,11 +1664,10 @@ class CParser ( Parser ): self.state =3D 253 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.IDENTIFIER: + if _la =3D=3D CParser.IDENTIFIER: self.state =3D 252 self.match(CParser.IDENTIFIER) =20 - self.state =3D 255 self.match(CParser.T__0) self.state =3D 256 @@ -1731,7 +1684,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1744,37 +1696,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_struct_or_union =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_or_union" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_or_union"): listener.enterStruct_or_union(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_or_union" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_or_union"): listener.exitStruct_or_union(self) =20 - - - def struct_or_union(self): =20 localctx =3D CParser.Struct_or_unionContext(self, self._ctx, self.= state) self.enterRule(localctx, 22, self.RULE_struct_or_union) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 264 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__20 or _la=3D=3DCParser.T__21): + if not(_la =3D=3D CParser.T__20 or _la =3D=3D CParser.T__21): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1791,39 +1739,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def struct_declaration(self,i=3DNone): + def struct_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Struct_declaratio= nContext) else: - return self.getTypedRuleContext(CParser.Struct_declaration= Context,i) - + return self.getTypedRuleContext(CParser.Struct_declaration= Context, i) =20 def getRuleIndex(self): return CParser.RULE_struct_declaration_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declaration_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declaration_list"): listener.enterStruct_declaration_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declaration_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declaration_list"): listener.exitStruct_declaration_list(self) =20 - - - def struct_declaration_list(self): =20 - localctx =3D CParser.Struct_declaration_listContext(self, self._ct= x, self.state) + localctx =3D CParser.Struct_declaration_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 24, self.RULE_struct_declaration_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 267 @@ -1835,7 +1780,7 @@ class CParser ( Parser ): self.state =3D 269 self._errHandler.sync(self) _la =3D self._input.LA(1) - if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 <<= CParser.T__10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CPars= er.T__13) | (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__= 16) | (1 << CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | = (1 << CParser.T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << = CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParse= r.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__3= 1) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (= 1 << CParser.T__35) | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.ID= ENTIFIER): + if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 <<= CParser.T__10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CPars= er.T__13) | (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__= 16) | (1 << CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | = (1 << CParser.T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << = CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParse= r.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__3= 1) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (= 1 << CParser.T__35) | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.= IDENTIFIER): break =20 except RecognitionException as re: @@ -1850,37 +1795,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def specifier_qualifier_list(self): - return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext,0) - + return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext, 0) =20 def struct_declarator_list(self): - return self.getTypedRuleContext(CParser.Struct_declarator_list= Context,0) - + return self.getTypedRuleContext(CParser.Struct_declarator_list= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_struct_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declaration"): listener.enterStruct_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declaration"): listener.exitStruct_declaration(self) =20 - - - def struct_declaration(self): =20 - localctx =3D CParser.Struct_declarationContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Struct_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 26, self.RULE_struct_declaration) try: self.enterOuterAlt(localctx, 1) @@ -1902,52 +1843,48 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 # @param i=3DNone Type: int - def type_specifier(self,i=3DNone): + def type_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_specifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_specifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_specifierCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_specifier_qualifier_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterSpecifier_qualifier_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterSpecifier_qualifier_list"): listener.enterSpecifier_qualifier_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitSpecifier_qualifier_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitSpecifier_qualifier_list"): listener.exitSpecifier_qualifier_list(self) =20 - - - def specifier_qualifier_list(self): =20 - localctx =3D CParser.Specifier_qualifier_listContext(self, self._c= tx, self.state) + localctx =3D CParser.Specifier_qualifier_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 28, self.RULE_specifier_qualifier_list) try: self.enterOuterAlt(localctx, 1) self.state =3D 277 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 277 self._errHandler.sync(self) @@ -1963,12 +1900,11 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - else: raise NoViableAltException(self) self.state =3D 279 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,21,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 21, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -1982,39 +1918,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def struct_declarator(self,i=3DNone): + def struct_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Struct_declarator= Context) else: - return self.getTypedRuleContext(CParser.Struct_declaratorC= ontext,i) - + return self.getTypedRuleContext(CParser.Struct_declaratorC= ontext, i) =20 def getRuleIndex(self): return CParser.RULE_struct_declarator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declarator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declarator_list"): listener.enterStruct_declarator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declarator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declarator_list"): listener.exitStruct_declarator_list(self) =20 - - - def struct_declarator_list(self): =20 - localctx =3D CParser.Struct_declarator_listContext(self, self._ctx= , self.state) + localctx =3D CParser.Struct_declarator_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 30, self.RULE_struct_declarator_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 281 @@ -2022,7 +1955,7 @@ class CParser ( Parser ): self.state =3D 286 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 282 self.match(CParser.T__3) self.state =3D 283 @@ -2043,39 +1976,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_struct_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declarator"): listener.enterStruct_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declarator"): listener.exitStruct_declarator(self) =20 - - - def struct_declarator(self): =20 - localctx =3D CParser.Struct_declaratorContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Struct_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 32, self.RULE_struct_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 296 self._errHandler.sync(self) @@ -2087,13 +2016,12 @@ class CParser ( Parser ): self.state =3D 292 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__22: + if _la =3D=3D CParser.T__22: self.state =3D 290 self.match(CParser.T__22) self.state =3D 291 self.constant_expression() =20 - pass elif token in [CParser.T__22]: self.enterOuterAlt(localctx, 2) @@ -2117,13 +2045,12 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def enumerator_list(self): - return self.getTypedRuleContext(CParser.Enumerator_listContext= ,0) - + return self.getTypedRuleContext(CParser.Enumerator_listContext= , 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) @@ -2132,27 +2059,24 @@ class CParser ( Parser ): return CParser.RULE_enum_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnum_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnum_specifier"): listener.enterEnum_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnum_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnum_specifier"): listener.exitEnum_specifier(self) =20 - - - def enum_specifier(self): =20 localctx =3D CParser.Enum_specifierContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 34, self.RULE_enum_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 317 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,27,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 27, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 298 @@ -2164,11 +2088,10 @@ class CParser ( Parser ): self.state =3D 302 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 301 self.match(CParser.T__3) =20 - self.state =3D 304 self.match(CParser.T__19) pass @@ -2186,11 +2109,10 @@ class CParser ( Parser ): self.state =3D 311 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 310 self.match(CParser.T__3) =20 - self.state =3D 313 self.match(CParser.T__19) pass @@ -2203,7 +2125,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2216,34 +2137,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def enumerator(self,i=3DNone): + def enumerator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.EnumeratorContext) else: - return self.getTypedRuleContext(CParser.EnumeratorContext,= i) - + return self.getTypedRuleContext(CParser.EnumeratorContext,= i) =20 def getRuleIndex(self): return CParser.RULE_enumerator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnumerator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnumerator_list"): listener.enterEnumerator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnumerator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnumerator_list"): listener.exitEnumerator_list(self) =20 - - - def enumerator_list(self): =20 localctx =3D CParser.Enumerator_listContext(self, self._ctx, self.= state) @@ -2254,16 +2171,16 @@ class CParser ( Parser ): self.enumerator() self.state =3D 324 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,28,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 28, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 320 self.match(CParser.T__3) self.state =3D 321 self.enumerator() self.state =3D 326 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,28,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 28, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -2277,7 +2194,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -2285,30 +2202,26 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_enumerator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnumerator" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnumerator"): listener.enterEnumerator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnumerator" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnumerator"): listener.exitEnumerator(self) =20 - - - def enumerator(self): =20 localctx =3D CParser.EnumeratorContext(self, self._ctx, self.state) self.enterRule(localctx, 38, self.RULE_enumerator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 327 @@ -2316,13 +2229,12 @@ class CParser ( Parser ): self.state =3D 330 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__4: + if _la =3D=3D CParser.T__4: self.state =3D 328 self.match(CParser.T__4) self.state =3D 329 self.constant_expression() =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2335,32 +2247,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_type_qualifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_qualifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_qualifier"): listener.enterType_qualifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_qualifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_qualifier"): listener.exitType_qualifier(self) =20 - - - def type_qualifier(self): =20 localctx =3D CParser.Type_qualifierContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 40, self.RULE_type_qualifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 332 @@ -2382,77 +2290,68 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def direct_declarator(self): - return self.getTypedRuleContext(CParser.Direct_declaratorConte= xt,0) - + return self.getTypedRuleContext(CParser.Direct_declaratorConte= xt, 0) =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclarator"): listener.enterDeclarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclarator"): listener.exitDeclarator(self) =20 - - - def declarator(self): =20 localctx =3D CParser.DeclaratorContext(self, self._ctx, self.state) self.enterRule(localctx, 42, self.RULE_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 348 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,34,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 34, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 335 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__41: + if _la =3D=3D CParser.T__41: self.state =3D 334 self.pointer() =20 - self.state =3D 338 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__33: + if _la =3D=3D CParser.T__33: self.state =3D 337 self.match(CParser.T__33) =20 - self.state =3D 341 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__34: + if _la =3D=3D CParser.T__34: self.state =3D 340 self.match(CParser.T__34) =20 - self.state =3D 344 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__35: + if _la =3D=3D CParser.T__35: self.state =3D 343 self.match(CParser.T__35) =20 - self.state =3D 346 self.direct_declarator() pass @@ -2463,7 +2362,6 @@ class CParser ( Parser ): self.pointer() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2476,7 +2374,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -2484,36 +2382,32 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def declarator_suffix(self,i=3DNone): + def declarator_suffix(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Declarator_suffix= Context) else: - return self.getTypedRuleContext(CParser.Declarator_suffixC= ontext,i) - + return self.getTypedRuleContext(CParser.Declarator_suffixC= ontext, i) =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def getRuleIndex(self): return CParser.RULE_direct_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDirect_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDirect_declarator"): listener.enterDirect_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDirect_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDirect_declarator"): listener.exitDirect_declarator(self) =20 - - - def direct_declarator(self): =20 - localctx =3D CParser.Direct_declaratorContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Direct_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 44, self.RULE_direct_declarator) try: self.state =3D 368 @@ -2525,14 +2419,15 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) self.state =3D 354 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,35,self.= _ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 35, sel= f._ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 351 self.declarator_suffix() self.state =3D 356 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,35,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 35, self._ctx) =20 pass elif token in [CParser.T__37]: @@ -2541,12 +2436,11 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 359 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,36,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 36, self= ._ctx) if la_ =3D=3D 1: self.state =3D 358 self.match(CParser.T__33) =20 - self.state =3D 361 self.declarator() self.state =3D 362 @@ -2554,7 +2448,7 @@ class CParser ( Parser ): self.state =3D 364 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 363 self.declarator_suffix() @@ -2563,7 +2457,8 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 366 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,37,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 37, self._ctx) =20 pass else: @@ -2581,46 +2476,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def parameter_type_list(self): - return self.getTypedRuleContext(CParser.Parameter_type_listCon= text,0) - + return self.getTypedRuleContext(CParser.Parameter_type_listCon= text, 0) =20 def identifier_list(self): - return self.getTypedRuleContext(CParser.Identifier_listContext= ,0) - + return self.getTypedRuleContext(CParser.Identifier_listContext= , 0) =20 def getRuleIndex(self): return CParser.RULE_declarator_suffix =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclarator_suffix" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclarator_suffix"): listener.enterDeclarator_suffix(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclarator_suffix" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclarator_suffix"): listener.exitDeclarator_suffix(self) =20 - - - def declarator_suffix(self): =20 - localctx =3D CParser.Declarator_suffixContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Declarator_suffixContext( + self, self._ctx, self.state) self.enterRule(localctx, 46, self.RULE_declarator_suffix) try: self.state =3D 386 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,39,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 39, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 370 @@ -2667,7 +2557,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2680,38 +2569,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_pointer =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPointer" ): + def enterRule(self, listener): + if hasattr(listener, "enterPointer"): listener.enterPointer(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPointer" ): + def exitRule(self, listener): + if hasattr(listener, "exitPointer"): listener.exitPointer(self) =20 - - - def pointer(self): =20 localctx =3D CParser.PointerContext(self, self._ctx, self.state) @@ -2719,7 +2603,7 @@ class CParser ( Parser ): try: self.state =3D 400 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,42,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 42, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 388 @@ -2727,7 +2611,7 @@ class CParser ( Parser ): self.state =3D 390 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 389 self.type_qualifier() @@ -2736,16 +2620,16 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 392 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,40,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 40, self._ctx) =20 self.state =3D 395 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,41,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 41, self= ._ctx) if la_ =3D=3D 1: self.state =3D 394 self.pointer() =20 - pass =20 elif la_ =3D=3D 2: @@ -2762,7 +2646,6 @@ class CParser ( Parser ): self.match(CParser.T__41) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2775,35 +2658,32 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def parameter_list(self): - return self.getTypedRuleContext(CParser.Parameter_listContext,= 0) - + return self.getTypedRuleContext(CParser.Parameter_listContext,= 0) =20 def getRuleIndex(self): return CParser.RULE_parameter_type_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_type_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_type_list"): listener.enterParameter_type_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_type_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_type_list"): listener.exitParameter_type_list(self) =20 - - - def parameter_type_list(self): =20 - localctx =3D CParser.Parameter_type_listContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Parameter_type_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 50, self.RULE_parameter_type_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 402 @@ -2811,21 +2691,19 @@ class CParser ( Parser ): self.state =3D 408 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 403 self.match(CParser.T__3) self.state =3D 405 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 404 self.match(CParser.T__28) =20 - self.state =3D 407 self.match(CParser.T__42) =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2838,34 +2716,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def parameter_declaration(self,i=3DNone): + def parameter_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Parameter_declara= tionContext) else: - return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext,i) - + return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_parameter_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_list"): listener.enterParameter_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_list"): listener.exitParameter_list(self) =20 - - - def parameter_list(self): =20 localctx =3D CParser.Parameter_listContext(self, self._ctx, self.s= tate) @@ -2876,24 +2750,24 @@ class CParser ( Parser ): self.parameter_declaration() self.state =3D 418 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,46,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 46, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 411 self.match(CParser.T__3) self.state =3D 413 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,45,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 45, self._ctx) if la_ =3D=3D 1: self.state =3D 412 self.match(CParser.T__28) =20 - self.state =3D 415 self.parameter_declaration() self.state =3D 420 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,46,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 46, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -2907,66 +2781,60 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declarator(self,i=3DNone): + def declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclaratorContext) else: - return self.getTypedRuleContext(CParser.DeclaratorContext,= i) - + return self.getTypedRuleContext(CParser.DeclaratorContext,= i) =20 # @param i=3DNone Type: int - def abstract_declarator(self,i=3DNone): + def abstract_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Abstract_declarat= orContext) else: - return self.getTypedRuleContext(CParser.Abstract_declarato= rContext,i) - + return self.getTypedRuleContext(CParser.Abstract_declarato= rContext, i) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def pointer(self,i=3DNone): + def pointer(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.PointerContext) else: - return self.getTypedRuleContext(CParser.PointerContext,i) - + return self.getTypedRuleContext(CParser.PointerContext, i) =20 def getRuleIndex(self): return CParser.RULE_parameter_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_declaration"): listener.enterParameter_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_declaration"): listener.exitParameter_declaration(self) =20 - - - def parameter_declaration(self): =20 - localctx =3D CParser.Parameter_declarationContext(self, self._ctx,= self.state) + localctx =3D CParser.Parameter_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 54, self.RULE_parameter_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 439 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,51,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 51, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 421 @@ -2977,7 +2845,8 @@ class CParser ( Parser ): while ((((_la - 34)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 3= 4)) & ((1 << (CParser.T__33 - 34)) | (1 << (CParser.T__34 - 34)) | (1 << (C= Parser.T__35 - 34)) | (1 << (CParser.T__37 - 34)) | (1 << (CParser.T__39 - = 34)) | (1 << (CParser.T__41 - 34)) | (1 << (CParser.IDENTIFIER - 34)))) != =3D 0): self.state =3D 424 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,47,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 47, self._ctx) if la_ =3D=3D 1: self.state =3D 422 self.declarator() @@ -2988,7 +2857,6 @@ class CParser ( Parser ): self.abstract_declarator() pass =20 - self.state =3D 428 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -2996,11 +2864,10 @@ class CParser ( Parser ): self.state =3D 430 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 429 self.match(CParser.T__28) =20 - pass =20 elif la_ =3D=3D 2: @@ -3008,7 +2875,7 @@ class CParser ( Parser ): self.state =3D 435 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__41: + while _la =3D=3D CParser.T__41: self.state =3D 432 self.pointer() self.state =3D 437 @@ -3019,7 +2886,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3032,12 +2898,12 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: @@ -3047,23 +2913,20 @@ class CParser ( Parser ): return CParser.RULE_identifier_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterIdentifier_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterIdentifier_list"): listener.enterIdentifier_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitIdentifier_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitIdentifier_list"): listener.exitIdentifier_list(self) =20 - - - def identifier_list(self): =20 localctx =3D CParser.Identifier_listContext(self, self._ctx, self.= state) self.enterRule(localctx, 56, self.RULE_identifier_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 441 @@ -3071,7 +2934,7 @@ class CParser ( Parser ): self.state =3D 446 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 442 self.match(CParser.T__3) self.state =3D 443 @@ -3092,47 +2955,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def specifier_qualifier_list(self): - return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext,0) - + return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext, 0) =20 def abstract_declarator(self): - return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text,0) - + return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text, 0) =20 def type_id(self): - return self.getTypedRuleContext(CParser.Type_idContext,0) - + return self.getTypedRuleContext(CParser.Type_idContext, 0) =20 def getRuleIndex(self): return CParser.RULE_type_name =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_name" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_name"): listener.enterType_name(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_name" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_name"): listener.exitType_name(self) =20 - - - def type_name(self): =20 localctx =3D CParser.Type_nameContext(self, self._ctx, self.state) self.enterRule(localctx, 58, self.RULE_type_name) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 454 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,54,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 54, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 449 @@ -3144,7 +3001,6 @@ class CParser ( Parser ): self.state =3D 450 self.abstract_declarator() =20 - pass =20 elif la_ =3D=3D 2: @@ -3153,7 +3009,6 @@ class CParser ( Parser ): self.type_id() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3166,37 +3021,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def direct_abstract_declarator(self): - return self.getTypedRuleContext(CParser.Direct_abstract_declar= atorContext,0) - + return self.getTypedRuleContext(CParser.Direct_abstract_declar= atorContext, 0) =20 def getRuleIndex(self): return CParser.RULE_abstract_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAbstract_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterAbstract_declarator"): listener.enterAbstract_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAbstract_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitAbstract_declarator"): listener.exitAbstract_declarator(self) =20 - - - def abstract_declarator(self): =20 - localctx =3D CParser.Abstract_declaratorContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Abstract_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 60, self.RULE_abstract_declarator) try: self.state =3D 461 @@ -3208,12 +3059,11 @@ class CParser ( Parser ): self.pointer() self.state =3D 458 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,55,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 55, self= ._ctx) if la_ =3D=3D 1: self.state =3D 457 self.direct_abstract_declarator() =20 - pass elif token in [CParser.T__37, CParser.T__39]: self.enterOuterAlt(localctx, 2) @@ -3235,46 +3085,43 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def abstract_declarator(self): - return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text,0) - + return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text, 0) =20 # @param i=3DNone Type: int - def abstract_declarator_suffix(self,i=3DNone): + def abstract_declarator_suffix(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Abstract_declarat= or_suffixContext) else: - return self.getTypedRuleContext(CParser.Abstract_declarato= r_suffixContext,i) - + return self.getTypedRuleContext(CParser.Abstract_declarato= r_suffixContext, i) =20 def getRuleIndex(self): return CParser.RULE_direct_abstract_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDirect_abstract_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDirect_abstract_declarator"): listener.enterDirect_abstract_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDirect_abstract_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDirect_abstract_declarator"): listener.exitDirect_abstract_declarator(self) =20 - - def direct_abstract_declarator(self): =20 - localctx =3D CParser.Direct_abstract_declaratorContext(self, self.= _ctx, self.state) + localctx =3D CParser.Direct_abstract_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 62, self.RULE_direct_abstract_declarator) try: self.enterOuterAlt(localctx, 1) self.state =3D 468 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,57,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 57, self._ct= x) if la_ =3D=3D 1: self.state =3D 463 self.match(CParser.T__37) @@ -3289,17 +3136,16 @@ class CParser ( Parser ): self.abstract_declarator_suffix() pass =20 - self.state =3D 473 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,58,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 58, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 470 self.abstract_declarator_suffix() self.state =3D 475 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,58,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 58, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -3313,42 +3159,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def parameter_type_list(self): - return self.getTypedRuleContext(CParser.Parameter_type_listCon= text,0) - + return self.getTypedRuleContext(CParser.Parameter_type_listCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_abstract_declarator_suffix =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAbstract_declarator_suffix" ): + def enterRule(self, listener): + if hasattr(listener, "enterAbstract_declarator_suffix"): listener.enterAbstract_declarator_suffix(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAbstract_declarator_suffix" ): + def exitRule(self, listener): + if hasattr(listener, "exitAbstract_declarator_suffix"): listener.exitAbstract_declarator_suffix(self) =20 - - - def abstract_declarator_suffix(self): =20 - localctx =3D CParser.Abstract_declarator_suffixContext(self, self.= _ctx, self.state) + localctx =3D CParser.Abstract_declarator_suffixContext( + self, self._ctx, self.state) self.enterRule(localctx, 64, self.RULE_abstract_declarator_suffix) try: self.state =3D 488 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,59,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 59, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 476 @@ -3385,7 +3227,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3398,39 +3239,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def assignment_expression(self): - return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext, 0) =20 def initializer_list(self): - return self.getTypedRuleContext(CParser.Initializer_listContex= t,0) - + return self.getTypedRuleContext(CParser.Initializer_listContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_initializer =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInitializer" ): + def enterRule(self, listener): + if hasattr(listener, "enterInitializer"): listener.enterInitializer(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInitializer" ): + def exitRule(self, listener): + if hasattr(listener, "exitInitializer"): listener.exitInitializer(self) =20 - - - def initializer(self): =20 localctx =3D CParser.InitializerContext(self, self._ctx, self.stat= e) self.enterRule(localctx, 66, self.RULE_initializer) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 498 self._errHandler.sync(self) @@ -3449,11 +3285,10 @@ class CParser ( Parser ): self.state =3D 494 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 493 self.match(CParser.T__3) =20 - self.state =3D 496 self.match(CParser.T__19) pass @@ -3472,34 +3307,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def initializer(self,i=3DNone): + def initializer(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.InitializerContex= t) else: - return self.getTypedRuleContext(CParser.InitializerContext= ,i) - + return self.getTypedRuleContext(CParser.InitializerContext= , i) =20 def getRuleIndex(self): return CParser.RULE_initializer_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInitializer_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterInitializer_list"): listener.enterInitializer_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInitializer_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitInitializer_list"): listener.exitInitializer_list(self) =20 - - - def initializer_list(self): =20 localctx =3D CParser.Initializer_listContext(self, self._ctx, self= .state) @@ -3510,16 +3341,16 @@ class CParser ( Parser ): self.initializer() self.state =3D 505 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,62,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 62, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 501 self.match(CParser.T__3) self.state =3D 502 self.initializer() self.state =3D 507 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,62,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 62, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -3533,39 +3364,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def assignment_expression(self,i=3DNone): + def assignment_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Assignment_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Assignment_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Assignment_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_argument_expression_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterArgument_expression_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterArgument_expression_list"): listener.enterArgument_expression_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitArgument_expression_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitArgument_expression_list"): listener.exitArgument_expression_list(self) =20 - - - def argument_expression_list(self): =20 - localctx =3D CParser.Argument_expression_listContext(self, self._c= tx, self.state) + localctx =3D CParser.Argument_expression_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 70, self.RULE_argument_expression_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 508 @@ -3573,15 +3401,14 @@ class CParser ( Parser ): self.state =3D 510 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 509 self.match(CParser.T__28) =20 - self.state =3D 519 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 512 self.match(CParser.T__3) self.state =3D 513 @@ -3589,11 +3416,10 @@ class CParser ( Parser ): self.state =3D 515 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 514 self.match(CParser.T__28) =20 - self.state =3D 521 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -3610,39 +3436,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def multiplicative_expression(self,i=3DNone): + def multiplicative_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Multiplicative_ex= pressionContext) else: - return self.getTypedRuleContext(CParser.Multiplicative_exp= ressionContext,i) - + return self.getTypedRuleContext(CParser.Multiplicative_exp= ressionContext, i) =20 def getRuleIndex(self): return CParser.RULE_additive_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAdditive_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAdditive_expression"): listener.enterAdditive_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAdditive_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAdditive_expression"): listener.exitAdditive_expression(self) =20 - - - def additive_expression(self): =20 - localctx =3D CParser.Additive_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Additive_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 72, self.RULE_additive_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 522 @@ -3650,7 +3473,7 @@ class CParser ( Parser ): self.state =3D 529 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__43 or _la=3D=3DCParser.T__44: + while _la =3D=3D CParser.T__43 or _la =3D=3D CParser.T__44: self.state =3D 527 self._errHandler.sync(self) token =3D self._input.LA(1) @@ -3685,39 +3508,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def cast_expression(self,i=3DNone): + def cast_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Cast_expressionCo= ntext) else: - return self.getTypedRuleContext(CParser.Cast_expressionCon= text,i) - + return self.getTypedRuleContext(CParser.Cast_expressionCon= text, i) =20 def getRuleIndex(self): return CParser.RULE_multiplicative_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMultiplicative_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterMultiplicative_expression"): listener.enterMultiplicative_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMultiplicative_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitMultiplicative_expression"): listener.exitMultiplicative_expression(self) =20 - - - def multiplicative_expression(self): =20 - localctx =3D CParser.Multiplicative_expressionContext(self, self._= ctx, self.state) + localctx =3D CParser.Multiplicative_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 74, self.RULE_multiplicative_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 532 @@ -3766,38 +3586,32 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def type_name(self): - return self.getTypedRuleContext(CParser.Type_nameContext,0) - + return self.getTypedRuleContext(CParser.Type_nameContext, 0) =20 def cast_expression(self): - return self.getTypedRuleContext(CParser.Cast_expressionContext= ,0) - + return self.getTypedRuleContext(CParser.Cast_expressionContext= , 0) =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_cast_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterCast_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterCast_expression"): listener.enterCast_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitCast_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitCast_expression"): listener.exitCast_expression(self) =20 - - - def cast_expression(self): =20 localctx =3D CParser.Cast_expressionContext(self, self._ctx, self.= state) @@ -3805,7 +3619,7 @@ class CParser ( Parser ): try: self.state =3D 550 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,70,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 70, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 544 @@ -3824,7 +3638,6 @@ class CParser ( Parser ): self.unary_expression() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3837,46 +3650,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def postfix_expression(self): - return self.getTypedRuleContext(CParser.Postfix_expressionCont= ext,0) - + return self.getTypedRuleContext(CParser.Postfix_expressionCont= ext, 0) =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def unary_operator(self): - return self.getTypedRuleContext(CParser.Unary_operatorContext,= 0) - + return self.getTypedRuleContext(CParser.Unary_operatorContext,= 0) =20 def cast_expression(self): - return self.getTypedRuleContext(CParser.Cast_expressionContext= ,0) - + return self.getTypedRuleContext(CParser.Cast_expressionContext= , 0) =20 def type_name(self): - return self.getTypedRuleContext(CParser.Type_nameContext,0) - + return self.getTypedRuleContext(CParser.Type_nameContext, 0) =20 def getRuleIndex(self): return CParser.RULE_unary_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterUnary_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterUnary_expression"): listener.enterUnary_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitUnary_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitUnary_expression"): listener.exitUnary_expression(self) =20 - - - def unary_expression(self): =20 localctx =3D CParser.Unary_expressionContext(self, self._ctx, self= .state) @@ -3884,7 +3689,7 @@ class CParser ( Parser ): try: self.state =3D 567 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,71,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 71, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 552 @@ -3935,7 +3740,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3948,48 +3752,44 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser self.FuncCallText =3D '' - self.p =3D None # Primary_expressionContext - self.a =3D None # Token - self.c =3D None # Argument_expression_listContext - self.b =3D None # Token - self.x =3D None # Token - self.y =3D None # Token - self.z =3D None # Token + self.p =3D None # Primary_expressionContext + self.a =3D None # Token + self.c =3D None # Argument_expression_listContext + self.b =3D None # Token + self.x =3D None # Token + self.y =3D None # Token + self.z =3D None # Token =20 def primary_expression(self): - return self.getTypedRuleContext(CParser.Primary_expressionCont= ext,0) - + return self.getTypedRuleContext(CParser.Primary_expressionCont= ext, 0) =20 # @param i=3DNone Type: int - def expression(self,i=3DNone): + def expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.ExpressionContext) else: - return self.getTypedRuleContext(CParser.ExpressionContext,= i) - + return self.getTypedRuleContext(CParser.ExpressionContext,= i) =20 # @param i=3DNone Type: int - def macro_parameter_list(self,i=3DNone): + def macro_parameter_list(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Macro_parameter_l= istContext) else: - return self.getTypedRuleContext(CParser.Macro_parameter_li= stContext,i) - + return self.getTypedRuleContext(CParser.Macro_parameter_li= stContext, i) =20 # @param i=3DNone Type: int - def argument_expression_list(self,i=3DNone): + def argument_expression_list(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Argument_expressi= on_listContext) else: - return self.getTypedRuleContext(CParser.Argument_expressio= n_listContext,i) - + return self.getTypedRuleContext(CParser.Argument_expressio= n_listContext, i) =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: @@ -3999,38 +3799,38 @@ class CParser ( Parser ): return CParser.RULE_postfix_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPostfix_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterPostfix_expression"): listener.enterPostfix_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPostfix_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitPostfix_expression"): listener.exitPostfix_expression(self) =20 - - - def postfix_expression(self): =20 - localctx =3D CParser.Postfix_expressionContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Postfix_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 80, self.RULE_postfix_expression) =20 - self.FuncCallText=3D'' + self.FuncCallText =3D '' =20 try: self.enterOuterAlt(localctx, 1) self.state =3D 569 localctx.p =3D self.primary_expression() - self.FuncCallText +=3D (None if localctx.p is None else self._= input.getText((localctx.p.start,localctx.p.stop))) + self.FuncCallText +=3D (None if localctx.p is None else self._= input.getText( + (localctx.p.start, localctx.p.stop))) self.state =3D 600 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,73,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 73, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 598 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,72,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 72, self._ctx) if la_ =3D=3D 1: self.state =3D 571 self.match(CParser.T__39) @@ -4045,7 +3845,8 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 576 localctx.a =3D self.match(CParser.T__38) - self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, (0 if localctx.a is None else localctx.a.line), localctx.a= .column, self.FuncCallText, '') + self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, ( + 0 if localctx.a is None else localctx.a.line),= localctx.a.column, self.FuncCallText, '') pass =20 elif la_ =3D=3D 3: @@ -4055,7 +3856,8 @@ class CParser ( Parser ): localctx.c =3D self.argument_expression_list() self.state =3D 580 localctx.b =3D self.match(CParser.T__38) - self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, (0 if localctx.b is None else localctx.b.line), localctx.b= .column, self.FuncCallText, (None if localctx.c is None else self._input.ge= tText((localctx.c.start,localctx.c.stop)))) + self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, ( + 0 if localctx.b is None else localctx.b.line),= localctx.b.column, self.FuncCallText, (None if localctx.c is None else sel= f._input.getText((localctx.c.start, localctx.c.stop)))) pass =20 elif la_ =3D=3D 4: @@ -4072,7 +3874,8 @@ class CParser ( Parser ): self.match(CParser.T__50) self.state =3D 588 localctx.x =3D self.match(CParser.IDENTIFIER) - self.FuncCallText +=3D '.' + (None if localctx.x i= s None else localctx.x.text) + self.FuncCallText +=3D '.' + \ + (None if localctx.x is None else localctx.x.te= xt) pass =20 elif la_ =3D=3D 6: @@ -4080,7 +3883,8 @@ class CParser ( Parser ): self.match(CParser.T__41) self.state =3D 591 localctx.y =3D self.match(CParser.IDENTIFIER) - self.FuncCallText =3D (None if localctx.y is None = else localctx.y.text) + self.FuncCallText =3D ( + None if localctx.y is None else localctx.y.tex= t) pass =20 elif la_ =3D=3D 7: @@ -4088,7 +3892,8 @@ class CParser ( Parser ): self.match(CParser.T__51) self.state =3D 594 localctx.z =3D self.match(CParser.IDENTIFIER) - self.FuncCallText +=3D '->' + (None if localctx.z = is None else localctx.z.text) + self.FuncCallText +=3D '->' + \ + (None if localctx.z is None else localctx.z.te= xt) pass =20 elif la_ =3D=3D 8: @@ -4101,10 +3906,9 @@ class CParser ( Parser ): self.match(CParser.T__48) pass =20 - self.state =3D 602 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,73,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 73, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -4118,39 +3922,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def parameter_declaration(self,i=3DNone): + def parameter_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Parameter_declara= tionContext) else: - return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext,i) - + return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_macro_parameter_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMacro_parameter_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterMacro_parameter_list"): listener.enterMacro_parameter_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMacro_parameter_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitMacro_parameter_list"): listener.exitMacro_parameter_list(self) =20 - - - def macro_parameter_list(self): =20 - localctx =3D CParser.Macro_parameter_listContext(self, self._ctx, = self.state) + localctx =3D CParser.Macro_parameter_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 82, self.RULE_macro_parameter_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 603 @@ -4158,7 +3959,7 @@ class CParser ( Parser ): self.state =3D 608 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 604 self.match(CParser.T__3) self.state =3D 605 @@ -4179,32 +3980,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_unary_operator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterUnary_operator" ): + def enterRule(self, listener): + if hasattr(listener, "enterUnary_operator"): listener.enterUnary_operator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitUnary_operator" ): + def exitRule(self, listener): + if hasattr(listener, "exitUnary_operator"): listener.exitUnary_operator(self) =20 - - - def unary_operator(self): =20 localctx =3D CParser.Unary_operatorContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 84, self.RULE_unary_operator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 611 @@ -4226,7 +4023,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -4234,37 +4031,33 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def constant(self): - return self.getTypedRuleContext(CParser.ConstantContext,0) - + return self.getTypedRuleContext(CParser.ConstantContext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_primary_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPrimary_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterPrimary_expression"): listener.enterPrimary_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPrimary_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitPrimary_expression"): listener.exitPrimary_expression(self) =20 - - - def primary_expression(self): =20 - localctx =3D CParser.Primary_expressionContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Primary_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 86, self.RULE_primary_expression) try: self.state =3D 619 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,75,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 75, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 613 @@ -4287,7 +4080,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -4300,7 +4092,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -4317,14 +4109,14 @@ class CParser ( Parser ): return self.getToken(CParser.CHARACTER_LITERAL, 0) =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: return self.getToken(CParser.IDENTIFIER, i) =20 # @param i=3DNone Type: int - def STRING_LITERAL(self,i=3DNone): + def STRING_LITERAL(self, i=3DNone): if i is None: return self.getTokens(CParser.STRING_LITERAL) else: @@ -4337,23 +4129,20 @@ class CParser ( Parser ): return CParser.RULE_constant =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConstant" ): + def enterRule(self, listener): + if hasattr(listener, "enterConstant"): listener.enterConstant(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConstant" ): + def exitRule(self, listener): + if hasattr(listener, "exitConstant"): listener.exitConstant(self) =20 - - - def constant(self): =20 localctx =3D CParser.ConstantContext(self, self._ctx, self.state) self.enterRule(localctx, 88, self.RULE_constant) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 647 self._errHandler.sync(self) @@ -4383,12 +4172,12 @@ class CParser ( Parser ): self.state =3D 636 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 628 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.IDENTIFIER: + while _la =3D=3D CParser.IDENTIFIER: self.state =3D 625 self.match(CParser.IDENTIFIER) self.state =3D 630 @@ -4398,7 +4187,7 @@ class CParser ( Parser ): self.state =3D 632 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NU= MBER: if _alt =3D=3D 1: self.state =3D 631 self.match(CParser.STRING_LITERAL) @@ -4407,19 +4196,20 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 634 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._in= put,77,self._ctx) - + _alt =3D self._interp.adaptivePredict( + self._input, 77, self._ctx) =20 else: raise NoViableAltException(self) self.state =3D 638 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,78,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 78, self._ctx) =20 self.state =3D 643 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.IDENTIFIER: + while _la =3D=3D CParser.IDENTIFIER: self.state =3D 640 self.match(CParser.IDENTIFIER) self.state =3D 645 @@ -4447,39 +4237,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def assignment_expression(self,i=3DNone): + def assignment_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Assignment_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Assignment_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Assignment_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExpression" ): + def enterRule(self, listener): + if hasattr(listener, "enterExpression"): listener.enterExpression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExpression" ): + def exitRule(self, listener): + if hasattr(listener, "exitExpression"): listener.exitExpression(self) =20 - - - def expression(self): =20 localctx =3D CParser.ExpressionContext(self, self._ctx, self.state) self.enterRule(localctx, 90, self.RULE_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 649 @@ -4487,7 +4273,7 @@ class CParser ( Parser ): self.state =3D 654 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 650 self.match(CParser.T__3) self.state =3D 651 @@ -4508,33 +4294,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_constant_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConstant_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterConstant_expression"): listener.enterConstant_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConstant_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitConstant_expression"): listener.exitConstant_expression(self) =20 - - - def constant_expression(self): =20 - localctx =3D CParser.Constant_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Constant_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 92, self.RULE_constant_expression) try: self.enterOuterAlt(localctx, 1) @@ -4552,50 +4335,44 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def lvalue(self): - return self.getTypedRuleContext(CParser.LvalueContext,0) - + return self.getTypedRuleContext(CParser.LvalueContext, 0) =20 def assignment_operator(self): - return self.getTypedRuleContext(CParser.Assignment_operatorCon= text,0) - + return self.getTypedRuleContext(CParser.Assignment_operatorCon= text, 0) =20 def assignment_expression(self): - return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext, 0) =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_assignment_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAssignment_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAssignment_expression"): listener.enterAssignment_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAssignment_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAssignment_expression"): listener.exitAssignment_expression(self) =20 - - - def assignment_expression(self): =20 - localctx =3D CParser.Assignment_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Assignment_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 94, self.RULE_assignment_expression) try: self.state =3D 664 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,82,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 82, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 659 @@ -4612,7 +4389,6 @@ class CParser ( Parser ): self.conditional_expression() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -4625,30 +4401,26 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_lvalue =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLvalue" ): + def enterRule(self, listener): + if hasattr(listener, "enterLvalue"): listener.enterLvalue(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLvalue" ): + def exitRule(self, listener): + if hasattr(listener, "exitLvalue"): listener.exitLvalue(self) =20 - - - def lvalue(self): =20 localctx =3D CParser.LvalueContext(self, self._ctx, self.state) @@ -4669,32 +4441,29 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_assignment_operator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAssignment_operator" ): + def enterRule(self, listener): + if hasattr(listener, "enterAssignment_operator"): listener.enterAssignment_operator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAssignment_operator" ): + def exitRule(self, listener): + if hasattr(listener, "exitAssignment_operator"): listener.exitAssignment_operator(self) =20 - - - def assignment_operator(self): =20 - localctx =3D CParser.Assignment_operatorContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Assignment_operatorContext( + self, self._ctx, self.state) self.enterRule(localctx, 98, self.RULE_assignment_operator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 668 @@ -4716,44 +4485,39 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # Logical_or_expressionContext + self.e =3D None # Logical_or_expressionContext =20 def logical_or_expression(self): - return self.getTypedRuleContext(CParser.Logical_or_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Logical_or_expressionC= ontext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_conditional_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConditional_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterConditional_expression"): listener.enterConditional_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConditional_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitConditional_expression"): listener.exitConditional_expression(self) =20 - - - def conditional_expression(self): =20 - localctx =3D CParser.Conditional_expressionContext(self, self._ctx= , self.state) + localctx =3D CParser.Conditional_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 100, self.RULE_conditional_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 670 @@ -4761,7 +4525,7 @@ class CParser ( Parser ): self.state =3D 677 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__65: + if _la =3D=3D CParser.T__65: self.state =3D 671 self.match(CParser.T__65) self.state =3D 672 @@ -4770,8 +4534,8 @@ class CParser ( Parser ): self.match(CParser.T__22) self.state =3D 674 self.conditional_expression() - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) - + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) =20 except RecognitionException as re: localctx.exception =3D re @@ -4785,39 +4549,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def logical_and_expression(self,i=3DNone): + def logical_and_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Logical_and_expre= ssionContext) else: - return self.getTypedRuleContext(CParser.Logical_and_expres= sionContext,i) - + return self.getTypedRuleContext(CParser.Logical_and_expres= sionContext, i) =20 def getRuleIndex(self): return CParser.RULE_logical_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLogical_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterLogical_or_expression"): listener.enterLogical_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLogical_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitLogical_or_expression"): listener.exitLogical_or_expression(self) =20 - - - def logical_or_expression(self): =20 - localctx =3D CParser.Logical_or_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Logical_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 102, self.RULE_logical_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 679 @@ -4825,7 +4586,7 @@ class CParser ( Parser ): self.state =3D 684 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__66: + while _la =3D=3D CParser.T__66: self.state =3D 680 self.match(CParser.T__66) self.state =3D 681 @@ -4846,39 +4607,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def inclusive_or_expression(self,i=3DNone): + def inclusive_or_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Inclusive_or_expr= essionContext) else: - return self.getTypedRuleContext(CParser.Inclusive_or_expre= ssionContext,i) - + return self.getTypedRuleContext(CParser.Inclusive_or_expre= ssionContext, i) =20 def getRuleIndex(self): return CParser.RULE_logical_and_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLogical_and_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterLogical_and_expression"): listener.enterLogical_and_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLogical_and_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitLogical_and_expression"): listener.exitLogical_and_expression(self) =20 - - - def logical_and_expression(self): =20 - localctx =3D CParser.Logical_and_expressionContext(self, self._ctx= , self.state) + localctx =3D CParser.Logical_and_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 104, self.RULE_logical_and_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 687 @@ -4886,7 +4644,7 @@ class CParser ( Parser ): self.state =3D 692 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__67: + while _la =3D=3D CParser.T__67: self.state =3D 688 self.match(CParser.T__67) self.state =3D 689 @@ -4907,39 +4665,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def exclusive_or_expression(self,i=3DNone): + def exclusive_or_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Exclusive_or_expr= essionContext) else: - return self.getTypedRuleContext(CParser.Exclusive_or_expre= ssionContext,i) - + return self.getTypedRuleContext(CParser.Exclusive_or_expre= ssionContext, i) =20 def getRuleIndex(self): return CParser.RULE_inclusive_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInclusive_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterInclusive_or_expression"): listener.enterInclusive_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInclusive_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitInclusive_or_expression"): listener.exitInclusive_or_expression(self) =20 - - - def inclusive_or_expression(self): =20 - localctx =3D CParser.Inclusive_or_expressionContext(self, self._ct= x, self.state) + localctx =3D CParser.Inclusive_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 106, self.RULE_inclusive_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 695 @@ -4947,7 +4702,7 @@ class CParser ( Parser ): self.state =3D 700 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__68: + while _la =3D=3D CParser.T__68: self.state =3D 696 self.match(CParser.T__68) self.state =3D 697 @@ -4968,39 +4723,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def and_expression(self,i=3DNone): + def and_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.And_expressionCon= text) else: - return self.getTypedRuleContext(CParser.And_expressionCont= ext,i) - + return self.getTypedRuleContext(CParser.And_expressionCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_exclusive_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExclusive_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterExclusive_or_expression"): listener.enterExclusive_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExclusive_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitExclusive_or_expression"): listener.exitExclusive_or_expression(self) =20 - - - def exclusive_or_expression(self): =20 - localctx =3D CParser.Exclusive_or_expressionContext(self, self._ct= x, self.state) + localctx =3D CParser.Exclusive_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 108, self.RULE_exclusive_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 703 @@ -5008,7 +4760,7 @@ class CParser ( Parser ): self.state =3D 708 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__69: + while _la =3D=3D CParser.T__69: self.state =3D 704 self.match(CParser.T__69) self.state =3D 705 @@ -5029,39 +4781,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def equality_expression(self,i=3DNone): + def equality_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Equality_expressi= onContext) else: - return self.getTypedRuleContext(CParser.Equality_expressio= nContext,i) - + return self.getTypedRuleContext(CParser.Equality_expressio= nContext, i) =20 def getRuleIndex(self): return CParser.RULE_and_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAnd_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAnd_expression"): listener.enterAnd_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAnd_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAnd_expression"): listener.exitAnd_expression(self) =20 - - - def and_expression(self): =20 localctx =3D CParser.And_expressionContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 110, self.RULE_and_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 711 @@ -5069,7 +4817,7 @@ class CParser ( Parser ): self.state =3D 716 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__52: + while _la =3D=3D CParser.T__52: self.state =3D 712 self.match(CParser.T__52) self.state =3D 713 @@ -5090,39 +4838,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def relational_expression(self,i=3DNone): + def relational_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Relational_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Relational_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Relational_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_equality_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEquality_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterEquality_expression"): listener.enterEquality_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEquality_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitEquality_expression"): listener.exitEquality_expression(self) =20 - - - def equality_expression(self): =20 - localctx =3D CParser.Equality_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Equality_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 112, self.RULE_equality_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 719 @@ -5130,10 +4875,10 @@ class CParser ( Parser ): self.state =3D 724 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__70 or _la=3D=3DCParser.T__71: + while _la =3D=3D CParser.T__70 or _la =3D=3D CParser.T__71: self.state =3D 720 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__70 or _la=3D=3DCParser.T__71): + if not(_la =3D=3D CParser.T__70 or _la =3D=3D CParser.T__7= 1): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5156,39 +4901,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def shift_expression(self,i=3DNone): + def shift_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Shift_expressionC= ontext) else: - return self.getTypedRuleContext(CParser.Shift_expressionCo= ntext,i) - + return self.getTypedRuleContext(CParser.Shift_expressionCo= ntext, i) =20 def getRuleIndex(self): return CParser.RULE_relational_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterRelational_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterRelational_expression"): listener.enterRelational_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitRelational_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitRelational_expression"): listener.exitRelational_expression(self) =20 - - - def relational_expression(self): =20 - localctx =3D CParser.Relational_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Relational_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 114, self.RULE_relational_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 727 @@ -5222,39 +4964,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def additive_expression(self,i=3DNone): + def additive_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Additive_expressi= onContext) else: - return self.getTypedRuleContext(CParser.Additive_expressio= nContext,i) - + return self.getTypedRuleContext(CParser.Additive_expressio= nContext, i) =20 def getRuleIndex(self): return CParser.RULE_shift_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterShift_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterShift_expression"): listener.enterShift_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitShift_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitShift_expression"): listener.exitShift_expression(self) =20 - - - def shift_expression(self): =20 localctx =3D CParser.Shift_expressionContext(self, self._ctx, self= .state) self.enterRule(localctx, 116, self.RULE_shift_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 735 @@ -5262,10 +5000,10 @@ class CParser ( Parser ): self.state =3D 740 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__76 or _la=3D=3DCParser.T__77: + while _la =3D=3D CParser.T__76 or _la =3D=3D CParser.T__77: self.state =3D 736 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__76 or _la=3D=3DCParser.T__77): + if not(_la =3D=3D CParser.T__76 or _la =3D=3D CParser.T__7= 7): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5288,70 +5026,56 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def labeled_statement(self): - return self.getTypedRuleContext(CParser.Labeled_statementConte= xt,0) - + return self.getTypedRuleContext(CParser.Labeled_statementConte= xt, 0) =20 def compound_statement(self): - return self.getTypedRuleContext(CParser.Compound_statementCont= ext,0) - + return self.getTypedRuleContext(CParser.Compound_statementCont= ext, 0) =20 def expression_statement(self): - return self.getTypedRuleContext(CParser.Expression_statementCo= ntext,0) - + return self.getTypedRuleContext(CParser.Expression_statementCo= ntext, 0) =20 def selection_statement(self): - return self.getTypedRuleContext(CParser.Selection_statementCon= text,0) - + return self.getTypedRuleContext(CParser.Selection_statementCon= text, 0) =20 def iteration_statement(self): - return self.getTypedRuleContext(CParser.Iteration_statementCon= text,0) - + return self.getTypedRuleContext(CParser.Iteration_statementCon= text, 0) =20 def jump_statement(self): - return self.getTypedRuleContext(CParser.Jump_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Jump_statementContext,= 0) =20 def macro_statement(self): - return self.getTypedRuleContext(CParser.Macro_statementContext= ,0) - + return self.getTypedRuleContext(CParser.Macro_statementContext= , 0) =20 def asm2_statement(self): - return self.getTypedRuleContext(CParser.Asm2_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Asm2_statementContext,= 0) =20 def asm1_statement(self): - return self.getTypedRuleContext(CParser.Asm1_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Asm1_statementContext,= 0) =20 def asm_statement(self): - return self.getTypedRuleContext(CParser.Asm_statementContext,0) - + return self.getTypedRuleContext(CParser.Asm_statementContext, = 0) =20 def declaration(self): - return self.getTypedRuleContext(CParser.DeclarationContext,0) - + return self.getTypedRuleContext(CParser.DeclarationContext, 0) =20 def getRuleIndex(self): return CParser.RULE_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStatement" ): + def enterRule(self, listener): + if hasattr(listener, "enterStatement"): listener.enterStatement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStatement" ): + def exitRule(self, listener): + if hasattr(listener, "exitStatement"): listener.exitStatement(self) =20 - - - def statement(self): =20 localctx =3D CParser.StatementContext(self, self._ctx, self.state) @@ -5359,7 +5083,7 @@ class CParser ( Parser ): try: self.state =3D 754 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,92,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 92, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 743 @@ -5426,7 +5150,6 @@ class CParser ( Parser ): self.declaration() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -5439,7 +5162,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5450,52 +5173,48 @@ class CParser ( Parser ): return CParser.RULE_asm2_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm2_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm2_statement"): listener.enterAsm2_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm2_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm2_statement"): listener.exitAsm2_statement(self) =20 - - - def asm2_statement(self): =20 localctx =3D CParser.Asm2_statementContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 120, self.RULE_asm2_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 757 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__78: + if _la =3D=3D CParser.T__78: self.state =3D 756 self.match(CParser.T__78) =20 - self.state =3D 759 self.match(CParser.IDENTIFIER) self.state =3D 760 self.match(CParser.T__37) self.state =3D 764 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,94,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 94, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 761 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__1: + if _la <=3D 0 or _la =3D=3D CParser.T__1: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() self.state =3D 766 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,94,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 94, sel= f._ctx) =20 self.state =3D 767 self.match(CParser.T__38) @@ -5513,32 +5232,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_asm1_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm1_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm1_statement"): listener.enterAsm1_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm1_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm1_statement"): listener.exitAsm1_statement(self) =20 - - - def asm1_statement(self): =20 localctx =3D CParser.Asm1_statementContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 122, self.RULE_asm1_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 770 @@ -5551,7 +5266,7 @@ class CParser ( Parser ): while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__0) | (1 << CParser.T__1) | (1 << CParser.T__2) | (1 << CParser.T__3) = | (1 << CParser.T__4) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << C= Parser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T_= _10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) |= (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 <<= CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CPars= er.T__21) | (1 << CParser.T__22) | (1 << CParser.T__23) | (1 << CParser.T__= 24) | (1 << CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | = (1 << CParser.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << = CParser.T__31) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParse= r.T__34) | (1 << CParser.T__35) | (1 << CParser.T__36) | (1 << CParser.T__3= 7) | (1 << CParser.T__38) | (1 << CParser.T__39) | (1 << CParser.T__40) | (= 1 << CParser.T__41) | (1 << CParser.T__42) | (1 << CParser.T__43) | (1 << C= Parser.T__44) | (1 << CParser.T__45) | (1 << CParser.T__46) | (1 << CParser= .T__47) | (1 << CParser.T__48) | (1 << CParser.T__49) | (1 << CParser.T__50= ) | (1 << CParser.T__51) | (1 << CParser.T__52) | (1 << CParser.T__53) | (1= << CParser.T__54) | (1 << CParser.T__55) | (1 << CParser.T__56) | (1 << CP= arser.T__57) | (1 << CParser.T__58) | (1 << CParser.T__59) | (1 << CParser.= T__60) | (1 << CParser.T__61) | (1 << CParser.T__62))) !=3D 0) or ((((_la -= 64)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 64)) & ((1 << (CParser.T__63 - 64= )) | (1 << (CParser.T__64 - 64)) | (1 << (CParser.T__65 - 64)) | (1 << (CPa= rser.T__66 - 64)) | (1 << (CParser.T__67 - 64)) | (1 << (CParser.T__68 - 64= )) | (1 << (CParser.T__69 - 64)) | (1 << (CParser.T__70 - 64)) | (1 << (CPa= rser.T__71 - 64)) | (1 << (CParser.T__72 - 64)) | (1 << (CParser.T__73 - 64= )) | (1 << (CParser.T__74 - 64)) | (1 << (CParser.T__75 - 64)) | (1 << (CPa= rser.T__76 - 64)) | (1 << (CParser.T__77 - 64)) | (1 << (CParser.T__78 - 64= )) | (1 << (CParser.T__79 - 64)) | (1 << (CParser.T__80 - 64)) | (1 << (CPa= rser.T__81 - 64)) | (1 << (CParser.T__82 - 64)) | (1 << (CParser.T__83 - 64= )) | (1 << (CParser.T__84 - 64)) | (1 << (CParser.T__85 - 64)) | (1 << (CPa= rser.T__86 - 64)) | (1 << (CParser.T__87 - 64)) | (1 << (CParser.T__88 - 64= )) | (1 << (CParser.T__89 - 64)) | (1 << (CParser.T__90 - 64)) | (1 << (CPa= rser.T__91 - 64)) | (1 << (CParser.IDENTIFIER - 64)) | (1 << (CParser.CHARA= CTER_LITERAL - 64)) | (1 << (CParser.STRING_LITERAL - 64)) | (1 << (CParser= .HEX_LITERAL - 64)) | (1 << (CParser.DECIMAL_LITERAL - 64)) | (1 << (CParse= r.OCTAL_LITERAL - 64)) | (1 << (CParser.FLOATING_POINT_LITERAL - 64)) | (1 = << (CParser.WS - 64)) | (1 << (CParser.BS - 64)) | (1 << (CParser.UnicodeVo= cabulary - 64)) | (1 << (CParser.COMMENT - 64)) | (1 << (CParser.LINE_COMME= NT - 64)) | (1 << (CParser.LINE_COMMAND - 64)))) !=3D 0): self.state =3D 772 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__19: + if _la <=3D 0 or _la =3D=3D CParser.T__19: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5574,32 +5289,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_asm_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm_statement"): listener.enterAsm_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm_statement"): listener.exitAsm_statement(self) =20 - - - def asm_statement(self): =20 localctx =3D CParser.Asm_statementContext(self, self._ctx, self.st= ate) self.enterRule(localctx, 124, self.RULE_asm_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 780 @@ -5612,7 +5323,7 @@ class CParser ( Parser ): while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__0) | (1 << CParser.T__1) | (1 << CParser.T__2) | (1 << CParser.T__3) = | (1 << CParser.T__4) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << C= Parser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T_= _10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) |= (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 <<= CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CPars= er.T__21) | (1 << CParser.T__22) | (1 << CParser.T__23) | (1 << CParser.T__= 24) | (1 << CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | = (1 << CParser.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << = CParser.T__31) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParse= r.T__34) | (1 << CParser.T__35) | (1 << CParser.T__36) | (1 << CParser.T__3= 7) | (1 << CParser.T__38) | (1 << CParser.T__39) | (1 << CParser.T__40) | (= 1 << CParser.T__41) | (1 << CParser.T__42) | (1 << CParser.T__43) | (1 << C= Parser.T__44) | (1 << CParser.T__45) | (1 << CParser.T__46) | (1 << CParser= .T__47) | (1 << CParser.T__48) | (1 << CParser.T__49) | (1 << CParser.T__50= ) | (1 << CParser.T__51) | (1 << CParser.T__52) | (1 << CParser.T__53) | (1= << CParser.T__54) | (1 << CParser.T__55) | (1 << CParser.T__56) | (1 << CP= arser.T__57) | (1 << CParser.T__58) | (1 << CParser.T__59) | (1 << CParser.= T__60) | (1 << CParser.T__61) | (1 << CParser.T__62))) !=3D 0) or ((((_la -= 64)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 64)) & ((1 << (CParser.T__63 - 64= )) | (1 << (CParser.T__64 - 64)) | (1 << (CParser.T__65 - 64)) | (1 << (CPa= rser.T__66 - 64)) | (1 << (CParser.T__67 - 64)) | (1 << (CParser.T__68 - 64= )) | (1 << (CParser.T__69 - 64)) | (1 << (CParser.T__70 - 64)) | (1 << (CPa= rser.T__71 - 64)) | (1 << (CParser.T__72 - 64)) | (1 << (CParser.T__73 - 64= )) | (1 << (CParser.T__74 - 64)) | (1 << (CParser.T__75 - 64)) | (1 << (CPa= rser.T__76 - 64)) | (1 << (CParser.T__77 - 64)) | (1 << (CParser.T__78 - 64= )) | (1 << (CParser.T__79 - 64)) | (1 << (CParser.T__80 - 64)) | (1 << (CPa= rser.T__81 - 64)) | (1 << (CParser.T__82 - 64)) | (1 << (CParser.T__83 - 64= )) | (1 << (CParser.T__84 - 64)) | (1 << (CParser.T__85 - 64)) | (1 << (CPa= rser.T__86 - 64)) | (1 << (CParser.T__87 - 64)) | (1 << (CParser.T__88 - 64= )) | (1 << (CParser.T__89 - 64)) | (1 << (CParser.T__90 - 64)) | (1 << (CPa= rser.T__91 - 64)) | (1 << (CParser.IDENTIFIER - 64)) | (1 << (CParser.CHARA= CTER_LITERAL - 64)) | (1 << (CParser.STRING_LITERAL - 64)) | (1 << (CParser= .HEX_LITERAL - 64)) | (1 << (CParser.DECIMAL_LITERAL - 64)) | (1 << (CParse= r.OCTAL_LITERAL - 64)) | (1 << (CParser.FLOATING_POINT_LITERAL - 64)) | (1 = << (CParser.WS - 64)) | (1 << (CParser.BS - 64)) | (1 << (CParser.UnicodeVo= cabulary - 64)) | (1 << (CParser.COMMENT - 64)) | (1 << (CParser.LINE_COMME= NT - 64)) | (1 << (CParser.LINE_COMMAND - 64)))) !=3D 0): self.state =3D 782 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__19: + if _la <=3D 0 or _la =3D=3D CParser.T__19: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5635,7 +5346,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5643,42 +5354,36 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def statement_list(self): - return self.getTypedRuleContext(CParser.Statement_listContext,= 0) - + return self.getTypedRuleContext(CParser.Statement_listContext,= 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_macro_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMacro_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterMacro_statement"): listener.enterMacro_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMacro_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitMacro_statement"): listener.exitMacro_statement(self) =20 - - - def macro_statement(self): =20 localctx =3D CParser.Macro_statementContext(self, self._ctx, self.= state) self.enterRule(localctx, 126, self.RULE_macro_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 790 @@ -5687,23 +5392,22 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 795 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,97,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 97, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 792 self.declaration() self.state =3D 797 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,97,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 97, sel= f._ctx) =20 self.state =3D 799 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,98,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 98, self._ct= x) if la_ =3D=3D 1: self.state =3D 798 self.statement_list() =20 - self.state =3D 802 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -5711,7 +5415,6 @@ class CParser ( Parser ): self.state =3D 801 self.expression() =20 - self.state =3D 804 self.match(CParser.T__38) except RecognitionException as re: @@ -5726,7 +5429,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5734,32 +5437,28 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def statement(self): - return self.getTypedRuleContext(CParser.StatementContext,0) - + return self.getTypedRuleContext(CParser.StatementContext, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_labeled_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLabeled_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterLabeled_statement"): listener.enterLabeled_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLabeled_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitLabeled_statement"): listener.exitLabeled_statement(self) =20 - - - def labeled_statement(self): =20 - localctx =3D CParser.Labeled_statementContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Labeled_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 128, self.RULE_labeled_statement) try: self.state =3D 817 @@ -5809,57 +5508,54 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def statement_list(self): - return self.getTypedRuleContext(CParser.Statement_listContext,= 0) - + return self.getTypedRuleContext(CParser.Statement_listContext,= 0) =20 def getRuleIndex(self): return CParser.RULE_compound_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterCompound_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterCompound_statement"): listener.enterCompound_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitCompound_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitCompound_statement"): listener.exitCompound_statement(self) =20 - - - def compound_statement(self): =20 - localctx =3D CParser.Compound_statementContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Compound_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 130, self.RULE_compound_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 819 self.match(CParser.T__0) self.state =3D 823 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,101,self._ct= x) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 101, self._= ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 820 self.declaration() self.state =3D 825 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,101,self= ._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 101, self._ctx) =20 self.state =3D 827 self._errHandler.sync(self) @@ -5868,7 +5564,6 @@ class CParser ( Parser ): self.state =3D 826 self.statement_list() =20 - self.state =3D 829 self.match(CParser.T__19) except RecognitionException as re: @@ -5883,34 +5578,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def statement(self,i=3DNone): + def statement(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.StatementContext) else: - return self.getTypedRuleContext(CParser.StatementContext,i) - + return self.getTypedRuleContext(CParser.StatementContext, = i) =20 def getRuleIndex(self): return CParser.RULE_statement_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStatement_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStatement_list"): listener.enterStatement_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStatement_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStatement_list"): listener.exitStatement_list(self) =20 - - - def statement_list(self): =20 localctx =3D CParser.Statement_listContext(self, self._ctx, self.s= tate) @@ -5920,7 +5611,7 @@ class CParser ( Parser ): self.state =3D 832 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 831 self.statement() @@ -5929,7 +5620,8 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 834 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,103,self= ._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 103, self._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -5943,33 +5635,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_expression_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExpression_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterExpression_statement"): listener.enterExpression_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExpression_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitExpression_statement"): listener.exitExpression_statement(self) =20 - - - def expression_statement(self): =20 - localctx =3D CParser.Expression_statementContext(self, self._ctx, = self.state) + localctx =3D CParser.Expression_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 134, self.RULE_expression_statement) try: self.state =3D 840 @@ -6002,42 +5691,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # ExpressionContext + self.e =3D None # ExpressionContext =20 # @param i=3DNone Type: int - def statement(self,i=3DNone): + def statement(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.StatementContext) else: - return self.getTypedRuleContext(CParser.StatementContext,i) - + return self.getTypedRuleContext(CParser.StatementContext, = i) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_selection_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterSelection_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterSelection_statement"): listener.enterSelection_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitSelection_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitSelection_statement"): listener.exitSelection_statement(self) =20 - - - def selection_statement(self): =20 - localctx =3D CParser.Selection_statementContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Selection_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 136, self.RULE_selection_statement) try: self.state =3D 858 @@ -6053,19 +5738,19 @@ class CParser ( Parser ): localctx.e =3D self.expression() self.state =3D 845 self.match(CParser.T__38) - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) self.state =3D 847 self.statement() self.state =3D 850 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,105,self.= _ctx) + la_ =3D self._interp.adaptivePredict(self._input, 105, sel= f._ctx) if la_ =3D=3D 1: self.state =3D 848 self.match(CParser.T__84) self.state =3D 849 self.statement() =20 - pass elif token in [CParser.T__85]: self.enterOuterAlt(localctx, 2) @@ -6095,38 +5780,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # ExpressionContext + self.e =3D None # ExpressionContext =20 def statement(self): - return self.getTypedRuleContext(CParser.StatementContext,0) - + return self.getTypedRuleContext(CParser.StatementContext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_iteration_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterIteration_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterIteration_statement"): listener.enterIteration_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitIteration_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitIteration_statement"): listener.exitIteration_statement(self) =20 - - - def iteration_statement(self): =20 - localctx =3D CParser.Iteration_statementContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Iteration_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 138, self.RULE_iteration_statement) try: self.state =3D 876 @@ -6144,7 +5825,8 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state =3D 864 self.statement() - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) pass elif token in [CParser.T__87]: self.enterOuterAlt(localctx, 2) @@ -6162,7 +5844,8 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state =3D 873 self.match(CParser.T__1) - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) pass else: raise NoViableAltException(self) @@ -6179,7 +5862,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -6187,25 +5870,21 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_jump_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterJump_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterJump_statement"): listener.enterJump_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitJump_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitJump_statement"): listener.exitJump_statement(self) =20 - - - def jump_statement(self): =20 localctx =3D CParser.Jump_statementContext(self, self._ctx, self.s= tate) @@ -6213,7 +5892,7 @@ class CParser ( Parser ): try: self.state =3D 891 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,108,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 108, self._c= tx) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 878 @@ -6258,7 +5937,6 @@ class CParser ( Parser ): self.match(CParser.T__1) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -6266,8 +5944,3 @@ class CParser ( Parser ): finally: self.exitRule() return localctx - - - - - diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python= /Ecc/Check.py index 33060db5f27a..362d4247560f 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define checkpoints used by ECC tool # # Copyright (c) 2021, Arm Limited. All rights reserved.
        @@ -17,12 +17,14 @@ from Ecc import c from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## Check +# Check # # This class is to define checkpoints used by ECC tool # # @param object: Inherited from object class # + + class Check(object): def __init__(self): pass @@ -42,7 +44,6 @@ class Check(object): def SmmCommParaCheck(self): self.SmmCommParaCheckBufferType() =20 - # Check if SMM communication function has correct parameter type # 1. Get function calling with instance./->Communicate() interface # and make sure the protocol instance is of type EFI_SMM_COMMUNICATION= _PROTOCOL. @@ -59,6 +60,7 @@ class Check(object): # report warning to indicate human code review. # e. it is a buffer from other kind of pointers (may need to trace = into nested function calls to locate), # repeat checks in a.b.c and d. + def SmmCommParaCheckBufferType(self): if EccGlobalData.gConfig.SmmCommParaCheckBufferType =3D=3D '1' or = EccGlobalData.gConfig.SmmCommParaCheckAll =3D=3D '1': EdkLogger.quiet("Checking SMM communication parameter type ...= ") @@ -88,7 +90,8 @@ class Check(object): if SecondPara.startswith('&'): SecondPara =3D SecondPara[1:] if SecondPara.endswith(']'): - SecondParaIndex =3D SecondPara[SecondPara.= find('[') + 1:-1] + SecondParaIndex =3D SecondPara[SecondPara.= find( + '[') + 1:-1] SecondPara =3D SecondPara[:SecondPara.find= ('[')] # Get the ID Id =3D Record[0] @@ -96,7 +99,8 @@ class Check(object): BelongsToFile =3D Record[3] # Get the source file path SqlCommand =3D """select FullPath from File wh= ere ID =3D %s""" % BelongsToFile - NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c(SqlCommand) + NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c( + SqlCommand) FullPath =3D NewRecordSet[0][0] # Get the line no of function calling StartLine =3D Record[4] @@ -104,7 +108,8 @@ class Check(object): SqlCommand =3D """select Value3 from INF where= BelongsToFile =3D (select ID from File where Path =3D (select Path fr= om File where ID =3D %s) and Model =3D 1011) and Value2 =3D 'MODULE_TYPE'""= " % BelongsToFile - NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c(SqlCommand) + NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c( + SqlCommand) ModuleType =3D NewRecordSet[0][0] if NewRecord= Set else None =20 # print BelongsToFile, FullPath, StartLine, Mo= duleType, SecondPara @@ -113,14 +118,14 @@ class Check(object): # Find the value of the parameter if Value: if 'AllocatePage' in Value \ - or 'AllocatePool' in Value \ - or 'AllocateRuntimePool' in Value \ - or 'AllocateZeroPool' in Value: + or 'AllocatePool' in Value \ + or 'AllocateRuntimePool' in Value \ + or 'AllocateZeroPool' in Value: pass else: if '->' in Value: if not EccGlobalData.gException.Is= Exception( - ERROR_SMM_COMM_PARA_CHECK_B= UFFER_TYPE, Value): + ERROR_SMM_COMM_PARA_CHECK_= BUFFER_TYPE, Value): EccGlobalData.gDb.TblReport.In= sert(ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE, = OtherMsg=3D"Please review the buffer type" = + "is correct or not. If it is correct" + @@ -130,7 +135,7 @@ class Check(object): = BelongsToItem=3DId) else: if not EccGlobalData.gException.Is= Exception( - ERROR_SMM_COMM_PARA_CHECK_B= UFFER_TYPE, Value): + ERROR_SMM_COMM_PARA_CHECK_= BUFFER_TYPE, Value): EccGlobalData.gDb.TblReport.In= sert(ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE, = OtherMsg=3D"Please review the buffer type" = + "is correct or not. If it is correct" + @@ -139,23 +144,23 @@ class Check(object): = BelongsToTable=3DIdentifierTable, = BelongsToItem=3DId) =20 - # Not find the value of the parameter else: SqlCommand =3D """select ID, Modifier, Nam= e, Value, Model, BelongsToFunction from %s where Name =3D '%s' and St= artLine < %s order by StartLine DESC""" \ % (IdentifierTable, Second= Para, StartLine) - NewRecordSet =3D EccGlobalData.gDb.TblFile= .Exec(SqlCommand) + NewRecordSet =3D EccGlobalData.gDb.TblFile= .Exec( + SqlCommand) if NewRecordSet: Value =3D NewRecordSet[0][1] if 'AllocatePage' in Value \ - or 'AllocatePool' in Value \ - or 'AllocateRuntimePool' in Value \ - or 'AllocateZeroPool' in Value: + or 'AllocatePool' in Value \ + or 'AllocateRuntimePool' in Va= lue \ + or 'AllocateZeroPool' in Value: pass else: if not EccGlobalData.gException.Is= Exception( - ERROR_SMM_COMM_PARA_CHECK_BUFF= ER_TYPE, Value): + ERROR_SMM_COMM_PARA_CHECK_= BUFFER_TYPE, Value): EccGlobalData.gDb.TblReport.In= sert(ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE, = OtherMsg=3D"Please review the buffer type" = + "is correct or not. If it is correct" + @@ -177,7 +182,8 @@ class Check(object): FileIn =3D open(File, 'rb').read(2) if FileIn !=3D '\xff\xfe': OtherMsg =3D "File %s is not a valid UTF-16 UNI file" = % Record[1] - EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK= _UNI, OtherMsg=3DOtherMsg, BelongsToTable=3D'File', BelongsToItem=3DRecord[= 0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_GENERAL_CHECK_UNI, OtherMsg=3DOtherMsg, Belo= ngsToTable=3D'File', BelongsToItem=3DRecord[0]) =20 # General Checking def GeneralCheck(self): @@ -203,8 +209,10 @@ class Check(object): for Char in Line: IndexOfChar +=3D 1 if Char =3D=3D '\t': - OtherMsg =3D "File %s has TAB char at line= %s column %s" % (Record[1], IndexOfLine, IndexOfChar) - EccGlobalData.gDb.TblReport.Insert(ERROR_G= ENERAL_CHECK_NO_TAB, OtherMsg=3DOtherMsg, BelongsToTable=3D'File', BelongsT= oItem=3DRecord[0]) + OtherMsg =3D "File %s has TAB char at line= %s column %s" % ( + Record[1], IndexOfLine, IndexOfChar) + EccGlobalData.gDb.TblReport.Insert( + ERROR_GENERAL_CHECK_NO_TAB, OtherMsg= =3DOtherMsg, BelongsToTable=3D'File', BelongsToItem=3DRecord[0]) =20 # Check Only use CRLF (Carriage Return Line Feed) line endings. def GeneralCheckLineEnding(self): @@ -219,8 +227,10 @@ class Check(object): for Line in op: IndexOfLine +=3D 1 if not bytes.decode(Line).endswith('\r\n'): - OtherMsg =3D "File %s has invalid line ending = at line %s" % (Record[1], IndexOfLine) - EccGlobalData.gDb.TblReport.Insert(ERROR_GENER= AL_CHECK_INVALID_LINE_ENDING, OtherMsg=3DOtherMsg, BelongsToTable=3D'File',= BelongsToItem=3DRecord[0]) + OtherMsg =3D "File %s has invalid line ending = at line %s" % ( + Record[1], IndexOfLine) + EccGlobalData.gDb.TblReport.Insert( + ERROR_GENERAL_CHECK_INVALID_LINE_ENDING, O= therMsg=3DOtherMsg, BelongsToTable=3D'File', BelongsToItem=3DRecord[0]) =20 # Check if there is no trailing white space in one line. def GeneralCheckTrailingWhiteSpaceLine(self): @@ -235,8 +245,10 @@ class Check(object): for Line in op: IndexOfLine +=3D 1 if Line.replace('\r', '').replace('\n', '').endswi= th(' '): - OtherMsg =3D "File %s has trailing white space= s at line %s" % (Record[1], IndexOfLine) - EccGlobalData.gDb.TblReport.Insert(ERROR_GENER= AL_CHECK_TRAILING_WHITE_SPACE_LINE, OtherMsg=3DOtherMsg, BelongsToTable=3D'= File', BelongsToItem=3DRecord[0]) + OtherMsg =3D "File %s has trailing white space= s at line %s" % ( + Record[1], IndexOfLine) + EccGlobalData.gDb.TblReport.Insert( + ERROR_GENERAL_CHECK_TRAILING_WHITE_SPACE_L= INE, OtherMsg=3DOtherMsg, BelongsToTable=3D'File', BelongsToItem=3DRecord[0= ]) =20 # Check whether file has non ACSII char def GeneralCheckNonAcsii(self): @@ -254,8 +266,10 @@ class Check(object): for Char in Line: IndexOfChar +=3D 1 if ord(Char) > 126: - OtherMsg =3D "File %s has Non-ASCII char a= t line %s column %s" % (Record[1], IndexOfLine, IndexOfChar) - EccGlobalData.gDb.TblReport.Insert(ERROR_G= ENERAL_CHECK_NON_ACSII, OtherMsg=3DOtherMsg, BelongsToTable=3D'File', Belon= gsToItem=3DRecord[0]) + OtherMsg =3D "File %s has Non-ASCII char a= t line %s column %s" % ( + Record[1], IndexOfLine, IndexOfChar) + EccGlobalData.gDb.TblReport.Insert( + ERROR_GENERAL_CHECK_NON_ACSII, OtherMs= g=3DOtherMsg, BelongsToTable=3D'File', BelongsToItem=3DRecord[0]) =20 # C Function Layout Checking def FunctionLayoutCheck(self): @@ -270,7 +284,8 @@ class Check(object): # To check if the deprecated functions are used def FunctionLayoutCheckDeprecated(self): if EccGlobalData.gConfig.CFunctionLayoutCheckNoDeprecated =3D=3D '= 1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll =3D=3D '1' or EccGlobal= Data.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking function no deprecated one being use= d ...") + EdkLogger.quiet( + "Checking function no deprecated one being used ...") =20 DeprecatedFunctionSet =3D ('UnicodeValueToString', 'AsciiValueToString', @@ -441,8 +456,8 @@ class Check(object): self.DeclCheckSameStructure() self.DeclCheckUnionType() =20 - # Check whether no use of int, unsigned, char, void, long in any .c, .= h or .asl files. + def DeclCheckNoUseCType(self): if EccGlobalData.gConfig.DeclarationDataTypeCheckNoUseCType =3D=3D= '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': EdkLogger.quiet("Checking Declaration No use C type ...") @@ -509,7 +524,8 @@ class Check(object): EdkLogger.quiet("Checking same struct ...") AllStructure =3D {} for IdentifierTable in EccGlobalData.gIdentifierTableList: - SqlCommand =3D """select ID, Name, BelongsToFile from %s w= here Model =3D %s""" % (IdentifierTable, MODEL_IDENTIFIER_STRUCTURE) + SqlCommand =3D """select ID, Name, BelongsToFile from %s w= here Model =3D %s""" % ( + IdentifierTable, MODEL_IDENTIFIER_STRUCTURE) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Record in RecordSet: if Record[1] !=3D '': @@ -518,12 +534,15 @@ class Check(object): else: ID =3D AllStructure[Record[1]] SqlCommand =3D """select FullPath from File wh= ere ID =3D %s """ % ID - NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c(SqlCommand) + NewRecordSet =3D EccGlobalData.gDb.TblFile.Exe= c( + SqlCommand) OtherMsg =3D "The structure name '%s' is dupli= cate" % Record[1] if NewRecordSet !=3D []: - OtherMsg =3D "The structure name [%s] is d= uplicate with the one defined in %s, maybe struct NOT typedefed or the type= def new type NOT used to qualify variables" % (Record[1], NewRecordSet[0][0= ]) + OtherMsg =3D "The structure name [%s] is d= uplicate with the one defined in %s, maybe struct NOT typedefed or the type= def new type NOT used to qualify variables" % ( + Record[1], NewRecordSet[0][0]) if not EccGlobalData.gException.IsException(ER= ROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_D= ECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE, OtherMsg=3DOtherMsg, BelongsToTa= ble=3DIdentifierTable, BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DECLARATION_DATA_TYPE_CHECK_SAME= _STRUCTURE, OtherMsg=3DOtherMsg, BelongsToTable=3DIdentifierTable, BelongsT= oItem=3DRecord[0]) =20 # Check whether Union Type has a 'typedef' and the name is capital def DeclCheckUnionType(self): @@ -564,7 +583,8 @@ class Check(object): # Check whether Non-Boolean comparisons use a compare operator (=3D=3D= , !=3D, >, < >=3D, <=3D). def PredicateExpressionCheckNonBooleanOperator(self): if EccGlobalData.gConfig.PredicateExpressionCheckNonBooleanOperato= r =3D=3D '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll =3D=3D '1= ' or EccGlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking predicate expression Non-Boolean var= iable...") + EdkLogger.quiet( + "Checking predicate expression Non-Boolean variable...") =20 # for Dirpath, Dirnames, Filenames in self.WalkTree(): # for F in Filenames: @@ -621,7 +641,8 @@ class Check(object): for Item in RecordDict[Key]: Path =3D mws.relpath(Item[1], EccGlobalData.gWorks= pace) if not EccGlobalData.gException.IsException(ERROR_= INCLUDE_FILE_CHECK_NAME, Path): - EccGlobalData.gDb.TblReport.Insert(ERROR_INCLU= DE_FILE_CHECK_NAME, OtherMsg=3D"The file name for [%s] is duplicate" % Path= , BelongsToTable=3D'File', BelongsToItem=3DItem[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg=3D= "The file name for [%s] is duplicate" % Path, BelongsToTable=3D'File', Belo= ngsToItem=3DItem[0]) =20 # Check whether all include file contents is guarded by a #ifndef stat= ement. def IncludeFileCheckIfndef(self): @@ -682,15 +703,15 @@ class Check(object): FullName =3D os.path.join(Dirpath, F) op =3D open(FullName).readlines() FileLinesList =3D op - LineNo =3D 0 - CurrentSection =3D MODEL_UNKNOWN - HeaderSectionLines =3D [] + LineNo =3D 0 + CurrentSection =3D MODEL_UNKNOWN + HeaderSectionLines =3D [] HeaderCommentStart =3D False - HeaderCommentEnd =3D False + HeaderCommentEnd =3D False =20 for Line in FileLinesList: - LineNo =3D LineNo + 1 - Line =3D Line.strip() + LineNo =3D LineNo + 1 + Line =3D Line.strip() if (LineNo < len(FileLinesList) - 1): NextLine =3D FileLinesList[LineNo].strip() =20 @@ -705,13 +726,15 @@ class Check(object): # if Line.startswith('#') and \ (Line.find('@file') > -1) and \ - not HeaderCommentStart: + not HeaderCommentStart: if CurrentSection !=3D MODEL_UNKNOWN: SqlStatement =3D """ select ID from Fi= le where FullPath like '%s'""" % FullName - ResultSet =3D EccGlobalData.gDb.TblFil= e.Exec(SqlStatement) + ResultSet =3D EccGlobalData.gDb.TblFil= e.Exec( + SqlStatement) for Result in ResultSet: Msg =3D 'INF/DEC/DSC/FDF file head= er comment should begin with ""## @file"" or ""# @file""at the very top fil= e' - EccGlobalData.gDb.TblReport.Insert= (ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADE= R, Msg, "File", Result[0]) =20 else: CurrentSection =3D MODEL_IDENTIFIER_FI= LE_HEADER @@ -726,38 +749,42 @@ class Check(object): # Collect Header content. # if (Line.startswith('#') and CurrentSection = =3D=3D MODEL_IDENTIFIER_FILE_HEADER) and\ - HeaderCommentStart and not Line.startswith= ('##') and not\ - HeaderCommentEnd and NextLine !=3D '': + HeaderCommentStart and not Line.starts= with('##') and not\ + HeaderCommentEnd and NextLine !=3D '': HeaderSectionLines.append((Line, LineNo)) continue # # Header content end # if (Line.startswith('##') or not Line.strip().= startswith("#")) and HeaderCommentStart \ - and not HeaderCommentEnd: + and not HeaderCommentEnd: if Line.startswith('##'): HeaderCommentEnd =3D True HeaderSectionLines.append((Line, LineNo)) - ParseHeaderCommentSection(HeaderSectionLin= es, FullName) + ParseHeaderCommentSection( + HeaderSectionLines, FullName) break if HeaderCommentStart =3D=3D False: SqlStatement =3D """ select ID from File where= FullPath like '%s'""" % FullName - ResultSet =3D EccGlobalData.gDb.TblFile.Exec(S= qlStatement) + ResultSet =3D EccGlobalData.gDb.TblFile.Exec( + SqlStatement) for Result in ResultSet: Msg =3D 'INF/DEC/DSC/FDF file header comme= nt should begin with ""## @file"" or ""# @file"" at the very top file' - EccGlobalData.gDb.TblReport.Insert(ERROR_D= OXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, = "File", Result[0]) if HeaderCommentEnd =3D=3D False: SqlStatement =3D """ select ID from File where= FullPath like '%s'""" % FullName - ResultSet =3D EccGlobalData.gDb.TblFile.Exec(S= qlStatement) + ResultSet =3D EccGlobalData.gDb.TblFile.Exec( + SqlStatement) for Result in ResultSet: Msg =3D 'INF/DEC/DSC/FDF file header comme= nt should end with ""##"" at the end of file header comment block' # Check whether File header Comment End wi= th '##' if EccGlobalData.gConfig.HeaderCheckFileCo= mmentEnd =3D=3D '1' or EccGlobalData.gConfig.HeaderCheckAll =3D=3D '1' or E= ccGlobalData.gConfig.CheckAll =3D=3D '1': - EccGlobalData.gDb.TblReport.Insert(ERR= OR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) - - + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, M= sg, "File", Result[0]) =20 # Check whether the function headers are followed Doxygen special docu= mentation blocks in section 2.3.5 + def DoxygenCheckFunctionHeader(self): if EccGlobalData.gConfig.DoxygenCheckFunctionHeader =3D=3D '1' or = EccGlobalData.gConfig.DoxygenCheckAll =3D=3D '1' or EccGlobalData.gConfig.C= heckAll =3D=3D '1': EdkLogger.quiet("Checking Doxygen function header ...") @@ -770,9 +797,9 @@ class Check(object): for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFil= eList: MsgList =3D c.CheckFuncHeaderDoxygenComments(FullName) =20 - # Check whether the first line of text in a comment block is a brief d= escription of the element being documented. # The brief description must end with a period. + def DoxygenCheckCommentDescription(self): if EccGlobalData.gConfig.DoxygenCheckCommentDescription =3D=3D '1'= or EccGlobalData.gConfig.DoxygenCheckAll =3D=3D '1' or EccGlobalData.gConf= ig.CheckAll =3D=3D '1': pass @@ -853,7 +880,8 @@ class Check(object): List =3D Record[1].split('|', 1) SupModType =3D [] if len(List) =3D=3D 1: - SupModType =3D DT.SUP_MODULE_LIST_STRING.split(DT.TAB_= VALUE_SPLIT) + SupModType =3D DT.SUP_MODULE_LIST_STRING.split( + DT.TAB_VALUE_SPLIT) elif len(List) =3D=3D 2: SupModType =3D List[1].split() =20 @@ -865,7 +893,8 @@ class Check(object): LibraryClasses[List[0]].append(Item) =20 if Record[2] !=3D DT.SUP_MODULE_BASE and Record[2] not in = SupModType: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_LIBRARY_INSTANCE_2, OtherMsg=3D"The Library Class '%s' does not spe= cify its supported module types" % (List[0]), BelongsToTable=3D'Inf', Belon= gsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_LIBRARY_INSTANCE_2, OtherMsg=3D"The Library Class '%s' does not spe= cify its supported module types" % ( + List[0]), BelongsToTable=3D'Inf', BelongsToItem=3D= Record[0]) =20 SqlCommand =3D """select A.ID, A.Value1, B.Value3 from Inf as = A left join Inf as B where A.Model =3D %s and B.Value2 =3D '%s' and= B.Model =3D %s @@ -885,22 +914,26 @@ class Check(object): if Record[1] in LibraryClasses: if Record[2] not in LibraryClasses[Record[1]] and DT.S= UP_MODULE_BASE not in RecordDict[Record[1]]: if not EccGlobalData.gException.IsException(ERROR_= META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg=3D"The type of Library Class [= %s] defined in Inf file does not match the type of the module" % (Record[1]= ), BelongsToTable=3D'Inf', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg=3D"The type of Library Class [= %s] defined in Inf file does not match the type of the module" % ( + Record[1]), BelongsToTable=3D'Inf', Belong= sToItem=3DRecord[0]) else: if not EccGlobalData.gException.IsException(ERROR_META= _DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg=3D"The type of Library Class [%s] = defined in Inf file does not match the type of the module" % (Record[1]), B= elongsToTable=3D'Inf', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg=3D"The type of Library Class [%s] = defined in Inf file does not match the type of the module" % ( + Record[1]), BelongsToTable=3D'Inf', BelongsToI= tem=3DRecord[0]) =20 # Check whether a Library Instance has been defined for all dependent = library classes def MetaDataFileCheckLibraryInstanceDependent(self): if EccGlobalData.gConfig.MetaDataFileCheckLibraryInstanceDependent= =3D=3D '1' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for library instance dependent issue= ...") + EdkLogger.quiet( + "Checking for library instance dependent issue ...") SqlCommand =3D """select ID, Value1, Value2 from Dsc where Mod= el =3D %s""" % MODEL_EFI_LIBRARY_CLASS LibraryClasses =3D EccGlobalData.gDb.TblDsc.Exec(SqlCommand) for LibraryClass in LibraryClasses: if LibraryClass[1].upper() =3D=3D 'NULL' or LibraryClass[1= ].startswith('!ifdef') or LibraryClass[1].startswith('!ifndef') or LibraryC= lass[1].endswith('!endif'): continue else: - LibraryIns =3D os.path.normpath(mws.join(EccGlobalData= .gWorkspace, LibraryClass[2])) + LibraryIns =3D os.path.normpath( + mws.join(EccGlobalData.gWorkspace, LibraryClass[2]= )) SkipDirString =3D '|'.join(EccGlobalData.gConfig.SkipD= irList) p =3D re.compile(r'.*[\\/](?:%s^\S)[\\/]?.*' % SkipDir= String) if p.match(os.path.split(LibraryIns)[0].upper()): @@ -916,7 +949,8 @@ class Check(object): IsFound =3D True if not IsFound: if not EccGlobalData.gException.IsException(ERROR_= META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, LibraryClass[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, OtherMsg=3D"The Library Class [= %s] is not specified in '%s'" % (LibraryClass[1], LibraryClass[2]), Belongs= ToTable=3D'Dsc', BelongsToItem=3DLibraryClass[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, OtherMsg=3D"The Library Class [= %s] is not specified in '%s'" % ( + LibraryClass[1], LibraryClass[2]), Belongs= ToTable=3D'Dsc', BelongsToItem=3DLibraryClass[0]) =20 # Check whether the Library Instances specified by the LibraryClasses = sections are listed in order of dependencies def MetaDataFileCheckLibraryInstanceOrder(self): @@ -929,11 +963,13 @@ class Check(object): def MetaDataFileCheckLibraryNoUse(self): if EccGlobalData.gConfig.MetaDataFileCheckLibraryNoUse =3D=3D '1' = or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData.g= Config.CheckAll =3D=3D '1': EdkLogger.quiet("Checking for library instance not used ...") - SqlCommand =3D """select ID, Value1 from Inf as A where A.Mode= l =3D %s and A.Value1 not in (select B.Value1 from Dsc as B where Model =3D= %s)""" % (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS) + SqlCommand =3D """select ID, Value1 from Inf as A where A.Mode= l =3D %s and A.Value1 not in (select B.Value1 from Dsc as B where Model =3D= %s)""" % ( + MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS) RecordSet =3D EccGlobalData.gDb.TblInf.Exec(SqlCommand) for Record in RecordSet: if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_LIBRARY_NO_USE, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_LIBRARY_NO_USE, OtherMsg=3D"The Library Class [%s] is not used in a= ny platform" % (Record[1]), BelongsToTable=3D'Inf', BelongsToItem=3DRecord[= 0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_LIBRARY_NO_USE, OtherMsg=3D"The Library Class [%s] is not used in a= ny platform" % ( + Record[1]), BelongsToTable=3D'Inf', BelongsToItem= =3DRecord[0]) SqlCommand =3D """ select A.ID, A.Value1, A.BelongsToFile, A.StartLi= ne, B.StartLine from Dsc as A left join Dsc as B where A.Model =3D %s and B.Model =3D %s and A.Sco= pe1 =3D B.Scope1 and A.Scope2 =3D B.Scope2 and A.ID !=3D B.ID @@ -942,16 +978,19 @@ class Check(object): RecordSet =3D EccGlobalData.gDb.TblDsc.Exec(SqlCommand) for Record in RecordSet: if Record[3] and Record[4] and Record[3] !=3D Record[4] an= d Record[1] !=3D 'NULL': - SqlCommand =3D """select FullPath from File where ID = =3D %s""" % (Record[2]) + SqlCommand =3D """select FullPath from File where ID = =3D %s""" % ( + Record[2]) FilePathList =3D EccGlobalData.gDb.TblFile.Exec(SqlCom= mand) for FilePath in FilePathList: if not EccGlobalData.gException.IsException(ERROR_= META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, OtherMsg=3D"The Library Class [%s] = is duplicated in '%s' line %s and line %s." % (Record[1], FilePath, Record[= 3], Record[4]), BelongsToTable=3D'Dsc', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, OtherMsg=3D"The Library Class [%s] = is duplicated in '%s' line %s and line %s." % ( + Record[1], FilePath, Record[3], Record[4])= , BelongsToTable=3D'Dsc', BelongsToItem=3DRecord[0]) =20 # Check the header file in Include\Library directory whether be define= d in the package DEC file. def MetaDataFileCheckLibraryDefinedInDec(self): if EccGlobalData.gConfig.MetaDataFileCheckLibraryDefinedInDec =3D= =3D '1' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlob= alData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for library instance whether be defi= ned in the package dec file ...") + EdkLogger.quiet( + "Checking for library instance whether be defined in the p= ackage dec file ...") SqlCommand =3D """ select A.Value1, A.StartLine, A.ID, B.Value1 from Inf = as A left join Dec as B on A.Model =3D B.Model and A.Value1 =3D B.Value1 where= A.Model=3D%s @@ -961,14 +1000,16 @@ class Check(object): LibraryInInf, Line, ID, LibraryDec =3D Record if not LibraryDec: if not EccGlobalData.gException.IsException(ERROR_META= _DATA_FILE_CHECK_LIBRARY_NOT_DEFINED, LibraryInInf): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_LIBRARY_NOT_DEFINED, \ - OtherMsg=3D"The Library Class = [%s] in %s line is not defined in the associated package file." % (LibraryI= nInf, Line), - BelongsToTable=3D'Inf', Belong= sToItem=3DID) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_LIBRARY_NOT_DEFINED, + OtherMsg=3D"The= Library Class [%s] in %s line is not defined in the associated package fil= e." % ( + LibraryInIn= f, Line), + BelongsToTable= =3D'Inf', BelongsToItem=3DID) =20 # Check whether an Inf file is specified in the FDF file, but not in t= he Dsc file, then the Inf file must be for a Binary module only def MetaDataFileCheckBinaryInfInFdf(self): if EccGlobalData.gConfig.MetaDataFileCheckBinaryInfInFdf =3D=3D '1= ' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData= .gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for non-binary modules defined in FD= F files ...") + EdkLogger.quiet( + "Checking for non-binary modules defined in FDF files ...") SqlCommand =3D """select A.ID, A.Value1 from Fdf as A where A.Model =3D %s and A.Enabled > -1 @@ -980,18 +1021,21 @@ class Check(object): for Record in RecordSet: FdfID =3D Record[0] FilePath =3D Record[1] - FilePath =3D os.path.normpath(mws.join(EccGlobalData.gWork= space, FilePath)) + FilePath =3D os.path.normpath( + mws.join(EccGlobalData.gWorkspace, FilePath)) SqlCommand =3D """select ID from Inf where Model =3D %s an= d BelongsToFile =3D (select ID from File where FullPath like '%s') """ % (MODEL_EFI_SOURCE_FILE, FilePath) NewRecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) if NewRecordSet !=3D []: if not EccGlobalData.gException.IsException(ERROR_META= _DATA_FILE_CHECK_BINARY_INF_IN_FDF, FilePath): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_BINARY_INF_IN_FDF, OtherMsg=3D"File [%s] defined in FDF file an= d not in DSC file must be a binary module" % (FilePath), BelongsToTable=3D'= Fdf', BelongsToItem=3DFdfID) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_BINARY_INF_IN_FDF, OtherMsg=3D"File [%s] defined in FDF file an= d not in DSC file must be a binary module" % ( + FilePath), BelongsToTable=3D'Fdf', BelongsToIt= em=3DFdfID) =20 # Check whether a PCD is set in a Dsc file or the FDF file, but not in= both. def MetaDataFileCheckPcdDuplicate(self): if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate =3D=3D '1' = or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData.g= Config.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for duplicate PCDs defined in both D= SC and FDF files ...") + EdkLogger.quiet( + "Checking for duplicate PCDs defined in both DSC and FDF f= iles ...") SqlCommand =3D """ select A.ID, A.Value1, A.Value2, A.BelongsToFile,= B.ID, B.Value1, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B where A.Model >=3D %s and A.Model < %s @@ -1006,16 +1050,21 @@ class Check(object): for Record in RecordSet: SqlCommand1 =3D """select Name from File where ID =3D %s""= " % Record[3] SqlCommand2 =3D """select Name from File where ID =3D %s""= " % Record[7] - DscFileName =3D os.path.splitext(EccGlobalData.gDb.TblDsc.= Exec(SqlCommand1)[0][0])[0] - FdfFileName =3D os.path.splitext(EccGlobalData.gDb.TblDsc.= Exec(SqlCommand2)[0][0])[0] + DscFileName =3D os.path.splitext( + EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0] + FdfFileName =3D os.path.splitext( + EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0] if DscFileName !=3D FdfFileName: continue if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_PCD_DUPLICATE, Record[1] + '.' + Record[2]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_DUPLICATE, OtherMsg=3D"The PCD [%s] is defined in both FDF file= and DSC file" % (Record[1] + '.' + Record[2]), BelongsToTable=3D'Dsc', Bel= ongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_DUPLICATE, OtherMsg=3D"The PCD [%s] is defined in both FDF file= and DSC file" % ( + Record[1] + '.' + Record[2]), BelongsToTable=3D'Ds= c', BelongsToItem=3DRecord[0]) if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_PCD_DUPLICATE, Record[5] + '.' + Record[6]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_DUPLICATE, OtherMsg=3D"The PCD [%s] is defined in both FDF file= and DSC file" % (Record[5] + '.' + Record[6]), BelongsToTable=3D'Fdf', Bel= ongsToItem=3DRecord[4]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_DUPLICATE, OtherMsg=3D"The PCD [%s] is defined in both FDF file= and DSC file" % ( + Record[5] + '.' + Record[6]), BelongsToTable=3D'Fd= f', BelongsToItem=3DRecord[4]) =20 - EdkLogger.quiet("Checking for duplicate PCDs defined in DEC fi= les ...") + EdkLogger.quiet( + "Checking for duplicate PCDs defined in DEC files ...") SqlCommand =3D """ select A.ID, A.Value1, A.Value2, A.Model, B.Model= from Dec as A left join Dec as B where A.Model >=3D %s and A.Model < %s @@ -1034,12 +1083,14 @@ class Check(object): for Record in RecordSet: RecordCat =3D Record[1] + '.' + Record[2] if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_PCD_DUPLICATE, RecordCat): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_DUPLICATE, OtherMsg=3D"The PCD [%s] is defined duplicated in DE= C file" % RecordCat, BelongsToTable=3D'Dec', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg= =3D"The PCD [%s] is defined duplicated in DEC file" % RecordCat, BelongsToT= able=3D'Dec', BelongsToItem=3DRecord[0]) =20 # Check whether PCD settings in the FDF file can only be related to fl= ash. def MetaDataFileCheckPcdFlash(self): if EccGlobalData.gConfig.MetaDataFileCheckPcdFlash =3D=3D '1' or E= ccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData.gConf= ig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking only Flash related PCDs are used in = FDF ...") + EdkLogger.quiet( + "Checking only Flash related PCDs are used in FDF ...") SqlCommand =3D """ select ID, Value1, Value2, BelongsToFile from Fdf= as A where A.Model >=3D %s and Model < %s @@ -1049,7 +1100,8 @@ class Check(object): RecordSet =3D EccGlobalData.gDb.TblFdf.Exec(SqlCommand) for Record in RecordSet: if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_PCD_FLASH, Record[1] + '.' + Record[2]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_FLASH, OtherMsg=3D"The PCD [%s] defined in FDF file is not rela= ted to Flash" % (Record[1] + '.' + Record[2]), BelongsToTable=3D'Fdf', Belo= ngsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_FLASH, OtherMsg=3D"The PCD [%s] defined in FDF file is not rela= ted to Flash" % ( + Record[1] + '.' + Record[2]), BelongsToTable=3D'Fd= f', BelongsToItem=3DRecord[0]) =20 # Check whether PCDs used in Inf files but not specified in Dsc or FDF= files def MetaDataFileCheckPcdNoUse(self): @@ -1071,24 +1123,34 @@ class Check(object): RecordSet =3D EccGlobalData.gDb.TblInf.Exec(SqlCommand) for Record in RecordSet: if not EccGlobalData.gException.IsException(ERROR_META_DAT= A_FILE_CHECK_PCD_NO_USE, Record[1] + '.' + Record[2]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_NO_USE, OtherMsg=3D"The PCD [%s] defined in INF file is not spe= cified in either DSC or FDF files" % (Record[1] + '.' + Record[2]), Belongs= ToTable=3D'Inf', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_PCD_NO_USE, OtherMsg=3D"The PCD [%s] defined in INF file is not spe= cified in either DSC or FDF files" % ( + Record[1] + '.' + Record[2]), BelongsToTable=3D'In= f', BelongsToItem=3DRecord[0]) =20 # Check whether having duplicate guids defined for Guid/Protocol/Ppi def MetaDataFileCheckGuidDuplicate(self): if EccGlobalData.gConfig.MetaDataFileCheckGuidDuplicate =3D=3D '1'= or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData.= gConfig.CheckAll =3D=3D '1': EdkLogger.quiet("Checking for duplicate GUID/PPI/PROTOCOL ...") # Check Guid - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _GUID, MODEL_EFI_GUID, EccGlobalData.gDb.TblDec) - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _GUID, MODEL_EFI_GUID, EccGlobalData.gDb.TblDsc) - self.CheckGuidProtocolPpiValue(ERROR_META_DATA_FILE_CHECK_DUPL= ICATE_GUID, MODEL_EFI_GUID) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID, MODEL_EFI_GUID,= EccGlobalData.gDb.TblDec) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID, MODEL_EFI_GUID,= EccGlobalData.gDb.TblDsc) + self.CheckGuidProtocolPpiValue( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID, MODEL_EFI_GUID) # Check protocol - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _PROTOCOL, MODEL_EFI_PROTOCOL, EccGlobalData.gDb.TblDec) - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _PROTOCOL, MODEL_EFI_PROTOCOL, EccGlobalData.gDb.TblDsc) - self.CheckGuidProtocolPpiValue(ERROR_META_DATA_FILE_CHECK_DUPL= ICATE_PROTOCOL, MODEL_EFI_PROTOCOL) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL, MODEL_EFI_P= ROTOCOL, EccGlobalData.gDb.TblDec) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL, MODEL_EFI_P= ROTOCOL, EccGlobalData.gDb.TblDsc) + self.CheckGuidProtocolPpiValue( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL, MODEL_EFI_P= ROTOCOL) # Check ppi - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _PPI, MODEL_EFI_PPI, EccGlobalData.gDb.TblDec) - self.CheckGuidProtocolPpi(ERROR_META_DATA_FILE_CHECK_DUPLICATE= _PPI, MODEL_EFI_PPI, EccGlobalData.gDb.TblDsc) - self.CheckGuidProtocolPpiValue(ERROR_META_DATA_FILE_CHECK_DUPL= ICATE_PPI, MODEL_EFI_PPI) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI, MODEL_EFI_PPI, E= ccGlobalData.gDb.TblDec) + self.CheckGuidProtocolPpi( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI, MODEL_EFI_PPI, E= ccGlobalData.gDb.TblDsc) + self.CheckGuidProtocolPpiValue( + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI, MODEL_EFI_PPI) =20 # Check whether all files under module directory are described in INF = files def MetaDataFileCheckModuleFileNoUse(self): @@ -1112,15 +1174,18 @@ class Check(object): RecordSet =3D EccGlobalData.gDb.TblInf.Exec(SqlCommand) for Record in RecordSet: Path =3D Record[1] - Path =3D Path.upper().replace('\X64', '').replace('\IA32',= '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '') + Path =3D Path.upper().replace('\X64', '').replace('\IA32',= '').replace( + '\EBC', '').replace('\IPF', '').replace('\ARM', '') if Path in InfPathList: if not EccGlobalData.gException.IsException(ERROR_META= _DATA_FILE_CHECK_MODULE_FILE_NO_USE, Record[2]): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg=3D"The source file [%s] is existin= g in module directory but it is not described in INF file." % (Record[2]), = BelongsToTable=3D'File', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg=3D"The source file [%s] is existin= g in module directory but it is not described in INF file." % ( + Record[2]), BelongsToTable=3D'File', BelongsTo= Item=3DRecord[0]) =20 # Check whether the PCD is correctly used in C function via its type def MetaDataFileCheckPcdType(self): if EccGlobalData.gConfig.MetaDataFileCheckPcdType =3D=3D '1' or Ec= cGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlobalData.gConfi= g.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for pcd type in c code function usag= e ...") + EdkLogger.quiet( + "Checking for pcd type in c code function usage ...") SqlCommand =3D """ select ID, Model, Value1, Value2, BelongsToFile f= rom INF where Model > %s and Model < %s """ % (MODEL_PCD, MODEL_META_DATA_HEADER) @@ -1148,19 +1213,23 @@ class Check(object): FunName =3D Record[0] if not EccGlobalData.gException.IsException(ERROR_= META_DATA_FILE_CHECK_PCD_TYPE, FunName): if Model in [MODEL_PCD_FIXED_AT_BUILD] and not= FunName.startswith('FixedPcdGet'): - EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a FixP= cd but now it is called by c function [%s]" % (PcdName, FunName), BelongsTo= Table=3DTblName, BelongsToItem=3DRecord[1]) + EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a FixP= cd but now it is called by c function [%s]" % ( + PcdName, FunName), BelongsToTable=3DTb= lName, BelongsToItem=3DRecord[1]) if Model in [MODEL_PCD_FEATURE_FLAG] and (not = FunName.startswith('FeaturePcdGet') and not FunName.startswith('FeaturePcdS= et')): - EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a Feat= urePcd but now it is called by c function [%s]" % (PcdName, FunName), Belon= gsToTable=3DTblName, BelongsToItem=3DRecord[1]) + EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a Feat= urePcd but now it is called by c function [%s]" % ( + PcdName, FunName), BelongsToTable=3DTb= lName, BelongsToItem=3DRecord[1]) if Model in [MODEL_PCD_PATCHABLE_IN_MODULE] an= d (not FunName.startswith('PatchablePcdGet') and not FunName.startswith('Pa= tchablePcdSet')): - EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a Patc= hablePcd but now it is called by c function [%s]" % (PcdName, FunName), Bel= ongsToTable=3DTblName, BelongsToItem=3DRecord[1]) + EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_PCD_TYPE, OtherMsg=3D"The pcd '%s' is defined as a Patc= hablePcd but now it is called by c function [%s]" % ( + PcdName, FunName), BelongsToTable=3DTb= lName, BelongsToItem=3DRecord[1]) =20 - #ERROR_META_DATA_FILE_CHECK_PCD_TYPE + # ERROR_META_DATA_FILE_CHECK_PCD_TYPE pass =20 # Internal worker function to get the INF workspace relative path from= FileID def GetInfFilePathFromID(self, FileID): Table =3D EccGlobalData.gDb.TblFile - SqlCommand =3D """select A.FullPath from %s as A where A.ID =3D %s= """ % (Table.Table, FileID) + SqlCommand =3D """select A.FullPath from %s as A where A.ID =3D %s= """ % ( + Table.Table, FileID) RecordSet =3D Table.Exec(SqlCommand) Path =3D "" for Record in RecordSet: @@ -1170,7 +1239,8 @@ class Check(object): # Check whether two module INFs under one workspace has the same FILE_= GUID value def MetaDataFileCheckModuleFileGuidDuplication(self): if EccGlobalData.gConfig.MetaDataFileCheckModuleFileGuidDuplicatio= n =3D=3D '1' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or Ec= cGlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking for pcd type in c code function usag= e ...") + EdkLogger.quiet( + "Checking for pcd type in c code function usage ...") Table =3D EccGlobalData.gDb.TblInf SqlCommand =3D """ select A.ID, A.Value3, A.BelongsToFile, B.Belongs= ToFile from %s as A, %s as B @@ -1183,11 +1253,13 @@ class Check(object): InfPath2 =3D self.GetInfFilePathFromID(Record[3]) if InfPath1 and InfPath2: if not EccGlobalData.gException.IsException(ERROR_META= _DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, InfPath1): - Msg =3D "The FILE_GUID of INF file [%s] is duplica= ted with that of %s" % (InfPath1, InfPath2) - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, OtherMsg=3DMsg, BelongsToTable=3D= Table.Table, BelongsToItem=3DRecord[0]) - + Msg =3D "The FILE_GUID of INF file [%s] is duplica= ted with that of %s" % ( + InfPath1, InfPath2) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DU= PLICATION, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRe= cord[0]) =20 # Check Guid Format in module INF + def MetaDataFileCheckModuleFileGuidFormat(self): if EccGlobalData.gConfig.MetaDataFileCheckModuleFileGuidFormat =3D= =3D '1' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlob= alData.gConfig.CheckAll =3D=3D '1': EdkLogger.quiet("Check Guid Format in module INF ...") @@ -1201,7 +1273,8 @@ class Check(object): Value2 =3D Record[2] GuidCommentList =3D [] InfPath =3D self.GetInfFilePathFromID(Record[3]) - Msg =3D "The GUID format of %s in INF file [%s] does not f= ollow rules" % (Value1, InfPath) + Msg =3D "The GUID format of %s in INF file [%s] does not f= ollow rules" % ( + Value1, InfPath) if Value2.startswith(DT.TAB_SPECIAL_COMMENT): GuidCommentList =3D Value2[2:].split(DT.TAB_SPECIAL_CO= MMENT) if GuidCommentList[0].strip().startswith(DT.TAB_INF_US= AGE_UNDEFINED): @@ -1211,7 +1284,8 @@ class Check(object): DT.T= AB_INF_USAGE_SOME_PRO, DT.T= AB_INF_USAGE_CON, DT.T= AB_INF_USAGE_SOME_CON)): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, = BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, Ot= herMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) if not (GuidCommentList[1].strip()).startswith(DT.= TAB_INF_GUIDTYPE_VAR) and \ not GuidCommentList[1].strip().startswith((DT.= TAB_INF_GUIDTYPE_EVENT, DT.= TAB_INF_GUIDTYPE_HII, @@ -1224,11 +1298,14 @@ class Check(object): DT.= TAB_INF_GUIDTYPE_PROTOCOL, DT.= TAB_INF_GUIDTYPE_PPI, DT.= TAB_INF_USAGE_UNDEFINED)): - EccGlobalData.gDb.TblReport.Insert(ERROR_M= ETA_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=3DMsg, BelongsToTable=3DTable.Tab= le, BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, Ot= herMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) else: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA= _FILE_CHECK_FORMAT_GUID, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, Belo= ngsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherM= sg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) else: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_FORMAT_GUID, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsT= oItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg= =3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) =20 # Check Protocol Format in module INF def MetaDataFileCheckModuleFileProtocolFormat(self): @@ -1244,7 +1321,8 @@ class Check(object): Value2 =3D Record[2] GuidCommentList =3D [] InfPath =3D self.GetInfFilePathFromID(Record[3]) - Msg =3D "The Protocol format of %s in INF file [%s] does n= ot follow rules" % (Value1, InfPath) + Msg =3D "The Protocol format of %s in INF file [%s] does n= ot follow rules" % ( + Value1, InfPath) if Value2.startswith(DT.TAB_SPECIAL_COMMENT): GuidCommentList =3D Value2[2:].split(DT.TAB_SPECIAL_CO= MMENT) if len(GuidCommentList) >=3D 1: @@ -1256,12 +1334,14 @@ class Check(object): DT.T= AB_INF_USAGE_TO_START, DT.T= AB_INF_USAGE_BY_START, DT.T= AB_INF_USAGE_UNDEFINED)): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_FORMAT_PROTOCOL, OtherMsg=3DMsg, BelongsToTable=3DTable.Tab= le, BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL= , OtherMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) else: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_FORMAT_PROTOCOL, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, Belo= ngsToItem=3DRecord[0]) - + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL, OtherM= sg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) =20 # Check Ppi Format in module INF + def MetaDataFileCheckModuleFilePpiFormat(self): if EccGlobalData.gConfig.MetaDataFileCheckModuleFilePpiFormat =3D= =3D '1' or EccGlobalData.gConfig.MetaDataFileCheckAll =3D=3D '1' or EccGlob= alData.gConfig.CheckAll =3D=3D '1': EdkLogger.quiet("Check Ppi Format in module INF ...") @@ -1275,7 +1355,8 @@ class Check(object): Value2 =3D Record[2] GuidCommentList =3D [] InfPath =3D self.GetInfFilePathFromID(Record[3]) - Msg =3D "The Ppi format of %s in INF file [%s] does not fo= llow rules" % (Value1, InfPath) + Msg =3D "The Ppi format of %s in INF file [%s] does not fo= llow rules" % ( + Value1, InfPath) if Value2.startswith(DT.TAB_SPECIAL_COMMENT): GuidCommentList =3D Value2[2:].split(DT.TAB_SPECIAL_CO= MMENT) if len(GuidCommentList) >=3D 1: @@ -1285,9 +1366,11 @@ class Check(object): DT.T= AB_INF_USAGE_SOME_CON, DT.T= AB_INF_USAGE_NOTIFY, DT.T= AB_INF_USAGE_UNDEFINED)): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_FORMAT_PPI, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, B= elongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PPI, Oth= erMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) else: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_FORMAT_PPI, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsTo= Item=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PPI, OtherMsg=3D= Msg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) =20 # Check Pcd Format in module INF def MetaDataFileCheckModuleFilePcdFormat(self): @@ -1304,7 +1387,8 @@ class Check(object): Usage =3D Record[4] PcdCommentList =3D [] InfPath =3D self.GetInfFilePathFromID(Record[5]) - Msg =3D "The Pcd format of %s in INF file [%s] does not fo= llow rules" % (PcdName, InfPath) + Msg =3D "The Pcd format of %s in INF file [%s] does not fo= llow rules" % ( + PcdName, InfPath) if Usage.startswith(DT.TAB_SPECIAL_COMMENT): PcdCommentList =3D Usage[2:].split(DT.TAB_SPECIAL_COMM= ENT) if len(PcdCommentList) >=3D 1: @@ -1312,16 +1396,19 @@ class Check(object): and not PcdCommentList[0].strip().startswith((= DT.TAB_INF_USAGE_SOME_PRO, = DT.TAB_INF_USAGE_CON, = DT.TAB_INF_USAGE_UNDEFINED)): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, B= elongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, Oth= erMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) if Model in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_= PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX] \ and not PcdCommentList[0].strip().startswith((= DT.TAB_INF_USAGE_PRO, = DT.TAB_INF_USAGE_SOME_PRO, = DT.TAB_INF_USAGE_CON, = DT.TAB_INF_USAGE_SOME_CON, = DT.TAB_INF_USAGE_UNDEFINED)): - EccGlobalData.gDb.TblReport.Insert(ERROR_META_= DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, B= elongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, Oth= erMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) else: - EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FIL= E_CHECK_FORMAT_PCD, OtherMsg=3DMsg, BelongsToTable=3DTable.Table, BelongsTo= Item=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=3D= Msg, BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) =20 # Check whether these is duplicate Guid/Ppi/Protocol name def CheckGuidProtocolPpi(self, ErrorID, Model, Table): @@ -1344,7 +1431,8 @@ class Check(object): RecordSet =3D Table.Exec(SqlCommand) for Record in RecordSet: if not EccGlobalData.gException.IsException(ErrorID, Record[1]= ): - EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg=3D"Th= e %s name [%s] is defined more than one time" % (Name.upper(), Record[1]), = BelongsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg=3D"Th= e %s name [%s] is defined more than one time" % ( + Name.upper(), Record[1]), BelongsToTable=3DTable.Table= , BelongsToItem=3DRecord[0]) =20 # Check whether these is duplicate Guid/Ppi/Protocol value def CheckGuidProtocolPpiValue(self, ErrorID, Model): @@ -1366,17 +1454,18 @@ class Check(object): RecordSet =3D Table.Exec(SqlCommand) for Record in RecordSet: if not EccGlobalData.gException.IsException(ErrorID, Record[2]= ): - EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg=3D"Th= e %s value [%s] is used more than one time" % (Name.upper(), Record[2]), Be= longsToTable=3DTable.Table, BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg=3D"Th= e %s value [%s] is used more than one time" % ( + Name.upper(), Record[2]), BelongsToTable=3DTable.Table= , BelongsToItem=3DRecord[0]) =20 # Naming Convention Check def NamingConventionCheck(self): if EccGlobalData.gConfig.NamingConventionCheckDefineStatement =3D= =3D '1' \ - or EccGlobalData.gConfig.NamingConventionCheckTypedefStatement =3D= =3D '1' \ - or EccGlobalData.gConfig.NamingConventionCheckIfndefStatement =3D= =3D '1' \ - or EccGlobalData.gConfig.NamingConventionCheckVariableName =3D=3D = '1' \ - or EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVaria= ble =3D=3D '1' \ - or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '1'\ - or EccGlobalData.gConfig.CheckAll =3D=3D '1': + or EccGlobalData.gConfig.NamingConventionCheckTypedefState= ment =3D=3D '1' \ + or EccGlobalData.gConfig.NamingConventionCheckIfndefStatem= ent =3D=3D '1' \ + or EccGlobalData.gConfig.NamingConventionCheckVariableName= =3D=3D '1' \ + or EccGlobalData.gConfig.NamingConventionCheckSingleCharac= terVariable =3D=3D '1' \ + or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '= 1'\ + or EccGlobalData.gConfig.CheckAll =3D=3D '1': for Dirpath, Dirnames, Filenames in self.WalkTree(): for F in Filenames: if os.path.splitext(F)[1] in ('.h', '.c'): @@ -1388,9 +1477,11 @@ class Check(object): self.NamingConventionCheckDefineStatement(FileTabl= e) self.NamingConventionCheckTypedefStatement(FileTab= le) self.NamingConventionCheckVariableName(FileTable) - self.NamingConventionCheckSingleCharacterVariable(= FileTable) + self.NamingConventionCheckSingleCharacterVariable( + FileTable) if os.path.splitext(F)[1] in ('.h'): - self.NamingConventionCheckIfndefStatement(File= Table) + self.NamingConventionCheckIfndefStatement( + FileTable) =20 self.NamingConventionCheckPathName() self.NamingConventionCheckFunctionName() @@ -1398,9 +1489,11 @@ class Check(object): # Check whether only capital letters are used for #define declarations def NamingConventionCheckDefineStatement(self, FileTable): if EccGlobalData.gConfig.NamingConventionCheckDefineStatement =3D= =3D '1' or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking naming convention of #define stateme= nt ...") + EdkLogger.quiet( + "Checking naming convention of #define statement ...") =20 - SqlCommand =3D """select ID, Value from %s where Model =3D %s"= "" % (FileTable, MODEL_IDENTIFIER_MACRO_DEFINE) + SqlCommand =3D """select ID, Value from %s where Model =3D %s"= "" % ( + FileTable, MODEL_IDENTIFIER_MACRO_DEFINE) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Record in RecordSet: Name =3D Record[1].strip().split()[1] @@ -1408,14 +1501,17 @@ class Check(object): Name =3D Name[0:Name.find('(')] if Name.upper() !=3D Name: if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_DEFINE_STATEMENT, Name): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_DEFINE_STATEMENT, OtherMsg=3D"The #define name [%s] does not= follow the rules" % (Name), BelongsToTable=3DFileTable, BelongsToItem=3DRe= cord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_DEFINE_STATEMENT, OtherMsg=3D"The #define name [%s] does not= follow the rules" % ( + Name), BelongsToTable=3DFileTable, BelongsToIt= em=3DRecord[0]) =20 # Check whether only capital letters are used for typedef declarations def NamingConventionCheckTypedefStatement(self, FileTable): if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement =3D= =3D '1' or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking naming convention of #typedef statem= ent ...") + EdkLogger.quiet( + "Checking naming convention of #typedef statement ...") =20 - SqlCommand =3D """select ID, Name from %s where Model =3D %s""= " % (FileTable, MODEL_IDENTIFIER_TYPEDEF) + SqlCommand =3D """select ID, Name from %s where Model =3D %s""= " % ( + FileTable, MODEL_IDENTIFIER_TYPEDEF) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Record in RecordSet: Name =3D Record[1].strip() @@ -1423,27 +1519,32 @@ class Check(object): if Name[0] =3D=3D '(': Name =3D Name[1:Name.find(')')] if Name.find('(') > -1: - Name =3D Name[Name.find('(') + 1 : Name.find(')')] + Name =3D Name[Name.find('(') + 1: Name.find(')')] Name =3D Name.replace('WINAPI', '') Name =3D Name.replace('*', '').strip() if Name.upper() !=3D Name: if not EccGlobalData.gException.IsException(ERROR_= NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT, Name): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMIN= G_CONVENTION_CHECK_TYPEDEF_STATEMENT, OtherMsg=3D"The #typedef name [%s] do= es not follow the rules" % (Name), BelongsToTable=3DFileTable, BelongsToIte= m=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMIN= G_CONVENTION_CHECK_TYPEDEF_STATEMENT, OtherMsg=3D"The #typedef name [%s] do= es not follow the rules" % ( + Name), BelongsToTable=3DFileTable, Belongs= ToItem=3DRecord[0]) =20 # Check whether the #ifndef at the start of an include file uses both = prefix and postfix underscore characters, '_'. def NamingConventionCheckIfndefStatement(self, FileTable): if EccGlobalData.gConfig.NamingConventionCheckIfndefStatement =3D= =3D '1' or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '1' or Ecc= GlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking naming convention of #ifndef stateme= nt ...") + EdkLogger.quiet( + "Checking naming convention of #ifndef statement ...") =20 - SqlCommand =3D """select ID, Value from %s where Model =3D %s"= "" % (FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF) + SqlCommand =3D """select ID, Value from %s where Model =3D %s"= "" % ( + FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) if RecordSet: # Only check the first ifndef statement of the file - FirstDefine =3D sorted(RecordSet, key=3Dlambda Record: Rec= ord[0])[0] + FirstDefine =3D sorted( + RecordSet, key=3Dlambda Record: Record[0])[0] Name =3D FirstDefine[1].replace('#ifndef', '').strip() if Name[0] =3D=3D '_' or Name[-1] !=3D '_' or Name[-2] =3D= =3D '_': if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_IFNDEF_STATEMENT, Name): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg=3D"The #ifndef name [%s] does not= follow the rules" % (Name), BelongsToTable=3DFileTable, BelongsToItem=3DFi= rstDefine[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg=3D"The #ifndef name [%s] does not= follow the rules" % ( + Name), BelongsToTable=3DFileTable, BelongsToIt= em=3DFirstDefine[0]) =20 # Rule for path name, variable name and function name # 1. First character should be upper case @@ -1459,7 +1560,8 @@ class Check(object): for Record in RecordSet: if not Pattern.match(Record[1]): if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_PATH_NAME, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_PATH_NAME, OtherMsg=3D"The file path [%s] does not follow th= e rules" % (Record[1]), BelongsToTable=3D'File', BelongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_PATH_NAME, OtherMsg=3D"The file path [%s] does not follow th= e rules" % ( + Record[1]), BelongsToTable=3D'File', BelongsTo= Item=3DRecord[0]) =20 # Rule for path name, variable name and function name # 1. First character should be upper case @@ -1472,7 +1574,8 @@ class Check(object): EdkLogger.quiet("Checking naming convention of variable name .= ..") Pattern =3D re.compile(r'^[A-Zgm]+\S*[a-z]\S*$') =20 - SqlCommand =3D """select ID, Name, Modifier from %s where Mode= l =3D %s""" % (FileTable, MODEL_IDENTIFIER_VARIABLE) + SqlCommand =3D """select ID, Name, Modifier from %s where Mode= l =3D %s""" % ( + FileTable, MODEL_IDENTIFIER_VARIABLE) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Record in RecordSet: Var =3D Record[1] @@ -1481,7 +1584,8 @@ class Check(object): Var =3D Var[5:].lstrip() if not Pattern.match(Var) and not (Modifier.endswith('*') = and Var.startswith('p')): if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_VARIABLE_NAME, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_VARIABLE_NAME, OtherMsg=3D"The variable name [%s] does not f= ollow the rules" % (Record[1]), BelongsToTable=3DFileTable, BelongsToItem= =3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_VARIABLE_NAME, OtherMsg=3D"The variable name [%s] does not f= ollow the rules" % ( + Record[1]), BelongsToTable=3DFileTable, Belong= sToItem=3DRecord[0]) =20 # Rule for path name, variable name and function name # 1. First character should be upper case @@ -1497,20 +1601,25 @@ class Check(object): for Record in RecordSet: if not Pattern.match(Record[1]): if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_FUNCTION_NAME, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_FUNCTION_NAME, OtherMsg=3D"The function name [%s] does not f= ollow the rules" % (Record[1]), BelongsToTable=3D'Function', BelongsToItem= =3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_FUNCTION_NAME, OtherMsg=3D"The function name [%s] does not f= ollow the rules" % ( + Record[1]), BelongsToTable=3D'Function', Belon= gsToItem=3DRecord[0]) =20 # Check whether NO use short variable name with single character def NamingConventionCheckSingleCharacterVariable(self, FileTable): if EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVaria= ble =3D=3D '1' or EccGlobalData.gConfig.NamingConventionCheckAll =3D=3D '1'= or EccGlobalData.gConfig.CheckAll =3D=3D '1': - EdkLogger.quiet("Checking naming convention of single characte= r variable name ...") + EdkLogger.quiet( + "Checking naming convention of single character variable n= ame ...") =20 - SqlCommand =3D """select ID, Name from %s where Model =3D %s""= " % (FileTable, MODEL_IDENTIFIER_VARIABLE) + SqlCommand =3D """select ID, Name from %s where Model =3D %s""= " % ( + FileTable, MODEL_IDENTIFIER_VARIABLE) RecordSet =3D EccGlobalData.gDb.TblFile.Exec(SqlCommand) for Record in RecordSet: Variable =3D Record[1].replace('*', '') if len(Variable) =3D=3D 1: if not EccGlobalData.gException.IsException(ERROR_NAMI= NG_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, Record[1]): - EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, OtherMsg=3D"The variable name [%s= ] does not follow the rules" % (Record[1]), BelongsToTable=3DFileTable, Bel= ongsToItem=3DRecord[0]) + EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CO= NVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, OtherMsg=3D"The variable name [%s= ] does not follow the rules" % ( + Record[1]), BelongsToTable=3DFileTable, Belong= sToItem=3DRecord[0]) + =20 def FindPara(FilePath, Para, CallingLine): Lines =3D open(FilePath).readlines() @@ -1525,6 +1634,7 @@ def FindPara(FilePath, Para, CallingLine): =20 return '' =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Ecc/CodeFragment.py b/BaseTools/Source= /Python/Ecc/CodeFragment.py index 8ced51f25bde..2f558196ae3c 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragment.py +++ b/BaseTools/Source/Python/Ecc/CodeFragment.py @@ -1,4 +1,4 @@ -## @file +# @file # fragments of source file # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -7,11 +7,11 @@ # =20 =20 -## The description of comment contents and start & end position +# The description of comment contents and start & end position # # -class Comment : - ## The constructor +class Comment: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -25,11 +25,13 @@ class Comment : self.EndPos =3D End self.Type =3D CommentType =20 -## The description of preprocess directives and start & end position +# The description of preprocess directives and start & end position # # -class PP_Directive : - ## The constructor + + +class PP_Directive: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -41,11 +43,13 @@ class PP_Directive : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of predicate expression and start & end position +# The description of predicate expression and start & end position # # -class PredicateExpression : - ## The constructor + + +class PredicateExpression: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -57,11 +61,13 @@ class PredicateExpression : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of function definition and start & end position +# The description of function definition and start & end position # # -class FunctionDefinition : - ## The constructor + + +class FunctionDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -77,11 +83,13 @@ class FunctionDefinition : self.LeftBracePos =3D LBPos self.NamePos =3D NamePos =20 -## The description of variable declaration and start & end position +# The description of variable declaration and start & end position # # -class VariableDeclaration : - ## The constructor + + +class VariableDeclaration: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -94,11 +102,13 @@ class VariableDeclaration : self.StartPos =3D Begin self.NameStartPos =3D NamePos =20 -## The description of enum definition and start & end position +# The description of enum definition and start & end position # # -class EnumerationDefinition : - ## The constructor + + +class EnumerationDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -110,11 +120,13 @@ class EnumerationDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of struct/union definition and start & end position +# The description of struct/union definition and start & end position # # -class StructUnionDefinition : - ## The constructor + + +class StructUnionDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -126,11 +138,13 @@ class StructUnionDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of 'Typedef' definition and start & end position +# The description of 'Typedef' definition and start & end position # # -class TypedefDefinition : - ## The constructor + + +class TypedefDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -143,8 +157,9 @@ class TypedefDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 + class FunctionCalling: - ## The constructor + # The constructor # # @param self The object pointer # @param Str The message to record @@ -156,4 +171,3 @@ class FunctionCalling: self.ParamList =3D Param self.StartPos =3D Begin self.EndPos =3D End - diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseToo= ls/Source/Python/Ecc/CodeFragmentCollector.py index d8d6aff08a6e..1f0bae3d6b92 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py @@ -1,4 +1,4 @@ -## @file +# @file # preprocess source file # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -32,21 +32,21 @@ from Ecc.CodeFragment import PP_Directive from Ecc.ParserWarning import Warning =20 =20 -##define T_CHAR_SPACE ' ' -##define T_CHAR_NULL '\0' -##define T_CHAR_CR '\r' -##define T_CHAR_TAB '\t' -##define T_CHAR_LF '\n' -##define T_CHAR_SLASH '/' -##define T_CHAR_BACKSLASH '\\' -##define T_CHAR_DOUBLE_QUOTE '\"' -##define T_CHAR_SINGLE_QUOTE '\'' -##define T_CHAR_STAR '*' -##define T_CHAR_HASH '#' +# define T_CHAR_SPACE ' ' +# define T_CHAR_NULL '\0' +# define T_CHAR_CR '\r' +# define T_CHAR_TAB '\t' +# define T_CHAR_LF '\n' +# define T_CHAR_SLASH '/' +# define T_CHAR_BACKSLASH '\\' +# define T_CHAR_DOUBLE_QUOTE '\"' +# define T_CHAR_SINGLE_QUOTE '\'' +# define T_CHAR_STAR '*' +# define T_CHAR_HASH '#' =20 -(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH= , \ -T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T= _CHAR_HASH) =3D \ -(' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') +(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH, + T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, = T_CHAR_HASH) =3D \ + (' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') =20 SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}') =20 @@ -54,15 +54,17 @@ SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}') =20 (T_PP_INCLUDE, T_PP_DEFINE, T_PP_OTHERS) =3D (0, 1, 2) =20 -## The collector for source code fragments. +# The collector for source code fragments. # # PreprocessFile method should be called prior to ParseFile # # GetNext*** procedures mean these procedures will get next token first, t= hen make judgement. # Get*** procedures mean these procedures will make judgement on current t= oken only. # + + class CodeFragmentCollector: - ## The constructor + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed @@ -77,7 +79,7 @@ class CodeFragmentCollector: self.__Token =3D "" self.__SkippedChars =3D "" =20 - ## __EndOfFile() method + # __EndOfFile() method # # Judge current buffer pos is at file end # @@ -98,7 +100,7 @@ class CodeFragmentCollector: else: return False =20 - ## __EndOfLine() method + # __EndOfLine() method # # Judge current buffer pos is at line end # @@ -107,13 +109,14 @@ class CodeFragmentCollector: # @retval False Current File buffer position is NOT at line end # def __EndOfLine(self): - SizeOfCurrentLine =3D len(self.Profile.FileLinesList[self.CurrentL= ineNumber - 1]) + SizeOfCurrentLine =3D len( + self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if self.CurrentOffsetWithinLine >=3D SizeOfCurrentLine - 1: return True else: return False =20 - ## Rewind() method + # Rewind() method # # Reset file data buffer to the initial state # @@ -123,7 +126,7 @@ class CodeFragmentCollector: self.CurrentLineNumber =3D 1 self.CurrentOffsetWithinLine =3D 0 =20 - ## __UndoOneChar() method + # __UndoOneChar() method # # Go back one char in the file buffer # @@ -142,7 +145,7 @@ class CodeFragmentCollector: self.CurrentOffsetWithinLine -=3D 1 return True =20 - ## __GetOneChar() method + # __GetOneChar() method # # Move forward one char in the file buffer # @@ -150,12 +153,12 @@ class CodeFragmentCollector: # def __GetOneChar(self): if self.CurrentOffsetWithinLine =3D=3D len(self.Profile.FileLinesL= ist[self.CurrentLineNumber - 1]) - 1: - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 + self.CurrentLineNumber +=3D 1 + self.CurrentOffsetWithinLine =3D 0 else: - self.CurrentOffsetWithinLine +=3D 1 + self.CurrentOffsetWithinLine +=3D 1 =20 - ## __CurrentChar() method + # __CurrentChar() method # # Get the char pointed to by the file buffer pointer # @@ -163,12 +166,13 @@ class CodeFragmentCollector: # @retval Char Current char # def __CurrentChar(self): - CurrentChar =3D self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine] + CurrentChar =3D self.Profile.FileLinesList[self.CurrentLineNumber - + 1][self.CurrentOffsetWith= inLine] # if CurrentChar > 255: # raise Warning("Non-Ascii char found At Line %d, offset %d" % = (self.CurrentLineNumber, self.CurrentOffsetWithinLine), self.FileName, self= .CurrentLineNumber) return CurrentChar =20 - ## __NextChar() method + # __NextChar() method # # Get the one char pass the char pointed to by the file buffer point= er # @@ -181,7 +185,7 @@ class CodeFragmentCollector: else: return self.Profile.FileLinesList[self.CurrentLineNumber - 1][= self.CurrentOffsetWithinLine + 1] =20 - ## __SetCurrentCharValue() method + # __SetCurrentCharValue() method # # Modify the value of current char # @@ -189,9 +193,10 @@ class CodeFragmentCollector: # @param Value The new value of current char # def __SetCurrentCharValue(self, Value): - self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.Curren= tOffsetWithinLine] =3D Value + self.Profile.FileLinesList[self.CurrentLineNumber - + 1][self.CurrentOffsetWithinLine] =3D Va= lue =20 - ## __SetCharValue() method + # __SetCharValue() method # # Modify the value of current char # @@ -201,7 +206,7 @@ class CodeFragmentCollector: def __SetCharValue(self, Line, Offset, Value): self.Profile.FileLinesList[Line - 1][Offset] =3D Value =20 - ## __CurrentLine() method + # __CurrentLine() method # # Get the list that contains current line contents # @@ -211,7 +216,7 @@ class CodeFragmentCollector: def __CurrentLine(self): return self.Profile.FileLinesList[self.CurrentLineNumber - 1] =20 - ## __InsertComma() method + # __InsertComma() method # # Insert ',' to replace PP # @@ -220,9 +225,9 @@ class CodeFragmentCollector: # def __InsertComma(self, Line): =20 - if self.Profile.FileLinesList[Line - 1][0] !=3D T_CHAR_HASH: - BeforeHashPart =3D str(self.Profile.FileLinesList[Line - 1]).s= plit(T_CHAR_HASH)[0] + BeforeHashPart =3D str( + self.Profile.FileLinesList[Line - 1]).split(T_CHAR_HASH)[0] if BeforeHashPart.rstrip().endswith(T_CHAR_COMMA) or BeforeHas= hPart.rstrip().endswith(';'): return =20 @@ -235,9 +240,10 @@ class CodeFragmentCollector: if str(self.Profile.FileLinesList[Line]).lstrip().startswith(',') = or str(self.Profile.FileLinesList[Line]).lstrip().startswith(';'): return =20 - self.Profile.FileLinesList[Line - 1].insert(self.CurrentOffsetWith= inLine, ',') + self.Profile.FileLinesList[Line - + 1].insert(self.CurrentOffsetWithinLine,= ',') =20 - ## PreprocessFile() method + # PreprocessFile() method # # Preprocess file contents, replace comments with spaces. # In the end, rewind the file buffer pointer to the beginning @@ -259,7 +265,8 @@ class CodeFragmentCollector: InString =3D False InCharLiteral =3D False =20 - self.Profile.FileLinesList =3D [list(s) for s in self.Profile.File= LinesListFromFile] + self.Profile.FileLinesList =3D [ + list(s) for s in self.Profile.FileLinesListFromFile] while not self.__EndOfFile(): =20 if not InComment and self.__CurrentChar() =3D=3D T_CHAR_DOUBLE= _QUOTE: @@ -276,7 +283,8 @@ class CodeFragmentCollector: else: PPExtend =3D False =20 - EndLinePos =3D (self.CurrentLineNumber, self.CurrentOffset= WithinLine) + EndLinePos =3D (self.CurrentLineNumber, + self.CurrentOffsetWithinLine) =20 if InComment and DoubleSlashComment: InComment =3D False @@ -297,7 +305,8 @@ class CodeFragmentCollector: CurrentLine =3D "".join(self.__CurrentLine()) if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).end= swith(T_CHAR_BACKSLASH): SlashIndex =3D CurrentLine.rindex(T_CHAR_BACKSLASH) - self.__SetCharValue(self.CurrentLineNumber, SlashI= ndex, T_CHAR_SPACE) + self.__SetCharValue( + self.CurrentLineNumber, SlashIndex, T_CHAR_SPA= CE) =20 if InComment and not DoubleSlashComment and not HashCommen= t: CommentObj.Content +=3D T_CHAR_LF @@ -310,7 +319,8 @@ class CodeFragmentCollector: self.__GetOneChar() CommentObj.Content +=3D self.__CurrentChar() # self.__SetCurrentCharValue(T_CHAR_SPACE) - CommentObj.EndPos =3D (self.CurrentLineNumber, self.Curren= tOffsetWithinLine) + CommentObj.EndPos =3D (self.CurrentLineNumber, + self.CurrentOffsetWithinLine) FileProfile.CommentList.append(CommentObj) CommentObj =3D None self.__GetOneChar() @@ -322,7 +332,8 @@ class CodeFragmentCollector: if self.__CurrentChar() =3D=3D T_CHAR_SLASH and self._= _NextChar() =3D=3D T_CHAR_SLASH: InComment =3D False HashComment =3D False - PPDirectiveObj.EndPos =3D (self.CurrentLineNumber,= self.CurrentOffsetWithinLine - 1) + PPDirectiveObj.EndPos =3D ( + self.CurrentLineNumber, self.CurrentOffsetWith= inLine - 1) FileProfile.PPDirectiveList.append(PPDirectiveObj) PPDirectiveObj =3D None continue @@ -338,15 +349,18 @@ class CodeFragmentCollector: elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_SLASH: InComment =3D True DoubleSlashComment =3D True - CommentObj =3D Comment('', (self.CurrentLineNumber, self.C= urrentOffsetWithinLine), None, T_COMMENT_TWO_SLASH) + CommentObj =3D Comment( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None, T_COMMENT_TWO_SLASH) # check for '#' comment elif self.__CurrentChar() =3D=3D T_CHAR_HASH and not InString = and not InCharLiteral: InComment =3D True HashComment =3D True - PPDirectiveObj =3D PP_Directive('', (self.CurrentLineNumbe= r, self.CurrentOffsetWithinLine), None) + PPDirectiveObj =3D PP_Directive( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None) # check for /* comment start elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_STAR: - CommentObj =3D Comment('', (self.CurrentLineNumber, self.C= urrentOffsetWithinLine), None, T_COMMENT_SLASH_STAR) + CommentObj =3D Comment( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None, T_COMMENT_SLASH_STAR) CommentObj.Content +=3D self.__CurrentChar() # self.__SetCurrentCharValue( T_CHAR_SPACE) self.__GetOneChar() @@ -381,7 +395,8 @@ class CodeFragmentCollector: InString =3D False InCharLiteral =3D False =20 - self.Profile.FileLinesList =3D [list(s) for s in self.Profile.File= LinesListFromFile] + self.Profile.FileLinesList =3D [ + list(s) for s in self.Profile.FileLinesListFromFile] while not self.__EndOfFile(): =20 if not InComment and self.__CurrentChar() =3D=3D T_CHAR_DOUBLE= _QUOTE: @@ -398,7 +413,8 @@ class CodeFragmentCollector: else: PPExtend =3D False =20 - EndLinePos =3D (self.CurrentLineNumber, self.CurrentOffset= WithinLine) + EndLinePos =3D (self.CurrentLineNumber, + self.CurrentOffsetWithinLine) =20 if InComment and DoubleSlashComment: InComment =3D False @@ -419,7 +435,8 @@ class CodeFragmentCollector: CurrentLine =3D "".join(self.__CurrentLine()) if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).end= swith(T_CHAR_BACKSLASH): SlashIndex =3D CurrentLine.rindex(T_CHAR_BACKSLASH) - self.__SetCharValue(self.CurrentLineNumber, SlashI= ndex, T_CHAR_SPACE) + self.__SetCharValue( + self.CurrentLineNumber, SlashIndex, T_CHAR_SPA= CE) =20 if InComment and not DoubleSlashComment and not HashCommen= t: CommentObj.Content +=3D T_CHAR_LF @@ -432,7 +449,8 @@ class CodeFragmentCollector: self.__GetOneChar() CommentObj.Content +=3D self.__CurrentChar() self.__SetCurrentCharValue(T_CHAR_SPACE) - CommentObj.EndPos =3D (self.CurrentLineNumber, self.Curren= tOffsetWithinLine) + CommentObj.EndPos =3D (self.CurrentLineNumber, + self.CurrentOffsetWithinLine) FileProfile.CommentList.append(CommentObj) CommentObj =3D None self.__GetOneChar() @@ -444,7 +462,8 @@ class CodeFragmentCollector: if self.__CurrentChar() =3D=3D T_CHAR_SLASH and self._= _NextChar() =3D=3D T_CHAR_SLASH: InComment =3D False HashComment =3D False - PPDirectiveObj.EndPos =3D (self.CurrentLineNumber,= self.CurrentOffsetWithinLine - 1) + PPDirectiveObj.EndPos =3D ( + self.CurrentLineNumber, self.CurrentOffsetWith= inLine - 1) FileProfile.PPDirectiveList.append(PPDirectiveObj) PPDirectiveObj =3D None continue @@ -460,20 +479,23 @@ class CodeFragmentCollector: elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_SLASH: InComment =3D True DoubleSlashComment =3D True - CommentObj =3D Comment('', (self.CurrentLineNumber, self.C= urrentOffsetWithinLine), None, T_COMMENT_TWO_SLASH) + CommentObj =3D Comment( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None, T_COMMENT_TWO_SLASH) # check for '#' comment elif self.__CurrentChar() =3D=3D T_CHAR_HASH and not InString = and not InCharLiteral: InComment =3D True HashComment =3D True - PPDirectiveObj =3D PP_Directive('', (self.CurrentLineNumbe= r, self.CurrentOffsetWithinLine), None) + PPDirectiveObj =3D PP_Directive( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None) # check for /* comment start elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_STAR: - CommentObj =3D Comment('', (self.CurrentLineNumber, self.C= urrentOffsetWithinLine), None, T_COMMENT_SLASH_STAR) + CommentObj =3D Comment( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None, T_COMMENT_SLASH_STAR) CommentObj.Content +=3D self.__CurrentChar() - self.__SetCurrentCharValue( T_CHAR_SPACE) + self.__SetCurrentCharValue(T_CHAR_SPACE) self.__GetOneChar() CommentObj.Content +=3D self.__CurrentChar() - self.__SetCurrentCharValue( T_CHAR_SPACE) + self.__SetCurrentCharValue(T_CHAR_SPACE) self.__GetOneChar() InComment =3D True else: @@ -489,7 +511,7 @@ class CodeFragmentCollector: FileProfile.PPDirectiveList.append(PPDirectiveObj) self.Rewind() =20 - ## ParseFile() method + # ParseFile() method # # Parse the file profile buffer to extract fd, fv ... information # Exception will be raised if syntax error found @@ -499,13 +521,15 @@ class CodeFragmentCollector: def ParseFile(self): self.PreprocessFile() # restore from ListOfList to ListOfString - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] + self.Profile.FileLinesList =3D [ + "".join(list) for list in self.Profile.FileLinesList] FileStringContents =3D '' for fileLine in self.Profile.FileLinesList: FileStringContents +=3D fileLine for Token in self.TokenReleaceList: if Token in FileStringContents: - FileStringContents =3D FileStringContents.replace(Token, '= TOKENSTRING') + FileStringContents =3D FileStringContents.replace( + Token, 'TOKENSTRING') cStream =3D antlr.InputStream(FileStringContents) lexer =3D CLexer(cStream) tStream =3D antlr.CommonTokenStream(lexer) @@ -515,7 +539,8 @@ class CodeFragmentCollector: def ParseFileWithClearedPPDirective(self): self.PreprocessFileWithClear() # restore from ListOfList to ListOfString - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] + self.Profile.FileLinesList =3D [ + "".join(list) for list in self.Profile.FileLinesList] FileStringContents =3D '' for fileLine in self.Profile.FileLinesList: FileStringContents +=3D fileLine @@ -556,13 +581,14 @@ class CodeFragmentCollector: print('/********* VARIABLE DECLARATIONS ********/') print('/****************************************/') for var in FileProfile.VariableDeclarationList: - print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator) + print(str(var.StartPos) + var.Modifier + ' ' + var.Declarator) =20 print('/****************************************/') print('/********* FUNCTION DEFINITIONS *********/') print('/****************************************/') for func in FileProfile.FunctionDefinitionList: - print(str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos)) + print(str(func.StartPos) + func.Modifier + ' ' + + func.Declarator + ' ' + str(func.NamePos)) =20 print('/****************************************/') print('/************ ENUMERATIONS **************/') @@ -588,6 +614,7 @@ class CodeFragmentCollector: for typedef in FileProfile.TypedefDefinitionList: print(str(typedef.StartPos) + typedef.ToType) =20 + if __name__ =3D=3D "__main__": =20 collector =3D CodeFragmentCollector(sys.argv[1]) diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Sourc= e/Python/Ecc/Configuration.py index 9d9feaca5eb6..c5ae3acfb8b0 100644 --- a/BaseTools/Source/Python/Ecc/Configuration.py +++ b/BaseTools/Source/Python/Ecc/Configuration.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class Configuration # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -17,129 +17,131 @@ from Common.LongFilePathSupport import OpenLongFilePa= th as open =20 _ConfigFileToInternalTranslation =3D { # not same - "ModifierList":"ModifierSet", + "ModifierList": "ModifierSet", =20 # same # please keep this in correct alphabetical order. - "AutoCorrect":"AutoCorrect", - "BinaryExtList":"BinaryExtList", - "CFunctionLayoutCheckAll":"CFunctionLayoutCheckAll", - "CFunctionLayoutCheckDataDeclaration":"CFunctionLayoutCheckDataDeclara= tion", - "CFunctionLayoutCheckFunctionBody":"CFunctionLayoutCheckFunctionBody", - "CFunctionLayoutCheckFunctionName":"CFunctionLayoutCheckFunctionName", - "CFunctionLayoutCheckFunctionPrototype":"CFunctionLayoutCheckFunctionP= rototype", - "CFunctionLayoutCheckNoInitOfVariable":"CFunctionLayoutCheckNoInitOfVa= riable", - "CFunctionLayoutCheckNoStatic":"CFunctionLayoutCheckNoStatic", - "CFunctionLayoutCheckOptionalFunctionalModifier":"CFunctionLayoutCheck= OptionalFunctionalModifier", - "CFunctionLayoutCheckReturnType":"CFunctionLayoutCheckReturnType", - "CheckAll":"CheckAll", - "Copyright":"Copyright", - "DeclarationDataTypeCheckAll":"DeclarationDataTypeCheckAll", - "DeclarationDataTypeCheckEFIAPIModifier":"DeclarationDataTypeCheckEFIA= PIModifier", - "DeclarationDataTypeCheckEnumeratedType":"DeclarationDataTypeCheckEnum= eratedType", - "DeclarationDataTypeCheckInOutModifier":"DeclarationDataTypeCheckInOut= Modifier", - "DeclarationDataTypeCheckNoUseCType":"DeclarationDataTypeCheckNoUseCTy= pe", - "DeclarationDataTypeCheckSameStructure":"DeclarationDataTypeCheckSameS= tructure", - "DeclarationDataTypeCheckStructureDeclaration":"DeclarationDataTypeChe= ckStructureDeclaration", - "DeclarationDataTypeCheckUnionType":"DeclarationDataTypeCheckUnionType= ", - "DoxygenCheckAll":"DoxygenCheckAll", - "DoxygenCheckCommand":"DoxygenCheckCommand", - "DoxygenCheckCommentDescription":"DoxygenCheckCommentDescription", - "DoxygenCheckCommentFormat":"DoxygenCheckCommentFormat", - "DoxygenCheckFileHeader":"DoxygenCheckFileHeader", - "DoxygenCheckFunctionHeader":"DoxygenCheckFunctionHeader", - "GeneralCheckAll":"GeneralCheckAll", - "GeneralCheckCarriageReturn":"GeneralCheckCarriageReturn", - "GeneralCheckFileExistence":"GeneralCheckFileExistence", - "GeneralCheckIndentation":"GeneralCheckIndentation", - "GeneralCheckIndentationWidth":"GeneralCheckIndentationWidth", - "GeneralCheckLine":"GeneralCheckLine", - "GeneralCheckLineEnding":"GeneralCheckLineEnding", - "GeneralCheckLineWidth":"GeneralCheckLineWidth", - "GeneralCheckNoProgma":"GeneralCheckNoProgma", - "GeneralCheckNoTab":"GeneralCheckNoTab", - "GeneralCheckNo_Asm":"GeneralCheckNo_Asm", - "GeneralCheckNonAcsii":"GeneralCheckNonAcsii", - "GeneralCheckTabWidth":"GeneralCheckTabWidth", - "GeneralCheckTrailingWhiteSpaceLine":"GeneralCheckTrailingWhiteSpaceLi= ne", - "GeneralCheckUni":"GeneralCheckUni", - "HeaderCheckAll":"HeaderCheckAll", - "HeaderCheckCFileCommentLicenseFormat":"HeaderCheckCFileCommentLicense= Format", - "HeaderCheckCFileCommentReferenceFormat":"HeaderCheckCFileCommentRefer= enceFormat", - "HeaderCheckCFileCommentStartSpacesNum":"HeaderCheckCFileCommentStartS= pacesNum", - "HeaderCheckFile":"HeaderCheckFile", - "HeaderCheckFileCommentEnd":"HeaderCheckFileCommentEnd", - "HeaderCheckFunction":"HeaderCheckFunction", - "IncludeFileCheckAll":"IncludeFileCheckAll", - "IncludeFileCheckData":"IncludeFileCheckData", - "IncludeFileCheckIfndefStatement":"IncludeFileCheckIfndefStatement", - "IncludeFileCheckSameName":"IncludeFileCheckSameName", - "MetaDataFileCheckAll":"MetaDataFileCheckAll", - "MetaDataFileCheckBinaryInfInFdf":"MetaDataFileCheckBinaryInfInFdf", - "MetaDataFileCheckGenerateFileList":"MetaDataFileCheckGenerateFileList= ", - "MetaDataFileCheckGuidDuplicate":"MetaDataFileCheckGuidDuplicate", - "MetaDataFileCheckLibraryDefinedInDec":"MetaDataFileCheckLibraryDefine= dInDec", - "MetaDataFileCheckLibraryInstance":"MetaDataFileCheckLibraryInstance", - "MetaDataFileCheckLibraryInstanceDependent":"MetaDataFileCheckLibraryI= nstanceDependent", - "MetaDataFileCheckLibraryInstanceOrder":"MetaDataFileCheckLibraryInsta= nceOrder", - "MetaDataFileCheckLibraryNoUse":"MetaDataFileCheckLibraryNoUse", - "MetaDataFileCheckModuleFileGuidDuplication":"MetaDataFileCheckModuleF= ileGuidDuplication", - "MetaDataFileCheckModuleFileGuidFormat":"MetaDataFileCheckModuleFileGu= idFormat", - "MetaDataFileCheckModuleFileNoUse":"MetaDataFileCheckModuleFileNoUse", - "MetaDataFileCheckModuleFilePcdFormat":"MetaDataFileCheckModuleFilePcd= Format", - "MetaDataFileCheckModuleFilePpiFormat":"MetaDataFileCheckModuleFilePpi= Format", - "MetaDataFileCheckModuleFileProtocolFormat":"MetaDataFileCheckModuleFi= leProtocolFormat", - "MetaDataFileCheckPathName":"MetaDataFileCheckPathName", - "MetaDataFileCheckPathOfGenerateFileList":"MetaDataFileCheckPathOfGene= rateFileList", - "MetaDataFileCheckPcdDuplicate":"MetaDataFileCheckPcdDuplicate", - "MetaDataFileCheckPcdFlash":"MetaDataFileCheckPcdFlash", - "MetaDataFileCheckPcdNoUse":"MetaDataFileCheckPcdNoUse", - "MetaDataFileCheckPcdType":"MetaDataFileCheckPcdType", - "NamingConventionCheckAll":"NamingConventionCheckAll", - "NamingConventionCheckDefineStatement":"NamingConventionCheckDefineSta= tement", - "NamingConventionCheckFunctionName":"NamingConventionCheckFunctionName= ", - "NamingConventionCheckIfndefStatement":"NamingConventionCheckIfndefSta= tement", - "NamingConventionCheckPathName":"NamingConventionCheckPathName", - "NamingConventionCheckSingleCharacterVariable":"NamingConventionCheckS= ingleCharacterVariable", - "NamingConventionCheckTypedefStatement":"NamingConventionCheckTypedefS= tatement", - "NamingConventionCheckVariableName":"NamingConventionCheckVariableName= ", - "PredicateExpressionCheckAll":"PredicateExpressionCheckAll", - "PredicateExpressionCheckBooleanValue":"PredicateExpressionCheckBoolea= nValue", - "PredicateExpressionCheckComparisonNullType":"PredicateExpressionCheck= ComparisonNullType", - "PredicateExpressionCheckNonBooleanOperator":"PredicateExpressionCheck= NonBooleanOperator", - "ScanOnlyDirList":"ScanOnlyDirList", - "SkipDirList":"SkipDirList", - "SkipFileList":"SkipFileList", - "SmmCommParaCheckAll":"SmmCommParaCheckAll", - "SmmCommParaCheckBufferType":"SmmCommParaCheckBufferType", - "SpaceCheckAll":"SpaceCheckAll", - "SpellingCheckAll":"SpellingCheckAll", - "TokenReleaceList":"TokenReleaceList", - "UniCheckAll":"UniCheckAll", - "UniCheckHelpInfo":"UniCheckHelpInfo", - "UniCheckPCDInfo":"UniCheckPCDInfo", - "Version":"Version" - } + "AutoCorrect": "AutoCorrect", + "BinaryExtList": "BinaryExtList", + "CFunctionLayoutCheckAll": "CFunctionLayoutCheckAll", + "CFunctionLayoutCheckDataDeclaration": "CFunctionLayoutCheckDataDeclar= ation", + "CFunctionLayoutCheckFunctionBody": "CFunctionLayoutCheckFunctionBody", + "CFunctionLayoutCheckFunctionName": "CFunctionLayoutCheckFunctionName", + "CFunctionLayoutCheckFunctionPrototype": "CFunctionLayoutCheckFunction= Prototype", + "CFunctionLayoutCheckNoInitOfVariable": "CFunctionLayoutCheckNoInitOfV= ariable", + "CFunctionLayoutCheckNoStatic": "CFunctionLayoutCheckNoStatic", + "CFunctionLayoutCheckOptionalFunctionalModifier": "CFunctionLayoutChec= kOptionalFunctionalModifier", + "CFunctionLayoutCheckReturnType": "CFunctionLayoutCheckReturnType", + "CheckAll": "CheckAll", + "Copyright": "Copyright", + "DeclarationDataTypeCheckAll": "DeclarationDataTypeCheckAll", + "DeclarationDataTypeCheckEFIAPIModifier": "DeclarationDataTypeCheckEFI= APIModifier", + "DeclarationDataTypeCheckEnumeratedType": "DeclarationDataTypeCheckEnu= meratedType", + "DeclarationDataTypeCheckInOutModifier": "DeclarationDataTypeCheckInOu= tModifier", + "DeclarationDataTypeCheckNoUseCType": "DeclarationDataTypeCheckNoUseCT= ype", + "DeclarationDataTypeCheckSameStructure": "DeclarationDataTypeCheckSame= Structure", + "DeclarationDataTypeCheckStructureDeclaration": "DeclarationDataTypeCh= eckStructureDeclaration", + "DeclarationDataTypeCheckUnionType": "DeclarationDataTypeCheckUnionTyp= e", + "DoxygenCheckAll": "DoxygenCheckAll", + "DoxygenCheckCommand": "DoxygenCheckCommand", + "DoxygenCheckCommentDescription": "DoxygenCheckCommentDescription", + "DoxygenCheckCommentFormat": "DoxygenCheckCommentFormat", + "DoxygenCheckFileHeader": "DoxygenCheckFileHeader", + "DoxygenCheckFunctionHeader": "DoxygenCheckFunctionHeader", + "GeneralCheckAll": "GeneralCheckAll", + "GeneralCheckCarriageReturn": "GeneralCheckCarriageReturn", + "GeneralCheckFileExistence": "GeneralCheckFileExistence", + "GeneralCheckIndentation": "GeneralCheckIndentation", + "GeneralCheckIndentationWidth": "GeneralCheckIndentationWidth", + "GeneralCheckLine": "GeneralCheckLine", + "GeneralCheckLineEnding": "GeneralCheckLineEnding", + "GeneralCheckLineWidth": "GeneralCheckLineWidth", + "GeneralCheckNoProgma": "GeneralCheckNoProgma", + "GeneralCheckNoTab": "GeneralCheckNoTab", + "GeneralCheckNo_Asm": "GeneralCheckNo_Asm", + "GeneralCheckNonAcsii": "GeneralCheckNonAcsii", + "GeneralCheckTabWidth": "GeneralCheckTabWidth", + "GeneralCheckTrailingWhiteSpaceLine": "GeneralCheckTrailingWhiteSpaceL= ine", + "GeneralCheckUni": "GeneralCheckUni", + "HeaderCheckAll": "HeaderCheckAll", + "HeaderCheckCFileCommentLicenseFormat": "HeaderCheckCFileCommentLicens= eFormat", + "HeaderCheckCFileCommentReferenceFormat": "HeaderCheckCFileCommentRefe= renceFormat", + "HeaderCheckCFileCommentStartSpacesNum": "HeaderCheckCFileCommentStart= SpacesNum", + "HeaderCheckFile": "HeaderCheckFile", + "HeaderCheckFileCommentEnd": "HeaderCheckFileCommentEnd", + "HeaderCheckFunction": "HeaderCheckFunction", + "IncludeFileCheckAll": "IncludeFileCheckAll", + "IncludeFileCheckData": "IncludeFileCheckData", + "IncludeFileCheckIfndefStatement": "IncludeFileCheckIfndefStatement", + "IncludeFileCheckSameName": "IncludeFileCheckSameName", + "MetaDataFileCheckAll": "MetaDataFileCheckAll", + "MetaDataFileCheckBinaryInfInFdf": "MetaDataFileCheckBinaryInfInFdf", + "MetaDataFileCheckGenerateFileList": "MetaDataFileCheckGenerateFileLis= t", + "MetaDataFileCheckGuidDuplicate": "MetaDataFileCheckGuidDuplicate", + "MetaDataFileCheckLibraryDefinedInDec": "MetaDataFileCheckLibraryDefin= edInDec", + "MetaDataFileCheckLibraryInstance": "MetaDataFileCheckLibraryInstance", + "MetaDataFileCheckLibraryInstanceDependent": "MetaDataFileCheckLibrary= InstanceDependent", + "MetaDataFileCheckLibraryInstanceOrder": "MetaDataFileCheckLibraryInst= anceOrder", + "MetaDataFileCheckLibraryNoUse": "MetaDataFileCheckLibraryNoUse", + "MetaDataFileCheckModuleFileGuidDuplication": "MetaDataFileCheckModule= FileGuidDuplication", + "MetaDataFileCheckModuleFileGuidFormat": "MetaDataFileCheckModuleFileG= uidFormat", + "MetaDataFileCheckModuleFileNoUse": "MetaDataFileCheckModuleFileNoUse", + "MetaDataFileCheckModuleFilePcdFormat": "MetaDataFileCheckModuleFilePc= dFormat", + "MetaDataFileCheckModuleFilePpiFormat": "MetaDataFileCheckModuleFilePp= iFormat", + "MetaDataFileCheckModuleFileProtocolFormat": "MetaDataFileCheckModuleF= ileProtocolFormat", + "MetaDataFileCheckPathName": "MetaDataFileCheckPathName", + "MetaDataFileCheckPathOfGenerateFileList": "MetaDataFileCheckPathOfGen= erateFileList", + "MetaDataFileCheckPcdDuplicate": "MetaDataFileCheckPcdDuplicate", + "MetaDataFileCheckPcdFlash": "MetaDataFileCheckPcdFlash", + "MetaDataFileCheckPcdNoUse": "MetaDataFileCheckPcdNoUse", + "MetaDataFileCheckPcdType": "MetaDataFileCheckPcdType", + "NamingConventionCheckAll": "NamingConventionCheckAll", + "NamingConventionCheckDefineStatement": "NamingConventionCheckDefineSt= atement", + "NamingConventionCheckFunctionName": "NamingConventionCheckFunctionNam= e", + "NamingConventionCheckIfndefStatement": "NamingConventionCheckIfndefSt= atement", + "NamingConventionCheckPathName": "NamingConventionCheckPathName", + "NamingConventionCheckSingleCharacterVariable": "NamingConventionCheck= SingleCharacterVariable", + "NamingConventionCheckTypedefStatement": "NamingConventionCheckTypedef= Statement", + "NamingConventionCheckVariableName": "NamingConventionCheckVariableNam= e", + "PredicateExpressionCheckAll": "PredicateExpressionCheckAll", + "PredicateExpressionCheckBooleanValue": "PredicateExpressionCheckBoole= anValue", + "PredicateExpressionCheckComparisonNullType": "PredicateExpressionChec= kComparisonNullType", + "PredicateExpressionCheckNonBooleanOperator": "PredicateExpressionChec= kNonBooleanOperator", + "ScanOnlyDirList": "ScanOnlyDirList", + "SkipDirList": "SkipDirList", + "SkipFileList": "SkipFileList", + "SmmCommParaCheckAll": "SmmCommParaCheckAll", + "SmmCommParaCheckBufferType": "SmmCommParaCheckBufferType", + "SpaceCheckAll": "SpaceCheckAll", + "SpellingCheckAll": "SpellingCheckAll", + "TokenReleaceList": "TokenReleaceList", + "UniCheckAll": "UniCheckAll", + "UniCheckHelpInfo": "UniCheckHelpInfo", + "UniCheckPCDInfo": "UniCheckPCDInfo", + "Version": "Version" +} =20 -## Configuration +# Configuration # # This class is used to define all items in configuration file # # @param Filename: The name of configuration file, the default is config.= ini # + + class Configuration(object): def __init__(self, Filename): self.Filename =3D Filename =20 self.Version =3D 0.1 =20 - ## Identify to if check all items + # Identify to if check all items # 1 - Check all items and ignore all other detailed items # 0 - Not check all items, the tool will go through all other deta= iled items to decide to check or not # self.CheckAll =3D 0 =20 - ## Identify to if automatically correct mistakes + # Identify to if automatically correct mistakes # 1 - Automatically correct # 0 - Not automatically correct # Only the following check points can be automatically corrected, = others not listed below are not supported even it is 1 @@ -156,7 +158,7 @@ class Configuration(object): # Defaultly use the definition in class DataType self.ModifierSet =3D MODIFIER_SET =20 - ## General Checking + # General Checking self.GeneralCheckAll =3D 0 =20 # Check whether NO Tab is used, replaced with spaces @@ -190,10 +192,10 @@ class Configuration(object): =20 self.CFunctionLayoutCheckNoDeprecated =3D 1 =20 - ## Space Checking + # Space Checking self.SpaceCheckAll =3D 1 =20 - ## Predicate Expression Checking + # Predicate Expression Checking self.PredicateExpressionCheckAll =3D 0 =20 # Check whether Boolean values, variable type BOOLEAN not use expl= icit comparisons to TRUE or FALSE @@ -203,7 +205,7 @@ class Configuration(object): # Check whether a comparison of any pointer to zero must be done v= ia the NULL type self.PredicateExpressionCheckComparisonNullType =3D 1 =20 - ## Headers Checking + # Headers Checking self.HeaderCheckAll =3D 0 =20 # Check whether File header exists @@ -219,7 +221,7 @@ class Configuration(object): # Check whether C File header Comment have the License immediately= after the ""Copyright"" line self.HeaderCheckCFileCommentLicenseFormat =3D 1 =20 - ## C Function Layout Checking + # C Function Layout Checking self.CFunctionLayoutCheckAll =3D 0 =20 # Check whether return type exists and in the first line @@ -240,10 +242,10 @@ class Configuration(object): # Check whether no use of STATIC for functions self.CFunctionLayoutCheckNoStatic =3D 1 =20 - ## Include Files Checking + # Include Files Checking self.IncludeFileCheckAll =3D 0 =20 - #Check whether having include files with same name + # Check whether having include files with same name self.IncludeFileCheckSameName =3D 1 # Check whether all include file contents is guarded by a #ifndef = statement. # the #ifndef must be the first line of code following the file he= ader comment @@ -253,7 +255,7 @@ class Configuration(object): # Check whether include files NOT contain code or define data vari= ables self.IncludeFileCheckData =3D 1 =20 - ## Declarations and Data Types Checking + # Declarations and Data Types Checking self.DeclarationDataTypeCheckAll =3D 0 =20 # Check whether no use of int, unsigned, char, void, long in any .= c, .h or .asl files. @@ -271,7 +273,7 @@ class Configuration(object): # Check whether Union Type has a 'typedef' and the name is capital self.DeclarationDataTypeCheckUnionType =3D 1 =20 - ## Naming Conventions Checking + # Naming Conventions Checking self.NamingConventionCheckAll =3D 0 =20 # Check whether only capital letters are used for #define declarat= ions @@ -293,7 +295,7 @@ class Configuration(object): # Check whether NO use short variable name with single character self.NamingConventionCheckSingleCharacterVariable =3D 1 =20 - ## Doxygen Checking + # Doxygen Checking self.DoxygenCheckAll =3D 0 =20 # Check whether the file headers are followed Doxygen special docu= mentation blocks in section 2.3.5 @@ -308,7 +310,7 @@ class Configuration(object): # Check whether only Doxygen commands allowed to mark the code are= @bug and @todo. self.DoxygenCheckCommand =3D 1 =20 - ## Meta-Data File Processing Checking + # Meta-Data File Processing Checking self.MetaDataFileCheckAll =3D 0 =20 # Check whether each file defined in meta-data exists @@ -398,7 +400,8 @@ class Configuration(object): Filepath =3D os.path.normpath(self.Filename) if not os.path.isfile(Filepath): ErrorMsg =3D "Can't find configuration file '%s'" % Filepath - EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, File =3D= Filepath) + EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, + ErrorMsg, File=3DFilepath) =20 LineNo =3D 0 for Line in open(Filepath, 'r'): @@ -408,8 +411,10 @@ class Configuration(object): List =3D GetSplitValueList(Line, TAB_EQUAL_SPLIT) if List[0] not in _ConfigFileToInternalTranslation: ErrorMsg =3D "Invalid configuration option '%s' was fo= und" % List[0] - EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, ErrorMsg, = File =3D Filepath, Line =3D LineNo) - assert _ConfigFileToInternalTranslation[List[0]] in self._= _dict__ + EdkLogger.error("Ecc", EdkLogger.ECC_ERROR, + ErrorMsg, File=3DFilepath, Line=3DLine= No) + assert _ConfigFileToInternalTranslation[List[0] + ] in self.__dict__ if List[0] =3D=3D 'ModifierList': List[1] =3D GetSplitValueList(List[1], TAB_COMMA_SPLIT) if List[0] =3D=3D 'MetaDataFileCheckPathOfGenerateFileList= ' and List[1] =3D=3D "": @@ -424,13 +429,15 @@ class Configuration(object): List[1] =3D GetSplitValueList(List[1], TAB_COMMA_SPLIT) if List[0] =3D=3D 'TokenReleaceList': List[1] =3D GetSplitValueList(List[1], TAB_COMMA_SPLIT) - self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = =3D List[1] + self.__dict__[ + _ConfigFileToInternalTranslation[List[0]]] =3D List[1] =20 def ShowMe(self): print(self.Filename) for Key in self.__dict__.keys(): print(Key, '=3D', self.__dict__[Key]) =20 + # # test that our dict and out class still match in contents. # diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Pyt= hon/Ecc/Database.py index a5b70c52029b..c567dfbd04cf 100644 --- a/BaseTools/Source/Python/Ecc/Database.py +++ b/BaseTools/Source/Python/Ecc/Database.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by ECC tool # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
        @@ -10,7 +10,8 @@ # from __future__ import absolute_import import sqlite3 -import Common.LongFilePathOs as os, time +import Common.LongFilePathOs as os +import time =20 import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass @@ -31,7 +32,7 @@ from Table.TableFdf import TableFdf # DATABASE_PATH =3D "Ecc.db" =20 -## Database +# Database # # This class defined the ECC database # During the phase of initialization, the database will create all tables = and @@ -44,6 +45,8 @@ DATABASE_PATH =3D "Ecc.db" # @var Cur: Cursor of the connection # @var TblDataModel: Local instance for TableDataModel # + + class Database(object): def __init__(self, DbPath): self.DbPath =3D DbPath @@ -60,13 +63,13 @@ class Database(object): self.TblDsc =3D None self.TblFdf =3D None =20 - ## Initialize ECC database + # Initialize ECC database # # 1. Delete all old existing tables # 2. Create new tables # 3. Initialize table DataModel # - def InitDatabase(self, NewDatabase =3D True): + def InitDatabase(self, NewDatabase=3DTrue): EdkLogger.verbose("\nInitialize ECC database started ...") # # Drop all old existing tables @@ -74,7 +77,7 @@ class Database(object): if NewDatabase: if os.path.exists(self.DbPath): os.remove(self.DbPath) - self.Conn =3D sqlite3.connect(self.DbPath, isolation_level =3D 'DE= FERRED') + self.Conn =3D sqlite3.connect(self.DbPath, isolation_level=3D'DEFE= RRED') self.Conn.execute("PRAGMA page_size=3D4096") self.Conn.execute("PRAGMA synchronous=3DOFF") # to avoid non-ascii character conversion error @@ -127,14 +130,14 @@ class Database(object): =20 EdkLogger.verbose("Initialize ECC database ... DONE!") =20 - ## Query a table + # Query a table # # @param Table: The instance of the table to be queried # def QueryTable(self, Table): Table.Query() =20 - ## Close entire database + # Close entire database # # Commit all first # Close the connection and cursor @@ -151,7 +154,7 @@ class Database(object): self.Cur.close() self.Conn.close() =20 - ## Insert one file information + # Insert one file information # # Insert one file's information to the database # 1. Create a record in TableFile @@ -165,7 +168,8 @@ class Database(object): # # Insert a record for file # - FileID =3D self.TblFile.Insert(File.Name, File.ExtName, File.Path,= File.FullPath, Model =3D File.Model, TimeStamp =3D File.TimeStamp) + FileID =3D self.TblFile.Insert( + File.Name, File.ExtName, File.Path, File.FullPath, Model=3DFil= e.Model, TimeStamp=3DFile.TimeStamp) =20 if File.Model =3D=3D DataClass.MODEL_FILE_C or File.Model =3D=3D D= ataClass.MODEL_FILE_H: IdTable =3D TableIdentifier(self.Cur) @@ -175,47 +179,49 @@ class Database(object): # Insert function of file # for Function in File.FunctionList: - FunctionID =3D self.TblFunction.Insert(Function.Header, Fu= nction.Modifier, Function.Name, Function.ReturnStatement, \ - Function.StartLine, Function.Start= Column, Function.EndLine, Function.EndColumn, \ - Function.BodyStartLine, Function.B= odyStartColumn, FileID, \ - Function.FunNameStartLine, Functio= n.FunNameStartColumn) + FunctionID =3D self.TblFunction.Insert(Function.Header, Fu= nction.Modifier, Function.Name, Function.ReturnStatement, + Function.StartLine, F= unction.StartColumn, Function.EndLine, Function.EndColumn, + Function.BodyStartLin= e, Function.BodyStartColumn, FileID, + Function.FunNameStart= Line, Function.FunNameStartColumn) # # Insert Identifier of function # for Identifier in Function.IdentifierList: - IdentifierID =3D IdTable.Insert(Identifier.Modifier, I= dentifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \ - FileID, FunctionID, Identifier= .StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColum= n) + IdentifierID =3D IdTable.Insert(Identifier.Modifier, I= dentifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, + FileID, FunctionID, Iden= tifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.En= dColumn) # # Insert Pcd of function # for Pcd in Function.PcdList: - PcdID =3D self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpace= GuidCName, Pcd.Token, Pcd.DatumType, Pcd.Model, \ - FileID, FunctionID, Pcd.StartLine, = Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn) + PcdID =3D self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpace= GuidCName, Pcd.Token, Pcd.DatumType, Pcd.Model, + FileID, FunctionID, Pcd.Sta= rtLine, Pcd.StartColumn, Pcd.EndLine, Pcd.EndColumn) # # Insert Identifier of file # for Identifier in File.IdentifierList: - IdentifierID =3D IdTable.Insert(Identifier.Modifier, Ident= ifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \ - FileID, -1, Identifier.StartLine, = Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn) + IdentifierID =3D IdTable.Insert(Identifier.Modifier, Ident= ifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, + FileID, -1, Identifier.Start= Line, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn) # # Insert Pcd of file # for Pcd in File.PcdList: - PcdID =3D self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpaceGuid= CName, Pcd.Token, Pcd.DatumType, Pcd.Model, \ - FileID, -1, Pcd.StartLine, Pcd.StartCol= umn, Pcd.EndLine, Pcd.EndColumn) + PcdID =3D self.TblPcd.Insert(Pcd.CName, Pcd.TokenSpaceGuid= CName, Pcd.Token, Pcd.DatumType, Pcd.Model, + FileID, -1, Pcd.StartLine, Pcd.= StartColumn, Pcd.EndLine, Pcd.EndColumn) =20 - EdkLogger.verbose("Insert information from file %s ... DONE!" % Fi= le.FullPath) + EdkLogger.verbose( + "Insert information from file %s ... DONE!" % File.FullPath) =20 - ## UpdateIdentifierBelongsToFunction + # UpdateIdentifierBelongsToFunction # # Update the field "BelongsToFunction" for each Identifier # # def UpdateIdentifierBelongsToFunction_disabled(self): - EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers star= ted ...") + EdkLogger.verbose( + "Update 'BelongsToFunction' for Identifiers started ...") =20 SqlCommand =3D """select ID, BelongsToFile, StartLine, EndLine, Mo= del from Identifier""" - EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand) + EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) self.Cur.execute(SqlCommand) Records =3D self.Cur.fetchall() for Record in Records: @@ -232,12 +238,13 @@ class Database(object): SqlCommand =3D """select ID from Function where StartLine < %s and EndLine > %s and BelongsToFile =3D %s""" % (StartLine, EndLine,= BelongsToFile) - EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand) + EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) self.Cur.execute(SqlCommand) IDs =3D self.Cur.fetchall() for ID in IDs: - SqlCommand =3D """Update Identifier set BelongsToFunction = =3D %s where ID =3D %s""" % (ID[0], IdentifierID) - EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand) + SqlCommand =3D """Update Identifier set BelongsToFunction = =3D %s where ID =3D %s""" % ( + ID[0], IdentifierID) + EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) self.Cur.execute(SqlCommand) =20 # @@ -248,24 +255,27 @@ class Database(object): SqlCommand =3D """select ID from Function where StartLine =3D %s + 1 and BelongsToFile =3D %s""" % (EndLine, BelongsToF= ile) - EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand) + EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) self.Cur.execute(SqlCommand) IDs =3D self.Cur.fetchall() for ID in IDs: - SqlCommand =3D """Update Identifier set BelongsToFunct= ion =3D %s, Model =3D %s where ID =3D %s""" % (ID[0], DataClass.MODEL_IDENT= IFIER_FUNCTION_HEADER, IdentifierID) - EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand) + SqlCommand =3D """Update Identifier set BelongsToFunct= ion =3D %s, Model =3D %s where ID =3D %s""" % ( + ID[0], DataClass.MODEL_IDENTIFIER_FUNCTION_HEADER,= IdentifierID) + EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) self.Cur.execute(SqlCommand) =20 - EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers ... = DONE") + EdkLogger.verbose( + "Update 'BelongsToFunction' for Identifiers ... DONE") =20 - - ## UpdateIdentifierBelongsToFunction + # UpdateIdentifierBelongsToFunction # # Update the field "BelongsToFunction" for each Identifier # # + def UpdateIdentifierBelongsToFunction(self): - EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers star= ted ...") + EdkLogger.verbose( + "Update 'BelongsToFunction' for Identifiers started ...") =20 SqlCommand =3D """select ID, BelongsToFile, StartLine, EndLine fro= m Function""" Records =3D self.TblFunction.Exec(SqlCommand) @@ -280,11 +290,12 @@ class Database(object): #Data2.append(("'file%s'" % BelongsToFile, FunctionID, DataCla= ss.MODEL_IDENTIFIER_FUNCTION_HEADER, BelongsToFile, DataClass.MODEL_IDENTIF= IER_COMMENT, StartLine - 1)) =20 SqlCommand =3D """Update Identifier%s set BelongsToFunction = =3D %s where BelongsToFile =3D %s and StartLine > %s and EndLine < %s""" % \ - (BelongsToFile, FunctionID, BelongsToFile, StartLi= ne, EndLine) + (BelongsToFile, FunctionID, BelongsToFile, StartLine, EndL= ine) self.TblIdentifier.Exec(SqlCommand) =20 SqlCommand =3D """Update Identifier%s set BelongsToFunction = =3D %s, Model =3D %s where BelongsToFile =3D %s and Model =3D %s and EndLin= e =3D %s""" % \ - (BelongsToFile, FunctionID, DataClass.MODEL_IDENT= IFIER_FUNCTION_HEADER, BelongsToFile, DataClass.MODEL_IDENTIFIER_COMMENT, S= tartLine - 1) + (BelongsToFile, FunctionID, DataClass.MODEL_IDENT= IFIER_FUNCTION_HEADER, + BelongsToFile, DataClass.MODEL_IDENTIFIER_COMMEN= T, StartLine - 1) self.TblIdentifier.Exec(SqlCommand) # # # # Check whether an identifier belongs to a function @@ -313,20 +324,27 @@ class Database(object): # if __name__ =3D=3D '__main__': EdkLogger.Initialize() - #EdkLogger.SetLevel(EdkLogger.VERBOSE) + # EdkLogger.SetLevel(EdkLogger.VERBOSE) EdkLogger.SetLevel(EdkLogger.DEBUG_0) - EdkLogger.verbose("Start at " + time.strftime('%H:%M:%S', time.localti= me())) + EdkLogger.verbose( + "Start at " + time.strftime('%H:%M:%S', time.localtime())) =20 Db =3D Database(DATABASE_PATH) Db.InitDatabase() Db.QueryTable(Db.TblDataModel) =20 - identifier1 =3D DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', D= ataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 32, 43, 54, 43) - identifier2 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', Dat= aClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 15, 43, 20, 43) - identifier3 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', Dat= aClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 55, 43, 58, 43) - identifier4 =3D DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', Da= taClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 77, 43, 88, 43) - fun1 =3D DataClass.FunctionClass(-1, '', '', 'fun1', '', 21, 2, 60, 4= 5, 1, 23, 0, [], []) - file =3D DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', Data= Class.MODEL_FILE_C, '2007-12-28', [fun1], [identifier1, identifier2, identi= fier3, identifier4], []) + identifier1 =3D DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 32, 43, 54, 43) + identifier2 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 15, 43, 20, 43) + identifier3 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 55, 43, 58, 43) + identifier4 =3D DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 77, 43, 88, 43) + fun1 =3D DataClass.FunctionClass(-1, '', '', + 'fun1', '', 21, 2, 60, 45, 1, 23, 0, [= ], []) + file =3D DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', Data= Class.MODEL_FILE_C, + '2007-12-28', [fun1], [identifier1, identif= ier2, identifier3, identifier4], []) Db.InsertOneFile(file) Db.UpdateIdentifierBelongsToFunction() =20 @@ -337,4 +355,3 @@ if __name__ =3D=3D '__main__': =20 Db.Close() EdkLogger.verbose("End at " + time.strftime('%H:%M:%S', time.localtime= ())) - diff --git a/BaseTools/Source/Python/Ecc/EccGlobalData.py b/BaseTools/Sourc= e/Python/Ecc/EccGlobalData.py index 89036dba071b..b9093d17664d 100644 --- a/BaseTools/Source/Python/Ecc/EccGlobalData.py +++ b/BaseTools/Source/Python/Ecc/EccGlobalData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to save global datas used by ECC tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        diff --git a/BaseTools/Source/Python/Ecc/EccMain.py b/BaseTools/Source/Pyth= on/Ecc/EccMain.py index a349cd80147f..c5c715901ad3 100644 --- a/BaseTools/Source/Python/Ecc/EccMain.py +++ b/BaseTools/Source/Python/Ecc/EccMain.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to be the main entrance of ECC tool # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
        @@ -10,7 +10,10 @@ # Import Modules # from __future__ import absolute_import -import Common.LongFilePathOs as os, time, glob, sys +import Common.LongFilePathOs as os +import time +import glob +import sys import Common.EdkLogger as EdkLogger from Ecc import Database from Ecc import EccGlobalData @@ -31,17 +34,20 @@ from Ecc.MetaFileWorkspace.MetaFileParser import InfPar= ser from Ecc.MetaFileWorkspace.MetaFileParser import Fdf from Ecc.MetaFileWorkspace.MetaFileTable import MetaFileStorage from Ecc import c -import re, string +import re +import string from Ecc.Exception import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## Ecc +# Ecc # # This class is used to define Ecc main entrance # # @param object: Inherited from object class # + + class Ecc(object): def __init__(self): # Version and Copyright @@ -61,9 +67,11 @@ class Ecc(object): =20 # Parse the options and args self.ParseOption() - EdkLogger.info(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime= ()) + "[00:00]" + "\n") + EdkLogger.info(time.strftime("%H:%M:%S, %b.%d %Y ", + time.localtime()) + "[00:00]" + "\n") =20 - WorkspaceDir =3D os.path.normcase(os.path.normpath(os.environ["WOR= KSPACE"])) + WorkspaceDir =3D os.path.normcase( + os.path.normpath(os.environ["WORKSPACE"])) os.environ["WORKSPACE"] =3D WorkspaceDir =20 # set multiple workspace @@ -72,7 +80,7 @@ class Ecc(object): =20 GlobalData.gWorkspace =3D WorkspaceDir =20 - GlobalData.gGlobalDefines["WORKSPACE"] =3D WorkspaceDir + GlobalData.gGlobalDefines["WORKSPACE"] =3D WorkspaceDir =20 EdkLogger.info("Loading ECC configuration ... done") # Generate checkpoints list @@ -112,11 +120,11 @@ class Ecc(object): return self.ConfigFile =3D 'config.ini' =20 - - ## DetectOnlyScan + # DetectOnlyScan # # Detect whether only scanned folders have been enabled # + def DetectOnlyScanDirs(self): if self.OnlyScan =3D=3D True: OnlyScanDirs =3D [] @@ -126,16 +134,17 @@ class Ecc(object): if len(OnlyScanDirs) !=3D 0: self.BuildDatabase(OnlyScanDirs) else: - EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID= , ExtraData=3D"Use -f option need to fill specific folders in config.ini fi= le") + EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID, + ExtraData=3D"Use -f option need to fill sp= ecific folders in config.ini file") else: self.BuildDatabase() =20 - - ## BuildDatabase + # BuildDatabase # # Build the database for target # - def BuildDatabase(self, SpeciDirs =3D None): + + def BuildDatabase(self, SpeciDirs=3DNone): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() @@ -151,27 +160,32 @@ class Ecc(object): c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) else: for specificDir in SpeciDirs: - c.CollectSourceCodeDataIntoDB(os.path.join(EccGlob= alData.gTarget, specificDir)) + c.CollectSourceCodeDataIntoDB( + os.path.join(EccGlobalData.gTarget, specificDi= r)) =20 - EccGlobalData.gIdentifierTableList =3D GetTableList((MODEL_FILE_C,= MODEL_FILE_H), 'Identifier', EccGlobalData.gDb) + EccGlobalData.gIdentifierTableList =3D GetTableList( + (MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb) EccGlobalData.gCFileList =3D GetFileList(MODEL_FILE_C, EccGlobalDa= ta.gDb) EccGlobalData.gHFileList =3D GetFileList(MODEL_FILE_H, EccGlobalDa= ta.gDb) - EccGlobalData.gUFileList =3D GetFileList(MODEL_FILE_UNI, EccGlobal= Data.gDb) + EccGlobalData.gUFileList =3D GetFileList( + MODEL_FILE_UNI, EccGlobalData.gDb) =20 - ## BuildMetaDataFileDatabase + # BuildMetaDataFileDatabase # # Build the database for meta data files # - def BuildMetaDataFileDatabase(self, SpecificDirs =3D None): + def BuildMetaDataFileDatabase(self, SpecificDirs=3DNone): ScanFolders =3D [] if SpecificDirs is None: ScanFolders.append(EccGlobalData.gTarget) else: for specificDir in SpecificDirs: - ScanFolders.append(os.path.join(EccGlobalData.gTarget, spe= cificDir)) + ScanFolders.append(os.path.join( + EccGlobalData.gTarget, specificDir)) EdkLogger.quiet("Building database for meta data files ...") - Op =3D open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateF= ileList, 'w+') - #SkipDirs =3D Read from config file + Op =3D open( + EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList,= 'w+') + # SkipDirs =3D Read from config file SkipDirs =3D EccGlobalData.gConfig.SkipDirList SkipDirString =3D '|'.join(SkipDirs) # p =3D re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) @@ -195,7 +209,8 @@ class Ecc(object): EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dec(Filename, True, True, EccGlobalData.gWorkspac= e, EccGlobalData.gDb) - self.MetaFile =3D DecParser(Filename, MODEL_FILE_D= EC, EccGlobalData.gDb.TblDec) + self.MetaFile =3D DecParser( + Filename, MODEL_FILE_DEC, EccGlobalData.gDb.Tb= lDec) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() =3D=3D ".DSC": @@ -203,7 +218,8 @@ class Ecc(object): EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dsc(Filename, True, True, EccGlobalData.gWorkspac= e, EccGlobalData.gDb) - self.MetaFile =3D DscParser(PathClass(Filename, Ro= ot), MODEL_FILE_DSC, MetaFileStorage(EccGlobalData.gDb.TblDsc.Cur, Filename= , MODEL_FILE_DSC, True)) + self.MetaFile =3D DscParser(PathClass(Filename, Ro= ot), MODEL_FILE_DSC, MetaFileStorage( + EccGlobalData.gDb.TblDsc.Cur, Filename, MODEL_= FILE_DSC, True)) # always do post-process, in case of macros change self.MetaFile.DoPostProcess() self.MetaFile.Start() @@ -214,21 +230,25 @@ class Ecc(object): EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Inf(Filename, True, True, EccGlobalData.gWorkspac= e, EccGlobalData.gDb) - self.MetaFile =3D InfParser(Filename, MODEL_FILE_I= NF, EccGlobalData.gDb.TblInf) + self.MetaFile =3D InfParser( + Filename, MODEL_FILE_INF, EccGlobalData.gDb.Tb= lInf) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() =3D=3D ".FDF": Filename =3D os.path.normpath(os.path.join(Root, F= ile)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) - Fdf(Filename, True, EccGlobalData.gWorkspace, EccG= lobalData.gDb) + Fdf(Filename, True, EccGlobalData.gWorkspace, + EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() =3D=3D ".UNI": Filename =3D os.path.normpath(os.path.join(Root, F= ile)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) - FileID =3D EccGlobalData.gDb.TblFile.InsertFile(Fi= lename, MODEL_FILE_UNI) - EccGlobalData.gDb.TblReport.UpdateBelongsToItemByF= ile(FileID, File) + FileID =3D EccGlobalData.gDb.TblFile.InsertFile( + Filename, MODEL_FILE_UNI) + EccGlobalData.gDb.TblReport.UpdateBelongsToItemByF= ile( + FileID, File) continue =20 Op.close() @@ -292,7 +312,7 @@ class Ecc(object): =20 return RealPath =20 - ## ParseOption + # ParseOption # # Parse options # @@ -309,7 +329,8 @@ class Ecc(object): else: EccGlobalData.gWorkspace =3D os.path.normpath(os.getenv("WORKS= PACE")) if not os.path.exists(EccGlobalData.gWorkspace): - EdkLogger.error("ECC", BuildToolError.FILE_NOT_FOUND, Extr= aData=3D"WORKSPACE =3D %s" % EccGlobalData.gWorkspace) + EdkLogger.error("ECC", BuildToolError.FILE_NOT_FOUND, + ExtraData=3D"WORKSPACE =3D %s" % EccGlobal= Data.gWorkspace) os.environ["WORKSPACE"] =3D EccGlobalData.gWorkspace # Set log level self.SetLogLevel(Options) @@ -325,16 +346,20 @@ class Ecc(object): self.ExceptionFile =3D Options.ExceptionFile if Options.Target is not None: if not os.path.isdir(Options.Target): - EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID= , ExtraData=3D"Target [%s] does NOT exist" % Options.Target) + EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID, + ExtraData=3D"Target [%s] does NOT exist" %= Options.Target) else: - EccGlobalData.gTarget =3D self.GetRealPathCase(os.path.nor= mpath(Options.Target)) + EccGlobalData.gTarget =3D self.GetRealPathCase( + os.path.normpath(Options.Target)) else: - EdkLogger.warn("Ecc", EdkLogger.ECC_ERROR, "The target source = tree was not specified, using current WORKSPACE instead!") + EdkLogger.warn("Ecc", EdkLogger.ECC_ERROR, + "The target source tree was not specified, usin= g current WORKSPACE instead!") EccGlobalData.gTarget =3D os.path.normpath(os.getenv("WORKSPAC= E")) if Options.keepdatabase is not None: self.IsInit =3D False if Options.metadata is not None and Options.sourcecode is not None: - EdkLogger.error("ECC", BuildToolError.OPTION_CONFLICT, ExtraDa= ta=3D"-m and -s can't be specified at one time") + EdkLogger.error("ECC", BuildToolError.OPTION_CONFLICT, + ExtraData=3D"-m and -s can't be specified at o= ne time") if Options.metadata is not None: self.ScanSourceCode =3D False if Options.sourcecode is not None: @@ -342,7 +367,7 @@ class Ecc(object): if Options.folders is not None: self.OnlyScan =3D True =20 - ## SetLogLevel + # SetLogLevel # # Set current log level of the tool based on args # @@ -358,7 +383,7 @@ class Ecc(object): else: EdkLogger.SetLevel(EdkLogger.INFO) =20 - ## Parse command line options + # Parse command line options # # Using standard Python module optparse to parse command line option o= f this tool. # @@ -366,37 +391,46 @@ class Ecc(object): # @retval Args Target of build command # def EccOptionParser(self): - Parser =3D OptionParser(description =3D self.Copyright, version = =3D self.Version, prog =3D "Ecc.exe", usage =3D "%prog [options]") + Parser =3D OptionParser(description=3Dself.Copyright, + version=3Dself.Version, prog=3D"Ecc.exe", us= age=3D"%prog [options]") Parser.add_option("-t", "--target sourcepath", action=3D"store", t= ype=3D"string", dest=3D'Target', - help=3D"Check all files under the target workspace.") + help=3D"Check all files under the target workspa= ce.") Parser.add_option("-c", "--config filename", action=3D"store", typ= e=3D"string", dest=3D"ConfigFile", - help=3D"Specify a configuration file. Defaultly use config.ini= under ECC tool directory.") + help=3D"Specify a configuration file. Defaultly = use config.ini under ECC tool directory.") Parser.add_option("-o", "--outfile filename", action=3D"store", ty= pe=3D"string", dest=3D"OutputFile", - help=3D"Specify the name of an output file, if and only if one= filename was specified.") + help=3D"Specify the name of an output file, if a= nd only if one filename was specified.") Parser.add_option("-r", "--reportfile filename", action=3D"store",= type=3D"string", dest=3D"ReportFile", - help=3D"Specify the name of an report file, if and only if one= filename was specified.") + help=3D"Specify the name of an report file, if a= nd only if one filename was specified.") Parser.add_option("-e", "--exceptionfile filename", action=3D"stor= e", type=3D"string", dest=3D"ExceptionFile", - help=3D"Specify the name of an exception file, if and only if = one filename was specified.") - Parser.add_option("-m", "--metadata", action=3D"store_true", type= =3DNone, help=3D"Only scan meta-data files information if this option is sp= ecified.") - Parser.add_option("-s", "--sourcecode", action=3D"store_true", typ= e=3DNone, help=3D"Only scan source code files information if this option is= specified.") - Parser.add_option("-k", "--keepdatabase", action=3D"store_true", t= ype=3DNone, help=3D"The existing Ecc database will not be cleaned except re= port information if this option is specified.") + help=3D"Specify the name of an exception file, i= f and only if one filename was specified.") + Parser.add_option("-m", "--metadata", action=3D"store_true", type= =3DNone, + help=3D"Only scan meta-data files information if= this option is specified.") + Parser.add_option("-s", "--sourcecode", action=3D"store_true", typ= e=3DNone, + help=3D"Only scan source code files information = if this option is specified.") + Parser.add_option("-k", "--keepdatabase", action=3D"store_true", t= ype=3DNone, + help=3D"The existing Ecc database will not be cl= eaned except report information if this option is specified.") Parser.add_option("-l", "--log filename", action=3D"store", dest= =3D"LogFile", help=3D"""If specified, the tool should emit the changes that = were made by the tool after printing the result message. = If filename, the emit to the file, otherwise emit to = standard output. If no modifications were made, then do not = create a log file, or output a log message.""") - Parser.add_option("-q", "--quiet", action=3D"store_true", type=3DN= one, help=3D"Disable all messages except FATAL ERRORS.") - Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , "\ - = "including library instances selected, final dependency expression= , "\ - = "and warning messages, etc.") - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int",= help=3D"Enable debug messages at specified level.") - Parser.add_option("-w", "--workspace", action=3D"store", type=3D"s= tring", dest=3D'Workspace', help=3D"Specify workspace.") - Parser.add_option("-f", "--folders", action=3D"store_true", type= =3DNone, help=3D"Only scanning specified folders which are recorded in conf= ig.ini file.") + Parser.add_option("-q", "--quiet", action=3D"store_true", + type=3DNone, help=3D"Disable all messages except= FATAL ERRORS.") + Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , " + "including library instances selected, final dep= endency expression, " + "and warning messages, etc.") + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + help=3D"Enable debug messages at specified level= .") + Parser.add_option("-w", "--workspace", action=3D"store", + type=3D"string", dest=3D'Workspace', help=3D"Spe= cify workspace.") + Parser.add_option("-f", "--folders", action=3D"store_true", type= =3DNone, + help=3D"Only scanning specified folders which ar= e recorded in config.ini file.") =20 - (Opt, Args)=3DParser.parse_args() + (Opt, Args) =3D Parser.parse_args() =20 return (Opt, Args) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -411,5 +445,7 @@ if __name__ =3D=3D '__main__': Ecc =3D Ecc() FinishTime =3D time.perf_counter() =20 - BuildDuration =3D time.strftime("%M:%S", time.gmtime(int(round(FinishT= ime - StartTime)))) - EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", tim= e.localtime()), BuildDuration)) + BuildDuration =3D time.strftime( + "%M:%S", time.gmtime(int(round(FinishTime - StartTime)))) + EdkLogger.quiet("\n%s [%s]" % (time.strftime( + "%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration)) diff --git a/BaseTools/Source/Python/Ecc/EccToolError.py b/BaseTools/Source= /Python/Ecc/EccToolError.py index d97bf7948ce8..0d370f49cd4d 100644 --- a/BaseTools/Source/Python/Ecc/EccToolError.py +++ b/BaseTools/Source/Python/Ecc/EccToolError.py @@ -1,4 +1,4 @@ -## @file +# @file # Standardized Error Handling infrastructures. # # Copyright (c) 2021, Arm Limited. All rights reserved.
        @@ -105,101 +105,100 @@ ERROR_SPELLING_CHECK_ALL =3D 11000 ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE =3D 12001 =20 gEccErrorMessage =3D { - ERROR_GENERAL_CHECK_ALL : "", - ERROR_GENERAL_CHECK_NO_TAB : "'TAB' character is not allowed in source= code, please replace each 'TAB' with two spaces.", - ERROR_GENERAL_CHECK_INDENTATION : "Indentation does not follow coding = style", - ERROR_GENERAL_CHECK_LINE : "The width of each line does not follow cod= ing style", - ERROR_GENERAL_CHECK_NO_ASM : "There should be no use of _asm in the so= urce file", - ERROR_GENERAL_CHECK_NO_PROGMA : """There should be no use of "#progma"= in source file except "#pragma pack(#)\"""", - ERROR_GENERAL_CHECK_CARRIAGE_RETURN : "There should be a carriage retu= rn at the end of the file", - ERROR_GENERAL_CHECK_FILE_EXISTENCE : "File not found", - ERROR_GENERAL_CHECK_NON_ACSII : "File has invalid Non-ACSII char", - ERROR_GENERAL_CHECK_UNI : "File is not a valid UTF-16 UNI file", - ERROR_GENERAL_CHECK_UNI_HELP_INFO : "UNI file that is associated by IN= F or DEC file need define the prompt and help information.", - ERROR_GENERAL_CHECK_INVALID_LINE_ENDING : "Only CRLF (Carriage Return = Line Feed) is allowed to line ending.", - ERROR_GENERAL_CHECK_TRAILING_WHITE_SPACE_LINE : "There should be no tr= ailing white space in one line.", + ERROR_GENERAL_CHECK_ALL: "", + ERROR_GENERAL_CHECK_NO_TAB: "'TAB' character is not allowed in source = code, please replace each 'TAB' with two spaces.", + ERROR_GENERAL_CHECK_INDENTATION: "Indentation does not follow coding s= tyle", + ERROR_GENERAL_CHECK_LINE: "The width of each line does not follow codi= ng style", + ERROR_GENERAL_CHECK_NO_ASM: "There should be no use of _asm in the sou= rce file", + ERROR_GENERAL_CHECK_NO_PROGMA: """There should be no use of "#progma" = in source file except "#pragma pack(#)\"""", + ERROR_GENERAL_CHECK_CARRIAGE_RETURN: "There should be a carriage retur= n at the end of the file", + ERROR_GENERAL_CHECK_FILE_EXISTENCE: "File not found", + ERROR_GENERAL_CHECK_NON_ACSII: "File has invalid Non-ACSII char", + ERROR_GENERAL_CHECK_UNI: "File is not a valid UTF-16 UNI file", + ERROR_GENERAL_CHECK_UNI_HELP_INFO: "UNI file that is associated by INF= or DEC file need define the prompt and help information.", + ERROR_GENERAL_CHECK_INVALID_LINE_ENDING: "Only CRLF (Carriage Return L= ine Feed) is allowed to line ending.", + ERROR_GENERAL_CHECK_TRAILING_WHITE_SPACE_LINE: "There should be no tra= iling white space in one line.", =20 - ERROR_SPACE_CHECK_ALL : "", + ERROR_SPACE_CHECK_ALL: "", =20 - ERROR_PREDICATE_EXPRESSION_CHECK_ALL : "", - ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN_VALUE : "Boolean values and v= ariable type BOOLEAN should not use explicit comparisons to TRUE or FALSE", - ERROR_PREDICATE_EXPRESSION_CHECK_NO_BOOLEAN_OPERATOR : "Non-Boolean co= mparisons should use a compare operator (=3D=3D, !=3D, >, < >=3D, <=3D)", - ERROR_PREDICATE_EXPRESSION_CHECK_COMPARISON_NULL_TYPE : "A comparison = of any pointer to zero must be done via the NULL type", + ERROR_PREDICATE_EXPRESSION_CHECK_ALL: "", + ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN_VALUE: "Boolean values and va= riable type BOOLEAN should not use explicit comparisons to TRUE or FALSE", + ERROR_PREDICATE_EXPRESSION_CHECK_NO_BOOLEAN_OPERATOR: "Non-Boolean com= parisons should use a compare operator (=3D=3D, !=3D, >, < >=3D, <=3D)", + ERROR_PREDICATE_EXPRESSION_CHECK_COMPARISON_NULL_TYPE: "A comparison o= f any pointer to zero must be done via the NULL type", =20 - ERROR_HEADER_CHECK_ALL : "", - ERROR_HEADER_CHECK_FILE : "File header doesn't exist", - ERROR_HEADER_CHECK_FUNCTION : "Function header doesn't exist", + ERROR_HEADER_CHECK_ALL: "", + ERROR_HEADER_CHECK_FILE: "File header doesn't exist", + ERROR_HEADER_CHECK_FUNCTION: "Function header doesn't exist", =20 - ERROR_C_FUNCTION_LAYOUT_CHECK_ALL : "", - ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE : "Return type of a function= should exist and in the first line", - ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER : "Any opti= onal functional modifiers should exist and next to the return type", - ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME : """Function name should = be left justified, followed by the beginning of the parameter list, with th= e closing parenthesis on its own line, indented two spaces""", - ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE : "Function prototyp= es in include files have the same form as function definitions", - ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2 : "Function protot= ypes in include files have different parameter number with function definit= ions", - ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3 : "Function protot= ypes in include files have different parameter modifier with function defin= itions", - ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY : "The body of a function = should be contained by open and close braces that must be in the first colu= mn", - ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION : "The data declaration= s should be the first code in a module", - ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE : "There should be n= o initialization of a variable as part of its declaration", - ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC : "There should be no use of S= TATIC for functions", + ERROR_C_FUNCTION_LAYOUT_CHECK_ALL: "", + ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE: "Return type of a function = should exist and in the first line", + ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER: "Any optio= nal functional modifiers should exist and next to the return type", + ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME: """Function name should b= e left justified, followed by the beginning of the parameter list, with the= closing parenthesis on its own line, indented two spaces""", + ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE: "Function prototype= s in include files have the same form as function definitions", + ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2: "Function prototy= pes in include files have different parameter number with function definiti= ons", + ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3: "Function prototy= pes in include files have different parameter modifier with function defini= tions", + ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY: "The body of a function s= hould be contained by open and close braces that must be in the first colum= n", + ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION: "The data declarations= should be the first code in a module", + ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE: "There should be no= initialization of a variable as part of its declaration", + ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC: "There should be no use of ST= ATIC for functions", =20 - ERROR_INCLUDE_FILE_CHECK_ALL : "", - ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 : "All include file conten= ts should be guarded by a #ifndef statement.", - ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_2 : "The #ifndef must be the= first line of code following the file header comment", - ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_3 : "The #endif must appear = on the last line in the file", - ERROR_INCLUDE_FILE_CHECK_DATA : "Include files should contain only pub= lic or only private data and cannot contain code or define data variables", - ERROR_INCLUDE_FILE_CHECK_NAME : "No permission for the include file wi= th same names", + ERROR_INCLUDE_FILE_CHECK_ALL: "", + ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1: "All include file content= s should be guarded by a #ifndef statement.", + ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_2: "The #ifndef must be the = first line of code following the file header comment", + ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_3: "The #endif must appear o= n the last line in the file", + ERROR_INCLUDE_FILE_CHECK_DATA: "Include files should contain only publ= ic or only private data and cannot contain code or define data variables", + ERROR_INCLUDE_FILE_CHECK_NAME: "No permission for the include file wit= h same names", =20 - ERROR_DECLARATION_DATA_TYPE_CHECK_ALL : "", - ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_TYPE : "There should be no = use of int, unsigned, char, void, long in any .c, .h or .asl files", - ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MODIFIER : """The modifiers I= N, OUT, OPTIONAL, and UNALIGNED should be used only to qualify arguments to= a function and should not appear in a data type declaration""", - ERROR_DECLARATION_DATA_TYPE_CHECK_EFI_API_MODIFIER : "The EFIAPI modif= ier should be used at the entry of drivers, events, and member functions of= protocols", - ERROR_DECLARATION_DATA_TYPE_CHECK_ENUMERATED_TYPE : "Enumerated Type s= hould have a 'typedef' and the name must be in capital letters", - ERROR_DECLARATION_DATA_TYPE_CHECK_STRUCTURE_DECLARATION : "Structure T= ype should have a 'typedef' and the name must be in capital letters", - ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE : "No permission for = the structure with same names", - ERROR_DECLARATION_DATA_TYPE_CHECK_UNION_TYPE : "Union Type should have= a 'typedef' and the name must be in capital letters", - ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STRUCTURE : "Complex types sh= ould be typedef-ed", + ERROR_DECLARATION_DATA_TYPE_CHECK_ALL: "", + ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_TYPE: "There should be no u= se of int, unsigned, char, void, long in any .c, .h or .asl files", + ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MODIFIER: """The modifiers IN= , OUT, OPTIONAL, and UNALIGNED should be used only to qualify arguments to = a function and should not appear in a data type declaration""", + ERROR_DECLARATION_DATA_TYPE_CHECK_EFI_API_MODIFIER: "The EFIAPI modifi= er should be used at the entry of drivers, events, and member functions of = protocols", + ERROR_DECLARATION_DATA_TYPE_CHECK_ENUMERATED_TYPE: "Enumerated Type sh= ould have a 'typedef' and the name must be in capital letters", + ERROR_DECLARATION_DATA_TYPE_CHECK_STRUCTURE_DECLARATION: "Structure Ty= pe should have a 'typedef' and the name must be in capital letters", + ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE: "No permission for t= he structure with same names", + ERROR_DECLARATION_DATA_TYPE_CHECK_UNION_TYPE: "Union Type should have = a 'typedef' and the name must be in capital letters", + ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STRUCTURE: "Complex types sho= uld be typedef-ed", =20 - ERROR_NAMING_CONVENTION_CHECK_ALL : "", - ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT : "Only capital letters= are allowed to be used for #define declarations", - ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT : "Only capital letter= s are allowed to be used for typedef declarations", - ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT : "The #ifndef at the s= tart of an include file should have one postfix underscore, and no prefix u= nderscore character '_'", - ERROR_NAMING_CONVENTION_CHECK_PATH_NAME : """Path name does not follow= the rules: 1. First character should be upper case 2. Must contain lower c= ase characters 3. No white space characters""", - ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME : """Variable name does no= t follow the rules: 1. First character should be upper case 2. Must contain= lower case characters 3. No white space characters 4. Global variable name= must start with a 'g'""", - ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME : """Function name does no= t follow the rules: 1. First character should be upper case 2. Must contain= lower case characters 3. No white space characters""", - ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE : "There shoul= d be no use of short (single character) variable names", + ERROR_NAMING_CONVENTION_CHECK_ALL: "", + ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT: "Only capital letters = are allowed to be used for #define declarations", + ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT: "Only capital letters= are allowed to be used for typedef declarations", + ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT: "The #ifndef at the st= art of an include file should have one postfix underscore, and no prefix un= derscore character '_'", + ERROR_NAMING_CONVENTION_CHECK_PATH_NAME: """Path name does not follow = the rules: 1. First character should be upper case 2. Must contain lower ca= se characters 3. No white space characters""", + ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME: """Variable name does not= follow the rules: 1. First character should be upper case 2. Must contain = lower case characters 3. No white space characters 4. Global variable name = must start with a 'g'""", + ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME: """Function name does not= follow the rules: 1. First character should be upper case 2. Must contain = lower case characters 3. No white space characters""", + ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE: "There should= be no use of short (single character) variable names", =20 - ERROR_DOXYGEN_CHECK_ALL : "", - ERROR_DOXYGEN_CHECK_FILE_HEADER : "The file headers should follow Doxy= gen special documentation blocks in section 2.3.5", - ERROR_DOXYGEN_CHECK_FUNCTION_HEADER : "The function headers should fol= low Doxygen special documentation blocks in section 2.3.5", - ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION : """The first line of text in= a comment block should be a brief description of the element being documen= ted and the brief description must end with a period.""", - ERROR_DOXYGEN_CHECK_COMMENT_FORMAT : "For comment line with '///< ... = text ...' format, if it is used, it should be after the code section", - ERROR_DOXYGEN_CHECK_COMMAND : "Only Doxygen commands '@bug', '@todo', = '@example', '@file', '@attention', '@param', '@post', '@pre', '@retval', '@= return', '@sa', '@since', '@test', '@note', '@par', '@endcode', '@code', '@= {', '@}' are allowed to mark the code", + ERROR_DOXYGEN_CHECK_ALL: "", + ERROR_DOXYGEN_CHECK_FILE_HEADER: "The file headers should follow Doxyg= en special documentation blocks in section 2.3.5", + ERROR_DOXYGEN_CHECK_FUNCTION_HEADER: "The function headers should foll= ow Doxygen special documentation blocks in section 2.3.5", + ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION: """The first line of text in = a comment block should be a brief description of the element being document= ed and the brief description must end with a period.""", + ERROR_DOXYGEN_CHECK_COMMENT_FORMAT: "For comment line with '///< ... t= ext ...' format, if it is used, it should be after the code section", + ERROR_DOXYGEN_CHECK_COMMAND: "Only Doxygen commands '@bug', '@todo', '= @example', '@file', '@attention', '@param', '@post', '@pre', '@retval', '@r= eturn', '@sa', '@since', '@test', '@note', '@par', '@endcode', '@code', '@{= ', '@}' are allowed to mark the code", =20 - ERROR_META_DATA_FILE_CHECK_ALL : "", - ERROR_META_DATA_FILE_CHECK_PATH_NAME : "The file defined in meta-data = does not exist", - ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1 : "A library instances d= efined for a given module (or dependent library instance) doesn't match the= module's type.", - ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2 : "A library instance mu= st specify the Supported Module Types in its INF file", - ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT : "A library ins= tance must be defined for all dependent library classes", - ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_ORDER : "The library Insta= nces specified by the LibraryClasses sections should be listed in order of = dependencies", - ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE : "There should be no unnece= ssary inclusion of library classes in the INF file", - ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE : "Duplicate Library= Class Name found", - ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF : "An INF file is specifi= ed in the FDF file, but not in the DSC file, therefore the INF file must be= for a Binary module only", - ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE : "Duplicate PCDs found", - ERROR_META_DATA_FILE_CHECK_PCD_FLASH : "PCD settings in the FDF file s= hould only be related to flash", - ERROR_META_DATA_FILE_CHECK_PCD_NO_USE : "There should be no PCDs decla= red in INF files that are not specified in in either a DSC or FDF file", - ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID : "Duplicate GUID found", - ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL : "Duplicate PROTOCOL fo= und", - ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI : "Duplicate PPI found", - ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE : "No used module files = found", - ERROR_META_DATA_FILE_CHECK_PCD_TYPE : "Wrong C code function used for = this kind of PCD", - ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION : "Module file= has FILE_GUID collision with other module file", - ERROR_META_DATA_FILE_CHECK_FORMAT_GUID : "Wrong GUID Format used in Mo= dule file", - ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL : "Wrong Protocol Format us= ed in Module file", - ERROR_META_DATA_FILE_CHECK_FORMAT_PPI : "Wrong Ppi Format used in Modu= le file", - ERROR_META_DATA_FILE_CHECK_FORMAT_PCD : "Wrong Pcd Format used in Modu= le file", - ERROR_META_DATA_FILE_CHECK_LIBRARY_NOT_DEFINED : "Not defined LibraryC= lass used in the Module file.", - ERROR_SPELLING_CHECK_ALL : "", - - ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE : "SMM communication function ma= y use wrong parameter type", - } + ERROR_META_DATA_FILE_CHECK_ALL: "", + ERROR_META_DATA_FILE_CHECK_PATH_NAME: "The file defined in meta-data d= oes not exist", + ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1: "A library instances de= fined for a given module (or dependent library instance) doesn't match the = module's type.", + ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2: "A library instance mus= t specify the Supported Module Types in its INF file", + ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT: "A library inst= ance must be defined for all dependent library classes", + ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_ORDER: "The library Instan= ces specified by the LibraryClasses sections should be listed in order of d= ependencies", + ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE: "There should be no unneces= sary inclusion of library classes in the INF file", + ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE: "Duplicate Library = Class Name found", + ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF: "An INF file is specifie= d in the FDF file, but not in the DSC file, therefore the INF file must be = for a Binary module only", + ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE: "Duplicate PCDs found", + ERROR_META_DATA_FILE_CHECK_PCD_FLASH: "PCD settings in the FDF file sh= ould only be related to flash", + ERROR_META_DATA_FILE_CHECK_PCD_NO_USE: "There should be no PCDs declar= ed in INF files that are not specified in in either a DSC or FDF file", + ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID: "Duplicate GUID found", + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL: "Duplicate PROTOCOL fou= nd", + ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI: "Duplicate PPI found", + ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE: "No used module files f= ound", + ERROR_META_DATA_FILE_CHECK_PCD_TYPE: "Wrong C code function used for t= his kind of PCD", + ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION: "Module file = has FILE_GUID collision with other module file", + ERROR_META_DATA_FILE_CHECK_FORMAT_GUID: "Wrong GUID Format used in Mod= ule file", + ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL: "Wrong Protocol Format use= d in Module file", + ERROR_META_DATA_FILE_CHECK_FORMAT_PPI: "Wrong Ppi Format used in Modul= e file", + ERROR_META_DATA_FILE_CHECK_FORMAT_PCD: "Wrong Pcd Format used in Modul= e file", + ERROR_META_DATA_FILE_CHECK_LIBRARY_NOT_DEFINED: "Not defined LibraryCl= ass used in the Module file.", + ERROR_SPELLING_CHECK_ALL: "", =20 + ERROR_SMM_COMM_PARA_CHECK_BUFFER_TYPE: "SMM communication function may= use wrong parameter type", +} diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Py= thon/Ecc/Exception.py index 9251b8d7c47f..f6dfbeb2c95f 100644 --- a/BaseTools/Source/Python/Ecc/Exception.py +++ b/BaseTools/Source/Python/Ecc/Exception.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse exception items found by ECC tool # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
        @@ -14,6 +14,8 @@ from Ecc.Xml.XmlRoutines import * import Common.LongFilePathOs as os =20 # ExceptionXml to parse Exception Node of XML file + + class ExceptionXml(object): def __init__(self): self.KeyWord =3D '' @@ -26,9 +28,11 @@ class ExceptionXml(object): self.FilePath =3D os.path.normpath(XmlElement(Item, '%s/FilePath' = % Key)) =20 def __str__(self): - return 'ErrorID =3D %s KeyWord =3D %s FilePath =3D %s' %(self.Erro= rID, self.KeyWord, self.FilePath) + return 'ErrorID =3D %s KeyWord =3D %s FilePath =3D %s' % (self.Err= orID, self.KeyWord, self.FilePath) =20 # ExceptionListXml to parse Exception Node List of XML file + + class ExceptionListXml(object): def __init__(self): self.List =3D [] @@ -56,8 +60,10 @@ class ExceptionListXml(object): return RtnStr =20 # A class to check exception + + class ExceptionCheck(object): - def __init__(self, FilePath =3D None): + def __init__(self, FilePath=3DNone): self.ExceptionList =3D [] self.ExceptionListXml =3D ExceptionListXml() self.LoadExceptionListXml(FilePath) @@ -73,11 +79,13 @@ class ExceptionCheck(object): else: return False =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another # script. # if __name__ =3D=3D '__main__': - El =3D ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\excepti= on.xml') + El =3D ExceptionCheck( + 'C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml') print(El.ExceptionList) diff --git a/BaseTools/Source/Python/Ecc/FileProfile.py b/BaseTools/Source/= Python/Ecc/FileProfile.py index eedf263b1f9d..ecc33fac2863 100644 --- a/BaseTools/Source/Python/Ecc/FileProfile.py +++ b/BaseTools/Source/Python/Ecc/FileProfile.py @@ -1,4 +1,4 @@ -## @file +# @file # fragments of source file # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -26,13 +26,15 @@ StructUnionDefinitionList =3D [] TypedefDefinitionList =3D [] FunctionCallingList =3D [] =20 -## record file data when parsing source +# record file data when parsing source # # May raise Exception when opening file. # -class FileProfile : =20 - ## The constructor + +class FileProfile: + + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Sour= ce/Python/Ecc/MetaDataParser.py index d9f0da1ee0d6..d8d0d2ee408a 100644 --- a/BaseTools/Source/Python/Ecc/MetaDataParser.py +++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common parser functions for meta-data # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -12,12 +12,14 @@ from Ecc.EccToolError import * from Common.MultipleWorkspace import MultipleWorkspace as mws from Ecc import EccGlobalData import re -## Get the include path list for a source file +# Get the include path list for a source file # # 1. Find the source file belongs to which inf file # 2. Find the inf's package # 3. Return the include path list of the package # + + def GetIncludeListOfFile(WorkSpace, Filepath, Db): IncludeList =3D [] Filepath =3D os.path.normpath(Filepath) @@ -46,26 +48,32 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db): =20 return IncludeList =20 -## Get the file list +# Get the file list # # Search table file and find all specific type files # + + def GetFileList(FileModel, Db): FileList =3D [] - SqlCommand =3D """select FullPath from File where Model =3D %s""" % st= r(FileModel) + SqlCommand =3D """select FullPath from File where Model =3D %s""" % st= r( + FileModel) RecordSet =3D Db.TblFile.Exec(SqlCommand) for Record in RecordSet: FileList.append(Record[0]) =20 return FileList =20 -## Get the table list +# Get the table list # # Search table file and find all small tables # + + def GetTableList(FileModelList, Table, Db): TableList =3D [] - SqlCommand =3D """select ID from File where Model in %s""" % str(FileM= odelList) + SqlCommand =3D """select ID from File where Model in %s""" % str( + FileModelList) RecordSet =3D Db.TblFile.Exec(SqlCommand) for Record in RecordSet: TableName =3D Table + str(Record[0]) @@ -73,7 +81,7 @@ def GetTableList(FileModelList, Table, Db): =20 return TableList =20 -## ParseHeaderCommentSection +# ParseHeaderCommentSection # # Parse Header comment section lines, extract Abstract, Description, Copyr= ight # , License lines @@ -81,7 +89,9 @@ def GetTableList(FileModelList, Table, Db): # @param CommentList: List of (Comment, LineNumber) # @param FileName: FileName of the comment # -def ParseHeaderCommentSection(CommentList, FileName =3D None): + + +def ParseHeaderCommentSection(CommentList, FileName=3DNone): =20 Abstract =3D '' Description =3D '' @@ -95,13 +105,13 @@ def ParseHeaderCommentSection(CommentList, FileName = =3D None): # inf files # HEADER_COMMENT_NOT_STARTED =3D -1 - HEADER_COMMENT_STARTED =3D 0 - HEADER_COMMENT_FILE =3D 1 - HEADER_COMMENT_ABSTRACT =3D 2 + HEADER_COMMENT_STARTED =3D 0 + HEADER_COMMENT_FILE =3D 1 + HEADER_COMMENT_ABSTRACT =3D 2 HEADER_COMMENT_DESCRIPTION =3D 3 - HEADER_COMMENT_COPYRIGHT =3D 4 - HEADER_COMMENT_LICENSE =3D 5 - HEADER_COMMENT_END =3D 6 + HEADER_COMMENT_COPYRIGHT =3D 4 + HEADER_COMMENT_LICENSE =3D 5 + HEADER_COMMENT_END =3D 6 # # first find the last copyright line # @@ -122,7 +132,8 @@ def ParseHeaderCommentSection(CommentList, FileName =3D= None): ResultSet =3D EccGlobalData.gDb.TblFile.Exec(SqlStatement) for Result in ResultSet: Msg =3D 'Comment must start with #' - EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FIL= E_HEADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0= ]) Comment =3D CleanString2(Line)[1] Comment =3D Comment.strip() # @@ -130,7 +141,7 @@ def ParseHeaderCommentSection(CommentList, FileName =3D= None): # indication of different block; or in the position that Abstract = should be, also keep it # as it indicates that no abstract # - if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICEN= SE, \ + if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICEN= SE, HEADER_COMMENT_DESCR= IPTION, HEADER_COMMENT_ABSTRACT]: continue =20 @@ -185,36 +196,41 @@ def ParseHeaderCommentSection(CommentList, FileName = =3D None): ResultSet =3D EccGlobalData.gDb.TblFile.Exec(SqlStatement) for Result in ResultSet: Msg =3D 'Header comment section must have copyright informatio= n' - EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HE= ADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) =20 if not License.strip(): SqlStatement =3D """ select ID from File where FullPath like '%s'"= "" % FileName ResultSet =3D EccGlobalData.gDb.TblFile.Exec(SqlStatement) for Result in ResultSet: Msg =3D 'Header comment section must have license information' - EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HE= ADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) =20 if not Abstract.strip() or Abstract.find('Component description file')= > -1: SqlStatement =3D """ select ID from File where FullPath like '%s'"= "" % FileName ResultSet =3D EccGlobalData.gDb.TblFile.Exec(SqlStatement) for Result in ResultSet: Msg =3D 'Header comment section must have Abstract information= .' - EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HE= ADER, Msg, "File", Result[0]) + EccGlobalData.gDb.TblReport.Insert( + ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0]) =20 return Abstract.strip(), Description.strip(), Copyright.strip(), Licen= se.strip() =20 -## _IsCopyrightLine +# _IsCopyrightLine # check whether current line is copyright line, the criteria is whether th= ere is case insensitive keyword "Copyright" # followed by zero or more white space characters followed by a "(" charac= ter # # @param LineContent: the line need to be checked # @return: True if current line is copyright line, False else # -def _IsCopyrightLine (LineContent): + + +def _IsCopyrightLine(LineContent): LineContent =3D LineContent.upper() Result =3D False =20 - #Support below Copyright format + # Support below Copyright format # Copyright (C) 2020 Hewlett Packard Enterprise Development LP
        # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
        ReIsCopyrightRe =3D re.compile(r"""(^|\s)COPYRIGHT *\(""", re.DOTALL) @@ -225,7 +241,7 @@ def _IsCopyrightLine (LineContent): return Result =20 =20 -## CleanString2 +# CleanString2 # # Split comments in a string # Remove spaces diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py= b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py index 1d7f6eb10434..0b5af17c48b6 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for files # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -15,11 +15,13 @@ import Common.EdkLogger as EdkLogger from CommonDataClass import DataClass from CommonDataClass.DataClass import FileClass =20 -## Convert to SQL required string format +# Convert to SQL required string format + + def ConvertToSqlString(StringList): return map(lambda s: "'" + s.replace("'", "''") + "'", StringList) =20 -## TableFile +# TableFile # # This class defined a common table # @@ -28,6 +30,8 @@ def ConvertToSqlString(StringList): # @param Cursor: Cursor of the database # @param TableName: Name of the table # + + class Table(object): _COLUMN_ =3D '' _ID_STEP_ =3D 1 @@ -44,7 +48,7 @@ class Table(object): def __str__(self): return self.Table =20 - ## Create table + # Create table # # Create a table # @@ -53,14 +57,16 @@ class Table(object): self.Drop() =20 if self.Temporary: - SqlCommand =3D """create temp table IF NOT EXISTS %s (%s)""" %= (self.Table, self._COLUMN_) + SqlCommand =3D """create temp table IF NOT EXISTS %s (%s)""" %= ( + self.Table, self._COLUMN_) else: - SqlCommand =3D """create table IF NOT EXISTS %s (%s)""" % (sel= f.Table, self._COLUMN_) + SqlCommand =3D """create table IF NOT EXISTS %s (%s)""" % ( + self.Table, self._COLUMN_) EdkLogger.debug(EdkLogger.DEBUG_8, SqlCommand) self.Cur.execute(SqlCommand) self.ID =3D self.GetId() =20 - ## Insert table + # Insert table # # Insert a record into a table # @@ -69,12 +75,13 @@ class Table(object): if self.ID >=3D (self.IdBase + self._ID_MAX_): self.ID =3D self.IdBase + self._ID_STEP_ Values =3D ", ".join(str(Arg) for Arg in Args) - SqlCommand =3D "insert into %s values(%s, %s)" % (self.Table, self= .ID, Values) + SqlCommand =3D "insert into %s values(%s, %s)" % ( + self.Table, self.ID, Values) EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand) self.Cur.execute(SqlCommand) return self.ID =20 - ## Query table + # Query table # # Query all records of the table # @@ -85,7 +92,7 @@ class Table(object): EdkLogger.verbose(str(Rs)) TotalCount =3D self.GetId() =20 - ## Drop a table + # Drop a table # # Drop the table # @@ -96,7 +103,7 @@ class Table(object): except Exception as e: print("An error occurred when Drop a table:", e.args[0]) =20 - ## Get count + # Get count # # Get a count of all records of the table # @@ -115,14 +122,14 @@ class Table(object): Id =3D self.IdBase return Id =20 - ## Init the ID of the table + # Init the ID of the table # # Init the ID of the table # def InitID(self): self.ID =3D self.GetId() =20 - ## Exec + # Exec # # Exec Sql Command, return result # @@ -149,7 +156,7 @@ class Table(object): return self.Exec("select * from %s where ID > 0 order by ID" % (se= lf.Table)) =20 =20 -## TableDataModel +# TableDataModel # # This class defined a table used for data model # @@ -163,10 +170,11 @@ class TableDataModel(Table): Name VARCHAR NOT NULL, Description VARCHAR """ + def __init__(self, Cursor): Table.__init__(self, Cursor, 'DataModel') =20 - ## Insert table + # Insert table # # Insert a record into table DataModel # @@ -179,7 +187,7 @@ class TableDataModel(Table): (Name, Description) =3D ConvertToSqlString((Name, Description)) return Table.Insert(self, CrossIndex, Name, Description) =20 - ## Init table + # Init table # # Create all default records of table DataModel # @@ -195,7 +203,7 @@ class TableDataModel(Table): self.Insert(CrossIndex, Name, Description) EdkLogger.verbose("Initialize table DataModel ... DONE!") =20 - ## Get CrossIndex + # Get CrossIndex # # Get a model's cross index from its name # @@ -210,4 +218,3 @@ class TableDataModel(Table): CrossIndex =3D Item[0] =20 return CrossIndex - diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.p= y b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 2d98ac5eadb2..1cf1815c2fe2 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse meta files # # Copyright (c) 2008 - 2020, Intel Corporation. All rights reserved.
        @@ -31,11 +31,13 @@ from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath =20 -## RegEx for finding file versions +# RegEx for finding file versions hexVersionPattern =3D re.compile(r'0[xX][\da-f-A-F]{5,8}') decVersionPattern =3D re.compile(r'\d+\.\d+') =20 -## A decorator used to parse macro definition +# A decorator used to parse macro definition + + def ParseMacro(Parser): def MacroParser(self): Match =3D GlobalData.gMacroDefPattern.match(self._CurrentLine) @@ -44,7 +46,8 @@ def ParseMacro(Parser): Parser(self) return =20 - TokenList =3D GetSplitValueList(self._CurrentLine[Match.end(1):], = TAB_EQUAL_SPLIT, 1) + TokenList =3D GetSplitValueList( + self._CurrentLine[Match.end(1):], TAB_EQUAL_SPLIT, 1) # Syntax check if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No macro name given= ", @@ -72,7 +75,8 @@ def ParseMacro(Parser): self._FileLocalMacros[Name] =3D Value else: for Scope in self._Scope: - self._SectionsMacroDict.setdefault((Scope[2], Scop= e[0], Scope[1]), {})[Name] =3D Value + self._SectionsMacroDict.setdefault( + (Scope[2], Scope[0], Scope[1]), {})[Name] =3D = Value elif self._SectionType =3D=3D MODEL_META_DATA_HEADER: self._FileLocalMacros[Name] =3D Value else: @@ -96,7 +100,7 @@ def ParseMacro(Parser): =20 return MacroParser =20 -## Base class of parser +# Base class of parser # # This class is used for derivation purpose. The specific parser for one = kind # type file must derive this class and implement some public interfaces. @@ -108,6 +112,8 @@ def ParseMacro(Parser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE= directive) # + + class MetaFileParser(object): # data type (file content) for specific file type DataType =3D {} @@ -115,7 +121,7 @@ class MetaFileParser(object): # Parser objects used to implement singleton MetaFiles =3D {} =20 - ## Factory method + # Factory method # # One file, one parser object. This factory method makes sure that the= re's # only one object constructed for one meta file. @@ -134,7 +140,7 @@ class MetaFileParser(object): Class.MetaFiles[FilePath] =3D ParserObject return ParserObject =20 - ## Constructor of MetaFileParser + # Constructor of MetaFileParser # # Initialize object of MetaFileParser # @@ -179,37 +185,37 @@ class MetaFileParser(object): self._UniObj =3D None self._UniExtraObj =3D None =20 - ## Store the parsed data in table + # Store the parsed data in table def _Store(self, *Args): return self._Table.Insert(*Args) =20 - ## Virtual method for starting parse + # Virtual method for starting parse def Start(self): raise NotImplementedError =20 - ## Notify a post-process is needed + # Notify a post-process is needed def DoPostProcess(self): self._PostProcessed =3D False =20 - ## Set parsing complete flag in both class and table + # Set parsing complete flag in both class and table def _Done(self): self._Finished =3D True - ## Do not set end flag when processing included files + # Do not set end flag when processing included files if self._From =3D=3D -1: self._Table.SetEndFlag() =20 def _PostProcess(self): self._PostProcessed =3D True =20 - ## Get the parse complete flag + # Get the parse complete flag def _GetFinished(self): return self._Finished =20 - ## Set the complete flag + # Set the complete flag def _SetFinished(self, Value): self._Finished =3D Value =20 - ## Use [] style to query data in table, just for readability + # Use [] style to query data in table, just for readability # # DataInfo =3D [data_type, scope1(arch), scope2(platform/moduletype)] # @@ -236,7 +242,7 @@ class MetaFileParser(object): =20 return self._Table.Query(*DataInfo) =20 - ## Data parser for the common format in different type of file + # Data parser for the common format in different type of file # # The common format in the meatfile is like # @@ -247,7 +253,7 @@ class MetaFileParser(object): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) self._ValueList[0:len(TokenList)] =3D TokenList =20 - ## Data parser for the format in which there's path + # Data parser for the format in which there's path # # Only path can have macro used. So we need to replace them before u= se. # @@ -258,23 +264,26 @@ class MetaFileParser(object): # Don't do macro replacement for dsc file at this point if not isinstance(self, DscParser): Macros =3D self._Macros - self._ValueList =3D [ReplaceMacro(Value, Macros) for Value in = self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, Macros) + for Value in self._ValueList] =20 - ## Skip unsupported data + # Skip unsupported data def _Skip(self): if self._SectionName =3D=3D TAB_USER_EXTENSIONS.upper() and self._= CurrentLine.upper().endswith('.UNI'): if EccGlobalData.gConfig.UniCheckHelpInfo =3D=3D '1' or EccGlo= balData.gConfig.UniCheckAll =3D=3D '1' or EccGlobalData.gConfig.CheckAll = =3D=3D '1': ExtraUni =3D self._CurrentLine.strip() - ExtraUniFile =3D os.path.join(os.path.dirname(self.MetaFil= e), ExtraUni) + ExtraUniFile =3D os.path.join( + os.path.dirname(self.MetaFile), ExtraUni) IsModuleUni =3D self.MetaFile.upper().endswith('.INF') - self._UniExtraObj =3D UniParser(ExtraUniFile, IsExtraUni= =3DTrue, IsModuleUni=3DIsModuleUni) + self._UniExtraObj =3D UniParser( + ExtraUniFile, IsExtraUni=3DTrue, IsModuleUni=3DIsModul= eUni) self._UniExtraObj.Start() else: EdkLogger.warn("Parser", "Unrecognized content", File=3Dself.M= etaFile, - Line=3Dself._LineIndex + 1, ExtraData=3Dself._= CurrentLine); + Line=3Dself._LineIndex + 1, ExtraData=3Dself._C= urrentLine) self._ValueList[0:1] =3D [self._CurrentLine] =20 - ## Section header parser + # Section header parser # # The section header is always in following format: # @@ -298,7 +307,7 @@ class MetaFileParser(object): else: self._SectionType =3D MODEL_UNKNOWN EdkLogger.warn("Parser", "Unrecognized section", File=3Dse= lf.MetaFile, - Line=3Dself._LineIndex+1, ExtraData=3Dself= ._CurrentLine) + Line=3Dself._LineIndex+1, ExtraData=3Dself.= _CurrentLine) # S1 is always Arch if len(ItemList) > 1: S1 =3D ItemList[1].upper() @@ -319,7 +328,7 @@ class MetaFileParser(object): # If the section information is needed later, it should be stored = in database self._ValueList[0] =3D self._SectionName =20 - ## [defines] section parser + # [defines] section parser @ParseMacro def _DefineParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -331,7 +340,8 @@ class MetaFileParser(object): EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex+1) =20 - self._ValueList =3D [ReplaceMacro(Value, self._Macros) for Value i= n self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, self._Macros) + for Value in self._ValueList] Name, Value =3D self._ValueList[1], self._ValueList[2] # Sometimes, we need to make differences between EDK and EDK2 modu= les if Name =3D=3D 'INF_VERSION': @@ -351,7 +361,8 @@ class MetaFileParser(object): elif Name =3D=3D 'MODULE_UNI_FILE': UniFile =3D os.path.join(os.path.dirname(self.MetaFile), Value) if os.path.exists(UniFile): - self._UniObj =3D UniParser(UniFile, IsExtraUni=3DFalse, Is= ModuleUni=3DTrue) + self._UniObj =3D UniParser( + UniFile, IsExtraUni=3DFalse, IsModuleUni=3DTrue) self._UniObj.Start() else: EdkLogger.error('Parser', FILE_NOT_FOUND, "Module UNI file= %s is missing." % Value, @@ -360,14 +371,15 @@ class MetaFileParser(object): elif Name =3D=3D 'PACKAGE_UNI_FILE': UniFile =3D os.path.join(os.path.dirname(self.MetaFile), Value) if os.path.exists(UniFile): - self._UniObj =3D UniParser(UniFile, IsExtraUni=3DFalse, Is= ModuleUni=3DFalse) + self._UniObj =3D UniParser( + UniFile, IsExtraUni=3DFalse, IsModuleUni=3DFalse) =20 if isinstance(self, InfParser) and self._Version < 0x00010005: # EDK module allows using defines as macros self._FileLocalMacros[Name] =3D Value self._Defines[Name] =3D Value =20 - ## [BuildOptions] section parser + # [BuildOptions] section parser @ParseMacro def _BuildOptionParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -377,18 +389,19 @@ class MetaFileParser(object): self._ValueList[1] =3D TokenList2[1] # keys else: self._ValueList[1] =3D TokenList[0] - if len(TokenList) =3D=3D 2 and not isinstance(self, DscParser): # = value + if len(TokenList) =3D=3D 2 and not isinstance(self, DscParser): #= value self._ValueList[2] =3D ReplaceMacro(TokenList[1], self._Macros) =20 if self._ValueList[1].count('_') !=3D 4: EdkLogger.error( 'Parser', FORMAT_INVALID, - "'%s' must be in format of ____FLAGS" % self._ValueList[1], + "'%s' must be in format of ____FLAGS" % self._ValueList[ + 1], ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex+1 - ) + ) =20 def _GetMacros(self): Macros =3D {} @@ -396,23 +409,24 @@ class MetaFileParser(object): Macros.update(self._GetApplicableSectionMacro()) return Macros =20 + # Get section Macros that are applicable to current line, which may co= me from other sections + # that share the same name while scope is wider =20 - ## Get section Macros that are applicable to current line, which may c= ome from other sections - ## that share the same name while scope is wider def _GetApplicableSectionMacro(self): Macros =3D {} for Scope1, Scope2 in [("COMMON", "COMMON"), ("COMMON", self._Scop= e[0][1]), (self._Scope[0][0], "COMMON"), (self._Scope= [0][0], self._Scope[0][1])]: if (self._SectionType, Scope1, Scope2) in self._SectionsMacroD= ict: - Macros.update(self._SectionsMacroDict[(self._SectionType, = Scope1, Scope2)]) + Macros.update(self._SectionsMacroDict[( + self._SectionType, Scope1, Scope2)]) return Macros =20 - _SectionParser =3D {} - Finished =3D property(_GetFinished, _SetFinished) - _Macros =3D property(_GetMacros) + _SectionParser =3D {} + Finished =3D property(_GetFinished, _SetFinished) + _Macros =3D property(_GetMacros) =20 =20 -## INF file parser class +# INF file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file @@ -422,30 +436,30 @@ class MetaFileParser(object): class InfParser(MetaFileParser): # INF file supported data types (one type per section) DataType =3D { - TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_INF_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DEFINE, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_PACKAGES.upper() : MODEL_META_DATA_PACKAGE, - TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE, - TAB_INF_FIXED_PCD.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_INF_PATCH_PCD.upper() : MODEL_PCD_PATCHABLE_IN_MODULE, - TAB_INF_FEATURE_PCD.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_INF_PCD_EX.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_INF_PCD.upper() : MODEL_PCD_DYNAMIC, - TAB_SOURCES.upper() : MODEL_EFI_SOURCE_FILE, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_DEPEX.upper() : MODEL_EFI_DEPEX, - TAB_BINARIES.upper() : MODEL_EFI_BINARY_FILE, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION + TAB_UNKNOWN.upper(): MODEL_UNKNOWN, + TAB_INF_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_BUILD_OPTIONS.upper(): MODEL_META_DATA_BUILD_OPTION, + TAB_INCLUDES.upper(): MODEL_EFI_INCLUDE, + TAB_LIBRARIES.upper(): MODEL_EFI_LIBRARY_INSTANCE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_PACKAGES.upper(): MODEL_META_DATA_PACKAGE, + TAB_NMAKE.upper(): MODEL_META_DATA_NMAKE, + TAB_INF_FIXED_PCD.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_INF_PATCH_PCD.upper(): MODEL_PCD_PATCHABLE_IN_MODULE, + TAB_INF_FEATURE_PCD.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_INF_PCD_EX.upper(): MODEL_PCD_DYNAMIC_EX, + TAB_INF_PCD.upper(): MODEL_PCD_DYNAMIC, + TAB_SOURCES.upper(): MODEL_EFI_SOURCE_FILE, + TAB_GUIDS.upper(): MODEL_EFI_GUID, + TAB_PROTOCOLS.upper(): MODEL_EFI_PROTOCOL, + TAB_PPIS.upper(): MODEL_EFI_PPI, + TAB_DEPEX.upper(): MODEL_EFI_DEPEX, + TAB_BINARIES.upper(): MODEL_EFI_BINARY_FILE, + TAB_USER_EXTENSIONS.upper(): MODEL_META_DATA_USER_EXTENSION } =20 - ## Constructor of InfParser + # Constructor of InfParser # # Initialize object of InfParser # @@ -462,7 +476,7 @@ class InfParser(MetaFileParser): self.TblFile =3D EccGlobalData.gDb.TblFile self.FileID =3D -1 =20 - ## Parser starter + # Parser starter def Start(self): NmakeLine =3D '' Content =3D '' @@ -470,7 +484,8 @@ class InfParser(MetaFileParser): try: Content =3D open(str(self.MetaFile), 'r').readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) # # Insert a record for file # @@ -503,7 +518,7 @@ class InfParser(MetaFileParser): Usage +=3D ' ' + Line[Line.find(TAB_COMMENT_SPLIT):] Line =3D Line[:Line.find(TAB_COMMENT_SPLIT)] else: - # skip empty, commented, block commented lines + # skip empty, commented, block commented lines Line =3D CleanString(Content[Index], AllowCppStyleComment= =3DTrue) Usage =3D '' NextLine =3D '' @@ -541,13 +556,15 @@ class InfParser(MetaFileParser): MODEL_EFI_PPI, MODEL_META_DATA_USER_EXTENSIO= N]: EdkLogger.error('Parser', FORMAT_INVALID, - "Section [%s] is not allowed in in= f file without version" % (self._SectionName), + "Section [%s] is not allowed in in= f file without version" % ( + self._SectionName), ExtraData=3Dself._CurrentLine, Fil= e=3Dself.MetaFile, Line=3Dself._LineIndex+1) elif self._SectionType in [MODEL_EFI_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, MODEL_META_DATA_NMAKE]: EdkLogger.error('Parser', FORMAT_INVALID, - "Section [%s] is not allowed in inf fi= le with version 0x%08x" % (self._SectionName, self._Version), + "Section [%s] is not allowed in inf fi= le with version 0x%08x" % ( + self._SectionName, self._Version), ExtraData=3Dself._CurrentLine, File=3D= self.MetaFile, Line=3Dself._LineIndex+1) continue # merge two lines specified by '\' in section NMAKE @@ -602,7 +619,7 @@ class InfParser(MetaFileParser): File=3Dself.MetaFile) self._Done() =20 - ## Data parser for the format in which there's path + # Data parser for the format in which there's path # # Only path can have macro used. So we need to replace them before u= se. # @@ -618,7 +635,7 @@ class InfParser(MetaFileParser): =20 self._ValueList[Index] =3D ReplaceMacro(Value, Macros) =20 - ## Parse [Sources] section + # Parse [Sources] section # # Only path can have macro used. So we need to replace them before u= se. # @@ -630,12 +647,14 @@ class InfParser(MetaFileParser): # For Acpi tables, remove macro like ' TABLE_NAME=3DSata1' if 'COMPONENT_TYPE' in Macros: if self._Defines['COMPONENT_TYPE'].upper() =3D=3D 'ACPITABLE': - self._ValueList[0] =3D GetSplitValueList(self._ValueList[0= ], ' ', 1)[0] + self._ValueList[0] =3D GetSplitValueList( + self._ValueList[0], ' ', 1)[0] if self._Defines['BASE_NAME'] =3D=3D 'Microcode': pass - self._ValueList =3D [ReplaceMacro(Value, Macros) for Value in self= ._ValueList] + self._ValueList =3D [ReplaceMacro(Value, Macros) + for Value in self._ValueList] =20 - ## Parse [Binaries] section + # Parse [Binaries] section # # Only path can have macro used. So we need to replace them before u= se. # @@ -644,20 +663,23 @@ class InfParser(MetaFileParser): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT= , 2) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No file type or pat= h specified", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No file type specif= ied", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if not TokenList[1]: EdkLogger.error('Parser', FORMAT_INVALID, "No file path specif= ied", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) self._ValueList[0:len(TokenList)] =3D TokenList self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], self._Macr= os) =20 - ## [nmake] section parser (Edk.x style only) + # [nmake] section parser (Edk.x style only) def _NmakeParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) self._ValueList[0:len(TokenList)] =3D TokenList @@ -666,60 +688,65 @@ class InfParser(MetaFileParser): # remove self-reference in macro setting #self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], {self._Va= lueList[0]:''}) =20 - ## [FixedPcd], [FeaturePcd], [PatchPcd], [Pcd] and [PcdEx] sections pa= rser + # [FixedPcd], [FeaturePcd], [PatchPcd], [Pcd] and [PcdEx] sections par= ser @ParseMacro def _PcdParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT= , 1) ValueList =3D GetSplitValueList(TokenList[0], TAB_SPLIT) if len(ValueList) !=3D 2: EdkLogger.error('Parser', FORMAT_INVALID, "Illegal token space= GUID and PCD name format", - ExtraData=3Dself._CurrentLine + " (.)", + ExtraData=3Dself._CurrentLine + + " (.)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) self._ValueList[0:1] =3D ValueList if len(TokenList) > 1: self._ValueList[2] =3D TokenList[1] if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID= or PCD name specified", - ExtraData=3Dself._CurrentLine + " (.)", + ExtraData=3Dself._CurrentLine + + " (.)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) =20 # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE'= , replace with integer 1 or 0. if self._ValueList[2] !=3D '': - InfPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_= SPLIT, 1) + InfPcdValueList =3D GetSplitValueList( + TokenList[1], TAB_VALUE_SPLIT, 1) if InfPcdValueList[0] in ['True', 'true', 'TRUE']: - self._ValueList[2] =3D TokenList[1].replace(InfPcdValueLis= t[0], '1', 1); + self._ValueList[2] =3D TokenList[1].replace( + InfPcdValueList[0], '1', 1) elif InfPcdValueList[0] in ['False', 'false', 'FALSE']: - self._ValueList[2] =3D TokenList[1].replace(InfPcdValueLis= t[0], '0', 1); + self._ValueList[2] =3D TokenList[1].replace( + InfPcdValueList[0], '0', 1) =20 - ## [depex] section parser + # [depex] section parser @ParseMacro def _DepexParser(self): self._ValueList[0:1] =3D [self._CurrentLine] =20 _SectionParser =3D { - MODEL_UNKNOWN : MetaFileParser._Skip, - MODEL_META_DATA_HEADER : MetaFileParser._DefineParser, - MODEL_META_DATA_BUILD_OPTION : MetaFileParser._BuildOptionPar= ser, - MODEL_EFI_INCLUDE : _IncludeParser, = # for Edk.x modules - MODEL_EFI_LIBRARY_INSTANCE : MetaFileParser._CommonParser, = # for Edk.x modules - MODEL_EFI_LIBRARY_CLASS : MetaFileParser._PathParser, - MODEL_META_DATA_PACKAGE : MetaFileParser._PathParser, - MODEL_META_DATA_NMAKE : _NmakeParser, = # for Edk.x modules - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC_EX : _PcdParser, - MODEL_PCD_DYNAMIC : _PcdParser, - MODEL_EFI_SOURCE_FILE : _SourceFileParser, - MODEL_EFI_GUID : MetaFileParser._CommonParser, - MODEL_EFI_PROTOCOL : MetaFileParser._CommonParser, - MODEL_EFI_PPI : MetaFileParser._CommonParser, - MODEL_EFI_DEPEX : _DepexParser, - MODEL_EFI_BINARY_FILE : _BinaryFileParser, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser._Skip, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_HEADER: MetaFileParser._DefineParser, + MODEL_META_DATA_BUILD_OPTION: MetaFileParser._BuildOptionParser, + MODEL_EFI_INCLUDE: _IncludeParser, # for Edk.x m= odules + MODEL_EFI_LIBRARY_INSTANCE: MetaFileParser._CommonParser, # fo= r Edk.x modules + MODEL_EFI_LIBRARY_CLASS: MetaFileParser._PathParser, + MODEL_META_DATA_PACKAGE: MetaFileParser._PathParser, + MODEL_META_DATA_NMAKE: _NmakeParser, # for Edk= .x modules + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC_EX: _PcdParser, + MODEL_PCD_DYNAMIC: _PcdParser, + MODEL_EFI_SOURCE_FILE: _SourceFileParser, + MODEL_EFI_GUID: MetaFileParser._CommonParser, + MODEL_EFI_PROTOCOL: MetaFileParser._CommonParser, + MODEL_EFI_PPI: MetaFileParser._CommonParser, + MODEL_EFI_DEPEX: _DepexParser, + MODEL_EFI_BINARY_FILE: _BinaryFileParser, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._Skip, } =20 -## DSC file parser class +# DSC file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file @@ -728,34 +755,36 @@ class InfParser(MetaFileParser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE= directive) # + + class DscParser(MetaFileParser): # DSC file supported data types (one type per section) DataType =3D { - TAB_SKUIDS.upper() : MODEL_EFI_SKU_ID, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_= INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_= CLASS, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BU= ILD_OPTION, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT= _BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABL= E_IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_= FLAG, - TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_= DEFAULT, - TAB_PCDS_DYNAMIC_HII_NULL.upper() : MODEL_PCD_DYNAMIC_= HII, - TAB_PCDS_DYNAMIC_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_= VPD, - TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_DEFAULT, - TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_HII, - TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_VPD, - TAB_COMPONENTS.upper() : MODEL_META_DATA_CO= MPONENT, - TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HE= ADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DE= FINE, - TAB_DSC_DEFINES_EDKGLOBAL : MODEL_META_DATA_GL= OBAL_DEFINE, - TAB_INCLUDE.upper() : MODEL_META_DATA_IN= CLUDE, - TAB_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IF, - TAB_IF_DEF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IFDEF, - TAB_IF_N_DEF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IFNDEF, - TAB_ELSE_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSEIF, - TAB_ELSE.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSE, - TAB_END_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ENDIF, - TAB_ERROR.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ERROR, + TAB_SKUIDS.upper(): MODEL_EFI_SKU_ID, + TAB_LIBRARIES.upper(): MODEL_EFI_LIBRARY_INSTANCE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_BUILD_OPTIONS.upper(): MODEL_META_DATA_BUILD_OPTION, + TAB_PCDS_FIXED_AT_BUILD_NULL.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(): MODEL_PCD_PATCHABLE_I= N_MODULE, + TAB_PCDS_FEATURE_FLAG_NULL.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper(): MODEL_PCD_DYNAMIC_DEFAULT, + TAB_PCDS_DYNAMIC_HII_NULL.upper(): MODEL_PCD_DYNAMIC_HII, + TAB_PCDS_DYNAMIC_VPD_NULL.upper(): MODEL_PCD_DYNAMIC_VPD, + TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper(): MODEL_PCD_DYNAMIC_EX_D= EFAULT, + TAB_PCDS_DYNAMIC_EX_HII_NULL.upper(): MODEL_PCD_DYNAMIC_EX_HII, + TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper(): MODEL_PCD_DYNAMIC_EX_VPD, + TAB_COMPONENTS.upper(): MODEL_META_DATA_COMPONENT, + TAB_DSC_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_DSC_DEFINES_EDKGLOBAL: MODEL_META_DATA_GLOBAL_DEFINE, + TAB_INCLUDE.upper(): MODEL_META_DATA_INCLUDE, + TAB_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, + TAB_IF_DEF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, + TAB_IF_N_DEF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IFND= EF, + TAB_ELSE_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEI= F, + TAB_ELSE.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, + TAB_END_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF, + TAB_ERROR.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR, } =20 # Valid names in define section @@ -784,7 +813,7 @@ class DscParser(MetaFileParser): =20 SymbolPattern =3D ValueExpression.SymbolPattern =20 - ## Constructor of DscParser + # Constructor of DscParser # # Initialize object of DscParser # @@ -812,18 +841,19 @@ class DscParser(MetaFileParser): # Map the ID between the original table and new table to track # the owner item # - self._IdMapping =3D {-1:-1} + self._IdMapping =3D {-1: -1} =20 self.TblFile =3D EccGlobalData.gDb.TblFile self.FileID =3D -1 =20 - ## Parser starter + # Parser starter def Start(self): Content =3D '' try: Content =3D open(str(self.MetaFile.Path), 'r').readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) # # Insert a record for file # @@ -834,7 +864,6 @@ class DscParser(MetaFileParser): else: self.FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_D= SC) =20 - for Index in range(0, len(Content)): Line =3D CleanString(Content[Index]) # skip empty line @@ -880,21 +909,21 @@ class DscParser(MetaFileParser): # for Arch, ModuleType in self._Scope: self._LastItem =3D self._Store( - self._ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - Arch, - ModuleType, - self._Owner[-1], - self.FileID, - self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, - self._Enabled - ) + self._ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + Arch, + ModuleType, + self._Owner[-1], + self.FileID, + self._From, + self._LineIndex+1, + -1, + self._LineIndex+1, + -1, + self._Enabled + ) =20 if self._DirectiveStack: Type, Line, Text =3D self._DirectiveStack[-1] @@ -902,7 +931,7 @@ class DscParser(MetaFileParser): ExtraData=3DText, File=3Dself.MetaFile, Line= =3DLine) self._Done() =20 - ## parser + # parser def _SubsectionHeaderParser(self): self._SubsectionName =3D self._CurrentLine[1:-1].upper() if self._SubsectionName in self.DataType: @@ -913,7 +942,7 @@ class DscParser(MetaFileParser): Line=3Dself._LineIndex+1, ExtraData=3Dself._Cur= rentLine) self._ValueList[0] =3D self._SubsectionName =20 - ## Directive statement parser + # Directive statement parser def _DirectiveParser(self): self._ValueList =3D ['', '', ''] TokenList =3D GetSplitValueList(self._CurrentLine, ' ', 1) @@ -951,7 +980,8 @@ class DscParser(MetaFileParser): EdkLogger.error("Parser", FORMAT_INVALID, "'!elseif' after= '!else'", File=3Dself.MetaFile, Line=3Dself._LineInd= ex+1, ExtraData=3Dself._CurrentLine) - self._DirectiveStack.append((ItemType, self._LineIndex+1, self= ._CurrentLine)) + self._DirectiveStack.append( + (ItemType, self._LineIndex+1, self._CurrentLine)) elif self._From > 0: EdkLogger.error('Parser', FORMAT_INVALID, "No '!include' allowed in included file", @@ -963,23 +993,23 @@ class DscParser(MetaFileParser): # LineBegin=3D-1, ColumnBegin=3D-1, LineEnd=3D-1, ColumnEnd=3D-1, = Enabled=3D-1 # self._LastItem =3D self._Store( - ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - 'COMMON', - 'COMMON', - self._Owner[-1], - self.FileID, - self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, - 0 - ) + ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + 'COMMON', + 'COMMON', + self._Owner[-1], + self.FileID, + self._From, + self._LineIndex+1, + -1, + self._LineIndex+1, + -1, + 0 + ) =20 - ## [defines] section parser + # [defines] section parser @ParseMacro def _DefineParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -993,7 +1023,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex+1) if (not self._ValueList[1] in self.DefineKeywords and - (self._InSubsection and self._ValueList[1] not in self.SubSect= ionDefineKeywords)): + (self._InSubsection and self._ValueList[1] not in self.Sub= SectionDefineKeywords)): EdkLogger.error('Parser', FORMAT_INVALID, "Unknown keyword found: %s. " "If this is a macro you must " @@ -1010,11 +1040,11 @@ class DscParser(MetaFileParser): ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex+1) self._ValueList[0:len(TokenList)] =3D TokenList =20 - ## Parse Edk style of library modules + # Parse Edk style of library modules def _LibraryInstanceParser(self): self._ValueList[0] =3D self._CurrentLine =20 - ## PCD sections parser + # PCD sections parser # # [PcdsFixedAtBuild] # [PcdsPatchableInModule] @@ -1036,20 +1066,24 @@ class DscParser(MetaFileParser): self._ValueList[2] =3D TokenList[1] if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID= or PCD name specified", - ExtraData=3Dself._CurrentLine + " (.|)", + ExtraData=3Dself._CurrentLine + + " (.|)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if self._ValueList[2] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value given", - ExtraData=3Dself._CurrentLine + " (.|)", + ExtraData=3Dself._CurrentLine + + " (.|)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE'= , replace with integer 1 or 0. DscPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_SPLI= T, 1) if DscPcdValueList[0] in ['True', 'true', 'TRUE']: - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList[0]= , '1', 1); + self._ValueList[2] =3D TokenList[1].replace( + DscPcdValueList[0], '1', 1) elif DscPcdValueList[0] in ['False', 'false', 'FALSE']: - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList[0]= , '0', 1); + self._ValueList[2] =3D TokenList[1].replace( + DscPcdValueList[0], '0', 1) =20 - ## [components] section parser + # [components] section parser @ParseMacro def _ComponentParser(self): if self._CurrentLine[-1] =3D=3D '{': @@ -1058,27 +1092,30 @@ class DscParser(MetaFileParser): else: self._ValueList[0] =3D self._CurrentLine =20 - ## [LibraryClasses] section + # [LibraryClasses] section @ParseMacro def _LibraryClassParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No library class or= instance specified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if TokenList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No library class sp= ecified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No library instance= specified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) =20 self._ValueList[0:len(TokenList)] =3D TokenList =20 + # [BuildOptions] section parser =20 - ## [BuildOptions] section parser @ParseMacro def _BuildOptionParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -1095,15 +1132,17 @@ class DscParser(MetaFileParser): EdkLogger.error( 'Parser', FORMAT_INVALID, - "'%s' must be in format of ____FLAGS" % self._ValueList[1], + "'%s' must be in format of ____FLAGS" % self._ValueList[ + 1], ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex+1 - ) + ) =20 - ## Override parent's method since we'll do all macro replacements in p= arser + # Override parent's method since we'll do all macro replacements in pa= rser def _GetMacros(self): - Macros =3D dict( [('ARCH', 'IA32'), ('FAMILY', TAB_COMPILER_MSFT),= ('TOOL_CHAIN_TAG', 'VS2008x86'), ('TARGET', 'DEBUG')]) + Macros =3D dict([('ARCH', 'IA32'), ('FAMILY', TAB_COMPILER_MSFT), + ('TOOL_CHAIN_TAG', 'VS2008x86'), ('TARGET', 'DEBUG')= ]) Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) Macros.update(GlobalData.gEdkGlobal) @@ -1116,39 +1155,40 @@ class DscParser(MetaFileParser): =20 def _PostProcess(self): Processer =3D { - MODEL_META_DATA_SECTION_HEADER : self.__Pro= cessSectionHeader, - MODEL_META_DATA_SUBSECTION_HEADER : self.__Pro= cessSubsectionHeader, - MODEL_META_DATA_HEADER : self.__Pro= cessDefine, - MODEL_META_DATA_DEFINE : self.__Pro= cessDefine, - MODEL_META_DATA_GLOBAL_DEFINE : self.__Pro= cessDefine, - MODEL_META_DATA_INCLUDE : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF : self.__Pro= cessDirective, - MODEL_EFI_SKU_ID : self.__Pro= cessSkuId, - MODEL_EFI_LIBRARY_INSTANCE : self.__Pro= cessLibraryInstance, - MODEL_EFI_LIBRARY_CLASS : self.__Pro= cessLibraryClass, - MODEL_PCD_FIXED_AT_BUILD : self.__Pro= cessPcd, - MODEL_PCD_PATCHABLE_IN_MODULE : self.__Pro= cessPcd, - MODEL_PCD_FEATURE_FLAG : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_DEFAULT : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_HII : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_VPD : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_DEFAULT : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_HII : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_VPD : self.__Pro= cessPcd, - MODEL_META_DATA_COMPONENT : self.__Pro= cessComponent, - MODEL_META_DATA_BUILD_OPTION : self.__Pro= cessBuildOption, - MODEL_UNKNOWN : self._Skip, - MODEL_META_DATA_USER_EXTENSION : self._Skip, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR : self._Skip, + MODEL_META_DATA_SECTION_HEADER: self.__ProcessSectionHeader, + MODEL_META_DATA_SUBSECTION_HEADER: self.__ProcessSubsectionH= eader, + MODEL_META_DATA_HEADER: self.__ProcessDefine, + MODEL_META_DATA_DEFINE: self.__ProcessDefine, + MODEL_META_DATA_GLOBAL_DEFINE: self.__ProcessDefine, + MODEL_META_DATA_INCLUDE: self.__ProcessDirective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IF: self.__ProcessDire= ctive, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE: self.__ProcessDi= rective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF: self.__ProcessD= irective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF: self.__Process= Directive, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF: self.__ProcessD= irective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF: self.__Process= Directive, + MODEL_EFI_SKU_ID: self.__ProcessSkuId, + MODEL_EFI_LIBRARY_INSTANCE: self.__ProcessLibraryInstance, + MODEL_EFI_LIBRARY_CLASS: self.__ProcessLibraryClass, + MODEL_PCD_FIXED_AT_BUILD: self.__ProcessPcd, + MODEL_PCD_PATCHABLE_IN_MODULE: self.__ProcessPcd, + MODEL_PCD_FEATURE_FLAG: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_DEFAULT: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_HII: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_VPD: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_DEFAULT: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_HII: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_VPD: self.__ProcessPcd, + MODEL_META_DATA_COMPONENT: self.__ProcessComponent, + MODEL_META_DATA_BUILD_OPTION: self.__ProcessBuildOption, + MODEL_UNKNOWN: self._Skip, + MODEL_META_DATA_USER_EXTENSION: self._Skip, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR: self._Skip, } =20 self._RawTable =3D self._Table - self._Table =3D MetaFileStorage(self._RawTable.Cur, self.MetaFile,= MODEL_FILE_DSC, True) + self._Table =3D MetaFileStorage( + self._RawTable.Cur, self.MetaFile, MODEL_FILE_DSC, True) self._DirectiveStack =3D [] self._DirectiveEvalStack =3D [] self._FileWithError =3D self.MetaFile @@ -1160,7 +1200,7 @@ class DscParser(MetaFileParser): self.__RetrievePcdValue() self._Content =3D self._RawTable.GetAll() self._ContentIndex =3D 0 - while self._ContentIndex < len(self._Content) : + while self._ContentIndex < len(self._Content): Id, self._ItemType, V1, V2, V3, S1, S2, Owner, BelongsToFile, = self._From, \ LineStart, ColStart, LineEnd, ColEnd, Enabled =3D self._Co= ntent[self._ContentIndex] =20 @@ -1186,30 +1226,32 @@ class DscParser(MetaFileParser): # Line=3Dself._LineIndex+1) except MacroException as Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), - File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList), + File=3Dself._FileWithError, ExtraData=3D' = '.join( + self._ValueList), Line=3Dself._LineIndex+1) =20 if self._ValueList is None: continue =20 NewOwner =3D self._IdMapping.get(Owner, -1) - self._Enabled =3D int((not self._DirectiveEvalStack) or (False= not in self._DirectiveEvalStack)) + self._Enabled =3D int((not self._DirectiveEvalStack) or ( + False not in self._DirectiveEvalStack)) self._LastItem =3D self._Store( - self._ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - S1, - S2, - NewOwner, - BelongsToFile, - self._From, - self._LineIndex+1, - -1, - self._LineIndex+1, - -1, - self._Enabled - ) + self._ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + S1, + S2, + NewOwner, + BelongsToFile, + self._From, + self._LineIndex+1, + -1, + self._LineIndex+1, + -1, + self._Enabled + ) self._IdMapping[Id] =3D self._LastItem =20 RecordList =3D self._Table.GetAll() @@ -1217,7 +1259,8 @@ class DscParser(MetaFileParser): self._RawTable.Drop() self._Table.Drop() for Record in RecordList: - EccGlobalData.gDb.TblDsc.Insert(Record[1], Record[2], Record[3= ], Record[4], Record[5], Record[6], Record[7], Record[8], Record[9], Record= [10], Record[11], Record[12], Record[13], Record[14]) + EccGlobalData.gDb.TblDsc.Insert(Record[1], Record[2], Record[3= ], Record[4], Record[5], Record[6], + Record[7], Record[8], Record[9= ], Record[10], Record[11], Record[12], Record[13], Record[14]) GlobalData.gPlatformDefines.update(self._FileLocalMacros) self._PostProcessed =3D True self._Content =3D None @@ -1237,7 +1280,8 @@ class DscParser(MetaFileParser): self._SubsectionType =3D MODEL_UNKNOWN =20 def __RetrievePcdValue(self): - Records =3D self._RawTable.Query(MODEL_PCD_FEATURE_FLAG, BelongsTo= Item=3D-1.0) + Records =3D self._RawTable.Query( + MODEL_PCD_FEATURE_FLAG, BelongsToItem=3D-1.0) for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Re= cords: Value, DatumType, MaxDatumSize =3D AnalyzePcdData(Value) # Only use PCD whose value is straitforward (no macro and PCD) @@ -1250,7 +1294,8 @@ class DscParser(MetaFileParser): continue self._Symbols[Name] =3D Value =20 - Records =3D self._RawTable.Query(MODEL_PCD_FIXED_AT_BUILD, Belongs= ToItem=3D-1.0) + Records =3D self._RawTable.Query( + MODEL_PCD_FIXED_AT_BUILD, BelongsToItem=3D-1.0) for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Re= cords: Value, DatumType, MaxDatumSize =3D AnalyzePcdData(Value) # Only use PCD whose value is straitforward (no macro and PCD) @@ -1298,7 +1343,8 @@ class DscParser(MetaFileParser): try: Result =3D ValueExpression(self._ValueList[1], Macros)() except SymbolNotFound as Exc: - EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) + EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), + self._ValueList[1]) Result =3D False except WrnExpression as Excpt: # @@ -1306,11 +1352,13 @@ class DscParser(MetaFileParser): # the precise number of line and return the evaluation res= ult # EdkLogger.warn('Parser', "Suspicious expression: %s" % str= (Excpt), - File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList), - Line=3Dself._LineIndex+1) + File=3Dself._FileWithError, ExtraData=3D' '= .join( + self._ValueList), + Line=3Dself._LineIndex+1) Result =3D Excpt.result except BadExpression as Exc: - EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) + EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), + self._ValueList[1]) Result =3D False =20 if self._ItemType in [MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, @@ -1321,7 +1369,8 @@ class DscParser(MetaFileParser): Result =3D bool(Result) else: Macro =3D self._ValueList[1] - Macro =3D Macro[2:-1] if (Macro.startswith("$(") and Macro= .endswith(")")) else Macro + Macro =3D Macro[2:-1] if (Macro.startswith("$(") + and Macro.endswith(")")) else Macro Result =3D Macro in self._Macros if self._ItemType =3D=3D MODEL_META_DATA_CONDITIONAL_STATE= MENT_IFNDEF: Result =3D not Result @@ -1356,7 +1405,8 @@ class DscParser(MetaFileParser): # __IncludeMacros.update(self._Macros) =20 - IncludedFile =3D NormPath(ReplaceMacro(self._ValueList[1], __I= ncludeMacros, RaiseError=3DTrue)) + IncludedFile =3D NormPath(ReplaceMacro( + self._ValueList[1], __IncludeMacros, RaiseError=3DTrue)) # # First search the include file under the same directory as DS= C file # @@ -1370,11 +1420,12 @@ class DscParser(MetaFileParser): ErrorCode, ErrorInfo2 =3D IncludedFile1.Validate() if ErrorCode !=3D 0: EdkLogger.error('parser', ErrorCode, File=3Dself._File= WithError, - Line=3Dself._LineIndex+1, ExtraData=3D= ErrorInfo1 + "\n"+ ErrorInfo2) + Line=3Dself._LineIndex+1, ExtraData=3D= ErrorInfo1 + "\n" + ErrorInfo2) =20 self._FileWithError =3D IncludedFile1 =20 - IncludedFileTable =3D MetaFileStorage(self._Table.Cur, Include= dFile1, MODEL_FILE_DSC, True) + IncludedFileTable =3D MetaFileStorage( + self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, True) Owner =3D self._Content[self._ContentIndex-1][0] Parser =3D DscParser(IncludedFile1, self._FileType, IncludedFi= leTable, Owner=3DOwner, From=3DOwner) @@ -1390,8 +1441,8 @@ class DscParser(MetaFileParser): # update current status with sub-parser's status self._SectionName =3D Parser._SectionName self._SectionType =3D Parser._SectionType - self._Scope =3D Parser._Scope - self._Enabled =3D Parser._Enabled + self._Scope =3D Parser._Scope + self._Enabled =3D Parser._Enabled =20 # Insert all records in the table for the included file into d= sc file table Records =3D IncludedFileTable.GetAll() @@ -1406,10 +1457,12 @@ class DscParser(MetaFileParser): for Value in self._ValueList] =20 def __ProcessLibraryInstance(self): - self._ValueList =3D [ReplaceMacro(Value, self._Macros) for Value i= n self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, self._Macros) + for Value in self._ValueList] =20 def __ProcessLibraryClass(self): - self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], self._Macr= os, RaiseError=3DTrue) + self._ValueList[1] =3D ReplaceMacro( + self._ValueList[1], self._Macros, RaiseError=3DTrue) =20 def __ProcessPcd(self): ValueList =3D GetSplitValueList(self._ValueList[2]) @@ -1444,54 +1497,56 @@ class DscParser(MetaFileParser): for Value in self._ValueList] =20 _SectionParser =3D { - MODEL_META_DATA_HEADER : _DefineParser, - MODEL_EFI_SKU_ID : _SkuIdParser, - MODEL_EFI_LIBRARY_INSTANCE : _LibraryInstan= ceParser, - MODEL_EFI_LIBRARY_CLASS : _LibraryClassP= arser, - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC_DEFAULT : _PcdParser, - MODEL_PCD_DYNAMIC_HII : _PcdParser, - MODEL_PCD_DYNAMIC_VPD : _PcdParser, - MODEL_PCD_DYNAMIC_EX_DEFAULT : _PcdParser, - MODEL_PCD_DYNAMIC_EX_HII : _PcdParser, - MODEL_PCD_DYNAMIC_EX_VPD : _PcdParser, - MODEL_META_DATA_COMPONENT : _ComponentPars= er, - MODEL_META_DATA_BUILD_OPTION : _BuildOptionPa= rser, - MODEL_UNKNOWN : MetaFileParser= ._Skip, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser= ._Skip, - MODEL_META_DATA_SECTION_HEADER : MetaFileParser= ._SectionHeaderParser, - MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHea= derParser, + MODEL_META_DATA_HEADER: _DefineParser, + MODEL_EFI_SKU_ID: _SkuIdParser, + MODEL_EFI_LIBRARY_INSTANCE: _LibraryInstanceParser, + MODEL_EFI_LIBRARY_CLASS: _LibraryClassParser, + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC_DEFAULT: _PcdParser, + MODEL_PCD_DYNAMIC_HII: _PcdParser, + MODEL_PCD_DYNAMIC_VPD: _PcdParser, + MODEL_PCD_DYNAMIC_EX_DEFAULT: _PcdParser, + MODEL_PCD_DYNAMIC_EX_HII: _PcdParser, + MODEL_PCD_DYNAMIC_EX_VPD: _PcdParser, + MODEL_META_DATA_COMPONENT: _ComponentParser, + MODEL_META_DATA_BUILD_OPTION: _BuildOptionParser, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._Skip, + MODEL_META_DATA_SECTION_HEADER: MetaFileParser._SectionHeaderPar= ser, + MODEL_META_DATA_SUBSECTION_HEADER: _SubsectionHeaderParser, } =20 - _Macros =3D property(_GetMacros) + _Macros =3D property(_GetMacros) =20 -## DEC file parser class +# DEC file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file # @param Table Database used to retrieve module/package i= nformation # @param Macros Macros used for replacement in file # + + class DecParser(MetaFileParser): # DEC file supported data types (one type per section) DataType =3D { - TAB_DEC_DEFINES.upper() : MODEL_META_DATA_HE= ADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DE= FINE, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_= CLASS, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT= _BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABL= E_IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_= FLAG, - TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC, - TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_= EX, + TAB_DEC_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_INCLUDES.upper(): MODEL_EFI_INCLUDE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_GUIDS.upper(): MODEL_EFI_GUID, + TAB_PPIS.upper(): MODEL_EFI_PPI, + TAB_PROTOCOLS.upper(): MODEL_EFI_PROTOCOL, + TAB_PCDS_FIXED_AT_BUILD_NULL.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(): MODEL_PCD_PATCHABLE_I= N_MODULE, + TAB_PCDS_FEATURE_FLAG_NULL.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_PCDS_DYNAMIC_NULL.upper(): MODEL_PCD_DYNAMIC, + TAB_PCDS_DYNAMIC_EX_NULL.upper(): MODEL_PCD_DYNAMIC_EX, } =20 - ## Constructor of DecParser + # Constructor of DecParser # # Initialize object of DecParser # @@ -1514,13 +1569,14 @@ class DecParser(MetaFileParser): self._include_flag =3D False self._package_flag =3D False =20 - ## Parser starter + # Parser starter def Start(self): Content =3D '' try: Content =3D open(str(self.MetaFile), 'r').readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) =20 # # Insert a record for file @@ -1580,7 +1636,7 @@ class DecParser(MetaFileParser): self._LineIndex+1, -1, 0 - ) + ) for Comment, LineNo in self._Comments: self._Store( MODEL_META_DATA_COMMENT, @@ -1596,7 +1652,7 @@ class DecParser(MetaFileParser): LineNo, -1, 0 - ) + ) self._Comments =3D [] self._Done() =20 @@ -1605,10 +1661,11 @@ class DecParser(MetaFileParser): for S1, S2, SectionType in self._Scope: for Scope1, Scope2 in [("COMMON", "COMMON"), ("COMMON", S2), (= S1, "COMMON"), (S1, S2)]: if (SectionType, Scope1, Scope2) in self._SectionsMacroDic= t: - Macros.update(self._SectionsMacroDict[(SectionType, Sc= ope1, Scope2)]) + Macros.update( + self._SectionsMacroDict[(SectionType, Scope1, Scop= e2)]) return Macros =20 - ## Section header parser + # Section header parser # # The section header is always in following format: # @@ -1631,18 +1688,18 @@ class DecParser(MetaFileParser): self._SectionType.append(self.DataType[self._SectionNa= me]) else: EdkLogger.warn("Parser", "Unrecognized section", File=3Dse= lf.MetaFile, - Line=3Dself._LineIndex+1, ExtraData=3Dself= ._CurrentLine) + Line=3Dself._LineIndex+1, ExtraData=3Dself.= _CurrentLine) continue =20 if MODEL_PCD_FEATURE_FLAG in self._SectionType and len(self._S= ectionType) > 1: EdkLogger.error( - 'Parser', - FORMAT_INVALID, - "%s must not be in the same section of other t= ypes of PCD" % TAB_PCDS_FEATURE_FLAG_NULL, - File=3Dself.MetaFile, - Line=3Dself._LineIndex+1, - ExtraData=3Dself._CurrentLine - ) + 'Parser', + FORMAT_INVALID, + "%s must not be in the same section of other types of = PCD" % TAB_PCDS_FEATURE_FLAG_NULL, + File=3Dself.MetaFile, + Line=3Dself._LineIndex+1, + ExtraData=3Dself._CurrentLine + ) # S1 is always Arch if len(ItemList) > 1: S1 =3D ItemList[1].upper() @@ -1662,29 +1719,32 @@ class DecParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must = not be used with specific ARCHs", File=3Dself.MetaFile, Line=3Dself._LineIndex+1= , ExtraData=3Dself._CurrentLine) =20 - ## [guids], [ppis] and [protocols] section parser + # [guids], [ppis] and [protocols] section parser @ParseMacro def _GuidParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name or val= ue specified", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if TokenList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name specif= ied", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID value speci= fied", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if TokenList[1][0] !=3D '{' or TokenList[1][-1] !=3D '}' or GuidSt= ructureStringToGuidString(TokenList[1]) =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Invalid GUID value = format", - ExtraData=3Dself._CurrentLine + \ - " ( =3D )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) self._ValueList[0] =3D TokenList[0] - #Parse the Guid value format + # Parse the Guid value format GuidValueList =3D TokenList[1].strip(' {}').split(',') Index =3D 0 HexList =3D [] @@ -1700,15 +1760,16 @@ class DecParser(MetaFileParser): GuidValue =3D GuidValue.lstrip(' {') HexList.append('0x' + str(GuidValue[2:])) Index +=3D 1 - self._ValueList[1] =3D "{ %s, %s, %s, { %s, %s, %s, %s, %s, %s= , %s, %s }}" % (HexList[0], HexList[1], HexList[2], HexList[3], HexList[4],= HexList[5], HexList[6], HexList[7], HexList[8], HexList[9], HexList[10]) + self._ValueList[1] =3D "{ %s, %s, %s, { %s, %s, %s, %s, %s, %s= , %s, %s }}" % ( + HexList[0], HexList[1], HexList[2], HexList[3], HexList[4]= , HexList[5], HexList[6], HexList[7], HexList[8], HexList[9], HexList[10]) else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid GUID value = format", - ExtraData=3Dself._CurrentLine + \ - " ( =3D )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) self._ValueList[0] =3D '' =20 - def ParsePcdName(self,namelist): + def ParsePcdName(self, namelist): if "[" in namelist[1]: pcdname =3D namelist[1][:namelist[1].index("[")] arrayindex =3D namelist[1][namelist[1].index("["):] @@ -1716,7 +1777,7 @@ class DecParser(MetaFileParser): if len(namelist) =3D=3D 2: namelist.append(arrayindex) else: - namelist[2] =3D ".".join((arrayindex,namelist[2])) + namelist[2] =3D ".".join((arrayindex, namelist[2])) return namelist =20 def StructPcdParser(self): @@ -1735,10 +1796,12 @@ class DecParser(MetaFileParser): return =20 if self._include_flag: - self._ValueList[1] =3D "_" + md5(self._Curren= tLine.encode('utf-8')).hexdigest() + self._ValueList[1] =3D "_" + \ + md5(self._CurrentLine.encode('utf-8')).hexdigest() self._ValueList[2] =3D self._CurrentLine if self._package_flag and "}" !=3D self._CurrentLine: - self._ValueList[1] =3D "_" + md5(self._CurrentLi= ne.encode('utf-8')).hexdigest() + self._ValueList[1] =3D "_" + \ + md5(self._CurrentLine.encode('utf-8')).hexdigest() self._ValueList[2] =3D self._CurrentLine if self._CurrentLine =3D=3D "}": self._package_flag =3D False @@ -1759,12 +1822,12 @@ class DecParser(MetaFileParser): else: if self._CurrentStructurePcdName !=3D TAB_SPLIT.join(PcdNa= mes[:2]): EdkLogger.error('Parser', FORMAT_INVALID, "Pcd Name do= es not match: %s and %s " % ( - self._CurrentStructurePcdName, TAB_SPLIT.join(PcdNames= [:2])), - File=3Dself.MetaFile, Line=3Dself._Lin= eIndex + 1) + self._CurrentStructurePcdName, TAB_SPLIT.join(PcdN= ames[:2])), + File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) self._ValueList[1] =3D TAB_SPLIT.join(PcdNames[2:]) self._ValueList[2] =3D PcdTockens[1] =20 - ## PCD sections parser + # PCD sections parser # # [PcdsFixedAtBuild] # [PcdsPatchableInModule] @@ -1782,52 +1845,50 @@ class DecParser(MetaFileParser): # check PCD information if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID= or PCD name specified", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # check PCD datum information if len(TokenList) < 2 or TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum inform= ation given", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) =20 - - ValueRe =3D re.compile(r'^\s*L?\".*\|.*\"') + ValueRe =3D re.compile(r'^\s*L?\".*\|.*\"') PtrValue =3D ValueRe.findall(TokenList[1]) =20 # Has VOID* type string, may contain "|" character in the string. if len(PtrValue) !=3D 0: ptrValueList =3D re.sub(ValueRe, '', TokenList[1]) - ValueList =3D GetSplitValueList(ptrValueList) + ValueList =3D GetSplitValueList(ptrValueList) ValueList[0] =3D PtrValue[0] else: ValueList =3D GetSplitValueList(TokenList[1]) =20 - # check if there's enough datum information given if len(ValueList) !=3D 3: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Datum i= nformation given", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # check default value if ValueList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing DefaultValu= e in PCD Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # check datum type if ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumType i= n PCD Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # check token of the PCD if ValueList[2] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token in PC= D Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|= ||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineIndex+1) # check format of default value against the datum type IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) @@ -1835,7 +1896,8 @@ class DecParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, Cause, ExtraData=3Ds= elf._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex+1) if Cause =3D=3D "StructurePcd": - self._CurrentStructurePcdName =3D TAB_SPLIT.join(self._ValueLi= st[0:2]) + self._CurrentStructurePcdName =3D TAB_SPLIT.join( + self._ValueList[0:2]) self._ValueList[0] =3D self._CurrentStructurePcdName self._ValueList[1] =3D ValueList[1].strip() =20 @@ -1848,7 +1910,8 @@ class DecParser(MetaFileParser): # check @ValidRange, @ValidList and @Expression format valid ErrorCodeValid =3D '0x0 <=3D %s <=3D 0xFFFFFFFF' PatternValidRangeIn =3D '(NOT)?\s*(\d+\s*-\s*\d+|0[xX][a-fA-F0= -9]+\s*-\s*0[xX][a-fA-F0-9]+|LT\s*\d+|LT\s*0[xX][a-fA-F0-9]+|GT\s*\d+|GT\s*= 0[xX][a-fA-F0-9]+|LE\s*\d+|LE\s*0[xX][a-fA-F0-9]+|GE\s*\d+|GE\s*0[xX][a-fA-= F0-9]+|XOR\s*\d+|XOR\s*0[xX][a-fA-F0-9]+|EQ\s*\d+|EQ\s*0[xX][a-fA-F0-9]+)' - PatternValidRng =3D re.compile('^' + '(NOT)?\s*' + PatternVali= dRangeIn + '$') + PatternValidRng =3D re.compile( + '^' + '(NOT)?\s*' + PatternValidRangeIn + '$') for Comment in self._Comments: Comm =3D Comment[0].strip() if not Comm: @@ -1871,11 +1934,14 @@ class DecParser(MetaFileParser): ErrorCode, Expression =3D ErrorCode.strip(), Expre= ssion.strip() try: if not eval(ErrorCodeValid % ErrorCode): - EdkLogger.warn('Parser', '@ValidRange Erro= rCode(%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@ValidRange ErrorCode(%s) o= f PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) except: - EdkLogger.warn('Parser', '@ValidRange ErrorCod= e(%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@ValidRange ErrorCode(%s) of PC= D %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) if not PatternValidRng.search(Expression): - EdkLogger.warn('Parser', '@ValidRange Expressi= on(%s) of PCD %s is incorrect format.' % (Expression, TokenList[0])) + EdkLogger.warn( + 'Parser', '@ValidRange Expression(%s) of P= CD %s is incorrect format.' % (Expression, TokenList[0])) if ValidFormt[0:10] =3D=3D '@ValidList': ValidFormt =3D ValidFormt[10:] ValidFormt =3D ValidFormt.lstrip() @@ -1887,16 +1953,19 @@ class DecParser(MetaFileParser): ErrorCode, Expression =3D ErrorCode.strip(), Expre= ssion.strip() try: if not eval(ErrorCodeValid % ErrorCode): - EdkLogger.warn('Parser', '@ValidList Error= Code(%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@ValidList ErrorCode(%s) of= PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) except: - EdkLogger.warn('Parser', '@ValidList ErrorCode= (%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@ValidList ErrorCode(%s) of PCD= %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) Values =3D Expression.split(',') for Value in Values: Value =3D Value.strip() try: eval(Value) except: - EdkLogger.warn('Parser', '@ValidList Expre= ssion of PCD %s include a invalid value(%s).' % (TokenList[0], Value)) + EdkLogger.warn( + 'Parser', '@ValidList Expression of PC= D %s include a invalid value(%s).' % (TokenList[0], Value)) break if ValidFormt[0:11] =3D=3D '@Expression': ValidFormt =3D ValidFormt[11:] @@ -1909,15 +1978,20 @@ class DecParser(MetaFileParser): ErrorCode, Expression =3D ErrorCode.strip(), Expre= ssion.strip() try: if not eval(ErrorCodeValid % ErrorCode): - EdkLogger.warn('Parser', '@Expression Erro= rCode(%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@Expression ErrorCode(%s) o= f PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) except: - EdkLogger.warn('Parser', '@Expression ErrorCod= e(%s) of PCD %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) + EdkLogger.warn( + 'Parser', '@Expression ErrorCode(%s) of PC= D %s is not valid UINT32 value.' % (ErrorCode, TokenList[0])) if not Expression: - EdkLogger.warn('Parser', '@Expression Expressi= on of PCD %s is incorrect format.' % TokenList[0]) + EdkLogger.warn( + 'Parser', '@Expression Expression of PCD %= s is incorrect format.' % TokenList[0]) if not Description: - EdkLogger.warn('Parser', 'PCD %s Description information i= s not provided.' % TokenList[0]) + EdkLogger.warn( + 'Parser', 'PCD %s Description information is not provi= ded.' % TokenList[0]) if not Prompt: - EdkLogger.warn('Parser', 'PCD %s Prompt information is not= provided.' % TokenList[0]) + EdkLogger.warn( + 'Parser', 'PCD %s Prompt information is not provided.'= % TokenList[0]) # check Description, Prompt localization information if self._UniObj: self._UniObj.CheckPcdInfo(TokenList[0]) @@ -1927,26 +2001,27 @@ class DecParser(MetaFileParser): elif ValueList[0] in ['False', 'false', 'FALSE']: ValueList[0] =3D '0' =20 - self._ValueList[2] =3D ValueList[0].strip() + '|' + ValueList[1].s= trip() + '|' + ValueList[2].strip() + self._ValueList[2] =3D ValueList[0].strip( + ) + '|' + ValueList[1].strip() + '|' + ValueList[2].strip() =20 _SectionParser =3D { - MODEL_META_DATA_HEADER : MetaFileParser._DefineParser, - MODEL_EFI_INCLUDE : MetaFileParser._PathParser, - MODEL_EFI_LIBRARY_CLASS : MetaFileParser._PathParser, - MODEL_EFI_GUID : _GuidParser, - MODEL_EFI_PPI : _GuidParser, - MODEL_EFI_PROTOCOL : _GuidParser, - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC : _PcdParser, - MODEL_PCD_DYNAMIC_EX : _PcdParser, - MODEL_UNKNOWN : MetaFileParser._Skip, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser._Skip, + MODEL_META_DATA_HEADER: MetaFileParser._DefineParser, + MODEL_EFI_INCLUDE: MetaFileParser._PathParser, + MODEL_EFI_LIBRARY_CLASS: MetaFileParser._PathParser, + MODEL_EFI_GUID: _GuidParser, + MODEL_EFI_PPI: _GuidParser, + MODEL_EFI_PROTOCOL: _GuidParser, + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC: _PcdParser, + MODEL_PCD_DYNAMIC_EX: _PcdParser, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._Skip, } =20 =20 -## Fdf +# Fdf # # This class defined the structure used in Fdf object # @@ -1954,7 +2029,7 @@ class DecParser(MetaFileParser): # @param WorkspaceDir: Input value for current workspace directory, defau= lt is None # class Fdf(object): - def __init__(self, Filename =3D None, IsToDatabase =3D False, Workspac= eDir =3D None, Database =3D None): + def __init__(self, Filename=3DNone, IsToDatabase=3DFalse, WorkspaceDir= =3DNone, Database=3DNone): self.WorkspaceDir =3D WorkspaceDir self.IsToDatabase =3D IsToDatabase =20 @@ -1985,13 +2060,13 @@ class Fdf(object): =20 return self.FileList[Filename] =20 - - ## Load Fdf file + # Load Fdf file # # Load the file if it exists # # @param Filename: Input value for filename of Fdf file # + def LoadFdfFile(self, Filename): FileList =3D [] # @@ -2006,7 +2081,7 @@ class Fdf(object): # if self.IsToDatabase: (Model, Value1, Value2, Value3, Scope1, Scope2, BelongsToItem,= BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled) =3D \ - (0, '', '', '', 'COMMON', 'COMMON', -1, -1, -1, -1, -1, -1, 0) + (0, '', '', '', 'COMMON', 'COMMON', -1, -1, -1, -1, -1, -1= , 0) for Index in range(0, len(Fdf.Profile.PcdDict)): pass for Key in Fdf.Profile.PcdDict.keys(): @@ -2016,7 +2091,8 @@ class Fdf(object): FileName =3D Fdf.Profile.PcdFileLineDict[Key][0] StartLine =3D Fdf.Profile.PcdFileLineDict[Key][1] BelongsToFile =3D self.InsertFile(FileName) - self.TblFdf.Insert(Model, Value1, Value2, Value3, Scope1, = Scope2, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndC= olumn, Enabled) + self.TblFdf.Insert(Model, Value1, Value2, Value3, Scope1, = Scope2, BelongsToItem, + BelongsToFile, StartLine, StartColumn, = EndLine, EndColumn, Enabled) for Index in range(0, len(Fdf.Profile.InfList)): Model =3D MODEL_META_DATA_COMPONENT Value1 =3D Fdf.Profile.InfList[Index] @@ -2024,7 +2100,9 @@ class Fdf(object): FileName =3D Fdf.Profile.InfFileLineList[Index][0] StartLine =3D Fdf.Profile.InfFileLineList[Index][1] BelongsToFile =3D self.InsertFile(FileName) - self.TblFdf.Insert(Model, Value1, Value2, Value3, Scope1, = Scope2, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndC= olumn, Enabled) + self.TblFdf.Insert(Model, Value1, Value2, Value3, Scope1, = Scope2, BelongsToItem, + BelongsToFile, StartLine, StartColumn, = EndLine, EndColumn, Enabled) + =20 class UniParser(object): # IsExtraUni defined the UNI file is Module UNI or extra Module UNI @@ -2040,11 +2118,14 @@ class UniParser(object): =20 def __read(self): try: - self.FileIn =3D CodecOpenLongFilePath(self.FilePath, Mode=3D'r= b', Encoding=3D'utf_8').read() + self.FileIn =3D CodecOpenLongFilePath( + self.FilePath, Mode=3D'rb', Encoding=3D'utf_8').read() except UnicodeError: - self.FileIn =3D CodecOpenLongFilePath(self.FilePath, Mode=3D'r= b', Encoding=3D'utf_16').read() + self.FileIn =3D CodecOpenLongFilePath( + self.FilePath, Mode=3D'rb', Encoding=3D'utf_16').read() except UnicodeError: - self.FileIn =3D CodecOpenLongFilePath(self.FilePath, Mode=3D'r= b', Encoding=3D'utf_16_le').read() + self.FileIn =3D CodecOpenLongFilePath( + self.FilePath, Mode=3D'rb', Encoding=3D'utf_16_le').read() except IOError: self.FileIn =3D "" =20 @@ -2056,7 +2137,8 @@ class UniParser(object): else: ModuleAbstract =3D self.CheckKeyValid('STR_MODULE_ABSTRACT= ') self.PrintLog('STR_MODULE_ABSTRACT', ModuleAbstract) - ModuleDescription =3D self.CheckKeyValid('STR_MODULE_DESCR= IPTION') + ModuleDescription =3D self.CheckKeyValid( + 'STR_MODULE_DESCRIPTION') self.PrintLog('STR_MODULE_DESCRIPTION', ModuleDescription) else: if self.IsExtraUni: @@ -2065,13 +2147,15 @@ class UniParser(object): else: PackageAbstract =3D self.CheckKeyValid('STR_PACKAGE_ABSTRA= CT') self.PrintLog('STR_PACKAGE_ABSTRACT', PackageAbstract) - PackageDescription =3D self.CheckKeyValid('STR_PACKAGE_DES= CRIPTION') + PackageDescription =3D self.CheckKeyValid( + 'STR_PACKAGE_DESCRIPTION') self.PrintLog('STR_PACKAGE_DESCRIPTION', PackageDescriptio= n) =20 def CheckKeyValid(self, Key, Contents=3DNone): if not Contents: Contents =3D self.FileIn - KeyPattern =3D re.compile('#string\s+%s\s+.*?#language.*?".*?"' % = Key, re.S) + KeyPattern =3D re.compile( + '#string\s+%s\s+.*?#language.*?".*?"' % Key, re.S) if KeyPattern.search(Contents): return True return False @@ -2088,9 +2172,11 @@ class UniParser(object): if not Value and Key not in self.Missing: Msg =3D '%s is missing in the %s file.' % (Key, self.FileName) EdkLogger.warn('Parser', Msg) - EccGlobalData.gDb.TblReport.Insert(EccToolError.ERROR_GENERAL_= CHECK_UNI_HELP_INFO, OtherMsg=3DMsg, BelongsToTable=3D'File', BelongsToItem= =3D-2) + EccGlobalData.gDb.TblReport.Insert( + EccToolError.ERROR_GENERAL_CHECK_UNI_HELP_INFO, OtherMsg= =3DMsg, BelongsToTable=3D'File', BelongsToItem=3D-2) self.Missing.append(Key) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -2098,4 +2184,3 @@ class UniParser(object): # if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py= b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py index 0914aec460f5..9f7f8b5fc7c7 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase a meta file table # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -17,11 +17,12 @@ import Ecc.EccGlobalData as EccGlobalData from Ecc.MetaFileWorkspace.MetaDataTable import Table from Ecc.MetaFileWorkspace.MetaDataTable import ConvertToSqlString from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODE= L_FILE_INF, \ - MODEL_FILE_OTHERS + MODEL_FILE_OTHERS + =20 class MetaFileTable(Table): - ## Constructor - def __init__(self, Cursor, MetaFile, FileType, TableName, Temporary = =3D False): + # Constructor + def __init__(self, Cursor, MetaFile, FileType, TableName, Temporary=3D= False): self.MetaFile =3D MetaFile self.TblFile =3D EccGlobalData.gDb.TblFile if (FileType =3D=3D MODEL_FILE_INF): @@ -38,7 +39,7 @@ class MetaFileTable(Table): self.Create(False) =20 =20 -## Python class representation of table storing module data +# Python class representation of table storing module data class ModuleTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -60,11 +61,11 @@ class ModuleTable(MetaFileTable): # used as table end flag, in case the changes to database is not commi= tted to db file _DUMMY_ =3D "-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1" =20 - ## Constructor + # Constructor def __init__(self, Cursor): MetaFileTable.__init__(self, Cursor, '', MODEL_FILE_INF, "Inf", Fa= lse) =20 - ## Insert a record into table Inf + # Insert a record into table Inf # # @param Model: Model of a Inf item # @param Value1: Value1 of a Inf item @@ -80,27 +81,28 @@ class ModuleTable(MetaFileTable): # @param Enabled: If this item enabled # def Insert(self, Model, Value1, Value2, Value3, Scope1=3D'COMMON', Sco= pe2=3D'COMMON', - BelongsToItem=3D-1, BelongsToFile =3D -1, StartLine=3D-1, S= tartColumn=3D-1, EndLine=3D-1, EndColumn=3D-1, Enabled=3D0, Usage=3D''): - (Value1, Value2, Value3, Usage, Scope1, Scope2) =3D ConvertToSqlSt= ring((Value1, Value2, Value3, Usage, Scope1, Scope2)) + BelongsToItem=3D-1, BelongsToFile=3D-1, StartLine=3D-1, Sta= rtColumn=3D-1, EndLine=3D-1, EndColumn=3D-1, Enabled=3D0, Usage=3D''): + (Value1, Value2, Value3, Usage, Scope1, Scope2) =3D ConvertToSqlSt= ring( + (Value1, Value2, Value3, Usage, Scope1, Scope2)) return Table.Insert( - self, - Model, - Value1, - Value2, - Value3, - Usage, - Scope1, - Scope2, - BelongsToItem, - BelongsToFile, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ) + self, + Model, + Value1, + Value2, + Value3, + Usage, + Scope1, + Scope2, + BelongsToItem, + BelongsToFile, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ) =20 - ## Query table + # Query table # # @param Model: The Model of Record # @param Arch: The Arch attribute of Record @@ -117,10 +119,13 @@ class ModuleTable(MetaFileTable): if Platform is not None and Platform !=3D 'COMMON': ConditionString +=3D " AND (Scope2=3D'%s' OR Scope2=3D'COMMON'= OR Scope2=3D'DEFAULT')" % Platform =20 - SqlCommand =3D "SELECT %s FROM %s WHERE %s" % (ValueString, self.T= able, ConditionString) + SqlCommand =3D "SELECT %s FROM %s WHERE %s" % ( + ValueString, self.Table, ConditionString) return self.Exec(SqlCommand) =20 -## Python class representation of table storing package data +# Python class representation of table storing package data + + class PackageTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -141,11 +146,11 @@ class PackageTable(MetaFileTable): # used as table end flag, in case the changes to database is not commi= tted to db file _DUMMY_ =3D "-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1" =20 - ## Constructor + # Constructor def __init__(self, Cursor): MetaFileTable.__init__(self, Cursor, '', MODEL_FILE_DEC, "Dec", Fa= lse) =20 - ## Insert table + # Insert table # # Insert a record into table Dec # @@ -163,26 +168,27 @@ class PackageTable(MetaFileTable): # @param Enabled: If this item enabled # def Insert(self, Model, Value1, Value2, Value3, Scope1=3D'COMMON', Sco= pe2=3D'COMMON', - BelongsToItem=3D-1, BelongsToFile =3D -1, StartLine=3D-1, S= tartColumn=3D-1, EndLine=3D-1, EndColumn=3D-1, Enabled=3D0): - (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString((V= alue1, Value2, Value3, Scope1, Scope2)) + BelongsToItem=3D-1, BelongsToFile=3D-1, StartLine=3D-1, Sta= rtColumn=3D-1, EndLine=3D-1, EndColumn=3D-1, Enabled=3D0): + (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString( + (Value1, Value2, Value3, Scope1, Scope2)) return Table.Insert( - self, - Model, - Value1, - Value2, - Value3, - Scope1, - Scope2, - BelongsToItem, - BelongsToFile, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ) + self, + Model, + Value1, + Value2, + Value3, + Scope1, + Scope2, + BelongsToItem, + BelongsToFile, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ) =20 - ## Query table + # Query table # # @param Model: The Model of Record # @param Arch: The Arch attribute of Record @@ -196,10 +202,13 @@ class PackageTable(MetaFileTable): if Arch is not None and Arch !=3D 'COMMON': ConditionString +=3D " AND (Scope1=3D'%s' OR Scope1=3D'COMMON'= )" % Arch =20 - SqlCommand =3D "SELECT %s FROM %s WHERE %s" % (ValueString, self.T= able, ConditionString) + SqlCommand =3D "SELECT %s FROM %s WHERE %s" % ( + ValueString, self.Table, ConditionString) return self.Exec(SqlCommand) =20 -## Python class representation of table storing platform data +# Python class representation of table storing platform data + + class PlatformTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -221,11 +230,12 @@ class PlatformTable(MetaFileTable): # used as table end flag, in case the changes to database is not commi= tted to db file _DUMMY_ =3D "-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1, -1" =20 - ## Constructor - def __init__(self, Cursor, MetaFile =3D '', FileType =3D MODEL_FILE_DS= C, Temporary =3D False): - MetaFileTable.__init__(self, Cursor, MetaFile, FileType, "Dsc", Te= mporary) + # Constructor + def __init__(self, Cursor, MetaFile=3D'', FileType=3DMODEL_FILE_DSC, T= emporary=3DFalse): + MetaFileTable.__init__(self, Cursor, MetaFile, + FileType, "Dsc", Temporary) =20 - ## Insert table + # Insert table # # Insert a record into table Dsc # @@ -243,28 +253,29 @@ class PlatformTable(MetaFileTable): # @param EndColumn: EndColumn of a Dsc item # @param Enabled: If this item enabled # - def Insert(self, Model, Value1, Value2, Value3, Scope1=3D'COMMON', Sco= pe2=3D'COMMON', BelongsToItem=3D-1, BelongsToFile =3D -1, + def Insert(self, Model, Value1, Value2, Value3, Scope1=3D'COMMON', Sco= pe2=3D'COMMON', BelongsToItem=3D-1, BelongsToFile=3D-1, FromItem=3D-1, StartLine=3D-1, StartColumn=3D-1, EndLine=3D= -1, EndColumn=3D-1, Enabled=3D1): - (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString((V= alue1, Value2, Value3, Scope1, Scope2)) + (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString( + (Value1, Value2, Value3, Scope1, Scope2)) return Table.Insert( - self, - Model, - Value1, - Value2, - Value3, - Scope1, - Scope2, - BelongsToItem, - BelongsToFile, - FromItem, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ) + self, + Model, + Value1, + Value2, + Value3, + Scope1, + Scope2, + BelongsToItem, + BelongsToFile, + FromItem, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ) =20 - ## Query table + # Query table # # @param Model: The Model of Record # @param Scope1: Arch of a Dsc item @@ -291,25 +302,28 @@ class PlatformTable(MetaFileTable): if FromItem is not None: ConditionString +=3D " AND FromItem=3D%s" % FromItem =20 - SqlCommand =3D "SELECT %s FROM %s WHERE %s" % (ValueString, self.T= able, ConditionString) + SqlCommand =3D "SELECT %s FROM %s WHERE %s" % ( + ValueString, self.Table, ConditionString) return self.Exec(SqlCommand) =20 -## Factory class to produce different storage for different type of meta-f= ile +# Factory class to produce different storage for different type of meta-fi= le + + class MetaFileStorage(object): _FILE_TABLE_ =3D { - MODEL_FILE_INF : ModuleTable, - MODEL_FILE_DEC : PackageTable, - MODEL_FILE_DSC : PlatformTable, - MODEL_FILE_OTHERS : MetaFileTable, + MODEL_FILE_INF: ModuleTable, + MODEL_FILE_DEC: PackageTable, + MODEL_FILE_DSC: PlatformTable, + MODEL_FILE_OTHERS: MetaFileTable, } =20 _FILE_TYPE_ =3D { - ".inf" : MODEL_FILE_INF, - ".dec" : MODEL_FILE_DEC, - ".dsc" : MODEL_FILE_DSC, + ".inf": MODEL_FILE_INF, + ".dec": MODEL_FILE_DEC, + ".dsc": MODEL_FILE_DSC, } =20 - ## Constructor + # Constructor def __new__(Class, Cursor, MetaFile, FileType=3DNone, Temporary=3DFals= e): # no type given, try to find one if not FileType: @@ -326,4 +340,3 @@ class MetaFileStorage(object): =20 # create the storage object and return it to caller return Class._FILE_TABLE_[FileType](*Args) - diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py b/Ba= seTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py index 85ae9937c43f..400adb76a0aa 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Workspace' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Ecc/ParserWarning.py b/BaseTools/Sourc= e/Python/Ecc/ParserWarning.py index 2ae66d48487e..bf192b9a593c 100644 --- a/BaseTools/Source/Python/Ecc/ParserWarning.py +++ b/BaseTools/Source/Python/Ecc/ParserWarning.py @@ -1,23 +1,23 @@ -## @file +# @file # This file is used to be the warning class of ECC tool # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## The exception class that used to report error messages when preprocessi= ng +# The exception class that used to report error messages when preprocessing # # Currently the "ToolName" is set to be "ECC PP". # class Warning (Exception): - ## The constructor + # The constructor # # @param self The object pointer # @param Str The message to record # @param File The FDF name # @param Line The Line number that error occurs # - def __init__(self, Str, File =3D None, Line =3D None): + def __init__(self, Str, File=3DNone, Line=3DNone): self.message =3D Str self.FileName =3D File self.LineNumber =3D Line diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py b/BaseTools/Sou= rce/Python/Ecc/Xml/XmlRoutines.py index b02f663b15a5..123cf66f7303 100644 --- a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py +++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py @@ -1,4 +1,4 @@ -## @file +# @file # This is an XML API that uses a syntax similar to XPath, but it is writte= n in # standard python so that no extra python packages are required to use it. # @@ -14,7 +14,7 @@ import xml.dom.minidom import codecs from Common.LongFilePathSupport import OpenLongFilePath as open =20 -## Create a element of XML +# Create a element of XML # # @param Name # @param String @@ -23,6 +23,8 @@ from Common.LongFilePathSupport import OpenLongFilePath a= s open # # @revel Element # + + def CreateXmlElement(Name, String, NodeList, AttributeList): Doc =3D xml.dom.minidom.Document() Element =3D Doc.createElement(Name) @@ -47,7 +49,7 @@ def CreateXmlElement(Name, String, NodeList, AttributeLis= t): =20 return Element =20 -## Get a list of XML nodes using XPath style syntax. +# Get a list of XML nodes using XPath style syntax. # # Return a list of XML DOM nodes from the root Dom specified by XPath Stri= ng. # If the input Dom or String is not valid, then an empty list is returned. @@ -57,6 +59,8 @@ def CreateXmlElement(Name, String, NodeList, AttributeLis= t): # # @revel Nodes A list of XML nodes matching XPath style Stin= g. # + + def XmlList(Dom, String): if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": return [] @@ -83,7 +87,7 @@ def XmlList(Dom, String): return Nodes =20 =20 -## Get a single XML node using XPath style syntax. +# Get a single XML node using XPath style syntax. # # Return a single XML DOM node from the root Dom specified by XPath String. # If the input Dom or String is not valid, then an empty string is returne= d. @@ -94,7 +98,7 @@ def XmlList(Dom, String): # @revel Node A single XML node matching XPath style Sting. # def XmlNode(Dom, String): - if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": + if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": return "" if Dom.nodeType =3D=3D Dom.DOCUMENT_NODE: Dom =3D Dom.documentElement @@ -116,7 +120,7 @@ def XmlNode(Dom, String): return "" =20 =20 -## Get a single XML element using XPath style syntax. +# Get a single XML element using XPath style syntax. # # Return a single XML element from the root Dom specified by XPath String. # If the input Dom or String is not valid, then an empty string is returne= d. @@ -133,7 +137,7 @@ def XmlElement(Dom, String): return "" =20 =20 -## Get a single XML element of the current node. +# Get a single XML element of the current node. # # Return a single XML element specified by the current root Dom. # If the input Dom is not valid, then an empty string is returned. @@ -149,7 +153,7 @@ def XmlElementData(Dom): return "" =20 =20 -## Get a list of XML elements using XPath style syntax. +# Get a list of XML elements using XPath style syntax. # # Return a list of XML elements from the root Dom specified by XPath Strin= g. # If the input Dom or String is not valid, then an empty list is returned. @@ -163,7 +167,7 @@ def XmlElementList(Dom, String): return map(XmlElementData, XmlList(Dom, String)) =20 =20 -## Get the XML attribute of the current node. +# Get the XML attribute of the current node. # # Return a single XML attribute named Attribute from the current root Dom. # If the input Dom or Attribute is not valid, then an empty string is retu= rned. @@ -180,7 +184,7 @@ def XmlAttribute(Dom, Attribute): return '' =20 =20 -## Get the XML node name of the current node. +# Get the XML node name of the current node. # # Return a single XML node name from the current root Dom. # If the input Dom is not valid, then an empty string is returned. @@ -195,7 +199,7 @@ def XmlNodeName(Dom): except: return '' =20 -## Parse an XML file. +# Parse an XML file. # # Parse the input XML file named FileName and return a XML DOM it stands f= or. # If the input File is not a valid XML file, then an empty string is retur= ned. @@ -204,9 +208,11 @@ def XmlNodeName(Dom): # # @revel Dom The Dom object achieved from the XML file. # + + def XmlParseFile(FileName): try: - XmlFile =3D codecs.open(FileName,encoding=3D'utf_8_sig') + XmlFile =3D codecs.open(FileName, encoding=3D'utf_8_sig') Dom =3D xml.dom.minidom.parse(XmlFile) XmlFile.close() return Dom @@ -214,12 +220,15 @@ def XmlParseFile(FileName): print(X) return "" =20 + # This acts like the main() function for the script, unless it is 'import'= ed # into another script. if __name__ =3D=3D '__main__': # Nothing to do here. Could do some unit tests. - A =3D CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']]= , [['A', '1'], ['B', '2']]) - B =3D CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']]= , [['A', '1'], ['B', '2']]) + A =3D CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']]= , [ + ['A', '1'], ['B', '2']]) + B =3D CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']]= , [ + ['A', '1'], ['B', '2']]) C =3D CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG']) - print(C.toprettyxml(indent =3D " ")) + print(C.toprettyxml(indent=3D" ")) pass diff --git a/BaseTools/Source/Python/Ecc/Xml/__init__.py b/BaseTools/Source= /Python/Ecc/Xml/__init__.py index 172e498451b8..03dedeed636e 100644 --- a/BaseTools/Source/Python/Ecc/Xml/__init__.py +++ b/BaseTools/Source/Python/Ecc/Xml/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Ecc/__init__.py b/BaseTools/Source/Pyt= hon/Ecc/__init__.py index a1cac674d619..a8fa5404c7bb 100644 --- a/BaseTools/Source/Python/Ecc/__init__.py +++ b/BaseTools/Source/Python/Ecc/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Ecc' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc= /c.py index 61ad084fcc5b..e569cd3b408c 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to be the c coding style checking of ECC tool # # Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
        @@ -28,30 +28,38 @@ ComplexTypeDict =3D {} SUDict =3D {} IgnoredKeywordList =3D ['EFI_ERROR'] =20 + def GetIgnoredDirListPattern(): skipList =3D list(EccGlobalData.gConfig.SkipDirList) + ['.svn'] DirString =3D '|'.join(skipList) p =3D re.compile(r'.*[\\/](?:%s)[\\/]?.*' % DirString) return p =20 + def GetFuncDeclPattern(): - p =3D re.compile(r'(?:EFIAPI|EFI_BOOT_SERVICE|EFI_RUNTIME_SERVICE)?\s*= [_\w]+\s*\(.*\)$', re.DOTALL) + p =3D re.compile( + r'(?:EFIAPI|EFI_BOOT_SERVICE|EFI_RUNTIME_SERVICE)?\s*[_\w]+\s*\(.*= \)$', re.DOTALL) return p =20 + def GetArrayPattern(): p =3D re.compile(r'[_\w]*\s*[\[.*\]]+') return p =20 + def GetTypedefFuncPointerPattern(): p =3D re.compile('[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOT= ALL) return p =20 + def GetDB(): return EccGlobalData.gDb =20 + def GetConfig(): return EccGlobalData.gConfig =20 + def PrintErrorMsg(ErrorType, Msg, TableName, ItemId): Msg =3D Msg.replace('\n', '').replace('\r', '') MsgPartList =3D Msg.split() @@ -59,7 +67,9 @@ def PrintErrorMsg(ErrorType, Msg, TableName, ItemId): for Part in MsgPartList: Msg +=3D Part Msg +=3D ' ' - GetDB().TblReport.Insert(ErrorType, OtherMsg=3DMsg, BelongsToTable=3DT= ableName, BelongsToItem=3DItemId) + GetDB().TblReport.Insert(ErrorType, OtherMsg=3DMsg, + BelongsToTable=3DTableName, BelongsToItem=3DI= temId) + =20 def GetIdType(Str): Type =3D DataClass.MODEL_UNKNOWN @@ -83,25 +93,30 @@ def GetIdType(Str): Type =3D DataClass.MODEL_UNKNOWN return Type =20 -def SuOccurInTypedef (Su, TdList): + +def SuOccurInTypedef(Su, TdList): for Td in TdList: if Su.StartPos[0] =3D=3D Td.StartPos[0] and Su.EndPos[0] =3D=3D Td= .EndPos[0]: return True return False =20 + def GetIdentifierList(): IdList =3D [] for comment in FileProfile.CommentList: - IdComment =3D DataClass.IdentifierClass(-1, '', '', '', comment.Co= ntent, DataClass.MODEL_IDENTIFIER_COMMENT, -1, -1, comment.StartPos[0], com= ment.StartPos[1], comment.EndPos[0], comment.EndPos[1]) + IdComment =3D DataClass.IdentifierClass(-1, '', '', '', comment.Co= ntent, DataClass.MODEL_IDENTIFIER_COMMENT, - + 1, -1, comment.StartPos[0], = comment.StartPos[1], comment.EndPos[0], comment.EndPos[1]) IdList.append(IdComment) =20 for pp in FileProfile.PPDirectiveList: Type =3D GetIdType(pp.Content) - IdPP =3D DataClass.IdentifierClass(-1, '', '', '', pp.Content, Typ= e, -1, -1, pp.StartPos[0], pp.StartPos[1], pp.EndPos[0], pp.EndPos[1]) + IdPP =3D DataClass.IdentifierClass(-1, '', '', '', pp.Content, Typ= e, - + 1, -1, pp.StartPos[0], pp.StartPo= s[1], pp.EndPos[0], pp.EndPos[1]) IdList.append(IdPP) =20 for pe in FileProfile.PredicateExpressionList: - IdPE =3D DataClass.IdentifierClass(-1, '', '', '', pe.Content, Dat= aClass.MODEL_IDENTIFIER_PREDICATE_EXPRESSION, -1, -1, pe.StartPos[0], pe.St= artPos[1], pe.EndPos[0], pe.EndPos[1]) + IdPE =3D DataClass.IdentifierClass(-1, '', '', '', pe.Content, Dat= aClass.MODEL_IDENTIFIER_PREDICATE_EXPRESSION, - + 1, -1, pe.StartPos[0], pe.StartPo= s[1], pe.EndPos[0], pe.EndPos[1]) IdList.append(IdPE) =20 FuncDeclPattern =3D GetFuncDeclPattern() @@ -177,7 +192,8 @@ def GetIdentifierList(): Index +=3D 1 VarNameStartColumn +=3D 1 PreChar =3D FirstChar - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', var.= Declarator, FuncName, DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, -1, = -1, var.StartPos[0], var.StartPos[1], VarNameStartLine, VarNameStartColumn) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', var.= Declarator, FuncName, DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, - + 1, -1, var.StartPos[0], var.= StartPos[1], VarNameStartLine, VarNameStartColumn) IdList.append(IdVar) continue =20 @@ -190,7 +206,8 @@ def GetIdentifierList(): var.Modifier +=3D ' ' + Name[LSBPos:] Name =3D Name[0:LSBPos] =20 - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', = Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDEN= TIFIER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], VarNameStartLine= , VarNameStartColumn) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', = Name, (len(DeclList) > 1 and [DeclList[1]] or [''])[ + 0], DataClass.MODEL_IDEN= TIFIER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], VarNameStartLine= , VarNameStartColumn) IdList.append(IdVar) else: DeclList =3D var.Declarator.split('=3D') @@ -199,7 +216,8 @@ def GetIdentifierList(): LSBPos =3D var.Declarator.find('[') var.Modifier +=3D ' ' + Name[LSBPos:] Name =3D Name[0:LSBPos] - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', Name= , (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFI= ER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], VarNameStartLine, Va= rNameStartColumn) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', Name= , (len(DeclList) > 1 and [DeclList[1]] or [''])[ + 0], DataClass.MODEL_IDENTIFI= ER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], VarNameStartLine, Va= rNameStartColumn) IdList.append(IdVar) =20 for enum in FileProfile.EnumerationDefinitionList: @@ -207,7 +225,8 @@ def GetIdentifierList(): RBPos =3D enum.Content.find('}') Name =3D enum.Content[4:LBPos].strip() Value =3D enum.Content[LBPos + 1:RBPos] - IdEnum =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Data= Class.MODEL_IDENTIFIER_ENUMERATE, -1, -1, enum.StartPos[0], enum.StartPos[1= ], enum.EndPos[0], enum.EndPos[1]) + IdEnum =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Data= Class.MODEL_IDENTIFIER_ENUMERATE, - + 1, -1, enum.StartPos[0], enum.S= tartPos[1], enum.EndPos[0], enum.EndPos[1]) IdList.append(IdEnum) =20 for su in FileProfile.StructUnionDefinitionList: @@ -226,7 +245,8 @@ def GetIdentifierList(): else: Name =3D su.Content[SkipLen:LBPos].strip() Value =3D su.Content[LBPos:RBPos + 1] - IdPE =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Type, = -1, -1, su.StartPos[0], su.StartPos[1], su.EndPos[0], su.EndPos[1]) + IdPE =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Type, - + 1, -1, su.StartPos[0], su.StartPo= s[1], su.EndPos[0], su.EndPos[1]) IdList.append(IdPE) =20 TdFuncPointerPattern =3D GetTypedefFuncPointerPattern() @@ -242,7 +262,7 @@ def GetIdentifierList(): if StarPos !=3D -1: Modifier +=3D ' ' + TmpStr[0:StarPos] while TmpStr[StarPos] =3D=3D '*': -# Modifier +=3D ' ' + '*' + # Modifier +=3D ' ' + '*' StarPos +=3D 1 TmpStr =3D TmpStr[StarPos:].strip() RBPos =3D TmpStr.find(')') @@ -256,17 +276,20 @@ def GetIdentifierList(): if Name.find('[') !=3D -1: LBPos =3D Name.find('[') RBPos =3D Name.rfind(']') - Value +=3D Name[LBPos : RBPos + 1] - Name =3D Name[0 : LBPos] + Value +=3D Name[LBPos: RBPos + 1] + Name =3D Name[0: LBPos] =20 - IdTd =3D DataClass.IdentifierClass(-1, Modifier, '', Name, Value, = DataClass.MODEL_IDENTIFIER_TYPEDEF, -1, -1, td.StartPos[0], td.StartPos[1],= td.EndPos[0], td.EndPos[1]) + IdTd =3D DataClass.IdentifierClass(-1, Modifier, '', Name, Value, = DataClass.MODEL_IDENTIFIER_TYPEDEF, - + 1, -1, td.StartPos[0], td.StartPo= s[1], td.EndPos[0], td.EndPos[1]) IdList.append(IdTd) =20 for funcCall in FileProfile.FunctionCallingList: - IdFC =3D DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, = funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, -1, -1, fu= ncCall.StartPos[0], funcCall.StartPos[1], funcCall.EndPos[0], funcCall.EndP= os[1]) + IdFC =3D DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, = funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, - + 1, -1, funcCall.StartPos[0], func= Call.StartPos[1], funcCall.EndPos[0], funcCall.EndPos[1]) IdList.append(IdFC) return IdList =20 + def StripNonAlnumChars(Str): StrippedStr =3D '' for Char in Str: @@ -274,12 +297,13 @@ def StripNonAlnumChars(Str): StrippedStr +=3D Char return StrippedStr =20 + def GetParamList(FuncDeclarator, FuncNameLine=3D0, FuncNameOffset=3D0): FuncDeclarator =3D StripComments(FuncDeclarator) ParamIdList =3D [] #DeclSplitList =3D FuncDeclarator.split('(') LBPos =3D FuncDeclarator.find('(') - #if len(DeclSplitList) < 2: + # if len(DeclSplitList) < 2: if LBPos =3D=3D -1: return ParamIdList #FuncName =3D DeclSplitList[0] @@ -309,7 +333,7 @@ def GetParamList(FuncDeclarator, FuncNameLine=3D0, Func= NameOffset=3D0): FuncName =3D FuncName[:-1] TailChar =3D FuncName[-1] =20 - OffsetSkipped +=3D 1 #skip '(' + OffsetSkipped +=3D 1 # skip '(' =20 for p in ParamStr.split(','): ListP =3D p.split() @@ -396,13 +420,15 @@ def GetParamList(FuncDeclarator, FuncNameLine=3D0, Fu= ncNameOffset=3D0): ParamEndOffset =3D FuncNameOffset + OffsetSkipped if ParamName !=3D '...': ParamName =3D StripNonAlnumChars(ParamName) - IdParam =3D DataClass.IdentifierClass(-1, ParamModifier, '', Param= Name, '', DataClass.MODEL_IDENTIFIER_PARAMETER, -1, -1, ParamBeginLine, Par= amBeginOffset, ParamEndLine, ParamEndOffset) + IdParam =3D DataClass.IdentifierClass(-1, ParamModifier, '', Param= Name, '', DataClass.MODEL_IDENTIFIER_PARAMETER, - + 1, -1, ParamBeginLine, ParamBe= ginOffset, ParamEndLine, ParamEndOffset) ParamIdList.append(IdParam) =20 - OffsetSkipped +=3D 1 #skip ',' + OffsetSkipped +=3D 1 # skip ',' =20 return ParamIdList =20 + def GetFunctionList(): FuncObjList =3D [] for FuncDef in FileProfile.FunctionDefinitionList: @@ -476,11 +502,13 @@ def GetFunctionList(): FuncNameStartColumn +=3D 1 PreChar =3D FirstChar =20 - FuncObj =3D DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDe= f.Modifier, FuncName.strip(), '', FuncDef.StartPos[0], FuncDef.StartPos[1],= FuncDef.EndPos[0], FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.Lef= tBracePos[1], -1, ParamIdList, [], FuncNameStartLine, FuncNameStartColumn) + FuncObj =3D DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDe= f.Modifier, FuncName.strip( + ), '', FuncDef.StartPos[0], FuncDef.StartPos[1], FuncDef.EndPos[0]= , FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.LeftBracePos[1], -1, = ParamIdList, [], FuncNameStartLine, FuncNameStartColumn) FuncObjList.append(FuncObj) =20 return FuncObjList =20 + def GetFileModificationTimeFromDB(FullFileName): TimeValue =3D 0.0 Db =3D GetDB() @@ -493,6 +521,7 @@ def GetFileModificationTimeFromDB(FullFileName): TimeValue =3D Result[0] return TimeValue =20 + def CollectSourceCodeDataIntoDB(RootDir): FileObjList =3D [] tuple =3D os.walk(RootDir) @@ -522,8 +551,10 @@ def CollectSourceCodeDataIntoDB(RootDir): model =3D DataClass.MODEL_FILE_OTHERS if os.path.splitext(f)[1] in ('.h', '.c'): EdkLogger.info("Parsing " + FullName) - model =3D f.endswith('c') and DataClass.MODEL_FILE_C or Da= taClass.MODEL_FILE_H - collector =3D CodeFragmentCollector.CodeFragmentCollector(= FullName) + model =3D f.endswith( + 'c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FIL= E_H + collector =3D CodeFragmentCollector.CodeFragmentCollector( + FullName) collector.TokenReleaceList =3D TokenReleaceList try: collector.ParseFile() @@ -536,13 +567,15 @@ def CollectSourceCodeDataIntoDB(RootDir): DirName =3D os.path.dirname(FullName) Ext =3D os.path.splitext(f)[1].lstrip('.') ModifiedTime =3D os.path.getmtime(FullName) - FileObj =3D DataClass.FileClass(-1, BaseName, Ext, DirName, Fu= llName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), []) + FileObj =3D DataClass.FileClass(-1, BaseName, Ext, DirName, Fu= llName, + model, ModifiedTime, GetFunction= List(), GetIdentifierList(), []) FileObjList.append(FileObj) if collector: collector.CleanFileProfileBuffer() =20 if len(ParseErrorFileList) > 0: - EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n"= % "\n\t".join(ParseErrorFileList)) + EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n"= % + "\n\t".join(ParseErrorFileList)) =20 Db =3D GetDB() for file in FileObjList: @@ -551,6 +584,7 @@ def CollectSourceCodeDataIntoDB(RootDir): =20 Db.UpdateIdentifierBelongsToFunction() =20 + def GetTableID(FullFileName, ErrorMsgList=3DNone): if ErrorMsgList is None: ErrorMsgList =3D [] @@ -565,14 +599,17 @@ def GetTableID(FullFileName, ErrorMsgList=3DNone): FileID =3D -1 for Result in ResultSet: if FileID !=3D -1: - ErrorMsgList.append('Duplicate file ID found in DB for file %s= ' % FullFileName) + ErrorMsgList.append( + 'Duplicate file ID found in DB for file %s' % FullFileName) return - 2 FileID =3D Result[0] if FileID =3D=3D -1: - ErrorMsgList.append('NO file ID found in DB for file %s' % FullFil= eName) + ErrorMsgList.append( + 'NO file ID found in DB for file %s' % FullFileName) return - 1 return FileID =20 + def GetIncludeFileList(FullFileName): if os.path.splitext(FullFileName)[1].upper() not in ('.H'): return [] @@ -594,6 +631,7 @@ def GetIncludeFileList(FullFileName): IncludeFileListDict[FullFileName] =3D ResultSet return ResultSet =20 + def GetFullPathOfIncludeFile(Str, IncludePathList): for IncludePath in IncludePathList: FullPath =3D os.path.join(IncludePath, Str) @@ -602,6 +640,7 @@ def GetFullPathOfIncludeFile(Str, IncludePathList): return FullPath return None =20 + def GetAllIncludeFiles(FullFileName): if AllIncludeFileListDict.get(FullFileName) is not None: return AllIncludeFileListDict.get(FullFileName) @@ -609,7 +648,8 @@ def GetAllIncludeFiles(FullFileName): FileDirName =3D os.path.dirname(FullFileName) IncludePathList =3D IncludePathListDict.get(FileDirName) if IncludePathList is None: - IncludePathList =3D MetaDataParser.GetIncludeListOfFile(EccGlobalD= ata.gWorkspace, FullFileName, GetDB()) + IncludePathList =3D MetaDataParser.GetIncludeListOfFile( + EccGlobalData.gWorkspace, FullFileName, GetDB()) if FileDirName not in IncludePathList: IncludePathList.insert(0, FileDirName) IncludePathListDict[FileDirName] =3D IncludePathList @@ -638,6 +678,7 @@ def GetAllIncludeFiles(FullFileName): AllIncludeFileListDict[FullFileName] =3D IncludeFileQueue return IncludeFileQueue =20 + def GetPredicateListFromPredicateExpStr(PES): =20 PredicateList =3D [] @@ -674,6 +715,7 @@ def GetPredicateListFromPredicateExpStr(PES): PredicateList.append(Exp.rstrip(';').rstrip(')').strip()) return PredicateList =20 + def GetCNameList(Lvalue, StarList=3D[]): Lvalue +=3D ' ' i =3D 0 @@ -700,7 +742,6 @@ def GetCNameList(Lvalue, StarList=3D[]): if VarEnd =3D=3D -1: break =20 - DotIndex =3D Lvalue[VarEnd:].find('.') ArrowIndex =3D Lvalue[VarEnd:].find('->') if DotIndex =3D=3D -1 and ArrowIndex =3D=3D -1: @@ -710,7 +751,8 @@ def GetCNameList(Lvalue, StarList=3D[]): elif ArrowIndex =3D=3D -1 and DotIndex !=3D -1: SearchBegin =3D VarEnd + DotIndex else: - SearchBegin =3D VarEnd + ((DotIndex < ArrowIndex) and DotIndex= or ArrowIndex) + SearchBegin =3D VarEnd + \ + ((DotIndex < ArrowIndex) and DotIndex or ArrowIndex) =20 i =3D SearchBegin VarStart =3D -1 @@ -718,6 +760,7 @@ def GetCNameList(Lvalue, StarList=3D[]): =20 return VarList =20 + def SplitPredicateByOp(Str, Op, IsFuncCalling=3DFalse): =20 Name =3D Str.strip() @@ -780,6 +823,7 @@ def SplitPredicateByOp(Str, Op, IsFuncCalling=3DFalse): =20 TmpStr =3D Str[0:Index - 1] =20 + def SplitPredicateStr(Str): =20 Str =3D Str.lstrip('(') @@ -815,12 +859,14 @@ def SplitPredicateStr(Str): =20 return [[Str, None], None] =20 + def GetFuncContainsPE(ExpLine, ResultSet): for Result in ResultSet: if Result[0] < ExpLine and Result[1] > ExpLine: return Result return None =20 + def PatternInModifier(Modifier, SubStr): PartList =3D Modifier.split() for Part in PartList: @@ -828,6 +874,7 @@ def PatternInModifier(Modifier, SubStr): return True return False =20 + def GetDataTypeFromModifier(ModifierStr): MList =3D ModifierStr.split() ReturnType =3D '' @@ -844,6 +891,7 @@ def GetDataTypeFromModifier(ModifierStr): ReturnType =3D 'VOID' return ReturnType =20 + def DiffModifier(Str1, Str2): PartList1 =3D Str1.split() PartList2 =3D Str2.split() @@ -852,6 +900,7 @@ def DiffModifier(Str1, Str2): else: return True =20 + def GetTypedefDict(FullFileName): =20 Dict =3D ComplexTypeDict.get(FullFileName) @@ -897,6 +946,7 @@ def GetTypedefDict(FullFileName): ComplexTypeDict[FullFileName] =3D Dict return Dict =20 + def GetSUDict(FullFileName): =20 Dict =3D SUDict.get(FullFileName) @@ -937,6 +987,7 @@ def GetSUDict(FullFileName): SUDict[FullFileName] =3D Dict return Dict =20 + def StripComments(Str): Str +=3D ' ' ListFromStr =3D list(Str) @@ -983,6 +1034,7 @@ def StripComments(Str): =20 return Str =20 + def GetFinalTypeValue(Type, FieldName, TypedefDict, SUDict): Value =3D TypedefDict.get(Type) if Value is None: @@ -1019,22 +1071,24 @@ def GetFinalTypeValue(Type, FieldName, TypedefDict,= SUDict): Type =3D GetDataTypeFromModifier(Field[0:Index]) return Type.strip() else: - # For the condition that the field in struct is an array with = [] suffixes... + # For the condition that the field in struct is an array w= ith [] suffixes... if not Field[Index + len(FieldName)].isalnum(): Type =3D GetDataTypeFromModifier(Field[0:Index]) return Type.strip() =20 return None =20 + def GetRealType(Type, TypedefDict, TargetType=3DNone): if TargetType is not None and Type =3D=3D TargetType: - return Type + return Type while TypedefDict.get(Type): Type =3D TypedefDict.get(Type) if TargetType is not None and Type =3D=3D TargetType: return Type return Type =20 + def GetTypeInfo(RefList, Modifier, FullFileName, TargetType=3DNone): TypedefDict =3D GetTypedefDict(FullFileName) SUDict =3D GetSUDict(FullFileName) @@ -1063,6 +1117,7 @@ def GetTypeInfo(RefList, Modifier, FullFileName, Targ= etType=3DNone): =20 return Type =20 + def GetVarInfo(PredVarList, FuncRecord, FullFileName, IsFuncCall=3DFalse, = TargetType=3DNone, StarList=3DNone): =20 PredVar =3D PredVarList[0] @@ -1147,10 +1202,11 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileNam= e, IsFuncCall=3DFalse, TargetTy VarFound =3D False for Result in ResultSet: if len(PredVarList) > 1: - Type =3D GetTypeInfo(PredVarList[1:], Result[0], FullFileName,= TargetType) + Type =3D GetTypeInfo( + PredVarList[1:], Result[0], FullFileName, TargetType) return Type else: -# Type =3D GetDataTypeFromModifier(Result[0]).split()[-1] + # Type =3D GetDataTypeFromModifier(Result[0]).split= ()[-1] TypeList =3D GetDataTypeFromModifier(Result[0]).split() Type =3D TypeList[-1] if len(TypeList) > 1 and StarList is not None: @@ -1169,7 +1225,8 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall=3DFalse, TargetTy for Param in ParamList: if Param.Name.strip() =3D=3D PredVar: if len(PredVarList) > 1: - Type =3D GetTypeInfo(PredVarList[1:], Param.Modifier, Full= FileName, TargetType) + Type =3D GetTypeInfo( + PredVarList[1:], Param.Modifier, FullFileName, TargetT= ype) return Type else: TypeList =3D GetDataTypeFromModifier(Param.Modifier).split= () @@ -1196,7 +1253,8 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall=3DFalse, TargetTy =20 for Result in ResultSet: if len(PredVarList) > 1: - Type =3D GetTypeInfo(PredVarList[1:], Result[0], FullFileName,= TargetType) + Type =3D GetTypeInfo( + PredVarList[1:], Result[0], FullFileName, TargetType) return Type else: TypeList =3D GetDataTypeFromModifier(Result[0]).split() @@ -1227,7 +1285,8 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall=3DFalse, TargetTy =20 for Result in ResultSet: if len(PredVarList) > 1: - Type =3D GetTypeInfo(PredVarList[1:], Result[0], FullFileN= ame, TargetType) + Type =3D GetTypeInfo( + PredVarList[1:], Result[0], FullFileName, TargetType) return Type else: TypeList =3D GetDataTypeFromModifier(Result[0]).split() @@ -1243,6 +1302,7 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall=3DFalse, TargetTy Type =3D GetRealType(Type, TypedefDict, TargetType) return Type =20 + def GetTypeFromArray(Type, Var): Count =3D Var.count('[') =20 @@ -1253,6 +1313,7 @@ def GetTypeFromArray(Type, Var): =20 return Type =20 + def CheckFuncLayoutReturnType(FullFileName): ErrorMsgList =3D [] =20 @@ -1278,10 +1339,12 @@ def CheckFuncLayoutReturnType(FullFileName): Result0 =3D Result0[6:].strip() Index =3D Result0.find(TypeStart) if Index !=3D 0 or Result[3] !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s]= Return Type should appear at the start of line' % FuncName, FileTable, Res= ult[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, + '[%s] Return Type should appear at the start of = line' % FuncName, FileTable, Result[1]) =20 if Result[2] =3D=3D Result[4]: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s]= Return Type should appear on its own line' % FuncName, FileTable, Result[1= ]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, + '[%s] Return Type should appear on its own line'= % FuncName, FileTable, Result[1]) =20 SqlStatement =3D """ select Modifier, ID, StartLine, StartColumn, FunN= ameStartLine, Name from Function @@ -1299,7 +1362,9 @@ def CheckFuncLayoutReturnType(FullFileName): Result0 =3D Result0[6:].strip() Index =3D Result0.find(TypeStart) if Index !=3D 0 or Result[3] !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '[%s]= Return Type should appear at the start of line' % FuncName, 'Function', Re= sult[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, + '[%s] Return Type should appear at the start of = line' % FuncName, 'Function', Result[1]) + =20 def CheckFuncLayoutModifier(FullFileName): ErrorMsgList =3D [] @@ -1323,7 +1388,8 @@ def CheckFuncLayoutModifier(FullFileName): Result0 =3D Result0[6:].strip() Index =3D Result0.find(TypeStart) if Index !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONA= L_MODIFIER, '', FileTable, Result[1]) + PrintErrorMsg( + ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER= , '', FileTable, Result[1]) =20 SqlStatement =3D """ select Modifier, ID from Function @@ -1338,7 +1404,9 @@ def CheckFuncLayoutModifier(FullFileName): Result0 =3D Result0[6:].strip() Index =3D Result0.find(TypeStart) if Index !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONA= L_MODIFIER, '', 'Function', Result[1]) + PrintErrorMsg( + ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER= , '', 'Function', Result[1]) + =20 def CheckFuncLayoutName(FullFileName): ErrorMsgList =3D [] @@ -1361,22 +1429,27 @@ def CheckFuncLayoutName(FullFileName): if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CH= ECK_FUNCTION_NAME, FuncName): continue if Result[2] !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Fu= nction name [%s] should appear at the start of a line' % FuncName, FileTabl= e, Result[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Function name [%s] should appear at the start o= f a line' % FuncName, FileTable, Result[1]) ParamList =3D GetParamList(Result[0]) if len(ParamList) =3D=3D 0: continue StartLine =3D 0 for Param in ParamList: if Param.StartLine <=3D StartLine: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME,= 'Parameter %s should be in its own line.' % Param.Name, FileTable, Result[= 1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Parameter %s should be in its own line.' % = Param.Name, FileTable, Result[1]) if Param.StartLine - StartLine > 1: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME,= 'Empty line appears before Parameter %s.' % Param.Name, FileTable, Result[= 1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Empty line appears before Parameter %s.' % = Param.Name, FileTable, Result[1]) if not Pattern.match(Param.Name) and not Param.Name in ParamIg= noreList and not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTI= ON_CHECK_VARIABLE_NAME, Param.Name): - PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME,= 'Parameter [%s] NOT follow naming convention.' % Param.Name, FileTable, Re= sult[1]) + PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, + 'Parameter [%s] NOT follow naming convention= .' % Param.Name, FileTable, Result[1]) StartLine =3D Param.StartLine =20 if not Result[0].endswith('\n )') and not Result[0].endswith('\r = )'): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, '\'= )\' should be on a new line and indented two spaces', FileTable, Result[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + '\')\' should be on a new line and indented two = spaces', FileTable, Result[1]) =20 SqlStatement =3D """ select Modifier, ID, FunNameStartColumn, Name from Function @@ -1388,21 +1461,27 @@ def CheckFuncLayoutName(FullFileName): if EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CH= ECK_FUNCTION_NAME, FuncName): continue if Result[2] !=3D 0: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, 'Fu= nction name [%s] should appear at the start of a line' % FuncName, 'Functio= n', Result[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Function name [%s] should appear at the start o= f a line' % FuncName, 'Function', Result[1]) ParamList =3D GetParamList(Result[0]) if len(ParamList) =3D=3D 0: continue StartLine =3D 0 for Param in ParamList: if Param.StartLine <=3D StartLine: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME,= 'Parameter %s should be in its own line.' % Param.Name, 'Function', Result= [1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Parameter %s should be in its own line.' % = Param.Name, 'Function', Result[1]) if Param.StartLine - StartLine > 1: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME,= 'Empty line appears before Parameter %s.' % Param.Name, 'Function', Result= [1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + 'Empty line appears before Parameter %s.' % = Param.Name, 'Function', Result[1]) if not Pattern.match(Param.Name) and not Param.Name in ParamIg= noreList and not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTI= ON_CHECK_VARIABLE_NAME, Param.Name): - PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME,= 'Parameter [%s] NOT follow naming convention.' % Param.Name, FileTable, Re= sult[1]) + PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, + 'Parameter [%s] NOT follow naming convention= .' % Param.Name, FileTable, Result[1]) StartLine =3D Param.StartLine if not Result[0].endswith('\n )') and not Result[0].endswith('\r = )'): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, '\'= )\' should be on a new line and indented two spaces', 'Function', Result[1]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME, + '\')\' should be on a new line and indented two = spaces', 'Function', Result[1]) + =20 def CheckFuncLayoutPrototype(FullFileName): ErrorMsgList =3D [] @@ -1445,17 +1524,20 @@ def CheckFuncLayoutPrototype(FullFileName): DeclModifier =3D FuncDecl[0] if DeclName =3D=3D FuncName: if DiffModifier(FuncModifier, DeclModifier) and not EccGlo= balData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO= _TYPE, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE, 'Function [%s] modifier different with prototype.' % FuncName, '= Function', FuncDef[3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE, + 'Function [%s] modifier different with p= rototype.' % FuncName, 'Function', FuncDef[3]) ParamListOfDef =3D GetParamList(FuncDefHeader) ParamListOfDecl =3D GetParamList(FuncDecl[1]) if len(ParamListOfDef) !=3D len(ParamListOfDecl) and not E= ccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_= PROTO_TYPE_2, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE_2, 'Parameter number different in function [%s].' % FuncName, 'Fu= nction', FuncDef[3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE_2, + 'Parameter number different in function = [%s].' % FuncName, 'Function', FuncDef[3]) break =20 Index =3D 0 while Index < len(ParamListOfDef): if DiffModifier(ParamListOfDef[Index].Modifier, ParamL= istOfDecl[Index].Modifier) and not EccGlobalData.gException.IsException(ERR= OR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTI= ON_PROTO_TYPE_3, 'Parameter %s has different modifier with prototype in fun= ction [%s].' % (ParamListOfDef[Index].Name, FuncName), 'Function', FuncDef[= 3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTI= ON_PROTO_TYPE_3, 'Parameter %s has different modifier with prototype in fun= ction [%s].' % ( + ParamListOfDef[Index].Name, FuncName), 'Functi= on', FuncDef[3]) Index +=3D 1 break else: @@ -1488,20 +1570,24 @@ def CheckFuncLayoutPrototype(FullFileName): DeclModifier =3D FuncDecl[0] if DeclName =3D=3D FuncName: if DiffModifier(FuncModifier, DeclModifier) and not EccGlo= balData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO= _TYPE, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE, 'Function [%s] modifier different with prototype.' % FuncName, '= Function', FuncDef[3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE, + 'Function [%s] modifier different with p= rototype.' % FuncName, 'Function', FuncDef[3]) ParamListOfDef =3D GetParamList(FuncDefHeader) ParamListOfDecl =3D GetParamList(FuncDecl[1]) if len(ParamListOfDef) !=3D len(ParamListOfDecl) and not E= ccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_= PROTO_TYPE_2, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE_2, 'Parameter number different in function [%s].' % FuncName, 'Fu= nction', FuncDef[3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_P= ROTO_TYPE_2, + 'Parameter number different in function = [%s].' % FuncName, 'Function', FuncDef[3]) break =20 Index =3D 0 while Index < len(ParamListOfDef): if DiffModifier(ParamListOfDef[Index].Modifier, ParamL= istOfDecl[Index].Modifier) and not EccGlobalData.gException.IsException(ERR= OR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3, FuncName): - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTI= ON_PROTO_TYPE_3, 'Parameter %s has different modifier with prototype in fun= ction [%s].' % (ParamListOfDef[Index].Name, FuncName), 'Function', FuncDef[= 3]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTI= ON_PROTO_TYPE_3, 'Parameter %s has different modifier with prototype in fun= ction [%s].' % ( + ParamListOfDef[Index].Name, FuncName), 'Functi= on', FuncDef[3]) Index +=3D 1 break =20 + def CheckFuncLayoutBody(FullFileName): ErrorMsgList =3D [] =20 @@ -1522,14 +1608,17 @@ def CheckFuncLayoutBody(FullFileName): if Result[0] !=3D 0: if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_L= AYOUT_CHECK_FUNCTION_BODY, Result[3]): PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, - 'The open brace should be at the very beginn= ing of a line for the function [%s].' % Result[3], + 'The open brace should be at the very beginn= ing of a line for the function [%s].' % Result[ + 3], 'Function', Result[2]) if Result[1] !=3D 0: if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_L= AYOUT_CHECK_FUNCTION_BODY, Result[3]): PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, - 'The close brace should be at the very begin= ning of a line for the function [%s].' % Result[3], + 'The close brace should be at the very begin= ning of a line for the function [%s].' % Result[ + 3], 'Function', Result[2]) =20 + def CheckFuncLayoutLocalVariable(FullFileName): ErrorMsgList =3D [] =20 @@ -1561,7 +1650,9 @@ def CheckFuncLayoutLocalVariable(FullFileName): =20 for Result in ResultSet: if len(Result[1]) > 0 and 'CONST' not in Result[3] and 'STATIC= ' not in Result[3]: - PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VAR= IABLE, 'Variable Name: %s' % Result[0], FileTable, Result[2]) + PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VAR= IABLE, + 'Variable Name: %s' % Result[0], FileTable, = Result[2]) + =20 def CheckMemberVariableFormat(Name, Value, FileTable, TdId, ModelId): ErrMsgList =3D [] @@ -1573,25 +1664,28 @@ def CheckMemberVariableFormat(Name, Value, FileTabl= e, TdId, ModelId): if LBPos =3D=3D -1 or RBPos =3D=3D -1: return ErrMsgList =20 - Fields =3D Value[LBPos + 1 : RBPos] + Fields =3D Value[LBPos + 1: RBPos] Fields =3D StripComments(Fields).strip() - NestPos =3D Fields.find ('struct') + NestPos =3D Fields.find('struct') if NestPos !=3D -1 and (NestPos + len('struct') < len(Fields)) and Mod= elId !=3D DataClass.MODEL_IDENTIFIER_UNION: if not Fields[NestPos + len('struct') + 1].isalnum(): if not EccGlobalData.gException.IsException(ERROR_DECLARATION_= DATA_TYPE_CHECK_NESTED_STRUCTURE, Name): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, 'Nested struct in [%s].' % (Name), FileTable, TdId) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, + 'Nested struct in [%s].' % (Name), FileTable= , TdId) return ErrMsgList - NestPos =3D Fields.find ('union') + NestPos =3D Fields.find('union') if NestPos !=3D -1 and (NestPos + len('union') < len(Fields)): if not Fields[NestPos + len('union') + 1].isalnum(): if not EccGlobalData.gException.IsException(ERROR_DECLARATION_= DATA_TYPE_CHECK_NESTED_STRUCTURE, Name): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, 'Nested union in [%s].' % (Name), FileTable, TdId) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, + 'Nested union in [%s].' % (Name), FileTable,= TdId) return ErrMsgList - NestPos =3D Fields.find ('enum') + NestPos =3D Fields.find('enum') if NestPos !=3D -1 and (NestPos + len('enum') < len(Fields)): if not Fields[NestPos + len('enum') + 1].isalnum(): if not EccGlobalData.gException.IsException(ERROR_DECLARATION_= DATA_TYPE_CHECK_NESTED_STRUCTURE, Name): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, 'Nested enum in [%s].' % (Name), FileTable, TdId) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STR= UCTURE, + 'Nested enum in [%s].' % (Name), FileTable, = TdId) return ErrMsgList =20 if ModelId =3D=3D DataClass.MODEL_IDENTIFIER_ENUMERATE: @@ -1655,6 +1749,7 @@ def CheckMemberVariableFormat(Name, Value, FileTable,= TdId, ModelId): =20 return ErrMsgList =20 + def CheckDeclTypedefFormat(FullFileName, ModelId): ErrorMsgList =3D [] =20 @@ -1705,11 +1800,13 @@ def CheckDeclTypedefFormat(FullFileName, ModelId): if ValueModelId !=3D ModelId: continue # Check member variable format. - ErrMsgList =3D CheckMemberVariableFormat(Name, Value, FileTable, T= d[5], ModelId) + ErrMsgList =3D CheckMemberVariableFormat( + Name, Value, FileTable, Td[5], ModelId) for ErrMsg in ErrMsgList: if EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTIO= N_CHECK_VARIABLE_NAME, Name + '.' + ErrMsg): continue - PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, 'Me= mber variable [%s] NOT follow naming convention.' % (Name + '.' + ErrMsg), = FileTable, Td[5]) + PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, 'Me= mber variable [%s] NOT follow naming convention.' % ( + Name + '.' + ErrMsg), FileTable, Td[5]) =20 # First check in current file to see whether struct/union/enum is type= def-ed. UntypedefedList =3D [] @@ -1728,11 +1825,13 @@ def CheckDeclTypedefFormat(FullFileName, ModelId): =20 if ValueModelId !=3D ModelId: continue - ErrMsgList =3D CheckMemberVariableFormat(Name, Value, FileTable, R= esult[3], ModelId) + ErrMsgList =3D CheckMemberVariableFormat( + Name, Value, FileTable, Result[3], ModelId) for ErrMsg in ErrMsgList: if EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTIO= N_CHECK_VARIABLE_NAME, Result[0] + '.' + ErrMsg): continue - PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, 'Me= mber variable [%s] NOT follow naming convention.' % (Result[0] + '.' + ErrM= sg), FileTable, Result[3]) + PrintErrorMsg(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, 'Me= mber variable [%s] NOT follow naming convention.' % ( + Result[0] + '.' + ErrMsg), FileTable, Result[3]) # Check whether it is typedefed. Found =3D False for Td in TdList: @@ -1742,11 +1841,13 @@ def CheckDeclTypedefFormat(FullFileName, ModelId): if Result[1] >=3D Td[3] and Td[4] >=3D Result[2]: Found =3D True if not Td[1].isupper(): - PrintErrorMsg(ErrorType, 'Typedef should be UPPER case= ', FileTable, Td[5]) + PrintErrorMsg( + ErrorType, 'Typedef should be UPPER case', FileTab= le, Td[5]) if Result[0] in Td[2].split(): Found =3D True if not Td[1].isupper(): - PrintErrorMsg(ErrorType, 'Typedef should be UPPER case= ', FileTable, Td[5]) + PrintErrorMsg( + ErrorType, 'Typedef should be UPPER case', FileTab= le, Td[5]) if Found: break =20 @@ -1783,27 +1884,34 @@ def CheckDeclTypedefFormat(FullFileName, ModelId): if Result[1] >=3D Td[3] and Td[4] >=3D Result[2]: Found =3D True if not Td[1].isupper(): - PrintErrorMsg(ErrorType, 'Typedef should be UPPER case= ', FileTable, Td[5]) + PrintErrorMsg( + ErrorType, 'Typedef should be UPPER case', FileTab= le, Td[5]) if Result[0] in Td[2].split(): Found =3D True if not Td[1].isupper(): - PrintErrorMsg(ErrorType, 'Typedef should be UPPER case= ', FileTable, Td[5]) + PrintErrorMsg( + ErrorType, 'Typedef should be UPPER case', FileTab= le, Td[5]) if Found: break =20 if not Found: - PrintErrorMsg(ErrorType, 'No Typedef for %s' % Result[0], File= Table, Result[3]) + PrintErrorMsg(ErrorType, 'No Typedef for %s' % + Result[0], FileTable, Result[3]) continue =20 + def CheckDeclStructTypedef(FullFileName): CheckDeclTypedefFormat(FullFileName, DataClass.MODEL_IDENTIFIER_STRUCT= URE) =20 + def CheckDeclEnumTypedef(FullFileName): CheckDeclTypedefFormat(FullFileName, DataClass.MODEL_IDENTIFIER_ENUMER= ATE) =20 + def CheckDeclUnionTypedef(FullFileName): CheckDeclTypedefFormat(FullFileName, DataClass.MODEL_IDENTIFIER_UNION) =20 + def CheckDeclArgModifier(FullFileName): ErrorMsgList =3D [] =20 @@ -1823,7 +1931,8 @@ def CheckDeclArgModifier(FullFileName): for Result in ResultSet: for Modifier in ModifierTuple: if PatternInModifier(Result[0], Modifier) and len(Result[0]) <= MAX_MODIFIER_LENGTH: - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, 'Variable Modifier %s' % Result[0], FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, + 'Variable Modifier %s' % Result[0], FileTabl= e, Result[2]) break =20 SqlStatement =3D """ select Modifier, Name, ID @@ -1834,7 +1943,8 @@ def CheckDeclArgModifier(FullFileName): for Result in ResultSet: for Modifier in ModifierTuple: if PatternInModifier(Result[0], Modifier): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, 'Return Type Modifier %s' % Result[0], FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, + 'Return Type Modifier %s' % Result[0], FileT= able, Result[2]) break =20 SqlStatement =3D """ select Modifier, Header, ID @@ -1845,9 +1955,11 @@ def CheckDeclArgModifier(FullFileName): for Result in ResultSet: for Modifier in ModifierTuple: if PatternInModifier(Result[0], Modifier): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, 'Return Type Modifier %s' % Result[0], FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MOD= IFIER, + 'Return Type Modifier %s' % Result[0], FileT= able, Result[2]) break =20 + def CheckDeclNoUseCType(FullFileName): ErrorMsgList =3D [] =20 @@ -1870,7 +1982,8 @@ def CheckDeclNoUseCType(FullFileName): Result[0] + ' ' + = Result[1]): continue PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_T= YPE, - 'Invalid variable type (%s) in definition [%= s]' % (Type, Result[0] + ' ' + Result[1]), + 'Invalid variable type (%s) in definition [%= s]' % ( + Type, Result[0] + ' ' + Result[1]), FileTable, Result[2]) break @@ -1887,11 +2000,13 @@ def CheckDeclNoUseCType(FullFileName): continue for Type in CTypeTuple: if PatternInModifier(Result[0], Type): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_T= YPE, '%s Return type %s' % (FuncName, Result[0]), FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_T= YPE, '%s Return type %s' % ( + FuncName, Result[0]), FileTable, Result[2]) =20 for Param in ParamList: if PatternInModifier(Param.Modifier, Type): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE= _C_TYPE, 'Parameter %s' % Param.Name, FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE= _C_TYPE, + 'Parameter %s' % Param.Name, FileTable, = Result[2]) =20 SqlStatement =3D """ select Modifier, Header, ID, Name from Function @@ -1905,11 +2020,13 @@ def CheckDeclNoUseCType(FullFileName): continue for Type in CTypeTuple: if PatternInModifier(Result[0], Type): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_T= YPE, '[%s] Return type %s' % (FuncName, Result[0]), FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_T= YPE, '[%s] Return type %s' % ( + FuncName, Result[0]), FileTable, Result[2]) =20 for Param in ParamList: if PatternInModifier(Param.Modifier, Type): - PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE= _C_TYPE, 'Parameter %s' % Param.Name, FileTable, Result[2]) + PrintErrorMsg(ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE= _C_TYPE, + 'Parameter %s' % Param.Name, FileTable, = Result[2]) =20 =20 def CheckPointerNullComparison(FullFileName): @@ -1976,20 +2093,24 @@ def CheckPointerNullComparison(FullFileName): Type =3D FuncReturnTypeDict.get(PredVarStr) if Type is not None: if Type.find('*') !=3D -1 and Type !=3D 'BOOLEAN*': - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _COMPARISON_NULL_TYPE, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _COMPARISON_NULL_TYPE, + 'Predicate Expression: %s' % Exp= , FileTable, Str[2]) continue =20 if PredVarStr in FuncReturnTypeDict: continue =20 - Type =3D GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall, None, StarList) + Type =3D GetVarInfo(PredVarList, FuncRecord, + FullFileName, IsFuncCall, None, StarList) if SearchInCache: FuncReturnTypeDict[PredVarStr] =3D Type if Type is None: continue Type =3D GetTypeFromArray(Type, PredVarStr) if Type.find('*') !=3D -1 and Type !=3D 'BOOLEAN*': - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_COMPARI= SON_NULL_TYPE, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_COMPARI= SON_NULL_TYPE, + 'Predicate Expression: %s' % Exp, FileTa= ble, Str[2]) + =20 def CheckNonBooleanValueComparison(FullFileName): ErrorMsgList =3D [] @@ -2056,18 +2177,21 @@ def CheckNonBooleanValueComparison(FullFileName): Type =3D FuncReturnTypeDict.get(PredVarStr) if Type is not None: if Type.find('BOOLEAN') =3D=3D -1: - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _NO_BOOLEAN_OPERATOR, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _NO_BOOLEAN_OPERATOR, + 'Predicate Expression: %s' % Exp= , FileTable, Str[2]) continue =20 if PredVarStr in FuncReturnTypeDict: continue - Type =3D GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall, 'BOOLEAN', StarList) + Type =3D GetVarInfo(PredVarList, FuncRecord, + FullFileName, IsFuncCall, 'BOOLEAN', Sta= rList) if SearchInCache: FuncReturnTypeDict[PredVarStr] =3D Type if Type is None: continue if Type.find('BOOLEAN') =3D=3D -1: - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_NO_BOOL= EAN_OPERATOR, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_NO_BOOL= EAN_OPERATOR, + 'Predicate Expression: %s' % Exp, FileTa= ble, Str[2]) =20 =20 def CheckBooleanValueComparison(FullFileName): @@ -2135,19 +2259,22 @@ def CheckBooleanValueComparison(FullFileName): Type =3D FuncReturnTypeDict.get(PredVarStr) if Type is not None: if Type.find('BOOLEAN') !=3D -1: - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _BOOLEAN_VALUE, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK= _BOOLEAN_VALUE, + 'Predicate Expression: %s' % Exp= , FileTable, Str[2]) continue =20 if PredVarStr in FuncReturnTypeDict: continue =20 - Type =3D GetVarInfo(PredVarList, FuncRecord, FullFileName,= IsFuncCall, 'BOOLEAN', StarList) + Type =3D GetVarInfo(PredVarList, FuncRecord, + FullFileName, IsFuncCall, 'BOOLEAN', Sta= rList) if SearchInCache: FuncReturnTypeDict[PredVarStr] =3D Type if Type is None: continue if Type.find('BOOLEAN') !=3D -1: - PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN= _VALUE, 'Predicate Expression: %s' % Exp, FileTable, Str[2]) + PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN= _VALUE, + 'Predicate Expression: %s' % Exp, FileTa= ble, Str[2]) =20 =20 def CheckHeaderFileData(FullFileName, AllTypedefFun=3D[]): @@ -2170,7 +2297,8 @@ def CheckHeaderFileData(FullFileName, AllTypedefFun= =3D[]): if '(%s)' % Result[1] in Item: break else: - PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, 'Variable def= inition appears in header file', FileTable, Result[0]) + PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, + 'Variable definition appears in header file'= , FileTable, Result[0]) =20 SqlStatement =3D """ select ID from Function @@ -2178,10 +2306,12 @@ def CheckHeaderFileData(FullFileName, AllTypedefFun= =3D[]): """ % FileID ResultSet =3D Db.TblFile.Exec(SqlStatement) for Result in ResultSet: - PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, 'Function definition = appears in header file', 'Function', Result[0]) + PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, + 'Function definition appears in header file', 'Funct= ion', Result[0]) =20 return ErrorMsgList =20 + def CheckHeaderFileIfndef(FullFileName): ErrorMsgList =3D [] =20 @@ -2197,7 +2327,8 @@ def CheckHeaderFileIfndef(FullFileName): """ % (FileTable, DataClass.MODEL_IDENTIFIER_MACRO_IFND= EF) ResultSet =3D Db.TblFile.Exec(SqlStatement) if len(ResultSet) =3D=3D 0: - PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1, '', 'Fi= le', FileID) + PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1, + '', 'File', FileID) return ErrorMsgList for Result in ResultSet: SqlStatement =3D """ select Value, EndLine @@ -2207,7 +2338,8 @@ def CheckHeaderFileIfndef(FullFileName): ResultSet =3D Db.TblFile.Exec(SqlStatement) for Result in ResultSet: if not Result[0].startswith('/*') and not Result[0].startswith= ('//'): - PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_2,= '', 'File', FileID) + PrintErrorMsg( + ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_2, '', 'File= ', FileID) break =20 SqlStatement =3D """ select Value @@ -2217,9 +2349,11 @@ def CheckHeaderFileIfndef(FullFileName): ResultSet =3D Db.TblFile.Exec(SqlStatement) for Result in ResultSet: if not Result[0].startswith('/*') and not Result[0].startswith('//= '): - PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_3, '',= 'File', FileID) + PrintErrorMsg( + ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_3, '', 'File', F= ileID) return ErrorMsgList =20 + def CheckDoxygenCommand(FullFileName): ErrorMsgList =3D [] =20 @@ -2241,9 +2375,11 @@ def CheckDoxygenCommand(FullFileName): CommentPartList =3D CommentStr.split() for Part in CommentPartList: if Part.upper() =3D=3D 'BUGBUG': - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, 'Bug should be = marked with doxygen tag @bug', FileTable, Result[1]) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, + 'Bug should be marked with doxygen tag @bug'= , FileTable, Result[1]) if Part.upper() =3D=3D 'TODO': - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, 'ToDo should be= marked with doxygen tag @todo', FileTable, Result[1]) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, + 'ToDo should be marked with doxygen tag @tod= o', FileTable, Result[1]) if Part.startswith('@'): if EccGlobalData.gException.IsException(ERROR_DOXYGEN_CHEC= K_COMMAND, Part): continue @@ -2253,14 +2389,17 @@ def CheckDoxygenCommand(FullFileName): continue if Part.lstrip('@').isalpha(): if Part.lstrip('@') not in DoxygenCommandList: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, 'Unknow= n doxygen command %s' % Part, FileTable, Result[1]) + PrintErrorMsg( + ERROR_DOXYGEN_CHECK_COMMAND, 'Unknown doxygen = command %s' % Part, FileTable, Result[1]) else: Index =3D Part.find('[') if Index =3D=3D -1: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, 'Unknow= n doxygen command %s' % Part, FileTable, Result[1]) + PrintErrorMsg( + ERROR_DOXYGEN_CHECK_COMMAND, 'Unknown doxygen = command %s' % Part, FileTable, Result[1]) RealCmd =3D Part[1:Index] if RealCmd not in DoxygenCommandList: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMAND, 'Unknow= n doxygen command %s' % Part, FileTable, Result[1]) + PrintErrorMsg( + ERROR_DOXYGEN_CHECK_COMMAND, 'Unknown doxygen = command %s' % Part, FileTable, Result[1]) =20 =20 def CheckDoxygenTripleForwardSlash(FullFileName): @@ -2284,7 +2423,6 @@ def CheckDoxygenTripleForwardSlash(FullFileName): for Result in ResultSet: FuncDefSet.append(Result) =20 - FileTable =3D 'Identifier' + str(FileID) SqlStatement =3D """ select Value, ID, StartLine, StartColumn, EndLine= , EndColumn from %s @@ -2299,7 +2437,6 @@ def CheckDoxygenTripleForwardSlash(FullFileName): except: print('Unrecognized chars in comment of file %s', FullFileName) =20 - for Result in CommentSet: CommentStr =3D Result[0] StartLine =3D Result[2] @@ -2324,7 +2461,8 @@ def CheckDoxygenTripleForwardSlash(FullFileName): Found =3D True break if Found: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_FORMAT, '', FileTabl= e, Result[1]) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_FORMAT, + '', FileTable, Result[1]) =20 =20 def CheckFileHeaderDoxygenComments(FullFileName): @@ -2342,7 +2480,8 @@ def CheckFileHeaderDoxygenComments(FullFileName): """ % (FileTable, DataClass.MODEL_IDENTIFIER_COMMENT) ResultSet =3D Db.TblFile.Exec(SqlStatement) if len(ResultSet) =3D=3D 0: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'No File License header app= ear at the very beginning of file.', 'File', FileID) + PrintErrorMsg(ERROR_HEADER_CHECK_FILE, + 'No File License header appear at the very beginning= of file.', 'File', FileID) return ErrorMsgList =20 NoHeaderCommentStartFlag =3D True @@ -2364,7 +2503,7 @@ def CheckFileHeaderDoxygenComments(FullFileName): for CommentLine in CommentStrListTemp: if CommentLine.strip().startswith('/** @file'): FileStartFlag =3D True - if FileStartFlag =3D=3D True: + if FileStartFlag =3D=3D True: CommentStrList.append(CommentLine) =20 ID =3D Result[1] @@ -2388,7 +2527,8 @@ def CheckFileHeaderDoxygenComments(FullFileName): # Check whether C File header Comment content start with two s= paces. if EccGlobalData.gConfig.HeaderCheckCFileCommentStartSpacesNum= =3D=3D '1' or EccGlobalData.gConfig.HeaderCheckAll =3D=3D '1' or EccGlobal= Data.gConfig.CheckAll =3D=3D '1': if CommentLine.startswith('/** @file') =3D=3D False and Co= mmentLine.startswith('**/') =3D=3D False and CommentLine.strip() and Commen= tLine.startswith(' ') =3D=3D False: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header co= mment content should start with two spaces at each line', FileTable, ID) + PrintErrorMsg( + ERROR_HEADER_CHECK_FILE, 'File header comment cont= ent should start with two spaces at each line', FileTable, ID) =20 CommentLine =3D CommentLine.strip() if CommentLine.startswith('Copyright') or ('Copyright' in Comm= entLine and CommentLine.lower().startswith('(c)')): @@ -2396,10 +2536,12 @@ def CheckFileHeaderDoxygenComments(FullFileName): if CommentLine.find('All rights reserved') =3D=3D -1: for Copyright in EccGlobalData.gConfig.Copyright: if CommentLine.find(Copyright) > -1: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, '""All = rights reserved"" announcement should be following the ""Copyright"" at the= same line', FileTable, ID) + PrintErrorMsg( + ERROR_HEADER_CHECK_FILE, '""All rights res= erved"" announcement should be following the ""Copyright"" at the same line= ', FileTable, ID) break if CommentLine.endswith('
        ') =3D=3D -1: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'The ""
        "" a= t the end of the Copyright line is required', FileTable, ID) + PrintErrorMsg( + ERROR_HEADER_CHECK_FILE, 'The ""
        "" at the end = of the Copyright line is required', FileTable, ID) if NextLineIndex < len(CommentStrList) and CommentStrList[= NextLineIndex].strip().startswith('Copyright') =3D=3D False and CommentStrL= ist[NextLineIndex].strip(): NoLicenseFlag =3D False if CommentLine.startswith('@par Revision Reference:'): @@ -2415,20 +2557,26 @@ def CheckFileHeaderDoxygenComments(FullFileName): if EccGlobalData.gConfig.HeaderCheckCFileCommentRefere= nceFormat =3D=3D '1' or EccGlobalData.gConfig.HeaderCheckAll =3D=3D '1' or = EccGlobalData.gConfig.CheckAll =3D=3D '1': if RefListFlag =3D=3D True: if RefLine.strip() and RefLine.strip().startsw= ith('**/') =3D=3D False and RefLine.startswith(' -') =3D=3D False: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'Ea= ch reference on a separate line should begin with a bullet character ""-"" = ', FileTable, ID) + PrintErrorMsg( + ERROR_HEADER_CHECK_FILE, 'Each referen= ce on a separate line should begin with a bullet character ""-"" ', FileTab= le, ID) =20 if NoHeaderCommentStartFlag: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, 'File header commen= t should begin with ""/** @file""', FileTable, ID) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FILE_HEADER, + 'File header comment should begin with ""/** @file""= ', FileTable, ID) return if NoHeaderCommentEndFlag: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment should= end with ""**/""', FileTable, ID) + PrintErrorMsg(ERROR_HEADER_CHECK_FILE, + 'File header comment should end with ""**/""', FileT= able, ID) return if NoCopyrightFlag: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment missin= g the ""Copyright""', FileTable, ID) - #Check whether C File header Comment have the License immediately afte= r the ""Copyright"" line. + PrintErrorMsg(ERROR_HEADER_CHECK_FILE, + 'File header comment missing the ""Copyright""', Fil= eTable, ID) + # Check whether C File header Comment have the License immediately aft= er the ""Copyright"" line. if EccGlobalData.gConfig.HeaderCheckCFileCommentLicenseFormat =3D=3D '= 1' or EccGlobalData.gConfig.HeaderCheckAll =3D=3D '1' or EccGlobalData.gCon= fig.CheckAll =3D=3D '1': if NoLicenseFlag: - PrintErrorMsg(ERROR_HEADER_CHECK_FILE, 'File header comment sh= ould have the License immediately after the ""Copyright"" line', FileTable,= ID) + PrintErrorMsg(ERROR_HEADER_CHECK_FILE, + 'File header comment should have the License imm= ediately after the ""Copyright"" line', FileTable, ID) + =20 def CheckFuncHeaderDoxygenComments(FullFileName): ErrorMsgList =3D [] @@ -2460,14 +2608,18 @@ def CheckFuncHeaderDoxygenComments(FullFileName): ResultSet =3D Db.TblFile.Exec(SqlStatement) for Result in ResultSet: FuncName =3D Result[4] - FunctionHeaderComment =3D CheckCommentImmediatelyPrecedeFunctionHe= ader(Result[1], Result[2], CommentSet) + FunctionHeaderComment =3D CheckCommentImmediatelyPrecedeFunctionHe= ader( + Result[1], Result[2], CommentSet) if FunctionHeaderComment: - CheckFunctionHeaderConsistentWithDoxygenComment(Result[0], Res= ult[1], Result[2], FunctionHeaderComment[0], FunctionHeaderComment[1], Erro= rMsgList, FunctionHeaderComment[3], FileTable) + CheckFunctionHeaderConsistentWithDoxygenComment( + Result[0], Result[1], Result[2], FunctionHeaderComment[0],= FunctionHeaderComment[1], ErrorMsgList, FunctionHeaderComment[3], FileTabl= e) else: if EccGlobalData.gException.IsException(ERROR_HEADER_CHECK_FUN= CTION, FuncName): continue - ErrorMsgList.append('Line %d :Function %s has NO comment immed= iately preceding it.' % (Result[2], Result[1])) - PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'Function [%s] has = NO comment immediately preceding it.' % (FuncName), FileTable, Result[3]) + ErrorMsgList.append( + 'Line %d :Function %s has NO comment immediately preceding= it.' % (Result[2], Result[1])) + PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'Function [%s] has = NO comment immediately preceding it.' % ( + FuncName), FileTable, Result[3]) =20 # Func Def check SqlStatement =3D """ select Value, StartLine, EndLine, ID @@ -2490,16 +2642,21 @@ def CheckFuncHeaderDoxygenComments(FullFileName): ResultSet =3D Db.TblFile.Exec(SqlStatement) for Result in ResultSet: FuncName =3D Result[4] - FunctionHeaderComment =3D CheckCommentImmediatelyPrecedeFunctionHe= ader(Result[1], Result[2], CommentSet) + FunctionHeaderComment =3D CheckCommentImmediatelyPrecedeFunctionHe= ader( + Result[1], Result[2], CommentSet) if FunctionHeaderComment: - CheckFunctionHeaderConsistentWithDoxygenComment(Result[0], Res= ult[1], Result[2], FunctionHeaderComment[0], FunctionHeaderComment[1], Erro= rMsgList, FunctionHeaderComment[3], FileTable) + CheckFunctionHeaderConsistentWithDoxygenComment( + Result[0], Result[1], Result[2], FunctionHeaderComment[0],= FunctionHeaderComment[1], ErrorMsgList, FunctionHeaderComment[3], FileTabl= e) else: if EccGlobalData.gException.IsException(ERROR_HEADER_CHECK_FUN= CTION, FuncName): continue - ErrorMsgList.append('Line %d :Function [%s] has NO comment imm= ediately preceding it.' % (Result[2], Result[1])) - PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'Function [%s] has = NO comment immediately preceding it.' % (FuncName), 'Function', Result[3]) + ErrorMsgList.append( + 'Line %d :Function [%s] has NO comment immediately precedi= ng it.' % (Result[2], Result[1])) + PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'Function [%s] has = NO comment immediately preceding it.' % ( + FuncName), 'Function', Result[3]) return ErrorMsgList =20 + def CheckCommentImmediatelyPrecedeFunctionHeader(FuncName, FuncStartLine, = CommentSet): =20 for Comment in CommentSet: @@ -2507,6 +2664,7 @@ def CheckCommentImmediatelyPrecedeFunctionHeader(Func= Name, FuncStartLine, Commen return Comment return None =20 + def GetDoxygenStrFromComment(Str): DoxygenStrList =3D [] ParamTagList =3D Str.split('@param') @@ -2543,28 +2701,38 @@ def GetDoxygenStrFromComment(Str): =20 return DoxygenStrList =20 -def CheckGeneralDoxygenCommentLayout(Str, StartLine, ErrorMsgList, Comment= Id=3D -1, TableName=3D''): - #/** --*/ @retval after @param + +def CheckGeneralDoxygenCommentLayout(Str, StartLine, ErrorMsgList, Comment= Id=3D-1, TableName=3D''): + # /** --*/ @retval after @param if not Str.startswith('/**'): - ErrorMsgList.append('Line %d : Comment does NOT have prefix /** ' = % StartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'Comment does N= OT have prefix /** ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : Comment does NOT have prefix /** ' % StartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'Comment does NOT have prefix /** ', TableName, Comm= entId) if not Str.endswith('**/'): - ErrorMsgList.append('Line %d : Comment does NOT have tail **/ ' % = StartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'Comment does N= OT have tail **/ ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : Comment does NOT have tail **/ ' % StartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'Comment does NOT have tail **/ ', TableName, Commen= tId) FirstRetvalIndex =3D Str.find('@retval') LastParamIndex =3D Str.rfind('@param') if (FirstRetvalIndex > 0) and (LastParamIndex > 0) and (FirstRetvalInd= ex < LastParamIndex): - ErrorMsgList.append('Line %d : @retval appear before @param ' % St= artLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, @r= etval appear before @param ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : @retval appear before @param ' % StartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'in Comment, @retval appear before @param ', TableN= ame, CommentId) =20 -def CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHead= er, FuncStartLine, CommentStr, CommentStartLine, ErrorMsgList, CommentId=3D= -1, TableName=3D''): + +def CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHead= er, FuncStartLine, CommentStr, CommentStartLine, ErrorMsgList, CommentId=3D= -1, TableName=3D''): =20 ParamList =3D GetParamList(FuncHeader) - CheckGeneralDoxygenCommentLayout(CommentStr, CommentStartLine, ErrorMs= gList, CommentId, TableName) + CheckGeneralDoxygenCommentLayout( + CommentStr, CommentStartLine, ErrorMsgList, CommentId, TableName) DescriptionStr =3D CommentStr DoxygenStrList =3D GetDoxygenStrFromComment(DescriptionStr) if DescriptionStr.find('.') =3D=3D -1: - PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, 'Comment de= scription should end with period \'.\'', TableName, CommentId) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION, + 'Comment description should end with period \'.\'', = TableName, CommentId) DoxygenTagNumber =3D len(DoxygenStrList) ParamNumber =3D len(ParamList) for Param in ParamList: @@ -2577,12 +2745,16 @@ def CheckFunctionHeaderConsistentWithDoxygenComment= (FuncModifier, FuncHeader, Fu ParamName =3D ParamList[Index].Name.strip() Tag =3D DoxygenStrList[Index].strip(' ') if (not Tag[-1] =3D=3D ('\n')) and (not Tag[-1] =3D=3D ('\r')): - ErrorMsgList.append('Line %d : in Comment, <%s> does NOT e= nd with new line ' % (CommentStartLine, Tag.replace('\n', '').replace('\r',= ''))) - PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'in Comment, <%= s> does NOT end with new line ' % (Tag.replace('\n', '').replace('\r', ''))= , TableName, CommentId) + ErrorMsgList.append('Line %d : in Comment, <%s> does NOT e= nd with new line ' % ( + CommentStartLine, Tag.replace('\n', '').replace('\r', = ''))) + PrintErrorMsg(ERROR_HEADER_CHECK_FUNCTION, 'in Comment, <%= s> does NOT end with new line ' % ( + Tag.replace('\n', '').replace('\r', '')), TableName, C= ommentId) TagPartList =3D Tag.split() if len(TagPartList) < 2: - ErrorMsgList.append('Line %d : in Comment, <%s> does NOT c= ontain doxygen contents ' % (CommentStartLine, Tag.replace('\n', '').replac= e('\r', ''))) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Com= ment, <%s> does NOT contain doxygen contents ' % (Tag.replace('\n', '').rep= lace('\r', '')), TableName, CommentId) + ErrorMsgList.append('Line %d : in Comment, <%s> does NOT c= ontain doxygen contents ' % ( + CommentStartLine, Tag.replace('\n', '').replace('\r', = ''))) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Com= ment, <%s> does NOT contain doxygen contents ' % ( + Tag.replace('\n', '').replace('\r', '')), TableName, C= ommentId) Index +=3D 1 continue LBPos =3D Tag.find('[') @@ -2603,46 +2775,62 @@ def CheckFunctionHeaderConsistentWithDoxygenComment= (FuncModifier, FuncHeader, Fu if InOutStr !=3D '': if Tag.find('[' + InOutStr + ']') =3D=3D -1: if InOutStr !=3D 'in, out': - ErrorMsgList.append('Line %d : in Comment, <%s= > does NOT have %s ' % (CommentStartLine, (TagPartList[0] + ' ' + TagPartLi= st[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']')) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEA= DER, 'in Comment, <%s> does NOT have %s ' % ((TagPartList[0] + ' ' + TagPar= tList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']'), Table= Name, CommentId) + ErrorMsgList.append('Line %d : in Comment, <%s= > does NOT have %s ' % ( + CommentStartLine, (TagPartList[0] + ' ' + = TagPartList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']')) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEA= DER, 'in Comment, <%s> does NOT have %s ' % ( + (TagPartList[0] + ' ' + TagPartList[1]).re= place('\n', '').replace('\r', ''), '[' + InOutStr + ']'), TableName, Commen= tId) else: if Tag.find('[in,out]') =3D=3D -1: - ErrorMsgList.append('Line %d : in Comment,= <%s> does NOT have %s ' % (CommentStartLine, (TagPartList[0] + ' ' + TagPa= rtList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']')) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION= _HEADER, 'in Comment, <%s> does NOT have %s ' % ((TagPartList[0] + ' ' + Ta= gPartList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']'), T= ableName, CommentId) - + ErrorMsgList.append('Line %d : in Comment,= <%s> does NOT have %s ' % ( + CommentStartLine, (TagPartList[0] + ' = ' + TagPartList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + '= ]')) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION= _HEADER, 'in Comment, <%s> does NOT have %s ' % ( + (TagPartList[0] + ' ' + TagPartList[1]= ).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']'), TableName, Co= mmentId) =20 if Tag.find(ParamName) =3D=3D -1 and ParamName !=3D 'VOID' and= ParamName !=3D 'void': - ErrorMsgList.append('Line %d : in Comment, <%s> is NOT con= sistent with parameter name %s ' % (CommentStartLine, (TagPartList[0] + ' '= + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName)) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Com= ment, <%s> is NOT consistent with parameter name %s ' % ((TagPartList[0] + = ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName), Tabl= eName, CommentId) + ErrorMsgList.append('Line %d : in Comment, <%s> is NOT con= sistent with parameter name %s ' % ( + CommentStartLine, (TagPartList[0] + ' ' + TagPartList[= 1]).replace('\n', '').replace('\r', ''), ParamName)) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Com= ment, <%s> is NOT consistent with parameter name %s ' % ( + (TagPartList[0] + ' ' + TagPartList[1]).replace('\n', = '').replace('\r', ''), ParamName), TableName, CommentId) Index +=3D 1 =20 if Index < ParamNumber: - ErrorMsgList.append('Line %d : Number of doxygen tags in comme= nt less than number of function parameters' % CommentStartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'Number of = doxygen tags in comment less than number of function parameters ', TableNam= e, CommentId) + ErrorMsgList.append( + 'Line %d : Number of doxygen tags in comment less than num= ber of function parameters' % CommentStartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'Number of doxygen tags in comment less than num= ber of function parameters ', TableName, CommentId) # VOID return type, NOT VOID*. VOID* should be matched with a doxy= gen tag. if (FuncModifier.find('VOID') !=3D -1 or FuncModifier.find('void')= !=3D -1) and FuncModifier.find('*') =3D=3D -1: =20 # assume we allow a return description tag for void func. retu= rn. that's why 'DoxygenTagNumber - 1' is used instead of 'DoxygenTagNumber' if Index < DoxygenTagNumber - 1 or (Index < DoxygenTagNumber a= nd DoxygenStrList[Index].startswith('@retval')): - ErrorMsgList.append('Line %d : VOID return type need NO do= xygen tags in comment' % CommentStartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'VOID r= eturn type need no doxygen tags in comment ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : VOID return type need NO doxygen tags in co= mment' % CommentStartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'VOID return type need no doxygen tags in co= mment ', TableName, CommentId) else: if Index < DoxygenTagNumber and not DoxygenStrList[Index].star= tswith('@retval') and not DoxygenStrList[Index].startswith('@return'): - ErrorMsgList.append('Line %d : Number of @param doxygen ta= gs in comment does NOT match number of function parameters' % CommentStartL= ine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'Number= of @param doxygen tags in comment does NOT match number of function parame= ters ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : Number of @param doxygen tags in comment do= es NOT match number of function parameters' % CommentStartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'Number of @param doxygen tags in comment do= es NOT match number of function parameters ', TableName, CommentId) else: if ParamNumber =3D=3D 0 and DoxygenTagNumber !=3D 0 and ((FuncModi= fier.find('VOID') !=3D -1 or FuncModifier.find('void') !=3D -1) and FuncMod= ifier.find('*') =3D=3D -1): - ErrorMsgList.append('Line %d : VOID return type need NO doxyge= n tags in comment' % CommentStartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'VOID retur= n type need NO doxygen tags in comment ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : VOID return type need NO doxygen tags in commen= t' % CommentStartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'VOID return type need NO doxygen tags in commen= t ', TableName, CommentId) if ParamNumber !=3D 0 and DoxygenTagNumber =3D=3D 0: - ErrorMsgList.append('Line %d : No doxygen tags in comment' % C= ommentStartLine) - PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'No doxygen= tags in comment ', TableName, CommentId) + ErrorMsgList.append( + 'Line %d : No doxygen tags in comment' % CommentStartLine) + PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, + 'No doxygen tags in comment ', TableName, Commen= tId) + =20 if __name__ =3D=3D '__main__': =20 -# EdkLogger.Initialize() -# EdkLogger.SetLevel(EdkLogger.QUIET) -# CollectSourceCodeDataIntoDB(sys.argv[1]) + # EdkLogger.Initialize() + # EdkLogger.SetLevel(EdkLogger.QUIET) + # CollectSourceCodeDataIntoDB(sys.argv[1]) try: test_file =3D sys.argv[1] except IndexError as v: diff --git a/BaseTools/Source/Python/Eot/CParser3/CLexer.py b/BaseTools/Sou= rce/Python/Eot/CParser3/CLexer.py index ca03adea7a65..c48cb2404bf0 100644 --- a/BaseTools/Source/Python/Eot/CParser3/CLexer.py +++ b/BaseTools/Source/Python/Eot/CParser3/CLexer.py @@ -3,7 +3,7 @@ from antlr3 import * from antlr3.compat import set, frozenset =20 -## @file +# @file # The file defines the Lexer for C source files. # # THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY THIS FILE. @@ -17,127 +17,127 @@ from antlr3.compat import set, frozenset ## =20 =20 - # for convenience in actions HIDDEN =3D BaseRecognizer.HIDDEN =20 # token types -T114=3D114 -T115=3D115 -T116=3D116 -T117=3D117 -FloatTypeSuffix=3D16 -LETTER=3D11 -T29=3D29 -T28=3D28 -T27=3D27 -T26=3D26 -T25=3D25 -EOF=3D-1 -STRING_LITERAL=3D9 -FLOATING_POINT_LITERAL=3D10 -T38=3D38 -T37=3D37 -T39=3D39 -T34=3D34 -COMMENT=3D22 -T33=3D33 -T36=3D36 -T35=3D35 -T30=3D30 -T32=3D32 -T31=3D31 -LINE_COMMENT=3D23 -IntegerTypeSuffix=3D14 -CHARACTER_LITERAL=3D8 -T49=3D49 -T48=3D48 -T100=3D100 -T43=3D43 -T42=3D42 -T102=3D102 -T41=3D41 -T101=3D101 -T40=3D40 -T47=3D47 -T46=3D46 -T45=3D45 -T44=3D44 -T109=3D109 -T107=3D107 -T108=3D108 -T105=3D105 -WS=3D19 -T106=3D106 -T103=3D103 -T104=3D104 -T50=3D50 -LINE_COMMAND=3D24 -T59=3D59 -T113=3D113 -T52=3D52 -T112=3D112 -T51=3D51 -T111=3D111 -T54=3D54 -T110=3D110 -EscapeSequence=3D12 -DECIMAL_LITERAL=3D7 -T53=3D53 -T56=3D56 -T55=3D55 -T58=3D58 -T57=3D57 -T75=3D75 -T76=3D76 -T73=3D73 -T74=3D74 -T79=3D79 -T77=3D77 -T78=3D78 -Exponent=3D15 -HexDigit=3D13 -T72=3D72 -T71=3D71 -T70=3D70 -T62=3D62 -T63=3D63 -T64=3D64 -T65=3D65 -T66=3D66 -T67=3D67 -T68=3D68 -T69=3D69 -IDENTIFIER=3D4 -UnicodeVocabulary=3D21 -HEX_LITERAL=3D5 -T61=3D61 -T60=3D60 -T99=3D99 -T97=3D97 -BS=3D20 -T98=3D98 -T95=3D95 -T96=3D96 -OCTAL_LITERAL=3D6 -T94=3D94 -Tokens=3D118 -T93=3D93 -T92=3D92 -T91=3D91 -T90=3D90 -T88=3D88 -T89=3D89 -T84=3D84 -T85=3D85 -T86=3D86 -T87=3D87 -UnicodeEscape=3D18 -T81=3D81 -T80=3D80 -T83=3D83 -OctalEscape=3D17 -T82=3D82 +T114 =3D 114 +T115 =3D 115 +T116 =3D 116 +T117 =3D 117 +FloatTypeSuffix =3D 16 +LETTER =3D 11 +T29 =3D 29 +T28 =3D 28 +T27 =3D 27 +T26 =3D 26 +T25 =3D 25 +EOF =3D -1 +STRING_LITERAL =3D 9 +FLOATING_POINT_LITERAL =3D 10 +T38 =3D 38 +T37 =3D 37 +T39 =3D 39 +T34 =3D 34 +COMMENT =3D 22 +T33 =3D 33 +T36 =3D 36 +T35 =3D 35 +T30 =3D 30 +T32 =3D 32 +T31 =3D 31 +LINE_COMMENT =3D 23 +IntegerTypeSuffix =3D 14 +CHARACTER_LITERAL =3D 8 +T49 =3D 49 +T48 =3D 48 +T100 =3D 100 +T43 =3D 43 +T42 =3D 42 +T102 =3D 102 +T41 =3D 41 +T101 =3D 101 +T40 =3D 40 +T47 =3D 47 +T46 =3D 46 +T45 =3D 45 +T44 =3D 44 +T109 =3D 109 +T107 =3D 107 +T108 =3D 108 +T105 =3D 105 +WS =3D 19 +T106 =3D 106 +T103 =3D 103 +T104 =3D 104 +T50 =3D 50 +LINE_COMMAND =3D 24 +T59 =3D 59 +T113 =3D 113 +T52 =3D 52 +T112 =3D 112 +T51 =3D 51 +T111 =3D 111 +T54 =3D 54 +T110 =3D 110 +EscapeSequence =3D 12 +DECIMAL_LITERAL =3D 7 +T53 =3D 53 +T56 =3D 56 +T55 =3D 55 +T58 =3D 58 +T57 =3D 57 +T75 =3D 75 +T76 =3D 76 +T73 =3D 73 +T74 =3D 74 +T79 =3D 79 +T77 =3D 77 +T78 =3D 78 +Exponent =3D 15 +HexDigit =3D 13 +T72 =3D 72 +T71 =3D 71 +T70 =3D 70 +T62 =3D 62 +T63 =3D 63 +T64 =3D 64 +T65 =3D 65 +T66 =3D 66 +T67 =3D 67 +T68 =3D 68 +T69 =3D 69 +IDENTIFIER =3D 4 +UnicodeVocabulary =3D 21 +HEX_LITERAL =3D 5 +T61 =3D 61 +T60 =3D 60 +T99 =3D 99 +T97 =3D 97 +BS =3D 20 +T98 =3D 98 +T95 =3D 95 +T96 =3D 96 +OCTAL_LITERAL =3D 6 +T94 =3D 94 +Tokens =3D 118 +T93 =3D 93 +T92 =3D 92 +T91 =3D 91 +T90 =3D 90 +T88 =3D 88 +T89 =3D 89 +T84 =3D 84 +T85 =3D 85 +T86 =3D 86 +T87 =3D 87 +UnicodeEscape =3D 18 +T81 =3D 81 +T80 =3D 80 +T83 =3D 83 +OctalEscape =3D 17 +T82 =3D 82 + =20 class CLexer(Lexer): =20 @@ -147,31 +147,27 @@ class CLexer(Lexer): Lexer.__init__(self, input) self.dfa25 =3D self.DFA25( self, 25, - eot =3D self.DFA25_eot, - eof =3D self.DFA25_eof, - min =3D self.DFA25_min, - max =3D self.DFA25_max, - accept =3D self.DFA25_accept, - special =3D self.DFA25_special, - transition =3D self.DFA25_transition - ) + eot=3Dself.DFA25_eot, + eof=3Dself.DFA25_eof, + min=3Dself.DFA25_min, + max=3Dself.DFA25_max, + accept=3Dself.DFA25_accept, + special=3Dself.DFA25_special, + transition=3Dself.DFA25_transition + ) self.dfa35 =3D self.DFA35( self, 35, - eot =3D self.DFA35_eot, - eof =3D self.DFA35_eof, - min =3D self.DFA35_min, - max =3D self.DFA35_max, - accept =3D self.DFA35_accept, - special =3D self.DFA35_special, - transition =3D self.DFA35_transition - ) - - - - - + eot=3Dself.DFA35_eot, + eof=3Dself.DFA35_eof, + min=3Dself.DFA35_min, + max=3Dself.DFA35_max, + accept=3Dself.DFA35_accept, + special=3Dself.DFA35_special, + transition=3Dself.DFA35_transition + ) =20 # $ANTLR start T25 + def mT25(self, ): =20 try: @@ -181,19 +177,14 @@ class CLexer(Lexer): # C.g:27:7: ';' self.match(u';') =20 - - - - finally: =20 pass =20 # $ANTLR end T25 =20 - - # $ANTLR start T26 + def mT26(self, ): =20 try: @@ -203,20 +194,14 @@ class CLexer(Lexer): # C.g:28:7: 'typedef' self.match("typedef") =20 - - - - - finally: =20 pass =20 # $ANTLR end T26 =20 - - # $ANTLR start T27 + def mT27(self, ): =20 try: @@ -226,19 +211,14 @@ class CLexer(Lexer): # C.g:29:7: ',' self.match(u',') =20 - - - - finally: =20 pass =20 # $ANTLR end T27 =20 - - # $ANTLR start T28 + def mT28(self, ): =20 try: @@ -248,19 +228,14 @@ class CLexer(Lexer): # C.g:30:7: '=3D' self.match(u'=3D') =20 - - - - finally: =20 pass =20 # $ANTLR end T28 =20 - - # $ANTLR start T29 + def mT29(self, ): =20 try: @@ -270,20 +245,14 @@ class CLexer(Lexer): # C.g:31:7: 'extern' self.match("extern") =20 - - - - - finally: =20 pass =20 # $ANTLR end T29 =20 - - # $ANTLR start T30 + def mT30(self, ): =20 try: @@ -293,20 +262,14 @@ class CLexer(Lexer): # C.g:32:7: 'static' self.match("static") =20 - - - - - finally: =20 pass =20 # $ANTLR end T30 =20 - - # $ANTLR start T31 + def mT31(self, ): =20 try: @@ -316,20 +279,14 @@ class CLexer(Lexer): # C.g:33:7: 'auto' self.match("auto") =20 - - - - - finally: =20 pass =20 # $ANTLR end T31 =20 - - # $ANTLR start T32 + def mT32(self, ): =20 try: @@ -339,20 +296,14 @@ class CLexer(Lexer): # C.g:34:7: 'register' self.match("register") =20 - - - - - finally: =20 pass =20 # $ANTLR end T32 =20 - - # $ANTLR start T33 + def mT33(self, ): =20 try: @@ -362,20 +313,14 @@ class CLexer(Lexer): # C.g:35:7: 'STATIC' self.match("STATIC") =20 - - - - - finally: =20 pass =20 # $ANTLR end T33 =20 - - # $ANTLR start T34 + def mT34(self, ): =20 try: @@ -385,20 +330,14 @@ class CLexer(Lexer): # C.g:36:7: 'void' self.match("void") =20 - - - - - finally: =20 pass =20 # $ANTLR end T34 =20 - - # $ANTLR start T35 + def mT35(self, ): =20 try: @@ -408,20 +347,14 @@ class CLexer(Lexer): # C.g:37:7: 'char' self.match("char") =20 - - - - - finally: =20 pass =20 # $ANTLR end T35 =20 - - # $ANTLR start T36 + def mT36(self, ): =20 try: @@ -431,20 +364,14 @@ class CLexer(Lexer): # C.g:38:7: 'short' self.match("short") =20 - - - - - finally: =20 pass =20 # $ANTLR end T36 =20 - - # $ANTLR start T37 + def mT37(self, ): =20 try: @@ -454,20 +381,14 @@ class CLexer(Lexer): # C.g:39:7: 'int' self.match("int") =20 - - - - - finally: =20 pass =20 # $ANTLR end T37 =20 - - # $ANTLR start T38 + def mT38(self, ): =20 try: @@ -477,20 +398,14 @@ class CLexer(Lexer): # C.g:40:7: 'long' self.match("long") =20 - - - - - finally: =20 pass =20 # $ANTLR end T38 =20 - - # $ANTLR start T39 + def mT39(self, ): =20 try: @@ -500,20 +415,14 @@ class CLexer(Lexer): # C.g:41:7: 'float' self.match("float") =20 - - - - - finally: =20 pass =20 # $ANTLR end T39 =20 - - # $ANTLR start T40 + def mT40(self, ): =20 try: @@ -523,20 +432,14 @@ class CLexer(Lexer): # C.g:42:7: 'double' self.match("double") =20 - - - - - finally: =20 pass =20 # $ANTLR end T40 =20 - - # $ANTLR start T41 + def mT41(self, ): =20 try: @@ -546,20 +449,14 @@ class CLexer(Lexer): # C.g:43:7: 'signed' self.match("signed") =20 - - - - - finally: =20 pass =20 # $ANTLR end T41 =20 - - # $ANTLR start T42 + def mT42(self, ): =20 try: @@ -569,20 +466,14 @@ class CLexer(Lexer): # C.g:44:7: 'unsigned' self.match("unsigned") =20 - - - - - finally: =20 pass =20 # $ANTLR end T42 =20 - - # $ANTLR start T43 + def mT43(self, ): =20 try: @@ -592,19 +483,14 @@ class CLexer(Lexer): # C.g:45:7: '{' self.match(u'{') =20 - - - - finally: =20 pass =20 # $ANTLR end T43 =20 - - # $ANTLR start T44 + def mT44(self, ): =20 try: @@ -614,19 +500,14 @@ class CLexer(Lexer): # C.g:46:7: '}' self.match(u'}') =20 - - - - finally: =20 pass =20 # $ANTLR end T44 =20 - - # $ANTLR start T45 + def mT45(self, ): =20 try: @@ -636,20 +517,14 @@ class CLexer(Lexer): # C.g:47:7: 'struct' self.match("struct") =20 - - - - - finally: =20 pass =20 # $ANTLR end T45 =20 - - # $ANTLR start T46 + def mT46(self, ): =20 try: @@ -659,20 +534,14 @@ class CLexer(Lexer): # C.g:48:7: 'union' self.match("union") =20 - - - - - finally: =20 pass =20 # $ANTLR end T46 =20 - - # $ANTLR start T47 + def mT47(self, ): =20 try: @@ -682,19 +551,14 @@ class CLexer(Lexer): # C.g:49:7: ':' self.match(u':') =20 - - - - finally: =20 pass =20 # $ANTLR end T47 =20 - - # $ANTLR start T48 + def mT48(self, ): =20 try: @@ -704,20 +568,14 @@ class CLexer(Lexer): # C.g:50:7: 'enum' self.match("enum") =20 - - - - - finally: =20 pass =20 # $ANTLR end T48 =20 - - # $ANTLR start T49 + def mT49(self, ): =20 try: @@ -727,20 +585,14 @@ class CLexer(Lexer): # C.g:51:7: 'const' self.match("const") =20 - - - - - finally: =20 pass =20 # $ANTLR end T49 =20 - - # $ANTLR start T50 + def mT50(self, ): =20 try: @@ -750,20 +602,14 @@ class CLexer(Lexer): # C.g:52:7: 'volatile' self.match("volatile") =20 - - - - - finally: =20 pass =20 # $ANTLR end T50 =20 - - # $ANTLR start T51 + def mT51(self, ): =20 try: @@ -773,20 +619,14 @@ class CLexer(Lexer): # C.g:53:7: 'IN' self.match("IN") =20 - - - - - finally: =20 pass =20 # $ANTLR end T51 =20 - - # $ANTLR start T52 + def mT52(self, ): =20 try: @@ -796,20 +636,14 @@ class CLexer(Lexer): # C.g:54:7: 'OUT' self.match("OUT") =20 - - - - - finally: =20 pass =20 # $ANTLR end T52 =20 - - # $ANTLR start T53 + def mT53(self, ): =20 try: @@ -819,20 +653,14 @@ class CLexer(Lexer): # C.g:55:7: 'OPTIONAL' self.match("OPTIONAL") =20 - - - - - finally: =20 pass =20 # $ANTLR end T53 =20 - - # $ANTLR start T54 + def mT54(self, ): =20 try: @@ -842,20 +670,14 @@ class CLexer(Lexer): # C.g:56:7: 'CONST' self.match("CONST") =20 - - - - - finally: =20 pass =20 # $ANTLR end T54 =20 - - # $ANTLR start T55 + def mT55(self, ): =20 try: @@ -865,20 +687,14 @@ class CLexer(Lexer): # C.g:57:7: 'UNALIGNED' self.match("UNALIGNED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T55 =20 - - # $ANTLR start T56 + def mT56(self, ): =20 try: @@ -888,20 +704,14 @@ class CLexer(Lexer): # C.g:58:7: 'VOLATILE' self.match("VOLATILE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T56 =20 - - # $ANTLR start T57 + def mT57(self, ): =20 try: @@ -911,20 +721,14 @@ class CLexer(Lexer): # C.g:59:7: 'GLOBAL_REMOVE_IF_UNREFERENCED' self.match("GLOBAL_REMOVE_IF_UNREFERENCED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T57 =20 - - # $ANTLR start T58 + def mT58(self, ): =20 try: @@ -934,20 +738,14 @@ class CLexer(Lexer): # C.g:60:7: 'EFIAPI' self.match("EFIAPI") =20 - - - - - finally: =20 pass =20 # $ANTLR end T58 =20 - - # $ANTLR start T59 + def mT59(self, ): =20 try: @@ -957,20 +755,14 @@ class CLexer(Lexer): # C.g:61:7: 'EFI_BOOTSERVICE' self.match("EFI_BOOTSERVICE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T59 =20 - - # $ANTLR start T60 + def mT60(self, ): =20 try: @@ -980,20 +772,14 @@ class CLexer(Lexer): # C.g:62:7: 'EFI_RUNTIMESERVICE' self.match("EFI_RUNTIMESERVICE") =20 - - - - - finally: =20 pass =20 # $ANTLR end T60 =20 - - # $ANTLR start T61 + def mT61(self, ): =20 try: @@ -1003,20 +789,14 @@ class CLexer(Lexer): # C.g:63:7: 'PACKED' self.match("PACKED") =20 - - - - - finally: =20 pass =20 # $ANTLR end T61 =20 - - # $ANTLR start T62 + def mT62(self, ): =20 try: @@ -1026,19 +806,14 @@ class CLexer(Lexer): # C.g:64:7: '(' self.match(u'(') =20 - - - - finally: =20 pass =20 # $ANTLR end T62 =20 - - # $ANTLR start T63 + def mT63(self, ): =20 try: @@ -1048,19 +823,14 @@ class CLexer(Lexer): # C.g:65:7: ')' self.match(u')') =20 - - - - finally: =20 pass =20 # $ANTLR end T63 =20 - - # $ANTLR start T64 + def mT64(self, ): =20 try: @@ -1070,19 +840,14 @@ class CLexer(Lexer): # C.g:66:7: '[' self.match(u'[') =20 - - - - finally: =20 pass =20 # $ANTLR end T64 =20 - - # $ANTLR start T65 + def mT65(self, ): =20 try: @@ -1092,19 +857,14 @@ class CLexer(Lexer): # C.g:67:7: ']' self.match(u']') =20 - - - - finally: =20 pass =20 # $ANTLR end T65 =20 - - # $ANTLR start T66 + def mT66(self, ): =20 try: @@ -1114,19 +874,14 @@ class CLexer(Lexer): # C.g:68:7: '*' self.match(u'*') =20 - - - - finally: =20 pass =20 # $ANTLR end T66 =20 - - # $ANTLR start T67 + def mT67(self, ): =20 try: @@ -1136,20 +891,14 @@ class CLexer(Lexer): # C.g:69:7: '...' self.match("...") =20 - - - - - finally: =20 pass =20 # $ANTLR end T67 =20 - - # $ANTLR start T68 + def mT68(self, ): =20 try: @@ -1159,19 +908,14 @@ class CLexer(Lexer): # C.g:70:7: '+' self.match(u'+') =20 - - - - finally: =20 pass =20 # $ANTLR end T68 =20 - - # $ANTLR start T69 + def mT69(self, ): =20 try: @@ -1181,19 +925,14 @@ class CLexer(Lexer): # C.g:71:7: '-' self.match(u'-') =20 - - - - finally: =20 pass =20 # $ANTLR end T69 =20 - - # $ANTLR start T70 + def mT70(self, ): =20 try: @@ -1203,19 +942,14 @@ class CLexer(Lexer): # C.g:72:7: '/' self.match(u'/') =20 - - - - finally: =20 pass =20 # $ANTLR end T70 =20 - - # $ANTLR start T71 + def mT71(self, ): =20 try: @@ -1225,19 +959,14 @@ class CLexer(Lexer): # C.g:73:7: '%' self.match(u'%') =20 - - - - finally: =20 pass =20 # $ANTLR end T71 =20 - - # $ANTLR start T72 + def mT72(self, ): =20 try: @@ -1247,20 +976,14 @@ class CLexer(Lexer): # C.g:74:7: '++' self.match("++") =20 - - - - - finally: =20 pass =20 # $ANTLR end T72 =20 - - # $ANTLR start T73 + def mT73(self, ): =20 try: @@ -1270,20 +993,14 @@ class CLexer(Lexer): # C.g:75:7: '--' self.match("--") =20 - - - - - finally: =20 pass =20 # $ANTLR end T73 =20 - - # $ANTLR start T74 + def mT74(self, ): =20 try: @@ -1293,20 +1010,14 @@ class CLexer(Lexer): # C.g:76:7: 'sizeof' self.match("sizeof") =20 - - - - - finally: =20 pass =20 # $ANTLR end T74 =20 - - # $ANTLR start T75 + def mT75(self, ): =20 try: @@ -1316,19 +1027,14 @@ class CLexer(Lexer): # C.g:77:7: '.' self.match(u'.') =20 - - - - finally: =20 pass =20 # $ANTLR end T75 =20 - - # $ANTLR start T76 + def mT76(self, ): =20 try: @@ -1338,20 +1044,14 @@ class CLexer(Lexer): # C.g:78:7: '->' self.match("->") =20 - - - - - finally: =20 pass =20 # $ANTLR end T76 =20 - - # $ANTLR start T77 + def mT77(self, ): =20 try: @@ -1361,19 +1061,14 @@ class CLexer(Lexer): # C.g:79:7: '&' self.match(u'&') =20 - - - - finally: =20 pass =20 # $ANTLR end T77 =20 - - # $ANTLR start T78 + def mT78(self, ): =20 try: @@ -1383,19 +1078,14 @@ class CLexer(Lexer): # C.g:80:7: '~' self.match(u'~') =20 - - - - finally: =20 pass =20 # $ANTLR end T78 =20 - - # $ANTLR start T79 + def mT79(self, ): =20 try: @@ -1405,19 +1095,14 @@ class CLexer(Lexer): # C.g:81:7: '!' self.match(u'!') =20 - - - - finally: =20 pass =20 # $ANTLR end T79 =20 - - # $ANTLR start T80 + def mT80(self, ): =20 try: @@ -1427,20 +1112,14 @@ class CLexer(Lexer): # C.g:82:7: '*=3D' self.match("*=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T80 =20 - - # $ANTLR start T81 + def mT81(self, ): =20 try: @@ -1450,20 +1129,14 @@ class CLexer(Lexer): # C.g:83:7: '/=3D' self.match("/=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T81 =20 - - # $ANTLR start T82 + def mT82(self, ): =20 try: @@ -1473,20 +1146,14 @@ class CLexer(Lexer): # C.g:84:7: '%=3D' self.match("%=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T82 =20 - - # $ANTLR start T83 + def mT83(self, ): =20 try: @@ -1496,20 +1163,14 @@ class CLexer(Lexer): # C.g:85:7: '+=3D' self.match("+=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T83 =20 - - # $ANTLR start T84 + def mT84(self, ): =20 try: @@ -1519,20 +1180,14 @@ class CLexer(Lexer): # C.g:86:7: '-=3D' self.match("-=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T84 =20 - - # $ANTLR start T85 + def mT85(self, ): =20 try: @@ -1542,20 +1197,14 @@ class CLexer(Lexer): # C.g:87:7: '<<=3D' self.match("<<=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T85 =20 - - # $ANTLR start T86 + def mT86(self, ): =20 try: @@ -1565,20 +1214,14 @@ class CLexer(Lexer): # C.g:88:7: '>>=3D' self.match(">>=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T86 =20 - - # $ANTLR start T87 + def mT87(self, ): =20 try: @@ -1588,20 +1231,14 @@ class CLexer(Lexer): # C.g:89:7: '&=3D' self.match("&=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T87 =20 - - # $ANTLR start T88 + def mT88(self, ): =20 try: @@ -1611,20 +1248,14 @@ class CLexer(Lexer): # C.g:90:7: '^=3D' self.match("^=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T88 =20 - - # $ANTLR start T89 + def mT89(self, ): =20 try: @@ -1634,20 +1265,14 @@ class CLexer(Lexer): # C.g:91:7: '|=3D' self.match("|=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T89 =20 - - # $ANTLR start T90 + def mT90(self, ): =20 try: @@ -1657,19 +1282,14 @@ class CLexer(Lexer): # C.g:92:7: '?' self.match(u'?') =20 - - - - finally: =20 pass =20 # $ANTLR end T90 =20 - - # $ANTLR start T91 + def mT91(self, ): =20 try: @@ -1679,20 +1299,14 @@ class CLexer(Lexer): # C.g:93:7: '||' self.match("||") =20 - - - - - finally: =20 pass =20 # $ANTLR end T91 =20 - - # $ANTLR start T92 + def mT92(self, ): =20 try: @@ -1702,20 +1316,14 @@ class CLexer(Lexer): # C.g:94:7: '&&' self.match("&&") =20 - - - - - finally: =20 pass =20 # $ANTLR end T92 =20 - - # $ANTLR start T93 + def mT93(self, ): =20 try: @@ -1725,19 +1333,14 @@ class CLexer(Lexer): # C.g:95:7: '|' self.match(u'|') =20 - - - - finally: =20 pass =20 # $ANTLR end T93 =20 - - # $ANTLR start T94 + def mT94(self, ): =20 try: @@ -1747,19 +1350,14 @@ class CLexer(Lexer): # C.g:96:7: '^' self.match(u'^') =20 - - - - finally: =20 pass =20 # $ANTLR end T94 =20 - - # $ANTLR start T95 + def mT95(self, ): =20 try: @@ -1769,20 +1367,14 @@ class CLexer(Lexer): # C.g:97:7: '=3D=3D' self.match("=3D=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T95 =20 - - # $ANTLR start T96 + def mT96(self, ): =20 try: @@ -1792,20 +1384,14 @@ class CLexer(Lexer): # C.g:98:7: '!=3D' self.match("!=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T96 =20 - - # $ANTLR start T97 + def mT97(self, ): =20 try: @@ -1815,19 +1401,14 @@ class CLexer(Lexer): # C.g:99:7: '<' self.match(u'<') =20 - - - - finally: =20 pass =20 # $ANTLR end T97 =20 - - # $ANTLR start T98 + def mT98(self, ): =20 try: @@ -1837,19 +1418,14 @@ class CLexer(Lexer): # C.g:100:7: '>' self.match(u'>') =20 - - - - finally: =20 pass =20 # $ANTLR end T98 =20 - - # $ANTLR start T99 + def mT99(self, ): =20 try: @@ -1859,20 +1435,14 @@ class CLexer(Lexer): # C.g:101:7: '<=3D' self.match("<=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T99 =20 - - # $ANTLR start T100 + def mT100(self, ): =20 try: @@ -1882,20 +1452,14 @@ class CLexer(Lexer): # C.g:102:8: '>=3D' self.match(">=3D") =20 - - - - - finally: =20 pass =20 # $ANTLR end T100 =20 - - # $ANTLR start T101 + def mT101(self, ): =20 try: @@ -1905,20 +1469,14 @@ class CLexer(Lexer): # C.g:103:8: '<<' self.match("<<") =20 - - - - - finally: =20 pass =20 # $ANTLR end T101 =20 - - # $ANTLR start T102 + def mT102(self, ): =20 try: @@ -1928,20 +1486,14 @@ class CLexer(Lexer): # C.g:104:8: '>>' self.match(">>") =20 - - - - - finally: =20 pass =20 # $ANTLR end T102 =20 - - # $ANTLR start T103 + def mT103(self, ): =20 try: @@ -1951,20 +1503,14 @@ class CLexer(Lexer): # C.g:105:8: '__asm__' self.match("__asm__") =20 - - - - - finally: =20 pass =20 # $ANTLR end T103 =20 - - # $ANTLR start T104 + def mT104(self, ): =20 try: @@ -1974,20 +1520,14 @@ class CLexer(Lexer): # C.g:106:8: '_asm' self.match("_asm") =20 - - - - - finally: =20 pass =20 # $ANTLR end T104 =20 - - # $ANTLR start T105 + def mT105(self, ): =20 try: @@ -1997,20 +1537,14 @@ class CLexer(Lexer): # C.g:107:8: '__asm' self.match("__asm") =20 - - - - - finally: =20 pass =20 # $ANTLR end T105 =20 - - # $ANTLR start T106 + def mT106(self, ): =20 try: @@ -2020,20 +1554,14 @@ class CLexer(Lexer): # C.g:108:8: 'case' self.match("case") =20 - - - - - finally: =20 pass =20 # $ANTLR end T106 =20 - - # $ANTLR start T107 + def mT107(self, ): =20 try: @@ -2043,20 +1571,14 @@ class CLexer(Lexer): # C.g:109:8: 'default' self.match("default") =20 - - - - - finally: =20 pass =20 # $ANTLR end T107 =20 - - # $ANTLR start T108 + def mT108(self, ): =20 try: @@ -2066,20 +1588,14 @@ class CLexer(Lexer): # C.g:110:8: 'if' self.match("if") =20 - - - - - finally: =20 pass =20 # $ANTLR end T108 =20 - - # $ANTLR start T109 + def mT109(self, ): =20 try: @@ -2089,20 +1605,14 @@ class CLexer(Lexer): # C.g:111:8: 'else' self.match("else") =20 - - - - - finally: =20 pass =20 # $ANTLR end T109 =20 - - # $ANTLR start T110 + def mT110(self, ): =20 try: @@ -2112,20 +1622,14 @@ class CLexer(Lexer): # C.g:112:8: 'switch' self.match("switch") =20 - - - - - finally: =20 pass =20 # $ANTLR end T110 =20 - - # $ANTLR start T111 + def mT111(self, ): =20 try: @@ -2135,20 +1639,14 @@ class CLexer(Lexer): # C.g:113:8: 'while' self.match("while") =20 - - - - - finally: =20 pass =20 # $ANTLR end T111 =20 - - # $ANTLR start T112 + def mT112(self, ): =20 try: @@ -2158,20 +1656,14 @@ class CLexer(Lexer): # C.g:114:8: 'do' self.match("do") =20 - - - - - finally: =20 pass =20 # $ANTLR end T112 =20 - - # $ANTLR start T113 + def mT113(self, ): =20 try: @@ -2181,20 +1673,14 @@ class CLexer(Lexer): # C.g:115:8: 'for' self.match("for") =20 - - - - - finally: =20 pass =20 # $ANTLR end T113 =20 - - # $ANTLR start T114 + def mT114(self, ): =20 try: @@ -2204,20 +1690,14 @@ class CLexer(Lexer): # C.g:116:8: 'goto' self.match("goto") =20 - - - - - finally: =20 pass =20 # $ANTLR end T114 =20 - - # $ANTLR start T115 + def mT115(self, ): =20 try: @@ -2227,20 +1707,14 @@ class CLexer(Lexer): # C.g:117:8: 'continue' self.match("continue") =20 - - - - - finally: =20 pass =20 # $ANTLR end T115 =20 - - # $ANTLR start T116 + def mT116(self, ): =20 try: @@ -2250,20 +1724,14 @@ class CLexer(Lexer): # C.g:118:8: 'break' self.match("break") =20 - - - - - finally: =20 pass =20 # $ANTLR end T116 =20 - - # $ANTLR start T117 + def mT117(self, ): =20 try: @@ -2273,20 +1741,14 @@ class CLexer(Lexer): # C.g:119:8: 'return' self.match("return") =20 - - - - - finally: =20 pass =20 # $ANTLR end T117 =20 - - # $ANTLR start IDENTIFIER + def mIDENTIFIER(self, ): =20 try: @@ -2297,34 +1759,25 @@ class CLexer(Lexer): self.mLETTER() =20 # C.g:586:11: ( LETTER | '0' .. '9' )* - while True: #loop1 + while True: # loop1 alt1 =3D 2 LA1_0 =3D self.input.LA(1) =20 - if (LA1_0 =3D=3D u'$' or (u'0' <=3D LA1_0 <=3D u'9') or (u= 'A' <=3D LA1_0 <=3D u'Z') or LA1_0 =3D=3D u'_' or (u'a' <=3D LA1_0 <=3D u'z= ')) : + if (LA1_0 =3D=3D u'$' or (u'0' <=3D LA1_0 <=3D u'9') or (u= 'A' <=3D LA1_0 <=3D u'Z') or LA1_0 =3D=3D u'_' or (u'a' <=3D LA1_0 <=3D u'z= ')): alt1 =3D 1 =20 - if alt1 =3D=3D 1: # C.g: if self.input.LA(1) =3D=3D u'$' or (u'0' <=3D self.inp= ut.LA(1) <=3D u'9') or (u'A' <=3D self.input.LA(1) <=3D u'Z') or self.input= .LA(1) =3D=3D u'_' or (u'a' <=3D self.input.LA(1) <=3D u'z'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop1 - - - - - + break # loop1 =20 finally: =20 @@ -2332,36 +1785,29 @@ class CLexer(Lexer): =20 # $ANTLR end IDENTIFIER =20 - - # $ANTLR start LETTER + def mLETTER(self, ): =20 try: # C.g:591:2: ( '$' | 'A' .. 'Z' | 'a' .. 'z' | '_' ) # C.g: if self.input.LA(1) =3D=3D u'$' or (u'A' <=3D self.input.LA(1)= <=3D u'Z') or self.input.LA(1) =3D=3D u'_' or (u'a' <=3D self.input.LA(1) = <=3D u'z'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end LETTER =20 - - # $ANTLR start CHARACTER_LITERAL + def mCHARACTER_LITERAL(self, ): =20 try: @@ -2373,27 +1819,25 @@ class CLexer(Lexer): alt2 =3D 2 LA2_0 =3D self.input.LA(1) =20 - if (LA2_0 =3D=3D u'L') : + if (LA2_0 =3D=3D u'L'): alt2 =3D 1 if alt2 =3D=3D 1: # C.g:598:10: 'L' self.match(u'L') =20 - - - self.match(u'\'') =20 # C.g:598:21: ( EscapeSequence | ~ ( '\\'' | '\\\\' ) ) alt3 =3D 2 LA3_0 =3D self.input.LA(1) =20 - if (LA3_0 =3D=3D u'\\') : + if (LA3_0 =3D=3D u'\\'): alt3 =3D 1 - elif ((u'\u0000' <=3D LA3_0 <=3D u'&') or (u'(' <=3D LA3_0 <= =3D u'[') or (u']' <=3D LA3_0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA3_0 <=3D u'&') or (u'(' <=3D LA3_0 <= =3D u'[') or (u']' <=3D LA3_0 <=3D u'\uFFFE')): alt3 =3D 2 else: - nvae =3D NoViableAltException("598:21: ( EscapeSequence | = ~ ( '\\'' | '\\\\' ) )", 3, 0, self.input) + nvae =3D NoViableAltException( + "598:21: ( EscapeSequence | ~ ( '\\'' | '\\\\' ) )", 3= , 0, self.input) =20 raise nvae =20 @@ -2401,37 +1845,26 @@ class CLexer(Lexer): # C.g:598:23: EscapeSequence self.mEscapeSequence() =20 - - elif alt3 =3D=3D 2: # C.g:598:40: ~ ( '\\'' | '\\\\' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'&') or (u'(' <= =3D self.input.LA(1) <=3D u'[') or (u']' <=3D self.input.LA(1) <=3D u'\uFFF= E'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - self.match(u'\'') =20 - - - - finally: =20 pass =20 # $ANTLR end CHARACTER_LITERAL =20 - - # $ANTLR start STRING_LITERAL + def mSTRING_LITERAL(self, ): =20 try: @@ -2443,66 +1876,51 @@ class CLexer(Lexer): alt4 =3D 2 LA4_0 =3D self.input.LA(1) =20 - if (LA4_0 =3D=3D u'L') : + if (LA4_0 =3D=3D u'L'): alt4 =3D 1 if alt4 =3D=3D 1: # C.g:602:9: 'L' self.match(u'L') =20 - - - self.match(u'"') =20 # C.g:602:19: ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* - while True: #loop5 + while True: # loop5 alt5 =3D 3 LA5_0 =3D self.input.LA(1) =20 - if (LA5_0 =3D=3D u'\\') : + if (LA5_0 =3D=3D u'\\'): alt5 =3D 1 - elif ((u'\u0000' <=3D LA5_0 <=3D u'!') or (u'#' <=3D LA5_0= <=3D u'[') or (u']' <=3D LA5_0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA5_0 <=3D u'!') or (u'#' <=3D LA5_0= <=3D u'[') or (u']' <=3D LA5_0 <=3D u'\uFFFE')): alt5 =3D 2 =20 - if alt5 =3D=3D 1: # C.g:602:21: EscapeSequence self.mEscapeSequence() =20 - - elif alt5 =3D=3D 2: # C.g:602:38: ~ ( '\\\\' | '\"' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'!') or (u'#= ' <=3D self.input.LA(1) <=3D u'[') or (u']' <=3D self.input.LA(1) <=3D u'\u= FFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop5 - + break # loop5 =20 self.match(u'"') =20 - - - - finally: =20 pass =20 # $ANTLR end STRING_LITERAL =20 - - # $ANTLR start HEX_LITERAL + def mHEX_LITERAL(self, ): =20 try: @@ -2513,66 +1931,53 @@ class CLexer(Lexer): self.match(u'0') =20 if self.input.LA(1) =3D=3D u'X' or self.input.LA(1) =3D=3D u'x= ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - # C.g:605:29: ( HexDigit )+ cnt6 =3D 0 - while True: #loop6 + while True: # loop6 alt6 =3D 2 LA6_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA6_0 <=3D u'9') or (u'A' <=3D LA6_0 <=3D u= 'F') or (u'a' <=3D LA6_0 <=3D u'f')) : + if ((u'0' <=3D LA6_0 <=3D u'9') or (u'A' <=3D LA6_0 <=3D u= 'F') or (u'a' <=3D LA6_0 <=3D u'f')): alt6 =3D 1 =20 - if alt6 =3D=3D 1: # C.g:605:29: HexDigit self.mHexDigit() =20 - - else: if cnt6 >=3D 1: - break #loop6 + break # loop6 =20 eee =3D EarlyExitException(6, self.input) raise eee =20 cnt6 +=3D 1 =20 - # C.g:605:39: ( IntegerTypeSuffix )? alt7 =3D 2 LA7_0 =3D self.input.LA(1) =20 - if (LA7_0 =3D=3D u'L' or LA7_0 =3D=3D u'U' or LA7_0 =3D=3D u'l= ' or LA7_0 =3D=3D u'u') : + if (LA7_0 =3D=3D u'L' or LA7_0 =3D=3D u'U' or LA7_0 =3D=3D u'l= ' or LA7_0 =3D=3D u'u'): alt7 =3D 1 if alt7 =3D=3D 1: # C.g:605:39: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end HEX_LITERAL =20 - - # $ANTLR start DECIMAL_LITERAL + def mDECIMAL_LITERAL(self, ): =20 try: @@ -2584,12 +1989,13 @@ class CLexer(Lexer): alt9 =3D 2 LA9_0 =3D self.input.LA(1) =20 - if (LA9_0 =3D=3D u'0') : + if (LA9_0 =3D=3D u'0'): alt9 =3D 1 - elif ((u'1' <=3D LA9_0 <=3D u'9')) : + elif ((u'1' <=3D LA9_0 <=3D u'9')): alt9 =3D 2 else: - nvae =3D NoViableAltException("607:19: ( '0' | '1' .. '9' = ( '0' .. '9' )* )", 9, 0, self.input) + nvae =3D NoViableAltException( + "607:19: ( '0' | '1' .. '9' ( '0' .. '9' )* )", 9, 0, = self.input) =20 raise nvae =20 @@ -2597,60 +2003,43 @@ class CLexer(Lexer): # C.g:607:20: '0' self.match(u'0') =20 - - elif alt9 =3D=3D 2: # C.g:607:26: '1' .. '9' ( '0' .. '9' )* self.matchRange(u'1', u'9') =20 # C.g:607:35: ( '0' .. '9' )* - while True: #loop8 + while True: # loop8 alt8 =3D 2 LA8_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA8_0 <=3D u'9')) : + if ((u'0' <=3D LA8_0 <=3D u'9')): alt8 =3D 1 =20 - if alt8 =3D=3D 1: # C.g:607:35: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: - break #loop8 - - - - + break # loop8 =20 # C.g:607:46: ( IntegerTypeSuffix )? alt10 =3D 2 LA10_0 =3D self.input.LA(1) =20 - if (LA10_0 =3D=3D u'L' or LA10_0 =3D=3D u'U' or LA10_0 =3D=3D = u'l' or LA10_0 =3D=3D u'u') : + if (LA10_0 =3D=3D u'L' or LA10_0 =3D=3D u'U' or LA10_0 =3D=3D = u'l' or LA10_0 =3D=3D u'u'): alt10 =3D 1 if alt10 =3D=3D 1: # C.g:607:46: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end DECIMAL_LITERAL =20 - - # $ANTLR start OCTAL_LITERAL + def mOCTAL_LITERAL(self, ): =20 try: @@ -2662,83 +2051,65 @@ class CLexer(Lexer): =20 # C.g:609:21: ( '0' .. '7' )+ cnt11 =3D 0 - while True: #loop11 + while True: # loop11 alt11 =3D 2 LA11_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA11_0 <=3D u'7')) : + if ((u'0' <=3D LA11_0 <=3D u'7')): alt11 =3D 1 =20 - if alt11 =3D=3D 1: # C.g:609:22: '0' .. '7' self.matchRange(u'0', u'7') =20 - - else: if cnt11 >=3D 1: - break #loop11 + break # loop11 =20 eee =3D EarlyExitException(11, self.input) raise eee =20 cnt11 +=3D 1 =20 - # C.g:609:33: ( IntegerTypeSuffix )? alt12 =3D 2 LA12_0 =3D self.input.LA(1) =20 - if (LA12_0 =3D=3D u'L' or LA12_0 =3D=3D u'U' or LA12_0 =3D=3D = u'l' or LA12_0 =3D=3D u'u') : + if (LA12_0 =3D=3D u'L' or LA12_0 =3D=3D u'U' or LA12_0 =3D=3D = u'l' or LA12_0 =3D=3D u'u'): alt12 =3D 1 if alt12 =3D=3D 1: # C.g:609:33: IntegerTypeSuffix self.mIntegerTypeSuffix() =20 - - - - - - - finally: =20 pass =20 # $ANTLR end OCTAL_LITERAL =20 - - # $ANTLR start HexDigit + def mHexDigit(self, ): =20 try: # C.g:612:10: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) ) # C.g:612:12: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) if (u'0' <=3D self.input.LA(1) <=3D u'9') or (u'A' <=3D self.i= nput.LA(1) <=3D u'F') or (u'a' <=3D self.input.LA(1) <=3D u'f'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end HexDigit =20 - - # $ANTLR start IntegerTypeSuffix + def mIntegerTypeSuffix(self, ): =20 try: @@ -2746,114 +2117,98 @@ class CLexer(Lexer): alt13 =3D 4 LA13_0 =3D self.input.LA(1) =20 - if (LA13_0 =3D=3D u'U' or LA13_0 =3D=3D u'u') : + if (LA13_0 =3D=3D u'U' or LA13_0 =3D=3D u'u'): LA13_1 =3D self.input.LA(2) =20 - if (LA13_1 =3D=3D u'L' or LA13_1 =3D=3D u'l') : + if (LA13_1 =3D=3D u'L' or LA13_1 =3D=3D u'l'): LA13_3 =3D self.input.LA(3) =20 - if (LA13_3 =3D=3D u'L' or LA13_3 =3D=3D u'l') : + if (LA13_3 =3D=3D u'L' or LA13_3 =3D=3D u'l'): alt13 =3D 4 else: alt13 =3D 3 else: alt13 =3D 1 - elif (LA13_0 =3D=3D u'L' or LA13_0 =3D=3D u'l') : + elif (LA13_0 =3D=3D u'L' or LA13_0 =3D=3D u'l'): alt13 =3D 2 else: - nvae =3D NoViableAltException("614:1: fragment IntegerType= Suffix : ( ( 'u' | 'U' ) | ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) | ( = 'u' | 'U' ) ( 'l' | 'L' ) ( 'l' | 'L' ) );", 13, 0, self.input) + nvae =3D NoViableAltException( + "614:1: fragment IntegerTypeSuffix : ( ( 'u' | 'U' ) |= ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) | ( 'u' | 'U' ) ( 'l' | 'L' ) = ( 'l' | 'L' ) );", 13, 0, self.input) =20 raise nvae =20 if alt13 =3D=3D 1: # C.g:616:4: ( 'u' | 'U' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 2: # C.g:617:4: ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 3: # C.g:618:4: ( 'u' | 'U' ) ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt13 =3D=3D 4: # C.g:619:4: ( 'u' | 'U' ) ( 'l' | 'L' ) ( 'l' | 'L' ) if self.input.LA(1) =3D=3D u'U' or self.input.LA(1) =3D=3D= u'u': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - if self.input.LA(1) =3D=3D u'L' or self.input.LA(1) =3D=3D= u'l': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - finally: =20 pass =20 # $ANTLR end IntegerTypeSuffix =20 - - # $ANTLR start FLOATING_POINT_LITERAL + def mFLOATING_POINT_LITERAL(self, ): =20 try: @@ -2866,337 +2221,269 @@ class CLexer(Lexer): # C.g:623:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( Exponen= t )? ( FloatTypeSuffix )? # C.g:623:9: ( '0' .. '9' )+ cnt14 =3D 0 - while True: #loop14 + while True: # loop14 alt14 =3D 2 LA14_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA14_0 <=3D u'9')) : + if ((u'0' <=3D LA14_0 <=3D u'9')): alt14 =3D 1 =20 - if alt14 =3D=3D 1: # C.g:623:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt14 >=3D 1: - break #loop14 + break # loop14 =20 eee =3D EarlyExitException(14, self.input) raise eee =20 cnt14 +=3D 1 =20 - self.match(u'.') =20 # C.g:623:25: ( '0' .. '9' )* - while True: #loop15 + while True: # loop15 alt15 =3D 2 LA15_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA15_0 <=3D u'9')) : + if ((u'0' <=3D LA15_0 <=3D u'9')): alt15 =3D 1 =20 - if alt15 =3D=3D 1: # C.g:623:26: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: - break #loop15 - + break # loop15 =20 # C.g:623:37: ( Exponent )? alt16 =3D 2 LA16_0 =3D self.input.LA(1) =20 - if (LA16_0 =3D=3D u'E' or LA16_0 =3D=3D u'e') : + if (LA16_0 =3D=3D u'E' or LA16_0 =3D=3D u'e'): alt16 =3D 1 if alt16 =3D=3D 1: # C.g:623:37: Exponent self.mExponent() =20 - - - # C.g:623:47: ( FloatTypeSuffix )? alt17 =3D 2 LA17_0 =3D self.input.LA(1) =20 - if (LA17_0 =3D=3D u'D' or LA17_0 =3D=3D u'F' or LA17_0 =3D= =3D u'd' or LA17_0 =3D=3D u'f') : + if (LA17_0 =3D=3D u'D' or LA17_0 =3D=3D u'F' or LA17_0 =3D= =3D u'd' or LA17_0 =3D=3D u'f'): alt17 =3D 1 if alt17 =3D=3D 1: # C.g:623:47: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 2: # C.g:624:9: '.' ( '0' .. '9' )+ ( Exponent )? ( FloatType= Suffix )? self.match(u'.') =20 # C.g:624:13: ( '0' .. '9' )+ cnt18 =3D 0 - while True: #loop18 + while True: # loop18 alt18 =3D 2 LA18_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA18_0 <=3D u'9')) : + if ((u'0' <=3D LA18_0 <=3D u'9')): alt18 =3D 1 =20 - if alt18 =3D=3D 1: # C.g:624:14: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt18 >=3D 1: - break #loop18 + break # loop18 =20 eee =3D EarlyExitException(18, self.input) raise eee =20 cnt18 +=3D 1 =20 - # C.g:624:25: ( Exponent )? alt19 =3D 2 LA19_0 =3D self.input.LA(1) =20 - if (LA19_0 =3D=3D u'E' or LA19_0 =3D=3D u'e') : + if (LA19_0 =3D=3D u'E' or LA19_0 =3D=3D u'e'): alt19 =3D 1 if alt19 =3D=3D 1: # C.g:624:25: Exponent self.mExponent() =20 - - - # C.g:624:35: ( FloatTypeSuffix )? alt20 =3D 2 LA20_0 =3D self.input.LA(1) =20 - if (LA20_0 =3D=3D u'D' or LA20_0 =3D=3D u'F' or LA20_0 =3D= =3D u'd' or LA20_0 =3D=3D u'f') : + if (LA20_0 =3D=3D u'D' or LA20_0 =3D=3D u'F' or LA20_0 =3D= =3D u'd' or LA20_0 =3D=3D u'f'): alt20 =3D 1 if alt20 =3D=3D 1: # C.g:624:35: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 3: # C.g:625:9: ( '0' .. '9' )+ Exponent ( FloatTypeSuffix )? # C.g:625:9: ( '0' .. '9' )+ cnt21 =3D 0 - while True: #loop21 + while True: # loop21 alt21 =3D 2 LA21_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA21_0 <=3D u'9')) : + if ((u'0' <=3D LA21_0 <=3D u'9')): alt21 =3D 1 =20 - if alt21 =3D=3D 1: # C.g:625:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt21 >=3D 1: - break #loop21 + break # loop21 =20 eee =3D EarlyExitException(21, self.input) raise eee =20 cnt21 +=3D 1 =20 - self.mExponent() =20 # C.g:625:30: ( FloatTypeSuffix )? alt22 =3D 2 LA22_0 =3D self.input.LA(1) =20 - if (LA22_0 =3D=3D u'D' or LA22_0 =3D=3D u'F' or LA22_0 =3D= =3D u'd' or LA22_0 =3D=3D u'f') : + if (LA22_0 =3D=3D u'D' or LA22_0 =3D=3D u'F' or LA22_0 =3D= =3D u'd' or LA22_0 =3D=3D u'f'): alt22 =3D 1 if alt22 =3D=3D 1: # C.g:625:30: FloatTypeSuffix self.mFloatTypeSuffix() =20 - - - - - elif alt25 =3D=3D 4: # C.g:626:9: ( '0' .. '9' )+ ( Exponent )? FloatTypeSuffix # C.g:626:9: ( '0' .. '9' )+ cnt23 =3D 0 - while True: #loop23 + while True: # loop23 alt23 =3D 2 LA23_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA23_0 <=3D u'9')) : + if ((u'0' <=3D LA23_0 <=3D u'9')): alt23 =3D 1 =20 - if alt23 =3D=3D 1: # C.g:626:10: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt23 >=3D 1: - break #loop23 + break # loop23 =20 eee =3D EarlyExitException(23, self.input) raise eee =20 cnt23 +=3D 1 =20 - # C.g:626:21: ( Exponent )? alt24 =3D 2 LA24_0 =3D self.input.LA(1) =20 - if (LA24_0 =3D=3D u'E' or LA24_0 =3D=3D u'e') : + if (LA24_0 =3D=3D u'E' or LA24_0 =3D=3D u'e'): alt24 =3D 1 if alt24 =3D=3D 1: # C.g:626:21: Exponent self.mExponent() =20 - - - self.mFloatTypeSuffix() =20 - - - finally: =20 pass =20 # $ANTLR end FLOATING_POINT_LITERAL =20 - - # $ANTLR start Exponent + def mExponent(self, ): =20 try: # C.g:630:10: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ ) # C.g:630:12: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ if self.input.LA(1) =3D=3D u'E' or self.input.LA(1) =3D=3D u'e= ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - # C.g:630:22: ( '+' | '-' )? alt26 =3D 2 LA26_0 =3D self.input.LA(1) =20 - if (LA26_0 =3D=3D u'+' or LA26_0 =3D=3D u'-') : + if (LA26_0 =3D=3D u'+' or LA26_0 =3D=3D u'-'): alt26 =3D 1 if alt26 =3D=3D 1: # C.g: if self.input.LA(1) =3D=3D u'+' or self.input.LA(1) =3D=3D= u'-': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - # C.g:630:33: ( '0' .. '9' )+ cnt27 =3D 0 - while True: #loop27 + while True: # loop27 alt27 =3D 2 LA27_0 =3D self.input.LA(1) =20 - if ((u'0' <=3D LA27_0 <=3D u'9')) : + if ((u'0' <=3D LA27_0 <=3D u'9')): alt27 =3D 1 =20 - if alt27 =3D=3D 1: # C.g:630:34: '0' .. '9' self.matchRange(u'0', u'9') =20 - - else: if cnt27 >=3D 1: - break #loop27 + break # loop27 =20 eee =3D EarlyExitException(27, self.input) raise eee =20 cnt27 +=3D 1 =20 - - - - - finally: =20 pass =20 # $ANTLR end Exponent =20 - - # $ANTLR start FloatTypeSuffix + def mFloatTypeSuffix(self, ): =20 try: # C.g:633:17: ( ( 'f' | 'F' | 'd' | 'D' ) ) # C.g:633:19: ( 'f' | 'F' | 'd' | 'D' ) if self.input.LA(1) =3D=3D u'D' or self.input.LA(1) =3D=3D u'F= ' or self.input.LA(1) =3D=3D u'd' or self.input.LA(1) =3D=3D u'f': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - - - finally: =20 pass =20 # $ANTLR end FloatTypeSuffix =20 - - # $ANTLR start EscapeSequence + def mEscapeSequence(self, ): =20 try: @@ -3204,20 +2491,22 @@ class CLexer(Lexer): alt28 =3D 2 LA28_0 =3D self.input.LA(1) =20 - if (LA28_0 =3D=3D u'\\') : + if (LA28_0 =3D=3D u'\\'): LA28_1 =3D self.input.LA(2) =20 - if (LA28_1 =3D=3D u'"' or LA28_1 =3D=3D u'\'' or LA28_1 = =3D=3D u'\\' or LA28_1 =3D=3D u'b' or LA28_1 =3D=3D u'f' or LA28_1 =3D=3D u= 'n' or LA28_1 =3D=3D u'r' or LA28_1 =3D=3D u't') : + if (LA28_1 =3D=3D u'"' or LA28_1 =3D=3D u'\'' or LA28_1 = =3D=3D u'\\' or LA28_1 =3D=3D u'b' or LA28_1 =3D=3D u'f' or LA28_1 =3D=3D u= 'n' or LA28_1 =3D=3D u'r' or LA28_1 =3D=3D u't'): alt28 =3D 1 - elif ((u'0' <=3D LA28_1 <=3D u'7')) : + elif ((u'0' <=3D LA28_1 <=3D u'7')): alt28 =3D 2 else: - nvae =3D NoViableAltException("635:1: fragment EscapeS= equence : ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' = ) | OctalEscape );", 28, 1, self.input) + nvae =3D NoViableAltException( + "635:1: fragment EscapeSequence : ( '\\\\' ( 'b' |= 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | OctalEscape );", 28, 1= , self.input) =20 raise nvae =20 else: - nvae =3D NoViableAltException("635:1: fragment EscapeSeque= nce : ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | = OctalEscape );", 28, 0, self.input) + nvae =3D NoViableAltException( + "635:1: fragment EscapeSequence : ( '\\\\' ( 'b' | 't'= | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | OctalEscape );", 28, 0, se= lf.input) =20 raise nvae =20 @@ -3226,32 +2515,25 @@ class CLexer(Lexer): self.match(u'\\') =20 if self.input.LA(1) =3D=3D u'"' or self.input.LA(1) =3D=3D= u'\'' or self.input.LA(1) =3D=3D u'\\' or self.input.LA(1) =3D=3D u'b' or = self.input.LA(1) =3D=3D u'f' or self.input.LA(1) =3D=3D u'n' or self.input.= LA(1) =3D=3D u'r' or self.input.LA(1) =3D=3D u't': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - elif alt28 =3D=3D 2: # C.g:638:9: OctalEscape self.mOctalEscape() =20 - - - finally: =20 pass =20 # $ANTLR end EscapeSequence =20 - - # $ANTLR start OctalEscape + def mOctalEscape(self, ): =20 try: @@ -3259,35 +2541,37 @@ class CLexer(Lexer): alt29 =3D 3 LA29_0 =3D self.input.LA(1) =20 - if (LA29_0 =3D=3D u'\\') : + if (LA29_0 =3D=3D u'\\'): LA29_1 =3D self.input.LA(2) =20 - if ((u'0' <=3D LA29_1 <=3D u'3')) : + if ((u'0' <=3D LA29_1 <=3D u'3')): LA29_2 =3D self.input.LA(3) =20 - if ((u'0' <=3D LA29_2 <=3D u'7')) : + if ((u'0' <=3D LA29_2 <=3D u'7')): LA29_4 =3D self.input.LA(4) =20 - if ((u'0' <=3D LA29_4 <=3D u'7')) : + if ((u'0' <=3D LA29_4 <=3D u'7')): alt29 =3D 1 else: alt29 =3D 2 else: alt29 =3D 3 - elif ((u'4' <=3D LA29_1 <=3D u'7')) : + elif ((u'4' <=3D LA29_1 <=3D u'7')): LA29_3 =3D self.input.LA(3) =20 - if ((u'0' <=3D LA29_3 <=3D u'7')) : + if ((u'0' <=3D LA29_3 <=3D u'7')): alt29 =3D 2 else: alt29 =3D 3 else: - nvae =3D NoViableAltException("641:1: fragment OctalEs= cape : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0'= .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );", 29, 1, self.input) + nvae =3D NoViableAltException( + "641:1: fragment OctalEscape : ( '\\\\' ( '0' .. '= 3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) |= '\\\\' ( '0' .. '7' ) );", 29, 1, self.input) =20 raise nvae =20 else: - nvae =3D NoViableAltException("641:1: fragment OctalEscape= : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. = '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );", 29, 0, self.input) + nvae =3D NoViableAltException( + "641:1: fragment OctalEscape : ( '\\\\' ( '0' .. '3' )= ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\= \\' ( '0' .. '7' ) );", 29, 0, self.input) =20 raise nvae =20 @@ -3299,25 +2583,14 @@ class CLexer(Lexer): # C.g:643:15: '0' .. '3' self.matchRange(u'0', u'3') =20 - - - # C.g:643:25: ( '0' .. '7' ) # C.g:643:26: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - # C.g:643:36: ( '0' .. '7' ) # C.g:643:37: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - elif alt29 =3D=3D 2: # C.g:644:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) self.match(u'\\') @@ -3326,18 +2599,10 @@ class CLexer(Lexer): # C.g:644:15: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - # C.g:644:25: ( '0' .. '7' ) # C.g:644:26: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - elif alt29 =3D=3D 3: # C.g:645:9: '\\\\' ( '0' .. '7' ) self.match(u'\\') @@ -3346,21 +2611,14 @@ class CLexer(Lexer): # C.g:645:15: '0' .. '7' self.matchRange(u'0', u'7') =20 - - - - - - finally: =20 pass =20 # $ANTLR end OctalEscape =20 - - # $ANTLR start UnicodeEscape + def mUnicodeEscape(self, ): =20 try: @@ -3378,19 +2636,14 @@ class CLexer(Lexer): =20 self.mHexDigit() =20 - - - - finally: =20 pass =20 # $ANTLR end UnicodeEscape =20 - - # $ANTLR start WS + def mWS(self, ): =20 try: @@ -3399,20 +2652,16 @@ class CLexer(Lexer): # C.g:653:5: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) # C.g:653:8: ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) if (u'\t' <=3D self.input.LA(1) <=3D u'\n') or (u'\f' <=3D sel= f.input.LA(1) <=3D u'\r') or self.input.LA(1) =3D=3D u' ': - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3420,9 +2669,8 @@ class CLexer(Lexer): =20 # $ANTLR end WS =20 - - # $ANTLR start BS + def mBS(self, ): =20 try: @@ -3434,15 +2682,9 @@ class CLexer(Lexer): # C.g:657:8: '\\\\' self.match(u'\\') =20 - - - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3450,9 +2692,8 @@ class CLexer(Lexer): =20 # $ANTLR end BS =20 - - # $ANTLR start UnicodeVocabulary + def mUnicodeVocabulary(self, ): =20 try: @@ -3462,19 +2703,14 @@ class CLexer(Lexer): # C.g:665:7: '\\u0003' .. '\\uFFFE' self.matchRange(u'\u0003', u'\uFFFE') =20 - - - - finally: =20 pass =20 # $ANTLR end UnicodeVocabulary =20 - - # $ANTLR start COMMENT + def mCOMMENT(self, ): =20 try: @@ -3484,44 +2720,34 @@ class CLexer(Lexer): # C.g:668:9: '/*' ( options {greedy=3Dfalse; } : . )* '*/' self.match("/*") =20 - # C.g:668:14: ( options {greedy=3Dfalse; } : . )* - while True: #loop30 + while True: # loop30 alt30 =3D 2 LA30_0 =3D self.input.LA(1) =20 - if (LA30_0 =3D=3D u'*') : + if (LA30_0 =3D=3D u'*'): LA30_1 =3D self.input.LA(2) =20 - if (LA30_1 =3D=3D u'/') : + if (LA30_1 =3D=3D u'/'): alt30 =3D 2 - elif ((u'\u0000' <=3D LA30_1 <=3D u'.') or (u'0' <=3D = LA30_1 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA30_1 <=3D u'.') or (u'0' <=3D = LA30_1 <=3D u'\uFFFE')): alt30 =3D 1 =20 - - elif ((u'\u0000' <=3D LA30_0 <=3D u')') or (u'+' <=3D LA30= _0 <=3D u'\uFFFE')) : + elif ((u'\u0000' <=3D LA30_0 <=3D u')') or (u'+' <=3D LA30= _0 <=3D u'\uFFFE')): alt30 =3D 1 =20 - if alt30 =3D=3D 1: # C.g:668:42: . self.matchAny() =20 - - else: - break #loop30 - + break # loop30 =20 self.match("*/") =20 - - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3529,9 +2755,8 @@ class CLexer(Lexer): =20 # $ANTLR end COMMENT =20 - - # $ANTLR start LINE_COMMENT + def mLINE_COMMENT(self, ): =20 try: @@ -3541,54 +2766,42 @@ class CLexer(Lexer): # C.g:673:7: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' self.match("//") =20 - # C.g:673:12: (~ ( '\\n' | '\\r' ) )* - while True: #loop31 + while True: # loop31 alt31 =3D 2 LA31_0 =3D self.input.LA(1) =20 - if ((u'\u0000' <=3D LA31_0 <=3D u'\t') or (u'\u000B' <=3D = LA31_0 <=3D u'\f') or (u'\u000E' <=3D LA31_0 <=3D u'\uFFFE')) : + if ((u'\u0000' <=3D LA31_0 <=3D u'\t') or (u'\u000B' <=3D = LA31_0 <=3D u'\f') or (u'\u000E' <=3D LA31_0 <=3D u'\uFFFE')): alt31 =3D 1 =20 - if alt31 =3D=3D 1: # C.g:673:12: ~ ( '\\n' | '\\r' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'\t') or (u'= \u000B' <=3D self.input.LA(1) <=3D u'\f') or (u'\u000E' <=3D self.input.LA(= 1) <=3D u'\uFFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop31 - + break # loop31 =20 # C.g:673:26: ( '\\r' )? alt32 =3D 2 LA32_0 =3D self.input.LA(1) =20 - if (LA32_0 =3D=3D u'\r') : + if (LA32_0 =3D=3D u'\r'): alt32 =3D 1 if alt32 =3D=3D 1: # C.g:673:26: '\\r' self.match(u'\r') =20 - - - self.match(u'\n') =20 - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3596,9 +2809,8 @@ class CLexer(Lexer): =20 # $ANTLR end LINE_COMMENT =20 - - # $ANTLR start LINE_COMMAND + def mLINE_COMMAND(self, ): =20 try: @@ -3609,52 +2821,41 @@ class CLexer(Lexer): self.match(u'#') =20 # C.g:678:11: (~ ( '\\n' | '\\r' ) )* - while True: #loop33 + while True: # loop33 alt33 =3D 2 LA33_0 =3D self.input.LA(1) =20 - if ((u'\u0000' <=3D LA33_0 <=3D u'\t') or (u'\u000B' <=3D = LA33_0 <=3D u'\f') or (u'\u000E' <=3D LA33_0 <=3D u'\uFFFE')) : + if ((u'\u0000' <=3D LA33_0 <=3D u'\t') or (u'\u000B' <=3D = LA33_0 <=3D u'\f') or (u'\u000E' <=3D LA33_0 <=3D u'\uFFFE')): alt33 =3D 1 =20 - if alt33 =3D=3D 1: # C.g:678:11: ~ ( '\\n' | '\\r' ) if (u'\u0000' <=3D self.input.LA(1) <=3D u'\t') or (u'= \u000B' <=3D self.input.LA(1) <=3D u'\f') or (u'\u000E' <=3D self.input.LA(= 1) <=3D u'\uFFFE'): - self.input.consume(); + self.input.consume() =20 else: mse =3D MismatchedSetException(None, self.input) self.recover(mse) raise mse =20 - - - else: - break #loop33 - + break # loop33 =20 # C.g:678:25: ( '\\r' )? alt34 =3D 2 LA34_0 =3D self.input.LA(1) =20 - if (LA34_0 =3D=3D u'\r') : + if (LA34_0 =3D=3D u'\r'): alt34 =3D 1 if alt34 =3D=3D 1: # C.g:678:25: '\\r' self.match(u'\r') =20 - - - self.match(u'\n') =20 - #action start - self.channel=3DHIDDEN; - #action end - - - + # action start + self.channel =3D HIDDEN + # action end =20 finally: =20 @@ -3662,8 +2863,6 @@ class CLexer(Lexer): =20 # $ANTLR end LINE_COMMAND =20 - - def mTokens(self): # C.g:1:8: ( T25 | T26 | T27 | T28 | T29 | T30 | T31 | T32 | T33 |= T34 | T35 | T36 | T37 | T38 | T39 | T40 | T41 | T42 | T43 | T44 | T45 | T4= 6 | T47 | T48 | T49 | T50 | T51 | T52 | T53 | T54 | T55 | T56 | T57 | T58 |= T59 | T60 | T61 | T62 | T63 | T64 | T65 | T66 | T67 | T68 | T69 | T70 | T7= 1 | T72 | T73 | T74 | T75 | T76 | T77 | T78 | T79 | T80 | T81 | T82 | T83 |= T84 | T85 | T86 | T87 | T88 | T89 | T90 | T91 | T92 | T93 | T94 | T95 | T9= 6 | T97 | T98 | T99 | T100 | T101 | T102 | T103 | T104 | T105 | T106 | T107= | T108 | T109 | T110 | T111 | T112 | T113 | T114 | T115 | T116 | T117 | ID= ENTIFIER | CHARACTER_LITERAL | STRING_LITERAL | HEX_LITERAL | DECIMAL_LITER= AL | OCTAL_LITERAL | FLOATING_POINT_LITERAL | WS | BS | UnicodeVocabulary |= COMMENT | LINE_COMMENT | LINE_COMMAND ) alt35 =3D 106 @@ -3672,681 +2871,463 @@ class CLexer(Lexer): # C.g:1:10: T25 self.mT25() =20 - - elif alt35 =3D=3D 2: # C.g:1:14: T26 self.mT26() =20 - - elif alt35 =3D=3D 3: # C.g:1:18: T27 self.mT27() =20 - - elif alt35 =3D=3D 4: # C.g:1:22: T28 self.mT28() =20 - - elif alt35 =3D=3D 5: # C.g:1:26: T29 self.mT29() =20 - - elif alt35 =3D=3D 6: # C.g:1:30: T30 self.mT30() =20 - - elif alt35 =3D=3D 7: # C.g:1:34: T31 self.mT31() =20 - - elif alt35 =3D=3D 8: # C.g:1:38: T32 self.mT32() =20 - - elif alt35 =3D=3D 9: # C.g:1:42: T33 self.mT33() =20 - - elif alt35 =3D=3D 10: # C.g:1:46: T34 self.mT34() =20 - - elif alt35 =3D=3D 11: # C.g:1:50: T35 self.mT35() =20 - - elif alt35 =3D=3D 12: # C.g:1:54: T36 self.mT36() =20 - - elif alt35 =3D=3D 13: # C.g:1:58: T37 self.mT37() =20 - - elif alt35 =3D=3D 14: # C.g:1:62: T38 self.mT38() =20 - - elif alt35 =3D=3D 15: # C.g:1:66: T39 self.mT39() =20 - - elif alt35 =3D=3D 16: # C.g:1:70: T40 self.mT40() =20 - - elif alt35 =3D=3D 17: # C.g:1:74: T41 self.mT41() =20 - - elif alt35 =3D=3D 18: # C.g:1:78: T42 self.mT42() =20 - - elif alt35 =3D=3D 19: # C.g:1:82: T43 self.mT43() =20 - - elif alt35 =3D=3D 20: # C.g:1:86: T44 self.mT44() =20 - - elif alt35 =3D=3D 21: # C.g:1:90: T45 self.mT45() =20 - - elif alt35 =3D=3D 22: # C.g:1:94: T46 self.mT46() =20 - - elif alt35 =3D=3D 23: # C.g:1:98: T47 self.mT47() =20 - - elif alt35 =3D=3D 24: # C.g:1:102: T48 self.mT48() =20 - - elif alt35 =3D=3D 25: # C.g:1:106: T49 self.mT49() =20 - - elif alt35 =3D=3D 26: # C.g:1:110: T50 self.mT50() =20 - - elif alt35 =3D=3D 27: # C.g:1:114: T51 self.mT51() =20 - - elif alt35 =3D=3D 28: # C.g:1:118: T52 self.mT52() =20 - - elif alt35 =3D=3D 29: # C.g:1:122: T53 self.mT53() =20 - - elif alt35 =3D=3D 30: # C.g:1:126: T54 self.mT54() =20 - - elif alt35 =3D=3D 31: # C.g:1:130: T55 self.mT55() =20 - - elif alt35 =3D=3D 32: # C.g:1:134: T56 self.mT56() =20 - - elif alt35 =3D=3D 33: # C.g:1:138: T57 self.mT57() =20 - - elif alt35 =3D=3D 34: # C.g:1:142: T58 self.mT58() =20 - - elif alt35 =3D=3D 35: # C.g:1:146: T59 self.mT59() =20 - - elif alt35 =3D=3D 36: # C.g:1:150: T60 self.mT60() =20 - - elif alt35 =3D=3D 37: # C.g:1:154: T61 self.mT61() =20 - - elif alt35 =3D=3D 38: # C.g:1:158: T62 self.mT62() =20 - - elif alt35 =3D=3D 39: # C.g:1:162: T63 self.mT63() =20 - - elif alt35 =3D=3D 40: # C.g:1:166: T64 self.mT64() =20 - - elif alt35 =3D=3D 41: # C.g:1:170: T65 self.mT65() =20 - - elif alt35 =3D=3D 42: # C.g:1:174: T66 self.mT66() =20 - - elif alt35 =3D=3D 43: # C.g:1:178: T67 self.mT67() =20 - - elif alt35 =3D=3D 44: # C.g:1:182: T68 self.mT68() =20 - - elif alt35 =3D=3D 45: # C.g:1:186: T69 self.mT69() =20 - - elif alt35 =3D=3D 46: # C.g:1:190: T70 self.mT70() =20 - - elif alt35 =3D=3D 47: # C.g:1:194: T71 self.mT71() =20 - - elif alt35 =3D=3D 48: # C.g:1:198: T72 self.mT72() =20 - - elif alt35 =3D=3D 49: # C.g:1:202: T73 self.mT73() =20 - - elif alt35 =3D=3D 50: # C.g:1:206: T74 self.mT74() =20 - - elif alt35 =3D=3D 51: # C.g:1:210: T75 self.mT75() =20 - - elif alt35 =3D=3D 52: # C.g:1:214: T76 self.mT76() =20 - - elif alt35 =3D=3D 53: # C.g:1:218: T77 self.mT77() =20 - - elif alt35 =3D=3D 54: # C.g:1:222: T78 self.mT78() =20 - - elif alt35 =3D=3D 55: # C.g:1:226: T79 self.mT79() =20 - - elif alt35 =3D=3D 56: # C.g:1:230: T80 self.mT80() =20 - - elif alt35 =3D=3D 57: # C.g:1:234: T81 self.mT81() =20 - - elif alt35 =3D=3D 58: # C.g:1:238: T82 self.mT82() =20 - - elif alt35 =3D=3D 59: # C.g:1:242: T83 self.mT83() =20 - - elif alt35 =3D=3D 60: # C.g:1:246: T84 self.mT84() =20 - - elif alt35 =3D=3D 61: # C.g:1:250: T85 self.mT85() =20 - - elif alt35 =3D=3D 62: # C.g:1:254: T86 self.mT86() =20 - - elif alt35 =3D=3D 63: # C.g:1:258: T87 self.mT87() =20 - - elif alt35 =3D=3D 64: # C.g:1:262: T88 self.mT88() =20 - - elif alt35 =3D=3D 65: # C.g:1:266: T89 self.mT89() =20 - - elif alt35 =3D=3D 66: # C.g:1:270: T90 self.mT90() =20 - - elif alt35 =3D=3D 67: # C.g:1:274: T91 self.mT91() =20 - - elif alt35 =3D=3D 68: # C.g:1:278: T92 self.mT92() =20 - - elif alt35 =3D=3D 69: # C.g:1:282: T93 self.mT93() =20 - - elif alt35 =3D=3D 70: # C.g:1:286: T94 self.mT94() =20 - - elif alt35 =3D=3D 71: # C.g:1:290: T95 self.mT95() =20 - - elif alt35 =3D=3D 72: # C.g:1:294: T96 self.mT96() =20 - - elif alt35 =3D=3D 73: # C.g:1:298: T97 self.mT97() =20 - - elif alt35 =3D=3D 74: # C.g:1:302: T98 self.mT98() =20 - - elif alt35 =3D=3D 75: # C.g:1:306: T99 self.mT99() =20 - - elif alt35 =3D=3D 76: # C.g:1:310: T100 self.mT100() =20 - - elif alt35 =3D=3D 77: # C.g:1:315: T101 self.mT101() =20 - - elif alt35 =3D=3D 78: # C.g:1:320: T102 self.mT102() =20 - - elif alt35 =3D=3D 79: # C.g:1:325: T103 self.mT103() =20 - - elif alt35 =3D=3D 80: # C.g:1:330: T104 self.mT104() =20 - - elif alt35 =3D=3D 81: # C.g:1:335: T105 self.mT105() =20 - - elif alt35 =3D=3D 82: # C.g:1:340: T106 self.mT106() =20 - - elif alt35 =3D=3D 83: # C.g:1:345: T107 self.mT107() =20 - - elif alt35 =3D=3D 84: # C.g:1:350: T108 self.mT108() =20 - - elif alt35 =3D=3D 85: # C.g:1:355: T109 self.mT109() =20 - - elif alt35 =3D=3D 86: # C.g:1:360: T110 self.mT110() =20 - - elif alt35 =3D=3D 87: # C.g:1:365: T111 self.mT111() =20 - - elif alt35 =3D=3D 88: # C.g:1:370: T112 self.mT112() =20 - - elif alt35 =3D=3D 89: # C.g:1:375: T113 self.mT113() =20 - - elif alt35 =3D=3D 90: # C.g:1:380: T114 self.mT114() =20 - - elif alt35 =3D=3D 91: # C.g:1:385: T115 self.mT115() =20 - - elif alt35 =3D=3D 92: # C.g:1:390: T116 self.mT116() =20 - - elif alt35 =3D=3D 93: # C.g:1:395: T117 self.mT117() =20 - - elif alt35 =3D=3D 94: # C.g:1:400: IDENTIFIER self.mIDENTIFIER() =20 - - elif alt35 =3D=3D 95: # C.g:1:411: CHARACTER_LITERAL self.mCHARACTER_LITERAL() =20 - - elif alt35 =3D=3D 96: # C.g:1:429: STRING_LITERAL self.mSTRING_LITERAL() =20 - - elif alt35 =3D=3D 97: # C.g:1:444: HEX_LITERAL self.mHEX_LITERAL() =20 - - elif alt35 =3D=3D 98: # C.g:1:456: DECIMAL_LITERAL self.mDECIMAL_LITERAL() =20 - - elif alt35 =3D=3D 99: # C.g:1:472: OCTAL_LITERAL self.mOCTAL_LITERAL() =20 - - elif alt35 =3D=3D 100: # C.g:1:486: FLOATING_POINT_LITERAL self.mFLOATING_POINT_LITERAL() =20 - - elif alt35 =3D=3D 101: # C.g:1:509: WS self.mWS() =20 - - elif alt35 =3D=3D 102: # C.g:1:512: BS self.mBS() =20 - - elif alt35 =3D=3D 103: # C.g:1:515: UnicodeVocabulary self.mUnicodeVocabulary() =20 - - elif alt35 =3D=3D 104: # C.g:1:533: COMMENT self.mCOMMENT() =20 - - elif alt35 =3D=3D 105: # C.g:1:541: LINE_COMMENT self.mLINE_COMMENT() =20 - - elif alt35 =3D=3D 106: # C.g:1:554: LINE_COMMAND self.mLINE_COMMAND() =20 - - - - - - - # lookup tables for DFA #25 =20 DFA25_eot =3D DFA.unpack( u"\7\uffff\1\10\2\uffff" - ) + ) =20 DFA25_eof =3D DFA.unpack( u"\12\uffff" - ) + ) =20 DFA25_min =3D DFA.unpack( u"\2\56\2\uffff\1\53\1\uffff\2\60\2\uffff" - ) + ) =20 DFA25_max =3D DFA.unpack( u"\1\71\1\146\2\uffff\1\71\1\uffff\1\71\1\146\2\uffff" - ) + ) =20 DFA25_accept =3D DFA.unpack( u"\2\uffff\1\2\1\1\1\uffff\1\4\2\uffff\2\3" - ) + ) =20 DFA25_special =3D DFA.unpack( u"\12\uffff" - ) - + ) =20 DFA25_transition =3D [ DFA.unpack(u"\1\2\1\uffff\12\1"), DFA.unpack(u"\1\3\1\uffff\12\1\12\uffff\1\5\1\4\1\5\35\uffff\1\5" - u"\1\4\1\5"), + u"\1\4\1\5"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\6\1\uffff\1\6\2\uffff\12\7"), DFA.unpack(u""), DFA.unpack(u"\12\7"), DFA.unpack(u"\12\7\12\uffff\1\11\1\uffff\1\11\35\uffff\1\11\1\ufff= f" - u"\1\11"), + u"\1\11"), DFA.unpack(u""), DFA.unpack(u"") ] @@ -4376,11 +3357,11 @@ class CLexer(Lexer): u"\uffff\1\u0164\1\u0165\1\76\1\u0167\3\76\6\uffff\1\u016b\1\uffff" u"\3\76\1\uffff\21\76\1\u0180\2\76\1\uffff\3\76\1\u0186\1\76\1\uff= ff" u"\11\76\1\u0191\1\uffff" - ) + ) =20 DFA35_eof =3D DFA.unpack( u"\u0192\uffff" - ) + ) =20 DFA35_min =3D DFA.unpack( u"\1\3\1\uffff\1\171\1\uffff\1\75\1\154\1\150\1\165\1\145\1\124\1" @@ -4413,7 +3394,7 @@ class CLexer(Lexer): u"\1\111\1\137\1\122\1\103\1\111\1\126\1\105\1\106\1\111\1\44\1\13= 7" u"\1\103\1\uffff\1\125\1\105\1\116\1\44\1\122\1\uffff\1\105\1\106" u"\1\105\1\122\1\105\1\116\1\103\1\105\1\104\1\44\1\uffff" - ) + ) =20 DFA35_max =3D DFA.unpack( u"\1\ufffe\1\uffff\1\171\1\uffff\1\75\1\170\1\167\1\165\1\145\1\12= 4" @@ -4447,7 +3428,7 @@ class CLexer(Lexer): u"\1\106\1\111\1\172\1\137\1\103\1\uffff\1\125\1\105\1\116\1\172" u"\1\122\1\uffff\1\105\1\106\1\105\1\122\1\105\1\116\1\103\1\105" u"\1\104\1\172\1\uffff" - ) + ) =20 DFA35_accept =3D DFA.unpack( u"\1\uffff\1\1\1\uffff\1\3\15\uffff\1\23\1\24\1\27\10\uffff\1\46" @@ -4467,21 +3448,20 @@ class CLexer(Lexer): u"\uffff\1\42\1\45\1\uffff\1\2\3\uffff\1\123\7\uffff\1\117\1\10\1" u"\32\1\133\1\22\1\35\1\uffff\1\40\3\uffff\1\37\24\uffff\1\43\5\uf= fff" u"\1\44\12\uffff\1\41" - ) + ) =20 DFA35_special =3D DFA.unpack( u"\u0192\uffff" - ) - + ) =20 DFA35_transition =3D [ DFA.unpack(u"\6\73\2\70\1\73\2\70\22\73\1\70\1\50\1\65\1\72\1\63" - u"\1\45\1\46\1\64\1\34\1\35\1\40\1\42\1\3\1\43\1\41\1\44\1\66\11" - u"\67\1\23\1\1\1\51\1\4\1\52\1\55\1\73\2\63\1\26\1\63\1\32\1\63\1" - u"\31\1\63\1\24\2\63\1\62\2\63\1\25\1\33\2\63\1\11\1\63\1\27\1\30" - u"\4\63\1\36\1\71\1\37\1\53\1\56\1\73\1\7\1\61\1\13\1\17\1\5\1\16" - u"\1\60\1\63\1\14\2\63\1\15\5\63\1\10\1\6\1\2\1\20\1\12\1\57\3\63" - u"\1\21\1\54\1\22\1\47\uff80\73"), + u"\1\45\1\46\1\64\1\34\1\35\1\40\1\42\1\3\1\43\1\41\1\4= 4\1\66\11" + u"\67\1\23\1\1\1\51\1\4\1\52\1\55\1\73\2\63\1\26\1\63\1= \32\1\63\1" + u"\31\1\63\1\24\2\63\1\62\2\63\1\25\1\33\2\63\1\11\1\63= \1\27\1\30" + u"\4\63\1\36\1\71\1\37\1\53\1\56\1\73\1\7\1\61\1\13\1\1= 7\1\5\1\16" + u"\1\60\1\63\1\14\2\63\1\15\5\63\1\10\1\6\1\2\1\20\1\12= \1\57\3\63" + u"\1\21\1\54\1\22\1\47\uff80\73"), DFA.unpack(u""), DFA.unpack(u"\1\75"), DFA.unpack(u""), @@ -4536,7 +3516,7 @@ class CLexer(Lexer): DFA.unpack(u"\47\u0092\1\uffff\uffd7\u0092"), DFA.unpack(u"\uffff\u0091"), DFA.unpack(u"\1\154\1\uffff\10\u0094\2\154\12\uffff\3\154\21\uffff" - u"\1\u0093\13\uffff\3\154\21\uffff\1\u0093"), + u"\1\u0093\13\uffff\3\154\21\uffff\1\u0093"), DFA.unpack(u"\1\154\1\uffff\12\u0096\12\uffff\3\154\35\uffff\3\154= "), DFA.unpack(u""), DFA.unpack(u""), @@ -4563,20 +3543,20 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00ab"), DFA.unpack(u"\1\u00ac"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00ae"), DFA.unpack(u"\1\u00af"), DFA.unpack(u"\1\u00b0"), DFA.unpack(u"\1\u00b1"), DFA.unpack(u"\1\u00b2"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\24\76\1\u00b3\5\76"), + u"\24\76\1\u00b3\5\76"), DFA.unpack(u"\1\u00b6\11\uffff\1\u00b5"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00b8"), DFA.unpack(u"\1\u00b9"), DFA.unpack(u"\1\u00ba"), @@ -4634,7 +3614,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\154\1\uffff\10\u0094\2\154\12\uffff\3\154\35\uffff" - u"\3\154"), + u"\3\154"), DFA.unpack(u""), DFA.unpack(u"\1\154\1\uffff\12\u0096\12\uffff\3\154\35\uffff\3\154= "), DFA.unpack(u""), @@ -4661,10 +3641,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00dd"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00df"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00e1"), DFA.unpack(u"\1\u00e2"), DFA.unpack(u"\1\u00e3"), @@ -4674,7 +3654,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u00e6"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00e8"), DFA.unpack(u"\1\u00e9"), DFA.unpack(u"\1\u00ea"), @@ -4693,10 +3673,10 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u00f4"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00f6"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00f8"), DFA.unpack(u"\1\u00f9"), DFA.unpack(u"\1\u00fa"), @@ -4704,22 +3684,22 @@ class CLexer(Lexer): DFA.unpack(u"\1\u00fc"), DFA.unpack(u"\1\u00fd"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u00ff"), DFA.unpack(u"\1\u0100"), DFA.unpack(u"\1\u0101"), DFA.unpack(u"\1\u0102"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0105"), DFA.unpack(u"\1\u0106"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0109"), DFA.unpack(u"\1\u010a"), @@ -4737,10 +3717,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0116"), DFA.unpack(u"\1\u0117"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0119"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u011b"), DFA.unpack(u"\1\u011c"), DFA.unpack(u""), @@ -4752,7 +3732,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0121"), DFA.unpack(u"\1\u0122"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0124"), DFA.unpack(u"\1\u0125"), @@ -4762,19 +3742,19 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u"\1\u0128"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u012b"), DFA.unpack(u"\1\u012c"), DFA.unpack(u"\1\u012d"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u012f"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0131"), DFA.unpack(u"\1\u0132"), DFA.unpack(u"\1\u0133"), @@ -4783,39 +3763,39 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0136"), DFA.unpack(u"\1\u0137"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\u0138\1" - u"\uffff\32\76"), + u"\uffff\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u013c"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0143"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0146"), DFA.unpack(u"\1\u0147"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\u0148"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u014a"), DFA.unpack(u""), DFA.unpack(u"\1\u014b"), @@ -4826,15 +3806,15 @@ class CLexer(Lexer): DFA.unpack(u"\1\u014f"), DFA.unpack(u"\1\u0150"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0153"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u""), @@ -4847,7 +3827,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0156"), DFA.unpack(u"\1\u0157"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u0159"), DFA.unpack(u"\1\u015a"), @@ -4859,22 +3839,22 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0166"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0168"), DFA.unpack(u"\1\u0169"), DFA.unpack(u"\1\u016a"), @@ -4885,7 +3865,7 @@ class CLexer(Lexer): DFA.unpack(u""), DFA.unpack(u""), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u""), DFA.unpack(u"\1\u016c"), DFA.unpack(u"\1\u016d"), @@ -4909,7 +3889,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u017e"), DFA.unpack(u"\1\u017f"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0181"), DFA.unpack(u"\1\u0182"), DFA.unpack(u""), @@ -4917,7 +3897,7 @@ class CLexer(Lexer): DFA.unpack(u"\1\u0184"), DFA.unpack(u"\1\u0185"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"\1\u0187"), DFA.unpack(u""), DFA.unpack(u"\1\u0188"), @@ -4930,12 +3910,10 @@ class CLexer(Lexer): DFA.unpack(u"\1\u018f"), DFA.unpack(u"\1\u0190"), DFA.unpack(u"\1\76\13\uffff\12\76\7\uffff\32\76\4\uffff\1\76\1\uff= ff" - u"\32\76"), + u"\32\76"), DFA.unpack(u"") ] =20 # class definition for DFA #35 =20 DFA35 =3D DFA - - diff --git a/BaseTools/Source/Python/Eot/CParser3/CParser.py b/BaseTools/So= urce/Python/Eot/CParser3/CParser.py index 42bb4d2a1fef..aaaa9f9b585e 100644 --- a/BaseTools/Source/Python/Eot/CParser3/CParser.py +++ b/BaseTools/Source/Python/Eot/CParser3/CParser.py @@ -5,7 +5,7 @@ from __future__ import absolute_import from antlr3 import * from antlr3.compat import set, frozenset =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY THIS FILE. @@ -22,33 +22,32 @@ from . import CodeFragment from . import FileProfile =20 =20 - # for convenience in actions HIDDEN =3D BaseRecognizer.HIDDEN =20 # token types -BS=3D20 -LINE_COMMENT=3D23 -FloatTypeSuffix=3D16 -IntegerTypeSuffix=3D14 -LETTER=3D11 -OCTAL_LITERAL=3D6 -CHARACTER_LITERAL=3D8 -Exponent=3D15 -EOF=3D-1 -HexDigit=3D13 -STRING_LITERAL=3D9 -WS=3D19 -FLOATING_POINT_LITERAL=3D10 -IDENTIFIER=3D4 -UnicodeEscape=3D18 -LINE_COMMAND=3D24 -UnicodeVocabulary=3D21 -HEX_LITERAL=3D5 -COMMENT=3D22 -DECIMAL_LITERAL=3D7 -EscapeSequence=3D12 -OctalEscape=3D17 +BS =3D 20 +LINE_COMMENT =3D 23 +FloatTypeSuffix =3D 16 +IntegerTypeSuffix =3D 14 +LETTER =3D 11 +OCTAL_LITERAL =3D 6 +CHARACTER_LITERAL =3D 8 +Exponent =3D 15 +EOF =3D -1 +HexDigit =3D 13 +STRING_LITERAL =3D 9 +WS =3D 19 +FLOATING_POINT_LITERAL =3D 10 +IDENTIFIER =3D 4 +UnicodeEscape =3D 18 +LINE_COMMAND =3D 24 +UnicodeVocabulary =3D 21 +HEX_LITERAL =3D 5 +COMMENT =3D 22 +DECIMAL_LITERAL =3D 7 +EscapeSequence =3D 12 +OctalEscape =3D 17 =20 # token names tokenNames =3D [ @@ -81,6 +80,8 @@ class function_definition_scope(object): self.LBOffset =3D None self.DeclLine =3D None self.DeclOffset =3D None + + class postfix_expression_scope(object): def __init__(self): self.FuncCallText =3D None @@ -98,41 +99,46 @@ class CParser(Parser): self.postfix_expression_stack =3D [] =20 def printTokenInfo(self, line, offset, tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Start= Offset), (EndLine, EndOffset)) - FileProfile.PredicateExpressionList.append(PredExp) + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.PredicateExpressionList.append(PredExp) =20 def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) - FileProfile.EnumerationDefinitionList.append(EnumDef) + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.EnumerationDefinitionList.append(EnumDef) =20 def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Start= Offset), (EndLine, EndOffset)) - FileProfile.StructUnionDefinitionList.append(SUDef) + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) + FileProfile.StructUnionDefinitionList.append(SUDef) =20 def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLine= , StartOffset), (EndLine, EndOffset)) - FileProfile.TypedefDefinitionList.append(Tdef) + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) + FileProfile.TypedefDefinitionList.append(Tdef) =20 def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText, = (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBraceOf= fset), (DeclLine, DeclOffset)) - FileProfile.FunctionDefinitionList.append(FuncDef) + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) + FileProfile.FunctionDefinitionList.append(FuncDef) =20 def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclText,= (StartLine, StartOffset), (EndLine, EndOffset)) - FileProfile.VariableDeclarationList.append(VarDecl) + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) + FileProfile.VariableDeclarationList.append(VarDecl) =20 def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (Star= tLine, StartOffset), (EndLine, EndOffset)) - FileProfile.FunctionCallingList.append(FuncCall) - - - + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) + FileProfile.FunctionCallingList.append(FuncCall) =20 # $ANTLR start translation_unit # C.g:102:1: translation_unit : ( external_declaration )* ; + def translation_unit(self, ): =20 translation_unit_StartIndex =3D self.input.index() @@ -144,30 +150,24 @@ class CParser(Parser): # C.g:103:2: ( ( external_declaration )* ) # C.g:103:4: ( external_declaration )* # C.g:103:4: ( external_declaration )* - while True: #loop1 + while True: # loop1 alt1 =3D 2 LA1_0 =3D self.input.LA(1) =20 - if (LA1_0 =3D=3D IDENTIFIER or LA1_0 =3D=3D 26 or (29 = <=3D LA1_0 <=3D 42) or (45 <=3D LA1_0 <=3D 46) or (48 <=3D LA1_0 <=3D 62) o= r LA1_0 =3D=3D 66) : + if (LA1_0 =3D=3D IDENTIFIER or LA1_0 =3D=3D 26 or (29 = <=3D LA1_0 <=3D 42) or (45 <=3D LA1_0 <=3D 46) or (48 <=3D LA1_0 <=3D 62) o= r LA1_0 =3D=3D 66): alt1 =3D 1 =20 - if alt1 =3D=3D 1: # C.g:0:0: external_declaration - self.following.append(self.FOLLOW_external_declara= tion_in_translation_unit74) + self.following.append( + self.FOLLOW_external_declaration_in_translatio= n_unit74) self.external_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop1 - - - - - + break # loop1 =20 except RecognitionException as re: self.reportError(re) @@ -182,9 +182,9 @@ class CParser(Parser): =20 # $ANTLR end translation_unit =20 - # $ANTLR start external_declaration # C.g:114:1: external_declaration options {k=3D1; } : ( ( ( declaratio= n_specifiers )? declarator ( declaration )* '{' )=3D> function_definition |= declaration | macro_statement ( ';' )? ); + def external_declaration(self, ): =20 external_declaration_StartIndex =3D self.input.index() @@ -197,316 +197,335 @@ class CParser(Parser): alt3 =3D 3 LA3_0 =3D self.input.LA(1) =20 - if ((29 <=3D LA3_0 <=3D 33)) : + if ((29 <=3D LA3_0 <=3D 33)): LA3_1 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 1, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 1, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 34) : + elif (LA3_0 =3D=3D 34): LA3_2 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 2, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 2, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 35) : + elif (LA3_0 =3D=3D 35): LA3_3 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 3, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 3, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 36) : + elif (LA3_0 =3D=3D 36): LA3_4 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 4, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 4, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 37) : + elif (LA3_0 =3D=3D 37): LA3_5 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 5, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 5, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 38) : + elif (LA3_0 =3D=3D 38): LA3_6 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 6, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 6, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 39) : + elif (LA3_0 =3D=3D 39): LA3_7 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 7, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 7, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 40) : + elif (LA3_0 =3D=3D 40): LA3_8 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 8, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 8, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 41) : + elif (LA3_0 =3D=3D 41): LA3_9 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 9, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 9, self.= input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 42) : + elif (LA3_0 =3D=3D 42): LA3_10 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 10, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 10, self= .input) =20 raise nvae =20 - elif ((45 <=3D LA3_0 <=3D 46)) : + elif ((45 <=3D LA3_0 <=3D 46)): LA3_11 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 11, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 11, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 48) : + elif (LA3_0 =3D=3D 48): LA3_12 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 12, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 12, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D IDENTIFIER) : + elif (LA3_0 =3D=3D IDENTIFIER): LA3_13 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 - elif (True) : + elif (True): alt3 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 13, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 13, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 58) : + elif (LA3_0 =3D=3D 58): LA3_14 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 14, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 14, self= .input) =20 raise nvae =20 elif (LA3_0 =3D=3D 66) and (self.synpred4()): alt3 =3D 1 - elif (LA3_0 =3D=3D 59) : + elif (LA3_0 =3D=3D 59): LA3_16 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 16, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 16, self= .input) =20 raise nvae =20 - elif (LA3_0 =3D=3D 60) : + elif (LA3_0 =3D=3D 60): LA3_17 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 17, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 17, self= .input) =20 raise nvae =20 - elif ((49 <=3D LA3_0 <=3D 57) or LA3_0 =3D=3D 61) : + elif ((49 <=3D LA3_0 <=3D 57) or LA3_0 =3D=3D 61): LA3_18 =3D self.input.LA(2) =20 - if (self.synpred4()) : + if (self.synpred4()): alt3 =3D 1 - elif (self.synpred5()) : + elif (self.synpred5()): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_dec= laration options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( d= eclaration )* '{' )=3D> function_definition | declaration | macro_statement= ( ';' )? );", 3, 18, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; }= : ( ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> fu= nction_definition | declaration | macro_statement ( ';' )? );", 3, 18, self= .input) =20 raise nvae =20 elif (LA3_0 =3D=3D 62) and (self.synpred4()): alt3 =3D 1 - elif (LA3_0 =3D=3D 26) : + elif (LA3_0 =3D=3D 26): alt3 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("114:1: external_declara= tion options {k=3D1; } : ( ( ( declaration_specifiers )? declarator ( decla= ration )* '{' )=3D> function_definition | declaration | macro_statement ( '= ;' )? );", 3, 0, self.input) + nvae =3D NoViableAltException( + "114:1: external_declaration options {k=3D1; } : (= ( ( declaration_specifiers )? declarator ( declaration )* '{' )=3D> functi= on_definition | declaration | macro_statement ( ';' )? );", 3, 0, self.inpu= t) =20 raise nvae =20 if alt3 =3D=3D 1: # C.g:119:4: ( ( declaration_specifiers )? declarator = ( declaration )* '{' )=3D> function_definition - self.following.append(self.FOLLOW_function_definition_= in_external_declaration113) + self.following.append( + self.FOLLOW_function_definition_in_external_declar= ation113) self.function_definition() self.following.pop() if self.failed: return =20 - elif alt3 =3D=3D 2: # C.g:120:4: declaration - self.following.append(self.FOLLOW_declaration_in_exter= nal_declaration118) + self.following.append( + self.FOLLOW_declaration_in_external_declaration118) self.declaration() self.following.pop() if self.failed: return =20 - elif alt3 =3D=3D 3: # C.g:121:4: macro_statement ( ';' )? - self.following.append(self.FOLLOW_macro_statement_in_e= xternal_declaration123) + self.following.append( + self.FOLLOW_macro_statement_in_external_declaratio= n123) self.macro_statement() self.following.pop() if self.failed: @@ -515,19 +534,15 @@ class CParser(Parser): alt2 =3D 2 LA2_0 =3D self.input.LA(1) =20 - if (LA2_0 =3D=3D 25) : + if (LA2_0 =3D=3D 25): alt2 =3D 1 if alt2 =3D=3D 1: # C.g:121:21: ';' - self.match(self.input, 25, self.FOLLOW_25_in_exter= nal_declaration126) + self.match(self.input, 25, + self.FOLLOW_25_in_external_declaration1= 26) if self.failed: return =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -546,10 +561,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start function_definition # C.g:126:1: function_definition : (d=3D declaration_specifiers )? dec= larator ( ( declaration )+ a=3D compound_statement | b=3D compound_statemen= t ) ; + def function_definition(self, ): self.function_definition_stack.append(function_definition_scope()) retval =3D self.function_definition_return() @@ -563,14 +577,12 @@ class CParser(Parser): =20 declarator1 =3D None =20 - - - self.function_definition_stack[-1].ModifierText =3D '' - self.function_definition_stack[-1].DeclText =3D '' - self.function_definition_stack[-1].LBLine =3D 0 - self.function_definition_stack[-1].LBOffset =3D 0 - self.function_definition_stack[-1].DeclLine =3D 0 - self.function_definition_stack[-1].DeclOffset =3D 0 + self.function_definition_stack[-1].ModifierText =3D '' + self.function_definition_stack[-1].DeclText =3D '' + self.function_definition_stack[-1].LBLine =3D 0 + self.function_definition_stack[-1].LBOffset =3D 0 + self.function_definition_stack[-1].DeclLine =3D 0 + self.function_definition_stack[-1].DeclOffset =3D 0 =20 try: try: @@ -591,119 +603,119 @@ class CParser(Parser): elif LA4 =3D=3D 58: LA4_21 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 59: LA4_22 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 60: LA4_23 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D IDENTIFIER: LA4_24 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 62: LA4_25 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 29 or LA4 =3D=3D 30 or LA4 =3D=3D 31 o= r LA4 =3D=3D 32 or LA4 =3D=3D 33: LA4_26 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 34: LA4_27 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 35: LA4_28 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 36: LA4_29 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 37: LA4_30 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 38: LA4_31 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 39: LA4_32 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 40: LA4_33 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 41: LA4_34 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 42: LA4_35 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 45 or LA4 =3D=3D 46: LA4_36 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 48: LA4_37 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 49 or LA4 =3D=3D 50 or LA4 =3D=3D 51 o= r LA4 =3D=3D 52 or LA4 =3D=3D 53 or LA4 =3D=3D 54 or LA4 =3D=3D 55 or LA4 = =3D=3D 56 or LA4 =3D=3D 57 or LA4 =3D=3D 61: LA4_38 =3D self.input.LA(3) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 58: LA4_14 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 59: LA4_16 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 elif LA4 =3D=3D 60: LA4_17 =3D self.input.LA(2) =20 - if (self.synpred7()) : + if (self.synpred7()): alt4 =3D 1 if alt4 =3D=3D 1: # C.g:0:0: d=3D declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifie= rs_in_function_definition157) + self.following.append( + self.FOLLOW_declaration_specifiers_in_function_def= inition157) d =3D self.declaration_specifiers() self.following.pop() if self.failed: return retval =20 - - - self.following.append(self.FOLLOW_declarator_in_function_d= efinition160) + self.following.append( + self.FOLLOW_declarator_in_function_definition160) declarator1 =3D self.declarator() self.following.pop() if self.failed: @@ -712,16 +724,17 @@ class CParser(Parser): alt6 =3D 2 LA6_0 =3D self.input.LA(1) =20 - if (LA6_0 =3D=3D IDENTIFIER or LA6_0 =3D=3D 26 or (29 <=3D= LA6_0 <=3D 42) or (45 <=3D LA6_0 <=3D 46) or (48 <=3D LA6_0 <=3D 61)) : + if (LA6_0 =3D=3D IDENTIFIER or LA6_0 =3D=3D 26 or (29 <=3D= LA6_0 <=3D 42) or (45 <=3D LA6_0 <=3D 46) or (48 <=3D LA6_0 <=3D 61)): alt6 =3D 1 - elif (LA6_0 =3D=3D 43) : + elif (LA6_0 =3D=3D 43): alt6 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("147:3: ( ( declaration = )+ a=3D compound_statement | b=3D compound_statement )", 6, 0, self.input) + nvae =3D NoViableAltException( + "147:3: ( ( declaration )+ a=3D compound_statement= | b=3D compound_statement )", 6, 0, self.input) =20 raise nvae =20 @@ -729,26 +742,25 @@ class CParser(Parser): # C.g:147:5: ( declaration )+ a=3D compound_statement # C.g:147:5: ( declaration )+ cnt5 =3D 0 - while True: #loop5 + while True: # loop5 alt5 =3D 2 LA5_0 =3D self.input.LA(1) =20 - if (LA5_0 =3D=3D IDENTIFIER or LA5_0 =3D=3D 26 or = (29 <=3D LA5_0 <=3D 42) or (45 <=3D LA5_0 <=3D 46) or (48 <=3D LA5_0 <=3D 6= 1)) : + if (LA5_0 =3D=3D IDENTIFIER or LA5_0 =3D=3D 26 or = (29 <=3D LA5_0 <=3D 42) or (45 <=3D LA5_0 <=3D 46) or (48 <=3D LA5_0 <=3D 6= 1)): alt5 =3D 1 =20 - if alt5 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_= in_function_definition166) + self.following.append( + self.FOLLOW_declaration_in_function_defini= tion166) self.declaration() self.following.pop() if self.failed: return retval =20 - else: if cnt5 >=3D 1: - break #loop5 + break # loop5 =20 if self.backtracking > 0: self.failed =3D True @@ -759,51 +771,46 @@ class CParser(Parser): =20 cnt5 +=3D 1 =20 - - self.following.append(self.FOLLOW_compound_statement_i= n_function_definition171) + self.following.append( + self.FOLLOW_compound_statement_in_function_definit= ion171) a =3D self.compound_statement() self.following.pop() if self.failed: return retval =20 - elif alt6 =3D=3D 2: # C.g:148:5: b=3D compound_statement - self.following.append(self.FOLLOW_compound_statement_i= n_function_definition180) + self.following.append( + self.FOLLOW_compound_statement_in_function_definit= ion180) b =3D self.compound_statement() self.following.pop() if self.failed: return retval =20 - - if self.backtracking =3D=3D 0: =20 if d is not None: - self.function_definition_stack[-1].ModifierText =3D = self.input.toString(d.start, d.stop) + self.function_definition_stack[-1].ModifierText = =3D self.input.toString( + d.start, d.stop) else: - self.function_definition_stack[-1].ModifierText =3D = '' - self.function_definition_stack[-1].DeclText =3D self.i= nput.toString(declarator1.start, declarator1.stop) + self.function_definition_stack[-1].ModifierText = =3D '' + self.function_definition_stack[-1].DeclText =3D self.i= nput.toString( + declarator1.start, declarator1.stop) self.function_definition_stack[-1].DeclLine =3D declar= ator1.start.line self.function_definition_stack[-1].DeclOffset =3D decl= arator1.start.charPositionInLine if a is not None: - self.function_definition_stack[-1].LBLine =3D a.star= t.line - self.function_definition_stack[-1].LBOffset =3D a.st= art.charPositionInLine + self.function_definition_stack[-1].LBLine =3D a.st= art.line + self.function_definition_stack[-1].LBOffset =3D a.= start.charPositionInLine else: - self.function_definition_stack[-1].LBLine =3D b.star= t.line - self.function_definition_stack[-1].LBOffset =3D b.st= art.charPositionInLine - - - - + self.function_definition_stack[-1].LBLine =3D b.st= art.line + self.function_definition_stack[-1].LBOffset =3D b.= start.charPositionInLine =20 retval.stop =3D self.input.LT(-1) =20 if self.backtracking =3D=3D 0: =20 - self.StoreFunctionDefinition(retval.start.line, retval= .start.charPositionInLine, retval.stop.line, retval.stop.charPositionInLine= , self.function_definition_stack[-1].ModifierText, self.function_definition= _stack[-1].DeclText, self.function_definition_stack[-1].LBLine, self.functi= on_definition_stack[-1].LBOffset, self.function_definition_stack[-1].DeclLi= ne, self.function_definition_stack[-1].DeclOffset) - - + self.StoreFunctionDefinition(retval.start.line, retval= .start.charPositionInLine, retval.stop.line, retval.stop.charPositionInLine= , self.function_definition_stack[-1].ModifierText, self.function_definition= _stack[ + -1].DeclText, self.functi= on_definition_stack[-1].LBLine, self.function_definition_stack[-1].LBOffset= , self.function_definition_stack[-1].DeclLine, self.function_definition_sta= ck[-1].DeclOffset) =20 except RecognitionException as re: self.reportError(re) @@ -819,9 +826,9 @@ class CParser(Parser): =20 # $ANTLR end function_definition =20 - # $ANTLR start declaration # C.g:166:1: declaration : (a=3D 'typedef' (b=3D declaration_specifier= s )? c=3D init_declarator_list d=3D ';' | s=3D declaration_specifiers (t=3D= init_declarator_list )? e=3D ';' ); + def declaration(self, ): =20 declaration_StartIndex =3D self.input.index() @@ -836,7 +843,6 @@ class CParser(Parser): =20 t =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 4): @@ -846,23 +852,25 @@ class CParser(Parser): alt9 =3D 2 LA9_0 =3D self.input.LA(1) =20 - if (LA9_0 =3D=3D 26) : + if (LA9_0 =3D=3D 26): alt9 =3D 1 - elif (LA9_0 =3D=3D IDENTIFIER or (29 <=3D LA9_0 <=3D 42) o= r (45 <=3D LA9_0 <=3D 46) or (48 <=3D LA9_0 <=3D 61)) : + elif (LA9_0 =3D=3D IDENTIFIER or (29 <=3D LA9_0 <=3D 42) o= r (45 <=3D LA9_0 <=3D 46) or (48 <=3D LA9_0 <=3D 61)): alt9 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("166:1: declaration : (a= =3D 'typedef' (b=3D declaration_specifiers )? c=3D init_declarator_list d= =3D ';' | s=3D declaration_specifiers (t=3D init_declarator_list )? e=3D ';= ' );", 9, 0, self.input) + nvae =3D NoViableAltException( + "166:1: declaration : (a=3D 'typedef' (b=3D declar= ation_specifiers )? c=3D init_declarator_list d=3D ';' | s=3D declaration_s= pecifiers (t=3D init_declarator_list )? e=3D ';' );", 9, 0, self.input) =20 raise nvae =20 if alt9 =3D=3D 1: # C.g:167:4: a=3D 'typedef' (b=3D declaration_specifie= rs )? c=3D init_declarator_list d=3D ';' a =3D self.input.LT(1) - self.match(self.input, 26, self.FOLLOW_26_in_declarati= on203) + self.match(self.input, 26, + self.FOLLOW_26_in_declaration203) if self.failed: return # C.g:167:17: (b=3D declaration_specifiers )? @@ -873,60 +881,61 @@ class CParser(Parser): elif LA7 =3D=3D IDENTIFIER: LA7_13 =3D self.input.LA(2) =20 - if (LA7_13 =3D=3D 62) : + if (LA7_13 =3D=3D 62): LA7_21 =3D self.input.LA(3) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 - elif (LA7_13 =3D=3D IDENTIFIER or (29 <=3D LA7_13 = <=3D 42) or (45 <=3D LA7_13 <=3D 46) or (48 <=3D LA7_13 <=3D 61) or LA7_13 = =3D=3D 66) : + elif (LA7_13 =3D=3D IDENTIFIER or (29 <=3D LA7_13 = <=3D 42) or (45 <=3D LA7_13 <=3D 46) or (48 <=3D LA7_13 <=3D 61) or LA7_13 = =3D=3D 66): alt7 =3D 1 elif LA7 =3D=3D 58: LA7_14 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 elif LA7 =3D=3D 59: LA7_16 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 elif LA7 =3D=3D 60: LA7_17 =3D self.input.LA(2) =20 - if (self.synpred10()) : + if (self.synpred10()): alt7 =3D 1 if alt7 =3D=3D 1: # C.g:0:0: b=3D declaration_specifiers - self.following.append(self.FOLLOW_declaration_spec= ifiers_in_declaration207) + self.following.append( + self.FOLLOW_declaration_specifiers_in_declarat= ion207) b =3D self.declaration_specifiers() self.following.pop() if self.failed: return =20 - - - self.following.append(self.FOLLOW_init_declarator_list= _in_declaration216) + self.following.append( + self.FOLLOW_init_declarator_list_in_declaration216) c =3D self.init_declarator_list() self.following.pop() if self.failed: return d =3D self.input.LT(1) - self.match(self.input, 25, self.FOLLOW_25_in_declarati= on220) + self.match(self.input, 25, + self.FOLLOW_25_in_declaration220) if self.failed: return if self.backtracking =3D=3D 0: =20 if b is not None: - self.StoreTypedefDefinition(a.line, a.charPositi= onInLine, d.line, d.charPositionInLine, self.input.toString(b.start, b.stop= ), self.input.toString(c.start, c.stop)) + self.StoreTypedefDefinition(a.line, a.charPosi= tionInLine, d.line, d.charPositionInLine, self.input.toString( + b.start, b.stop), self.input.toString(c.st= art, c.stop)) else: - self.StoreTypedefDefinition(a.line, a.charPositi= onInLine, d.line, d.charPositionInLine, '', self.input.toString(c.start, c.= stop)) - - - + self.StoreTypedefDefinition( + a.line, a.charPositionInLine, d.line, d.ch= arPositionInLine, '', self.input.toString(c.start, c.stop)) =20 elif alt9 =3D=3D 2: # C.g:175:4: s=3D declaration_specifiers (t=3D init_de= clarator_list )? e=3D ';' - self.following.append(self.FOLLOW_declaration_specifie= rs_in_declaration234) + self.following.append( + self.FOLLOW_declaration_specifiers_in_declaration2= 34) s =3D self.declaration_specifiers() self.following.pop() if self.failed: @@ -935,30 +944,27 @@ class CParser(Parser): alt8 =3D 2 LA8_0 =3D self.input.LA(1) =20 - if (LA8_0 =3D=3D IDENTIFIER or (58 <=3D LA8_0 <=3D 60)= or LA8_0 =3D=3D 62 or LA8_0 =3D=3D 66) : + if (LA8_0 =3D=3D IDENTIFIER or (58 <=3D LA8_0 <=3D 60)= or LA8_0 =3D=3D 62 or LA8_0 =3D=3D 66): alt8 =3D 1 if alt8 =3D=3D 1: # C.g:0:0: t=3D init_declarator_list - self.following.append(self.FOLLOW_init_declarator_= list_in_declaration238) + self.following.append( + self.FOLLOW_init_declarator_list_in_declaratio= n238) t =3D self.init_declarator_list() self.following.pop() if self.failed: return =20 - - e =3D self.input.LT(1) - self.match(self.input, 25, self.FOLLOW_25_in_declarati= on243) + self.match(self.input, 25, + self.FOLLOW_25_in_declaration243) if self.failed: return if self.backtracking =3D=3D 0: =20 if t is not None: - self.StoreVariableDeclaration(s.start.line, s.st= art.charPositionInLine, t.start.line, t.start.charPositionInLine, self.inpu= t.toString(s.start, s.stop), self.input.toString(t.start, t.stop)) - - - - + self.StoreVariableDeclaration(s.start.line, s.= start.charPositionInLine, t.start.line, t.start.charPositionInLine, self.in= put.toString( + s.start, s.stop), self.input.toString(t.st= art, t.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -978,10 +984,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start declaration_specifiers # C.g:182:1: declaration_specifiers : ( storage_class_specifier | type= _specifier | type_qualifier )+ ; + def declaration_specifiers(self, ): =20 retval =3D self.declaration_specifiers_return() @@ -996,44 +1001,39 @@ class CParser(Parser): # C.g:183:6: ( storage_class_specifier | type_specifier | = type_qualifier )+ # C.g:183:6: ( storage_class_specifier | type_specifier | = type_qualifier )+ cnt10 =3D 0 - while True: #loop10 + while True: # loop10 alt10 =3D 4 LA10 =3D self.input.LA(1) if LA10 =3D=3D 58: LA10_2 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 59: LA10_3 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 60: LA10_4 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D IDENTIFIER: LA10_5 =3D self.input.LA(2) =20 - if (self.synpred14()) : + if (self.synpred14()): alt10 =3D 2 =20 - elif LA10 =3D=3D 53: LA10_9 =3D self.input.LA(2) =20 - if (self.synpred15()) : + if (self.synpred15()): alt10 =3D 3 =20 - elif LA10 =3D=3D 29 or LA10 =3D=3D 30 or LA10 =3D=3D 3= 1 or LA10 =3D=3D 32 or LA10 =3D=3D 33: alt10 =3D 1 elif LA10 =3D=3D 34 or LA10 =3D=3D 35 or LA10 =3D=3D 3= 6 or LA10 =3D=3D 37 or LA10 =3D=3D 38 or LA10 =3D=3D 39 or LA10 =3D=3D 40 o= r LA10 =3D=3D 41 or LA10 =3D=3D 42 or LA10 =3D=3D 45 or LA10 =3D=3D 46 or L= A10 =3D=3D 48: @@ -1043,34 +1043,34 @@ class CParser(Parser): =20 if alt10 =3D=3D 1: # C.g:183:10: storage_class_specifier - self.following.append(self.FOLLOW_storage_class_sp= ecifier_in_declaration_specifiers264) + self.following.append( + self.FOLLOW_storage_class_specifier_in_declara= tion_specifiers264) self.storage_class_specifier() self.following.pop() if self.failed: return retval =20 - elif alt10 =3D=3D 2: # C.g:184:7: type_specifier - self.following.append(self.FOLLOW_type_specifier_i= n_declaration_specifiers272) + self.following.append( + self.FOLLOW_type_specifier_in_declaration_spec= ifiers272) self.type_specifier() self.following.pop() if self.failed: return retval =20 - elif alt10 =3D=3D 3: # C.g:185:13: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_i= n_declaration_specifiers286) + self.following.append( + self.FOLLOW_type_qualifier_in_declaration_spec= ifiers286) self.type_qualifier() self.following.pop() if self.failed: return retval =20 - else: if cnt10 >=3D 1: - break #loop10 + break # loop10 =20 if self.backtracking > 0: self.failed =3D True @@ -1081,13 +1081,8 @@ class CParser(Parser): =20 cnt10 +=3D 1 =20 - - - - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1106,10 +1101,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start init_declarator_list # C.g:189:1: init_declarator_list : init_declarator ( ',' init_declara= tor )* ; + def init_declarator_list(self, ): =20 retval =3D self.init_declarator_list_return() @@ -1122,42 +1116,38 @@ class CParser(Parser): =20 # C.g:190:2: ( init_declarator ( ',' init_declarator )* ) # C.g:190:4: init_declarator ( ',' init_declarator )* - self.following.append(self.FOLLOW_init_declarator_in_init_= declarator_list308) + self.following.append( + self.FOLLOW_init_declarator_in_init_declarator_list308) self.init_declarator() self.following.pop() if self.failed: return retval # C.g:190:20: ( ',' init_declarator )* - while True: #loop11 + while True: # loop11 alt11 =3D 2 LA11_0 =3D self.input.LA(1) =20 - if (LA11_0 =3D=3D 27) : + if (LA11_0 =3D=3D 27): alt11 =3D 1 =20 - if alt11 =3D=3D 1: # C.g:190:21: ',' init_declarator - self.match(self.input, 27, self.FOLLOW_27_in_init_= declarator_list311) + self.match(self.input, 27, + self.FOLLOW_27_in_init_declarator_list3= 11) if self.failed: return retval - self.following.append(self.FOLLOW_init_declarator_= in_init_declarator_list313) + self.following.append( + self.FOLLOW_init_declarator_in_init_declarator= _list313) self.init_declarator() self.following.pop() if self.failed: return retval =20 - else: - break #loop11 - - - - + break # loop11 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1171,9 +1161,9 @@ class CParser(Parser): =20 # $ANTLR end init_declarator_list =20 - # $ANTLR start init_declarator # C.g:193:1: init_declarator : declarator ( '=3D' initializer )? ; + def init_declarator(self, ): =20 init_declarator_StartIndex =3D self.input.index() @@ -1184,7 +1174,8 @@ class CParser(Parser): =20 # C.g:194:2: ( declarator ( '=3D' initializer )? ) # C.g:194:4: declarator ( '=3D' initializer )? - self.following.append(self.FOLLOW_declarator_in_init_decla= rator326) + self.following.append( + self.FOLLOW_declarator_in_init_declarator326) self.declarator() self.following.pop() if self.failed: @@ -1193,25 +1184,21 @@ class CParser(Parser): alt12 =3D 2 LA12_0 =3D self.input.LA(1) =20 - if (LA12_0 =3D=3D 28) : + if (LA12_0 =3D=3D 28): alt12 =3D 1 if alt12 =3D=3D 1: # C.g:194:16: '=3D' initializer - self.match(self.input, 28, self.FOLLOW_28_in_init_decl= arator329) + self.match(self.input, 28, + self.FOLLOW_28_in_init_declarator329) if self.failed: return - self.following.append(self.FOLLOW_initializer_in_init_= declarator331) + self.following.append( + self.FOLLOW_initializer_in_init_declarator331) self.initializer() self.following.pop() if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1225,9 +1212,9 @@ class CParser(Parser): =20 # $ANTLR end init_declarator =20 - # $ANTLR start storage_class_specifier # C.g:197:1: storage_class_specifier : ( 'extern' | 'static' | 'auto' = | 'register' | 'STATIC' ); + def storage_class_specifier(self, ): =20 storage_class_specifier_StartIndex =3D self.input.index() @@ -1239,7 +1226,7 @@ class CParser(Parser): # C.g:198:2: ( 'extern' | 'static' | 'auto' | 'register' |= 'STATIC' ) # C.g: if (29 <=3D self.input.LA(1) <=3D 33): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -1251,14 +1238,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_storage_class_= specifier0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1272,9 +1254,9 @@ class CParser(Parser): =20 # $ANTLR end storage_class_specifier =20 - # $ANTLR start type_specifier # C.g:205:1: type_specifier : ( 'void' | 'char' | 'short' | 'int' | 'l= ong' | 'float' | 'double' | 'signed' | 'unsigned' | s=3D struct_or_union_sp= ecifier | e=3D enum_specifier | ( IDENTIFIER ( type_qualifier )* declarator= )=3D> type_id ); + def type_specifier(self, ): =20 type_specifier_StartIndex =3D self.input.index() @@ -1282,7 +1264,6 @@ class CParser(Parser): =20 e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 9): @@ -1292,27 +1273,27 @@ class CParser(Parser): alt13 =3D 12 LA13_0 =3D self.input.LA(1) =20 - if (LA13_0 =3D=3D 34) : + if (LA13_0 =3D=3D 34): alt13 =3D 1 - elif (LA13_0 =3D=3D 35) : + elif (LA13_0 =3D=3D 35): alt13 =3D 2 - elif (LA13_0 =3D=3D 36) : + elif (LA13_0 =3D=3D 36): alt13 =3D 3 - elif (LA13_0 =3D=3D 37) : + elif (LA13_0 =3D=3D 37): alt13 =3D 4 - elif (LA13_0 =3D=3D 38) : + elif (LA13_0 =3D=3D 38): alt13 =3D 5 - elif (LA13_0 =3D=3D 39) : + elif (LA13_0 =3D=3D 39): alt13 =3D 6 - elif (LA13_0 =3D=3D 40) : + elif (LA13_0 =3D=3D 40): alt13 =3D 7 - elif (LA13_0 =3D=3D 41) : + elif (LA13_0 =3D=3D 41): alt13 =3D 8 - elif (LA13_0 =3D=3D 42) : + elif (LA13_0 =3D=3D 42): alt13 =3D 9 - elif ((45 <=3D LA13_0 <=3D 46)) : + elif ((45 <=3D LA13_0 <=3D 46)): alt13 =3D 10 - elif (LA13_0 =3D=3D 48) : + elif (LA13_0 =3D=3D 48): alt13 =3D 11 elif (LA13_0 =3D=3D IDENTIFIER) and (self.synpred34()): alt13 =3D 12 @@ -1321,76 +1302,78 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("205:1: type_specifier := ( 'void' | 'char' | 'short' | 'int' | 'long' | 'float' | 'double' | 'signe= d' | 'unsigned' | s=3D struct_or_union_specifier | e=3D enum_specifier | ( = IDENTIFIER ( type_qualifier )* declarator )=3D> type_id );", 13, 0, self.in= put) + nvae =3D NoViableAltException( + "205:1: type_specifier : ( 'void' | 'char' | 'shor= t' | 'int' | 'long' | 'float' | 'double' | 'signed' | 'unsigned' | s=3D str= uct_or_union_specifier | e=3D enum_specifier | ( IDENTIFIER ( type_qualifie= r )* declarator )=3D> type_id );", 13, 0, self.input) =20 raise nvae =20 if alt13 =3D=3D 1: # C.g:206:4: 'void' - self.match(self.input, 34, self.FOLLOW_34_in_type_spec= ifier376) + self.match(self.input, 34, + self.FOLLOW_34_in_type_specifier376) if self.failed: return =20 - elif alt13 =3D=3D 2: # C.g:207:4: 'char' - self.match(self.input, 35, self.FOLLOW_35_in_type_spec= ifier381) + self.match(self.input, 35, + self.FOLLOW_35_in_type_specifier381) if self.failed: return =20 - elif alt13 =3D=3D 3: # C.g:208:4: 'short' - self.match(self.input, 36, self.FOLLOW_36_in_type_spec= ifier386) + self.match(self.input, 36, + self.FOLLOW_36_in_type_specifier386) if self.failed: return =20 - elif alt13 =3D=3D 4: # C.g:209:4: 'int' - self.match(self.input, 37, self.FOLLOW_37_in_type_spec= ifier391) + self.match(self.input, 37, + self.FOLLOW_37_in_type_specifier391) if self.failed: return =20 - elif alt13 =3D=3D 5: # C.g:210:4: 'long' - self.match(self.input, 38, self.FOLLOW_38_in_type_spec= ifier396) + self.match(self.input, 38, + self.FOLLOW_38_in_type_specifier396) if self.failed: return =20 - elif alt13 =3D=3D 6: # C.g:211:4: 'float' - self.match(self.input, 39, self.FOLLOW_39_in_type_spec= ifier401) + self.match(self.input, 39, + self.FOLLOW_39_in_type_specifier401) if self.failed: return =20 - elif alt13 =3D=3D 7: # C.g:212:4: 'double' - self.match(self.input, 40, self.FOLLOW_40_in_type_spec= ifier406) + self.match(self.input, 40, + self.FOLLOW_40_in_type_specifier406) if self.failed: return =20 - elif alt13 =3D=3D 8: # C.g:213:4: 'signed' - self.match(self.input, 41, self.FOLLOW_41_in_type_spec= ifier411) + self.match(self.input, 41, + self.FOLLOW_41_in_type_specifier411) if self.failed: return =20 - elif alt13 =3D=3D 9: # C.g:214:4: 'unsigned' - self.match(self.input, 42, self.FOLLOW_42_in_type_spec= ifier416) + self.match(self.input, 42, + self.FOLLOW_42_in_type_specifier416) if self.failed: return =20 - elif alt13 =3D=3D 10: # C.g:215:4: s=3D struct_or_union_specifier - self.following.append(self.FOLLOW_struct_or_union_spec= ifier_in_type_specifier423) + self.following.append( + self.FOLLOW_struct_or_union_specifier_in_type_spec= ifier423) s =3D self.struct_or_union_specifier() self.following.pop() if self.failed: @@ -1398,14 +1381,13 @@ class CParser(Parser): if self.backtracking =3D=3D 0: =20 if s.stop is not None: - self.StoreStructUnionDefinition(s.start.line, s.= start.charPositionInLine, s.stop.line, s.stop.charPositionInLine, self.inpu= t.toString(s.start, s.stop)) - - - + self.StoreStructUnionDefinition( + s.start.line, s.start.charPositionInLine, = s.stop.line, s.stop.charPositionInLine, self.input.toString(s.start, s.stop= )) =20 elif alt13 =3D=3D 11: # C.g:220:4: e=3D enum_specifier - self.following.append(self.FOLLOW_enum_specifier_in_ty= pe_specifier433) + self.following.append( + self.FOLLOW_enum_specifier_in_type_specifier433) e =3D self.enum_specifier() self.following.pop() if self.failed: @@ -1413,21 +1395,18 @@ class CParser(Parser): if self.backtracking =3D=3D 0: =20 if e.stop is not None: - self.StoreEnumerationDefinition(e.start.line, e.= start.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.inpu= t.toString(e.start, e.stop)) - - - + self.StoreEnumerationDefinition( + e.start.line, e.start.charPositionInLine, = e.stop.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop= )) =20 elif alt13 =3D=3D 12: # C.g:225:4: ( IDENTIFIER ( type_qualifier )* declarat= or )=3D> type_id - self.following.append(self.FOLLOW_type_id_in_type_spec= ifier451) + self.following.append( + self.FOLLOW_type_id_in_type_specifier451) self.type_id() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1441,9 +1420,9 @@ class CParser(Parser): =20 # $ANTLR end type_specifier =20 - # $ANTLR start type_id # C.g:228:1: type_id : IDENTIFIER ; + def type_id(self, ): =20 type_id_StartIndex =3D self.input.index() @@ -1454,13 +1433,11 @@ class CParser(Parser): =20 # C.g:229:5: ( IDENTIFIER ) # C.g:229:9: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_type_id467) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_type_id467) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1479,10 +1456,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start struct_or_union_specifier # C.g:233:1: struct_or_union_specifier options {k=3D3; } : ( struct_or= _union ( IDENTIFIER )? '{' struct_declaration_list '}' | struct_or_union ID= ENTIFIER ); + def struct_or_union_specifier(self, ): =20 retval =3D self.struct_or_union_specifier_return() @@ -1497,33 +1473,35 @@ class CParser(Parser): alt15 =3D 2 LA15_0 =3D self.input.LA(1) =20 - if ((45 <=3D LA15_0 <=3D 46)) : + if ((45 <=3D LA15_0 <=3D 46)): LA15_1 =3D self.input.LA(2) =20 - if (LA15_1 =3D=3D IDENTIFIER) : + if (LA15_1 =3D=3D IDENTIFIER): LA15_2 =3D self.input.LA(3) =20 - if (LA15_2 =3D=3D 43) : + if (LA15_2 =3D=3D 43): alt15 =3D 1 - elif (LA15_2 =3D=3D EOF or LA15_2 =3D=3D IDENTIFIE= R or LA15_2 =3D=3D 25 or LA15_2 =3D=3D 27 or (29 <=3D LA15_2 <=3D 42) or (4= 5 <=3D LA15_2 <=3D 64) or LA15_2 =3D=3D 66) : + elif (LA15_2 =3D=3D EOF or LA15_2 =3D=3D IDENTIFIE= R or LA15_2 =3D=3D 25 or LA15_2 =3D=3D 27 or (29 <=3D LA15_2 <=3D 42) or (4= 5 <=3D LA15_2 <=3D 64) or LA15_2 =3D=3D 66): alt15 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_o= r_union_specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{'= struct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 2, self.= input) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options = {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '= }' | struct_or_union IDENTIFIER );", 15, 2, self.input) =20 raise nvae =20 - elif (LA15_1 =3D=3D 43) : + elif (LA15_1 =3D=3D 43): alt15 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_or_un= ion_specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' str= uct_declaration_list '}' | struct_or_union IDENTIFIER );", 15, 1, self.inpu= t) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options {k= =3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}'= | struct_or_union IDENTIFIER );", 15, 1, self.input) =20 raise nvae =20 @@ -1532,13 +1510,15 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("233:1: struct_or_union_= specifier options {k=3D3; } : ( struct_or_union ( IDENTIFIER )? '{' struct_= declaration_list '}' | struct_or_union IDENTIFIER );", 15, 0, self.input) + nvae =3D NoViableAltException( + "233:1: struct_or_union_specifier options {k=3D3; = } : ( struct_or_union ( IDENTIFIER )? '{' struct_declaration_list '}' | str= uct_or_union IDENTIFIER );", 15, 0, self.input) =20 raise nvae =20 if alt15 =3D=3D 1: # C.g:235:4: struct_or_union ( IDENTIFIER )? '{' struc= t_declaration_list '}' - self.following.append(self.FOLLOW_struct_or_union_in_s= truct_or_union_specifier494) + self.following.append( + self.FOLLOW_struct_or_union_in_struct_or_union_spe= cifier494) self.struct_or_union() self.following.pop() if self.failed: @@ -1547,50 +1527,52 @@ class CParser(Parser): alt14 =3D 2 LA14_0 =3D self.input.LA(1) =20 - if (LA14_0 =3D=3D IDENTIFIER) : + if (LA14_0 =3D=3D IDENTIFIER): alt14 =3D 1 if alt14 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_struct_or_union_specifier496) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_struct_or_union_specifier496) if self.failed: return retval =20 - - - self.match(self.input, 43, self.FOLLOW_43_in_struct_or= _union_specifier499) + self.match(self.input, 43, + self.FOLLOW_43_in_struct_or_union_specifier= 499) if self.failed: return retval - self.following.append(self.FOLLOW_struct_declaration_l= ist_in_struct_or_union_specifier501) + self.following.append( + self.FOLLOW_struct_declaration_list_in_struct_or_u= nion_specifier501) self.struct_declaration_list() self.following.pop() if self.failed: return retval - self.match(self.input, 44, self.FOLLOW_44_in_struct_or= _union_specifier503) + self.match(self.input, 44, + self.FOLLOW_44_in_struct_or_union_specifier= 503) if self.failed: return retval =20 - elif alt15 =3D=3D 2: # C.g:236:4: struct_or_union IDENTIFIER - self.following.append(self.FOLLOW_struct_or_union_in_s= truct_or_union_specifier508) + self.following.append( + self.FOLLOW_struct_or_union_in_struct_or_union_spe= cifier508) self.struct_or_union() self.following.pop() if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_struct_or_union_specifier510) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_= struct_or_union_specifier510) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 11, struct_or_union_specifier_Sta= rtIndex) + self.memoize(self.input, 11, + struct_or_union_specifier_StartIndex) =20 pass =20 @@ -1598,9 +1580,9 @@ class CParser(Parser): =20 # $ANTLR end struct_or_union_specifier =20 - # $ANTLR start struct_or_union # C.g:239:1: struct_or_union : ( 'struct' | 'union' ); + def struct_or_union(self, ): =20 struct_or_union_StartIndex =3D self.input.index() @@ -1612,7 +1594,7 @@ class CParser(Parser): # C.g:240:2: ( 'struct' | 'union' ) # C.g: if (45 <=3D self.input.LA(1) <=3D 46): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -1624,14 +1606,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_struct_or_unio= n0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1645,9 +1622,9 @@ class CParser(Parser): =20 # $ANTLR end struct_or_union =20 - # $ANTLR start struct_declaration_list # C.g:244:1: struct_declaration_list : ( struct_declaration )+ ; + def struct_declaration_list(self, ): =20 struct_declaration_list_StartIndex =3D self.input.index() @@ -1660,26 +1637,25 @@ class CParser(Parser): # C.g:245:4: ( struct_declaration )+ # C.g:245:4: ( struct_declaration )+ cnt16 =3D 0 - while True: #loop16 + while True: # loop16 alt16 =3D 2 LA16_0 =3D self.input.LA(1) =20 - if (LA16_0 =3D=3D IDENTIFIER or (34 <=3D LA16_0 <=3D 4= 2) or (45 <=3D LA16_0 <=3D 46) or (48 <=3D LA16_0 <=3D 61)) : + if (LA16_0 =3D=3D IDENTIFIER or (34 <=3D LA16_0 <=3D 4= 2) or (45 <=3D LA16_0 <=3D 46) or (48 <=3D LA16_0 <=3D 61)): alt16 =3D 1 =20 - if alt16 =3D=3D 1: # C.g:0:0: struct_declaration - self.following.append(self.FOLLOW_struct_declarati= on_in_struct_declaration_list537) + self.following.append( + self.FOLLOW_struct_declaration_in_struct_decla= ration_list537) self.struct_declaration() self.following.pop() if self.failed: return =20 - else: if cnt16 >=3D 1: - break #loop16 + break # loop16 =20 if self.backtracking > 0: self.failed =3D True @@ -1690,17 +1666,13 @@ class CParser(Parser): =20 cnt16 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 13, struct_declaration_list_Start= Index) + self.memoize(self.input, 13, + struct_declaration_list_StartIndex) =20 pass =20 @@ -1708,9 +1680,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declaration_list =20 - # $ANTLR start struct_declaration # C.g:248:1: struct_declaration : specifier_qualifier_list struct_decl= arator_list ';' ; + def struct_declaration(self, ): =20 struct_declaration_StartIndex =3D self.input.index() @@ -1721,23 +1693,23 @@ class CParser(Parser): =20 # C.g:249:2: ( specifier_qualifier_list struct_declarator_= list ';' ) # C.g:249:4: specifier_qualifier_list struct_declarator_li= st ';' - self.following.append(self.FOLLOW_specifier_qualifier_list= _in_struct_declaration549) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_struct_declara= tion549) self.specifier_qualifier_list() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_struct_declarator_list_i= n_struct_declaration551) + self.following.append( + self.FOLLOW_struct_declarator_list_in_struct_declarati= on551) self.struct_declarator_list() self.following.pop() if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_struct_declar= ation553) + self.match(self.input, 25, + self.FOLLOW_25_in_struct_declaration553) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -1751,9 +1723,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declaration =20 - # $ANTLR start specifier_qualifier_list # C.g:252:1: specifier_qualifier_list : ( type_qualifier | type_specif= ier )+ ; + def specifier_qualifier_list(self, ): =20 specifier_qualifier_list_StartIndex =3D self.input.index() @@ -1766,30 +1738,27 @@ class CParser(Parser): # C.g:253:4: ( type_qualifier | type_specifier )+ # C.g:253:4: ( type_qualifier | type_specifier )+ cnt17 =3D 0 - while True: #loop17 + while True: # loop17 alt17 =3D 3 LA17 =3D self.input.LA(1) if LA17 =3D=3D 58: LA17_2 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D 59: LA17_3 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D 60: LA17_4 =3D self.input.LA(2) =20 - if (self.synpred39()) : + if (self.synpred39()): alt17 =3D 1 =20 - elif LA17 =3D=3D IDENTIFIER: LA17 =3D self.input.LA(2) if LA17 =3D=3D EOF or LA17 =3D=3D IDENTIFIER or LA= 17 =3D=3D 34 or LA17 =3D=3D 35 or LA17 =3D=3D 36 or LA17 =3D=3D 37 or LA17 = =3D=3D 38 or LA17 =3D=3D 39 or LA17 =3D=3D 40 or LA17 =3D=3D 41 or LA17 =3D= =3D 42 or LA17 =3D=3D 45 or LA17 =3D=3D 46 or LA17 =3D=3D 48 or LA17 =3D=3D= 49 or LA17 =3D=3D 50 or LA17 =3D=3D 51 or LA17 =3D=3D 52 or LA17 =3D=3D 53= or LA17 =3D=3D 54 or LA17 =3D=3D 55 or LA17 =3D=3D 56 or LA17 =3D=3D 57 or= LA17 =3D=3D 58 or LA17 =3D=3D 59 or LA17 =3D=3D 60 or LA17 =3D=3D 61 or LA= 17 =3D=3D 63 or LA17 =3D=3D 66: @@ -1797,25 +1766,21 @@ class CParser(Parser): elif LA17 =3D=3D 62: LA17_94 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - elif LA17 =3D=3D 47: LA17_95 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - elif LA17 =3D=3D 64: LA17_96 =3D self.input.LA(3) =20 - if (self.synpred40()) : + if (self.synpred40()): alt17 =3D 2 =20 - - elif LA17 =3D=3D 49 or LA17 =3D=3D 50 or LA17 =3D=3D 5= 1 or LA17 =3D=3D 52 or LA17 =3D=3D 53 or LA17 =3D=3D 54 or LA17 =3D=3D 55 o= r LA17 =3D=3D 56 or LA17 =3D=3D 57 or LA17 =3D=3D 61: alt17 =3D 1 elif LA17 =3D=3D 34 or LA17 =3D=3D 35 or LA17 =3D=3D 3= 6 or LA17 =3D=3D 37 or LA17 =3D=3D 38 or LA17 =3D=3D 39 or LA17 =3D=3D 40 o= r LA17 =3D=3D 41 or LA17 =3D=3D 42 or LA17 =3D=3D 45 or LA17 =3D=3D 46 or L= A17 =3D=3D 48: @@ -1823,25 +1788,25 @@ class CParser(Parser): =20 if alt17 =3D=3D 1: # C.g:253:6: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_i= n_specifier_qualifier_list566) + self.following.append( + self.FOLLOW_type_qualifier_in_specifier_qualif= ier_list566) self.type_qualifier() self.following.pop() if self.failed: return =20 - elif alt17 =3D=3D 2: # C.g:253:23: type_specifier - self.following.append(self.FOLLOW_type_specifier_i= n_specifier_qualifier_list570) + self.following.append( + self.FOLLOW_type_specifier_in_specifier_qualif= ier_list570) self.type_specifier() self.following.pop() if self.failed: return =20 - else: if cnt17 >=3D 1: - break #loop17 + break # loop17 =20 if self.backtracking > 0: self.failed =3D True @@ -1852,17 +1817,13 @@ class CParser(Parser): =20 cnt17 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 15, specifier_qualifier_list_Star= tIndex) + self.memoize(self.input, 15, + specifier_qualifier_list_StartIndex) =20 pass =20 @@ -1870,9 +1831,9 @@ class CParser(Parser): =20 # $ANTLR end specifier_qualifier_list =20 - # $ANTLR start struct_declarator_list # C.g:256:1: struct_declarator_list : struct_declarator ( ',' struct_d= eclarator )* ; + def struct_declarator_list(self, ): =20 struct_declarator_list_StartIndex =3D self.input.index() @@ -1883,39 +1844,35 @@ class CParser(Parser): =20 # C.g:257:2: ( struct_declarator ( ',' struct_declarator )= * ) # C.g:257:4: struct_declarator ( ',' struct_declarator )* - self.following.append(self.FOLLOW_struct_declarator_in_str= uct_declarator_list584) + self.following.append( + self.FOLLOW_struct_declarator_in_struct_declarator_lis= t584) self.struct_declarator() self.following.pop() if self.failed: return # C.g:257:22: ( ',' struct_declarator )* - while True: #loop18 + while True: # loop18 alt18 =3D 2 LA18_0 =3D self.input.LA(1) =20 - if (LA18_0 =3D=3D 27) : + if (LA18_0 =3D=3D 27): alt18 =3D 1 =20 - if alt18 =3D=3D 1: # C.g:257:23: ',' struct_declarator - self.match(self.input, 27, self.FOLLOW_27_in_struc= t_declarator_list587) + self.match(self.input, 27, + self.FOLLOW_27_in_struct_declarator_lis= t587) if self.failed: return - self.following.append(self.FOLLOW_struct_declarato= r_in_struct_declarator_list589) + self.following.append( + self.FOLLOW_struct_declarator_in_struct_declar= ator_list589) self.struct_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop18 - - - - - + break # loop18 =20 except RecognitionException as re: self.reportError(re) @@ -1930,9 +1887,9 @@ class CParser(Parser): =20 # $ANTLR end struct_declarator_list =20 - # $ANTLR start struct_declarator # C.g:260:1: struct_declarator : ( declarator ( ':' constant_expressio= n )? | ':' constant_expression ); + def struct_declarator(self, ): =20 struct_declarator_StartIndex =3D self.input.index() @@ -1945,22 +1902,24 @@ class CParser(Parser): alt20 =3D 2 LA20_0 =3D self.input.LA(1) =20 - if (LA20_0 =3D=3D IDENTIFIER or (58 <=3D LA20_0 <=3D 60) o= r LA20_0 =3D=3D 62 or LA20_0 =3D=3D 66) : + if (LA20_0 =3D=3D IDENTIFIER or (58 <=3D LA20_0 <=3D 60) o= r LA20_0 =3D=3D 62 or LA20_0 =3D=3D 66): alt20 =3D 1 - elif (LA20_0 =3D=3D 47) : + elif (LA20_0 =3D=3D 47): alt20 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("260:1: struct_declarato= r : ( declarator ( ':' constant_expression )? | ':' constant_expression );"= , 20, 0, self.input) + nvae =3D NoViableAltException( + "260:1: struct_declarator : ( declarator ( ':' con= stant_expression )? | ':' constant_expression );", 20, 0, self.input) =20 raise nvae =20 if alt20 =3D=3D 1: # C.g:261:4: declarator ( ':' constant_expression )? - self.following.append(self.FOLLOW_declarator_in_struct= _declarator602) + self.following.append( + self.FOLLOW_declarator_in_struct_declarator602) self.declarator() self.following.pop() if self.failed: @@ -1969,36 +1928,34 @@ class CParser(Parser): alt19 =3D 2 LA19_0 =3D self.input.LA(1) =20 - if (LA19_0 =3D=3D 47) : + if (LA19_0 =3D=3D 47): alt19 =3D 1 if alt19 =3D=3D 1: # C.g:261:16: ':' constant_expression - self.match(self.input, 47, self.FOLLOW_47_in_struc= t_declarator605) + self.match(self.input, 47, + self.FOLLOW_47_in_struct_declarator605) if self.failed: return - self.following.append(self.FOLLOW_constant_express= ion_in_struct_declarator607) + self.following.append( + self.FOLLOW_constant_expression_in_struct_decl= arator607) self.constant_expression() self.following.pop() if self.failed: return =20 - - - - elif alt20 =3D=3D 2: # C.g:262:4: ':' constant_expression - self.match(self.input, 47, self.FOLLOW_47_in_struct_de= clarator614) + self.match(self.input, 47, + self.FOLLOW_47_in_struct_declarator614) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_struct_declarator616) + self.following.append( + self.FOLLOW_constant_expression_in_struct_declarat= or616) self.constant_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2017,10 +1974,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start enum_specifier # C.g:265:1: enum_specifier options {k=3D3; } : ( 'enum' '{' enumerato= r_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list ( ',' )? '}' | = 'enum' IDENTIFIER ); + def enum_specifier(self, ): =20 retval =3D self.enum_specifier_return() @@ -2035,33 +1991,35 @@ class CParser(Parser): alt23 =3D 3 LA23_0 =3D self.input.LA(1) =20 - if (LA23_0 =3D=3D 48) : + if (LA23_0 =3D=3D 48): LA23_1 =3D self.input.LA(2) =20 - if (LA23_1 =3D=3D IDENTIFIER) : + if (LA23_1 =3D=3D IDENTIFIER): LA23_2 =3D self.input.LA(3) =20 - if (LA23_2 =3D=3D 43) : + if (LA23_2 =3D=3D 43): alt23 =3D 2 - elif (LA23_2 =3D=3D EOF or LA23_2 =3D=3D IDENTIFIE= R or LA23_2 =3D=3D 25 or LA23_2 =3D=3D 27 or (29 <=3D LA23_2 <=3D 42) or (4= 5 <=3D LA23_2 <=3D 64) or LA23_2 =3D=3D 66) : + elif (LA23_2 =3D=3D EOF or LA23_2 =3D=3D IDENTIFIE= R or LA23_2 =3D=3D 25 or LA23_2 =3D=3D 27 or (29 <=3D LA23_2 <=3D 42) or (4= 5 <=3D LA23_2 <=3D 64) or LA23_2 =3D=3D 66): alt23 =3D 3 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_spe= cifier options {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enu= m' IDENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23,= 2, self.input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } := ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerat= or_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 2, self.input) =20 raise nvae =20 - elif (LA23_1 =3D=3D 43) : + elif (LA23_1 =3D=3D 43): alt23 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_specifi= er options {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' I= DENTIFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 1, = self.input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } : ( '= enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_l= ist ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 1, self.input) =20 raise nvae =20 @@ -2070,19 +2028,23 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("265:1: enum_specifier o= ptions {k=3D3; } : ( 'enum' '{' enumerator_list ( ',' )? '}' | 'enum' IDENT= IFIER '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 0, self= .input) + nvae =3D NoViableAltException( + "265:1: enum_specifier options {k=3D3; } : ( 'enum= ' '{' enumerator_list ( ',' )? '}' | 'enum' IDENTIFIER '{' enumerator_list = ( ',' )? '}' | 'enum' IDENTIFIER );", 23, 0, self.input) =20 raise nvae =20 if alt23 =3D=3D 1: # C.g:267:4: 'enum' '{' enumerator_list ( ',' )? '}' - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier634) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier634) if self.failed: return retval - self.match(self.input, 43, self.FOLLOW_43_in_enum_spec= ifier636) + self.match(self.input, 43, + self.FOLLOW_43_in_enum_specifier636) if self.failed: return retval - self.following.append(self.FOLLOW_enumerator_list_in_e= num_specifier638) + self.following.append( + self.FOLLOW_enumerator_list_in_enum_specifier638) self.enumerator_list() self.following.pop() if self.failed: @@ -2091,33 +2053,36 @@ class CParser(Parser): alt21 =3D 2 LA21_0 =3D self.input.LA(1) =20 - if (LA21_0 =3D=3D 27) : + if (LA21_0 =3D=3D 27): alt21 =3D 1 if alt21 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_enum_= specifier640) + self.match(self.input, 27, + self.FOLLOW_27_in_enum_specifier640) if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_enum_spec= ifier643) + self.match(self.input, 44, + self.FOLLOW_44_in_enum_specifier643) if self.failed: return retval =20 - elif alt23 =3D=3D 2: # C.g:268:4: 'enum' IDENTIFIER '{' enumerator_list ( '= ,' )? '}' - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier648) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier648) if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_enum_specifier650) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enum_specifier650) if self.failed: return retval - self.match(self.input, 43, self.FOLLOW_43_in_enum_spec= ifier652) + self.match(self.input, 43, + self.FOLLOW_43_in_enum_specifier652) if self.failed: return retval - self.following.append(self.FOLLOW_enumerator_list_in_e= num_specifier654) + self.following.append( + self.FOLLOW_enumerator_list_in_enum_specifier654) self.enumerator_list() self.following.pop() if self.failed: @@ -2126,34 +2091,33 @@ class CParser(Parser): alt22 =3D 2 LA22_0 =3D self.input.LA(1) =20 - if (LA22_0 =3D=3D 27) : + if (LA22_0 =3D=3D 27): alt22 =3D 1 if alt22 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_enum_= specifier656) + self.match(self.input, 27, + self.FOLLOW_27_in_enum_specifier656) if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_enum_spec= ifier659) + self.match(self.input, 44, + self.FOLLOW_44_in_enum_specifier659) if self.failed: return retval =20 - elif alt23 =3D=3D 3: # C.g:269:4: 'enum' IDENTIFIER - self.match(self.input, 48, self.FOLLOW_48_in_enum_spec= ifier664) + self.match(self.input, 48, + self.FOLLOW_48_in_enum_specifier664) if self.failed: return retval - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_enum_specifier666) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enum_specifier666) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2167,9 +2131,9 @@ class CParser(Parser): =20 # $ANTLR end enum_specifier =20 - # $ANTLR start enumerator_list # C.g:272:1: enumerator_list : enumerator ( ',' enumerator )* ; + def enumerator_list(self, ): =20 enumerator_list_StartIndex =3D self.input.index() @@ -2180,44 +2144,38 @@ class CParser(Parser): =20 # C.g:273:2: ( enumerator ( ',' enumerator )* ) # C.g:273:4: enumerator ( ',' enumerator )* - self.following.append(self.FOLLOW_enumerator_in_enumerator= _list677) + self.following.append( + self.FOLLOW_enumerator_in_enumerator_list677) self.enumerator() self.following.pop() if self.failed: return # C.g:273:15: ( ',' enumerator )* - while True: #loop24 + while True: # loop24 alt24 =3D 2 LA24_0 =3D self.input.LA(1) =20 - if (LA24_0 =3D=3D 27) : + if (LA24_0 =3D=3D 27): LA24_1 =3D self.input.LA(2) =20 - if (LA24_1 =3D=3D IDENTIFIER) : + if (LA24_1 =3D=3D IDENTIFIER): alt24 =3D 1 =20 - - - if alt24 =3D=3D 1: # C.g:273:16: ',' enumerator - self.match(self.input, 27, self.FOLLOW_27_in_enume= rator_list680) + self.match(self.input, 27, + self.FOLLOW_27_in_enumerator_list680) if self.failed: return - self.following.append(self.FOLLOW_enumerator_in_en= umerator_list682) + self.following.append( + self.FOLLOW_enumerator_in_enumerator_list682) self.enumerator() self.following.pop() if self.failed: return =20 - else: - break #loop24 - - - - - + break # loop24 =20 except RecognitionException as re: self.reportError(re) @@ -2232,9 +2190,9 @@ class CParser(Parser): =20 # $ANTLR end enumerator_list =20 - # $ANTLR start enumerator # C.g:276:1: enumerator : IDENTIFIER ( '=3D' constant_expression )? ; + def enumerator(self, ): =20 enumerator_StartIndex =3D self.input.index() @@ -2245,32 +2203,28 @@ class CParser(Parser): =20 # C.g:277:2: ( IDENTIFIER ( '=3D' constant_expression )? ) # C.g:277:4: IDENTIFIER ( '=3D' constant_expression )? - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_enumerator695) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_enumerator695) if self.failed: return # C.g:277:15: ( '=3D' constant_expression )? alt25 =3D 2 LA25_0 =3D self.input.LA(1) =20 - if (LA25_0 =3D=3D 28) : + if (LA25_0 =3D=3D 28): alt25 =3D 1 if alt25 =3D=3D 1: # C.g:277:16: '=3D' constant_expression self.match(self.input, 28, self.FOLLOW_28_in_enumerato= r698) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_enumerator700) + self.following.append( + self.FOLLOW_constant_expression_in_enumerator700) self.constant_expression() self.following.pop() if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2284,9 +2238,9 @@ class CParser(Parser): =20 # $ANTLR end enumerator =20 - # $ANTLR start type_qualifier # C.g:280:1: type_qualifier : ( 'const' | 'volatile' | 'IN' | 'OUT' | = 'OPTIONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFER= ENCED' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' ); + def type_qualifier(self, ): =20 type_qualifier_StartIndex =3D self.input.index() @@ -2298,7 +2252,7 @@ class CParser(Parser): # C.g:281:2: ( 'const' | 'volatile' | 'IN' | 'OUT' | 'OPTI= ONAL' | 'CONST' | 'UNALIGNED' | 'VOLATILE' | 'GLOBAL_REMOVE_IF_UNREFERENCED= ' | 'EFIAPI' | 'EFI_BOOTSERVICE' | 'EFI_RUNTIMESERVICE' | 'PACKED' ) # C.g: if (49 <=3D self.input.LA(1) <=3D 61): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -2310,14 +2264,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_type_qualifier0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2336,10 +2285,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start declarator # C.g:296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERV= ICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointer ); + def declarator(self, ): =20 retval =3D self.declarator_return() @@ -2354,30 +2302,32 @@ class CParser(Parser): alt30 =3D 2 LA30_0 =3D self.input.LA(1) =20 - if (LA30_0 =3D=3D 66) : + if (LA30_0 =3D=3D 66): LA30_1 =3D self.input.LA(2) =20 - if (self.synpred66()) : + if (self.synpred66()): alt30 =3D 1 - elif (True) : + elif (True): alt30 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("296:1: declarator := ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE'= )? direct_declarator | pointer );", 30, 1, self.input) + nvae =3D NoViableAltException( + "296:1: declarator : ( ( pointer )? ( 'EFIAPI'= )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | po= inter );", 30, 1, self.input) =20 raise nvae =20 - elif (LA30_0 =3D=3D IDENTIFIER or (58 <=3D LA30_0 <=3D 60)= or LA30_0 =3D=3D 62) : + elif (LA30_0 =3D=3D IDENTIFIER or (58 <=3D LA30_0 <=3D 60)= or LA30_0 =3D=3D 62): alt30 =3D 1 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("296:1: declarator : ( (= pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? = direct_declarator | pointer );", 30, 0, self.input) + nvae =3D NoViableAltException( + "296:1: declarator : ( ( pointer )? ( 'EFIAPI' )? = ( 'EFI_BOOTSERVICE' )? ( 'EFI_RUNTIMESERVICE' )? direct_declarator | pointe= r );", 30, 0, self.input) =20 raise nvae =20 @@ -2387,67 +2337,63 @@ class CParser(Parser): alt26 =3D 2 LA26_0 =3D self.input.LA(1) =20 - if (LA26_0 =3D=3D 66) : + if (LA26_0 =3D=3D 66): alt26 =3D 1 if alt26 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_decla= rator784) + self.following.append( + self.FOLLOW_pointer_in_declarator784) self.pointer() self.following.pop() if self.failed: return retval =20 - - # C.g:297:13: ( 'EFIAPI' )? alt27 =3D 2 LA27_0 =3D self.input.LA(1) =20 - if (LA27_0 =3D=3D 58) : + if (LA27_0 =3D=3D 58): alt27 =3D 1 if alt27 =3D=3D 1: # C.g:297:14: 'EFIAPI' - self.match(self.input, 58, self.FOLLOW_58_in_decla= rator788) + self.match(self.input, 58, + self.FOLLOW_58_in_declarator788) if self.failed: return retval =20 - - # C.g:297:25: ( 'EFI_BOOTSERVICE' )? alt28 =3D 2 LA28_0 =3D self.input.LA(1) =20 - if (LA28_0 =3D=3D 59) : + if (LA28_0 =3D=3D 59): alt28 =3D 1 if alt28 =3D=3D 1: # C.g:297:26: 'EFI_BOOTSERVICE' - self.match(self.input, 59, self.FOLLOW_59_in_decla= rator793) + self.match(self.input, 59, + self.FOLLOW_59_in_declarator793) if self.failed: return retval =20 - - # C.g:297:46: ( 'EFI_RUNTIMESERVICE' )? alt29 =3D 2 LA29_0 =3D self.input.LA(1) =20 - if (LA29_0 =3D=3D 60) : + if (LA29_0 =3D=3D 60): alt29 =3D 1 if alt29 =3D=3D 1: # C.g:297:47: 'EFI_RUNTIMESERVICE' - self.match(self.input, 60, self.FOLLOW_60_in_decla= rator798) + self.match(self.input, 60, + self.FOLLOW_60_in_declarator798) if self.failed: return retval =20 - - - self.following.append(self.FOLLOW_direct_declarator_in= _declarator802) + self.following.append( + self.FOLLOW_direct_declarator_in_declarator802) self.direct_declarator() self.following.pop() if self.failed: return retval =20 - elif alt30 =3D=3D 2: # C.g:299:4: pointer self.following.append(self.FOLLOW_pointer_in_declarato= r808) @@ -2456,10 +2402,8 @@ class CParser(Parser): if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -2473,9 +2417,9 @@ class CParser(Parser): =20 # $ANTLR end declarator =20 - # $ANTLR start direct_declarator # C.g:302:1: direct_declarator : ( IDENTIFIER ( declarator_suffix )* |= '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ ); + def direct_declarator(self, ): =20 direct_declarator_StartIndex =3D self.input.index() @@ -2488,556 +2432,485 @@ class CParser(Parser): alt34 =3D 2 LA34_0 =3D self.input.LA(1) =20 - if (LA34_0 =3D=3D IDENTIFIER) : + if (LA34_0 =3D=3D IDENTIFIER): alt34 =3D 1 - elif (LA34_0 =3D=3D 62) : + elif (LA34_0 =3D=3D 62): alt34 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("302:1: direct_declarato= r : ( IDENTIFIER ( declarator_suffix )* | '(' ( 'EFIAPI' )? declarator ')' = ( declarator_suffix )+ );", 34, 0, self.input) + nvae =3D NoViableAltException( + "302:1: direct_declarator : ( IDENTIFIER ( declara= tor_suffix )* | '(' ( 'EFIAPI' )? declarator ')' ( declarator_suffix )+ );"= , 34, 0, self.input) =20 raise nvae =20 if alt34 =3D=3D 1: # C.g:303:4: IDENTIFIER ( declarator_suffix )* - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_direct_declarator819) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_direct_declarator= 819) if self.failed: return # C.g:303:15: ( declarator_suffix )* - while True: #loop31 + while True: # loop31 alt31 =3D 2 LA31_0 =3D self.input.LA(1) =20 - if (LA31_0 =3D=3D 62) : + if (LA31_0 =3D=3D 62): LA31 =3D self.input.LA(2) if LA31 =3D=3D 63: LA31_30 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 58: LA31_31 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 66: LA31_32 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 59: LA31_33 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 60: LA31_34 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D IDENTIFIER: LA31_35 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 29 or LA31 =3D=3D 30 or LA31 = =3D=3D 31 or LA31 =3D=3D 32 or LA31 =3D=3D 33: LA31_37 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 34: LA31_38 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 35: LA31_39 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 36: LA31_40 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 37: LA31_41 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 38: LA31_42 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 39: LA31_43 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 40: LA31_44 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 41: LA31_45 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 42: LA31_46 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 45 or LA31 =3D=3D 46: LA31_47 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 48: LA31_48 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 49 or LA31 =3D=3D 50 or LA31 = =3D=3D 51 or LA31 =3D=3D 52 or LA31 =3D=3D 53 or LA31 =3D=3D 54 or LA31 =3D= =3D 55 or LA31 =3D=3D 56 or LA31 =3D=3D 57 or LA31 =3D=3D 61: LA31_49 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - - - elif (LA31_0 =3D=3D 64) : + elif (LA31_0 =3D=3D 64): LA31 =3D self.input.LA(2) if LA31 =3D=3D 65: LA31_51 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 62: LA31_52 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D IDENTIFIER: LA31_53 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D HEX_LITERAL: LA31_54 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D OCTAL_LITERAL: LA31_55 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D DECIMAL_LITERAL: LA31_56 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D CHARACTER_LITERAL: LA31_57 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D STRING_LITERAL: LA31_58 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D FLOATING_POINT_LITERAL: LA31_59 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 72: LA31_60 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 73: LA31_61 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 66 or LA31 =3D=3D 68 or LA31 = =3D=3D 69 or LA31 =3D=3D 77 or LA31 =3D=3D 78 or LA31 =3D=3D 79: LA31_62 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - elif LA31 =3D=3D 74: LA31_63 =3D self.input.LA(3) =20 - if (self.synpred67()) : + if (self.synpred67()): alt31 =3D 1 =20 - - - - if alt31 =3D=3D 1: # C.g:0:0: declarator_suffix - self.following.append(self.FOLLOW_declarator_s= uffix_in_direct_declarator821) + self.following.append( + self.FOLLOW_declarator_suffix_in_direct_de= clarator821) self.declarator_suffix() self.following.pop() if self.failed: return =20 - else: - break #loop31 - - - + break # loop31 =20 elif alt34 =3D=3D 2: # C.g:304:4: '(' ( 'EFIAPI' )? declarator ')' ( declar= ator_suffix )+ - self.match(self.input, 62, self.FOLLOW_62_in_direct_de= clarator827) + self.match(self.input, 62, + self.FOLLOW_62_in_direct_declarator827) if self.failed: return # C.g:304:8: ( 'EFIAPI' )? alt32 =3D 2 LA32_0 =3D self.input.LA(1) =20 - if (LA32_0 =3D=3D 58) : + if (LA32_0 =3D=3D 58): LA32_1 =3D self.input.LA(2) =20 - if (self.synpred69()) : + if (self.synpred69()): alt32 =3D 1 if alt32 =3D=3D 1: # C.g:304:9: 'EFIAPI' - self.match(self.input, 58, self.FOLLOW_58_in_direc= t_declarator830) + self.match(self.input, 58, + self.FOLLOW_58_in_direct_declarator830) if self.failed: return =20 - - - self.following.append(self.FOLLOW_declarator_in_direct= _declarator834) + self.following.append( + self.FOLLOW_declarator_in_direct_declarator834) self.declarator() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_direct_de= clarator836) + self.match(self.input, 63, + self.FOLLOW_63_in_direct_declarator836) if self.failed: return # C.g:304:35: ( declarator_suffix )+ cnt33 =3D 0 - while True: #loop33 + while True: # loop33 alt33 =3D 2 LA33_0 =3D self.input.LA(1) =20 - if (LA33_0 =3D=3D 62) : + if (LA33_0 =3D=3D 62): LA33 =3D self.input.LA(2) if LA33 =3D=3D 63: LA33_30 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 58: LA33_31 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 66: LA33_32 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 59: LA33_33 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 60: LA33_34 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D IDENTIFIER: LA33_35 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 29 or LA33 =3D=3D 30 or LA33 = =3D=3D 31 or LA33 =3D=3D 32 or LA33 =3D=3D 33: LA33_37 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 34: LA33_38 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 35: LA33_39 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 36: LA33_40 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 37: LA33_41 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 38: LA33_42 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 39: LA33_43 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 40: LA33_44 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 41: LA33_45 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 42: LA33_46 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 45 or LA33 =3D=3D 46: LA33_47 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 48: LA33_48 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 49 or LA33 =3D=3D 50 or LA33 = =3D=3D 51 or LA33 =3D=3D 52 or LA33 =3D=3D 53 or LA33 =3D=3D 54 or LA33 =3D= =3D 55 or LA33 =3D=3D 56 or LA33 =3D=3D 57 or LA33 =3D=3D 61: LA33_49 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - - - elif (LA33_0 =3D=3D 64) : + elif (LA33_0 =3D=3D 64): LA33 =3D self.input.LA(2) if LA33 =3D=3D 65: LA33_51 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 62: LA33_52 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D IDENTIFIER: LA33_53 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D HEX_LITERAL: LA33_54 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D OCTAL_LITERAL: LA33_55 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D DECIMAL_LITERAL: LA33_56 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D CHARACTER_LITERAL: LA33_57 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D STRING_LITERAL: LA33_58 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D FLOATING_POINT_LITERAL: LA33_59 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 72: LA33_60 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 73: LA33_61 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 66 or LA33 =3D=3D 68 or LA33 = =3D=3D 69 or LA33 =3D=3D 77 or LA33 =3D=3D 78 or LA33 =3D=3D 79: LA33_62 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - elif LA33 =3D=3D 74: LA33_63 =3D self.input.LA(3) =20 - if (self.synpred70()) : + if (self.synpred70()): alt33 =3D 1 =20 - - - - if alt33 =3D=3D 1: # C.g:0:0: declarator_suffix - self.following.append(self.FOLLOW_declarator_s= uffix_in_direct_declarator838) + self.following.append( + self.FOLLOW_declarator_suffix_in_direct_de= clarator838) self.declarator_suffix() self.following.pop() if self.failed: return =20 - else: if cnt33 >=3D 1: - break #loop33 + break # loop33 =20 if self.backtracking > 0: self.failed =3D True @@ -3048,10 +2921,6 @@ class CParser(Parser): =20 cnt33 +=3D 1 =20 - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3065,9 +2934,9 @@ class CParser(Parser): =20 # $ANTLR end direct_declarator =20 - # $ANTLR start declarator_suffix # C.g:307:1: declarator_suffix : ( '[' constant_expression ']' | '[' '= ]' | '(' parameter_type_list ')' | '(' identifier_list ')' | '(' ')' ); + def declarator_suffix(self, ): =20 declarator_suffix_StartIndex =3D self.input.index() @@ -3080,23 +2949,24 @@ class CParser(Parser): alt35 =3D 5 LA35_0 =3D self.input.LA(1) =20 - if (LA35_0 =3D=3D 64) : + if (LA35_0 =3D=3D 64): LA35_1 =3D self.input.LA(2) =20 - if (LA35_1 =3D=3D 65) : + if (LA35_1 =3D=3D 65): alt35 =3D 2 - elif ((IDENTIFIER <=3D LA35_1 <=3D FLOATING_POINT_LITE= RAL) or LA35_1 =3D=3D 62 or LA35_1 =3D=3D 66 or (68 <=3D LA35_1 <=3D 69) or= (72 <=3D LA35_1 <=3D 74) or (77 <=3D LA35_1 <=3D 79)) : + elif ((IDENTIFIER <=3D LA35_1 <=3D FLOATING_POINT_LITE= RAL) or LA35_1 =3D=3D 62 or LA35_1 =3D=3D 66 or (68 <=3D LA35_1 <=3D 69) or= (72 <=3D LA35_1 <=3D 74) or (77 <=3D LA35_1 <=3D 79)): alt35 =3D 1 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_s= uffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list '= )' | '(' identifier_list ')' | '(' ')' );", 35, 1, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_exp= ression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list '= )' | '(' ')' );", 35, 1, self.input) =20 raise nvae =20 - elif (LA35_0 =3D=3D 62) : + elif (LA35_0 =3D=3D 62): LA35 =3D self.input.LA(2) if LA35 =3D=3D 63: alt35 =3D 5 @@ -3105,16 +2975,17 @@ class CParser(Parser): elif LA35 =3D=3D IDENTIFIER: LA35_29 =3D self.input.LA(3) =20 - if (self.synpred73()) : + if (self.synpred73()): alt35 =3D 3 - elif (self.synpred74()) : + elif (self.synpred74()): alt35 =3D 4 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarat= or_suffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_li= st ')' | '(' identifier_list ')' | '(' ')' );", 35, 29, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant= _expression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_li= st ')' | '(' ')' );", 35, 29, self.input) =20 raise nvae =20 @@ -3123,7 +2994,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_s= uffix : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list '= )' | '(' identifier_list ')' | '(' ')' );", 35, 2, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_exp= ression ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list '= )' | '(' ')' );", 35, 2, self.input) =20 raise nvae =20 @@ -3132,76 +3004,84 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("307:1: declarator_suffi= x : ( '[' constant_expression ']' | '[' ']' | '(' parameter_type_list ')' |= '(' identifier_list ')' | '(' ')' );", 35, 0, self.input) + nvae =3D NoViableAltException( + "307:1: declarator_suffix : ( '[' constant_express= ion ']' | '[' ']' | '(' parameter_type_list ')' | '(' identifier_list ')' |= '(' ')' );", 35, 0, self.input) =20 raise nvae =20 if alt35 =3D=3D 1: # C.g:308:6: '[' constant_expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_declarato= r_suffix852) + self.match(self.input, 64, + self.FOLLOW_64_in_declarator_suffix852) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_declarator_suffix854) + self.following.append( + self.FOLLOW_constant_expression_in_declarator_suff= ix854) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_declarato= r_suffix856) + self.match(self.input, 65, + self.FOLLOW_65_in_declarator_suffix856) if self.failed: return =20 - elif alt35 =3D=3D 2: # C.g:309:9: '[' ']' - self.match(self.input, 64, self.FOLLOW_64_in_declarato= r_suffix866) + self.match(self.input, 64, + self.FOLLOW_64_in_declarator_suffix866) if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_declarato= r_suffix868) + self.match(self.input, 65, + self.FOLLOW_65_in_declarator_suffix868) if self.failed: return =20 - elif alt35 =3D=3D 3: # C.g:310:9: '(' parameter_type_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix878) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix878) if self.failed: return - self.following.append(self.FOLLOW_parameter_type_list_= in_declarator_suffix880) + self.following.append( + self.FOLLOW_parameter_type_list_in_declarator_suff= ix880) self.parameter_type_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix882) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix882) if self.failed: return =20 - elif alt35 =3D=3D 4: # C.g:311:9: '(' identifier_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix892) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix892) if self.failed: return - self.following.append(self.FOLLOW_identifier_list_in_d= eclarator_suffix894) + self.following.append( + self.FOLLOW_identifier_list_in_declarator_suffix89= 4) self.identifier_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix896) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix896) if self.failed: return =20 - elif alt35 =3D=3D 5: # C.g:312:9: '(' ')' - self.match(self.input, 62, self.FOLLOW_62_in_declarato= r_suffix906) + self.match(self.input, 62, + self.FOLLOW_62_in_declarator_suffix906) if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_declarato= r_suffix908) + self.match(self.input, 63, + self.FOLLOW_63_in_declarator_suffix908) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3215,9 +3095,9 @@ class CParser(Parser): =20 # $ANTLR end declarator_suffix =20 - # $ANTLR start pointer # C.g:315:1: pointer : ( '*' ( type_qualifier )+ ( pointer )? | '*' po= inter | '*' ); + def pointer(self, ): =20 pointer_StartIndex =3D self.input.index() @@ -3230,69 +3110,73 @@ class CParser(Parser): alt38 =3D 3 LA38_0 =3D self.input.LA(1) =20 - if (LA38_0 =3D=3D 66) : + if (LA38_0 =3D=3D 66): LA38 =3D self.input.LA(2) if LA38 =3D=3D 66: LA38_2 =3D self.input.LA(3) =20 - if (self.synpred78()) : + if (self.synpred78()): alt38 =3D 2 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 2, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 2, self.input) =20 raise nvae =20 elif LA38 =3D=3D 58: LA38_3 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 3, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 3, self.input) =20 raise nvae =20 elif LA38 =3D=3D 59: LA38_4 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 4, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 4, self.input) =20 raise nvae =20 elif LA38 =3D=3D 60: LA38_5 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 5, se= lf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 5, self.input) =20 raise nvae =20 @@ -3301,32 +3185,34 @@ class CParser(Parser): elif LA38 =3D=3D 53: LA38_21 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 21, s= elf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 21, self.input) =20 raise nvae =20 elif LA38 =3D=3D 49 or LA38 =3D=3D 50 or LA38 =3D=3D 5= 1 or LA38 =3D=3D 52 or LA38 =3D=3D 54 or LA38 =3D=3D 55 or LA38 =3D=3D 56 o= r LA38 =3D=3D 57 or LA38 =3D=3D 61: LA38_29 =3D self.input.LA(3) =20 - if (self.synpred77()) : + if (self.synpred77()): alt38 =3D 1 - elif (True) : + elif (True): alt38 =3D 3 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer = : ( '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 29, s= elf.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )= + ( pointer )? | '*' pointer | '*' );", 38, 29, self.input) =20 raise nvae =20 @@ -3335,7 +3221,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer : ( = '*' ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 1, self.i= nput) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )+ ( = pointer )? | '*' pointer | '*' );", 38, 1, self.input) =20 raise nvae =20 @@ -3344,7 +3231,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("315:1: pointer : ( '*' = ( type_qualifier )+ ( pointer )? | '*' pointer | '*' );", 38, 0, self.input) + nvae =3D NoViableAltException( + "315:1: pointer : ( '*' ( type_qualifier )+ ( poin= ter )? | '*' pointer | '*' );", 38, 0, self.input) =20 raise nvae =20 @@ -3355,57 +3243,51 @@ class CParser(Parser): return # C.g:316:8: ( type_qualifier )+ cnt36 =3D 0 - while True: #loop36 + while True: # loop36 alt36 =3D 2 LA36 =3D self.input.LA(1) if LA36 =3D=3D 58: LA36_2 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 59: LA36_3 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 60: LA36_4 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 53: LA36_20 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - elif LA36 =3D=3D 49 or LA36 =3D=3D 50 or LA36 =3D= =3D 51 or LA36 =3D=3D 52 or LA36 =3D=3D 54 or LA36 =3D=3D 55 or LA36 =3D=3D= 56 or LA36 =3D=3D 57 or LA36 =3D=3D 61: LA36_28 =3D self.input.LA(2) =20 - if (self.synpred75()) : + if (self.synpred75()): alt36 =3D 1 =20 - - if alt36 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifi= er_in_pointer921) + self.following.append( + self.FOLLOW_type_qualifier_in_pointer921) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: if cnt36 >=3D 1: - break #loop36 + break # loop36 =20 if self.backtracking > 0: self.failed =3D True @@ -3416,28 +3298,24 @@ class CParser(Parser): =20 cnt36 +=3D 1 =20 - # C.g:316:24: ( pointer )? alt37 =3D 2 LA37_0 =3D self.input.LA(1) =20 - if (LA37_0 =3D=3D 66) : + if (LA37_0 =3D=3D 66): LA37_1 =3D self.input.LA(2) =20 - if (self.synpred76()) : + if (self.synpred76()): alt37 =3D 1 if alt37 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_point= er924) + self.following.append( + self.FOLLOW_pointer_in_pointer924) self.pointer() self.following.pop() if self.failed: return =20 - - - - elif alt38 =3D=3D 2: # C.g:317:4: '*' pointer self.match(self.input, 66, self.FOLLOW_66_in_pointer93= 0) @@ -3449,15 +3327,12 @@ class CParser(Parser): if self.failed: return =20 - elif alt38 =3D=3D 3: # C.g:318:4: '*' self.match(self.input, 66, self.FOLLOW_66_in_pointer93= 7) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3471,9 +3346,9 @@ class CParser(Parser): =20 # $ANTLR end pointer =20 - # $ANTLR start parameter_type_list # C.g:321:1: parameter_type_list : parameter_list ( ',' ( 'OPTIONAL' )= ? '...' )? ; + def parameter_type_list(self, ): =20 parameter_type_list_StartIndex =3D self.input.index() @@ -3484,7 +3359,8 @@ class CParser(Parser): =20 # C.g:322:2: ( parameter_list ( ',' ( 'OPTIONAL' )? '...' = )? ) # C.g:322:4: parameter_list ( ',' ( 'OPTIONAL' )? '...' )? - self.following.append(self.FOLLOW_parameter_list_in_parame= ter_type_list948) + self.following.append( + self.FOLLOW_parameter_list_in_parameter_type_list948) self.parameter_list() self.following.pop() if self.failed: @@ -3493,37 +3369,32 @@ class CParser(Parser): alt40 =3D 2 LA40_0 =3D self.input.LA(1) =20 - if (LA40_0 =3D=3D 27) : + if (LA40_0 =3D=3D 27): alt40 =3D 1 if alt40 =3D=3D 1: # C.g:322:20: ',' ( 'OPTIONAL' )? '...' - self.match(self.input, 27, self.FOLLOW_27_in_parameter= _type_list951) + self.match(self.input, 27, + self.FOLLOW_27_in_parameter_type_list951) if self.failed: return # C.g:322:24: ( 'OPTIONAL' )? alt39 =3D 2 LA39_0 =3D self.input.LA(1) =20 - if (LA39_0 =3D=3D 53) : + if (LA39_0 =3D=3D 53): alt39 =3D 1 if alt39 =3D=3D 1: # C.g:322:25: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_param= eter_type_list954) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_type_list95= 4) if self.failed: return =20 - - - self.match(self.input, 67, self.FOLLOW_67_in_parameter= _type_list958) + self.match(self.input, 67, + self.FOLLOW_67_in_parameter_type_list958) if self.failed: return =20 - - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3537,9 +3408,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_type_list =20 - # $ANTLR start parameter_list # C.g:325:1: parameter_list : parameter_declaration ( ',' ( 'OPTIONAL'= )? parameter_declaration )* ; + def parameter_list(self, ): =20 parameter_list_StartIndex =3D self.input.index() @@ -3550,68 +3421,60 @@ class CParser(Parser): =20 # C.g:326:2: ( parameter_declaration ( ',' ( 'OPTIONAL' )?= parameter_declaration )* ) # C.g:326:4: parameter_declaration ( ',' ( 'OPTIONAL' )? p= arameter_declaration )* - self.following.append(self.FOLLOW_parameter_declaration_in= _parameter_list971) + self.following.append( + self.FOLLOW_parameter_declaration_in_parameter_list971) self.parameter_declaration() self.following.pop() if self.failed: return # C.g:326:26: ( ',' ( 'OPTIONAL' )? parameter_declaration = )* - while True: #loop42 + while True: # loop42 alt42 =3D 2 LA42_0 =3D self.input.LA(1) =20 - if (LA42_0 =3D=3D 27) : + if (LA42_0 =3D=3D 27): LA42_1 =3D self.input.LA(2) =20 - if (LA42_1 =3D=3D 53) : + if (LA42_1 =3D=3D 53): LA42_3 =3D self.input.LA(3) =20 - if (self.synpred82()) : + if (self.synpred82()): alt42 =3D 1 =20 - - elif (LA42_1 =3D=3D IDENTIFIER or (29 <=3D LA42_1 = <=3D 42) or (45 <=3D LA42_1 <=3D 46) or (48 <=3D LA42_1 <=3D 52) or (54 <= =3D LA42_1 <=3D 61) or LA42_1 =3D=3D 66) : + elif (LA42_1 =3D=3D IDENTIFIER or (29 <=3D LA42_1 = <=3D 42) or (45 <=3D LA42_1 <=3D 46) or (48 <=3D LA42_1 <=3D 52) or (54 <= =3D LA42_1 <=3D 61) or LA42_1 =3D=3D 66): alt42 =3D 1 =20 - - - if alt42 =3D=3D 1: # C.g:326:27: ',' ( 'OPTIONAL' )? parameter_declar= ation - self.match(self.input, 27, self.FOLLOW_27_in_param= eter_list974) + self.match(self.input, 27, + self.FOLLOW_27_in_parameter_list974) if self.failed: return # C.g:326:31: ( 'OPTIONAL' )? alt41 =3D 2 LA41_0 =3D self.input.LA(1) =20 - if (LA41_0 =3D=3D 53) : + if (LA41_0 =3D=3D 53): LA41_1 =3D self.input.LA(2) =20 - if (self.synpred81()) : + if (self.synpred81()): alt41 =3D 1 if alt41 =3D=3D 1: # C.g:326:32: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_p= arameter_list977) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_list977) if self.failed: return =20 - - - self.following.append(self.FOLLOW_parameter_declar= ation_in_parameter_list981) + self.following.append( + self.FOLLOW_parameter_declaration_in_parameter= _list981) self.parameter_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop42 - - - - - + break # loop42 =20 except RecognitionException as re: self.reportError(re) @@ -3626,9 +3489,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_list =20 - # $ANTLR start parameter_declaration # C.g:329:1: parameter_declaration : ( declaration_specifiers ( declar= ator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointer )* IDENTIFIER ); + def parameter_declaration(self, ): =20 parameter_declaration_StartIndex =3D self.input.index() @@ -3645,16 +3508,17 @@ class CParser(Parser): elif LA46 =3D=3D IDENTIFIER: LA46_13 =3D self.input.LA(2) =20 - if (self.synpred86()) : + if (self.synpred86()): alt46 =3D 1 - elif (True) : + elif (True): alt46 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("329:1: parameter_de= claration : ( declaration_specifiers ( declarator | abstract_declarator )* = ( 'OPTIONAL' )? | ( pointer )* IDENTIFIER );", 46, 13, self.input) + nvae =3D NoViableAltException( + "329:1: parameter_declaration : ( declaration_= specifiers ( declarator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointe= r )* IDENTIFIER );", 46, 13, self.input) =20 raise nvae =20 @@ -3665,30 +3529,31 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("329:1: parameter_declar= ation : ( declaration_specifiers ( declarator | abstract_declarator )* ( 'O= PTIONAL' )? | ( pointer )* IDENTIFIER );", 46, 0, self.input) + nvae =3D NoViableAltException( + "329:1: parameter_declaration : ( declaration_spec= ifiers ( declarator | abstract_declarator )* ( 'OPTIONAL' )? | ( pointer )*= IDENTIFIER );", 46, 0, self.input) =20 raise nvae =20 if alt46 =3D=3D 1: # C.g:330:4: declaration_specifiers ( declarator | abs= tract_declarator )* ( 'OPTIONAL' )? - self.following.append(self.FOLLOW_declaration_specifie= rs_in_parameter_declaration994) + self.following.append( + self.FOLLOW_declaration_specifiers_in_parameter_de= claration994) self.declaration_specifiers() self.following.pop() if self.failed: return # C.g:330:27: ( declarator | abstract_declarator )* - while True: #loop43 + while True: # loop43 alt43 =3D 3 LA43 =3D self.input.LA(1) if LA43 =3D=3D 66: LA43_5 =3D self.input.LA(2) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D IDENTIFIER or LA43 =3D=3D 58 or L= A43 =3D=3D 59 or LA43 =3D=3D 60: alt43 =3D 1 elif LA43 =3D=3D 62: @@ -3698,129 +3563,115 @@ class CParser(Parser): elif LA43 =3D=3D IDENTIFIER: LA43_37 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 58: LA43_38 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 66: LA43_39 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 59: LA43_40 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 60: LA43_41 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - elif LA43 =3D=3D 62: LA43_43 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt43 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt43 =3D 2 =20 - - elif LA43 =3D=3D 64: alt43 =3D 2 =20 if alt43 =3D=3D 1: # C.g:330:28: declarator - self.following.append(self.FOLLOW_declarator_i= n_parameter_declaration997) + self.following.append( + self.FOLLOW_declarator_in_parameter_declar= ation997) self.declarator() self.following.pop() if self.failed: return =20 - elif alt43 =3D=3D 2: # C.g:330:39: abstract_declarator - self.following.append(self.FOLLOW_abstract_dec= larator_in_parameter_declaration999) + self.following.append( + self.FOLLOW_abstract_declarator_in_paramet= er_declaration999) self.abstract_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop43 - + break # loop43 =20 # C.g:330:61: ( 'OPTIONAL' )? alt44 =3D 2 LA44_0 =3D self.input.LA(1) =20 - if (LA44_0 =3D=3D 53) : + if (LA44_0 =3D=3D 53): alt44 =3D 1 if alt44 =3D=3D 1: # C.g:330:62: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_param= eter_declaration1004) + self.match(self.input, 53, + self.FOLLOW_53_in_parameter_declaration= 1004) if self.failed: return =20 - - - - elif alt46 =3D=3D 2: # C.g:332:4: ( pointer )* IDENTIFIER # C.g:332:4: ( pointer )* - while True: #loop45 + while True: # loop45 alt45 =3D 2 LA45_0 =3D self.input.LA(1) =20 - if (LA45_0 =3D=3D 66) : + if (LA45_0 =3D=3D 66): alt45 =3D 1 =20 - if alt45 =3D=3D 1: # C.g:0:0: pointer - self.following.append(self.FOLLOW_pointer_in_p= arameter_declaration1013) + self.following.append( + self.FOLLOW_pointer_in_parameter_declarati= on1013) self.pointer() self.following.pop() if self.failed: return =20 - else: - break #loop45 + break # loop45 =20 - - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_parameter_declaration1016) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_parameter_declara= tion1016) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3834,9 +3685,9 @@ class CParser(Parser): =20 # $ANTLR end parameter_declaration =20 - # $ANTLR start identifier_list # C.g:335:1: identifier_list : IDENTIFIER ( ',' IDENTIFIER )* ; + def identifier_list(self, ): =20 identifier_list_StartIndex =3D self.input.index() @@ -3847,35 +3698,31 @@ class CParser(Parser): =20 # C.g:336:2: ( IDENTIFIER ( ',' IDENTIFIER )* ) # C.g:336:4: IDENTIFIER ( ',' IDENTIFIER )* - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_identifier_list1027) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_identifier_list1027) if self.failed: return # C.g:337:2: ( ',' IDENTIFIER )* - while True: #loop47 + while True: # loop47 alt47 =3D 2 LA47_0 =3D self.input.LA(1) =20 - if (LA47_0 =3D=3D 27) : + if (LA47_0 =3D=3D 27): alt47 =3D 1 =20 - if alt47 =3D=3D 1: # C.g:337:3: ',' IDENTIFIER - self.match(self.input, 27, self.FOLLOW_27_in_ident= ifier_list1031) + self.match(self.input, 27, + self.FOLLOW_27_in_identifier_list1031) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_identifier_list1033) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_identifier_li= st1033) if self.failed: return =20 - else: - break #loop47 - - - - - + break # loop47 =20 except RecognitionException as re: self.reportError(re) @@ -3890,9 +3737,9 @@ class CParser(Parser): =20 # $ANTLR end identifier_list =20 - # $ANTLR start type_name # C.g:340:1: type_name : ( specifier_qualifier_list ( abstract_declara= tor )? | type_id ); + def type_name(self, ): =20 type_name_StartIndex =3D self.input.index() @@ -3905,21 +3752,22 @@ class CParser(Parser): alt49 =3D 2 LA49_0 =3D self.input.LA(1) =20 - if ((34 <=3D LA49_0 <=3D 42) or (45 <=3D LA49_0 <=3D 46) o= r (48 <=3D LA49_0 <=3D 61)) : + if ((34 <=3D LA49_0 <=3D 42) or (45 <=3D LA49_0 <=3D 46) o= r (48 <=3D LA49_0 <=3D 61)): alt49 =3D 1 - elif (LA49_0 =3D=3D IDENTIFIER) : + elif (LA49_0 =3D=3D IDENTIFIER): LA49_13 =3D self.input.LA(2) =20 - if (self.synpred90()) : + if (self.synpred90()): alt49 =3D 1 - elif (True) : + elif (True): alt49 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("340:1: type_name : = ( specifier_qualifier_list ( abstract_declarator )? | type_id );", 49, 13, = self.input) + nvae =3D NoViableAltException( + "340:1: type_name : ( specifier_qualifier_list= ( abstract_declarator )? | type_id );", 49, 13, self.input) =20 raise nvae =20 @@ -3928,13 +3776,15 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("340:1: type_name : ( sp= ecifier_qualifier_list ( abstract_declarator )? | type_id );", 49, 0, self.= input) + nvae =3D NoViableAltException( + "340:1: type_name : ( specifier_qualifier_list ( a= bstract_declarator )? | type_id );", 49, 0, self.input) =20 raise nvae =20 if alt49 =3D=3D 1: # C.g:341:4: specifier_qualifier_list ( abstract_decla= rator )? - self.following.append(self.FOLLOW_specifier_qualifier_= list_in_type_name1046) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_type_name1= 046) self.specifier_qualifier_list() self.following.pop() if self.failed: @@ -3943,20 +3793,17 @@ class CParser(Parser): alt48 =3D 2 LA48_0 =3D self.input.LA(1) =20 - if (LA48_0 =3D=3D 62 or LA48_0 =3D=3D 64 or LA48_0 =3D= =3D 66) : + if (LA48_0 =3D=3D 62 or LA48_0 =3D=3D 64 or LA48_0 =3D= =3D 66): alt48 =3D 1 if alt48 =3D=3D 1: # C.g:0:0: abstract_declarator - self.following.append(self.FOLLOW_abstract_declara= tor_in_type_name1048) + self.following.append( + self.FOLLOW_abstract_declarator_in_type_name10= 48) self.abstract_declarator() self.following.pop() if self.failed: return =20 - - - - elif alt49 =3D=3D 2: # C.g:342:4: type_id self.following.append(self.FOLLOW_type_id_in_type_name= 1054) @@ -3965,8 +3812,6 @@ class CParser(Parser): if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -3980,9 +3825,9 @@ class CParser(Parser): =20 # $ANTLR end type_name =20 - # $ANTLR start abstract_declarator # C.g:345:1: abstract_declarator : ( pointer ( direct_abstract_declara= tor )? | direct_abstract_declarator ); + def abstract_declarator(self, ): =20 abstract_declarator_StartIndex =3D self.input.index() @@ -3995,22 +3840,24 @@ class CParser(Parser): alt51 =3D 2 LA51_0 =3D self.input.LA(1) =20 - if (LA51_0 =3D=3D 66) : + if (LA51_0 =3D=3D 66): alt51 =3D 1 - elif (LA51_0 =3D=3D 62 or LA51_0 =3D=3D 64) : + elif (LA51_0 =3D=3D 62 or LA51_0 =3D=3D 64): alt51 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("345:1: abstract_declara= tor : ( pointer ( direct_abstract_declarator )? | direct_abstract_declarato= r );", 51, 0, self.input) + nvae =3D NoViableAltException( + "345:1: abstract_declarator : ( pointer ( direct_a= bstract_declarator )? | direct_abstract_declarator );", 51, 0, self.input) =20 raise nvae =20 if alt51 =3D=3D 1: # C.g:346:4: pointer ( direct_abstract_declarator )? - self.following.append(self.FOLLOW_pointer_in_abstract_= declarator1065) + self.following.append( + self.FOLLOW_pointer_in_abstract_declarator1065) self.pointer() self.following.pop() if self.failed: @@ -4019,202 +3866,198 @@ class CParser(Parser): alt50 =3D 2 LA50_0 =3D self.input.LA(1) =20 - if (LA50_0 =3D=3D 62) : + if (LA50_0 =3D=3D 62): LA50 =3D self.input.LA(2) if LA50 =3D=3D 63: LA50_12 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 58: LA50_13 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 66: LA50_14 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 59: LA50_15 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 60: LA50_16 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D IDENTIFIER: LA50_17 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 62: LA50_18 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 64: LA50_19 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 29 or LA50 =3D=3D 30 or LA50 =3D= =3D 31 or LA50 =3D=3D 32 or LA50 =3D=3D 33: LA50_20 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 34: LA50_21 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 35: LA50_22 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 36: LA50_23 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 37: LA50_24 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 38: LA50_25 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 39: LA50_26 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 40: LA50_27 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 41: LA50_28 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 42: LA50_29 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 45 or LA50 =3D=3D 46: LA50_30 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 48: LA50_31 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 49 or LA50 =3D=3D 50 or LA50 =3D= =3D 51 or LA50 =3D=3D 52 or LA50 =3D=3D 53 or LA50 =3D=3D 54 or LA50 =3D=3D= 55 or LA50 =3D=3D 56 or LA50 =3D=3D 57 or LA50 =3D=3D 61: LA50_32 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 - elif (LA50_0 =3D=3D 64) : + elif (LA50_0 =3D=3D 64): LA50 =3D self.input.LA(2) if LA50 =3D=3D 65: LA50_33 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 62: LA50_34 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D IDENTIFIER: LA50_35 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D HEX_LITERAL: LA50_36 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D OCTAL_LITERAL: LA50_37 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D DECIMAL_LITERAL: LA50_38 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D CHARACTER_LITERAL: LA50_39 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D STRING_LITERAL: LA50_40 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D FLOATING_POINT_LITERAL: LA50_41 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 72: LA50_42 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 73: LA50_43 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 66 or LA50 =3D=3D 68 or LA50 =3D= =3D 69 or LA50 =3D=3D 77 or LA50 =3D=3D 78 or LA50 =3D=3D 79: LA50_44 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 elif LA50 =3D=3D 74: LA50_45 =3D self.input.LA(3) =20 - if (self.synpred91()) : + if (self.synpred91()): alt50 =3D 1 if alt50 =3D=3D 1: # C.g:0:0: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_= declarator_in_abstract_declarator1067) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_abst= ract_declarator1067) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - - - - elif alt51 =3D=3D 2: # C.g:347:4: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_decl= arator_in_abstract_declarator1073) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_abstract= _declarator1073) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -4228,9 +4071,9 @@ class CParser(Parser): =20 # $ANTLR end abstract_declarator =20 - # $ANTLR start direct_abstract_declarator # C.g:350:1: direct_abstract_declarator : ( '(' abstract_declarator ')= ' | abstract_declarator_suffix ) ( abstract_declarator_suffix )* ; + def direct_abstract_declarator(self, ): =20 direct_abstract_declarator_StartIndex =3D self.input.index() @@ -4245,23 +4088,24 @@ class CParser(Parser): alt52 =3D 2 LA52_0 =3D self.input.LA(1) =20 - if (LA52_0 =3D=3D 62) : + if (LA52_0 =3D=3D 62): LA52 =3D self.input.LA(2) if LA52 =3D=3D IDENTIFIER or LA52 =3D=3D 29 or LA52 = =3D=3D 30 or LA52 =3D=3D 31 or LA52 =3D=3D 32 or LA52 =3D=3D 33 or LA52 =3D= =3D 34 or LA52 =3D=3D 35 or LA52 =3D=3D 36 or LA52 =3D=3D 37 or LA52 =3D=3D= 38 or LA52 =3D=3D 39 or LA52 =3D=3D 40 or LA52 =3D=3D 41 or LA52 =3D=3D 42= or LA52 =3D=3D 45 or LA52 =3D=3D 46 or LA52 =3D=3D 48 or LA52 =3D=3D 49 or= LA52 =3D=3D 50 or LA52 =3D=3D 51 or LA52 =3D=3D 52 or LA52 =3D=3D 53 or LA= 52 =3D=3D 54 or LA52 =3D=3D 55 or LA52 =3D=3D 56 or LA52 =3D=3D 57 or LA52 = =3D=3D 58 or LA52 =3D=3D 59 or LA52 =3D=3D 60 or LA52 =3D=3D 61 or LA52 =3D= =3D 63: alt52 =3D 2 elif LA52 =3D=3D 66: LA52_18 =3D self.input.LA(3) =20 - if (self.synpred93()) : + if (self.synpred93()): alt52 =3D 1 - elif (True) : + elif (True): alt52 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' ab= stract_declarator ')' | abstract_declarator_suffix )", 52, 18, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | ab= stract_declarator_suffix )", 52, 18, self.input) =20 raise nvae =20 @@ -4272,306 +4116,269 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' abstra= ct_declarator ')' | abstract_declarator_suffix )", 52, 1, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | abstra= ct_declarator_suffix )", 52, 1, self.input) =20 raise nvae =20 - elif (LA52_0 =3D=3D 64) : + elif (LA52_0 =3D=3D 64): alt52 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("351:4: ( '(' abstract_d= eclarator ')' | abstract_declarator_suffix )", 52, 0, self.input) + nvae =3D NoViableAltException( + "351:4: ( '(' abstract_declarator ')' | abstract_d= eclarator_suffix )", 52, 0, self.input) =20 raise nvae =20 if alt52 =3D=3D 1: # C.g:351:6: '(' abstract_declarator ')' - self.match(self.input, 62, self.FOLLOW_62_in_direct_ab= stract_declarator1086) + self.match( + self.input, 62, self.FOLLOW_62_in_direct_abstract_= declarator1086) if self.failed: return - self.following.append(self.FOLLOW_abstract_declarator_= in_direct_abstract_declarator1088) + self.following.append( + self.FOLLOW_abstract_declarator_in_direct_abstract= _declarator1088) self.abstract_declarator() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_direct_ab= stract_declarator1090) + self.match( + self.input, 63, self.FOLLOW_63_in_direct_abstract_= declarator1090) if self.failed: return =20 - elif alt52 =3D=3D 2: # C.g:351:36: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declarator_= suffix_in_direct_abstract_declarator1094) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_direct_a= bstract_declarator1094) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - - # C.g:351:65: ( abstract_declarator_suffix )* - while True: #loop53 + while True: # loop53 alt53 =3D 2 LA53_0 =3D self.input.LA(1) =20 - if (LA53_0 =3D=3D 62) : + if (LA53_0 =3D=3D 62): LA53 =3D self.input.LA(2) if LA53 =3D=3D 63: LA53_12 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 58: LA53_13 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 66: LA53_14 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 59: LA53_15 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 60: LA53_16 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D IDENTIFIER: LA53_17 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 29 or LA53 =3D=3D 30 or LA53 =3D= =3D 31 or LA53 =3D=3D 32 or LA53 =3D=3D 33: LA53_19 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 34: LA53_20 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 35: LA53_21 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 36: LA53_22 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 37: LA53_23 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 38: LA53_24 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 39: LA53_25 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 40: LA53_26 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 41: LA53_27 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 42: LA53_28 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 45 or LA53 =3D=3D 46: LA53_29 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 48: LA53_30 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 49 or LA53 =3D=3D 50 or LA53 =3D= =3D 51 or LA53 =3D=3D 52 or LA53 =3D=3D 53 or LA53 =3D=3D 54 or LA53 =3D=3D= 55 or LA53 =3D=3D 56 or LA53 =3D=3D 57 or LA53 =3D=3D 61: LA53_31 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - - - elif (LA53_0 =3D=3D 64) : + elif (LA53_0 =3D=3D 64): LA53 =3D self.input.LA(2) if LA53 =3D=3D 65: LA53_33 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 62: LA53_34 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D IDENTIFIER: LA53_35 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D HEX_LITERAL: LA53_36 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D OCTAL_LITERAL: LA53_37 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D DECIMAL_LITERAL: LA53_38 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D CHARACTER_LITERAL: LA53_39 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D STRING_LITERAL: LA53_40 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D FLOATING_POINT_LITERAL: LA53_41 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 72: LA53_42 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 73: LA53_43 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 66 or LA53 =3D=3D 68 or LA53 =3D= =3D 69 or LA53 =3D=3D 77 or LA53 =3D=3D 78 or LA53 =3D=3D 79: LA53_44 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - elif LA53 =3D=3D 74: LA53_45 =3D self.input.LA(3) =20 - if (self.synpred94()) : + if (self.synpred94()): alt53 =3D 1 =20 - - - - if alt53 =3D=3D 1: # C.g:0:0: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declara= tor_suffix_in_direct_abstract_declarator1098) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_dire= ct_abstract_declarator1098) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - else: - break #loop53 - - - - - + break # loop53 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 32, direct_abstract_declarator_St= artIndex) + self.memoize(self.input, 32, + direct_abstract_declarator_StartIndex) =20 pass =20 @@ -4579,9 +4386,9 @@ class CParser(Parser): =20 # $ANTLR end direct_abstract_declarator =20 - # $ANTLR start abstract_declarator_suffix # C.g:354:1: abstract_declarator_suffix : ( '[' ']' | '[' constant_exp= ression ']' | '(' ')' | '(' parameter_type_list ')' ); + def abstract_declarator_suffix(self, ): =20 abstract_declarator_suffix_StartIndex =3D self.input.index() @@ -4594,35 +4401,37 @@ class CParser(Parser): alt54 =3D 4 LA54_0 =3D self.input.LA(1) =20 - if (LA54_0 =3D=3D 64) : + if (LA54_0 =3D=3D 64): LA54_1 =3D self.input.LA(2) =20 - if (LA54_1 =3D=3D 65) : + if (LA54_1 =3D=3D 65): alt54 =3D 1 - elif ((IDENTIFIER <=3D LA54_1 <=3D FLOATING_POINT_LITE= RAL) or LA54_1 =3D=3D 62 or LA54_1 =3D=3D 66 or (68 <=3D LA54_1 <=3D 69) or= (72 <=3D LA54_1 <=3D 74) or (77 <=3D LA54_1 <=3D 79)) : + elif ((IDENTIFIER <=3D LA54_1 <=3D FLOATING_POINT_LITE= RAL) or LA54_1 =3D=3D 62 or LA54_1 =3D=3D 66 or (68 <=3D LA54_1 <=3D 69) or= (72 <=3D LA54_1 <=3D 74) or (77 <=3D LA54_1 <=3D 79)): alt54 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_dec= larator_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' pa= rameter_type_list ')' );", 54, 1, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']'= | '[' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );",= 54, 1, self.input) =20 raise nvae =20 - elif (LA54_0 =3D=3D 62) : + elif (LA54_0 =3D=3D 62): LA54_2 =3D self.input.LA(2) =20 - if (LA54_2 =3D=3D 63) : + if (LA54_2 =3D=3D 63): alt54 =3D 3 - elif (LA54_2 =3D=3D IDENTIFIER or (29 <=3D LA54_2 <=3D= 42) or (45 <=3D LA54_2 <=3D 46) or (48 <=3D LA54_2 <=3D 61) or LA54_2 =3D= =3D 66) : + elif (LA54_2 =3D=3D IDENTIFIER or (29 <=3D LA54_2 <=3D= 42) or (45 <=3D LA54_2 <=3D 46) or (48 <=3D LA54_2 <=3D 61) or LA54_2 =3D= =3D 66): alt54 =3D 4 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_dec= larator_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' pa= rameter_type_list ')' );", 54, 2, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']'= | '[' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );",= 54, 2, self.input) =20 raise nvae =20 @@ -4631,67 +4440,74 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("354:1: abstract_declara= tor_suffix : ( '[' ']' | '[' constant_expression ']' | '(' ')' | '(' parame= ter_type_list ')' );", 54, 0, self.input) + nvae =3D NoViableAltException( + "354:1: abstract_declarator_suffix : ( '[' ']' | '= [' constant_expression ']' | '(' ')' | '(' parameter_type_list ')' );", 54,= 0, self.input) =20 raise nvae =20 if alt54 =3D=3D 1: # C.g:355:4: '[' ']' - self.match(self.input, 64, self.FOLLOW_64_in_abstract_= declarator_suffix1110) + self.match( + self.input, 64, self.FOLLOW_64_in_abstract_declara= tor_suffix1110) if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_abstract_= declarator_suffix1112) + self.match( + self.input, 65, self.FOLLOW_65_in_abstract_declara= tor_suffix1112) if self.failed: return =20 - elif alt54 =3D=3D 2: # C.g:356:4: '[' constant_expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_abstract_= declarator_suffix1117) + self.match( + self.input, 64, self.FOLLOW_64_in_abstract_declara= tor_suffix1117) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_abstract_declarator_suffix1119) + self.following.append( + self.FOLLOW_constant_expression_in_abstract_declar= ator_suffix1119) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_abstract_= declarator_suffix1121) + self.match( + self.input, 65, self.FOLLOW_65_in_abstract_declara= tor_suffix1121) if self.failed: return =20 - elif alt54 =3D=3D 3: # C.g:357:4: '(' ')' - self.match(self.input, 62, self.FOLLOW_62_in_abstract_= declarator_suffix1126) + self.match( + self.input, 62, self.FOLLOW_62_in_abstract_declara= tor_suffix1126) if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_abstract_= declarator_suffix1128) + self.match( + self.input, 63, self.FOLLOW_63_in_abstract_declara= tor_suffix1128) if self.failed: return =20 - elif alt54 =3D=3D 4: # C.g:358:4: '(' parameter_type_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_abstract_= declarator_suffix1133) + self.match( + self.input, 62, self.FOLLOW_62_in_abstract_declara= tor_suffix1133) if self.failed: return - self.following.append(self.FOLLOW_parameter_type_list_= in_abstract_declarator_suffix1135) + self.following.append( + self.FOLLOW_parameter_type_list_in_abstract_declar= ator_suffix1135) self.parameter_type_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_abstract_= declarator_suffix1137) + self.match( + self.input, 63, self.FOLLOW_63_in_abstract_declara= tor_suffix1137) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 33, abstract_declarator_suffix_St= artIndex) + self.memoize(self.input, 33, + abstract_declarator_suffix_StartIndex) =20 pass =20 @@ -4699,9 +4515,9 @@ class CParser(Parser): =20 # $ANTLR end abstract_declarator_suffix =20 - # $ANTLR start initializer # C.g:361:1: initializer : ( assignment_expression | '{' initializer_l= ist ( ',' )? '}' ); + def initializer(self, ): =20 initializer_StartIndex =3D self.input.index() @@ -4714,34 +4530,37 @@ class CParser(Parser): alt56 =3D 2 LA56_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA56_0 <=3D FLOATING_POINT_LITERAL) o= r LA56_0 =3D=3D 62 or LA56_0 =3D=3D 66 or (68 <=3D LA56_0 <=3D 69) or (72 <= =3D LA56_0 <=3D 74) or (77 <=3D LA56_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA56_0 <=3D FLOATING_POINT_LITERAL) o= r LA56_0 =3D=3D 62 or LA56_0 =3D=3D 66 or (68 <=3D LA56_0 <=3D 69) or (72 <= =3D LA56_0 <=3D 74) or (77 <=3D LA56_0 <=3D 79)): alt56 =3D 1 - elif (LA56_0 =3D=3D 43) : + elif (LA56_0 =3D=3D 43): alt56 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("361:1: initializer : ( = assignment_expression | '{' initializer_list ( ',' )? '}' );", 56, 0, self.= input) + nvae =3D NoViableAltException( + "361:1: initializer : ( assignment_expression | '{= ' initializer_list ( ',' )? '}' );", 56, 0, self.input) =20 raise nvae =20 if alt56 =3D=3D 1: # C.g:363:4: assignment_expression - self.following.append(self.FOLLOW_assignment_expressio= n_in_initializer1150) + self.following.append( + self.FOLLOW_assignment_expression_in_initializer11= 50) self.assignment_expression() self.following.pop() if self.failed: return =20 - elif alt56 =3D=3D 2: # C.g:364:4: '{' initializer_list ( ',' )? '}' - self.match(self.input, 43, self.FOLLOW_43_in_initializ= er1155) + self.match(self.input, 43, + self.FOLLOW_43_in_initializer1155) if self.failed: return - self.following.append(self.FOLLOW_initializer_list_in_= initializer1157) + self.following.append( + self.FOLLOW_initializer_list_in_initializer1157) self.initializer_list() self.following.pop() if self.failed: @@ -4750,22 +4569,20 @@ class CParser(Parser): alt55 =3D 2 LA55_0 =3D self.input.LA(1) =20 - if (LA55_0 =3D=3D 27) : + if (LA55_0 =3D=3D 27): alt55 =3D 1 if alt55 =3D=3D 1: # C.g:0:0: ',' - self.match(self.input, 27, self.FOLLOW_27_in_initi= alizer1159) + self.match(self.input, 27, + self.FOLLOW_27_in_initializer1159) if self.failed: return =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_initializ= er1162) + self.match(self.input, 44, + self.FOLLOW_44_in_initializer1162) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -4779,9 +4596,9 @@ class CParser(Parser): =20 # $ANTLR end initializer =20 - # $ANTLR start initializer_list # C.g:367:1: initializer_list : initializer ( ',' initializer )* ; + def initializer_list(self, ): =20 initializer_list_StartIndex =3D self.input.index() @@ -4792,44 +4609,38 @@ class CParser(Parser): =20 # C.g:368:2: ( initializer ( ',' initializer )* ) # C.g:368:4: initializer ( ',' initializer )* - self.following.append(self.FOLLOW_initializer_in_initializ= er_list1173) + self.following.append( + self.FOLLOW_initializer_in_initializer_list1173) self.initializer() self.following.pop() if self.failed: return # C.g:368:16: ( ',' initializer )* - while True: #loop57 + while True: # loop57 alt57 =3D 2 LA57_0 =3D self.input.LA(1) =20 - if (LA57_0 =3D=3D 27) : + if (LA57_0 =3D=3D 27): LA57_1 =3D self.input.LA(2) =20 - if ((IDENTIFIER <=3D LA57_1 <=3D FLOATING_POINT_LI= TERAL) or LA57_1 =3D=3D 43 or LA57_1 =3D=3D 62 or LA57_1 =3D=3D 66 or (68 <= =3D LA57_1 <=3D 69) or (72 <=3D LA57_1 <=3D 74) or (77 <=3D LA57_1 <=3D 79)= ) : + if ((IDENTIFIER <=3D LA57_1 <=3D FLOATING_POINT_LI= TERAL) or LA57_1 =3D=3D 43 or LA57_1 =3D=3D 62 or LA57_1 =3D=3D 66 or (68 <= =3D LA57_1 <=3D 69) or (72 <=3D LA57_1 <=3D 74) or (77 <=3D LA57_1 <=3D 79)= ): alt57 =3D 1 =20 - - - if alt57 =3D=3D 1: # C.g:368:17: ',' initializer - self.match(self.input, 27, self.FOLLOW_27_in_initi= alizer_list1176) + self.match(self.input, 27, + self.FOLLOW_27_in_initializer_list1176) if self.failed: return - self.following.append(self.FOLLOW_initializer_in_i= nitializer_list1178) + self.following.append( + self.FOLLOW_initializer_in_initializer_list117= 8) self.initializer() self.following.pop() if self.failed: return =20 - else: - break #loop57 - - - - - + break # loop57 =20 except RecognitionException as re: self.reportError(re) @@ -4849,10 +4660,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start argument_expression_list # C.g:373:1: argument_expression_list : assignment_expression ( 'OPTIO= NAL' )? ( ',' assignment_expression ( 'OPTIONAL' )? )* ; + def argument_expression_list(self, ): =20 retval =3D self.argument_expression_list_return() @@ -4865,7 +4675,8 @@ class CParser(Parser): =20 # C.g:374:2: ( assignment_expression ( 'OPTIONAL' )? ( ','= assignment_expression ( 'OPTIONAL' )? )* ) # C.g:374:6: assignment_expression ( 'OPTIONAL' )? ( ',' a= ssignment_expression ( 'OPTIONAL' )? )* - self.following.append(self.FOLLOW_assignment_expression_in= _argument_expression_list1196) + self.following.append( + self.FOLLOW_assignment_expression_in_argument_expressi= on_list1196) self.assignment_expression() self.following.pop() if self.failed: @@ -4874,31 +4685,31 @@ class CParser(Parser): alt58 =3D 2 LA58_0 =3D self.input.LA(1) =20 - if (LA58_0 =3D=3D 53) : + if (LA58_0 =3D=3D 53): alt58 =3D 1 if alt58 =3D=3D 1: # C.g:374:29: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_argument_= expression_list1199) + self.match(self.input, 53, + self.FOLLOW_53_in_argument_expression_list1= 199) if self.failed: return retval =20 - - # C.g:374:42: ( ',' assignment_expression ( 'OPTIONAL' )? = )* - while True: #loop60 + while True: # loop60 alt60 =3D 2 LA60_0 =3D self.input.LA(1) =20 - if (LA60_0 =3D=3D 27) : + if (LA60_0 =3D=3D 27): alt60 =3D 1 =20 - if alt60 =3D=3D 1: # C.g:374:43: ',' assignment_expression ( 'OPTIONA= L' )? - self.match(self.input, 27, self.FOLLOW_27_in_argum= ent_expression_list1204) + self.match( + self.input, 27, self.FOLLOW_27_in_argument_exp= ression_list1204) if self.failed: return retval - self.following.append(self.FOLLOW_assignment_expre= ssion_in_argument_expression_list1206) + self.following.append( + self.FOLLOW_assignment_expression_in_argument_= expression_list1206) self.assignment_expression() self.following.pop() if self.failed: @@ -4907,34 +4718,27 @@ class CParser(Parser): alt59 =3D 2 LA59_0 =3D self.input.LA(1) =20 - if (LA59_0 =3D=3D 53) : + if (LA59_0 =3D=3D 53): alt59 =3D 1 if alt59 =3D=3D 1: # C.g:374:70: 'OPTIONAL' - self.match(self.input, 53, self.FOLLOW_53_in_a= rgument_expression_list1209) + self.match( + self.input, 53, self.FOLLOW_53_in_argument= _expression_list1209) if self.failed: return retval =20 - - - - else: - break #loop60 - - - - + break # loop60 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 36, argument_expression_list_Star= tIndex) + self.memoize(self.input, 36, + argument_expression_list_StartIndex) =20 pass =20 @@ -4942,9 +4746,9 @@ class CParser(Parser): =20 # $ANTLR end argument_expression_list =20 - # $ANTLR start additive_expression # C.g:377:1: additive_expression : ( multiplicative_expression ) ( '+'= multiplicative_expression | '-' multiplicative_expression )* ; + def additive_expression(self, ): =20 additive_expression_StartIndex =3D self.input.index() @@ -4957,56 +4761,51 @@ class CParser(Parser): # C.g:378:4: ( multiplicative_expression ) ( '+' multiplic= ative_expression | '-' multiplicative_expression )* # C.g:378:4: ( multiplicative_expression ) # C.g:378:5: multiplicative_expression - self.following.append(self.FOLLOW_multiplicative_expressio= n_in_additive_expression1225) + self.following.append( + self.FOLLOW_multiplicative_expression_in_additive_expr= ession1225) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - - # C.g:378:32: ( '+' multiplicative_expression | '-' multip= licative_expression )* - while True: #loop61 + while True: # loop61 alt61 =3D 3 LA61_0 =3D self.input.LA(1) =20 - if (LA61_0 =3D=3D 68) : + if (LA61_0 =3D=3D 68): alt61 =3D 1 - elif (LA61_0 =3D=3D 69) : + elif (LA61_0 =3D=3D 69): alt61 =3D 2 =20 - if alt61 =3D=3D 1: # C.g:378:33: '+' multiplicative_expression - self.match(self.input, 68, self.FOLLOW_68_in_addit= ive_expression1229) + self.match(self.input, 68, + self.FOLLOW_68_in_additive_expression12= 29) if self.failed: return - self.following.append(self.FOLLOW_multiplicative_e= xpression_in_additive_expression1231) + self.following.append( + self.FOLLOW_multiplicative_expression_in_addit= ive_expression1231) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - elif alt61 =3D=3D 2: # C.g:378:65: '-' multiplicative_expression - self.match(self.input, 69, self.FOLLOW_69_in_addit= ive_expression1235) + self.match(self.input, 69, + self.FOLLOW_69_in_additive_expression12= 35) if self.failed: return - self.following.append(self.FOLLOW_multiplicative_e= xpression_in_additive_expression1237) + self.following.append( + self.FOLLOW_multiplicative_expression_in_addit= ive_expression1237) self.multiplicative_expression() self.following.pop() if self.failed: return =20 - else: - break #loop61 - - - - - + break # loop61 =20 except RecognitionException as re: self.reportError(re) @@ -5021,9 +4820,9 @@ class CParser(Parser): =20 # $ANTLR end additive_expression =20 - # $ANTLR start multiplicative_expression # C.g:381:1: multiplicative_expression : ( cast_expression ) ( '*' cas= t_expression | '/' cast_expression | '%' cast_expression )* ; + def multiplicative_expression(self, ): =20 multiplicative_expression_StartIndex =3D self.input.index() @@ -5036,16 +4835,15 @@ class CParser(Parser): # C.g:382:4: ( cast_expression ) ( '*' cast_expression | '= /' cast_expression | '%' cast_expression )* # C.g:382:4: ( cast_expression ) # C.g:382:5: cast_expression - self.following.append(self.FOLLOW_cast_expression_in_multi= plicative_expression1251) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_expressi= on1251) self.cast_expression() self.following.pop() if self.failed: return =20 - - # C.g:382:22: ( '*' cast_expression | '/' cast_expression = | '%' cast_expression )* - while True: #loop62 + while True: # loop62 alt62 =3D 4 LA62 =3D self.input.LA(1) if LA62 =3D=3D 66: @@ -5057,54 +4855,53 @@ class CParser(Parser): =20 if alt62 =3D=3D 1: # C.g:382:23: '*' cast_expression - self.match(self.input, 66, self.FOLLOW_66_in_multi= plicative_expression1255) + self.match( + self.input, 66, self.FOLLOW_66_in_multiplicati= ve_expression1255) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1257) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1257) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt62 =3D=3D 2: # C.g:382:45: '/' cast_expression - self.match(self.input, 70, self.FOLLOW_70_in_multi= plicative_expression1261) + self.match( + self.input, 70, self.FOLLOW_70_in_multiplicati= ve_expression1261) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1263) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1263) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt62 =3D=3D 3: # C.g:382:67: '%' cast_expression - self.match(self.input, 71, self.FOLLOW_71_in_multi= plicative_expression1267) + self.match( + self.input, 71, self.FOLLOW_71_in_multiplicati= ve_expression1267) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_= in_multiplicative_expression1269) + self.following.append( + self.FOLLOW_cast_expression_in_multiplicative_= expression1269) self.cast_expression() self.following.pop() if self.failed: return =20 - else: - break #loop62 - - - - - + break # loop62 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 38, multiplicative_expression_Sta= rtIndex) + self.memoize(self.input, 38, + multiplicative_expression_StartIndex) =20 pass =20 @@ -5112,9 +4909,9 @@ class CParser(Parser): =20 # $ANTLR end multiplicative_expression =20 - # $ANTLR start cast_expression # C.g:385:1: cast_expression : ( '(' type_name ')' cast_expression | u= nary_expression ); + def cast_expression(self, ): =20 cast_expression_StartIndex =3D self.input.index() @@ -5127,23 +4924,24 @@ class CParser(Parser): alt63 =3D 2 LA63_0 =3D self.input.LA(1) =20 - if (LA63_0 =3D=3D 62) : + if (LA63_0 =3D=3D 62): LA63 =3D self.input.LA(2) if LA63 =3D=3D 34 or LA63 =3D=3D 35 or LA63 =3D=3D 36 = or LA63 =3D=3D 37 or LA63 =3D=3D 38 or LA63 =3D=3D 39 or LA63 =3D=3D 40 or = LA63 =3D=3D 41 or LA63 =3D=3D 42 or LA63 =3D=3D 45 or LA63 =3D=3D 46 or LA6= 3 =3D=3D 48 or LA63 =3D=3D 49 or LA63 =3D=3D 50 or LA63 =3D=3D 51 or LA63 = =3D=3D 52 or LA63 =3D=3D 53 or LA63 =3D=3D 54 or LA63 =3D=3D 55 or LA63 =3D= =3D 56 or LA63 =3D=3D 57 or LA63 =3D=3D 58 or LA63 =3D=3D 59 or LA63 =3D=3D= 60 or LA63 =3D=3D 61: alt63 =3D 1 elif LA63 =3D=3D IDENTIFIER: LA63_25 =3D self.input.LA(3) =20 - if (self.synpred109()) : + if (self.synpred109()): alt63 =3D 1 - elif (True) : + elif (True): alt63 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_exp= ression : ( '(' type_name ')' cast_expression | unary_expression );", 63, 2= 5, self.input) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name = ')' cast_expression | unary_expression );", 63, 25, self.input) =20 raise nvae =20 @@ -5154,51 +4952,55 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_express= ion : ( '(' type_name ')' cast_expression | unary_expression );", 63, 1, se= lf.input) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name ')' = cast_expression | unary_expression );", 63, 1, self.input) =20 raise nvae =20 - elif ((IDENTIFIER <=3D LA63_0 <=3D FLOATING_POINT_LITERAL)= or LA63_0 =3D=3D 66 or (68 <=3D LA63_0 <=3D 69) or (72 <=3D LA63_0 <=3D 74= ) or (77 <=3D LA63_0 <=3D 79)) : + elif ((IDENTIFIER <=3D LA63_0 <=3D FLOATING_POINT_LITERAL)= or LA63_0 =3D=3D 66 or (68 <=3D LA63_0 <=3D 69) or (72 <=3D LA63_0 <=3D 74= ) or (77 <=3D LA63_0 <=3D 79)): alt63 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("385:1: cast_expression = : ( '(' type_name ')' cast_expression | unary_expression );", 63, 0, self.i= nput) + nvae =3D NoViableAltException( + "385:1: cast_expression : ( '(' type_name ')' cast= _expression | unary_expression );", 63, 0, self.input) =20 raise nvae =20 if alt63 =3D=3D 1: # C.g:386:4: '(' type_name ')' cast_expression - self.match(self.input, 62, self.FOLLOW_62_in_cast_expr= ession1282) + self.match(self.input, 62, + self.FOLLOW_62_in_cast_expression1282) if self.failed: return - self.following.append(self.FOLLOW_type_name_in_cast_ex= pression1284) + self.following.append( + self.FOLLOW_type_name_in_cast_expression1284) self.type_name() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_cast_expr= ession1286) + self.match(self.input, 63, + self.FOLLOW_63_in_cast_expression1286) if self.failed: return - self.following.append(self.FOLLOW_cast_expression_in_c= ast_expression1288) + self.following.append( + self.FOLLOW_cast_expression_in_cast_expression1288) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt63 =3D=3D 2: # C.g:387:4: unary_expression - self.following.append(self.FOLLOW_unary_expression_in_= cast_expression1293) + self.following.append( + self.FOLLOW_unary_expression_in_cast_expression129= 3) self.unary_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5212,9 +5014,9 @@ class CParser(Parser): =20 # $ANTLR end cast_expression =20 - # $ANTLR start unary_expression # C.g:390:1: unary_expression : ( postfix_expression | '++' unary_expr= ession | '--' unary_expression | unary_operator cast_expression | 'sizeof' = unary_expression | 'sizeof' '(' type_name ')' ); + def unary_expression(self, ): =20 unary_expression_StartIndex =3D self.input.index() @@ -5237,30 +5039,32 @@ class CParser(Parser): elif LA64 =3D=3D 74: LA64_12 =3D self.input.LA(2) =20 - if (LA64_12 =3D=3D 62) : + if (LA64_12 =3D=3D 62): LA64_13 =3D self.input.LA(3) =20 - if (self.synpred114()) : + if (self.synpred114()): alt64 =3D 5 - elif (True) : + elif (True): alt64 =3D 6 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_ex= pression : ( postfix_expression | '++' unary_expression | '--' unary_expres= sion | unary_operator cast_expression | 'sizeof' unary_expression | 'sizeof= ' '(' type_name ')' );", 64, 13, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expre= ssion | '++' unary_expression | '--' unary_expression | unary_operator cast= _expression | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 6= 4, 13, self.input) =20 raise nvae =20 - elif ((IDENTIFIER <=3D LA64_12 <=3D FLOATING_POINT_LIT= ERAL) or LA64_12 =3D=3D 66 or (68 <=3D LA64_12 <=3D 69) or (72 <=3D LA64_12= <=3D 74) or (77 <=3D LA64_12 <=3D 79)) : + elif ((IDENTIFIER <=3D LA64_12 <=3D FLOATING_POINT_LIT= ERAL) or LA64_12 =3D=3D 66 or (68 <=3D LA64_12 <=3D 69) or (72 <=3D LA64_12= <=3D 74) or (77 <=3D LA64_12 <=3D 79)): alt64 =3D 5 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_expres= sion : ( postfix_expression | '++' unary_expression | '--' unary_expression= | unary_operator cast_expression | 'sizeof' unary_expression | 'sizeof' '(= ' type_name ')' );", 64, 12, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expressio= n | '++' unary_expression | '--' unary_expression | unary_operator cast_exp= ression | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 64, 1= 2, self.input) =20 raise nvae =20 @@ -5269,88 +5073,95 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("390:1: unary_expression= : ( postfix_expression | '++' unary_expression | '--' unary_expression | u= nary_operator cast_expression | 'sizeof' unary_expression | 'sizeof' '(' ty= pe_name ')' );", 64, 0, self.input) + nvae =3D NoViableAltException( + "390:1: unary_expression : ( postfix_expression | = '++' unary_expression | '--' unary_expression | unary_operator cast_express= ion | 'sizeof' unary_expression | 'sizeof' '(' type_name ')' );", 64, 0, se= lf.input) =20 raise nvae =20 if alt64 =3D=3D 1: # C.g:391:4: postfix_expression - self.following.append(self.FOLLOW_postfix_expression_i= n_unary_expression1304) + self.following.append( + self.FOLLOW_postfix_expression_in_unary_expression= 1304) self.postfix_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 2: # C.g:392:4: '++' unary_expression - self.match(self.input, 72, self.FOLLOW_72_in_unary_exp= ression1309) + self.match(self.input, 72, + self.FOLLOW_72_in_unary_expression1309) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1311) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 11) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 3: # C.g:393:4: '--' unary_expression - self.match(self.input, 73, self.FOLLOW_73_in_unary_exp= ression1316) + self.match(self.input, 73, + self.FOLLOW_73_in_unary_expression1316) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1318) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 18) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 4: # C.g:394:4: unary_operator cast_expression - self.following.append(self.FOLLOW_unary_operator_in_un= ary_expression1323) + self.following.append( + self.FOLLOW_unary_operator_in_unary_expression1323) self.unary_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_cast_expression_in_u= nary_expression1325) + self.following.append( + self.FOLLOW_cast_expression_in_unary_expression132= 5) self.cast_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 5: # C.g:395:4: 'sizeof' unary_expression - self.match(self.input, 74, self.FOLLOW_74_in_unary_exp= ression1330) + self.match(self.input, 74, + self.FOLLOW_74_in_unary_expression1330) if self.failed: return - self.following.append(self.FOLLOW_unary_expression_in_= unary_expression1332) + self.following.append( + self.FOLLOW_unary_expression_in_unary_expression13= 32) self.unary_expression() self.following.pop() if self.failed: return =20 - elif alt64 =3D=3D 6: # C.g:396:4: 'sizeof' '(' type_name ')' - self.match(self.input, 74, self.FOLLOW_74_in_unary_exp= ression1337) + self.match(self.input, 74, + self.FOLLOW_74_in_unary_expression1337) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_unary_exp= ression1339) + self.match(self.input, 62, + self.FOLLOW_62_in_unary_expression1339) if self.failed: return - self.following.append(self.FOLLOW_type_name_in_unary_e= xpression1341) + self.following.append( + self.FOLLOW_type_name_in_unary_expression1341) self.type_name() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_unary_exp= ression1343) + self.match(self.input, 63, + self.FOLLOW_63_in_unary_expression1343) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5364,9 +5175,9 @@ class CParser(Parser): =20 # $ANTLR end unary_expression =20 - # $ANTLR start postfix_expression # C.g:399:1: postfix_expression : p=3D primary_expression ( '[' expres= sion ']' | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' = macro_parameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->'= z=3D IDENTIFIER | '++' | '--' )* ; + def postfix_expression(self, ): self.postfix_expression_stack.append(postfix_expression_scope()) postfix_expression_StartIndex =3D self.input.index() @@ -5379,9 +5190,7 @@ class CParser(Parser): =20 c =3D None =20 - - - self.postfix_expression_stack[-1].FuncCallText =3D '' + self.postfix_expression_stack[-1].FuncCallText =3D '' =20 try: try: @@ -5390,30 +5199,29 @@ class CParser(Parser): =20 # C.g:406:2: (p=3D primary_expression ( '[' expression ']'= | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' macro_pa= rameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D ID= ENTIFIER | '++' | '--' )* ) # C.g:406:6: p=3D primary_expression ( '[' expression ']' = | '(' a=3D ')' | '(' c=3D argument_expression_list b=3D ')' | '(' macro_par= ameter_list ')' | '.' x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D IDE= NTIFIER | '++' | '--' )* - self.following.append(self.FOLLOW_primary_expression_in_po= stfix_expression1367) + self.following.append( + self.FOLLOW_primary_expression_in_postfix_expression13= 67) p =3D self.primary_expression() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.postfix_expression_stack[-1].FuncCallText +=3D se= lf.input.toString(p.start, p.stop) + self.postfix_expression_stack[-1].FuncCallText +=3D se= lf.input.toString( + p.start, p.stop) =20 # C.g:407:9: ( '[' expression ']' | '(' a=3D ')' | '(' c= =3D argument_expression_list b=3D ')' | '(' macro_parameter_list ')' | '.' = x=3D IDENTIFIER | '*' y=3D IDENTIFIER | '->' z=3D IDENTIFIER | '++' | '--' = )* - while True: #loop65 + while True: # loop65 alt65 =3D 10 LA65 =3D self.input.LA(1) if LA65 =3D=3D 66: LA65_1 =3D self.input.LA(2) =20 - if (LA65_1 =3D=3D IDENTIFIER) : + if (LA65_1 =3D=3D IDENTIFIER): LA65_30 =3D self.input.LA(3) =20 - if (self.synpred120()) : + if (self.synpred120()): alt65 =3D 6 =20 - - - elif LA65 =3D=3D 64: alt65 =3D 1 elif LA65 =3D=3D 62: @@ -5425,21 +5233,19 @@ class CParser(Parser): elif LA65 =3D=3D IDENTIFIER: LA65_55 =3D self.input.LA(3) =20 - if (self.synpred117()) : + if (self.synpred117()): alt65 =3D 3 - elif (self.synpred118()) : + elif (self.synpred118()): alt65 =3D 4 =20 - elif LA65 =3D=3D 66: LA65_57 =3D self.input.LA(3) =20 - if (self.synpred117()) : + if (self.synpred117()): alt65 =3D 3 - elif (self.synpred118()) : + elif (self.synpred118()): alt65 =3D 4 =20 - elif LA65 =3D=3D HEX_LITERAL or LA65 =3D=3D OCTAL_= LITERAL or LA65 =3D=3D DECIMAL_LITERAL or LA65 =3D=3D CHARACTER_LITERAL or = LA65 =3D=3D STRING_LITERAL or LA65 =3D=3D FLOATING_POINT_LITERAL or LA65 = =3D=3D 62 or LA65 =3D=3D 68 or LA65 =3D=3D 69 or LA65 =3D=3D 72 or LA65 =3D= =3D 73 or LA65 =3D=3D 74 or LA65 =3D=3D 77 or LA65 =3D=3D 78 or LA65 =3D=3D= 79: alt65 =3D 3 =20 @@ -5454,130 +5260,132 @@ class CParser(Parser): =20 if alt65 =3D=3D 1: # C.g:407:13: '[' expression ']' - self.match(self.input, 64, self.FOLLOW_64_in_postf= ix_expression1383) + self.match(self.input, 64, + self.FOLLOW_64_in_postfix_expression138= 3) if self.failed: return - self.following.append(self.FOLLOW_expression_in_po= stfix_expression1385) + self.following.append( + self.FOLLOW_expression_in_postfix_expression13= 85) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 65, self.FOLLOW_65_in_postf= ix_expression1387) + self.match(self.input, 65, + self.FOLLOW_65_in_postfix_expression138= 7) if self.failed: return =20 - elif alt65 =3D=3D 2: # C.g:408:13: '(' a=3D ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1401) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression140= 1) if self.failed: return a =3D self.input.LT(1) - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1405) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression140= 5) if self.failed: return if self.backtracking =3D=3D 0: - self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, a.line, a.charPositionInLine, self.postfix_expression= _stack[-1].FuncCallText, '') - - + self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, a.line, + a.charPositionInLine= , self.postfix_expression_stack[-1].FuncCallText, '') =20 elif alt65 =3D=3D 3: # C.g:409:13: '(' c=3D argument_expression_list b= =3D ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1420) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression142= 0) if self.failed: return - self.following.append(self.FOLLOW_argument_express= ion_list_in_postfix_expression1424) + self.following.append( + self.FOLLOW_argument_expression_list_in_postfi= x_expression1424) c =3D self.argument_expression_list() self.following.pop() if self.failed: return b =3D self.input.LT(1) - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1428) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression142= 8) if self.failed: return if self.backtracking =3D=3D 0: - self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, b.line, b.charPositionInLine, self.postfix_expression= _stack[-1].FuncCallText, self.input.toString(c.start, c.stop)) - - + self.StoreFunctionCalling(p.start.line, p.star= t.charPositionInLine, b.line, b.charPositionInLine, + self.postfix_express= ion_stack[-1].FuncCallText, self.input.toString(c.start, c.stop)) =20 elif alt65 =3D=3D 4: # C.g:410:13: '(' macro_parameter_list ')' - self.match(self.input, 62, self.FOLLOW_62_in_postf= ix_expression1444) + self.match(self.input, 62, + self.FOLLOW_62_in_postfix_expression144= 4) if self.failed: return - self.following.append(self.FOLLOW_macro_parameter_= list_in_postfix_expression1446) + self.following.append( + self.FOLLOW_macro_parameter_list_in_postfix_ex= pression1446) self.macro_parameter_list() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_postf= ix_expression1448) + self.match(self.input, 63, + self.FOLLOW_63_in_postfix_expression144= 8) if self.failed: return =20 - elif alt65 =3D=3D 5: # C.g:411:13: '.' x=3D IDENTIFIER - self.match(self.input, 75, self.FOLLOW_75_in_postf= ix_expression1462) + self.match(self.input, 75, + self.FOLLOW_75_in_postfix_expression146= 2) if self.failed: return x =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1466) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1466) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= +=3D '.' + x.text =20 - - elif alt65 =3D=3D 6: # C.g:412:13: '*' y=3D IDENTIFIER - self.match(self.input, 66, self.FOLLOW_66_in_postf= ix_expression1482) + self.match(self.input, 66, + self.FOLLOW_66_in_postfix_expression148= 2) if self.failed: return y =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1486) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1486) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= =3D y.text =20 - - elif alt65 =3D=3D 7: # C.g:413:13: '->' z=3D IDENTIFIER - self.match(self.input, 76, self.FOLLOW_76_in_postf= ix_expression1502) + self.match(self.input, 76, + self.FOLLOW_76_in_postfix_expression150= 2) if self.failed: return z =3D self.input.LT(1) - self.match(self.input, IDENTIFIER, self.FOLLOW_IDE= NTIFIER_in_postfix_expression1506) + self.match( + self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER= _in_postfix_expression1506) if self.failed: return if self.backtracking =3D=3D 0: self.postfix_expression_stack[-1].FuncCallText= +=3D '->' + z.text =20 - - elif alt65 =3D=3D 8: # C.g:414:13: '++' - self.match(self.input, 72, self.FOLLOW_72_in_postf= ix_expression1522) + self.match(self.input, 72, + self.FOLLOW_72_in_postfix_expression152= 2) if self.failed: return =20 - elif alt65 =3D=3D 9: # C.g:415:13: '--' - self.match(self.input, 73, self.FOLLOW_73_in_postf= ix_expression1536) + self.match(self.input, 73, + self.FOLLOW_73_in_postfix_expression153= 6) if self.failed: return =20 - else: - break #loop65 - - - - - + break # loop65 =20 except RecognitionException as re: self.reportError(re) @@ -5593,9 +5401,9 @@ class CParser(Parser): =20 # $ANTLR end postfix_expression =20 - # $ANTLR start macro_parameter_list # C.g:419:1: macro_parameter_list : parameter_declaration ( ',' parame= ter_declaration )* ; + def macro_parameter_list(self, ): =20 macro_parameter_list_StartIndex =3D self.input.index() @@ -5606,39 +5414,35 @@ class CParser(Parser): =20 # C.g:420:2: ( parameter_declaration ( ',' parameter_decla= ration )* ) # C.g:420:4: parameter_declaration ( ',' parameter_declara= tion )* - self.following.append(self.FOLLOW_parameter_declaration_in= _macro_parameter_list1559) + self.following.append( + self.FOLLOW_parameter_declaration_in_macro_parameter_l= ist1559) self.parameter_declaration() self.following.pop() if self.failed: return # C.g:420:26: ( ',' parameter_declaration )* - while True: #loop66 + while True: # loop66 alt66 =3D 2 LA66_0 =3D self.input.LA(1) =20 - if (LA66_0 =3D=3D 27) : + if (LA66_0 =3D=3D 27): alt66 =3D 1 =20 - if alt66 =3D=3D 1: # C.g:420:27: ',' parameter_declaration - self.match(self.input, 27, self.FOLLOW_27_in_macro= _parameter_list1562) + self.match(self.input, 27, + self.FOLLOW_27_in_macro_parameter_list1= 562) if self.failed: return - self.following.append(self.FOLLOW_parameter_declar= ation_in_macro_parameter_list1564) + self.following.append( + self.FOLLOW_parameter_declaration_in_macro_par= ameter_list1564) self.parameter_declaration() self.following.pop() if self.failed: return =20 - else: - break #loop66 - - - - - + break # loop66 =20 except RecognitionException as re: self.reportError(re) @@ -5653,9 +5457,9 @@ class CParser(Parser): =20 # $ANTLR end macro_parameter_list =20 - # $ANTLR start unary_operator # C.g:423:1: unary_operator : ( '&' | '*' | '+' | '-' | '~' | '!' ); + def unary_operator(self, ): =20 unary_operator_StartIndex =3D self.input.index() @@ -5667,7 +5471,7 @@ class CParser(Parser): # C.g:424:2: ( '&' | '*' | '+' | '-' | '~' | '!' ) # C.g: if self.input.LA(1) =3D=3D 66 or (68 <=3D self.input.LA(1)= <=3D 69) or (77 <=3D self.input.LA(1) <=3D 79): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -5679,14 +5483,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_unary_operator0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5705,10 +5504,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start primary_expression # C.g:432:1: primary_expression : ( IDENTIFIER | constant | '(' expres= sion ')' ); + def primary_expression(self, ): =20 retval =3D self.primary_expression_return() @@ -5725,16 +5523,17 @@ class CParser(Parser): if LA67 =3D=3D IDENTIFIER: LA67_1 =3D self.input.LA(2) =20 - if (LA67_1 =3D=3D EOF or LA67_1 =3D=3D 25 or (27 <=3D = LA67_1 <=3D 28) or LA67_1 =3D=3D 44 or LA67_1 =3D=3D 47 or LA67_1 =3D=3D 53= or (62 <=3D LA67_1 <=3D 66) or (68 <=3D LA67_1 <=3D 73) or (75 <=3D LA67_1= <=3D 77) or (80 <=3D LA67_1 <=3D 102)) : + if (LA67_1 =3D=3D EOF or LA67_1 =3D=3D 25 or (27 <=3D = LA67_1 <=3D 28) or LA67_1 =3D=3D 44 or LA67_1 =3D=3D 47 or LA67_1 =3D=3D 53= or (62 <=3D LA67_1 <=3D 66) or (68 <=3D LA67_1 <=3D 73) or (75 <=3D LA67_1= <=3D 77) or (80 <=3D LA67_1 <=3D 102)): alt67 =3D 1 - elif (LA67_1 =3D=3D IDENTIFIER or LA67_1 =3D=3D STRING= _LITERAL) : + elif (LA67_1 =3D=3D IDENTIFIER or LA67_1 =3D=3D STRING= _LITERAL): alt67 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("432:1: primary_expr= ession : ( IDENTIFIER | constant | '(' expression ')' );", 67, 1, self.inpu= t) + nvae =3D NoViableAltException( + "432:1: primary_expression : ( IDENTIFIER | co= nstant | '(' expression ')' );", 67, 1, self.input) =20 raise nvae =20 @@ -5747,44 +5546,46 @@ class CParser(Parser): self.failed =3D True return retval =20 - nvae =3D NoViableAltException("432:1: primary_expressi= on : ( IDENTIFIER | constant | '(' expression ')' );", 67, 0, self.input) + nvae =3D NoViableAltException( + "432:1: primary_expression : ( IDENTIFIER | consta= nt | '(' expression ')' );", 67, 0, self.input) =20 raise nvae =20 if alt67 =3D=3D 1: # C.g:433:4: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_primary_expression1613) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_primary_expressio= n1613) if self.failed: return retval =20 - elif alt67 =3D=3D 2: # C.g:434:4: constant - self.following.append(self.FOLLOW_constant_in_primary_= expression1618) + self.following.append( + self.FOLLOW_constant_in_primary_expression1618) self.constant() self.following.pop() if self.failed: return retval =20 - elif alt67 =3D=3D 3: # C.g:435:4: '(' expression ')' - self.match(self.input, 62, self.FOLLOW_62_in_primary_e= xpression1623) + self.match(self.input, 62, + self.FOLLOW_62_in_primary_expression1623) if self.failed: return retval - self.following.append(self.FOLLOW_expression_in_primar= y_expression1625) + self.following.append( + self.FOLLOW_expression_in_primary_expression1625) self.expression() self.following.pop() if self.failed: return retval - self.match(self.input, 63, self.FOLLOW_63_in_primary_e= xpression1627) + self.match(self.input, 63, + self.FOLLOW_63_in_primary_expression1627) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -5798,9 +5599,9 @@ class CParser(Parser): =20 # $ANTLR end primary_expression =20 - # $ANTLR start constant # C.g:438:1: constant : ( HEX_LITERAL | OCTAL_LITERAL | DECIMAL_LITERA= L | CHARACTER_LITERAL | ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ ( IDENTIFI= ER )* | FLOATING_POINT_LITERAL ); + def constant(self, ): =20 constant_StartIndex =3D self.input.index() @@ -5829,111 +5630,103 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("438:1: constant : ( HEX= _LITERAL | OCTAL_LITERAL | DECIMAL_LITERAL | CHARACTER_LITERAL | ( ( IDENTI= FIER )* ( STRING_LITERAL )+ )+ ( IDENTIFIER )* | FLOATING_POINT_LITERAL );"= , 72, 0, self.input) + nvae =3D NoViableAltException( + "438:1: constant : ( HEX_LITERAL | OCTAL_LITERAL |= DECIMAL_LITERAL | CHARACTER_LITERAL | ( ( IDENTIFIER )* ( STRING_LITERAL )= + )+ ( IDENTIFIER )* | FLOATING_POINT_LITERAL );", 72, 0, self.input) =20 raise nvae =20 if alt72 =3D=3D 1: # C.g:439:9: HEX_LITERAL - self.match(self.input, HEX_LITERAL, self.FOLLOW_HEX_LI= TERAL_in_constant1643) + self.match(self.input, HEX_LITERAL, + self.FOLLOW_HEX_LITERAL_in_constant1643) if self.failed: return =20 - elif alt72 =3D=3D 2: # C.g:440:9: OCTAL_LITERAL - self.match(self.input, OCTAL_LITERAL, self.FOLLOW_OCTA= L_LITERAL_in_constant1653) + self.match(self.input, OCTAL_LITERAL, + self.FOLLOW_OCTAL_LITERAL_in_constant1653) if self.failed: return =20 - elif alt72 =3D=3D 3: # C.g:441:9: DECIMAL_LITERAL - self.match(self.input, DECIMAL_LITERAL, self.FOLLOW_DE= CIMAL_LITERAL_in_constant1663) + self.match(self.input, DECIMAL_LITERAL, + self.FOLLOW_DECIMAL_LITERAL_in_constant1663) if self.failed: return =20 - elif alt72 =3D=3D 4: # C.g:442:7: CHARACTER_LITERAL - self.match(self.input, CHARACTER_LITERAL, self.FOLLOW_= CHARACTER_LITERAL_in_constant1671) + self.match(self.input, CHARACTER_LITERAL, + self.FOLLOW_CHARACTER_LITERAL_in_constant16= 71) if self.failed: return =20 - elif alt72 =3D=3D 5: # C.g:443:7: ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ = ( IDENTIFIER )* # C.g:443:7: ( ( IDENTIFIER )* ( STRING_LITERAL )+ )+ cnt70 =3D 0 - while True: #loop70 + while True: # loop70 alt70 =3D 2 LA70_0 =3D self.input.LA(1) =20 - if (LA70_0 =3D=3D IDENTIFIER) : + if (LA70_0 =3D=3D IDENTIFIER): LA70_1 =3D self.input.LA(2) =20 - if (LA70_1 =3D=3D STRING_LITERAL) : + if (LA70_1 =3D=3D STRING_LITERAL): alt70 =3D 1 - elif (LA70_1 =3D=3D IDENTIFIER) : + elif (LA70_1 =3D=3D IDENTIFIER): LA70_33 =3D self.input.LA(3) =20 - if (self.synpred138()) : + if (self.synpred138()): alt70 =3D 1 =20 - - - - elif (LA70_0 =3D=3D STRING_LITERAL) : + elif (LA70_0 =3D=3D STRING_LITERAL): alt70 =3D 1 =20 - if alt70 =3D=3D 1: # C.g:443:8: ( IDENTIFIER )* ( STRING_LITERAL = )+ # C.g:443:8: ( IDENTIFIER )* - while True: #loop68 + while True: # loop68 alt68 =3D 2 LA68_0 =3D self.input.LA(1) =20 - if (LA68_0 =3D=3D IDENTIFIER) : + if (LA68_0 =3D=3D IDENTIFIER): alt68 =3D 1 =20 - if alt68 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, sel= f.FOLLOW_IDENTIFIER_in_constant1680) + self.match( + self.input, IDENTIFIER, self.FOLLO= W_IDENTIFIER_in_constant1680) if self.failed: return =20 - else: - break #loop68 - + break # loop68 =20 # C.g:443:20: ( STRING_LITERAL )+ cnt69 =3D 0 - while True: #loop69 + while True: # loop69 alt69 =3D 2 LA69_0 =3D self.input.LA(1) =20 - if (LA69_0 =3D=3D STRING_LITERAL) : + if (LA69_0 =3D=3D STRING_LITERAL): LA69_31 =3D self.input.LA(2) =20 - if (self.synpred137()) : + if (self.synpred137()): alt69 =3D 1 =20 - - - if alt69 =3D=3D 1: # C.g:0:0: STRING_LITERAL - self.match(self.input, STRING_LITERAL,= self.FOLLOW_STRING_LITERAL_in_constant1683) + self.match( + self.input, STRING_LITERAL, self.F= OLLOW_STRING_LITERAL_in_constant1683) if self.failed: return =20 - else: if cnt69 >=3D 1: - break #loop69 + break # loop69 =20 if self.backtracking > 0: self.failed =3D True @@ -5944,12 +5737,9 @@ class CParser(Parser): =20 cnt69 +=3D 1 =20 - - - else: if cnt70 >=3D 1: - break #loop70 + break # loop70 =20 if self.backtracking > 0: self.failed =3D True @@ -5960,37 +5750,31 @@ class CParser(Parser): =20 cnt70 +=3D 1 =20 - # C.g:443:38: ( IDENTIFIER )* - while True: #loop71 + while True: # loop71 alt71 =3D 2 LA71_0 =3D self.input.LA(1) =20 - if (LA71_0 =3D=3D IDENTIFIER) : + if (LA71_0 =3D=3D IDENTIFIER): alt71 =3D 1 =20 - if alt71 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW= _IDENTIFIER_in_constant1688) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_constant1= 688) if self.failed: return =20 - else: - break #loop71 - - - + break # loop71 =20 elif alt72 =3D=3D 6: # C.g:444:9: FLOATING_POINT_LITERAL - self.match(self.input, FLOATING_POINT_LITERAL, self.FO= LLOW_FLOATING_POINT_LITERAL_in_constant1699) + self.match(self.input, FLOATING_POINT_LITERAL, + self.FOLLOW_FLOATING_POINT_LITERAL_in_const= ant1699) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6009,10 +5793,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start expression # C.g:449:1: expression : assignment_expression ( ',' assignment_expre= ssion )* ; + def expression(self, ): =20 retval =3D self.expression_return() @@ -6025,42 +5808,38 @@ class CParser(Parser): =20 # C.g:450:2: ( assignment_expression ( ',' assignment_expr= ession )* ) # C.g:450:4: assignment_expression ( ',' assignment_expres= sion )* - self.following.append(self.FOLLOW_assignment_expression_in= _expression1715) + self.following.append( + self.FOLLOW_assignment_expression_in_expression1715) self.assignment_expression() self.following.pop() if self.failed: return retval # C.g:450:26: ( ',' assignment_expression )* - while True: #loop73 + while True: # loop73 alt73 =3D 2 LA73_0 =3D self.input.LA(1) =20 - if (LA73_0 =3D=3D 27) : + if (LA73_0 =3D=3D 27): alt73 =3D 1 =20 - if alt73 =3D=3D 1: # C.g:450:27: ',' assignment_expression - self.match(self.input, 27, self.FOLLOW_27_in_expre= ssion1718) + self.match(self.input, 27, + self.FOLLOW_27_in_expression1718) if self.failed: return retval - self.following.append(self.FOLLOW_assignment_expre= ssion_in_expression1720) + self.following.append( + self.FOLLOW_assignment_expression_in_expressio= n1720) self.assignment_expression() self.following.pop() if self.failed: return retval =20 - else: - break #loop73 - - - - + break # loop73 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6074,9 +5853,9 @@ class CParser(Parser): =20 # $ANTLR end expression =20 - # $ANTLR start constant_expression # C.g:453:1: constant_expression : conditional_expression ; + def constant_expression(self, ): =20 constant_expression_StartIndex =3D self.input.index() @@ -6087,15 +5866,13 @@ class CParser(Parser): =20 # C.g:454:2: ( conditional_expression ) # C.g:454:4: conditional_expression - self.following.append(self.FOLLOW_conditional_expression_i= n_constant_expression1733) + self.following.append( + self.FOLLOW_conditional_expression_in_constant_express= ion1733) self.conditional_expression() self.following.pop() if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -6109,9 +5886,9 @@ class CParser(Parser): =20 # $ANTLR end constant_expression =20 - # $ANTLR start assignment_expression # C.g:457:1: assignment_expression : ( lvalue assignment_operator assi= gnment_expression | conditional_expression ); + def assignment_expression(self, ): =20 assignment_expression_StartIndex =3D self.input.index() @@ -6128,112 +5905,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_13 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 13, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 13, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_14 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 14, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 14, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_15 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 15, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 15, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_16 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 16, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 16, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_17 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 17, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 17, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_18 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 18, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 18, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_19 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 19, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 19, self.input) =20 raise nvae =20 @@ -6242,32 +6026,34 @@ class CParser(Parser): elif LA74 =3D=3D STRING_LITERAL: LA74_21 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 21, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 21, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_22 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 22, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 22, self.input) =20 raise nvae =20 @@ -6278,7 +6064,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 1, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 1, s= elf.input) =20 raise nvae =20 @@ -6287,112 +6074,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_44 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 44, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 44, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_45 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 45, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 45, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_46 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 46, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 46, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_47 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 47, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 47, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_48 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 48, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 48, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_49 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 49, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 49, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_50 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 50, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 50, self.input) =20 raise nvae =20 @@ -6405,7 +6199,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 2, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 2, s= elf.input) =20 raise nvae =20 @@ -6414,112 +6209,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_73 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 73, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 73, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_74 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 74, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 74, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_75 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 75, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 75, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_76 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 76, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 76, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_77 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 77, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 77, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_78 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 78, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 78, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_79 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 79, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 79, self.input) =20 raise nvae =20 @@ -6532,7 +6334,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 3, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 3, s= elf.input) =20 raise nvae =20 @@ -6541,112 +6344,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_102 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 102, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 102, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_103 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 103, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 103, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_104 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 104, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 104, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_105 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 105, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 105, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_106 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 106, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 106, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_107 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 107, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 107, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_108 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 108, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 108, self.input) =20 raise nvae =20 @@ -6659,7 +6469,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 4, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 4, s= elf.input) =20 raise nvae =20 @@ -6668,112 +6479,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_131 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 131, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 131, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_132 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 132, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 132, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_133 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 133, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 133, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_134 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 134, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 134, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_135 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 135, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 135, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_136 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 136, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 136, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_137 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 137, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 137, self.input) =20 raise nvae =20 @@ -6786,7 +6604,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 5, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 5, s= elf.input) =20 raise nvae =20 @@ -6795,128 +6614,136 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_160 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 160, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 160, self.input) =20 raise nvae =20 elif LA74 =3D=3D 64: LA74_161 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 161, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 161, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_162 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 162, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 162, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_163 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 163, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 163, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_164 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 164, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 164, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_165 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 165, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 165, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_166 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 166, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 166, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_167 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 167, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 167, self.input) =20 raise nvae =20 @@ -6925,16 +6752,17 @@ class CParser(Parser): elif LA74 =3D=3D STRING_LITERAL: LA74_189 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 189, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 189, self.input) =20 raise nvae =20 @@ -6945,7 +6773,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 6, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 6, s= elf.input) =20 raise nvae =20 @@ -6954,112 +6783,119 @@ class CParser(Parser): if LA74 =3D=3D 64: LA74_191 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 191, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 191, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_192 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 192, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 192, self.input) =20 raise nvae =20 elif LA74 =3D=3D 75: LA74_193 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 193, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 193, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66: LA74_194 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 194, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 194, self.input) =20 raise nvae =20 elif LA74 =3D=3D 76: LA74_195 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 195, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 195, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_196 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 196, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 196, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_197 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 197, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 197, self.input) =20 raise nvae =20 @@ -7072,7 +6908,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 7, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 7, s= elf.input) =20 raise nvae =20 @@ -7081,192 +6918,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_220 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 220, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 220, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_221 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 221, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 221, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_222 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 222, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 222, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_223 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 223, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 223, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_224 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 224, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 224, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_225 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 225, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 225, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_226 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 226, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 226, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_227 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 227, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 227, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_228 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 228, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 228, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_229 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 229, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 229, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_230 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 230, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 230, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_231 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 231, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 231, self.input) =20 raise nvae =20 @@ -7277,7 +7126,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 8, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 8, s= elf.input) =20 raise nvae =20 @@ -7286,192 +7136,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_244 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 244, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 244, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_245 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 245, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 245, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_246 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 246, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 246, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_247 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 247, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 247, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_248 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 248, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 248, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_249 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 249, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 249, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_250 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 250, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 250, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_251 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 251, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 251, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_252 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 252, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 252, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_253 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 253, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 253, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_254 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 254, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 254, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_255 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 255, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 255, self.input) =20 raise nvae =20 @@ -7480,7 +7342,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 9, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 9, s= elf.input) =20 raise nvae =20 @@ -7489,192 +7352,204 @@ class CParser(Parser): if LA74 =3D=3D IDENTIFIER: LA74_256 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 256, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 256, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_257 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 257, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 257, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_258 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 258, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 258, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_259 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 259, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 259, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_260 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 260, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 260, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_261 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 261, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 261, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_262 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 262, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 262, self.input) =20 raise nvae =20 elif LA74 =3D=3D 62: LA74_263 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 263, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 263, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_264 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 264, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 264, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_265 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 265, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 265, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_266 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 266, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 266, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_267 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 267, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 267, self.input) =20 raise nvae =20 @@ -7683,7 +7558,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 10, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 10, = self.input) =20 raise nvae =20 @@ -7692,192 +7568,204 @@ class CParser(Parser): if LA74 =3D=3D 62: LA74_268 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 268, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 268, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_269 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 269, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 269, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_270 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 270, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 270, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_271 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 271, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 271, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_272 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 272, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 272, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_273 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 273, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 273, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_274 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 274, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 274, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_275 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 275, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 275, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_276 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 276, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 276, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_277 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 277, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 277, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_278 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 278, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 278, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_279 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 279, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 279, self.input) =20 raise nvae =20 @@ -7886,7 +7774,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 11, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 11, = self.input) =20 raise nvae =20 @@ -7895,192 +7784,204 @@ class CParser(Parser): if LA74 =3D=3D 62: LA74_280 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 280, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 280, self.input) =20 raise nvae =20 elif LA74 =3D=3D IDENTIFIER: LA74_281 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 281, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 281, self.input) =20 raise nvae =20 elif LA74 =3D=3D HEX_LITERAL: LA74_282 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 282, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 282, self.input) =20 raise nvae =20 elif LA74 =3D=3D OCTAL_LITERAL: LA74_283 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 283, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 283, self.input) =20 raise nvae =20 elif LA74 =3D=3D DECIMAL_LITERAL: LA74_284 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 284, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 284, self.input) =20 raise nvae =20 elif LA74 =3D=3D CHARACTER_LITERAL: LA74_285 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 285, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 285, self.input) =20 raise nvae =20 elif LA74 =3D=3D STRING_LITERAL: LA74_286 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 286, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 286, self.input) =20 raise nvae =20 elif LA74 =3D=3D FLOATING_POINT_LITERAL: LA74_287 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 287, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 287, self.input) =20 raise nvae =20 elif LA74 =3D=3D 72: LA74_288 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 288, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 288, self.input) =20 raise nvae =20 elif LA74 =3D=3D 73: LA74_289 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 289, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 289, self.input) =20 raise nvae =20 elif LA74 =3D=3D 66 or LA74 =3D=3D 68 or LA74 =3D=3D 6= 9 or LA74 =3D=3D 77 or LA74 =3D=3D 78 or LA74 =3D=3D 79: LA74_290 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 290, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 290, self.input) =20 raise nvae =20 elif LA74 =3D=3D 74: LA74_291 =3D self.input.LA(3) =20 - if (self.synpred142()) : + if (self.synpred142()): alt74 =3D 1 - elif (True) : + elif (True): alt74 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignme= nt_expression : ( lvalue assignment_operator assignment_expression | condit= ional_expression );", 74, 291, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue a= ssignment_operator assignment_expression | conditional_expression );", 74, = 291, self.input) =20 raise nvae =20 @@ -8089,7 +7990,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_e= xpression : ( lvalue assignment_operator assignment_expression | conditiona= l_expression );", 74, 12, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assig= nment_operator assignment_expression | conditional_expression );", 74, 12, = self.input) =20 raise nvae =20 @@ -8098,39 +8000,41 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("457:1: assignment_expre= ssion : ( lvalue assignment_operator assignment_expression | conditional_ex= pression );", 74, 0, self.input) + nvae =3D NoViableAltException( + "457:1: assignment_expression : ( lvalue assignmen= t_operator assignment_expression | conditional_expression );", 74, 0, self.= input) =20 raise nvae =20 if alt74 =3D=3D 1: # C.g:458:4: lvalue assignment_operator assignment_exp= ression - self.following.append(self.FOLLOW_lvalue_in_assignment= _expression1744) + self.following.append( + self.FOLLOW_lvalue_in_assignment_expression1744) self.lvalue() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_operator_= in_assignment_expression1746) + self.following.append( + self.FOLLOW_assignment_operator_in_assignment_expr= ession1746) self.assignment_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_expressio= n_in_assignment_expression1748) + self.following.append( + self.FOLLOW_assignment_expression_in_assignment_ex= pression1748) self.assignment_expression() self.following.pop() if self.failed: return =20 - elif alt74 =3D=3D 2: # C.g:459:4: conditional_expression - self.following.append(self.FOLLOW_conditional_expressi= on_in_assignment_expression1753) + self.following.append( + self.FOLLOW_conditional_expression_in_assignment_e= xpression1753) self.conditional_expression() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8144,9 +8048,9 @@ class CParser(Parser): =20 # $ANTLR end assignment_expression =20 - # $ANTLR start lvalue # C.g:462:1: lvalue : unary_expression ; + def lvalue(self, ): =20 lvalue_StartIndex =3D self.input.index() @@ -8157,15 +8061,13 @@ class CParser(Parser): =20 # C.g:463:2: ( unary_expression ) # C.g:463:4: unary_expression - self.following.append(self.FOLLOW_unary_expression_in_lval= ue1765) + self.following.append( + self.FOLLOW_unary_expression_in_lvalue1765) self.unary_expression() self.following.pop() if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8179,9 +8081,9 @@ class CParser(Parser): =20 # $ANTLR end lvalue =20 - # $ANTLR start assignment_operator # C.g:466:1: assignment_operator : ( '=3D' | '*=3D' | '/=3D' | '%=3D' = | '+=3D' | '-=3D' | '<<=3D' | '>>=3D' | '&=3D' | '^=3D' | '|=3D' ); + def assignment_operator(self, ): =20 assignment_operator_StartIndex =3D self.input.index() @@ -8193,7 +8095,7 @@ class CParser(Parser): # C.g:467:2: ( '=3D' | '*=3D' | '/=3D' | '%=3D' | '+=3D' |= '-=3D' | '<<=3D' | '>>=3D' | '&=3D' | '^=3D' | '|=3D' ) # C.g: if self.input.LA(1) =3D=3D 28 or (80 <=3D self.input.LA(1)= <=3D 89): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8205,14 +8107,9 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.input) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_assignment_ope= rator0 - ) + ) raise mse =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8226,15 +8123,14 @@ class CParser(Parser): =20 # $ANTLR end assignment_operator =20 - # $ANTLR start conditional_expression # C.g:480:1: conditional_expression : e=3D logical_or_expression ( '?'= expression ':' conditional_expression )? ; + def conditional_expression(self, ): =20 conditional_expression_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 51): @@ -8242,7 +8138,8 @@ class CParser(Parser): =20 # C.g:481:2: (e=3D logical_or_expression ( '?' expression = ':' conditional_expression )? ) # C.g:481:4: e=3D logical_or_expression ( '?' expression '= :' conditional_expression )? - self.following.append(self.FOLLOW_logical_or_expression_in= _conditional_expression1839) + self.following.append( + self.FOLLOW_logical_or_expression_in_conditional_expre= ssion1839) e =3D self.logical_or_expression() self.following.pop() if self.failed: @@ -8251,35 +8148,33 @@ class CParser(Parser): alt75 =3D 2 LA75_0 =3D self.input.LA(1) =20 - if (LA75_0 =3D=3D 90) : + if (LA75_0 =3D=3D 90): alt75 =3D 1 if alt75 =3D=3D 1: # C.g:481:29: '?' expression ':' conditional_expression - self.match(self.input, 90, self.FOLLOW_90_in_condition= al_expression1842) + self.match(self.input, 90, + self.FOLLOW_90_in_conditional_expression184= 2) if self.failed: return - self.following.append(self.FOLLOW_expression_in_condit= ional_expression1844) + self.following.append( + self.FOLLOW_expression_in_conditional_expression18= 44) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_condition= al_expression1846) + self.match(self.input, 47, + self.FOLLOW_47_in_conditional_expression184= 6) if self.failed: return - self.following.append(self.FOLLOW_conditional_expressi= on_in_conditional_expression1848) + self.following.append( + self.FOLLOW_conditional_expression_in_conditional_= expression1848) self.conditional_expression() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - - - - - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -8299,10 +8194,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start logical_or_expression # C.g:484:1: logical_or_expression : logical_and_expression ( '||' log= ical_and_expression )* ; + def logical_or_expression(self, ): =20 retval =3D self.logical_or_expression_return() @@ -8315,42 +8209,38 @@ class CParser(Parser): =20 # C.g:485:2: ( logical_and_expression ( '||' logical_and_e= xpression )* ) # C.g:485:4: logical_and_expression ( '||' logical_and_exp= ression )* - self.following.append(self.FOLLOW_logical_and_expression_i= n_logical_or_expression1863) + self.following.append( + self.FOLLOW_logical_and_expression_in_logical_or_expre= ssion1863) self.logical_and_expression() self.following.pop() if self.failed: return retval # C.g:485:27: ( '||' logical_and_expression )* - while True: #loop76 + while True: # loop76 alt76 =3D 2 LA76_0 =3D self.input.LA(1) =20 - if (LA76_0 =3D=3D 91) : + if (LA76_0 =3D=3D 91): alt76 =3D 1 =20 - if alt76 =3D=3D 1: # C.g:485:28: '||' logical_and_expression - self.match(self.input, 91, self.FOLLOW_91_in_logic= al_or_expression1866) + self.match(self.input, 91, + self.FOLLOW_91_in_logical_or_expression= 1866) if self.failed: return retval - self.following.append(self.FOLLOW_logical_and_expr= ession_in_logical_or_expression1868) + self.following.append( + self.FOLLOW_logical_and_expression_in_logical_= or_expression1868) self.logical_and_expression() self.following.pop() if self.failed: return retval =20 - else: - break #loop76 - - - - + break # loop76 =20 retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -8364,9 +8254,9 @@ class CParser(Parser): =20 # $ANTLR end logical_or_expression =20 - # $ANTLR start logical_and_expression # C.g:488:1: logical_and_expression : inclusive_or_expression ( '&&' i= nclusive_or_expression )* ; + def logical_and_expression(self, ): =20 logical_and_expression_StartIndex =3D self.input.index() @@ -8377,39 +8267,35 @@ class CParser(Parser): =20 # C.g:489:2: ( inclusive_or_expression ( '&&' inclusive_or= _expression )* ) # C.g:489:4: inclusive_or_expression ( '&&' inclusive_or_e= xpression )* - self.following.append(self.FOLLOW_inclusive_or_expression_= in_logical_and_expression1881) + self.following.append( + self.FOLLOW_inclusive_or_expression_in_logical_and_exp= ression1881) self.inclusive_or_expression() self.following.pop() if self.failed: return # C.g:489:28: ( '&&' inclusive_or_expression )* - while True: #loop77 + while True: # loop77 alt77 =3D 2 LA77_0 =3D self.input.LA(1) =20 - if (LA77_0 =3D=3D 92) : + if (LA77_0 =3D=3D 92): alt77 =3D 1 =20 - if alt77 =3D=3D 1: # C.g:489:29: '&&' inclusive_or_expression - self.match(self.input, 92, self.FOLLOW_92_in_logic= al_and_expression1884) + self.match( + self.input, 92, self.FOLLOW_92_in_logical_and_= expression1884) if self.failed: return - self.following.append(self.FOLLOW_inclusive_or_exp= ression_in_logical_and_expression1886) + self.following.append( + self.FOLLOW_inclusive_or_expression_in_logical= _and_expression1886) self.inclusive_or_expression() self.following.pop() if self.failed: return =20 - else: - break #loop77 - - - - - + break # loop77 =20 except RecognitionException as re: self.reportError(re) @@ -8424,9 +8310,9 @@ class CParser(Parser): =20 # $ANTLR end logical_and_expression =20 - # $ANTLR start inclusive_or_expression # C.g:492:1: inclusive_or_expression : exclusive_or_expression ( '|' e= xclusive_or_expression )* ; + def inclusive_or_expression(self, ): =20 inclusive_or_expression_StartIndex =3D self.input.index() @@ -8437,46 +8323,43 @@ class CParser(Parser): =20 # C.g:493:2: ( exclusive_or_expression ( '|' exclusive_or_= expression )* ) # C.g:493:4: exclusive_or_expression ( '|' exclusive_or_ex= pression )* - self.following.append(self.FOLLOW_exclusive_or_expression_= in_inclusive_or_expression1899) + self.following.append( + self.FOLLOW_exclusive_or_expression_in_inclusive_or_ex= pression1899) self.exclusive_or_expression() self.following.pop() if self.failed: return # C.g:493:28: ( '|' exclusive_or_expression )* - while True: #loop78 + while True: # loop78 alt78 =3D 2 LA78_0 =3D self.input.LA(1) =20 - if (LA78_0 =3D=3D 93) : + if (LA78_0 =3D=3D 93): alt78 =3D 1 =20 - if alt78 =3D=3D 1: # C.g:493:29: '|' exclusive_or_expression - self.match(self.input, 93, self.FOLLOW_93_in_inclu= sive_or_expression1902) + self.match( + self.input, 93, self.FOLLOW_93_in_inclusive_or= _expression1902) if self.failed: return - self.following.append(self.FOLLOW_exclusive_or_exp= ression_in_inclusive_or_expression1904) + self.following.append( + self.FOLLOW_exclusive_or_expression_in_inclusi= ve_or_expression1904) self.exclusive_or_expression() self.following.pop() if self.failed: return =20 - else: - break #loop78 - - - - - + break # loop78 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 54, inclusive_or_expression_Start= Index) + self.memoize(self.input, 54, + inclusive_or_expression_StartIndex) =20 pass =20 @@ -8484,9 +8367,9 @@ class CParser(Parser): =20 # $ANTLR end inclusive_or_expression =20 - # $ANTLR start exclusive_or_expression # C.g:496:1: exclusive_or_expression : and_expression ( '^' and_expres= sion )* ; + def exclusive_or_expression(self, ): =20 exclusive_or_expression_StartIndex =3D self.input.index() @@ -8497,46 +8380,43 @@ class CParser(Parser): =20 # C.g:497:2: ( and_expression ( '^' and_expression )* ) # C.g:497:4: and_expression ( '^' and_expression )* - self.following.append(self.FOLLOW_and_expression_in_exclus= ive_or_expression1917) + self.following.append( + self.FOLLOW_and_expression_in_exclusive_or_expression1= 917) self.and_expression() self.following.pop() if self.failed: return # C.g:497:19: ( '^' and_expression )* - while True: #loop79 + while True: # loop79 alt79 =3D 2 LA79_0 =3D self.input.LA(1) =20 - if (LA79_0 =3D=3D 94) : + if (LA79_0 =3D=3D 94): alt79 =3D 1 =20 - if alt79 =3D=3D 1: # C.g:497:20: '^' and_expression - self.match(self.input, 94, self.FOLLOW_94_in_exclu= sive_or_expression1920) + self.match( + self.input, 94, self.FOLLOW_94_in_exclusive_or= _expression1920) if self.failed: return - self.following.append(self.FOLLOW_and_expression_i= n_exclusive_or_expression1922) + self.following.append( + self.FOLLOW_and_expression_in_exclusive_or_exp= ression1922) self.and_expression() self.following.pop() if self.failed: return =20 - else: - break #loop79 - - - - - + break # loop79 =20 except RecognitionException as re: self.reportError(re) self.recover(self.input, re) finally: if self.backtracking > 0: - self.memoize(self.input, 55, exclusive_or_expression_Start= Index) + self.memoize(self.input, 55, + exclusive_or_expression_StartIndex) =20 pass =20 @@ -8544,9 +8424,9 @@ class CParser(Parser): =20 # $ANTLR end exclusive_or_expression =20 - # $ANTLR start and_expression # C.g:500:1: and_expression : equality_expression ( '&' equality_expre= ssion )* ; + def and_expression(self, ): =20 and_expression_StartIndex =3D self.input.index() @@ -8557,39 +8437,35 @@ class CParser(Parser): =20 # C.g:501:2: ( equality_expression ( '&' equality_expressi= on )* ) # C.g:501:4: equality_expression ( '&' equality_expression= )* - self.following.append(self.FOLLOW_equality_expression_in_a= nd_expression1935) + self.following.append( + self.FOLLOW_equality_expression_in_and_expression1935) self.equality_expression() self.following.pop() if self.failed: return # C.g:501:24: ( '&' equality_expression )* - while True: #loop80 + while True: # loop80 alt80 =3D 2 LA80_0 =3D self.input.LA(1) =20 - if (LA80_0 =3D=3D 77) : + if (LA80_0 =3D=3D 77): alt80 =3D 1 =20 - if alt80 =3D=3D 1: # C.g:501:25: '&' equality_expression - self.match(self.input, 77, self.FOLLOW_77_in_and_e= xpression1938) + self.match(self.input, 77, + self.FOLLOW_77_in_and_expression1938) if self.failed: return - self.following.append(self.FOLLOW_equality_express= ion_in_and_expression1940) + self.following.append( + self.FOLLOW_equality_expression_in_and_express= ion1940) self.equality_expression() self.following.pop() if self.failed: return =20 - else: - break #loop80 - - - - - + break # loop80 =20 except RecognitionException as re: self.reportError(re) @@ -8604,9 +8480,9 @@ class CParser(Parser): =20 # $ANTLR end and_expression =20 - # $ANTLR start equality_expression # C.g:503:1: equality_expression : relational_expression ( ( '=3D=3D' = | '!=3D' ) relational_expression )* ; + def equality_expression(self, ): =20 equality_expression_StartIndex =3D self.input.index() @@ -8617,24 +8493,24 @@ class CParser(Parser): =20 # C.g:504:2: ( relational_expression ( ( '=3D=3D' | '!=3D'= ) relational_expression )* ) # C.g:504:4: relational_expression ( ( '=3D=3D' | '!=3D' )= relational_expression )* - self.following.append(self.FOLLOW_relational_expression_in= _equality_expression1952) + self.following.append( + self.FOLLOW_relational_expression_in_equality_expressi= on1952) self.relational_expression() self.following.pop() if self.failed: return # C.g:504:26: ( ( '=3D=3D' | '!=3D' ) relational_expressio= n )* - while True: #loop81 + while True: # loop81 alt81 =3D 2 LA81_0 =3D self.input.LA(1) =20 - if ((95 <=3D LA81_0 <=3D 96)) : + if ((95 <=3D LA81_0 <=3D 96)): alt81 =3D 1 =20 - if alt81 =3D=3D 1: # C.g:504:27: ( '=3D=3D' | '!=3D' ) relational_exp= ression if (95 <=3D self.input.LA(1) <=3D 96): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8646,24 +8522,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_equali= ty_expression1955 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_relational_expre= ssion_in_equality_expression1961) + self.following.append( + self.FOLLOW_relational_expression_in_equality_= expression1961) self.relational_expression() self.following.pop() if self.failed: return =20 - else: - break #loop81 - - - - - + break # loop81 =20 except RecognitionException as re: self.reportError(re) @@ -8678,9 +8548,9 @@ class CParser(Parser): =20 # $ANTLR end equality_expression =20 - # $ANTLR start relational_expression # C.g:507:1: relational_expression : shift_expression ( ( '<' | '>' | = '<=3D' | '>=3D' ) shift_expression )* ; + def relational_expression(self, ): =20 relational_expression_StartIndex =3D self.input.index() @@ -8691,24 +8561,24 @@ class CParser(Parser): =20 # C.g:508:2: ( shift_expression ( ( '<' | '>' | '<=3D' | '= >=3D' ) shift_expression )* ) # C.g:508:4: shift_expression ( ( '<' | '>' | '<=3D' | '>= =3D' ) shift_expression )* - self.following.append(self.FOLLOW_shift_expression_in_rela= tional_expression1975) + self.following.append( + self.FOLLOW_shift_expression_in_relational_expression1= 975) self.shift_expression() self.following.pop() if self.failed: return # C.g:508:21: ( ( '<' | '>' | '<=3D' | '>=3D' ) shift_expr= ession )* - while True: #loop82 + while True: # loop82 alt82 =3D 2 LA82_0 =3D self.input.LA(1) =20 - if ((97 <=3D LA82_0 <=3D 100)) : + if ((97 <=3D LA82_0 <=3D 100)): alt82 =3D 1 =20 - if alt82 =3D=3D 1: # C.g:508:22: ( '<' | '>' | '<=3D' | '>=3D' ) shif= t_expression if (97 <=3D self.input.LA(1) <=3D 100): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8720,24 +8590,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_relati= onal_expression1978 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_shift_expression= _in_relational_expression1988) + self.following.append( + self.FOLLOW_shift_expression_in_relational_exp= ression1988) self.shift_expression() self.following.pop() if self.failed: return =20 - else: - break #loop82 - - - - - + break # loop82 =20 except RecognitionException as re: self.reportError(re) @@ -8752,9 +8616,9 @@ class CParser(Parser): =20 # $ANTLR end relational_expression =20 - # $ANTLR start shift_expression # C.g:511:1: shift_expression : additive_expression ( ( '<<' | '>>' ) = additive_expression )* ; + def shift_expression(self, ): =20 shift_expression_StartIndex =3D self.input.index() @@ -8765,24 +8629,24 @@ class CParser(Parser): =20 # C.g:512:2: ( additive_expression ( ( '<<' | '>>' ) addit= ive_expression )* ) # C.g:512:4: additive_expression ( ( '<<' | '>>' ) additiv= e_expression )* - self.following.append(self.FOLLOW_additive_expression_in_s= hift_expression2001) + self.following.append( + self.FOLLOW_additive_expression_in_shift_expression200= 1) self.additive_expression() self.following.pop() if self.failed: return # C.g:512:24: ( ( '<<' | '>>' ) additive_expression )* - while True: #loop83 + while True: # loop83 alt83 =3D 2 LA83_0 =3D self.input.LA(1) =20 - if ((101 <=3D LA83_0 <=3D 102)) : + if ((101 <=3D LA83_0 <=3D 102)): alt83 =3D 1 =20 - if alt83 =3D=3D 1: # C.g:512:25: ( '<<' | '>>' ) additive_expression if (101 <=3D self.input.LA(1) <=3D 102): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -8794,24 +8658,18 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_shift_= expression2004 - ) + ) raise mse =20 - - self.following.append(self.FOLLOW_additive_express= ion_in_shift_expression2010) + self.following.append( + self.FOLLOW_additive_expression_in_shift_expre= ssion2010) self.additive_expression() self.following.pop() if self.failed: return =20 - else: - break #loop83 - - - - - + break # loop83 =20 except RecognitionException as re: self.reportError(re) @@ -8826,9 +8684,9 @@ class CParser(Parser): =20 # $ANTLR end shift_expression =20 - # $ANTLR start statement # C.g:517:1: statement : ( labeled_statement | compound_statement | ex= pression_statement | selection_statement | iteration_statement | jump_state= ment | macro_statement | asm2_statement | asm1_statement | asm_statement | = declaration ); + def statement(self, ): =20 statement_StartIndex =3D self.input.index() @@ -8845,20 +8703,21 @@ class CParser(Parser): if LA84 =3D=3D 62: LA84_43 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (self.synpred173()) : + elif (self.synpred173()): alt84 =3D 7 - elif (self.synpred174()) : + elif (self.synpred174()): alt84 =3D 8 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 43, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 43, self.input) =20 raise nvae =20 @@ -8869,48 +8728,51 @@ class CParser(Parser): elif LA84 =3D=3D 66: LA84_47 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 47, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 47, self.input) =20 raise nvae =20 elif LA84 =3D=3D IDENTIFIER: LA84_53 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 53, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 53, self.input) =20 raise nvae =20 elif LA84 =3D=3D 25: LA84_68 =3D self.input.LA(3) =20 - if (self.synpred169()) : + if (self.synpred169()): alt84 =3D 3 - elif (True) : + elif (True): alt84 =3D 11 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statemen= t : ( labeled_statement | compound_statement | expression_statement | selec= tion_statement | iteration_statement | jump_statement | macro_statement | a= sm2_statement | asm1_statement | asm_statement | declaration );", 84, 68, s= elf.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | = compound_statement | expression_statement | selection_statement | iteration= _statement | jump_statement | macro_statement | asm2_statement | asm1_state= ment | asm_statement | declaration );", 84, 68, self.input) =20 raise nvae =20 @@ -8921,7 +8783,8 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statement : = ( labeled_statement | compound_statement | expression_statement | selection= _statement | iteration_statement | jump_statement | macro_statement | asm2_= statement | asm1_statement | asm_statement | declaration );", 84, 1, self.i= nput) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | comp= ound_statement | expression_statement | selection_statement | iteration_sta= tement | jump_statement | macro_statement | asm2_statement | asm1_statement= | asm_statement | declaration );", 84, 1, self.input) =20 raise nvae =20 @@ -8950,110 +8813,110 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("517:1: statement : ( la= beled_statement | compound_statement | expression_statement | selection_sta= tement | iteration_statement | jump_statement | macro_statement | asm2_stat= ement | asm1_statement | asm_statement | declaration );", 84, 0, self.input) + nvae =3D NoViableAltException( + "517:1: statement : ( labeled_statement | compound= _statement | expression_statement | selection_statement | iteration_stateme= nt | jump_statement | macro_statement | asm2_statement | asm1_statement | a= sm_statement | declaration );", 84, 0, self.input) =20 raise nvae =20 if alt84 =3D=3D 1: # C.g:518:4: labeled_statement - self.following.append(self.FOLLOW_labeled_statement_in= _statement2025) + self.following.append( + self.FOLLOW_labeled_statement_in_statement2025) self.labeled_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 2: # C.g:519:4: compound_statement - self.following.append(self.FOLLOW_compound_statement_i= n_statement2030) + self.following.append( + self.FOLLOW_compound_statement_in_statement2030) self.compound_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 3: # C.g:520:4: expression_statement - self.following.append(self.FOLLOW_expression_statement= _in_statement2035) + self.following.append( + self.FOLLOW_expression_statement_in_statement2035) self.expression_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 4: # C.g:521:4: selection_statement - self.following.append(self.FOLLOW_selection_statement_= in_statement2040) + self.following.append( + self.FOLLOW_selection_statement_in_statement2040) self.selection_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 5: # C.g:522:4: iteration_statement - self.following.append(self.FOLLOW_iteration_statement_= in_statement2045) + self.following.append( + self.FOLLOW_iteration_statement_in_statement2045) self.iteration_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 6: # C.g:523:4: jump_statement - self.following.append(self.FOLLOW_jump_statement_in_st= atement2050) + self.following.append( + self.FOLLOW_jump_statement_in_statement2050) self.jump_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 7: # C.g:524:4: macro_statement - self.following.append(self.FOLLOW_macro_statement_in_s= tatement2055) + self.following.append( + self.FOLLOW_macro_statement_in_statement2055) self.macro_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 8: # C.g:525:4: asm2_statement - self.following.append(self.FOLLOW_asm2_statement_in_st= atement2060) + self.following.append( + self.FOLLOW_asm2_statement_in_statement2060) self.asm2_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 9: # C.g:526:4: asm1_statement - self.following.append(self.FOLLOW_asm1_statement_in_st= atement2065) + self.following.append( + self.FOLLOW_asm1_statement_in_statement2065) self.asm1_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 10: # C.g:527:4: asm_statement - self.following.append(self.FOLLOW_asm_statement_in_sta= tement2070) + self.following.append( + self.FOLLOW_asm_statement_in_statement2070) self.asm_statement() self.following.pop() if self.failed: return =20 - elif alt84 =3D=3D 11: # C.g:528:4: declaration - self.following.append(self.FOLLOW_declaration_in_state= ment2075) + self.following.append( + self.FOLLOW_declaration_in_statement2075) self.declaration() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9067,9 +8930,9 @@ class CParser(Parser): =20 # $ANTLR end statement =20 - # $ANTLR start asm2_statement # C.g:531:1: asm2_statement : ( '__asm__' )? IDENTIFIER '(' (~ ( ';' )= )* ')' ';' ; + def asm2_statement(self, ): =20 asm2_statement_StartIndex =3D self.input.index() @@ -9084,42 +8947,41 @@ class CParser(Parser): alt85 =3D 2 LA85_0 =3D self.input.LA(1) =20 - if (LA85_0 =3D=3D 103) : + if (LA85_0 =3D=3D 103): alt85 =3D 1 if alt85 =3D=3D 1: # C.g:0:0: '__asm__' - self.match(self.input, 103, self.FOLLOW_103_in_asm2_st= atement2086) + self.match(self.input, 103, + self.FOLLOW_103_in_asm2_statement2086) if self.failed: return =20 - - - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_asm2_statement2089) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_asm2_statement2089) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_asm2_statemen= t2091) + self.match(self.input, 62, + self.FOLLOW_62_in_asm2_statement2091) if self.failed: return # C.g:532:30: (~ ( ';' ) )* - while True: #loop86 + while True: # loop86 alt86 =3D 2 LA86_0 =3D self.input.LA(1) =20 - if (LA86_0 =3D=3D 63) : + if (LA86_0 =3D=3D 63): LA86_1 =3D self.input.LA(2) =20 - if ((IDENTIFIER <=3D LA86_1 <=3D LINE_COMMAND) or = (26 <=3D LA86_1 <=3D 117)) : + if ((IDENTIFIER <=3D LA86_1 <=3D LINE_COMMAND) or = (26 <=3D LA86_1 <=3D 117)): alt86 =3D 1 =20 - - elif ((IDENTIFIER <=3D LA86_0 <=3D LINE_COMMAND) or (2= 6 <=3D LA86_0 <=3D 62) or (64 <=3D LA86_0 <=3D 117)) : + elif ((IDENTIFIER <=3D LA86_0 <=3D LINE_COMMAND) or (2= 6 <=3D LA86_0 <=3D 62) or (64 <=3D LA86_0 <=3D 117)): alt86 =3D 1 =20 - if alt86 =3D=3D 1: # C.g:532:31: ~ ( ';' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D LINE_COM= MAND) or (26 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9131,26 +8993,21 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm2_s= tatement2094 - ) + ) raise mse =20 - - - else: - break #loop86 + break # loop86 =20 - - self.match(self.input, 63, self.FOLLOW_63_in_asm2_statemen= t2101) + self.match(self.input, 63, + self.FOLLOW_63_in_asm2_statement2101) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_asm2_statemen= t2103) + self.match(self.input, 25, + self.FOLLOW_25_in_asm2_statement2103) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9164,9 +9021,9 @@ class CParser(Parser): =20 # $ANTLR end asm2_statement =20 - # $ANTLR start asm1_statement # C.g:535:1: asm1_statement : '_asm' '{' (~ ( '}' ) )* '}' ; + def asm1_statement(self, ): =20 asm1_statement_StartIndex =3D self.input.index() @@ -9177,25 +9034,26 @@ class CParser(Parser): =20 # C.g:536:2: ( '_asm' '{' (~ ( '}' ) )* '}' ) # C.g:536:4: '_asm' '{' (~ ( '}' ) )* '}' - self.match(self.input, 104, self.FOLLOW_104_in_asm1_statem= ent2115) + self.match(self.input, 104, + self.FOLLOW_104_in_asm1_statement2115) if self.failed: return - self.match(self.input, 43, self.FOLLOW_43_in_asm1_statemen= t2117) + self.match(self.input, 43, + self.FOLLOW_43_in_asm1_statement2117) if self.failed: return # C.g:536:15: (~ ( '}' ) )* - while True: #loop87 + while True: # loop87 alt87 =3D 2 LA87_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA87_0 <=3D 43) or (45 <=3D LA87_= 0 <=3D 117)) : + if ((IDENTIFIER <=3D LA87_0 <=3D 43) or (45 <=3D LA87_= 0 <=3D 117)): alt87 =3D 1 =20 - if alt87 =3D=3D 1: # C.g:536:16: ~ ( '}' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D 43) or (= 45 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9207,23 +9065,17 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm1_s= tatement2120 - ) + ) raise mse =20 - - - else: - break #loop87 + break # loop87 =20 - - self.match(self.input, 44, self.FOLLOW_44_in_asm1_statemen= t2127) + self.match(self.input, 44, + self.FOLLOW_44_in_asm1_statement2127) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9237,9 +9089,9 @@ class CParser(Parser): =20 # $ANTLR end asm1_statement =20 - # $ANTLR start asm_statement # C.g:539:1: asm_statement : '__asm' '{' (~ ( '}' ) )* '}' ; + def asm_statement(self, ): =20 asm_statement_StartIndex =3D self.input.index() @@ -9250,25 +9102,25 @@ class CParser(Parser): =20 # C.g:540:2: ( '__asm' '{' (~ ( '}' ) )* '}' ) # C.g:540:4: '__asm' '{' (~ ( '}' ) )* '}' - self.match(self.input, 105, self.FOLLOW_105_in_asm_stateme= nt2138) + self.match(self.input, 105, + self.FOLLOW_105_in_asm_statement2138) if self.failed: return self.match(self.input, 43, self.FOLLOW_43_in_asm_statement= 2140) if self.failed: return # C.g:540:16: (~ ( '}' ) )* - while True: #loop88 + while True: # loop88 alt88 =3D 2 LA88_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA88_0 <=3D 43) or (45 <=3D LA88_= 0 <=3D 117)) : + if ((IDENTIFIER <=3D LA88_0 <=3D 43) or (45 <=3D LA88_= 0 <=3D 117)): alt88 =3D 1 =20 - if alt88 =3D=3D 1: # C.g:540:17: ~ ( '}' ) if (IDENTIFIER <=3D self.input.LA(1) <=3D 43) or (= 45 <=3D self.input.LA(1) <=3D 117): - self.input.consume(); + self.input.consume() self.errorRecovery =3D False self.failed =3D False =20 @@ -9280,23 +9132,16 @@ class CParser(Parser): mse =3D MismatchedSetException(None, self.inpu= t) self.recoverFromMismatchedSet( self.input, mse, self.FOLLOW_set_in_asm_st= atement2143 - ) + ) raise mse =20 - - - else: - break #loop88 - + break # loop88 =20 self.match(self.input, 44, self.FOLLOW_44_in_asm_statement= 2150) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -9310,9 +9155,9 @@ class CParser(Parser): =20 # $ANTLR end asm_statement =20 - # $ANTLR start macro_statement # C.g:543:1: macro_statement : IDENTIFIER '(' ( declaration )* ( state= ment_list )? ( expression )? ')' ; + def macro_statement(self, ): =20 macro_statement_StartIndex =3D self.input.index() @@ -9323,14 +9168,16 @@ class CParser(Parser): =20 # C.g:544:2: ( IDENTIFIER '(' ( declaration )* ( statement= _list )? ( expression )? ')' ) # C.g:544:4: IDENTIFIER '(' ( declaration )* ( statement_l= ist )? ( expression )? ')' - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_macro_statement2162) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_macro_statement2162) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_macro_stateme= nt2164) + self.match(self.input, 62, + self.FOLLOW_62_in_macro_statement2164) if self.failed: return # C.g:544:19: ( declaration )* - while True: #loop89 + while True: # loop89 alt89 =3D 2 LA89 =3D self.input.LA(1) if LA89 =3D=3D IDENTIFIER: @@ -9338,1904 +9185,1622 @@ class CParser(Parser): if LA89 =3D=3D 62: LA89_45 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_47 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 66: LA89_50 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_68 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_71 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_72 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_73 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_74 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_75 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_76 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_77 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_78 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_79 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_80 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_81 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_82 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_83 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_84 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_85 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_86 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 26: LA89 =3D self.input.LA(2) if LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D=3D= 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_87 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_88 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_89 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_90 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_91 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_92 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_93 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_94 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_95 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_96 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_97 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_98 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_99 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_100 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 66: LA89_101 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_102 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_103 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_104 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_105 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D=3D 3= 1 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_106 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_107 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_108 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_109 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_110 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_111 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_112 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_113 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_114 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_115 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_116 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_117 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_118 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_119 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_120 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_121 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_122 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_123 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_124 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_125 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 34: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_126 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_127 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_128 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_129 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_130 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_131 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_132 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_133 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_134 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_135 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_136 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_137 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_138 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_139 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_140 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_141 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_142 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_143 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_144 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_145 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 35: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_146 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_147 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_148 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_149 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_150 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_151 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_152 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_153 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_154 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_155 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_156 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_157 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_158 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_159 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_160 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_161 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_162 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_163 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_164 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_165 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 36: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_166 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_167 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_168 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_169 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_170 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_171 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_172 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_173 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_174 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_175 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_176 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_177 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_178 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_179 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_180 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_181 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_182 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_183 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_184 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_185 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 37: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_186 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_187 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_188 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_189 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_190 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_191 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_192 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_193 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_194 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_195 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_196 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_197 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_198 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_199 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_200 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_201 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_202 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_203 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_204 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_205 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 38: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_206 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_207 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_208 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_209 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_210 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_211 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_212 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_213 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_214 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_215 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_216 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_217 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_218 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_219 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_220 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_221 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_222 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_223 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_224 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_225 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 39: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_226 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_227 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_228 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_229 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_230 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_231 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_232 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_233 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_234 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_235 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_236 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_237 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_238 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_239 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_240 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_241 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_242 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_243 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_244 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_245 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 40: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_246 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_247 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_248 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_249 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_250 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_251 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_252 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_253 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_254 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_255 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_256 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_257 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_258 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_259 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_260 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_261 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_262 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_263 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_264 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_265 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 41: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_266 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_267 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_268 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_269 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_270 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_271 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_272 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_273 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_274 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_275 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_276 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_277 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_278 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_279 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_280 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_281 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_282 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_283 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_284 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_285 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 42: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_286 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_287 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_288 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_289 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_290 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_291 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_292 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_293 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_294 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_295 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_296 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_297 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_298 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_299 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_300 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_301 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_302 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_303 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_304 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_305 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_40 =3D self.input.LA(2) =20 - if (LA89_40 =3D=3D IDENTIFIER) : + if (LA89_40 =3D=3D IDENTIFIER): LA89_306 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif (LA89_40 =3D=3D 43) : + elif (LA89_40 =3D=3D 43): LA89_307 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - elif LA89 =3D=3D 48: LA89_41 =3D self.input.LA(2) =20 - if (LA89_41 =3D=3D 43) : + if (LA89_41 =3D=3D 43): LA89_308 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - elif (LA89_41 =3D=3D IDENTIFIER) : + elif (LA89_41 =3D=3D IDENTIFIER): LA89_309 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D=3D 5= 1 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D 55 o= r LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 58 or LA89 =3D=3D 59 or L= A89 =3D=3D 60 or LA89 =3D=3D 61: LA89 =3D self.input.LA(2) if LA89 =3D=3D 66: LA89_310 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 58: LA89_311 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 59: LA89_312 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 60: LA89_313 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D IDENTIFIER: LA89_314 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 62: LA89_315 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 25: LA89_316 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 29 or LA89 =3D=3D 30 or LA89 =3D= =3D 31 or LA89 =3D=3D 32 or LA89 =3D=3D 33: LA89_317 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 34: LA89_318 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 35: LA89_319 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 36: LA89_320 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 37: LA89_321 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 38: LA89_322 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 39: LA89_323 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 40: LA89_324 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 41: LA89_325 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 42: LA89_326 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 45 or LA89 =3D=3D 46: LA89_327 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 48: LA89_328 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - elif LA89 =3D=3D 49 or LA89 =3D=3D 50 or LA89 =3D= =3D 51 or LA89 =3D=3D 52 or LA89 =3D=3D 53 or LA89 =3D=3D 54 or LA89 =3D=3D= 55 or LA89 =3D=3D 56 or LA89 =3D=3D 57 or LA89 =3D=3D 61: LA89_329 =3D self.input.LA(3) =20 - if (self.synpred181()) : + if (self.synpred181()): alt89 =3D 1 =20 - - - if alt89 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_in_m= acro_statement2166) + self.following.append( + self.FOLLOW_declaration_in_macro_statement2166) self.declaration() self.following.pop() if self.failed: return =20 - else: - break #loop89 - + break # loop89 =20 # C.g:544:33: ( statement_list )? alt90 =3D 2 @@ -11247,122 +10812,122 @@ class CParser(Parser): elif LA90 =3D=3D 62: LA90_45 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_46 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_47 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 64: LA90_48 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_49 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_50 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_51 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_52 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_53 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_54 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_55 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_56 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_57 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_58 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_59 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_60 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_61 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_62 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_63 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_64 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_65 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_66 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_67 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_70 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25 or LA90 =3D=3D 26 or LA90 =3D=3D 29 or= LA90 =3D=3D 30 or LA90 =3D=3D 31 or LA90 =3D=3D 32 or LA90 =3D=3D 33 or LA= 90 =3D=3D 34 or LA90 =3D=3D 35 or LA90 =3D=3D 36 or LA90 =3D=3D 37 or LA90 = =3D=3D 38 or LA90 =3D=3D 39 or LA90 =3D=3D 40 or LA90 =3D=3D 41 or LA90 =3D= =3D 42 or LA90 =3D=3D 43 or LA90 =3D=3D 45 or LA90 =3D=3D 46 or LA90 =3D=3D= 48 or LA90 =3D=3D 49 or LA90 =3D=3D 50 or LA90 =3D=3D 51 or LA90 =3D=3D 52= or LA90 =3D=3D 53 or LA90 =3D=3D 54 or LA90 =3D=3D 55 or LA90 =3D=3D 56 or= LA90 =3D=3D 57 or LA90 =3D=3D 58 or LA90 =3D=3D 59 or LA90 =3D=3D 60 or LA= 90 =3D=3D 61 or LA90 =3D=3D 103 or LA90 =3D=3D 104 or LA90 =3D=3D 105 or LA= 90 =3D=3D 106 or LA90 =3D=3D 107 or LA90 =3D=3D 108 or LA90 =3D=3D 110 or L= A90 =3D=3D 111 or LA90 =3D=3D 112 or LA90 =3D=3D 113 or LA90 =3D=3D 114 or = LA90 =3D=3D 115 or LA90 =3D=3D 116 or LA90 =3D=3D 117: alt90 =3D 1 @@ -11371,112 +10936,112 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_87 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_88 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_89 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_90 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_91 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_92 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_93 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_94 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_95 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_96 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_97 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_98 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_99 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_100 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_101 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_102 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_103 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_104 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_105 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_106 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_107 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_108 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11485,226 +11050,226 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_111 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_112 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_113 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_114 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_115 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_116 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_117 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_118 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_119 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_120 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_121 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_122 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_123 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_124 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_125 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_126 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_127 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_128 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_129 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_130 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_131 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_134 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90 =3D self.input.LA(2) if LA90 =3D=3D 64: LA90_135 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_136 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_137 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_138 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_139 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_140 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_141 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_142 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_143 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_144 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_145 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_146 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_147 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_148 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_149 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_150 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_151 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_152 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_153 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_154 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_155 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_156 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11713,236 +11278,236 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_159 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_160 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_161 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_162 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_163 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_164 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_165 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_166 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_167 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_168 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_169 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_170 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_171 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_172 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_173 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_174 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_175 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_176 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_177 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_178 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_179 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_181 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_183 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 64: LA90_184 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_185 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_186 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_187 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_188 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_189 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_190 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_191 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_192 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_193 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_194 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_195 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_196 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_197 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_198 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_199 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_200 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_201 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_202 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_203 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_204 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_205 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_206 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -11951,112 +11516,112 @@ class CParser(Parser): if LA90 =3D=3D 64: LA90_209 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_210 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 75: LA90_211 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66: LA90_212 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 76: LA90_213 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_214 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_215 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 28 or LA90 =3D=3D 80 or LA90 =3D=3D 8= 1 or LA90 =3D=3D 82 or LA90 =3D=3D 83 or LA90 =3D=3D 84 or LA90 =3D=3D 85 o= r LA90 =3D=3D 86 or LA90 =3D=3D 87 or LA90 =3D=3D 88 or LA90 =3D=3D 89: LA90_216 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 70: LA90_217 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 71: LA90_218 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 68: LA90_219 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 69: LA90_220 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 101 or LA90 =3D=3D 102: LA90_221 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 97 or LA90 =3D=3D 98 or LA90 =3D=3D 9= 9 or LA90 =3D=3D 100: LA90_222 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 95 or LA90 =3D=3D 96: LA90_223 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 77: LA90_224 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 94: LA90_225 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 93: LA90_226 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 92: LA90_227 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 91: LA90_228 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 90: LA90_229 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 27: LA90_230 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 25: alt90 =3D 1 @@ -12065,404 +11630,400 @@ class CParser(Parser): if LA90 =3D=3D IDENTIFIER: LA90_233 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_234 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_235 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_236 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_237 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_238 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_239 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_240 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_241 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_242 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_243 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_244 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 49 or LA90 =3D=3D 50 or LA90 =3D=3D 5= 1 or LA90 =3D=3D 52 or LA90 =3D=3D 53 or LA90 =3D=3D 54 or LA90 =3D=3D 55 o= r LA90 =3D=3D 56 or LA90 =3D=3D 57 or LA90 =3D=3D 58 or LA90 =3D=3D 59 or L= A90 =3D=3D 60 or LA90 =3D=3D 61: LA90_245 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 34: LA90_246 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 35: LA90_247 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 36: LA90_248 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 37: LA90_249 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 38: LA90_250 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 39: LA90_251 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 40: LA90_252 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 41: LA90_253 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 42: LA90_254 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 45 or LA90 =3D=3D 46: LA90_255 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 48: LA90_256 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_257 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_258 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_259 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_260 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_261 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_262 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_263 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_264 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_265 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_266 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_267 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_268 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90 =3D self.input.LA(2) if LA90 =3D=3D IDENTIFIER: LA90_269 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_270 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_271 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_272 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_273 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_274 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_275 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 62: LA90_276 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_277 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_278 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_279 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_280 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 69 or= LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90 =3D self.input.LA(2) if LA90 =3D=3D 62: LA90_281 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_282 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_283 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_284 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_285 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_286 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_287 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_288 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_289 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_290 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_291 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_292 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90 =3D self.input.LA(2) if LA90 =3D=3D 62: LA90_293 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D IDENTIFIER: LA90_294 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D HEX_LITERAL: LA90_295 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D OCTAL_LITERAL: LA90_296 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D DECIMAL_LITERAL: LA90_297 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D CHARACTER_LITERAL: LA90_298 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D STRING_LITERAL: LA90_299 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D FLOATING_POINT_LITERAL: LA90_300 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 72: LA90_301 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 73: LA90_302 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 66 or LA90 =3D=3D 68 or LA90 =3D=3D 6= 9 or LA90 =3D=3D 77 or LA90 =3D=3D 78 or LA90 =3D=3D 79: LA90_303 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 elif LA90 =3D=3D 74: LA90_304 =3D self.input.LA(3) =20 - if (self.synpred182()) : + if (self.synpred182()): alt90 =3D 1 if alt90 =3D=3D 1: # C.g:0:0: statement_list - self.following.append(self.FOLLOW_statement_list_in_ma= cro_statement2170) + self.following.append( + self.FOLLOW_statement_list_in_macro_statement2170) self.statement_list() self.following.pop() if self.failed: return =20 - - # C.g:544:49: ( expression )? alt91 =3D 2 LA91_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA91_0 <=3D FLOATING_POINT_LITERAL) o= r LA91_0 =3D=3D 62 or LA91_0 =3D=3D 66 or (68 <=3D LA91_0 <=3D 69) or (72 <= =3D LA91_0 <=3D 74) or (77 <=3D LA91_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA91_0 <=3D FLOATING_POINT_LITERAL) o= r LA91_0 =3D=3D 62 or LA91_0 =3D=3D 66 or (68 <=3D LA91_0 <=3D 69) or (72 <= =3D LA91_0 <=3D 74) or (77 <=3D LA91_0 <=3D 79)): alt91 =3D 1 if alt91 =3D=3D 1: # C.g:0:0: expression - self.following.append(self.FOLLOW_expression_in_macro_= statement2173) + self.following.append( + self.FOLLOW_expression_in_macro_statement2173) self.expression() self.following.pop() if self.failed: return =20 - - - self.match(self.input, 63, self.FOLLOW_63_in_macro_stateme= nt2176) + self.match(self.input, 63, + self.FOLLOW_63_in_macro_statement2176) if self.failed: return =20 - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -12476,9 +12037,9 @@ class CParser(Parser): =20 # $ANTLR end macro_statement =20 - # $ANTLR start labeled_statement # C.g:547:1: labeled_statement : ( IDENTIFIER ':' statement | 'case' c= onstant_expression ':' statement | 'default' ':' statement ); + def labeled_statement(self, ): =20 labeled_statement_StartIndex =3D self.input.index() @@ -12501,61 +12062,68 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("547:1: labeled_statemen= t : ( IDENTIFIER ':' statement | 'case' constant_expression ':' statement |= 'default' ':' statement );", 92, 0, self.input) + nvae =3D NoViableAltException( + "547:1: labeled_statement : ( IDENTIFIER ':' state= ment | 'case' constant_expression ':' statement | 'default' ':' statement )= ;", 92, 0, self.input) =20 raise nvae =20 if alt92 =3D=3D 1: # C.g:548:4: IDENTIFIER ':' statement - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_labeled_statement2188) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_labeled_statement= 2188) if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2190) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2190) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2192) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2192) self.statement() self.following.pop() if self.failed: return =20 - elif alt92 =3D=3D 2: # C.g:549:4: 'case' constant_expression ':' statement - self.match(self.input, 106, self.FOLLOW_106_in_labeled= _statement2197) + self.match(self.input, 106, + self.FOLLOW_106_in_labeled_statement2197) if self.failed: return - self.following.append(self.FOLLOW_constant_expression_= in_labeled_statement2199) + self.following.append( + self.FOLLOW_constant_expression_in_labeled_stateme= nt2199) self.constant_expression() self.following.pop() if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2201) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2201) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2203) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2203) self.statement() self.following.pop() if self.failed: return =20 - elif alt92 =3D=3D 3: # C.g:550:4: 'default' ':' statement - self.match(self.input, 107, self.FOLLOW_107_in_labeled= _statement2208) + self.match(self.input, 107, + self.FOLLOW_107_in_labeled_statement2208) if self.failed: return - self.match(self.input, 47, self.FOLLOW_47_in_labeled_s= tatement2210) + self.match(self.input, 47, + self.FOLLOW_47_in_labeled_statement2210) if self.failed: return - self.following.append(self.FOLLOW_statement_in_labeled= _statement2212) + self.following.append( + self.FOLLOW_statement_in_labeled_statement2212) self.statement() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -12574,10 +12142,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start compound_statement # C.g:553:1: compound_statement : '{' ( declaration )* ( statement_lis= t )? '}' ; + def compound_statement(self, ): =20 retval =3D self.compound_statement_return() @@ -12590,11 +12157,12 @@ class CParser(Parser): =20 # C.g:554:2: ( '{' ( declaration )* ( statement_list )? '}= ' ) # C.g:554:4: '{' ( declaration )* ( statement_list )? '}' - self.match(self.input, 43, self.FOLLOW_43_in_compound_stat= ement2223) + self.match(self.input, 43, + self.FOLLOW_43_in_compound_statement2223) if self.failed: return retval # C.g:554:8: ( declaration )* - while True: #loop93 + while True: # loop93 alt93 =3D 2 LA93 =3D self.input.LA(1) if LA93 =3D=3D IDENTIFIER: @@ -12602,1930 +12170,1645 @@ class CParser(Parser): if LA93 =3D=3D 62: LA93_44 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_47 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 66: LA93_48 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_49 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_50 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_51 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_52 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_53 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_54 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_55 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_56 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_57 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_58 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_59 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_60 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_61 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_62 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_63 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_64 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_65 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 26: LA93 =3D self.input.LA(2) if LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D=3D= 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_86 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_87 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_88 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_89 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_90 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_91 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_92 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_93 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_94 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_95 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_96 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_97 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_98 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_99 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 66: LA93_100 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_101 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_102 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_103 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_104 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D=3D 3= 1 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_105 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_106 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_107 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_108 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_109 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_110 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_111 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_112 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_113 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_114 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_115 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_116 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_117 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_118 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_119 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_120 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_121 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_122 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_123 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_124 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 34: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_125 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_126 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_127 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_128 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_129 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_130 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_131 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_132 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_133 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_134 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_135 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_136 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_137 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_138 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_139 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_140 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_141 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_142 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_143 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_144 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 35: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_145 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_146 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_147 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_148 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_149 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_150 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_151 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_152 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_153 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_154 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_155 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_156 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_157 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_158 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_159 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_160 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_161 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_162 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_163 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_164 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 36: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_165 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_166 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_167 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_168 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_169 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_170 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_171 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_172 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_173 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_174 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_175 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_176 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_177 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_178 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_179 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_180 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_181 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_182 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_183 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_184 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 37: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_185 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_186 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_187 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_188 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_189 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_190 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_191 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_192 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_193 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_194 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_195 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_196 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_197 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_198 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_199 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_200 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_201 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_202 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_203 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_204 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 38: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_205 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_206 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_207 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_208 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_209 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_210 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_211 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_212 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_213 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_214 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_215 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_216 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_217 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_218 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_219 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_220 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_221 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_222 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_223 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_224 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 39: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_225 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_226 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_227 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_228 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_229 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_230 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_231 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_232 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_233 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_234 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_235 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_236 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_237 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_238 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_239 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_240 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_241 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_242 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_243 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_244 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 40: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_245 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_246 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_247 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_248 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_249 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_250 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_251 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_252 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_253 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_254 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_255 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_256 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_257 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_258 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_259 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_260 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_261 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_262 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_263 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_264 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 41: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_265 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_266 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_267 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_268 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_269 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_270 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_271 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_272 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_273 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_274 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_275 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_276 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_277 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_278 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_279 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_280 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_281 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_282 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_283 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_284 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 42: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_285 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_286 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_287 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_288 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_289 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_290 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_291 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_292 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_293 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_294 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_295 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_296 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_297 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_298 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_299 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_300 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_301 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_302 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_303 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_304 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_40 =3D self.input.LA(2) =20 - if (LA93_40 =3D=3D IDENTIFIER) : + if (LA93_40 =3D=3D IDENTIFIER): LA93_305 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif (LA93_40 =3D=3D 43) : + elif (LA93_40 =3D=3D 43): LA93_306 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - elif LA93 =3D=3D 48: LA93_41 =3D self.input.LA(2) =20 - if (LA93_41 =3D=3D 43) : + if (LA93_41 =3D=3D 43): LA93_307 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - elif (LA93_41 =3D=3D IDENTIFIER) : + elif (LA93_41 =3D=3D IDENTIFIER): LA93_308 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D=3D 5= 1 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D 55 o= r LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 58 or LA93 =3D=3D 59 or L= A93 =3D=3D 60 or LA93 =3D=3D 61: LA93 =3D self.input.LA(2) if LA93 =3D=3D 66: LA93_309 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 58: LA93_310 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 59: LA93_311 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 60: LA93_312 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D IDENTIFIER: LA93_313 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 62: LA93_314 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 25: LA93_315 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 29 or LA93 =3D=3D 30 or LA93 =3D= =3D 31 or LA93 =3D=3D 32 or LA93 =3D=3D 33: LA93_316 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 34: LA93_317 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 35: LA93_318 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 36: LA93_319 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 37: LA93_320 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 38: LA93_321 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 39: LA93_322 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 40: LA93_323 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 41: LA93_324 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 42: LA93_325 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 45 or LA93 =3D=3D 46: LA93_326 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 48: LA93_327 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - elif LA93 =3D=3D 49 or LA93 =3D=3D 50 or LA93 =3D= =3D 51 or LA93 =3D=3D 52 or LA93 =3D=3D 53 or LA93 =3D=3D 54 or LA93 =3D=3D= 55 or LA93 =3D=3D 56 or LA93 =3D=3D 57 or LA93 =3D=3D 61: LA93_328 =3D self.input.LA(3) =20 - if (self.synpred186()) : + if (self.synpred186()): alt93 =3D 1 =20 - - - if alt93 =3D=3D 1: # C.g:0:0: declaration - self.following.append(self.FOLLOW_declaration_in_c= ompound_statement2225) + self.following.append( + self.FOLLOW_declaration_in_compound_statement2= 225) self.declaration() self.following.pop() if self.failed: return retval =20 - else: - break #loop93 - + break # loop93 =20 # C.g:554:21: ( statement_list )? alt94 =3D 2 LA94_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA94_0 <=3D FLOATING_POINT_LITERAL) o= r (25 <=3D LA94_0 <=3D 26) or (29 <=3D LA94_0 <=3D 43) or (45 <=3D LA94_0 <= =3D 46) or (48 <=3D LA94_0 <=3D 62) or LA94_0 =3D=3D 66 or (68 <=3D LA94_0 = <=3D 69) or (72 <=3D LA94_0 <=3D 74) or (77 <=3D LA94_0 <=3D 79) or (103 <= =3D LA94_0 <=3D 108) or (110 <=3D LA94_0 <=3D 117)) : + if ((IDENTIFIER <=3D LA94_0 <=3D FLOATING_POINT_LITERAL) o= r (25 <=3D LA94_0 <=3D 26) or (29 <=3D LA94_0 <=3D 43) or (45 <=3D LA94_0 <= =3D 46) or (48 <=3D LA94_0 <=3D 62) or LA94_0 =3D=3D 66 or (68 <=3D LA94_0 = <=3D 69) or (72 <=3D LA94_0 <=3D 74) or (77 <=3D LA94_0 <=3D 79) or (103 <= =3D LA94_0 <=3D 108) or (110 <=3D LA94_0 <=3D 117)): alt94 =3D 1 if alt94 =3D=3D 1: # C.g:0:0: statement_list - self.following.append(self.FOLLOW_statement_list_in_co= mpound_statement2228) + self.following.append( + self.FOLLOW_statement_list_in_compound_statement22= 28) self.statement_list() self.following.pop() if self.failed: return retval =20 - - - self.match(self.input, 44, self.FOLLOW_44_in_compound_stat= ement2231) + self.match(self.input, 44, + self.FOLLOW_44_in_compound_statement2231) if self.failed: return retval =20 - - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -14539,9 +13822,9 @@ class CParser(Parser): =20 # $ANTLR end compound_statement =20 - # $ANTLR start statement_list # C.g:557:1: statement_list : ( statement )+ ; + def statement_list(self, ): =20 statement_list_StartIndex =3D self.input.index() @@ -14554,7 +13837,7 @@ class CParser(Parser): # C.g:558:4: ( statement )+ # C.g:558:4: ( statement )+ cnt95 =3D 0 - while True: #loop95 + while True: # loop95 alt95 =3D 2 LA95 =3D self.input.LA(1) if LA95 =3D=3D IDENTIFIER: @@ -14562,330 +13845,283 @@ class CParser(Parser): if LA95 =3D=3D 62: LA95_46 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25 or LA95 =3D=3D 29 or LA95 =3D= =3D 30 or LA95 =3D=3D 31 or LA95 =3D=3D 32 or LA95 =3D=3D 33 or LA95 =3D=3D= 34 or LA95 =3D=3D 35 or LA95 =3D=3D 36 or LA95 =3D=3D 37 or LA95 =3D=3D 38= or LA95 =3D=3D 39 or LA95 =3D=3D 40 or LA95 =3D=3D 41 or LA95 =3D=3D 42 or= LA95 =3D=3D 45 or LA95 =3D=3D 46 or LA95 =3D=3D 47 or LA95 =3D=3D 48 or LA= 95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D=3D 51 or LA95 =3D=3D 52 or LA95 = =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D 55 or LA95 =3D=3D 56 or LA95 =3D= =3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59 or LA95 =3D=3D 60 or LA95 =3D=3D= 61: alt95 =3D 1 elif LA95 =3D=3D STRING_LITERAL: LA95_48 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_49 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 64: LA95_50 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_51 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_52 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_53 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_54 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_55 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_56 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_57 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_58 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_59 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_60 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_61 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_62 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_63 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_64 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_65 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_66 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_67 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_68 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_69 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_88 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D HEX_LITERAL: LA95 =3D self.input.LA(2) if LA95 =3D=3D 64: LA95_89 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_90 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_91 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_92 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_93 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_94 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_95 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_96 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_97 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_98 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_99 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_100 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_101 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_102 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_103 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_104 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_105 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_106 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_107 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_108 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_109 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_110 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -14894,157 +14130,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_113 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_114 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_115 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_116 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_117 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_118 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_119 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_120 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_121 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_122 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_123 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_124 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_125 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_126 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_127 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_128 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_129 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_130 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_131 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_132 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_133 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_135 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15053,157 +14267,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_137 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_138 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_139 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_140 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_141 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_142 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_143 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_144 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_145 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_146 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_147 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_148 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_149 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_150 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_151 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_152 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_153 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_154 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_155 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_156 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_157 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_158 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15212,157 +14404,135 @@ class CParser(Parser): if LA95 =3D=3D 64: LA95_161 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_162 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_163 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_164 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_165 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_166 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_167 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_168 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_169 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_170 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_171 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_172 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_173 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_174 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_175 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_176 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_177 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_178 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_179 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_180 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_181 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_182 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 =20 @@ -15371,867 +14541,742 @@ class CParser(Parser): if LA95 =3D=3D IDENTIFIER: LA95_185 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 64: LA95_186 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_187 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_188 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_189 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_190 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_191 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_192 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_193 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_194 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_195 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_196 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_197 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_198 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_199 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_200 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_201 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_202 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_203 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_204 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_205 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_206 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 elif LA95 =3D=3D STRING_LITERAL: LA95_208 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_209 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95 =3D self.input.LA(2) if LA95 =3D=3D 64: LA95_211 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_212 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 75: LA95_213 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66: LA95_214 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 76: LA95_215 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_216 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_217 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 70: LA95_218 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 71: LA95_219 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 68: LA95_220 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 69: LA95_221 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 101 or LA95 =3D=3D 102: LA95_222 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 97 or LA95 =3D=3D 98 or LA95 =3D= =3D 99 or LA95 =3D=3D 100: LA95_223 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 95 or LA95 =3D=3D 96: LA95_224 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 77: LA95_225 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 94: LA95_226 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 93: LA95_227 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 92: LA95_228 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 91: LA95_229 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 90: LA95_230 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 27: LA95_231 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 25: alt95 =3D 1 elif LA95 =3D=3D 28 or LA95 =3D=3D 80 or LA95 =3D= =3D 81 or LA95 =3D=3D 82 or LA95 =3D=3D 83 or LA95 =3D=3D 84 or LA95 =3D=3D= 85 or LA95 =3D=3D 86 or LA95 =3D=3D 87 or LA95 =3D=3D 88 or LA95 =3D=3D 89: LA95_234 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 62: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_235 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_236 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_237 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_238 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_239 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_240 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_241 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_242 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_243 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_244 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_245 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_246 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D= =3D 51 or LA95 =3D=3D 52 or LA95 =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D= 55 or LA95 =3D=3D 56 or LA95 =3D=3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59= or LA95 =3D=3D 60 or LA95 =3D=3D 61: LA95_247 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 34: LA95_248 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 35: LA95_249 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 36: LA95_250 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 37: LA95_251 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 38: LA95_252 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 39: LA95_253 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 40: LA95_254 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 41: LA95_255 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 42: LA95_256 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 45 or LA95 =3D=3D 46: LA95_257 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 48: LA95_258 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 72: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_259 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_260 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_261 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_262 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_263 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_264 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_265 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_266 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_267 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_268 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_269 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_270 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 73: LA95 =3D self.input.LA(2) if LA95 =3D=3D IDENTIFIER: LA95_271 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_272 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_273 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_274 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_275 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_276 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_277 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 62: LA95_278 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_279 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_280 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_281 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_282 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D=3D 6= 9 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95 =3D self.input.LA(2) if LA95 =3D=3D 62: LA95_283 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_284 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_285 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_286 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_287 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_288 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_289 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_290 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_291 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_292 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_293 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_294 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 74: LA95 =3D self.input.LA(2) if LA95 =3D=3D 62: LA95_295 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D IDENTIFIER: LA95_296 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D HEX_LITERAL: LA95_297 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D OCTAL_LITERAL: LA95_298 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D DECIMAL_LITERAL: LA95_299 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D CHARACTER_LITERAL: LA95_300 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D STRING_LITERAL: LA95_301 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D FLOATING_POINT_LITERAL: LA95_302 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 72: LA95_303 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 73: LA95_304 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 66 or LA95 =3D=3D 68 or LA95 =3D= =3D 69 or LA95 =3D=3D 77 or LA95 =3D=3D 78 or LA95 =3D=3D 79: LA95_305 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - elif LA95 =3D=3D 74: LA95_306 =3D self.input.LA(3) =20 - if (self.synpred188()) : + if (self.synpred188()): alt95 =3D 1 =20 - - elif LA95 =3D=3D 25 or LA95 =3D=3D 26 or LA95 =3D=3D 2= 9 or LA95 =3D=3D 30 or LA95 =3D=3D 31 or LA95 =3D=3D 32 or LA95 =3D=3D 33 o= r LA95 =3D=3D 34 or LA95 =3D=3D 35 or LA95 =3D=3D 36 or LA95 =3D=3D 37 or L= A95 =3D=3D 38 or LA95 =3D=3D 39 or LA95 =3D=3D 40 or LA95 =3D=3D 41 or LA95= =3D=3D 42 or LA95 =3D=3D 43 or LA95 =3D=3D 45 or LA95 =3D=3D 46 or LA95 = =3D=3D 48 or LA95 =3D=3D 49 or LA95 =3D=3D 50 or LA95 =3D=3D 51 or LA95 =3D= =3D 52 or LA95 =3D=3D 53 or LA95 =3D=3D 54 or LA95 =3D=3D 55 or LA95 =3D=3D= 56 or LA95 =3D=3D 57 or LA95 =3D=3D 58 or LA95 =3D=3D 59 or LA95 =3D=3D 60= or LA95 =3D=3D 61 or LA95 =3D=3D 103 or LA95 =3D=3D 104 or LA95 =3D=3D 105= or LA95 =3D=3D 106 or LA95 =3D=3D 107 or LA95 =3D=3D 108 or LA95 =3D=3D 11= 0 or LA95 =3D=3D 111 or LA95 =3D=3D 112 or LA95 =3D=3D 113 or LA95 =3D=3D 1= 14 or LA95 =3D=3D 115 or LA95 =3D=3D 116 or LA95 =3D=3D 117: alt95 =3D 1 =20 if alt95 =3D=3D 1: # C.g:0:0: statement - self.following.append(self.FOLLOW_statement_in_sta= tement_list2242) + self.following.append( + self.FOLLOW_statement_in_statement_list2242) self.statement() self.following.pop() if self.failed: return =20 - else: if cnt95 >=3D 1: - break #loop95 + break # loop95 =20 if self.backtracking > 0: self.failed =3D True @@ -16242,11 +15287,6 @@ class CParser(Parser): =20 cnt95 +=3D 1 =20 - - - - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16265,10 +15305,9 @@ class CParser(Parser): self.start =3D None self.stop =3D None =20 - - # $ANTLR start expression_statement # C.g:561:1: expression_statement : ( ';' | expression ';' ); + def expression_statement(self, ): =20 retval =3D self.expression_statement_return() @@ -16283,41 +15322,42 @@ class CParser(Parser): alt96 =3D 2 LA96_0 =3D self.input.LA(1) =20 - if (LA96_0 =3D=3D 25) : + if (LA96_0 =3D=3D 25): alt96 =3D 1 - elif ((IDENTIFIER <=3D LA96_0 <=3D FLOATING_POINT_LITERAL)= or LA96_0 =3D=3D 62 or LA96_0 =3D=3D 66 or (68 <=3D LA96_0 <=3D 69) or (72= <=3D LA96_0 <=3D 74) or (77 <=3D LA96_0 <=3D 79)) : + elif ((IDENTIFIER <=3D LA96_0 <=3D FLOATING_POINT_LITERAL)= or LA96_0 =3D=3D 62 or LA96_0 =3D=3D 66 or (68 <=3D LA96_0 <=3D 69) or (72= <=3D LA96_0 <=3D 74) or (77 <=3D LA96_0 <=3D 79)): alt96 =3D 2 else: if self.backtracking > 0: self.failed =3D True return retval =20 - nvae =3D NoViableAltException("561:1: expression_state= ment : ( ';' | expression ';' );", 96, 0, self.input) + nvae =3D NoViableAltException( + "561:1: expression_statement : ( ';' | expression = ';' );", 96, 0, self.input) =20 raise nvae =20 if alt96 =3D=3D 1: # C.g:562:4: ';' - self.match(self.input, 25, self.FOLLOW_25_in_expressio= n_statement2254) + self.match(self.input, 25, + self.FOLLOW_25_in_expression_statement2254) if self.failed: return retval =20 - elif alt96 =3D=3D 2: # C.g:563:4: expression ';' - self.following.append(self.FOLLOW_expression_in_expres= sion_statement2259) + self.following.append( + self.FOLLOW_expression_in_expression_statement2259) self.expression() self.following.pop() if self.failed: return retval - self.match(self.input, 25, self.FOLLOW_25_in_expressio= n_statement2261) + self.match(self.input, 25, + self.FOLLOW_25_in_expression_statement2261) if self.failed: return retval =20 - retval.stop =3D self.input.LT(-1) =20 - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16331,15 +15371,14 @@ class CParser(Parser): =20 # $ANTLR end expression_statement =20 - # $ANTLR start selection_statement # C.g:566:1: selection_statement : ( 'if' '(' e=3D expression ')' stat= ement ( options {k=3D1; backtrack=3Dfalse; } : 'else' statement )? | 'switc= h' '(' expression ')' statement ); + def selection_statement(self, ): =20 selection_statement_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 69): @@ -16349,39 +15388,46 @@ class CParser(Parser): alt98 =3D 2 LA98_0 =3D self.input.LA(1) =20 - if (LA98_0 =3D=3D 108) : + if (LA98_0 =3D=3D 108): alt98 =3D 1 - elif (LA98_0 =3D=3D 110) : + elif (LA98_0 =3D=3D 110): alt98 =3D 2 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("566:1: selection_statem= ent : ( 'if' '(' e=3D expression ')' statement ( options {k=3D1; backtrack= =3Dfalse; } : 'else' statement )? | 'switch' '(' expression ')' statement )= ;", 98, 0, self.input) + nvae =3D NoViableAltException( + "566:1: selection_statement : ( 'if' '(' e=3D expr= ession ')' statement ( options {k=3D1; backtrack=3Dfalse; } : 'else' statem= ent )? | 'switch' '(' expression ')' statement );", 98, 0, self.input) =20 raise nvae =20 if alt98 =3D=3D 1: # C.g:567:4: 'if' '(' e=3D expression ')' statement ( = options {k=3D1; backtrack=3Dfalse; } : 'else' statement )? - self.match(self.input, 108, self.FOLLOW_108_in_selecti= on_statement2272) + self.match(self.input, 108, + self.FOLLOW_108_in_selection_statement2272) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_selection= _statement2274) + self.match(self.input, 62, + self.FOLLOW_62_in_selection_statement2274) if self.failed: return - self.following.append(self.FOLLOW_expression_in_select= ion_statement2278) + self.following.append( + self.FOLLOW_expression_in_selection_statement2278) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_selection= _statement2280) + self.match(self.input, 63, + self.FOLLOW_63_in_selection_statement2280) if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 - self.following.append(self.FOLLOW_statement_in_selecti= on_statement2284) + self.following.append( + self.FOLLOW_statement_in_selection_statement2284) self.statement() self.following.pop() if self.failed: @@ -16390,47 +15436,48 @@ class CParser(Parser): alt97 =3D 2 LA97_0 =3D self.input.LA(1) =20 - if (LA97_0 =3D=3D 109) : + if (LA97_0 =3D=3D 109): alt97 =3D 1 if alt97 =3D=3D 1: # C.g:567:200: 'else' statement - self.match(self.input, 109, self.FOLLOW_109_in_sel= ection_statement2299) + self.match(self.input, 109, + self.FOLLOW_109_in_selection_statement2= 299) if self.failed: return - self.following.append(self.FOLLOW_statement_in_sel= ection_statement2301) + self.following.append( + self.FOLLOW_statement_in_selection_statement23= 01) self.statement() self.following.pop() if self.failed: return =20 - - - - elif alt98 =3D=3D 2: # C.g:568:4: 'switch' '(' expression ')' statement - self.match(self.input, 110, self.FOLLOW_110_in_selecti= on_statement2308) + self.match(self.input, 110, + self.FOLLOW_110_in_selection_statement2308) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_selection= _statement2310) + self.match(self.input, 62, + self.FOLLOW_62_in_selection_statement2310) if self.failed: return - self.following.append(self.FOLLOW_expression_in_select= ion_statement2312) + self.following.append( + self.FOLLOW_expression_in_selection_statement2312) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_selection= _statement2314) + self.match(self.input, 63, + self.FOLLOW_63_in_selection_statement2314) if self.failed: return - self.following.append(self.FOLLOW_statement_in_selecti= on_statement2316) + self.following.append( + self.FOLLOW_statement_in_selection_statement2316) self.statement() self.following.pop() if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16444,15 +15491,14 @@ class CParser(Parser): =20 # $ANTLR end selection_statement =20 - # $ANTLR start iteration_statement # C.g:571:1: iteration_statement : ( 'while' '(' e=3D expression ')' s= tatement | 'do' statement 'while' '(' e=3D expression ')' ';' | 'for' '(' e= xpression_statement e=3D expression_statement ( expression )? ')' statement= ); + def iteration_statement(self, ): =20 iteration_statement_StartIndex =3D self.input.index() e =3D None =20 - try: try: if self.backtracking > 0 and self.alreadyParsedRule(self.i= nput, 70): @@ -16472,82 +15518,97 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("571:1: iteration_statem= ent : ( 'while' '(' e=3D expression ')' statement | 'do' statement 'while' = '(' e=3D expression ')' ';' | 'for' '(' expression_statement e=3D expressio= n_statement ( expression )? ')' statement );", 100, 0, self.input) + nvae =3D NoViableAltException( + "571:1: iteration_statement : ( 'while' '(' e=3D e= xpression ')' statement | 'do' statement 'while' '(' e=3D expression ')' ';= ' | 'for' '(' expression_statement e=3D expression_statement ( expression )= ? ')' statement );", 100, 0, self.input) =20 raise nvae =20 if alt100 =3D=3D 1: # C.g:572:4: 'while' '(' e=3D expression ')' statement - self.match(self.input, 111, self.FOLLOW_111_in_iterati= on_statement2327) + self.match(self.input, 111, + self.FOLLOW_111_in_iteration_statement2327) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2329) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2329) if self.failed: return - self.following.append(self.FOLLOW_expression_in_iterat= ion_statement2333) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2333) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2335) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2335) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2337) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2337) self.statement() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 elif alt100 =3D=3D 2: # C.g:573:4: 'do' statement 'while' '(' e=3D expressio= n ')' ';' - self.match(self.input, 112, self.FOLLOW_112_in_iterati= on_statement2344) + self.match(self.input, 112, + self.FOLLOW_112_in_iteration_statement2344) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2346) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2346) self.statement() self.following.pop() if self.failed: return - self.match(self.input, 111, self.FOLLOW_111_in_iterati= on_statement2348) + self.match(self.input, 111, + self.FOLLOW_111_in_iteration_statement2348) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2350) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2350) if self.failed: return - self.following.append(self.FOLLOW_expression_in_iterat= ion_statement2354) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2354) e =3D self.expression() self.following.pop() if self.failed: return - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2356) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2356) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_iteration= _statement2358) + self.match(self.input, 25, + self.FOLLOW_25_in_iteration_statement2358) if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 elif alt100 =3D=3D 3: # C.g:574:4: 'for' '(' expression_statement e=3D expre= ssion_statement ( expression )? ')' statement - self.match(self.input, 113, self.FOLLOW_113_in_iterati= on_statement2365) + self.match(self.input, 113, + self.FOLLOW_113_in_iteration_statement2365) if self.failed: return - self.match(self.input, 62, self.FOLLOW_62_in_iteration= _statement2367) + self.match(self.input, 62, + self.FOLLOW_62_in_iteration_statement2367) if self.failed: return - self.following.append(self.FOLLOW_expression_statement= _in_iteration_statement2369) + self.following.append( + self.FOLLOW_expression_statement_in_iteration_stat= ement2369) self.expression_statement() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_expression_statement= _in_iteration_statement2373) + self.following.append( + self.FOLLOW_expression_statement_in_iteration_stat= ement2373) e =3D self.expression_statement() self.following.pop() if self.failed: @@ -16556,31 +15617,30 @@ class CParser(Parser): alt99 =3D 2 LA99_0 =3D self.input.LA(1) =20 - if ((IDENTIFIER <=3D LA99_0 <=3D FLOATING_POINT_LITERA= L) or LA99_0 =3D=3D 62 or LA99_0 =3D=3D 66 or (68 <=3D LA99_0 <=3D 69) or (= 72 <=3D LA99_0 <=3D 74) or (77 <=3D LA99_0 <=3D 79)) : + if ((IDENTIFIER <=3D LA99_0 <=3D FLOATING_POINT_LITERA= L) or LA99_0 =3D=3D 62 or LA99_0 =3D=3D 66 or (68 <=3D LA99_0 <=3D 69) or (= 72 <=3D LA99_0 <=3D 74) or (77 <=3D LA99_0 <=3D 79)): alt99 =3D 1 if alt99 =3D=3D 1: # C.g:0:0: expression - self.following.append(self.FOLLOW_expression_in_it= eration_statement2375) + self.following.append( + self.FOLLOW_expression_in_iteration_statement2= 375) self.expression() self.following.pop() if self.failed: return =20 - - - self.match(self.input, 63, self.FOLLOW_63_in_iteration= _statement2378) + self.match(self.input, 63, + self.FOLLOW_63_in_iteration_statement2378) if self.failed: return - self.following.append(self.FOLLOW_statement_in_iterati= on_statement2380) + self.following.append( + self.FOLLOW_statement_in_iteration_statement2380) self.statement() self.following.pop() if self.failed: return if self.backtracking =3D=3D 0: - self.StorePredicateExpression(e.start.line, e.star= t.charPositionInLine, e.stop.line, e.stop.charPositionInLine, self.input.to= String(e.start, e.stop)) - - - + self.StorePredicateExpression( + e.start.line, e.start.charPositionInLine, e.st= op.line, e.stop.charPositionInLine, self.input.toString(e.start, e.stop)) =20 except RecognitionException as re: self.reportError(re) @@ -16595,9 +15655,9 @@ class CParser(Parser): =20 # $ANTLR end iteration_statement =20 - # $ANTLR start jump_statement # C.g:577:1: jump_statement : ( 'goto' IDENTIFIER ';' | 'continue' ';'= | 'break' ';' | 'return' ';' | 'return' expression ';' ); + def jump_statement(self, ): =20 jump_statement_StartIndex =3D self.input.index() @@ -16618,16 +15678,17 @@ class CParser(Parser): elif LA101 =3D=3D 117: LA101_4 =3D self.input.LA(2) =20 - if (LA101_4 =3D=3D 25) : + if (LA101_4 =3D=3D 25): alt101 =3D 4 - elif ((IDENTIFIER <=3D LA101_4 <=3D FLOATING_POINT_LIT= ERAL) or LA101_4 =3D=3D 62 or LA101_4 =3D=3D 66 or (68 <=3D LA101_4 <=3D 69= ) or (72 <=3D LA101_4 <=3D 74) or (77 <=3D LA101_4 <=3D 79)) : + elif ((IDENTIFIER <=3D LA101_4 <=3D FLOATING_POINT_LIT= ERAL) or LA101_4 =3D=3D 62 or LA101_4 =3D=3D 66 or (68 <=3D LA101_4 <=3D 69= ) or (72 <=3D LA101_4 <=3D 74) or (77 <=3D LA101_4 <=3D 79)): alt101 =3D 5 else: if self.backtracking > 0: self.failed =3D True return =20 - nvae =3D NoViableAltException("577:1: jump_stateme= nt : ( 'goto' IDENTIFIER ';' | 'continue' ';' | 'break' ';' | 'return' ';' = | 'return' expression ';' );", 101, 4, self.input) + nvae =3D NoViableAltException( + "577:1: jump_statement : ( 'goto' IDENTIFIER '= ;' | 'continue' ';' | 'break' ';' | 'return' ';' | 'return' expression ';' = );", 101, 4, self.input) =20 raise nvae =20 @@ -16636,69 +15697,76 @@ class CParser(Parser): self.failed =3D True return =20 - nvae =3D NoViableAltException("577:1: jump_statement := ( 'goto' IDENTIFIER ';' | 'continue' ';' | 'break' ';' | 'return' ';' | 'r= eturn' expression ';' );", 101, 0, self.input) + nvae =3D NoViableAltException( + "577:1: jump_statement : ( 'goto' IDENTIFIER ';' |= 'continue' ';' | 'break' ';' | 'return' ';' | 'return' expression ';' );",= 101, 0, self.input) =20 raise nvae =20 if alt101 =3D=3D 1: # C.g:578:4: 'goto' IDENTIFIER ';' - self.match(self.input, 114, self.FOLLOW_114_in_jump_st= atement2393) + self.match(self.input, 114, + self.FOLLOW_114_in_jump_statement2393) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIF= IER_in_jump_statement2395) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_jump_statement239= 5) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2397) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2397) if self.failed: return =20 - elif alt101 =3D=3D 2: # C.g:579:4: 'continue' ';' - self.match(self.input, 115, self.FOLLOW_115_in_jump_st= atement2402) + self.match(self.input, 115, + self.FOLLOW_115_in_jump_statement2402) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2404) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2404) if self.failed: return =20 - elif alt101 =3D=3D 3: # C.g:580:4: 'break' ';' - self.match(self.input, 116, self.FOLLOW_116_in_jump_st= atement2409) + self.match(self.input, 116, + self.FOLLOW_116_in_jump_statement2409) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2411) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2411) if self.failed: return =20 - elif alt101 =3D=3D 4: # C.g:581:4: 'return' ';' - self.match(self.input, 117, self.FOLLOW_117_in_jump_st= atement2416) + self.match(self.input, 117, + self.FOLLOW_117_in_jump_statement2416) if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2418) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2418) if self.failed: return =20 - elif alt101 =3D=3D 5: # C.g:582:4: 'return' expression ';' - self.match(self.input, 117, self.FOLLOW_117_in_jump_st= atement2423) + self.match(self.input, 117, + self.FOLLOW_117_in_jump_statement2423) if self.failed: return - self.following.append(self.FOLLOW_expression_in_jump_s= tatement2425) + self.following.append( + self.FOLLOW_expression_in_jump_statement2425) self.expression() self.following.pop() if self.failed: return - self.match(self.input, 25, self.FOLLOW_25_in_jump_stat= ement2427) + self.match(self.input, 25, + self.FOLLOW_25_in_jump_statement2427) if self.failed: return =20 - - except RecognitionException as re: self.reportError(re) self.recover(self.input, re) @@ -16716,18 +15784,17 @@ class CParser(Parser): def synpred2_fragment(self, ): # C.g:119:6: ( declaration_specifiers ) # C.g:119:6: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d2100) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred2100) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred2 =20 - - # $ANTLR start synpred4 + def synpred4_fragment(self, ): # C.g:119:4: ( ( declaration_specifiers )? declarator ( declaratio= n )* '{' ) # C.g:119:6: ( declaration_specifiers )? declarator ( declaration = )* '{' @@ -16741,134 +15808,132 @@ class CParser(Parser): if LA102 =3D=3D 62: LA102_21 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 29 or LA102 =3D=3D 30 or LA102 =3D=3D 31 or = LA102 =3D=3D 32 or LA102 =3D=3D 33: LA102_23 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 34: LA102_24 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 35: LA102_25 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 36: LA102_26 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 37: LA102_27 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 38: LA102_28 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 39: LA102_29 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 40: LA102_30 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 41: LA102_31 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 42: LA102_32 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 45 or LA102 =3D=3D 46: LA102_33 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 48: LA102_34 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D IDENTIFIER: LA102_35 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 58: LA102_36 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 66: alt102 =3D 1 elif LA102 =3D=3D 59: LA102_39 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 60: LA102_40 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 49 or LA102 =3D=3D 50 or LA102 =3D=3D 51 or = LA102 =3D=3D 52 or LA102 =3D=3D 53 or LA102 =3D=3D 54 or LA102 =3D=3D 55 or= LA102 =3D=3D 56 or LA102 =3D=3D 57 or LA102 =3D=3D 61: LA102_41 =3D self.input.LA(3) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 58: LA102_14 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 59: LA102_16 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 elif LA102 =3D=3D 60: LA102_17 =3D self.input.LA(2) =20 - if (self.synpred2()) : + if (self.synpred2()): alt102 =3D 1 if alt102 =3D=3D 1: # C.g:0:0: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_sy= npred4100) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred4100) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - - self.following.append(self.FOLLOW_declarator_in_synpred4103) self.declarator() self.following.pop() if self.failed: return # C.g:119:41: ( declaration )* - while True: #loop103 + while True: # loop103 alt103 =3D 2 LA103_0 =3D self.input.LA(1) =20 - if (LA103_0 =3D=3D IDENTIFIER or LA103_0 =3D=3D 26 or (29 <=3D= LA103_0 <=3D 42) or (45 <=3D LA103_0 <=3D 46) or (48 <=3D LA103_0 <=3D 61)= ) : + if (LA103_0 =3D=3D IDENTIFIER or LA103_0 =3D=3D 26 or (29 <=3D= LA103_0 <=3D 42) or (45 <=3D LA103_0 <=3D 46) or (48 <=3D LA103_0 <=3D 61)= ): alt103 =3D 1 =20 - if alt103 =3D=3D 1: # C.g:0:0: declaration self.following.append(self.FOLLOW_declaration_in_synpred41= 05) @@ -16877,21 +15942,17 @@ class CParser(Parser): if self.failed: return =20 - else: - break #loop103 - + break # loop103 =20 self.match(self.input, 43, self.FOLLOW_43_in_synpred4108) if self.failed: return =20 - # $ANTLR end synpred4 =20 - - # $ANTLR start synpred5 + def synpred5_fragment(self, ): # C.g:120:4: ( declaration ) # C.g:120:4: declaration @@ -16901,42 +15962,38 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred5 =20 - - # $ANTLR start synpred7 + def synpred7_fragment(self, ): # C.g:146:6: ( declaration_specifiers ) # C.g:146:6: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d7157) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred7157) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred7 =20 - - # $ANTLR start synpred10 + def synpred10_fragment(self, ): # C.g:167:18: ( declaration_specifiers ) # C.g:167:18: declaration_specifiers - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d10207) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred10207) self.declaration_specifiers() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred10 =20 - - # $ANTLR start synpred14 + def synpred14_fragment(self, ): # C.g:184:7: ( type_specifier ) # C.g:184:7: type_specifier @@ -16946,12 +16003,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred14 =20 - - # $ANTLR start synpred15 + def synpred15_fragment(self, ): # C.g:185:13: ( type_qualifier ) # C.g:185:13: type_qualifier @@ -16961,12 +16016,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred15 =20 - - # $ANTLR start synpred33 + def synpred33_fragment(self, ): # C.g:225:16: ( type_qualifier ) # C.g:225:16: type_qualifier @@ -16976,58 +16029,53 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred33 =20 - - # $ANTLR start synpred34 + def synpred34_fragment(self, ): # C.g:225:4: ( IDENTIFIER ( type_qualifier )* declarator ) # C.g:225:5: IDENTIFIER ( type_qualifier )* declarator - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_synpr= ed34442) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred34442) if self.failed: return # C.g:225:16: ( type_qualifier )* - while True: #loop106 + while True: # loop106 alt106 =3D 2 LA106 =3D self.input.LA(1) if LA106 =3D=3D 58: LA106_2 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 59: LA106_3 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 60: LA106_4 =3D self.input.LA(2) =20 - if (self.synpred33()) : + if (self.synpred33()): alt106 =3D 1 =20 - elif LA106 =3D=3D 49 or LA106 =3D=3D 50 or LA106 =3D=3D 51 or = LA106 =3D=3D 52 or LA106 =3D=3D 53 or LA106 =3D=3D 54 or LA106 =3D=3D 55 or= LA106 =3D=3D 56 or LA106 =3D=3D 57 or LA106 =3D=3D 61: alt106 =3D 1 =20 if alt106 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_in_synpre= d34444) + self.following.append( + self.FOLLOW_type_qualifier_in_synpred34444) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: - break #loop106 - + break # loop106 =20 self.following.append(self.FOLLOW_declarator_in_synpred34447) self.declarator() @@ -17035,12 +16083,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred34 =20 - - # $ANTLR start synpred39 + def synpred39_fragment(self, ): # C.g:253:6: ( type_qualifier ) # C.g:253:6: type_qualifier @@ -17050,12 +16096,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred39 =20 - - # $ANTLR start synpred40 + def synpred40_fragment(self, ): # C.g:253:23: ( type_specifier ) # C.g:253:23: type_specifier @@ -17065,12 +16109,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred40 =20 - - # $ANTLR start synpred66 + def synpred66_fragment(self, ): # C.g:297:4: ( ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? (= 'EFI_RUNTIMESERVICE' )? direct_declarator ) # C.g:297:4: ( pointer )? ( 'EFIAPI' )? ( 'EFI_BOOTSERVICE' )? ( '= EFI_RUNTIMESERVICE' )? direct_declarator @@ -17078,7 +16120,7 @@ class CParser(Parser): alt111 =3D 2 LA111_0 =3D self.input.LA(1) =20 - if (LA111_0 =3D=3D 66) : + if (LA111_0 =3D=3D 66): alt111 =3D 1 if alt111 =3D=3D 1: # C.g:0:0: pointer @@ -17088,13 +16130,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:13: ( 'EFIAPI' )? alt112 =3D 2 LA112_0 =3D self.input.LA(1) =20 - if (LA112_0 =3D=3D 58) : + if (LA112_0 =3D=3D 58): alt112 =3D 1 if alt112 =3D=3D 1: # C.g:297:14: 'EFIAPI' @@ -17102,13 +16142,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:25: ( 'EFI_BOOTSERVICE' )? alt113 =3D 2 LA113_0 =3D self.input.LA(1) =20 - if (LA113_0 =3D=3D 59) : + if (LA113_0 =3D=3D 59): alt113 =3D 1 if alt113 =3D=3D 1: # C.g:297:26: 'EFI_BOOTSERVICE' @@ -17116,13 +16154,11 @@ class CParser(Parser): if self.failed: return =20 - - # C.g:297:46: ( 'EFI_RUNTIMESERVICE' )? alt114 =3D 2 LA114_0 =3D self.input.LA(1) =20 - if (LA114_0 =3D=3D 60) : + if (LA114_0 =3D=3D 60): alt114 =3D 1 if alt114 =3D=3D 1: # C.g:297:47: 'EFI_RUNTIMESERVICE' @@ -17130,20 +16166,16 @@ class CParser(Parser): if self.failed: return =20 - - self.following.append(self.FOLLOW_direct_declarator_in_synpred6680= 2) self.direct_declarator() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred66 =20 - - # $ANTLR start synpred67 + def synpred67_fragment(self, ): # C.g:303:15: ( declarator_suffix ) # C.g:303:15: declarator_suffix @@ -17153,12 +16185,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred67 =20 - - # $ANTLR start synpred69 + def synpred69_fragment(self, ): # C.g:304:9: ( 'EFIAPI' ) # C.g:304:9: 'EFIAPI' @@ -17166,12 +16196,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred69 =20 - - # $ANTLR start synpred70 + def synpred70_fragment(self, ): # C.g:304:35: ( declarator_suffix ) # C.g:304:35: declarator_suffix @@ -17181,12 +16209,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred70 =20 - - # $ANTLR start synpred73 + def synpred73_fragment(self, ): # C.g:310:9: ( '(' parameter_type_list ')' ) # C.g:310:9: '(' parameter_type_list ')' @@ -17202,12 +16228,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred73 =20 - - # $ANTLR start synpred74 + def synpred74_fragment(self, ): # C.g:311:9: ( '(' identifier_list ')' ) # C.g:311:9: '(' identifier_list ')' @@ -17223,12 +16247,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred74 =20 - - # $ANTLR start synpred75 + def synpred75_fragment(self, ): # C.g:316:8: ( type_qualifier ) # C.g:316:8: type_qualifier @@ -17238,12 +16260,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred75 =20 - - # $ANTLR start synpred76 + def synpred76_fragment(self, ): # C.g:316:24: ( pointer ) # C.g:316:24: pointer @@ -17253,12 +16273,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred76 =20 - - # $ANTLR start synpred77 + def synpred77_fragment(self, ): # C.g:316:4: ( '*' ( type_qualifier )+ ( pointer )? ) # C.g:316:4: '*' ( type_qualifier )+ ( pointer )? @@ -17267,26 +16285,25 @@ class CParser(Parser): return # C.g:316:8: ( type_qualifier )+ cnt116 =3D 0 - while True: #loop116 + while True: # loop116 alt116 =3D 2 LA116_0 =3D self.input.LA(1) =20 - if ((49 <=3D LA116_0 <=3D 61)) : + if ((49 <=3D LA116_0 <=3D 61)): alt116 =3D 1 =20 - if alt116 =3D=3D 1: # C.g:0:0: type_qualifier - self.following.append(self.FOLLOW_type_qualifier_in_synpre= d77921) + self.following.append( + self.FOLLOW_type_qualifier_in_synpred77921) self.type_qualifier() self.following.pop() if self.failed: return =20 - else: if cnt116 >=3D 1: - break #loop116 + break # loop116 =20 if self.backtracking > 0: self.failed =3D True @@ -17297,12 +16314,11 @@ class CParser(Parser): =20 cnt116 +=3D 1 =20 - # C.g:316:24: ( pointer )? alt117 =3D 2 LA117_0 =3D self.input.LA(1) =20 - if (LA117_0 =3D=3D 66) : + if (LA117_0 =3D=3D 66): alt117 =3D 1 if alt117 =3D=3D 1: # C.g:0:0: pointer @@ -17312,15 +16328,10 @@ class CParser(Parser): if self.failed: return =20 - - - - # $ANTLR end synpred77 =20 - - # $ANTLR start synpred78 + def synpred78_fragment(self, ): # C.g:317:4: ( '*' pointer ) # C.g:317:4: '*' pointer @@ -17333,12 +16344,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred78 =20 - - # $ANTLR start synpred81 + def synpred81_fragment(self, ): # C.g:326:32: ( 'OPTIONAL' ) # C.g:326:32: 'OPTIONAL' @@ -17346,12 +16355,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred81 =20 - - # $ANTLR start synpred82 + def synpred82_fragment(self, ): # C.g:326:27: ( ',' ( 'OPTIONAL' )? parameter_declaration ) # C.g:326:27: ',' ( 'OPTIONAL' )? parameter_declaration @@ -17362,10 +16369,10 @@ class CParser(Parser): alt119 =3D 2 LA119_0 =3D self.input.LA(1) =20 - if (LA119_0 =3D=3D 53) : + if (LA119_0 =3D=3D 53): LA119_1 =3D self.input.LA(2) =20 - if (self.synpred81()) : + if (self.synpred81()): alt119 =3D 1 if alt119 =3D=3D 1: # C.g:326:32: 'OPTIONAL' @@ -17373,20 +16380,17 @@ class CParser(Parser): if self.failed: return =20 - - - self.following.append(self.FOLLOW_parameter_declaration_in_synpred= 82981) + self.following.append( + self.FOLLOW_parameter_declaration_in_synpred82981) self.parameter_declaration() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred82 =20 - - # $ANTLR start synpred83 + def synpred83_fragment(self, ): # C.g:330:28: ( declarator ) # C.g:330:28: declarator @@ -17396,12 +16400,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred83 =20 - - # $ANTLR start synpred84 + def synpred84_fragment(self, ): # C.g:330:39: ( abstract_declarator ) # C.g:330:39: abstract_declarator @@ -17411,33 +16413,31 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred84 =20 - - # $ANTLR start synpred86 + def synpred86_fragment(self, ): # C.g:330:4: ( declaration_specifiers ( declarator | abstract_decl= arator )* ( 'OPTIONAL' )? ) # C.g:330:4: declaration_specifiers ( declarator | abstract_declar= ator )* ( 'OPTIONAL' )? - self.following.append(self.FOLLOW_declaration_specifiers_in_synpre= d86994) + self.following.append( + self.FOLLOW_declaration_specifiers_in_synpred86994) self.declaration_specifiers() self.following.pop() if self.failed: return # C.g:330:27: ( declarator | abstract_declarator )* - while True: #loop120 + while True: # loop120 alt120 =3D 3 LA120 =3D self.input.LA(1) if LA120 =3D=3D 66: LA120_3 =3D self.input.LA(2) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D IDENTIFIER or LA120 =3D=3D 58 or LA120 =3D= =3D 59 or LA120 =3D=3D 60: alt120 =3D 1 elif LA120 =3D=3D 62: @@ -17447,58 +16447,51 @@ class CParser(Parser): elif LA120 =3D=3D 58: LA120_21 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 66: LA120_22 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 59: LA120_23 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 60: LA120_24 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D IDENTIFIER: LA120_25 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - elif LA120 =3D=3D 62: LA120_26 =3D self.input.LA(3) =20 - if (self.synpred83()) : + if (self.synpred83()): alt120 =3D 1 - elif (self.synpred84()) : + elif (self.synpred84()): alt120 =3D 2 =20 - - elif LA120 =3D=3D 64: alt120 =3D 2 =20 @@ -17510,25 +16503,23 @@ class CParser(Parser): if self.failed: return =20 - elif alt120 =3D=3D 2: # C.g:330:39: abstract_declarator - self.following.append(self.FOLLOW_abstract_declarator_in_s= ynpred86999) + self.following.append( + self.FOLLOW_abstract_declarator_in_synpred86999) self.abstract_declarator() self.following.pop() if self.failed: return =20 - else: - break #loop120 - + break # loop120 =20 # C.g:330:61: ( 'OPTIONAL' )? alt121 =3D 2 LA121_0 =3D self.input.LA(1) =20 - if (LA121_0 =3D=3D 53) : + if (LA121_0 =3D=3D 53): alt121 =3D 1 if alt121 =3D=3D 1: # C.g:330:62: 'OPTIONAL' @@ -17536,19 +16527,15 @@ class CParser(Parser): if self.failed: return =20 - - - - # $ANTLR end synpred86 =20 - - # $ANTLR start synpred90 + def synpred90_fragment(self, ): # C.g:341:4: ( specifier_qualifier_list ( abstract_declarator )? ) # C.g:341:4: specifier_qualifier_list ( abstract_declarator )? - self.following.append(self.FOLLOW_specifier_qualifier_list_in_synp= red901046) + self.following.append( + self.FOLLOW_specifier_qualifier_list_in_synpred901046) self.specifier_qualifier_list() self.following.pop() if self.failed: @@ -17557,40 +16544,35 @@ class CParser(Parser): alt122 =3D 2 LA122_0 =3D self.input.LA(1) =20 - if (LA122_0 =3D=3D 62 or LA122_0 =3D=3D 64 or LA122_0 =3D=3D 66) : + if (LA122_0 =3D=3D 62 or LA122_0 =3D=3D 64 or LA122_0 =3D=3D 66): alt122 =3D 1 if alt122 =3D=3D 1: # C.g:0:0: abstract_declarator - self.following.append(self.FOLLOW_abstract_declarator_in_synpr= ed901048) + self.following.append( + self.FOLLOW_abstract_declarator_in_synpred901048) self.abstract_declarator() self.following.pop() if self.failed: return =20 - - - - # $ANTLR end synpred90 =20 - - # $ANTLR start synpred91 + def synpred91_fragment(self, ): # C.g:346:12: ( direct_abstract_declarator ) # C.g:346:12: direct_abstract_declarator - self.following.append(self.FOLLOW_direct_abstract_declarator_in_sy= npred911067) + self.following.append( + self.FOLLOW_direct_abstract_declarator_in_synpred911067) self.direct_abstract_declarator() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred91 =20 - - # $ANTLR start synpred93 + def synpred93_fragment(self, ): # C.g:351:6: ( '(' abstract_declarator ')' ) # C.g:351:6: '(' abstract_declarator ')' @@ -17606,27 +16588,24 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred93 =20 - - # $ANTLR start synpred94 + def synpred94_fragment(self, ): # C.g:351:65: ( abstract_declarator_suffix ) # C.g:351:65: abstract_declarator_suffix - self.following.append(self.FOLLOW_abstract_declarator_suffix_in_sy= npred941098) + self.following.append( + self.FOLLOW_abstract_declarator_suffix_in_synpred941098) self.abstract_declarator_suffix() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred94 =20 - - # $ANTLR start synpred109 + def synpred109_fragment(self, ): # C.g:386:4: ( '(' type_name ')' cast_expression ) # C.g:386:4: '(' type_name ')' cast_expression @@ -17647,12 +16626,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred109 =20 - - # $ANTLR start synpred114 + def synpred114_fragment(self, ): # C.g:395:4: ( 'sizeof' unary_expression ) # C.g:395:4: 'sizeof' unary_expression @@ -17665,19 +16642,18 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred114 =20 - - # $ANTLR start synpred117 + def synpred117_fragment(self, ): # C.g:409:13: ( '(' argument_expression_list ')' ) # C.g:409:13: '(' argument_expression_list ')' self.match(self.input, 62, self.FOLLOW_62_in_synpred1171420) if self.failed: return - self.following.append(self.FOLLOW_argument_expression_list_in_synp= red1171424) + self.following.append( + self.FOLLOW_argument_expression_list_in_synpred1171424) self.argument_expression_list() self.following.pop() if self.failed: @@ -17686,19 +16662,18 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred117 =20 - - # $ANTLR start synpred118 + def synpred118_fragment(self, ): # C.g:410:13: ( '(' macro_parameter_list ')' ) # C.g:410:13: '(' macro_parameter_list ')' self.match(self.input, 62, self.FOLLOW_62_in_synpred1181444) if self.failed: return - self.following.append(self.FOLLOW_macro_parameter_list_in_synpred1= 181446) + self.following.append( + self.FOLLOW_macro_parameter_list_in_synpred1181446) self.macro_parameter_list() self.following.pop() if self.failed: @@ -17707,84 +16682,77 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred118 =20 - - # $ANTLR start synpred120 + def synpred120_fragment(self, ): # C.g:412:13: ( '*' IDENTIFIER ) # C.g:412:13: '*' IDENTIFIER self.match(self.input, 66, self.FOLLOW_66_in_synpred1201482) if self.failed: return - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_in_synpr= ed1201486) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred1201486) if self.failed: return =20 - # $ANTLR end synpred120 =20 - - # $ANTLR start synpred137 + def synpred137_fragment(self, ): # C.g:443:20: ( STRING_LITERAL ) # C.g:443:20: STRING_LITERAL - self.match(self.input, STRING_LITERAL, self.FOLLOW_STRING_LITERAL_= in_synpred1371683) + self.match(self.input, STRING_LITERAL, + self.FOLLOW_STRING_LITERAL_in_synpred1371683) if self.failed: return =20 - # $ANTLR end synpred137 =20 - - # $ANTLR start synpred138 + def synpred138_fragment(self, ): # C.g:443:8: ( ( IDENTIFIER )* ( STRING_LITERAL )+ ) # C.g:443:8: ( IDENTIFIER )* ( STRING_LITERAL )+ # C.g:443:8: ( IDENTIFIER )* - while True: #loop125 + while True: # loop125 alt125 =3D 2 LA125_0 =3D self.input.LA(1) =20 - if (LA125_0 =3D=3D IDENTIFIER) : + if (LA125_0 =3D=3D IDENTIFIER): alt125 =3D 1 =20 - if alt125 =3D=3D 1: # C.g:0:0: IDENTIFIER - self.match(self.input, IDENTIFIER, self.FOLLOW_IDENTIFIER_= in_synpred1381680) + self.match(self.input, IDENTIFIER, + self.FOLLOW_IDENTIFIER_in_synpred1381680) if self.failed: return =20 - else: - break #loop125 - + break # loop125 =20 # C.g:443:20: ( STRING_LITERAL )+ cnt126 =3D 0 - while True: #loop126 + while True: # loop126 alt126 =3D 2 LA126_0 =3D self.input.LA(1) =20 - if (LA126_0 =3D=3D STRING_LITERAL) : + if (LA126_0 =3D=3D STRING_LITERAL): alt126 =3D 1 =20 - if alt126 =3D=3D 1: # C.g:0:0: STRING_LITERAL - self.match(self.input, STRING_LITERAL, self.FOLLOW_STRING_= LITERAL_in_synpred1381683) + self.match(self.input, STRING_LITERAL, + self.FOLLOW_STRING_LITERAL_in_synpred1381683) if self.failed: return =20 - else: if cnt126 >=3D 1: - break #loop126 + break # loop126 =20 if self.backtracking > 0: self.failed =3D True @@ -17795,14 +16763,10 @@ class CParser(Parser): =20 cnt126 +=3D 1 =20 - - - # $ANTLR end synpred138 =20 - - # $ANTLR start synpred142 + def synpred142_fragment(self, ): # C.g:458:4: ( lvalue assignment_operator assignment_expression ) # C.g:458:4: lvalue assignment_operator assignment_expression @@ -17811,38 +16775,37 @@ class CParser(Parser): self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_operator_in_synpred14= 21746) + self.following.append( + self.FOLLOW_assignment_operator_in_synpred1421746) self.assignment_operator() self.following.pop() if self.failed: return - self.following.append(self.FOLLOW_assignment_expression_in_synpred= 1421748) + self.following.append( + self.FOLLOW_assignment_expression_in_synpred1421748) self.assignment_expression() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred142 =20 - - # $ANTLR start synpred169 + def synpred169_fragment(self, ): # C.g:520:4: ( expression_statement ) # C.g:520:4: expression_statement - self.following.append(self.FOLLOW_expression_statement_in_synpred1= 692035) + self.following.append( + self.FOLLOW_expression_statement_in_synpred1692035) self.expression_statement() self.following.pop() if self.failed: return =20 - # $ANTLR end synpred169 =20 - - # $ANTLR start synpred173 + def synpred173_fragment(self, ): # C.g:524:4: ( macro_statement ) # C.g:524:4: macro_statement @@ -17852,12 +16815,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred173 =20 - - # $ANTLR start synpred174 + def synpred174_fragment(self, ): # C.g:525:4: ( asm2_statement ) # C.g:525:4: asm2_statement @@ -17867,12 +16828,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred174 =20 - - # $ANTLR start synpred181 + def synpred181_fragment(self, ): # C.g:544:19: ( declaration ) # C.g:544:19: declaration @@ -17882,12 +16841,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred181 =20 - - # $ANTLR start synpred182 + def synpred182_fragment(self, ): # C.g:544:33: ( statement_list ) # C.g:544:33: statement_list @@ -17897,12 +16854,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred182 =20 - - # $ANTLR start synpred186 + def synpred186_fragment(self, ): # C.g:554:8: ( declaration ) # C.g:554:8: declaration @@ -17912,12 +16867,10 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred186 =20 - - # $ANTLR start synpred188 + def synpred188_fragment(self, ): # C.g:558:4: ( statement ) # C.g:558:4: statement @@ -17927,11 +16880,8 @@ class CParser(Parser): if self.failed: return =20 - # $ANTLR end synpred188 =20 - - def synpred69(self): self.backtracking +=3D 1 start =3D self.input.mark() @@ -18382,35 +17332,42 @@ class CParser(Parser): self.failed =3D False return success =20 - - - - - FOLLOW_external_declaration_in_translation_unit74 =3D frozenset([1, 4,= 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_external_declaration_in_translation_unit74 =3D frozenset( + [1, 4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) FOLLOW_function_definition_in_external_declaration113 =3D frozenset([1= ]) FOLLOW_declaration_in_external_declaration118 =3D frozenset([1]) FOLLOW_macro_statement_in_external_declaration123 =3D frozenset([1, 25= ]) FOLLOW_25_in_external_declaration126 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_function_definition157 =3D frozenset(= [4, 58, 59, 60, 62, 66]) - FOLLOW_declarator_in_function_definition160 =3D frozenset([4, 26, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50,= 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_declaration_in_function_definition166 =3D frozenset([4, 26, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50= , 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_specifiers_in_function_definition157 =3D frozenset( + [4, 58, 59, 60, 62, 66]) + FOLLOW_declarator_in_function_definition160 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_in_function_definition166 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_compound_statement_in_function_definition171 =3D frozenset([1]) FOLLOW_compound_statement_in_function_definition180 =3D frozenset([1]) - FOLLOW_26_in_declaration203 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66]) - FOLLOW_declaration_specifiers_in_declaration207 =3D frozenset([4, 58, = 59, 60, 62, 66]) + FOLLOW_26_in_declaration203 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50= , 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_declaration_specifiers_in_declaration207 =3D frozenset( + [4, 58, 59, 60, 62, 66]) FOLLOW_init_declarator_list_in_declaration216 =3D frozenset([25]) FOLLOW_25_in_declaration220 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_declaration234 =3D frozenset([4, 25, = 58, 59, 60, 62, 66]) + FOLLOW_declaration_specifiers_in_declaration234 =3D frozenset( + [4, 25, 58, 59, 60, 62, 66]) FOLLOW_init_declarator_list_in_declaration238 =3D frozenset([25]) FOLLOW_25_in_declaration243 =3D frozenset([1]) - FOLLOW_storage_class_specifier_in_declaration_specifiers264 =3D frozen= set([1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, = 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_specifier_in_declaration_specifiers272 =3D frozenset([1, 4= , 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 5= 0, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_declaration_specifiers286 =3D frozenset([1, 4= , 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 5= 0, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_storage_class_specifier_in_declaration_specifiers264 =3D frozen= set( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_specifier_in_declaration_specifiers272 =3D frozenset( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_declaration_specifiers286 =3D frozenset( + [1, 4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_init_declarator_in_init_declarator_list308 =3D frozenset([1, 27= ]) FOLLOW_27_in_init_declarator_list311 =3D frozenset([4, 58, 59, 60, 62,= 66]) FOLLOW_init_declarator_in_init_declarator_list313 =3D frozenset([1, 27= ]) FOLLOW_declarator_in_init_declarator326 =3D frozenset([1, 28]) - FOLLOW_28_in_init_declarator329 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 4= 3, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_28_in_init_declarator329 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_in_init_declarator331 =3D frozenset([1]) FOLLOW_set_in_storage_class_specifier0 =3D frozenset([1]) FOLLOW_34_in_type_specifier376 =3D frozenset([1]) @@ -18428,25 +17385,34 @@ class CParser(Parser): FOLLOW_IDENTIFIER_in_type_id467 =3D frozenset([1]) FOLLOW_struct_or_union_in_struct_or_union_specifier494 =3D frozenset([= 4, 43]) FOLLOW_IDENTIFIER_in_struct_or_union_specifier496 =3D frozenset([43]) - FOLLOW_43_in_struct_or_union_specifier499 =3D frozenset([4, 34, 35, 36= , 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 5= 8, 59, 60, 61]) - FOLLOW_struct_declaration_list_in_struct_or_union_specifier501 =3D fro= zenset([44]) + FOLLOW_43_in_struct_or_union_specifier499 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_struct_declaration_list_in_struct_or_union_specifier501 =3D fro= zenset([ + = 44]) FOLLOW_44_in_struct_or_union_specifier503 =3D frozenset([1]) FOLLOW_struct_or_union_in_struct_or_union_specifier508 =3D frozenset([= 4]) FOLLOW_IDENTIFIER_in_struct_or_union_specifier510 =3D frozenset([1]) FOLLOW_set_in_struct_or_union0 =3D frozenset([1]) - FOLLOW_struct_declaration_in_struct_declaration_list537 =3D frozenset(= [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, = 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_specifier_qualifier_list_in_struct_declaration549 =3D frozenset= ([4, 47, 58, 59, 60, 62, 66]) + FOLLOW_struct_declaration_in_struct_declaration_list537 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_specifier_qualifier_list_in_struct_declaration549 =3D frozenset( + [4, 47, 58, 59, 60, 62, 66]) FOLLOW_struct_declarator_list_in_struct_declaration551 =3D frozenset([= 25]) FOLLOW_25_in_struct_declaration553 =3D frozenset([1]) - FOLLOW_type_qualifier_in_specifier_qualifier_list566 =3D frozenset([1,= 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_type_specifier_in_specifier_qualifier_list570 =3D frozenset([1,= 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_specifier_qualifier_list566 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_specifier_in_specifier_qualifier_list570 =3D frozenset( + [1, 4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51,= 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_struct_declarator_in_struct_declarator_list584 =3D frozenset([1= , 27]) - FOLLOW_27_in_struct_declarator_list587 =3D frozenset([4, 47, 58, 59, 6= 0, 62, 66]) + FOLLOW_27_in_struct_declarator_list587 =3D frozenset( + [4, 47, 58, 59, 60, 62, 66]) FOLLOW_struct_declarator_in_struct_declarator_list589 =3D frozenset([1= , 27]) FOLLOW_declarator_in_struct_declarator602 =3D frozenset([1, 47]) - FOLLOW_47_in_struct_declarator605 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_47_in_struct_declarator605 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_struct_declarator607 =3D frozenset([1]) - FOLLOW_47_in_struct_declarator614 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_47_in_struct_declarator614 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_struct_declarator616 =3D frozenset([1]) FOLLOW_48_in_enum_specifier634 =3D frozenset([43]) FOLLOW_43_in_enum_specifier636 =3D frozenset([4]) @@ -18465,7 +17431,8 @@ class CParser(Parser): FOLLOW_27_in_enumerator_list680 =3D frozenset([4]) FOLLOW_enumerator_in_enumerator_list682 =3D frozenset([1, 27]) FOLLOW_IDENTIFIER_in_enumerator695 =3D frozenset([1, 28]) - FOLLOW_28_in_enumerator698 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 66= , 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_28_in_enumerator698 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_enumerator700 =3D frozenset([1]) FOLLOW_set_in_type_qualifier0 =3D frozenset([1]) FOLLOW_pointer_in_declarator784 =3D frozenset([4, 58, 59, 60, 62]) @@ -18481,12 +17448,14 @@ class CParser(Parser): FOLLOW_declarator_in_direct_declarator834 =3D frozenset([63]) FOLLOW_63_in_direct_declarator836 =3D frozenset([62, 64]) FOLLOW_declarator_suffix_in_direct_declarator838 =3D frozenset([1, 62,= 64]) - FOLLOW_64_in_declarator_suffix852 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_64_in_declarator_suffix852 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_declarator_suffix854 =3D frozenset([65]) FOLLOW_65_in_declarator_suffix856 =3D frozenset([1]) FOLLOW_64_in_declarator_suffix866 =3D frozenset([65]) FOLLOW_65_in_declarator_suffix868 =3D frozenset([1]) - FOLLOW_62_in_declarator_suffix878 =3D frozenset([4, 29, 30, 31, 32, 33= , 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 5= 5, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_62_in_declarator_suffix878 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_type_list_in_declarator_suffix880 =3D frozenset([63]) FOLLOW_63_in_declarator_suffix882 =3D frozenset([1]) FOLLOW_62_in_declarator_suffix892 =3D frozenset([4]) @@ -18494,8 +17463,10 @@ class CParser(Parser): FOLLOW_63_in_declarator_suffix896 =3D frozenset([1]) FOLLOW_62_in_declarator_suffix906 =3D frozenset([63]) FOLLOW_63_in_declarator_suffix908 =3D frozenset([1]) - FOLLOW_66_in_pointer919 =3D frozenset([49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_pointer921 =3D frozenset([1, 49, 50, 51, 52, = 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_66_in_pointer919 =3D frozenset( + [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_pointer921 =3D frozenset( + [1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_pointer_in_pointer924 =3D frozenset([1]) FOLLOW_66_in_pointer930 =3D frozenset([66]) FOLLOW_pointer_in_pointer932 =3D frozenset([1]) @@ -18505,109 +17476,165 @@ class CParser(Parser): FOLLOW_53_in_parameter_type_list954 =3D frozenset([67]) FOLLOW_67_in_parameter_type_list958 =3D frozenset([1]) FOLLOW_parameter_declaration_in_parameter_list971 =3D frozenset([1, 27= ]) - FOLLOW_27_in_parameter_list974 =3D frozenset([4, 29, 30, 31, 32, 33, 3= 4, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, = 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_53_in_parameter_list977 =3D frozenset([4, 29, 30, 31, 32, 33, 3= 4, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, = 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_27_in_parameter_list974 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_53_in_parameter_list977 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_declaration_in_parameter_list981 =3D frozenset([1, 27= ]) - FOLLOW_declaration_specifiers_in_parameter_declaration994 =3D frozense= t([1, 4, 53, 58, 59, 60, 62, 64, 66]) - FOLLOW_declarator_in_parameter_declaration997 =3D frozenset([1, 4, 53,= 58, 59, 60, 62, 64, 66]) - FOLLOW_abstract_declarator_in_parameter_declaration999 =3D frozenset([= 1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declaration_specifiers_in_parameter_declaration994 =3D frozense= t( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declarator_in_parameter_declaration997 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_abstract_declarator_in_parameter_declaration999 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) FOLLOW_53_in_parameter_declaration1004 =3D frozenset([1]) FOLLOW_pointer_in_parameter_declaration1013 =3D frozenset([4, 66]) FOLLOW_IDENTIFIER_in_parameter_declaration1016 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_identifier_list1027 =3D frozenset([1, 27]) FOLLOW_27_in_identifier_list1031 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_identifier_list1033 =3D frozenset([1, 27]) - FOLLOW_specifier_qualifier_list_in_type_name1046 =3D frozenset([1, 62,= 64, 66]) + FOLLOW_specifier_qualifier_list_in_type_name1046 =3D frozenset([ + 1, 62, 64= , 66]) FOLLOW_abstract_declarator_in_type_name1048 =3D frozenset([1]) FOLLOW_type_id_in_type_name1054 =3D frozenset([1]) FOLLOW_pointer_in_abstract_declarator1065 =3D frozenset([1, 62, 64]) - FOLLOW_direct_abstract_declarator_in_abstract_declarator1067 =3D froze= nset([1]) - FOLLOW_direct_abstract_declarator_in_abstract_declarator1073 =3D froze= nset([1]) + FOLLOW_direct_abstract_declarator_in_abstract_declarator1067 =3D froze= nset([ + = 1]) + FOLLOW_direct_abstract_declarator_in_abstract_declarator1073 =3D froze= nset([ + = 1]) FOLLOW_62_in_direct_abstract_declarator1086 =3D frozenset([62, 64, 66]) - FOLLOW_abstract_declarator_in_direct_abstract_declarator1088 =3D froze= nset([63]) + FOLLOW_abstract_declarator_in_direct_abstract_declarator1088 =3D froze= nset([ + = 63]) FOLLOW_63_in_direct_abstract_declarator1090 =3D frozenset([1, 62, 64]) - FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1094 = =3D frozenset([1, 62, 64]) - FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1098 = =3D frozenset([1, 62, 64]) + FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1094 = =3D frozenset([ + = 1, 62, 64]) + FOLLOW_abstract_declarator_suffix_in_direct_abstract_declarator1098 = =3D frozenset([ + = 1, 62, 64]) FOLLOW_64_in_abstract_declarator_suffix1110 =3D frozenset([65]) FOLLOW_65_in_abstract_declarator_suffix1112 =3D frozenset([1]) - FOLLOW_64_in_abstract_declarator_suffix1117 =3D frozenset([4, 5, 6, 7,= 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_constant_expression_in_abstract_declarator_suffix1119 =3D froze= nset([65]) + FOLLOW_64_in_abstract_declarator_suffix1117 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_constant_expression_in_abstract_declarator_suffix1119 =3D froze= nset([ + = 65]) FOLLOW_65_in_abstract_declarator_suffix1121 =3D frozenset([1]) FOLLOW_62_in_abstract_declarator_suffix1126 =3D frozenset([63]) FOLLOW_63_in_abstract_declarator_suffix1128 =3D frozenset([1]) - FOLLOW_62_in_abstract_declarator_suffix1133 =3D frozenset([4, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52,= 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_parameter_type_list_in_abstract_declarator_suffix1135 =3D froze= nset([63]) + FOLLOW_62_in_abstract_declarator_suffix1133 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_parameter_type_list_in_abstract_declarator_suffix1135 =3D froze= nset([ + = 63]) FOLLOW_63_in_abstract_declarator_suffix1137 =3D frozenset([1]) FOLLOW_assignment_expression_in_initializer1150 =3D frozenset([1]) - FOLLOW_43_in_initializer1155 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 43, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_43_in_initializer1155 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_list_in_initializer1157 =3D frozenset([27, 44]) FOLLOW_27_in_initializer1159 =3D frozenset([44]) FOLLOW_44_in_initializer1162 =3D frozenset([1]) FOLLOW_initializer_in_initializer_list1173 =3D frozenset([1, 27]) - FOLLOW_27_in_initializer_list1176 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_27_in_initializer_list1176 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 43, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_initializer_in_initializer_list1178 =3D frozenset([1, 27]) - FOLLOW_assignment_expression_in_argument_expression_list1196 =3D froze= nset([1, 27, 53]) + FOLLOW_assignment_expression_in_argument_expression_list1196 =3D froze= nset([ + = 1, 27, 53]) FOLLOW_53_in_argument_expression_list1199 =3D frozenset([1, 27]) - FOLLOW_27_in_argument_expression_list1204 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_assignment_expression_in_argument_expression_list1206 =3D froze= nset([1, 27, 53]) + FOLLOW_27_in_argument_expression_list1204 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_assignment_expression_in_argument_expression_list1206 =3D froze= nset([ + = 1, 27, 53]) FOLLOW_53_in_argument_expression_list1209 =3D frozenset([1, 27]) - FOLLOW_multiplicative_expression_in_additive_expression1225 =3D frozen= set([1, 68, 69]) - FOLLOW_68_in_additive_expression1229 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_multiplicative_expression_in_additive_expression1231 =3D frozen= set([1, 68, 69]) - FOLLOW_69_in_additive_expression1235 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_multiplicative_expression_in_additive_expression1237 =3D frozen= set([1, 68, 69]) - FOLLOW_cast_expression_in_multiplicative_expression1251 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_66_in_multiplicative_expression1255 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1257 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_70_in_multiplicative_expression1261 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1263 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_71_in_multiplicative_expression1267 =3D frozenset([4, 5, 6, 7, = 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_cast_expression_in_multiplicative_expression1269 =3D frozenset(= [1, 66, 70, 71]) - FOLLOW_62_in_cast_expression1282 =3D frozenset([4, 34, 35, 36, 37, 38,= 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60= , 61]) + FOLLOW_multiplicative_expression_in_additive_expression1225 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_68_in_additive_expression1229 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_multiplicative_expression_in_additive_expression1231 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_69_in_additive_expression1235 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_multiplicative_expression_in_additive_expression1237 =3D frozen= set([ + = 1, 68, 69]) + FOLLOW_cast_expression_in_multiplicative_expression1251 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_66_in_multiplicative_expression1255 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1257 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_70_in_multiplicative_expression1261 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1263 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_71_in_multiplicative_expression1267 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_cast_expression_in_multiplicative_expression1269 =3D frozenset([ + 1,= 66, 70, 71]) + FOLLOW_62_in_cast_expression1282 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_cast_expression1284 =3D frozenset([63]) - FOLLOW_63_in_cast_expression1286 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_cast_expression1286 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_cast_expression1288 =3D frozenset([1]) FOLLOW_unary_expression_in_cast_expression1293 =3D frozenset([1]) FOLLOW_postfix_expression_in_unary_expression1304 =3D frozenset([1]) - FOLLOW_72_in_unary_expression1309 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_72_in_unary_expression1309 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1311 =3D frozenset([1]) - FOLLOW_73_in_unary_expression1316 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_73_in_unary_expression1316 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1318 =3D frozenset([1]) - FOLLOW_unary_operator_in_unary_expression1323 =3D frozenset([4, 5, 6, = 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_unary_operator_in_unary_expression1323 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_unary_expression1325 =3D frozenset([1]) - FOLLOW_74_in_unary_expression1330 =3D frozenset([4, 5, 6, 7, 8, 9, 10,= 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_74_in_unary_expression1330 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_unary_expression1332 =3D frozenset([1]) FOLLOW_74_in_unary_expression1337 =3D frozenset([62]) - FOLLOW_62_in_unary_expression1339 =3D frozenset([4, 34, 35, 36, 37, 38= , 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6= 0, 61]) + FOLLOW_62_in_unary_expression1339 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_unary_expression1341 =3D frozenset([63]) FOLLOW_63_in_unary_expression1343 =3D frozenset([1]) - FOLLOW_primary_expression_in_postfix_expression1367 =3D frozenset([1, = 62, 64, 66, 72, 73, 75, 76]) - FOLLOW_64_in_postfix_expression1383 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_primary_expression_in_postfix_expression1367 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_64_in_postfix_expression1383 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_postfix_expression1385 =3D frozenset([65]) - FOLLOW_65_in_postfix_expression1387 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) + FOLLOW_65_in_postfix_expression1387 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_62_in_postfix_expression1401 =3D frozenset([63]) - FOLLOW_63_in_postfix_expression1405 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_62_in_postfix_expression1420 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_postfix_expression1405 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_62_in_postfix_expression1420 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_argument_expression_list_in_postfix_expression1424 =3D frozense= t([63]) - FOLLOW_63_in_postfix_expression1428 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_62_in_postfix_expression1444 =3D frozenset([4, 29, 30, 31, 32, = 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_63_in_postfix_expression1428 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_62_in_postfix_expression1444 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_macro_parameter_list_in_postfix_expression1446 =3D frozenset([6= 3]) - FOLLOW_63_in_postfix_expression1448 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) + FOLLOW_63_in_postfix_expression1448 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_75_in_postfix_expression1462 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1466 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) + FOLLOW_IDENTIFIER_in_postfix_expression1466 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_66_in_postfix_expression1482 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1486 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) + FOLLOW_IDENTIFIER_in_postfix_expression1486 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) FOLLOW_76_in_postfix_expression1502 =3D frozenset([4]) - FOLLOW_IDENTIFIER_in_postfix_expression1506 =3D frozenset([1, 62, 64, = 66, 72, 73, 75, 76]) - FOLLOW_72_in_postfix_expression1522 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_73_in_postfix_expression1536 =3D frozenset([1, 62, 64, 66, 72, = 73, 75, 76]) - FOLLOW_parameter_declaration_in_macro_parameter_list1559 =3D frozenset= ([1, 27]) - FOLLOW_27_in_macro_parameter_list1562 =3D frozenset([4, 29, 30, 31, 32= , 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 5= 4, 55, 56, 57, 58, 59, 60, 61, 66]) - FOLLOW_parameter_declaration_in_macro_parameter_list1564 =3D frozenset= ([1, 27]) + FOLLOW_IDENTIFIER_in_postfix_expression1506 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_72_in_postfix_expression1522 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_73_in_postfix_expression1536 =3D frozenset( + [1, 62, 64, 66, 72, 73, 75, 76]) + FOLLOW_parameter_declaration_in_macro_parameter_list1559 =3D frozenset= ([ + 1= , 27]) + FOLLOW_27_in_macro_parameter_list1562 =3D frozenset( + [4, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46= , 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_parameter_declaration_in_macro_parameter_list1564 =3D frozenset= ([ + 1= , 27]) FOLLOW_set_in_unary_operator0 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_primary_expression1613 =3D frozenset([1]) FOLLOW_constant_in_primary_expression1618 =3D frozenset([1]) - FOLLOW_62_in_primary_expression1623 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_primary_expression1623 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_primary_expression1625 =3D frozenset([63]) FOLLOW_63_in_primary_expression1627 =3D frozenset([1]) FOLLOW_HEX_LITERAL_in_constant1643 =3D frozenset([1]) @@ -18619,44 +17646,71 @@ class CParser(Parser): FOLLOW_IDENTIFIER_in_constant1688 =3D frozenset([1, 4]) FOLLOW_FLOATING_POINT_LITERAL_in_constant1699 =3D frozenset([1]) FOLLOW_assignment_expression_in_expression1715 =3D frozenset([1, 27]) - FOLLOW_27_in_expression1718 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_27_in_expression1718 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_expression1720 =3D frozenset([1, 27]) FOLLOW_conditional_expression_in_constant_expression1733 =3D frozenset= ([1]) - FOLLOW_lvalue_in_assignment_expression1744 =3D frozenset([28, 80, 81, = 82, 83, 84, 85, 86, 87, 88, 89]) - FOLLOW_assignment_operator_in_assignment_expression1746 =3D frozenset(= [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_lvalue_in_assignment_expression1744 =3D frozenset( + [28, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]) + FOLLOW_assignment_operator_in_assignment_expression1746 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_assignment_expression1748 =3D frozense= t([1]) FOLLOW_conditional_expression_in_assignment_expression1753 =3D frozens= et([1]) FOLLOW_unary_expression_in_lvalue1765 =3D frozenset([1]) FOLLOW_set_in_assignment_operator0 =3D frozenset([1]) - FOLLOW_logical_or_expression_in_conditional_expression1839 =3D frozens= et([1, 90]) - FOLLOW_90_in_conditional_expression1842 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_logical_or_expression_in_conditional_expression1839 =3D frozens= et([ + = 1, 90]) + FOLLOW_90_in_conditional_expression1842 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_conditional_expression1844 =3D frozenset([47]) - FOLLOW_47_in_conditional_expression1846 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_conditional_expression_in_conditional_expression1848 =3D frozen= set([1]) - FOLLOW_logical_and_expression_in_logical_or_expression1863 =3D frozens= et([1, 91]) - FOLLOW_91_in_logical_or_expression1866 =3D frozenset([4, 5, 6, 7, 8, 9= , 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_logical_and_expression_in_logical_or_expression1868 =3D frozens= et([1, 91]) - FOLLOW_inclusive_or_expression_in_logical_and_expression1881 =3D froze= nset([1, 92]) - FOLLOW_92_in_logical_and_expression1884 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_inclusive_or_expression_in_logical_and_expression1886 =3D froze= nset([1, 92]) - FOLLOW_exclusive_or_expression_in_inclusive_or_expression1899 =3D froz= enset([1, 93]) - FOLLOW_93_in_inclusive_or_expression1902 =3D frozenset([4, 5, 6, 7, 8,= 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_exclusive_or_expression_in_inclusive_or_expression1904 =3D froz= enset([1, 93]) + FOLLOW_47_in_conditional_expression1846 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_conditional_expression_in_conditional_expression1848 =3D frozen= set([ + = 1]) + FOLLOW_logical_and_expression_in_logical_or_expression1863 =3D frozens= et([ + = 1, 91]) + FOLLOW_91_in_logical_or_expression1866 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_logical_and_expression_in_logical_or_expression1868 =3D frozens= et([ + = 1, 91]) + FOLLOW_inclusive_or_expression_in_logical_and_expression1881 =3D froze= nset([ + = 1, 92]) + FOLLOW_92_in_logical_and_expression1884 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_inclusive_or_expression_in_logical_and_expression1886 =3D froze= nset([ + = 1, 92]) + FOLLOW_exclusive_or_expression_in_inclusive_or_expression1899 =3D froz= enset([ + = 1, 93]) + FOLLOW_93_in_inclusive_or_expression1902 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_exclusive_or_expression_in_inclusive_or_expression1904 =3D froz= enset([ + = 1, 93]) FOLLOW_and_expression_in_exclusive_or_expression1917 =3D frozenset([1,= 94]) - FOLLOW_94_in_exclusive_or_expression1920 =3D frozenset([4, 5, 6, 7, 8,= 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_94_in_exclusive_or_expression1920 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_and_expression_in_exclusive_or_expression1922 =3D frozenset([1,= 94]) FOLLOW_equality_expression_in_and_expression1935 =3D frozenset([1, 77]) - FOLLOW_77_in_and_expression1938 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 6= 2, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_77_in_and_expression1938 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_equality_expression_in_and_expression1940 =3D frozenset([1, 77]) - FOLLOW_relational_expression_in_equality_expression1952 =3D frozenset(= [1, 95, 96]) - FOLLOW_set_in_equality_expression1955 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_relational_expression_in_equality_expression1961 =3D frozenset(= [1, 95, 96]) - FOLLOW_shift_expression_in_relational_expression1975 =3D frozenset([1,= 97, 98, 99, 100]) - FOLLOW_set_in_relational_expression1978 =3D frozenset([4, 5, 6, 7, 8, = 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_shift_expression_in_relational_expression1988 =3D frozenset([1,= 97, 98, 99, 100]) - FOLLOW_additive_expression_in_shift_expression2001 =3D frozenset([1, 1= 01, 102]) - FOLLOW_set_in_shift_expression2004 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_additive_expression_in_shift_expression2010 =3D frozenset([1, 1= 01, 102]) + FOLLOW_relational_expression_in_equality_expression1952 =3D frozenset([ + 1,= 95, 96]) + FOLLOW_set_in_equality_expression1955 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_relational_expression_in_equality_expression1961 =3D frozenset([ + 1,= 95, 96]) + FOLLOW_shift_expression_in_relational_expression1975 =3D frozenset([ + 1, 97= , 98, 99, 100]) + FOLLOW_set_in_relational_expression1978 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_shift_expression_in_relational_expression1988 =3D frozenset([ + 1, 97= , 98, 99, 100]) + FOLLOW_additive_expression_in_shift_expression2001 =3D frozenset([ + 1, 101,= 102]) + FOLLOW_set_in_shift_expression2004 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_additive_expression_in_shift_expression2010 =3D frozenset([ + 1, 101,= 102]) FOLLOW_labeled_statement_in_statement2025 =3D frozenset([1]) FOLLOW_compound_statement_in_statement2030 =3D frozenset([1]) FOLLOW_expression_statement_in_statement2035 =3D frozenset([1]) @@ -18670,72 +17724,101 @@ class CParser(Parser): FOLLOW_declaration_in_statement2075 =3D frozenset([1]) FOLLOW_103_in_asm2_statement2086 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_asm2_statement2089 =3D frozenset([62]) - FOLLOW_62_in_asm2_statement2091 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,= 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68= , 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 8= 7, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,= 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm2_statement2094 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30,= 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 6= 8, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, = 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104= , 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_62_in_asm2_statement2091 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, = 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,= 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) + FOLLOW_set_in_asm2_statement2094 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30,= 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 6= 5, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, = 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 1= 02, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 1= 17]) FOLLOW_63_in_asm2_statement2101 =3D frozenset([25]) FOLLOW_25_in_asm2_statement2103 =3D frozenset([1]) FOLLOW_104_in_asm1_statement2115 =3D frozenset([43]) - FOLLOW_43_in_asm1_statement2117 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67= , 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 8= 6, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, = 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm1_statement2120 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48= , 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 6= 7, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, = 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,= 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_asm1_statement2117 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) + FOLLOW_set_in_asm1_statement2120 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,= 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48= , 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 6= 5, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, = 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 1= 02, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 1= 17]) FOLLOW_44_in_asm1_statement2127 =3D frozenset([1]) FOLLOW_105_in_asm_statement2138 =3D frozenset([43]) - FOLLOW_43_in_asm_statement2140 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 11= , 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3= 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, = 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,= 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86= , 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 1= 04, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) - FOLLOW_set_in_asm_statement2143 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67= , 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 8= 6, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, = 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_asm_statement2140 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 11= , 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3= 0, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, = 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65,= 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84= , 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102= , 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117= ]) + FOLLOW_set_in_asm_statement2143 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 1= 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, = 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,= 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65= , 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 8= 4, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 10= 2, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 11= 7]) FOLLOW_44_in_asm_statement2150 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_macro_statement2162 =3D frozenset([62]) - FOLLOW_62_in_macro_statement2164 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46,= 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) - FOLLOW_declaration_in_macro_statement2166 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, = 112, 113, 114, 115, 116, 117]) - FOLLOW_statement_list_in_macro_statement2170 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_macro_statement2164 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46,= 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 5= 8, 59, 60, 61, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 1= 06, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_declaration_in_macro_statement2166 =3D frozenset([4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, + 50, 51, 52, 53, = 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79,= 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_statement_list_in_macro_statement2170 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_macro_statement2173 =3D frozenset([63]) FOLLOW_63_in_macro_statement2176 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_labeled_statement2188 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2190 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2190 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2192 =3D frozenset([1]) - FOLLOW_106_in_labeled_statement2197 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_106_in_labeled_statement2197 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_constant_expression_in_labeled_statement2199 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2201 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2201 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2203 =3D frozenset([1]) FOLLOW_107_in_labeled_statement2208 =3D frozenset([47]) - FOLLOW_47_in_labeled_statement2210 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, = 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 1= 14, 115, 116, 117]) + FOLLOW_47_in_labeled_statement2210 =3D frozenset([4, 5, 6, 7, 8, 9, 10= , 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 4= 6, 48, 49, 50, + 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105,= 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_labeled_statement2212 =3D frozenset([1]) - FOLLOW_43_in_compound_statement2223 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, = 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68,= 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 1= 13, 114, 115, 116, 117]) - FOLLOW_declaration_in_compound_statement2225 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62= , 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 11= 1, 112, 113, 114, 115, 116, 117]) + FOLLOW_43_in_compound_statement2223 =3D frozenset([4, 5, 6, 7, 8, 9, 1= 0, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, = 45, 46, 48, 49, + 50, 51, 52, 53, 54, 55= , 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104,= 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) + FOLLOW_declaration_in_compound_statement2225 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,= 43, 44, 45, 46, 48, + 49, 50, 51, 5= 2, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, = 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_list_in_compound_statement2228 =3D frozenset([44]) FOLLOW_44_in_compound_statement2231 =3D frozenset([1]) - FOLLOW_statement_in_statement_list2242 =3D frozenset([1, 4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 6= 8, 69, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112,= 113, 114, 115, 116, 117]) + FOLLOW_statement_in_statement_list2242 =3D frozenset([1, 4, 5, 6, 7, 8= , 9, 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, + 50, 51, 52, 53, 54,= 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 1= 04, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_25_in_expression_statement2254 =3D frozenset([1]) FOLLOW_expression_in_expression_statement2259 =3D frozenset([25]) FOLLOW_25_in_expression_statement2261 =3D frozenset([1]) FOLLOW_108_in_selection_statement2272 =3D frozenset([62]) - FOLLOW_62_in_selection_statement2274 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_selection_statement2274 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_selection_statement2278 =3D frozenset([63]) - FOLLOW_63_in_selection_statement2280 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_selection_statement2280 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2284 =3D frozenset([1, 109]) - FOLLOW_109_in_selection_statement2299 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 6= 9, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113= , 114, 115, 116, 117]) + FOLLOW_109_in_selection_statement2299 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, + 50, 51, 52, 53, 54, = 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 10= 4, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2301 =3D frozenset([1]) FOLLOW_110_in_selection_statement2308 =3D frozenset([62]) - FOLLOW_62_in_selection_statement2310 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_selection_statement2310 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_selection_statement2312 =3D frozenset([63]) - FOLLOW_63_in_selection_statement2314 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_selection_statement2314 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_selection_statement2316 =3D frozenset([1]) FOLLOW_111_in_iteration_statement2327 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2329 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2329 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2333 =3D frozenset([63]) - FOLLOW_63_in_iteration_statement2335 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_iteration_statement2335 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2337 =3D frozenset([1]) - FOLLOW_112_in_iteration_statement2344 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 6= 9, 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113= , 114, 115, 116, 117]) + FOLLOW_112_in_iteration_statement2344 =3D frozenset([4, 5, 6, 7, 8, 9,= 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45= , 46, 48, 49, + 50, 51, 52, 53, 54, = 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 10= 4, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2346 =3D frozenset([111]) FOLLOW_111_in_iteration_statement2348 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2350 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2350 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2354 =3D frozenset([63]) FOLLOW_63_in_iteration_statement2356 =3D frozenset([25]) FOLLOW_25_in_iteration_statement2358 =3D frozenset([1]) FOLLOW_113_in_iteration_statement2365 =3D frozenset([62]) - FOLLOW_62_in_iteration_statement2367 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_expression_statement_in_iteration_statement2369 =3D frozenset([= 4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) - FOLLOW_expression_statement_in_iteration_statement2373 =3D frozenset([= 4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_iteration_statement2367 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_expression_statement_in_iteration_statement2369 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 25, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_expression_statement_in_iteration_statement2373 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 63, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_iteration_statement2375 =3D frozenset([63]) - FOLLOW_63_in_iteration_statement2378 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66, 68, 69= , 72, 73, 74, 77, 78, 79, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113,= 114, 115, 116, 117]) + FOLLOW_63_in_iteration_statement2378 =3D frozenset([4, 5, 6, 7, 8, 9, = 10, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45,= 46, 48, 49, 50, + 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79, 103, 104, 10= 5, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117]) FOLLOW_statement_in_iteration_statement2380 =3D frozenset([1]) FOLLOW_114_in_jump_statement2393 =3D frozenset([4]) FOLLOW_IDENTIFIER_in_jump_statement2395 =3D frozenset([25]) @@ -18746,13 +17829,17 @@ class CParser(Parser): FOLLOW_25_in_jump_statement2411 =3D frozenset([1]) FOLLOW_117_in_jump_statement2416 =3D frozenset([25]) FOLLOW_25_in_jump_statement2418 =3D frozenset([1]) - FOLLOW_117_in_jump_statement2423 =3D frozenset([4, 5, 6, 7, 8, 9, 10, = 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_117_in_jump_statement2423 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_expression_in_jump_statement2425 =3D frozenset([25]) FOLLOW_25_in_jump_statement2427 =3D frozenset([1]) FOLLOW_declaration_specifiers_in_synpred2100 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_synpred4100 =3D frozenset([4, 58, 59,= 60, 62, 66]) - FOLLOW_declarator_in_synpred4103 =3D frozenset([4, 26, 29, 30, 31, 32,= 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50, 51, 52, 53= , 54, 55, 56, 57, 58, 59, 60, 61]) - FOLLOW_declaration_in_synpred4105 =3D frozenset([4, 26, 29, 30, 31, 32= , 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 48, 49, 50, 51, 52, 5= 3, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_specifiers_in_synpred4100 =3D frozenset( + [4, 58, 59, 60, 62, 66]) + FOLLOW_declarator_in_synpred4103 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_declaration_in_synpred4105 =3D frozenset( + [4, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43= , 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_43_in_synpred4108 =3D frozenset([1]) FOLLOW_declaration_in_synpred5118 =3D frozenset([1]) FOLLOW_declaration_specifiers_in_synpred7157 =3D frozenset([1]) @@ -18760,8 +17847,10 @@ class CParser(Parser): FOLLOW_type_specifier_in_synpred14272 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred15286 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred33444 =3D frozenset([1]) - FOLLOW_IDENTIFIER_in_synpred34442 =3D frozenset([4, 49, 50, 51, 52, 53= , 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) - FOLLOW_type_qualifier_in_synpred34444 =3D frozenset([4, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_IDENTIFIER_in_synpred34442 =3D frozenset( + [4, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) + FOLLOW_type_qualifier_in_synpred34444 =3D frozenset( + [4, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 66]) FOLLOW_declarator_in_synpred34447 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred39566 =3D frozenset([1]) FOLLOW_type_specifier_in_synpred40570 =3D frozenset([1]) @@ -18773,7 +17862,8 @@ class CParser(Parser): FOLLOW_declarator_suffix_in_synpred67821 =3D frozenset([1]) FOLLOW_58_in_synpred69830 =3D frozenset([1]) FOLLOW_declarator_suffix_in_synpred70838 =3D frozenset([1]) - FOLLOW_62_in_synpred73878 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) + FOLLOW_62_in_synpred73878 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_type_list_in_synpred73880 =3D frozenset([63]) FOLLOW_63_in_synpred73882 =3D frozenset([1]) FOLLOW_62_in_synpred74892 =3D frozenset([4]) @@ -18781,38 +17871,51 @@ class CParser(Parser): FOLLOW_63_in_synpred74896 =3D frozenset([1]) FOLLOW_type_qualifier_in_synpred75921 =3D frozenset([1]) FOLLOW_pointer_in_synpred76924 =3D frozenset([1]) - FOLLOW_66_in_synpred77919 =3D frozenset([49, 50, 51, 52, 53, 54, 55, 5= 6, 57, 58, 59, 60, 61]) - FOLLOW_type_qualifier_in_synpred77921 =3D frozenset([1, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_66_in_synpred77919 =3D frozenset( + [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_type_qualifier_in_synpred77921 =3D frozenset( + [1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_pointer_in_synpred77924 =3D frozenset([1]) FOLLOW_66_in_synpred78930 =3D frozenset([66]) FOLLOW_pointer_in_synpred78932 =3D frozenset([1]) FOLLOW_53_in_synpred81977 =3D frozenset([1]) - FOLLOW_27_in_synpred82974 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) - FOLLOW_53_in_synpred82977 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 5= 7, 58, 59, 60, 61, 66]) + FOLLOW_27_in_synpred82974 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) + FOLLOW_53_in_synpred82977 =3D frozenset([4, 29, 30, 31, 32, 33, 34, 35= , 36, 37, 38, 39, + 40, 41, 42, 45, 46, 48, 49, 50, = 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_parameter_declaration_in_synpred82981 =3D frozenset([1]) FOLLOW_declarator_in_synpred83997 =3D frozenset([1]) FOLLOW_abstract_declarator_in_synpred84999 =3D frozenset([1]) - FOLLOW_declaration_specifiers_in_synpred86994 =3D frozenset([1, 4, 53,= 58, 59, 60, 62, 64, 66]) - FOLLOW_declarator_in_synpred86997 =3D frozenset([1, 4, 53, 58, 59, 60,= 62, 64, 66]) - FOLLOW_abstract_declarator_in_synpred86999 =3D frozenset([1, 4, 53, 58= , 59, 60, 62, 64, 66]) + FOLLOW_declaration_specifiers_in_synpred86994 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_declarator_in_synpred86997 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) + FOLLOW_abstract_declarator_in_synpred86999 =3D frozenset( + [1, 4, 53, 58, 59, 60, 62, 64, 66]) FOLLOW_53_in_synpred861004 =3D frozenset([1]) - FOLLOW_specifier_qualifier_list_in_synpred901046 =3D frozenset([1, 62,= 64, 66]) + FOLLOW_specifier_qualifier_list_in_synpred901046 =3D frozenset([ + 1, 62, 64= , 66]) FOLLOW_abstract_declarator_in_synpred901048 =3D frozenset([1]) FOLLOW_direct_abstract_declarator_in_synpred911067 =3D frozenset([1]) FOLLOW_62_in_synpred931086 =3D frozenset([62, 64, 66]) FOLLOW_abstract_declarator_in_synpred931088 =3D frozenset([63]) FOLLOW_63_in_synpred931090 =3D frozenset([1]) FOLLOW_abstract_declarator_suffix_in_synpred941098 =3D frozenset([1]) - FOLLOW_62_in_synpred1091282 =3D frozenset([4, 34, 35, 36, 37, 38, 39, = 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61]) + FOLLOW_62_in_synpred1091282 =3D frozenset( + [4, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52= , 53, 54, 55, 56, 57, 58, 59, 60, 61]) FOLLOW_type_name_in_synpred1091284 =3D frozenset([63]) - FOLLOW_63_in_synpred1091286 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_63_in_synpred1091286 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_cast_expression_in_synpred1091288 =3D frozenset([1]) - FOLLOW_74_in_synpred1141330 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_74_in_synpred1141330 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_unary_expression_in_synpred1141332 =3D frozenset([1]) - FOLLOW_62_in_synpred1171420 =3D frozenset([4, 5, 6, 7, 8, 9, 10, 62, 6= 6, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_62_in_synpred1171420 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_argument_expression_list_in_synpred1171424 =3D frozenset([63]) FOLLOW_63_in_synpred1171428 =3D frozenset([1]) - FOLLOW_62_in_synpred1181444 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56,= 57, 58, 59, 60, 61, 66]) + FOLLOW_62_in_synpred1181444 =3D frozenset([4, 29, 30, 31, 32, 33, 34, = 35, 36, 37, 38, + 39, 40, 41, 42, 45, 46, 48, 49= , 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 66]) FOLLOW_macro_parameter_list_in_synpred1181446 =3D frozenset([63]) FOLLOW_63_in_synpred1181448 =3D frozenset([1]) FOLLOW_66_in_synpred1201482 =3D frozenset([4]) @@ -18820,8 +17923,10 @@ class CParser(Parser): FOLLOW_STRING_LITERAL_in_synpred1371683 =3D frozenset([1]) FOLLOW_IDENTIFIER_in_synpred1381680 =3D frozenset([4, 9]) FOLLOW_STRING_LITERAL_in_synpred1381683 =3D frozenset([1, 9]) - FOLLOW_lvalue_in_synpred1421744 =3D frozenset([28, 80, 81, 82, 83, 84,= 85, 86, 87, 88, 89]) - FOLLOW_assignment_operator_in_synpred1421746 =3D frozenset([4, 5, 6, 7= , 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) + FOLLOW_lvalue_in_synpred1421744 =3D frozenset( + [28, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]) + FOLLOW_assignment_operator_in_synpred1421746 =3D frozenset( + [4, 5, 6, 7, 8, 9, 10, 62, 66, 68, 69, 72, 73, 74, 77, 78, 79]) FOLLOW_assignment_expression_in_synpred1421748 =3D frozenset([1]) FOLLOW_expression_statement_in_synpred1692035 =3D frozenset([1]) FOLLOW_macro_statement_in_synpred1732055 =3D frozenset([1]) @@ -18830,4 +17935,3 @@ class CParser(Parser): FOLLOW_statement_list_in_synpred1822170 =3D frozenset([1]) FOLLOW_declaration_in_synpred1862225 =3D frozenset([1]) FOLLOW_statement_in_synpred1882242 =3D frozenset([1]) - diff --git a/BaseTools/Source/Python/Eot/CParser4/CLexer.py b/BaseTools/Sou= rce/Python/Eot/CParser4/CLexer.py index 54374fd6e82d..739152edf0f5 100644 --- a/BaseTools/Source/Python/Eot/CParser4/CLexer.py +++ b/BaseTools/Source/Python/Eot/CParser4/CLexer.py @@ -5,7 +5,7 @@ from typing.io import TextIO import sys =20 =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -424,7 +424,7 @@ class CLexer(Lexer): =20 atn =3D ATNDeserializer().deserialize(serializedATN()) =20 - decisionsToDFA =3D [ DFA(ds, i) for i, ds in enumerate(atn.decisionToS= tate) ] + decisionsToDFA =3D [DFA(ds, i) for i, ds in enumerate(atn.decisionToSt= ate)] =20 T__0 =3D 1 T__1 =3D 2 @@ -532,96 +532,99 @@ class CLexer(Lexer): LINE_COMMENT =3D 104 LINE_COMMAND =3D 105 =20 - channelNames =3D [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] + channelNames =3D [u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN"] =20 - modeNames =3D [ "DEFAULT_MODE" ] + modeNames =3D ["DEFAULT_MODE"] =20 - literalNames =3D [ "", - "'{'", "';'", "'typedef'", "','", "'=3D'", "'extern'", "'stati= c'", - "'auto'", "'register'", "'STATIC'", "'void'", "'char'", "'shor= t'", - "'int'", "'long'", "'float'", "'double'", "'signed'", "'unsign= ed'", - "'}'", "'struct'", "'union'", "':'", "'enum'", "'const'", "'vo= latile'", - "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'", "'VOL= ATILE'", - "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFIAPI'", "'EFI_BOOTSERVI= CE'", - "'EFI_RUNTIMESERVICE'", "'PACKED'", "'('", "')'", "'['", "']'", - "'*'", "'...'", "'+'", "'-'", "'/'", "'%'", "'++'", "'--'", - "'sizeof'", "'.'", "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/= =3D'", - "'%=3D'", "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", = "'^=3D'", "'|=3D'", - "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!=3D'", "'<= '", - "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__asm__'", "'_asm= '", - "'__asm'", "'case'", "'default'", "'if'", "'else'", "'switch'", - "'while'", "'do'", "'goto'", "'continue'", "'break'", "'return= '" ] + literalNames =3D ["", + "'{'", "';'", "'typedef'", "','", "'=3D'", "'extern'",= "'static'", + "'auto'", "'register'", "'STATIC'", "'void'", "'char'"= , "'short'", + "'int'", "'long'", "'float'", "'double'", "'signed'", = "'unsigned'", + "'}'", "'struct'", "'union'", "':'", "'enum'", "'const= '", "'volatile'", + "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'= ", "'VOLATILE'", + "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFIAPI'", "'EFI_B= OOTSERVICE'", + "'EFI_RUNTIMESERVICE'", "'PACKED'", "'('", "')'", "'['= ", "']'", + "'*'", "'...'", "'+'", "'-'", "'/'", "'%'", "'++'", "'= --'", + "'sizeof'", "'.'", "'->'", "'&'", "'~'", "'!'", "'*=3D= '", "'/=3D'", + "'%=3D'", "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'= &=3D'", "'^=3D'", "'|=3D'", + "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", "'<'", + "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__asm__'"= , "'_asm'", + "'__asm'", "'case'", "'default'", "'if'", "'else'", "'= switch'", + "'while'", "'do'", "'goto'", "'continue'", "'break'", = "'return'"] =20 - symbolicNames =3D [ "", - "IDENTIFIER", "CHARACTER_LITERAL", "STRING_LITERAL", "HEX_LITE= RAL", - "DECIMAL_LITERAL", "OCTAL_LITERAL", "FLOATING_POINT_LITERAL", - "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMENT", - "LINE_COMMAND" ] + symbolicNames =3D ["", + "IDENTIFIER", "CHARACTER_LITERAL", "STRING_LITERAL", = "HEX_LITERAL", + "DECIMAL_LITERAL", "OCTAL_LITERAL", "FLOATING_POINT_L= ITERAL", + "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COM= MENT", + "LINE_COMMAND"] =20 - ruleNames =3D [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", - "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__1= 3", - "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", - "T__20", "T__21", "T__22", "T__23", "T__24", "T__25", - "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", - "T__32", "T__33", "T__34", "T__35", "T__36", "T__37", - "T__38", "T__39", "T__40", "T__41", "T__42", "T__43", - "T__44", "T__45", "T__46", "T__47", "T__48", "T__49", - "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", - "T__56", "T__57", "T__58", "T__59", "T__60", "T__61", - "T__62", "T__63", "T__64", "T__65", "T__66", "T__67", - "T__68", "T__69", "T__70", "T__71", "T__72", "T__73", - "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", - "T__80", "T__81", "T__82", "T__83", "T__84", "T__85", - "T__86", "T__87", "T__88", "T__89", "T__90", "T__91", - "IDENTIFIER", "LETTER", "CHARACTER_LITERAL", "STRING_LIT= ERAL", - "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", "HexD= igit", - "IntegerTypeSuffix", "FLOATING_POINT_LITERAL", "Exponent= ", - "FloatTypeSuffix", "EscapeSequence", "OctalEscape", "Uni= codeEscape", - "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMEN= T", - "LINE_COMMAND" ] + ruleNames =3D ["T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", + "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13= ", + "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", + "T__20", "T__21", "T__22", "T__23", "T__24", "T__25", + "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", + "T__32", "T__33", "T__34", "T__35", "T__36", "T__37", + "T__38", "T__39", "T__40", "T__41", "T__42", "T__43", + "T__44", "T__45", "T__46", "T__47", "T__48", "T__49", + "T__50", "T__51", "T__52", "T__53", "T__54", "T__55", + "T__56", "T__57", "T__58", "T__59", "T__60", "T__61", + "T__62", "T__63", "T__64", "T__65", "T__66", "T__67", + "T__68", "T__69", "T__70", "T__71", "T__72", "T__73", + "T__74", "T__75", "T__76", "T__77", "T__78", "T__79", + "T__80", "T__81", "T__82", "T__83", "T__84", "T__85", + "T__86", "T__87", "T__88", "T__89", "T__90", "T__91", + "IDENTIFIER", "LETTER", "CHARACTER_LITERAL", "STRING_LITE= RAL", + "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", "HexDi= git", + "IntegerTypeSuffix", "FLOATING_POINT_LITERAL", "Exponent", + "FloatTypeSuffix", "EscapeSequence", "OctalEscape", "Unic= odeEscape", + "WS", "BS", "UnicodeVocabulary", "COMMENT", "LINE_COMMENT= ", + "LINE_COMMAND"] =20 grammarFileName =3D "C.g4" =20 # @param output=3D sys.stdout Type: TextIO - def __init__(self,input=3DNone,output=3D sys.stdout): + def __init__(self, input=3DNone, output=3Dsys.stdout): super().__init__(input, output) self.checkVersion("4.7.1") - self._interp =3D LexerATNSimulator(self, self.atn, self.decisionsT= oDFA, PredictionContextCache()) + self._interp =3D LexerATNSimulator( + self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions =3D None self._predicates =3D None =20 + def printTokenInfo(self, line, offset, tokenText): + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 - - def printTokenInfo(self,line,offset,tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) - - def StorePredicateExpression(self,StartLine,StartOffset,EndLine,EndOff= set,Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.PredicateExpressionList.append(PredExp) =20 - def StoreEnumerationDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, S= tartOffset), (EndLine, EndOffset)) + def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.EnumerationDefinitionList.append(EnumDef) =20 - def StoreStructUnionDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.StructUnionDefinitionList.append(SUDef) =20 - def StoreTypedefDefinition(self,StartLine,StartOffset,EndLine,EndOffse= t,FromText,ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLi= ne, StartOffset), (EndLine, EndOffset)) + def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) FileProfile.TypedefDefinitionList.append(Tdef) =20 - def StoreFunctionDefinition(self,StartLine,StartOffset,EndLine,EndOffs= et,ModifierText,DeclText,LeftBraceLine,LeftBraceOffset,DeclLine,DeclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBrace= Offset), (DeclLine, DeclOffset)) + def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) FileProfile.FunctionDefinitionList.append(FuncDef) =20 - def StoreVariableDeclaration(self,StartLine,StartOffset,EndLine,EndOff= set,ModifierText,DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclTex= t, (StartLine, StartOffset), (EndLine, EndOffset)) + def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) FileProfile.VariableDeclarationList.append(VarDecl) =20 - def StoreFunctionCalling(self,StartLine,StartOffset,EndLine,EndOffset,= FuncName,ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (St= artLine, StartOffset), (EndLine, EndOffset)) + def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) FileProfile.FunctionCallingList.append(FuncCall) - - - diff --git a/BaseTools/Source/Python/Eot/CParser4/CListener.py b/BaseTools/= Source/Python/Eot/CParser4/CListener.py index 46f7f1b3d1ca..866d5717d42b 100644 --- a/BaseTools/Source/Python/Eot/CParser4/CListener.py +++ b/BaseTools/Source/Python/Eot/CParser4/CListener.py @@ -5,7 +5,7 @@ if __name__ is not None and "." in __name__: else: from CParser import CParser =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -27,782 +27,710 @@ class CListener(ParseTreeListener): =20 # Enter a parse tree produced by CParser#translation_unit. # @param ctx Type: CParser.Translation_unitContext - def enterTranslation_unit(self,ctx): + def enterTranslation_unit(self, ctx): pass =20 # Exit a parse tree produced by CParser#translation_unit. # @param ctx Type: CParser.Translation_unitContext - def exitTranslation_unit(self,ctx): + def exitTranslation_unit(self, ctx): pass =20 - # Enter a parse tree produced by CParser#external_declaration. # @param ctx Type: CParser.External_declarationContext - def enterExternal_declaration(self,ctx): + def enterExternal_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#external_declaration. # @param ctx Type: CParser.External_declarationContext - def exitExternal_declaration(self,ctx): + def exitExternal_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#function_definition. # @param ctx Type: CParser.Function_definitionContext - def enterFunction_definition(self,ctx): + def enterFunction_definition(self, ctx): pass =20 # Exit a parse tree produced by CParser#function_definition. # @param ctx Type: CParser.Function_definitionContext - def exitFunction_definition(self,ctx): + def exitFunction_definition(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declaration_specifiers. # @param ctx Type: CParser.Declaration_specifiersContext - def enterDeclaration_specifiers(self,ctx): + def enterDeclaration_specifiers(self, ctx): pass =20 # Exit a parse tree produced by CParser#declaration_specifiers. # @param ctx Type: CParser.Declaration_specifiersContext - def exitDeclaration_specifiers(self,ctx): + def exitDeclaration_specifiers(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declaration. # @param ctx Type: CParser.DeclarationContext - def enterDeclaration(self,ctx): + def enterDeclaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#declaration. # @param ctx Type: CParser.DeclarationContext - def exitDeclaration(self,ctx): + def exitDeclaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#init_declarator_list. # @param ctx Type: CParser.Init_declarator_listContext - def enterInit_declarator_list(self,ctx): + def enterInit_declarator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#init_declarator_list. # @param ctx Type: CParser.Init_declarator_listContext - def exitInit_declarator_list(self,ctx): + def exitInit_declarator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#init_declarator. # @param ctx Type: CParser.Init_declaratorContext - def enterInit_declarator(self,ctx): + def enterInit_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#init_declarator. # @param ctx Type: CParser.Init_declaratorContext - def exitInit_declarator(self,ctx): + def exitInit_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#storage_class_specifier. # @param ctx Type: CParser.Storage_class_specifierContext - def enterStorage_class_specifier(self,ctx): + def enterStorage_class_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#storage_class_specifier. # @param ctx Type: CParser.Storage_class_specifierContext - def exitStorage_class_specifier(self,ctx): + def exitStorage_class_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_specifier. # @param ctx Type: CParser.Type_specifierContext - def enterType_specifier(self,ctx): + def enterType_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_specifier. # @param ctx Type: CParser.Type_specifierContext - def exitType_specifier(self,ctx): + def exitType_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_id. # @param ctx Type: CParser.Type_idContext - def enterType_id(self,ctx): + def enterType_id(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_id. # @param ctx Type: CParser.Type_idContext - def exitType_id(self,ctx): + def exitType_id(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_or_union_specifier. # @param ctx Type: CParser.Struct_or_union_specifierContext - def enterStruct_or_union_specifier(self,ctx): + def enterStruct_or_union_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_or_union_specifier. # @param ctx Type: CParser.Struct_or_union_specifierContext - def exitStruct_or_union_specifier(self,ctx): + def exitStruct_or_union_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_or_union. # @param ctx Type: CParser.Struct_or_unionContext - def enterStruct_or_union(self,ctx): + def enterStruct_or_union(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_or_union. # @param ctx Type: CParser.Struct_or_unionContext - def exitStruct_or_union(self,ctx): + def exitStruct_or_union(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declaration_list. # @param ctx Type: CParser.Struct_declaration_listContext - def enterStruct_declaration_list(self,ctx): + def enterStruct_declaration_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declaration_list. # @param ctx Type: CParser.Struct_declaration_listContext - def exitStruct_declaration_list(self,ctx): + def exitStruct_declaration_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declaration. # @param ctx Type: CParser.Struct_declarationContext - def enterStruct_declaration(self,ctx): + def enterStruct_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declaration. # @param ctx Type: CParser.Struct_declarationContext - def exitStruct_declaration(self,ctx): + def exitStruct_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#specifier_qualifier_list. # @param ctx Type: CParser.Specifier_qualifier_listContext - def enterSpecifier_qualifier_list(self,ctx): + def enterSpecifier_qualifier_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#specifier_qualifier_list. # @param ctx Type: CParser.Specifier_qualifier_listContext - def exitSpecifier_qualifier_list(self,ctx): + def exitSpecifier_qualifier_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declarator_list. # @param ctx Type: CParser.Struct_declarator_listContext - def enterStruct_declarator_list(self,ctx): + def enterStruct_declarator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declarator_list. # @param ctx Type: CParser.Struct_declarator_listContext - def exitStruct_declarator_list(self,ctx): + def exitStruct_declarator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#struct_declarator. # @param ctx Type: CParser.Struct_declaratorContext - def enterStruct_declarator(self,ctx): + def enterStruct_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#struct_declarator. # @param ctx Type: CParser.Struct_declaratorContext - def exitStruct_declarator(self,ctx): + def exitStruct_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enum_specifier. # @param ctx Type: CParser.Enum_specifierContext - def enterEnum_specifier(self,ctx): + def enterEnum_specifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#enum_specifier. # @param ctx Type: CParser.Enum_specifierContext - def exitEnum_specifier(self,ctx): + def exitEnum_specifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enumerator_list. # @param ctx Type: CParser.Enumerator_listContext - def enterEnumerator_list(self,ctx): + def enterEnumerator_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#enumerator_list. # @param ctx Type: CParser.Enumerator_listContext - def exitEnumerator_list(self,ctx): + def exitEnumerator_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#enumerator. # @param ctx Type: CParser.EnumeratorContext - def enterEnumerator(self,ctx): + def enterEnumerator(self, ctx): pass =20 # Exit a parse tree produced by CParser#enumerator. # @param ctx Type: CParser.EnumeratorContext - def exitEnumerator(self,ctx): + def exitEnumerator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_qualifier. # @param ctx Type: CParser.Type_qualifierContext - def enterType_qualifier(self,ctx): + def enterType_qualifier(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_qualifier. # @param ctx Type: CParser.Type_qualifierContext - def exitType_qualifier(self,ctx): + def exitType_qualifier(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declarator. # @param ctx Type: CParser.DeclaratorContext - def enterDeclarator(self,ctx): + def enterDeclarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#declarator. # @param ctx Type: CParser.DeclaratorContext - def exitDeclarator(self,ctx): + def exitDeclarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#direct_declarator. # @param ctx Type: CParser.Direct_declaratorContext - def enterDirect_declarator(self,ctx): + def enterDirect_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#direct_declarator. # @param ctx Type: CParser.Direct_declaratorContext - def exitDirect_declarator(self,ctx): + def exitDirect_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#declarator_suffix. # @param ctx Type: CParser.Declarator_suffixContext - def enterDeclarator_suffix(self,ctx): + def enterDeclarator_suffix(self, ctx): pass =20 # Exit a parse tree produced by CParser#declarator_suffix. # @param ctx Type: CParser.Declarator_suffixContext - def exitDeclarator_suffix(self,ctx): + def exitDeclarator_suffix(self, ctx): pass =20 - # Enter a parse tree produced by CParser#pointer. # @param ctx Type: CParser.PointerContext - def enterPointer(self,ctx): + def enterPointer(self, ctx): pass =20 # Exit a parse tree produced by CParser#pointer. # @param ctx Type: CParser.PointerContext - def exitPointer(self,ctx): + def exitPointer(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_type_list. # @param ctx Type: CParser.Parameter_type_listContext - def enterParameter_type_list(self,ctx): + def enterParameter_type_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_type_list. # @param ctx Type: CParser.Parameter_type_listContext - def exitParameter_type_list(self,ctx): + def exitParameter_type_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_list. # @param ctx Type: CParser.Parameter_listContext - def enterParameter_list(self,ctx): + def enterParameter_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_list. # @param ctx Type: CParser.Parameter_listContext - def exitParameter_list(self,ctx): + def exitParameter_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#parameter_declaration. # @param ctx Type: CParser.Parameter_declarationContext - def enterParameter_declaration(self,ctx): + def enterParameter_declaration(self, ctx): pass =20 # Exit a parse tree produced by CParser#parameter_declaration. # @param ctx Type: CParser.Parameter_declarationContext - def exitParameter_declaration(self,ctx): + def exitParameter_declaration(self, ctx): pass =20 - # Enter a parse tree produced by CParser#identifier_list. # @param ctx Type: CParser.Identifier_listContext - def enterIdentifier_list(self,ctx): + def enterIdentifier_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#identifier_list. # @param ctx Type: CParser.Identifier_listContext - def exitIdentifier_list(self,ctx): + def exitIdentifier_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#type_name. # @param ctx Type: CParser.Type_nameContext - def enterType_name(self,ctx): + def enterType_name(self, ctx): pass =20 # Exit a parse tree produced by CParser#type_name. # @param ctx Type: CParser.Type_nameContext - def exitType_name(self,ctx): + def exitType_name(self, ctx): pass =20 - # Enter a parse tree produced by CParser#abstract_declarator. # @param ctx Type: CParser.Abstract_declaratorContext - def enterAbstract_declarator(self,ctx): + def enterAbstract_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#abstract_declarator. # @param ctx Type: CParser.Abstract_declaratorContext - def exitAbstract_declarator(self,ctx): + def exitAbstract_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#direct_abstract_declarator. # @param ctx Type: CParser.Direct_abstract_declaratorContext - def enterDirect_abstract_declarator(self,ctx): + def enterDirect_abstract_declarator(self, ctx): pass =20 # Exit a parse tree produced by CParser#direct_abstract_declarator. # @param ctx Type: CParser.Direct_abstract_declaratorContext - def exitDirect_abstract_declarator(self,ctx): + def exitDirect_abstract_declarator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#abstract_declarator_suffix. # @param ctx Type: CParser.Abstract_declarator_suffixContext - def enterAbstract_declarator_suffix(self,ctx): + def enterAbstract_declarator_suffix(self, ctx): pass =20 # Exit a parse tree produced by CParser#abstract_declarator_suffix. # @param ctx Type: CParser.Abstract_declarator_suffixContext - def exitAbstract_declarator_suffix(self,ctx): + def exitAbstract_declarator_suffix(self, ctx): pass =20 - # Enter a parse tree produced by CParser#initializer. # @param ctx Type: CParser.InitializerContext - def enterInitializer(self,ctx): + def enterInitializer(self, ctx): pass =20 # Exit a parse tree produced by CParser#initializer. # @param ctx Type: CParser.InitializerContext - def exitInitializer(self,ctx): + def exitInitializer(self, ctx): pass =20 - # Enter a parse tree produced by CParser#initializer_list. # @param ctx Type: CParser.Initializer_listContext - def enterInitializer_list(self,ctx): + def enterInitializer_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#initializer_list. # @param ctx Type: CParser.Initializer_listContext - def exitInitializer_list(self,ctx): + def exitInitializer_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#argument_expression_list. # @param ctx Type: CParser.Argument_expression_listContext - def enterArgument_expression_list(self,ctx): + def enterArgument_expression_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#argument_expression_list. # @param ctx Type: CParser.Argument_expression_listContext - def exitArgument_expression_list(self,ctx): + def exitArgument_expression_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#additive_expression. # @param ctx Type: CParser.Additive_expressionContext - def enterAdditive_expression(self,ctx): + def enterAdditive_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#additive_expression. # @param ctx Type: CParser.Additive_expressionContext - def exitAdditive_expression(self,ctx): + def exitAdditive_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#multiplicative_expression. # @param ctx Type: CParser.Multiplicative_expressionContext - def enterMultiplicative_expression(self,ctx): + def enterMultiplicative_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#multiplicative_expression. # @param ctx Type: CParser.Multiplicative_expressionContext - def exitMultiplicative_expression(self,ctx): + def exitMultiplicative_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#cast_expression. # @param ctx Type: CParser.Cast_expressionContext - def enterCast_expression(self,ctx): + def enterCast_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#cast_expression. # @param ctx Type: CParser.Cast_expressionContext - def exitCast_expression(self,ctx): + def exitCast_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#unary_expression. # @param ctx Type: CParser.Unary_expressionContext - def enterUnary_expression(self,ctx): + def enterUnary_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#unary_expression. # @param ctx Type: CParser.Unary_expressionContext - def exitUnary_expression(self,ctx): + def exitUnary_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#postfix_expression. # @param ctx Type: CParser.Postfix_expressionContext - def enterPostfix_expression(self,ctx): + def enterPostfix_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#postfix_expression. # @param ctx Type: CParser.Postfix_expressionContext - def exitPostfix_expression(self,ctx): + def exitPostfix_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#macro_parameter_list. # @param ctx Type: CParser.Macro_parameter_listContext - def enterMacro_parameter_list(self,ctx): + def enterMacro_parameter_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#macro_parameter_list. # @param ctx Type: CParser.Macro_parameter_listContext - def exitMacro_parameter_list(self,ctx): + def exitMacro_parameter_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#unary_operator. # @param ctx Type: CParser.Unary_operatorContext - def enterUnary_operator(self,ctx): + def enterUnary_operator(self, ctx): pass =20 # Exit a parse tree produced by CParser#unary_operator. # @param ctx Type: CParser.Unary_operatorContext - def exitUnary_operator(self,ctx): + def exitUnary_operator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#primary_expression. # @param ctx Type: CParser.Primary_expressionContext - def enterPrimary_expression(self,ctx): + def enterPrimary_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#primary_expression. # @param ctx Type: CParser.Primary_expressionContext - def exitPrimary_expression(self,ctx): + def exitPrimary_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#constant. # @param ctx Type: CParser.ConstantContext - def enterConstant(self,ctx): + def enterConstant(self, ctx): pass =20 # Exit a parse tree produced by CParser#constant. # @param ctx Type: CParser.ConstantContext - def exitConstant(self,ctx): + def exitConstant(self, ctx): pass =20 - # Enter a parse tree produced by CParser#expression. # @param ctx Type: CParser.ExpressionContext - def enterExpression(self,ctx): + def enterExpression(self, ctx): pass =20 # Exit a parse tree produced by CParser#expression. # @param ctx Type: CParser.ExpressionContext - def exitExpression(self,ctx): + def exitExpression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#constant_expression. # @param ctx Type: CParser.Constant_expressionContext - def enterConstant_expression(self,ctx): + def enterConstant_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#constant_expression. # @param ctx Type: CParser.Constant_expressionContext - def exitConstant_expression(self,ctx): + def exitConstant_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#assignment_expression. # @param ctx Type: CParser.Assignment_expressionContext - def enterAssignment_expression(self,ctx): + def enterAssignment_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#assignment_expression. # @param ctx Type: CParser.Assignment_expressionContext - def exitAssignment_expression(self,ctx): + def exitAssignment_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#lvalue. # @param ctx Type: CParser.LvalueContext - def enterLvalue(self,ctx): + def enterLvalue(self, ctx): pass =20 # Exit a parse tree produced by CParser#lvalue. # @param ctx Type: CParser.LvalueContext - def exitLvalue(self,ctx): + def exitLvalue(self, ctx): pass =20 - # Enter a parse tree produced by CParser#assignment_operator. # @param ctx Type: CParser.Assignment_operatorContext - def enterAssignment_operator(self,ctx): + def enterAssignment_operator(self, ctx): pass =20 # Exit a parse tree produced by CParser#assignment_operator. # @param ctx Type: CParser.Assignment_operatorContext - def exitAssignment_operator(self,ctx): + def exitAssignment_operator(self, ctx): pass =20 - # Enter a parse tree produced by CParser#conditional_expression. # @param ctx Type: CParser.Conditional_expressionContext - def enterConditional_expression(self,ctx): + def enterConditional_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#conditional_expression. # @param ctx Type: CParser.Conditional_expressionContext - def exitConditional_expression(self,ctx): + def exitConditional_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#logical_or_expression. # @param ctx Type: CParser.Logical_or_expressionContext - def enterLogical_or_expression(self,ctx): + def enterLogical_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#logical_or_expression. # @param ctx Type: CParser.Logical_or_expressionContext - def exitLogical_or_expression(self,ctx): + def exitLogical_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#logical_and_expression. # @param ctx Type: CParser.Logical_and_expressionContext - def enterLogical_and_expression(self,ctx): + def enterLogical_and_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#logical_and_expression. # @param ctx Type: CParser.Logical_and_expressionContext - def exitLogical_and_expression(self,ctx): + def exitLogical_and_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#inclusive_or_expression. # @param ctx Type: CParser.Inclusive_or_expressionContext - def enterInclusive_or_expression(self,ctx): + def enterInclusive_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#inclusive_or_expression. # @param ctx Type: CParser.Inclusive_or_expressionContext - def exitInclusive_or_expression(self,ctx): + def exitInclusive_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#exclusive_or_expression. # @param ctx Type: CParser.Exclusive_or_expressionContext - def enterExclusive_or_expression(self,ctx): + def enterExclusive_or_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#exclusive_or_expression. # @param ctx Type: CParser.Exclusive_or_expressionContext - def exitExclusive_or_expression(self,ctx): + def exitExclusive_or_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#and_expression. # @param ctx Type: CParser.And_expressionContext - def enterAnd_expression(self,ctx): + def enterAnd_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#and_expression. # @param ctx Type: CParser.And_expressionContext - def exitAnd_expression(self,ctx): + def exitAnd_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#equality_expression. # @param ctx Type: CParser.Equality_expressionContext - def enterEquality_expression(self,ctx): + def enterEquality_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#equality_expression. # @param ctx Type: CParser.Equality_expressionContext - def exitEquality_expression(self,ctx): + def exitEquality_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#relational_expression. # @param ctx Type: CParser.Relational_expressionContext - def enterRelational_expression(self,ctx): + def enterRelational_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#relational_expression. # @param ctx Type: CParser.Relational_expressionContext - def exitRelational_expression(self,ctx): + def exitRelational_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#shift_expression. # @param ctx Type: CParser.Shift_expressionContext - def enterShift_expression(self,ctx): + def enterShift_expression(self, ctx): pass =20 # Exit a parse tree produced by CParser#shift_expression. # @param ctx Type: CParser.Shift_expressionContext - def exitShift_expression(self,ctx): + def exitShift_expression(self, ctx): pass =20 - # Enter a parse tree produced by CParser#statement. # @param ctx Type: CParser.StatementContext - def enterStatement(self,ctx): + def enterStatement(self, ctx): pass =20 # Exit a parse tree produced by CParser#statement. # @param ctx Type: CParser.StatementContext - def exitStatement(self,ctx): + def exitStatement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm2_statement. # @param ctx Type: CParser.Asm2_statementContext - def enterAsm2_statement(self,ctx): + def enterAsm2_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm2_statement. # @param ctx Type: CParser.Asm2_statementContext - def exitAsm2_statement(self,ctx): + def exitAsm2_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm1_statement. # @param ctx Type: CParser.Asm1_statementContext - def enterAsm1_statement(self,ctx): + def enterAsm1_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm1_statement. # @param ctx Type: CParser.Asm1_statementContext - def exitAsm1_statement(self,ctx): + def exitAsm1_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#asm_statement. # @param ctx Type: CParser.Asm_statementContext - def enterAsm_statement(self,ctx): + def enterAsm_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#asm_statement. # @param ctx Type: CParser.Asm_statementContext - def exitAsm_statement(self,ctx): + def exitAsm_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#macro_statement. # @param ctx Type: CParser.Macro_statementContext - def enterMacro_statement(self,ctx): + def enterMacro_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#macro_statement. # @param ctx Type: CParser.Macro_statementContext - def exitMacro_statement(self,ctx): + def exitMacro_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#labeled_statement. # @param ctx Type: CParser.Labeled_statementContext - def enterLabeled_statement(self,ctx): + def enterLabeled_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#labeled_statement. # @param ctx Type: CParser.Labeled_statementContext - def exitLabeled_statement(self,ctx): + def exitLabeled_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#compound_statement. # @param ctx Type: CParser.Compound_statementContext - def enterCompound_statement(self,ctx): + def enterCompound_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#compound_statement. # @param ctx Type: CParser.Compound_statementContext - def exitCompound_statement(self,ctx): + def exitCompound_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#statement_list. # @param ctx Type: CParser.Statement_listContext - def enterStatement_list(self,ctx): + def enterStatement_list(self, ctx): pass =20 # Exit a parse tree produced by CParser#statement_list. # @param ctx Type: CParser.Statement_listContext - def exitStatement_list(self,ctx): + def exitStatement_list(self, ctx): pass =20 - # Enter a parse tree produced by CParser#expression_statement. # @param ctx Type: CParser.Expression_statementContext - def enterExpression_statement(self,ctx): + def enterExpression_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#expression_statement. # @param ctx Type: CParser.Expression_statementContext - def exitExpression_statement(self,ctx): + def exitExpression_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#selection_statement. # @param ctx Type: CParser.Selection_statementContext - def enterSelection_statement(self,ctx): + def enterSelection_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#selection_statement. # @param ctx Type: CParser.Selection_statementContext - def exitSelection_statement(self,ctx): + def exitSelection_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#iteration_statement. # @param ctx Type: CParser.Iteration_statementContext - def enterIteration_statement(self,ctx): + def enterIteration_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#iteration_statement. # @param ctx Type: CParser.Iteration_statementContext - def exitIteration_statement(self,ctx): + def exitIteration_statement(self, ctx): pass =20 - # Enter a parse tree produced by CParser#jump_statement. # @param ctx Type: CParser.Jump_statementContext - def enterJump_statement(self,ctx): + def enterJump_statement(self, ctx): pass =20 # Exit a parse tree produced by CParser#jump_statement. # @param ctx Type: CParser.Jump_statementContext - def exitJump_statement(self,ctx): + def exitJump_statement(self, ctx): pass - - diff --git a/BaseTools/Source/Python/Eot/CParser4/CParser.py b/BaseTools/So= urce/Python/Eot/CParser4/CParser.py index 31d23d55aa57..22c17c66680a 100644 --- a/BaseTools/Source/Python/Eot/CParser4/CParser.py +++ b/BaseTools/Source/Python/Eot/CParser4/CParser.py @@ -6,7 +6,7 @@ from typing.io import TextIO import sys =20 =20 -## @file +# @file # The file defines the parser for C source files. # # THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE. @@ -22,6 +22,7 @@ import sys import Ecc.CodeFragment as CodeFragment import Ecc.FileProfile as FileProfile =20 + def serializedATN(): with StringIO() as buf: buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3k") @@ -475,61 +476,61 @@ def serializedATN(): return buf.getvalue() =20 =20 -class CParser ( Parser ): +class CParser (Parser): =20 grammarFileName =3D "C.g4" =20 atn =3D ATNDeserializer().deserialize(serializedATN()) =20 - decisionsToDFA =3D [ DFA(ds, i) for i, ds in enumerate(atn.decisionToS= tate) ] + decisionsToDFA =3D [DFA(ds, i) for i, ds in enumerate(atn.decisionToSt= ate)] =20 sharedContextCache =3D PredictionContextCache() =20 - literalNames =3D [ "", "'{'", "';'", "'typedef'", "','", "'= =3D'", - "'extern'", "'static'", "'auto'", "'register'", "'STA= TIC'", - "'void'", "'char'", "'short'", "'int'", "'long'", "'f= loat'", - "'double'", "'signed'", "'unsigned'", "'}'", "'struct= '", - "'union'", "':'", "'enum'", "'const'", "'volatile'", - "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED= '", - "'VOLATILE'", "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EF= IAPI'", - "'EFI_BOOTSERVICE'", "'EFI_RUNTIMESERVICE'", "'PACKED= '", - "'('", "')'", "'['", "']'", "'*'", "'...'", "'+'", - "'-'", "'/'", "'%'", "'++'", "'--'", "'sizeof'", "'.'= ", - "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/=3D'", "'%= =3D'", - "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", "= '^=3D'", "'|=3D'", - "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", - "'<'", "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'_= _asm__'", - "'_asm'", "'__asm'", "'case'", "'default'", "'if'", - "'else'", "'switch'", "'while'", "'do'", "'goto'", - "'continue'", "'break'", "'return'" ] + literalNames =3D ["", "'{'", "';'", "'typedef'", "','", "'=3D= '", + "'extern'", "'static'", "'auto'", "'register'", "'STAT= IC'", + "'void'", "'char'", "'short'", "'int'", "'long'", "'fl= oat'", + "'double'", "'signed'", "'unsigned'", "'}'", "'struct'= ", + "'union'", "':'", "'enum'", "'const'", "'volatile'", + "'IN'", "'OUT'", "'OPTIONAL'", "'CONST'", "'UNALIGNED'= ", + "'VOLATILE'", "'GLOBAL_REMOVE_IF_UNREFERENCED'", "'EFI= API'", + "'EFI_BOOTSERVICE'", "'EFI_RUNTIMESERVICE'", "'PACKED'= ", + "'('", "')'", "'['", "']'", "'*'", "'...'", "'+'", + "'-'", "'/'", "'%'", "'++'", "'--'", "'sizeof'", "'.'", + "'->'", "'&'", "'~'", "'!'", "'*=3D'", "'/=3D'", "'%= =3D'", + "'+=3D'", "'-=3D'", "'<<=3D'", "'>>=3D'", "'&=3D'", "'= ^=3D'", "'|=3D'", + "'?'", "'||'", "'&&'", "'|'", "'^'", "'=3D=3D'", "'!= =3D'", + "'<'", "'>'", "'<=3D'", "'>=3D'", "'<<'", "'>>'", "'__= asm__'", + "'_asm'", "'__asm'", "'case'", "'default'", "'if'", + "'else'", "'switch'", "'while'", "'do'", "'goto'", + "'continue'", "'break'", "'return'"] =20 - symbolicNames =3D [ "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "", "", "", - "", "IDENTIFIER", "CHARACTER_LITERAL", "STR= ING_LITERAL", - "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", - "FLOATING_POINT_LITERAL", "WS", "BS", "UnicodeVocabu= lary", - "COMMENT", "LINE_COMMENT", "LINE_COMMAND" ] + symbolicNames =3D ["", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "IDENTIFIER", "CHARACTER_LITERAL", "STRI= NG_LITERAL", + "HEX_LITERAL", "DECIMAL_LITERAL", "OCTAL_LITERAL", + "FLOATING_POINT_LITERAL", "WS", "BS", "UnicodeVocabul= ary", + "COMMENT", "LINE_COMMENT", "LINE_COMMAND"] =20 RULE_translation_unit =3D 0 RULE_external_declaration =3D 1 @@ -603,225 +604,224 @@ class CParser ( Parser ): RULE_iteration_statement =3D 69 RULE_jump_statement =3D 70 =20 - ruleNames =3D [ "translation_unit", "external_declaration", "function= _definition", - "declaration_specifiers", "declaration", "init_declarat= or_list", - "init_declarator", "storage_class_specifier", "type_spe= cifier", - "type_id", "struct_or_union_specifier", "struct_or_unio= n", - "struct_declaration_list", "struct_declaration", "speci= fier_qualifier_list", - "struct_declarator_list", "struct_declarator", "enum_sp= ecifier", - "enumerator_list", "enumerator", "type_qualifier", "dec= larator", - "direct_declarator", "declarator_suffix", "pointer", - "parameter_type_list", "parameter_list", "parameter_dec= laration", - "identifier_list", "type_name", "abstract_declarator", - "direct_abstract_declarator", "abstract_declarator_suff= ix", - "initializer", "initializer_list", "argument_expression= _list", - "additive_expression", "multiplicative_expression", "ca= st_expression", - "unary_expression", "postfix_expression", "macro_parame= ter_list", - "unary_operator", "primary_expression", "constant", "ex= pression", - "constant_expression", "assignment_expression", "lvalue= ", - "assignment_operator", "conditional_expression", "logic= al_or_expression", - "logical_and_expression", "inclusive_or_expression", - "exclusive_or_expression", "and_expression", "equality_= expression", - "relational_expression", "shift_expression", "statement= ", - "asm2_statement", "asm1_statement", "asm_statement", - "macro_statement", "labeled_statement", "compound_state= ment", - "statement_list", "expression_statement", "selection_st= atement", - "iteration_statement", "jump_statement" ] + ruleNames =3D ["translation_unit", "external_declaration", "function_d= efinition", + "declaration_specifiers", "declaration", "init_declarator= _list", + "init_declarator", "storage_class_specifier", "type_speci= fier", + "type_id", "struct_or_union_specifier", "struct_or_union", + "struct_declaration_list", "struct_declaration", "specifi= er_qualifier_list", + "struct_declarator_list", "struct_declarator", "enum_spec= ifier", + "enumerator_list", "enumerator", "type_qualifier", "decla= rator", + "direct_declarator", "declarator_suffix", "pointer", + "parameter_type_list", "parameter_list", "parameter_decla= ration", + "identifier_list", "type_name", "abstract_declarator", + "direct_abstract_declarator", "abstract_declarator_suffix= ", + "initializer", "initializer_list", "argument_expression_l= ist", + "additive_expression", "multiplicative_expression", "cast= _expression", + "unary_expression", "postfix_expression", "macro_paramete= r_list", + "unary_operator", "primary_expression", "constant", "expr= ession", + "constant_expression", "assignment_expression", "lvalue", + "assignment_operator", "conditional_expression", "logical= _or_expression", + "logical_and_expression", "inclusive_or_expression", + "exclusive_or_expression", "and_expression", "equality_ex= pression", + "relational_expression", "shift_expression", "statement", + "asm2_statement", "asm1_statement", "asm_statement", + "macro_statement", "labeled_statement", "compound_stateme= nt", + "statement_list", "expression_statement", "selection_stat= ement", + "iteration_statement", "jump_statement"] =20 EOF =3D Token.EOF - T__0=3D1 - T__1=3D2 - T__2=3D3 - T__3=3D4 - T__4=3D5 - T__5=3D6 - T__6=3D7 - T__7=3D8 - T__8=3D9 - T__9=3D10 - T__10=3D11 - T__11=3D12 - T__12=3D13 - T__13=3D14 - T__14=3D15 - T__15=3D16 - T__16=3D17 - T__17=3D18 - T__18=3D19 - T__19=3D20 - T__20=3D21 - T__21=3D22 - T__22=3D23 - T__23=3D24 - T__24=3D25 - T__25=3D26 - T__26=3D27 - T__27=3D28 - T__28=3D29 - T__29=3D30 - T__30=3D31 - T__31=3D32 - T__32=3D33 - T__33=3D34 - T__34=3D35 - T__35=3D36 - T__36=3D37 - T__37=3D38 - T__38=3D39 - T__39=3D40 - T__40=3D41 - T__41=3D42 - T__42=3D43 - T__43=3D44 - T__44=3D45 - T__45=3D46 - T__46=3D47 - T__47=3D48 - T__48=3D49 - T__49=3D50 - T__50=3D51 - T__51=3D52 - T__52=3D53 - T__53=3D54 - T__54=3D55 - T__55=3D56 - T__56=3D57 - T__57=3D58 - T__58=3D59 - T__59=3D60 - T__60=3D61 - T__61=3D62 - T__62=3D63 - T__63=3D64 - T__64=3D65 - T__65=3D66 - T__66=3D67 - T__67=3D68 - T__68=3D69 - T__69=3D70 - T__70=3D71 - T__71=3D72 - T__72=3D73 - T__73=3D74 - T__74=3D75 - T__75=3D76 - T__76=3D77 - T__77=3D78 - T__78=3D79 - T__79=3D80 - T__80=3D81 - T__81=3D82 - T__82=3D83 - T__83=3D84 - T__84=3D85 - T__85=3D86 - T__86=3D87 - T__87=3D88 - T__88=3D89 - T__89=3D90 - T__90=3D91 - T__91=3D92 - IDENTIFIER=3D93 - CHARACTER_LITERAL=3D94 - STRING_LITERAL=3D95 - HEX_LITERAL=3D96 - DECIMAL_LITERAL=3D97 - OCTAL_LITERAL=3D98 - FLOATING_POINT_LITERAL=3D99 - WS=3D100 - BS=3D101 - UnicodeVocabulary=3D102 - COMMENT=3D103 - LINE_COMMENT=3D104 - LINE_COMMAND=3D105 + T__0 =3D 1 + T__1 =3D 2 + T__2 =3D 3 + T__3 =3D 4 + T__4 =3D 5 + T__5 =3D 6 + T__6 =3D 7 + T__7 =3D 8 + T__8 =3D 9 + T__9 =3D 10 + T__10 =3D 11 + T__11 =3D 12 + T__12 =3D 13 + T__13 =3D 14 + T__14 =3D 15 + T__15 =3D 16 + T__16 =3D 17 + T__17 =3D 18 + T__18 =3D 19 + T__19 =3D 20 + T__20 =3D 21 + T__21 =3D 22 + T__22 =3D 23 + T__23 =3D 24 + T__24 =3D 25 + T__25 =3D 26 + T__26 =3D 27 + T__27 =3D 28 + T__28 =3D 29 + T__29 =3D 30 + T__30 =3D 31 + T__31 =3D 32 + T__32 =3D 33 + T__33 =3D 34 + T__34 =3D 35 + T__35 =3D 36 + T__36 =3D 37 + T__37 =3D 38 + T__38 =3D 39 + T__39 =3D 40 + T__40 =3D 41 + T__41 =3D 42 + T__42 =3D 43 + T__43 =3D 44 + T__44 =3D 45 + T__45 =3D 46 + T__46 =3D 47 + T__47 =3D 48 + T__48 =3D 49 + T__49 =3D 50 + T__50 =3D 51 + T__51 =3D 52 + T__52 =3D 53 + T__53 =3D 54 + T__54 =3D 55 + T__55 =3D 56 + T__56 =3D 57 + T__57 =3D 58 + T__58 =3D 59 + T__59 =3D 60 + T__60 =3D 61 + T__61 =3D 62 + T__62 =3D 63 + T__63 =3D 64 + T__64 =3D 65 + T__65 =3D 66 + T__66 =3D 67 + T__67 =3D 68 + T__68 =3D 69 + T__69 =3D 70 + T__70 =3D 71 + T__71 =3D 72 + T__72 =3D 73 + T__73 =3D 74 + T__74 =3D 75 + T__75 =3D 76 + T__76 =3D 77 + T__77 =3D 78 + T__78 =3D 79 + T__79 =3D 80 + T__80 =3D 81 + T__81 =3D 82 + T__82 =3D 83 + T__83 =3D 84 + T__84 =3D 85 + T__85 =3D 86 + T__86 =3D 87 + T__87 =3D 88 + T__88 =3D 89 + T__89 =3D 90 + T__90 =3D 91 + T__91 =3D 92 + IDENTIFIER =3D 93 + CHARACTER_LITERAL =3D 94 + STRING_LITERAL =3D 95 + HEX_LITERAL =3D 96 + DECIMAL_LITERAL =3D 97 + OCTAL_LITERAL =3D 98 + FLOATING_POINT_LITERAL =3D 99 + WS =3D 100 + BS =3D 101 + UnicodeVocabulary =3D 102 + COMMENT =3D 103 + LINE_COMMENT =3D 104 + LINE_COMMAND =3D 105 =20 # @param input Type: TokenStream # @param output=3D sys.stdout Type: TextIO - def __init__(self,input,output=3D sys.stdout): + def __init__(self, input, output=3Dsys.stdout): super().__init__(input, output) self.checkVersion("4.7.1") - self._interp =3D ParserATNSimulator(self, self.atn, self.decisions= ToDFA, self.sharedContextCache) + self._interp =3D ParserATNSimulator( + self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates =3D None =20 + def printTokenInfo(self, line, offset, tokenText): + print(str(line) + ',' + str(offset) + ':' + str(tokenText)) =20 - - - def printTokenInfo(self,line,offset,tokenText): - print(str(line)+ ',' + str(offset) + ':' + str(tokenText)) - - def StorePredicateExpression(self,StartLine,StartOffset,EndLine,EndOff= set,Text): - PredExp =3D CodeFragment.PredicateExpression(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StorePredicateExpression(self, StartLine, StartOffset, EndLine, En= dOffset, Text): + PredExp =3D CodeFragment.PredicateExpression( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.PredicateExpressionList.append(PredExp) =20 - def StoreEnumerationDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - EnumDef =3D CodeFragment.EnumerationDefinition(Text, (StartLine, S= tartOffset), (EndLine, EndOffset)) + def StoreEnumerationDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + EnumDef =3D CodeFragment.EnumerationDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.EnumerationDefinitionList.append(EnumDef) =20 - def StoreStructUnionDefinition(self,StartLine,StartOffset,EndLine,EndO= ffset,Text): - SUDef =3D CodeFragment.StructUnionDefinition(Text, (StartLine, Sta= rtOffset), (EndLine, EndOffset)) + def StoreStructUnionDefinition(self, StartLine, StartOffset, EndLine, = EndOffset, Text): + SUDef =3D CodeFragment.StructUnionDefinition( + Text, (StartLine, StartOffset), (EndLine, EndOffset)) FileProfile.StructUnionDefinitionList.append(SUDef) =20 - def StoreTypedefDefinition(self,StartLine,StartOffset,EndLine,EndOffse= t,FromText,ToText): - Tdef =3D CodeFragment.TypedefDefinition(FromText, ToText, (StartLi= ne, StartOffset), (EndLine, EndOffset)) + def StoreTypedefDefinition(self, StartLine, StartOffset, EndLine, EndO= ffset, FromText, ToText): + Tdef =3D CodeFragment.TypedefDefinition( + FromText, ToText, (StartLine, StartOffset), (EndLine, EndOffse= t)) FileProfile.TypedefDefinitionList.append(Tdef) =20 - def StoreFunctionDefinition(self,StartLine,StartOffset,EndLine,EndOffs= et,ModifierText,DeclText,LeftBraceLine,LeftBraceOffset,DeclLine,DeclOffset): - FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), (EndLine, EndOffset), (LeftBraceLine, LeftBrace= Offset), (DeclLine, DeclOffset)) + def StoreFunctionDefinition(self, StartLine, StartOffset, EndLine, End= Offset, ModifierText, DeclText, LeftBraceLine, LeftBraceOffset, DeclLine, D= eclOffset): + FuncDef =3D CodeFragment.FunctionDefinition(ModifierText, DeclText= , (StartLine, StartOffset), ( + EndLine, EndOffset), (LeftBraceLine, LeftBraceOffset), (DeclLi= ne, DeclOffset)) FileProfile.FunctionDefinitionList.append(FuncDef) =20 - def StoreVariableDeclaration(self,StartLine,StartOffset,EndLine,EndOff= set,ModifierText,DeclText): - VarDecl =3D CodeFragment.VariableDeclaration(ModifierText, DeclTex= t, (StartLine, StartOffset), (EndLine, EndOffset)) + def StoreVariableDeclaration(self, StartLine, StartOffset, EndLine, En= dOffset, ModifierText, DeclText): + VarDecl =3D CodeFragment.VariableDeclaration( + ModifierText, DeclText, (StartLine, StartOffset), (EndLine, En= dOffset)) FileProfile.VariableDeclarationList.append(VarDecl) =20 - def StoreFunctionCalling(self,StartLine,StartOffset,EndLine,EndOffset,= FuncName,ParamList): - FuncCall =3D CodeFragment.FunctionCalling(FuncName, ParamList, (St= artLine, StartOffset), (EndLine, EndOffset)) + def StoreFunctionCalling(self, StartLine, StartOffset, EndLine, EndOff= set, FuncName, ParamList): + FuncCall =3D CodeFragment.FunctionCalling( + FuncName, ParamList, (StartLine, StartOffset), (EndLine, EndOf= fset)) FileProfile.FunctionCallingList.append(FuncCall) =20 - - class Translation_unitContext(ParserRuleContext): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def external_declaration(self,i=3DNone): + def external_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.External_declarat= ionContext) else: - return self.getTypedRuleContext(CParser.External_declarati= onContext,i) - + return self.getTypedRuleContext(CParser.External_declarati= onContext, i) =20 def getRuleIndex(self): return CParser.RULE_translation_unit =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterTranslation_unit" ): + def enterRule(self, listener): + if hasattr(listener, "enterTranslation_unit"): listener.enterTranslation_unit(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitTranslation_unit" ): + def exitRule(self, listener): + if hasattr(listener, "exitTranslation_unit"): listener.exitTranslation_unit(self) =20 - - - def translation_unit(self): =20 localctx =3D CParser.Translation_unitContext(self, self._ctx, self= .state) self.enterRule(localctx, 0, self.RULE_translation_unit) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 145 self._errHandler.sync(self) _la =3D self._input.LA(1) - while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T__7) = | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1 << = CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CParse= r.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.T__1= 7) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21) | (= 1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 << C= Parser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CParser= .T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T__32= ) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) | (1= << CParser.T__36) | (1 << CParser.T__37) | (1 << CParser.T__41))) !=3D 0) = or _la=3D=3DCParser.IDENTIFIER: + while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T__7) = | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1 << = CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CParse= r.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.T__1= 7) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21) | (= 1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 << C= Parser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CParser= .T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T__32= ) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) | (1= << CParser.T__36) | (1 << CParser.T__37) | (1 << CParser.T__41))) !=3D 0) = or _la =3D=3D CParser.IDENTIFIER: self.state =3D 142 self.external_declaration() self.state =3D 147 @@ -840,75 +840,67 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def function_definition(self): - return self.getTypedRuleContext(CParser.Function_definitionCon= text,0) - + return self.getTypedRuleContext(CParser.Function_definitionCon= text, 0) =20 def macro_statement(self): - return self.getTypedRuleContext(CParser.Macro_statementContext= ,0) - + return self.getTypedRuleContext(CParser.Macro_statementContext= , 0) =20 def getRuleIndex(self): return CParser.RULE_external_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExternal_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterExternal_declaration"): listener.enterExternal_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExternal_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitExternal_declaration"): listener.exitExternal_declaration(self) =20 - - - def external_declaration(self): =20 - localctx =3D CParser.External_declarationContext(self, self._ctx, = self.state) + localctx =3D CParser.External_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 2, self.RULE_external_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 166 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,4,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 4, self._ctx) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 149 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,1,self._c= tx) + la_ =3D self._interp.adaptivePredict(self._input, 1, self.= _ctx) if la_ =3D=3D 1: self.state =3D 148 self.declaration_specifiers() =20 - self.state =3D 151 self.declarator() self.state =3D 155 self._errHandler.sync(self) _la =3D self._input.LA(1) - while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << C= Parser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T_= _7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1= << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CP= arser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.= T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21)= | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 = << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CPa= rser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T= __32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) = | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.IDENTIFIER: + while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << C= Parser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CParser.T_= _7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10) | (1= << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1 << CP= arser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CParser.= T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.T__21)= | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25) | (1 = << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 << CPa= rser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CParser.T= __32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T__35) = | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.IDENTIFIER: self.state =3D 152 self.declaration() self.state =3D 157 @@ -938,14 +930,12 @@ class CParser ( Parser ): self.state =3D 164 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__1: + if _la =3D=3D CParser.T__1: self.state =3D 163 self.match(CParser.T__1) =20 - pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -958,7 +948,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser self.ModifierText =3D '' @@ -967,71 +957,64 @@ class CParser ( Parser ): self.LBOffset =3D 0 self.DeclLine =3D 0 self.DeclOffset =3D 0 - self.d =3D None # Declaration_specifiersContext - self._declaration_specifiers =3D None # Declaration_specifiers= Context - self._declarator =3D None # DeclaratorContext - self.a =3D None # Compound_statementContext - self.b =3D None # Compound_statementContext + self.d =3D None # Declaration_specifiersContext + self._declaration_specifiers =3D None # Declaration_specifier= sContext + self._declarator =3D None # DeclaratorContext + self.a =3D None # Compound_statementContext + self.b =3D None # Compound_statementContext =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def compound_statement(self): - return self.getTypedRuleContext(CParser.Compound_statementCont= ext,0) - + return self.getTypedRuleContext(CParser.Compound_statementCont= ext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def getRuleIndex(self): return CParser.RULE_function_definition =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterFunction_definition" ): + def enterRule(self, listener): + if hasattr(listener, "enterFunction_definition"): listener.enterFunction_definition(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitFunction_definition" ): + def exitRule(self, listener): + if hasattr(listener, "exitFunction_definition"): listener.exitFunction_definition(self) =20 - - - def function_definition(self): =20 - localctx =3D CParser.Function_definitionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Function_definitionContext( + self, self._ctx, self.state) self.enterRule(localctx, 4, self.RULE_function_definition) =20 - ModifierText =3D ''; - DeclText =3D ''; - LBLine =3D 0; - LBOffset =3D 0; - DeclLine =3D 0; - DeclOffset =3D 0; + ModifierText =3D '' + DeclText =3D '' + LBLine =3D 0 + LBOffset =3D 0 + DeclLine =3D 0 + DeclOffset =3D 0 =20 - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 169 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,5,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 5, self._ctx) if la_ =3D=3D 1: self.state =3D 168 localctx.d =3D localctx._declaration_specifiers =3D self.d= eclaration_specifiers() =20 - self.state =3D 171 localctx._declarator =3D self.declarator() self.state =3D 180 @@ -1047,7 +1030,7 @@ class CParser ( Parser ): self.state =3D 175 self._errHandler.sync(self) _la =3D self._input.LA(1) - if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((= 1 << CParser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CPar= ser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10= ) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1= << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CP= arser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.= T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25)= | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 = << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CPa= rser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T= __35) | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.IDENTIFIER): + if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((= 1 << CParser.T__2) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << CPar= ser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T__10= ) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) | (1= << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 << CP= arser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CParser.= T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << CParser.T__25)= | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParser.T__28) | (1 = << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__31) | (1 << CPa= rser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (1 << CParser.T= __35) | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.IDENTIFIER): break =20 self.state =3D 177 @@ -1060,24 +1043,30 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - if localctx.d !=3D None: - ModifierText =3D (None if localctx._declaration_specifiers= is None else self._input.getText((localctx._declaration_specifiers.start,l= ocalctx._declaration_specifiers.stop))) + ModifierText =3D (None if localctx._declaration_specifiers= is None else self._input.getText( + (localctx._declaration_specifiers.start, localctx._dec= laration_specifiers.stop))) else: ModifierText =3D '' - DeclText =3D (None if localctx._declarator is None else self._= input.getText((localctx._declarator.start,localctx._declarator.stop))) - DeclLine =3D (None if localctx._declarator is None else localc= tx._declarator.start).line - DeclOffset =3D (None if localctx._declarator is None else loca= lctx._declarator.start).column + DeclText =3D (None if localctx._declarator is None else self._= input.getText( + (localctx._declarator.start, localctx._declarator.stop))) + DeclLine =3D ( + None if localctx._declarator is None else localctx._declar= ator.start).line + DeclOffset =3D ( + None if localctx._declarator is None else localctx._declar= ator.start).column if localctx.a !=3D None: LBLine =3D (None if localctx.a is None else localctx.a.sta= rt).line - LBOffset =3D (None if localctx.a is None else localctx.a.s= tart).column + LBOffset =3D ( + None if localctx.a is None else localctx.a.start).colu= mn else: LBLine =3D (None if localctx.b is None else localctx.b.sta= rt).line - LBOffset =3D (None if localctx.b is None else localctx.b.s= tart).column + LBOffset =3D ( + None if localctx.b is None else localctx.b.start).colu= mn =20 self._ctx.stop =3D self._input.LT(-1) =20 - self.StoreFunctionDefinition(localctx.start.line, localctx.sta= rt.column, localctx.stop.line, localctx.stop.column, ModifierText, DeclText= , LBLine, LBOffset, DeclLine, DeclOffset) + self.StoreFunctionDefinition(localctx.start.line, localctx.sta= rt.column, localctx.stop.line, + localctx.stop.column, ModifierTex= t, DeclText, LBLine, LBOffset, DeclLine, DeclOffset) =20 except RecognitionException as re: localctx.exception =3D re @@ -1091,60 +1080,55 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def storage_class_specifier(self,i=3DNone): + def storage_class_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Storage_class_spe= cifierContext) else: - return self.getTypedRuleContext(CParser.Storage_class_spec= ifierContext,i) - + return self.getTypedRuleContext(CParser.Storage_class_spec= ifierContext, i) =20 # @param i=3DNone Type: int - def type_specifier(self,i=3DNone): + def type_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_specifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_specifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_specifierCont= ext, i) =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_declaration_specifiers =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclaration_specifiers" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclaration_specifiers"): listener.enterDeclaration_specifiers(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclaration_specifiers" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclaration_specifiers"): listener.exitDeclaration_specifiers(self) =20 - - - def declaration_specifiers(self): =20 - localctx =3D CParser.Declaration_specifiersContext(self, self._ctx= , self.state) + localctx =3D CParser.Declaration_specifiersContext( + self, self._ctx, self.state) self.enterRule(localctx, 6, self.RULE_declaration_specifiers) try: self.enterOuterAlt(localctx, 1) self.state =3D 187 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 187 self._errHandler.sync(self) @@ -1164,12 +1148,11 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - else: raise NoViableAltException(self) self.state =3D 189 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,9,self._= ctx) + _alt =3D self._interp.adaptivePredict(self._input, 9, self= ._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -1183,46 +1166,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.a =3D None # Token - self.b =3D None # Declaration_specifiersContext - self.c =3D None # Init_declarator_listContext - self.d =3D None # Token - self.s =3D None # Declaration_specifiersContext - self.t =3D None # Init_declarator_listContext - self.e =3D None # Token + self.a =3D None # Token + self.b =3D None # Declaration_specifiersContext + self.c =3D None # Init_declarator_listContext + self.d =3D None # Token + self.s =3D None # Declaration_specifiersContext + self.t =3D None # Init_declarator_listContext + self.e =3D None # Token =20 def init_declarator_list(self): - return self.getTypedRuleContext(CParser.Init_declarator_listCo= ntext,0) - + return self.getTypedRuleContext(CParser.Init_declarator_listCo= ntext, 0) =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclaration"): listener.enterDeclaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclaration"): listener.exitDeclaration(self) =20 - - - def declaration(self): =20 localctx =3D CParser.DeclarationContext(self, self._ctx, self.stat= e) self.enterRule(localctx, 8, self.RULE_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 206 self._errHandler.sync(self) @@ -1233,21 +1211,22 @@ class CParser ( Parser ): localctx.a =3D self.match(CParser.T__2) self.state =3D 193 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,10,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 10, self= ._ctx) if la_ =3D=3D 1: self.state =3D 192 localctx.b =3D self.declaration_specifiers() =20 - self.state =3D 195 localctx.c =3D self.init_declarator_list() self.state =3D 196 localctx.d =3D self.match(CParser.T__1) =20 if localctx.b is not None: - self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , (None if localctx.b is None else self._input.getText((localctx.b.start,lo= calctx.b.stop))), (None if localctx.c is None else self._input.getText((loc= alctx.c.start,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , (None if localctx.b is None else self._input.getText( + (localctx.b.start, localctx.b.stop))), (None if lo= calctx.c is None else self._input.getText((localctx.c.start, localctx.c.sto= p)))) else: - self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column= , '', (None if localctx.c is None else self._input.getText((localctx.c.star= t,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.= a.column, (0 if localctx.d is None else localctx.d.line), + localctx.d.column, '', (No= ne if localctx.c is None else self._input.getText((localctx.c.start, localc= tx.c.stop)))) =20 pass elif token in [CParser.T__5, CParser.T__6, CParser.T__7, CPars= er.T__8, CParser.T__9, CParser.T__10, CParser.T__11, CParser.T__12, CParser= .T__13, CParser.T__14, CParser.T__15, CParser.T__16, CParser.T__17, CParser= .T__18, CParser.T__20, CParser.T__21, CParser.T__23, CParser.T__24, CParser= .T__25, CParser.T__26, CParser.T__27, CParser.T__28, CParser.T__29, CParser= .T__30, CParser.T__31, CParser.T__32, CParser.T__33, CParser.T__34, CParser= .T__35, CParser.T__36, CParser.IDENTIFIER]: @@ -1261,12 +1240,12 @@ class CParser ( Parser ): self.state =3D 200 localctx.t =3D self.init_declarator_list() =20 - self.state =3D 203 localctx.e =3D self.match(CParser.T__1) =20 if localctx.t is not None: - self.StoreVariableDeclaration((None if localctx.s is N= one else localctx.s.start).line, (None if localctx.s is None else localctx.= s.start).column, (None if localctx.t is None else localctx.t.start).line, (= None if localctx.t is None else localctx.t.start).column, (None if localctx= .s is None else self._input.getText((localctx.s.start,localctx.s.stop))), (= None if localctx.t is None else self._input.getText((localctx.t.start,local= ctx.t.stop)))) + self.StoreVariableDeclaration((None if localctx.s is N= one else localctx.s.start).line, (None if localctx.s is None else localctx.= s.start).column, (None if localctx.t is None else localctx.t.start).line, ( + None if localctx.t is None else localctx.t.start).= column, (None if localctx.s is None else self._input.getText((localctx.s.st= art, localctx.s.stop))), (None if localctx.t is None else self._input.getTe= xt((localctx.t.start, localctx.t.stop)))) =20 pass else: @@ -1284,39 +1263,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def init_declarator(self,i=3DNone): + def init_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Init_declaratorCo= ntext) else: - return self.getTypedRuleContext(CParser.Init_declaratorCon= text,i) - + return self.getTypedRuleContext(CParser.Init_declaratorCon= text, i) =20 def getRuleIndex(self): return CParser.RULE_init_declarator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInit_declarator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterInit_declarator_list"): listener.enterInit_declarator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInit_declarator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitInit_declarator_list"): listener.exitInit_declarator_list(self) =20 - - - def init_declarator_list(self): =20 - localctx =3D CParser.Init_declarator_listContext(self, self._ctx, = self.state) + localctx =3D CParser.Init_declarator_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 10, self.RULE_init_declarator_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 208 @@ -1324,7 +1300,7 @@ class CParser ( Parser ): self.state =3D 213 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 209 self.match(CParser.T__3) self.state =3D 210 @@ -1345,39 +1321,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def initializer(self): - return self.getTypedRuleContext(CParser.InitializerContext,0) - + return self.getTypedRuleContext(CParser.InitializerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_init_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInit_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterInit_declarator"): listener.enterInit_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInit_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitInit_declarator"): listener.exitInit_declarator(self) =20 - - - def init_declarator(self): =20 localctx =3D CParser.Init_declaratorContext(self, self._ctx, self.= state) self.enterRule(localctx, 12, self.RULE_init_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 216 @@ -1385,13 +1356,12 @@ class CParser ( Parser ): self.state =3D 219 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__4: + if _la =3D=3D CParser.T__4: self.state =3D 217 self.match(CParser.T__4) self.state =3D 218 self.initializer() =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1404,32 +1374,29 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_storage_class_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStorage_class_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterStorage_class_specifier"): listener.enterStorage_class_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStorage_class_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitStorage_class_specifier"): listener.exitStorage_class_specifier(self) =20 - - - def storage_class_specifier(self): =20 - localctx =3D CParser.Storage_class_specifierContext(self, self._ct= x, self.state) + localctx =3D CParser.Storage_class_specifierContext( + self, self._ctx, self.state) self.enterRule(localctx, 14, self.RULE_storage_class_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 221 @@ -1451,55 +1418,47 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.s =3D None # Struct_or_union_specifierContext - self.e =3D None # Enum_specifierContext + self.s =3D None # Struct_or_union_specifierContext + self.e =3D None # Enum_specifierContext =20 def struct_or_union_specifier(self): - return self.getTypedRuleContext(CParser.Struct_or_union_specif= ierContext,0) - + return self.getTypedRuleContext(CParser.Struct_or_union_specif= ierContext, 0) =20 def enum_specifier(self): - return self.getTypedRuleContext(CParser.Enum_specifierContext,= 0) - + return self.getTypedRuleContext(CParser.Enum_specifierContext,= 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def type_id(self): - return self.getTypedRuleContext(CParser.Type_idContext,0) - + return self.getTypedRuleContext(CParser.Type_idContext, 0) =20 def getRuleIndex(self): return CParser.RULE_type_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_specifier"): listener.enterType_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_specifier"): listener.exitType_specifier(self) =20 - - - def type_specifier(self): =20 localctx =3D CParser.Type_specifierContext(self, self._ctx, self.s= tate) @@ -1507,7 +1466,7 @@ class CParser ( Parser ): try: self.state =3D 247 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,16,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 16, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 223 @@ -1568,7 +1527,8 @@ class CParser ( Parser ): localctx.s =3D self.struct_or_union_specifier() =20 if localctx.s.stop is not None: - self.StoreStructUnionDefinition((None if localctx.s is= None else localctx.s.start).line, (None if localctx.s is None else localct= x.s.start).column, (None if localctx.s is None else localctx.s.stop).line, = (None if localctx.s is None else localctx.s.stop).column, (None if localctx= .s is None else self._input.getText((localctx.s.start,localctx.s.stop)))) + self.StoreStructUnionDefinition((None if localctx.s is= None else localctx.s.start).line, (None if localctx.s is None else localct= x.s.start).column, (None if localctx.s is None else localctx.s.stop).line, ( + None if localctx.s is None else localctx.s.stop).c= olumn, (None if localctx.s is None else self._input.getText((localctx.s.sta= rt, localctx.s.stop)))) =20 pass =20 @@ -1578,7 +1538,8 @@ class CParser ( Parser ): localctx.e =3D self.enum_specifier() =20 if localctx.e.stop is not None: - self.StoreEnumerationDefinition((None if localctx.e is= None else localctx.e.start).line, (None if localctx.e is None else localct= x.e.start).column, (None if localctx.e is None else localctx.e.stop).line, = (None if localctx.e is None else localctx.e.stop).column, (None if localctx= .e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StoreEnumerationDefinition((None if localctx.e is= None else localctx.e.start).line, (None if localctx.e is None else localct= x.e.start).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).c= olumn, (None if localctx.e is None else self._input.getText((localctx.e.sta= rt, localctx.e.stop)))) =20 pass =20 @@ -1588,14 +1549,15 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) self.state =3D 242 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,15,self.= _ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 15, sel= f._ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 239 self.type_qualifier() self.state =3D 244 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,15,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 15, self._ctx) =20 self.state =3D 245 self.declarator() @@ -1607,7 +1569,6 @@ class CParser ( Parser ): self.type_id() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1620,7 +1581,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -1631,18 +1592,15 @@ class CParser ( Parser ): return CParser.RULE_type_id =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_id" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_id"): listener.enterType_id(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_id" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_id"): listener.exitType_id(self) =20 - - - def type_id(self): =20 localctx =3D CParser.Type_idContext(self, self._ctx, self.state) @@ -1663,17 +1621,15 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def struct_or_union(self): - return self.getTypedRuleContext(CParser.Struct_or_unionContext= ,0) - + return self.getTypedRuleContext(CParser.Struct_or_unionContext= , 0) =20 def struct_declaration_list(self): - return self.getTypedRuleContext(CParser.Struct_declaration_lis= tContext,0) - + return self.getTypedRuleContext(CParser.Struct_declaration_lis= tContext, 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) @@ -1682,27 +1638,25 @@ class CParser ( Parser ): return CParser.RULE_struct_or_union_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_or_union_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_or_union_specifier"): listener.enterStruct_or_union_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_or_union_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_or_union_specifier"): listener.exitStruct_or_union_specifier(self) =20 - - - def struct_or_union_specifier(self): =20 - localctx =3D CParser.Struct_or_union_specifierContext(self, self._= ctx, self.state) + localctx =3D CParser.Struct_or_union_specifierContext( + self, self._ctx, self.state) self.enterRule(localctx, 20, self.RULE_struct_or_union_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 262 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,18,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 18, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 251 @@ -1710,11 +1664,10 @@ class CParser ( Parser ): self.state =3D 253 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.IDENTIFIER: + if _la =3D=3D CParser.IDENTIFIER: self.state =3D 252 self.match(CParser.IDENTIFIER) =20 - self.state =3D 255 self.match(CParser.T__0) self.state =3D 256 @@ -1731,7 +1684,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -1744,37 +1696,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_struct_or_union =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_or_union" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_or_union"): listener.enterStruct_or_union(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_or_union" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_or_union"): listener.exitStruct_or_union(self) =20 - - - def struct_or_union(self): =20 localctx =3D CParser.Struct_or_unionContext(self, self._ctx, self.= state) self.enterRule(localctx, 22, self.RULE_struct_or_union) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 264 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__20 or _la=3D=3DCParser.T__21): + if not(_la =3D=3D CParser.T__20 or _la =3D=3D CParser.T__21): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1791,39 +1739,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def struct_declaration(self,i=3DNone): + def struct_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Struct_declaratio= nContext) else: - return self.getTypedRuleContext(CParser.Struct_declaration= Context,i) - + return self.getTypedRuleContext(CParser.Struct_declaration= Context, i) =20 def getRuleIndex(self): return CParser.RULE_struct_declaration_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declaration_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declaration_list"): listener.enterStruct_declaration_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declaration_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declaration_list"): listener.exitStruct_declaration_list(self) =20 - - - def struct_declaration_list(self): =20 - localctx =3D CParser.Struct_declaration_listContext(self, self._ct= x, self.state) + localctx =3D CParser.Struct_declaration_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 24, self.RULE_struct_declaration_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 267 @@ -1835,7 +1780,7 @@ class CParser ( Parser ): self.state =3D 269 self._errHandler.sync(self) _la =3D self._input.LA(1) - if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 <<= CParser.T__10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CPars= er.T__13) | (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__= 16) | (1 << CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | = (1 << CParser.T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << = CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParse= r.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__3= 1) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (= 1 << CParser.T__35) | (1 << CParser.T__36))) !=3D 0) or _la=3D=3DCParser.ID= ENTIFIER): + if not ((((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 <<= CParser.T__10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CPars= er.T__13) | (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__= 16) | (1 << CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | = (1 << CParser.T__21) | (1 << CParser.T__23) | (1 << CParser.T__24) | (1 << = CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | (1 << CParse= r.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << CParser.T__3= 1) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParser.T__34) | (= 1 << CParser.T__35) | (1 << CParser.T__36))) !=3D 0) or _la =3D=3D CParser.= IDENTIFIER): break =20 except RecognitionException as re: @@ -1850,37 +1795,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def specifier_qualifier_list(self): - return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext,0) - + return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext, 0) =20 def struct_declarator_list(self): - return self.getTypedRuleContext(CParser.Struct_declarator_list= Context,0) - + return self.getTypedRuleContext(CParser.Struct_declarator_list= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_struct_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declaration"): listener.enterStruct_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declaration"): listener.exitStruct_declaration(self) =20 - - - def struct_declaration(self): =20 - localctx =3D CParser.Struct_declarationContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Struct_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 26, self.RULE_struct_declaration) try: self.enterOuterAlt(localctx, 1) @@ -1902,52 +1843,48 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 # @param i=3DNone Type: int - def type_specifier(self,i=3DNone): + def type_specifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_specifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_specifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_specifierCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_specifier_qualifier_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterSpecifier_qualifier_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterSpecifier_qualifier_list"): listener.enterSpecifier_qualifier_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitSpecifier_qualifier_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitSpecifier_qualifier_list"): listener.exitSpecifier_qualifier_list(self) =20 - - - def specifier_qualifier_list(self): =20 - localctx =3D CParser.Specifier_qualifier_listContext(self, self._c= tx, self.state) + localctx =3D CParser.Specifier_qualifier_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 28, self.RULE_specifier_qualifier_list) try: self.enterOuterAlt(localctx, 1) self.state =3D 277 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 277 self._errHandler.sync(self) @@ -1963,12 +1900,11 @@ class CParser ( Parser ): else: raise NoViableAltException(self) =20 - else: raise NoViableAltException(self) self.state =3D 279 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,21,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 21, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -1982,39 +1918,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def struct_declarator(self,i=3DNone): + def struct_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Struct_declarator= Context) else: - return self.getTypedRuleContext(CParser.Struct_declaratorC= ontext,i) - + return self.getTypedRuleContext(CParser.Struct_declaratorC= ontext, i) =20 def getRuleIndex(self): return CParser.RULE_struct_declarator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declarator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declarator_list"): listener.enterStruct_declarator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declarator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declarator_list"): listener.exitStruct_declarator_list(self) =20 - - - def struct_declarator_list(self): =20 - localctx =3D CParser.Struct_declarator_listContext(self, self._ctx= , self.state) + localctx =3D CParser.Struct_declarator_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 30, self.RULE_struct_declarator_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 281 @@ -2022,7 +1955,7 @@ class CParser ( Parser ): self.state =3D 286 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 282 self.match(CParser.T__3) self.state =3D 283 @@ -2043,39 +1976,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_struct_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStruct_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterStruct_declarator"): listener.enterStruct_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStruct_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitStruct_declarator"): listener.exitStruct_declarator(self) =20 - - - def struct_declarator(self): =20 - localctx =3D CParser.Struct_declaratorContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Struct_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 32, self.RULE_struct_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 296 self._errHandler.sync(self) @@ -2087,13 +2016,12 @@ class CParser ( Parser ): self.state =3D 292 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__22: + if _la =3D=3D CParser.T__22: self.state =3D 290 self.match(CParser.T__22) self.state =3D 291 self.constant_expression() =20 - pass elif token in [CParser.T__22]: self.enterOuterAlt(localctx, 2) @@ -2117,13 +2045,12 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def enumerator_list(self): - return self.getTypedRuleContext(CParser.Enumerator_listContext= ,0) - + return self.getTypedRuleContext(CParser.Enumerator_listContext= , 0) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) @@ -2132,27 +2059,24 @@ class CParser ( Parser ): return CParser.RULE_enum_specifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnum_specifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnum_specifier"): listener.enterEnum_specifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnum_specifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnum_specifier"): listener.exitEnum_specifier(self) =20 - - - def enum_specifier(self): =20 localctx =3D CParser.Enum_specifierContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 34, self.RULE_enum_specifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 317 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,27,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 27, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 298 @@ -2164,11 +2088,10 @@ class CParser ( Parser ): self.state =3D 302 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 301 self.match(CParser.T__3) =20 - self.state =3D 304 self.match(CParser.T__19) pass @@ -2186,11 +2109,10 @@ class CParser ( Parser ): self.state =3D 311 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 310 self.match(CParser.T__3) =20 - self.state =3D 313 self.match(CParser.T__19) pass @@ -2203,7 +2125,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2216,34 +2137,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def enumerator(self,i=3DNone): + def enumerator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.EnumeratorContext) else: - return self.getTypedRuleContext(CParser.EnumeratorContext,= i) - + return self.getTypedRuleContext(CParser.EnumeratorContext,= i) =20 def getRuleIndex(self): return CParser.RULE_enumerator_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnumerator_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnumerator_list"): listener.enterEnumerator_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnumerator_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnumerator_list"): listener.exitEnumerator_list(self) =20 - - - def enumerator_list(self): =20 localctx =3D CParser.Enumerator_listContext(self, self._ctx, self.= state) @@ -2254,16 +2171,16 @@ class CParser ( Parser ): self.enumerator() self.state =3D 324 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,28,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 28, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 320 self.match(CParser.T__3) self.state =3D 321 self.enumerator() self.state =3D 326 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,28,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 28, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -2277,7 +2194,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -2285,30 +2202,26 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_enumerator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEnumerator" ): + def enterRule(self, listener): + if hasattr(listener, "enterEnumerator"): listener.enterEnumerator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEnumerator" ): + def exitRule(self, listener): + if hasattr(listener, "exitEnumerator"): listener.exitEnumerator(self) =20 - - - def enumerator(self): =20 localctx =3D CParser.EnumeratorContext(self, self._ctx, self.state) self.enterRule(localctx, 38, self.RULE_enumerator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 327 @@ -2316,13 +2229,12 @@ class CParser ( Parser ): self.state =3D 330 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__4: + if _la =3D=3D CParser.T__4: self.state =3D 328 self.match(CParser.T__4) self.state =3D 329 self.constant_expression() =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2335,32 +2247,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_type_qualifier =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_qualifier" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_qualifier"): listener.enterType_qualifier(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_qualifier" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_qualifier"): listener.exitType_qualifier(self) =20 - - - def type_qualifier(self): =20 localctx =3D CParser.Type_qualifierContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 40, self.RULE_type_qualifier) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 332 @@ -2382,77 +2290,68 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def direct_declarator(self): - return self.getTypedRuleContext(CParser.Direct_declaratorConte= xt,0) - + return self.getTypedRuleContext(CParser.Direct_declaratorConte= xt, 0) =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclarator"): listener.enterDeclarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclarator"): listener.exitDeclarator(self) =20 - - - def declarator(self): =20 localctx =3D CParser.DeclaratorContext(self, self._ctx, self.state) self.enterRule(localctx, 42, self.RULE_declarator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 348 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,34,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 34, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 335 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__41: + if _la =3D=3D CParser.T__41: self.state =3D 334 self.pointer() =20 - self.state =3D 338 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__33: + if _la =3D=3D CParser.T__33: self.state =3D 337 self.match(CParser.T__33) =20 - self.state =3D 341 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__34: + if _la =3D=3D CParser.T__34: self.state =3D 340 self.match(CParser.T__34) =20 - self.state =3D 344 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__35: + if _la =3D=3D CParser.T__35: self.state =3D 343 self.match(CParser.T__35) =20 - self.state =3D 346 self.direct_declarator() pass @@ -2463,7 +2362,6 @@ class CParser ( Parser ): self.pointer() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2476,7 +2374,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -2484,36 +2382,32 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def declarator_suffix(self,i=3DNone): + def declarator_suffix(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Declarator_suffix= Context) else: - return self.getTypedRuleContext(CParser.Declarator_suffixC= ontext,i) - + return self.getTypedRuleContext(CParser.Declarator_suffixC= ontext, i) =20 def declarator(self): - return self.getTypedRuleContext(CParser.DeclaratorContext,0) - + return self.getTypedRuleContext(CParser.DeclaratorContext, 0) =20 def getRuleIndex(self): return CParser.RULE_direct_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDirect_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDirect_declarator"): listener.enterDirect_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDirect_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDirect_declarator"): listener.exitDirect_declarator(self) =20 - - - def direct_declarator(self): =20 - localctx =3D CParser.Direct_declaratorContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Direct_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 44, self.RULE_direct_declarator) try: self.state =3D 368 @@ -2525,14 +2419,15 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) self.state =3D 354 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,35,self.= _ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 35, sel= f._ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 351 self.declarator_suffix() self.state =3D 356 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,35,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 35, self._ctx) =20 pass elif token in [CParser.T__37]: @@ -2541,12 +2436,11 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 359 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,36,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 36, self= ._ctx) if la_ =3D=3D 1: self.state =3D 358 self.match(CParser.T__33) =20 - self.state =3D 361 self.declarator() self.state =3D 362 @@ -2554,7 +2448,7 @@ class CParser ( Parser ): self.state =3D 364 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 363 self.declarator_suffix() @@ -2563,7 +2457,8 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 366 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,37,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 37, self._ctx) =20 pass else: @@ -2581,46 +2476,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def parameter_type_list(self): - return self.getTypedRuleContext(CParser.Parameter_type_listCon= text,0) - + return self.getTypedRuleContext(CParser.Parameter_type_listCon= text, 0) =20 def identifier_list(self): - return self.getTypedRuleContext(CParser.Identifier_listContext= ,0) - + return self.getTypedRuleContext(CParser.Identifier_listContext= , 0) =20 def getRuleIndex(self): return CParser.RULE_declarator_suffix =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDeclarator_suffix" ): + def enterRule(self, listener): + if hasattr(listener, "enterDeclarator_suffix"): listener.enterDeclarator_suffix(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDeclarator_suffix" ): + def exitRule(self, listener): + if hasattr(listener, "exitDeclarator_suffix"): listener.exitDeclarator_suffix(self) =20 - - - def declarator_suffix(self): =20 - localctx =3D CParser.Declarator_suffixContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Declarator_suffixContext( + self, self._ctx, self.state) self.enterRule(localctx, 46, self.RULE_declarator_suffix) try: self.state =3D 386 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,39,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 39, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 370 @@ -2667,7 +2557,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2680,38 +2569,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def type_qualifier(self,i=3DNone): + def type_qualifier(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Type_qualifierCon= text) else: - return self.getTypedRuleContext(CParser.Type_qualifierCont= ext,i) - + return self.getTypedRuleContext(CParser.Type_qualifierCont= ext, i) =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def getRuleIndex(self): return CParser.RULE_pointer =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPointer" ): + def enterRule(self, listener): + if hasattr(listener, "enterPointer"): listener.enterPointer(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPointer" ): + def exitRule(self, listener): + if hasattr(listener, "exitPointer"): listener.exitPointer(self) =20 - - - def pointer(self): =20 localctx =3D CParser.PointerContext(self, self._ctx, self.state) @@ -2719,7 +2603,7 @@ class CParser ( Parser ): try: self.state =3D 400 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,42,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 42, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 388 @@ -2727,7 +2611,7 @@ class CParser ( Parser ): self.state =3D 390 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 389 self.type_qualifier() @@ -2736,16 +2620,16 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 392 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,40,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 40, self._ctx) =20 self.state =3D 395 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,41,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 41, self= ._ctx) if la_ =3D=3D 1: self.state =3D 394 self.pointer() =20 - pass =20 elif la_ =3D=3D 2: @@ -2762,7 +2646,6 @@ class CParser ( Parser ): self.match(CParser.T__41) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2775,35 +2658,32 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def parameter_list(self): - return self.getTypedRuleContext(CParser.Parameter_listContext,= 0) - + return self.getTypedRuleContext(CParser.Parameter_listContext,= 0) =20 def getRuleIndex(self): return CParser.RULE_parameter_type_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_type_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_type_list"): listener.enterParameter_type_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_type_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_type_list"): listener.exitParameter_type_list(self) =20 - - - def parameter_type_list(self): =20 - localctx =3D CParser.Parameter_type_listContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Parameter_type_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 50, self.RULE_parameter_type_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 402 @@ -2811,21 +2691,19 @@ class CParser ( Parser ): self.state =3D 408 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 403 self.match(CParser.T__3) self.state =3D 405 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 404 self.match(CParser.T__28) =20 - self.state =3D 407 self.match(CParser.T__42) =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -2838,34 +2716,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def parameter_declaration(self,i=3DNone): + def parameter_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Parameter_declara= tionContext) else: - return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext,i) - + return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_parameter_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_list"): listener.enterParameter_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_list"): listener.exitParameter_list(self) =20 - - - def parameter_list(self): =20 localctx =3D CParser.Parameter_listContext(self, self._ctx, self.s= tate) @@ -2876,24 +2750,24 @@ class CParser ( Parser ): self.parameter_declaration() self.state =3D 418 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,46,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 46, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 411 self.match(CParser.T__3) self.state =3D 413 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,45,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 45, self._ctx) if la_ =3D=3D 1: self.state =3D 412 self.match(CParser.T__28) =20 - self.state =3D 415 self.parameter_declaration() self.state =3D 420 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,46,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 46, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -2907,66 +2781,60 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def declaration_specifiers(self): - return self.getTypedRuleContext(CParser.Declaration_specifiers= Context,0) - + return self.getTypedRuleContext(CParser.Declaration_specifiers= Context, 0) =20 # @param i=3DNone Type: int - def declarator(self,i=3DNone): + def declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclaratorContext) else: - return self.getTypedRuleContext(CParser.DeclaratorContext,= i) - + return self.getTypedRuleContext(CParser.DeclaratorContext,= i) =20 # @param i=3DNone Type: int - def abstract_declarator(self,i=3DNone): + def abstract_declarator(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Abstract_declarat= orContext) else: - return self.getTypedRuleContext(CParser.Abstract_declarato= rContext,i) - + return self.getTypedRuleContext(CParser.Abstract_declarato= rContext, i) =20 def IDENTIFIER(self): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def pointer(self,i=3DNone): + def pointer(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.PointerContext) else: - return self.getTypedRuleContext(CParser.PointerContext,i) - + return self.getTypedRuleContext(CParser.PointerContext, i) =20 def getRuleIndex(self): return CParser.RULE_parameter_declaration =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterParameter_declaration" ): + def enterRule(self, listener): + if hasattr(listener, "enterParameter_declaration"): listener.enterParameter_declaration(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitParameter_declaration" ): + def exitRule(self, listener): + if hasattr(listener, "exitParameter_declaration"): listener.exitParameter_declaration(self) =20 - - - def parameter_declaration(self): =20 - localctx =3D CParser.Parameter_declarationContext(self, self._ctx,= self.state) + localctx =3D CParser.Parameter_declarationContext( + self, self._ctx, self.state) self.enterRule(localctx, 54, self.RULE_parameter_declaration) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 439 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,51,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 51, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 421 @@ -2977,7 +2845,8 @@ class CParser ( Parser ): while ((((_la - 34)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 3= 4)) & ((1 << (CParser.T__33 - 34)) | (1 << (CParser.T__34 - 34)) | (1 << (C= Parser.T__35 - 34)) | (1 << (CParser.T__37 - 34)) | (1 << (CParser.T__39 - = 34)) | (1 << (CParser.T__41 - 34)) | (1 << (CParser.IDENTIFIER - 34)))) != =3D 0): self.state =3D 424 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,47,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 47, self._ctx) if la_ =3D=3D 1: self.state =3D 422 self.declarator() @@ -2988,7 +2857,6 @@ class CParser ( Parser ): self.abstract_declarator() pass =20 - self.state =3D 428 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -2996,11 +2864,10 @@ class CParser ( Parser ): self.state =3D 430 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 429 self.match(CParser.T__28) =20 - pass =20 elif la_ =3D=3D 2: @@ -3008,7 +2875,7 @@ class CParser ( Parser ): self.state =3D 435 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__41: + while _la =3D=3D CParser.T__41: self.state =3D 432 self.pointer() self.state =3D 437 @@ -3019,7 +2886,6 @@ class CParser ( Parser ): self.match(CParser.IDENTIFIER) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3032,12 +2898,12 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: @@ -3047,23 +2913,20 @@ class CParser ( Parser ): return CParser.RULE_identifier_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterIdentifier_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterIdentifier_list"): listener.enterIdentifier_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitIdentifier_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitIdentifier_list"): listener.exitIdentifier_list(self) =20 - - - def identifier_list(self): =20 localctx =3D CParser.Identifier_listContext(self, self._ctx, self.= state) self.enterRule(localctx, 56, self.RULE_identifier_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 441 @@ -3071,7 +2934,7 @@ class CParser ( Parser ): self.state =3D 446 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 442 self.match(CParser.T__3) self.state =3D 443 @@ -3092,47 +2955,41 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def specifier_qualifier_list(self): - return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext,0) - + return self.getTypedRuleContext(CParser.Specifier_qualifier_li= stContext, 0) =20 def abstract_declarator(self): - return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text,0) - + return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text, 0) =20 def type_id(self): - return self.getTypedRuleContext(CParser.Type_idContext,0) - + return self.getTypedRuleContext(CParser.Type_idContext, 0) =20 def getRuleIndex(self): return CParser.RULE_type_name =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterType_name" ): + def enterRule(self, listener): + if hasattr(listener, "enterType_name"): listener.enterType_name(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitType_name" ): + def exitRule(self, listener): + if hasattr(listener, "exitType_name"): listener.exitType_name(self) =20 - - - def type_name(self): =20 localctx =3D CParser.Type_nameContext(self, self._ctx, self.state) self.enterRule(localctx, 58, self.RULE_type_name) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 454 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,54,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 54, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 449 @@ -3144,7 +3001,6 @@ class CParser ( Parser ): self.state =3D 450 self.abstract_declarator() =20 - pass =20 elif la_ =3D=3D 2: @@ -3153,7 +3009,6 @@ class CParser ( Parser ): self.type_id() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3166,37 +3021,33 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def pointer(self): - return self.getTypedRuleContext(CParser.PointerContext,0) - + return self.getTypedRuleContext(CParser.PointerContext, 0) =20 def direct_abstract_declarator(self): - return self.getTypedRuleContext(CParser.Direct_abstract_declar= atorContext,0) - + return self.getTypedRuleContext(CParser.Direct_abstract_declar= atorContext, 0) =20 def getRuleIndex(self): return CParser.RULE_abstract_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAbstract_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterAbstract_declarator"): listener.enterAbstract_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAbstract_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitAbstract_declarator"): listener.exitAbstract_declarator(self) =20 - - - def abstract_declarator(self): =20 - localctx =3D CParser.Abstract_declaratorContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Abstract_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 60, self.RULE_abstract_declarator) try: self.state =3D 461 @@ -3208,12 +3059,11 @@ class CParser ( Parser ): self.pointer() self.state =3D 458 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,55,self._= ctx) + la_ =3D self._interp.adaptivePredict(self._input, 55, self= ._ctx) if la_ =3D=3D 1: self.state =3D 457 self.direct_abstract_declarator() =20 - pass elif token in [CParser.T__37, CParser.T__39]: self.enterOuterAlt(localctx, 2) @@ -3235,46 +3085,43 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def abstract_declarator(self): - return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text,0) - + return self.getTypedRuleContext(CParser.Abstract_declaratorCon= text, 0) =20 # @param i=3DNone Type: int - def abstract_declarator_suffix(self,i=3DNone): + def abstract_declarator_suffix(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Abstract_declarat= or_suffixContext) else: - return self.getTypedRuleContext(CParser.Abstract_declarato= r_suffixContext,i) - + return self.getTypedRuleContext(CParser.Abstract_declarato= r_suffixContext, i) =20 def getRuleIndex(self): return CParser.RULE_direct_abstract_declarator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterDirect_abstract_declarator" ): + def enterRule(self, listener): + if hasattr(listener, "enterDirect_abstract_declarator"): listener.enterDirect_abstract_declarator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitDirect_abstract_declarator" ): + def exitRule(self, listener): + if hasattr(listener, "exitDirect_abstract_declarator"): listener.exitDirect_abstract_declarator(self) =20 - - def direct_abstract_declarator(self): =20 - localctx =3D CParser.Direct_abstract_declaratorContext(self, self.= _ctx, self.state) + localctx =3D CParser.Direct_abstract_declaratorContext( + self, self._ctx, self.state) self.enterRule(localctx, 62, self.RULE_direct_abstract_declarator) try: self.enterOuterAlt(localctx, 1) self.state =3D 468 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,57,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 57, self._ct= x) if la_ =3D=3D 1: self.state =3D 463 self.match(CParser.T__37) @@ -3289,17 +3136,16 @@ class CParser ( Parser ): self.abstract_declarator_suffix() pass =20 - self.state =3D 473 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,58,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 58, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 470 self.abstract_declarator_suffix() self.state =3D 475 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,58,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 58, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -3313,42 +3159,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def parameter_type_list(self): - return self.getTypedRuleContext(CParser.Parameter_type_listCon= text,0) - + return self.getTypedRuleContext(CParser.Parameter_type_listCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_abstract_declarator_suffix =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAbstract_declarator_suffix" ): + def enterRule(self, listener): + if hasattr(listener, "enterAbstract_declarator_suffix"): listener.enterAbstract_declarator_suffix(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAbstract_declarator_suffix" ): + def exitRule(self, listener): + if hasattr(listener, "exitAbstract_declarator_suffix"): listener.exitAbstract_declarator_suffix(self) =20 - - - def abstract_declarator_suffix(self): =20 - localctx =3D CParser.Abstract_declarator_suffixContext(self, self.= _ctx, self.state) + localctx =3D CParser.Abstract_declarator_suffixContext( + self, self._ctx, self.state) self.enterRule(localctx, 64, self.RULE_abstract_declarator_suffix) try: self.state =3D 488 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,59,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 59, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 476 @@ -3385,7 +3227,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3398,39 +3239,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def assignment_expression(self): - return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext, 0) =20 def initializer_list(self): - return self.getTypedRuleContext(CParser.Initializer_listContex= t,0) - + return self.getTypedRuleContext(CParser.Initializer_listContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_initializer =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInitializer" ): + def enterRule(self, listener): + if hasattr(listener, "enterInitializer"): listener.enterInitializer(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInitializer" ): + def exitRule(self, listener): + if hasattr(listener, "exitInitializer"): listener.exitInitializer(self) =20 - - - def initializer(self): =20 localctx =3D CParser.InitializerContext(self, self._ctx, self.stat= e) self.enterRule(localctx, 66, self.RULE_initializer) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 498 self._errHandler.sync(self) @@ -3449,11 +3285,10 @@ class CParser ( Parser ): self.state =3D 494 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__3: + if _la =3D=3D CParser.T__3: self.state =3D 493 self.match(CParser.T__3) =20 - self.state =3D 496 self.match(CParser.T__19) pass @@ -3472,34 +3307,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def initializer(self,i=3DNone): + def initializer(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.InitializerContex= t) else: - return self.getTypedRuleContext(CParser.InitializerContext= ,i) - + return self.getTypedRuleContext(CParser.InitializerContext= , i) =20 def getRuleIndex(self): return CParser.RULE_initializer_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInitializer_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterInitializer_list"): listener.enterInitializer_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInitializer_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitInitializer_list"): listener.exitInitializer_list(self) =20 - - - def initializer_list(self): =20 localctx =3D CParser.Initializer_listContext(self, self._ctx, self= .state) @@ -3510,16 +3341,16 @@ class CParser ( Parser ): self.initializer() self.state =3D 505 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,62,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 62, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 501 self.match(CParser.T__3) self.state =3D 502 self.initializer() self.state =3D 507 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,62,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 62, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -3533,39 +3364,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def assignment_expression(self,i=3DNone): + def assignment_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Assignment_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Assignment_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Assignment_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_argument_expression_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterArgument_expression_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterArgument_expression_list"): listener.enterArgument_expression_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitArgument_expression_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitArgument_expression_list"): listener.exitArgument_expression_list(self) =20 - - - def argument_expression_list(self): =20 - localctx =3D CParser.Argument_expression_listContext(self, self._c= tx, self.state) + localctx =3D CParser.Argument_expression_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 70, self.RULE_argument_expression_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 508 @@ -3573,15 +3401,14 @@ class CParser ( Parser ): self.state =3D 510 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 509 self.match(CParser.T__28) =20 - self.state =3D 519 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 512 self.match(CParser.T__3) self.state =3D 513 @@ -3589,11 +3416,10 @@ class CParser ( Parser ): self.state =3D 515 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__28: + if _la =3D=3D CParser.T__28: self.state =3D 514 self.match(CParser.T__28) =20 - self.state =3D 521 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -3610,39 +3436,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def multiplicative_expression(self,i=3DNone): + def multiplicative_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Multiplicative_ex= pressionContext) else: - return self.getTypedRuleContext(CParser.Multiplicative_exp= ressionContext,i) - + return self.getTypedRuleContext(CParser.Multiplicative_exp= ressionContext, i) =20 def getRuleIndex(self): return CParser.RULE_additive_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAdditive_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAdditive_expression"): listener.enterAdditive_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAdditive_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAdditive_expression"): listener.exitAdditive_expression(self) =20 - - - def additive_expression(self): =20 - localctx =3D CParser.Additive_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Additive_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 72, self.RULE_additive_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 522 @@ -3650,7 +3473,7 @@ class CParser ( Parser ): self.state =3D 529 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__43 or _la=3D=3DCParser.T__44: + while _la =3D=3D CParser.T__43 or _la =3D=3D CParser.T__44: self.state =3D 527 self._errHandler.sync(self) token =3D self._input.LA(1) @@ -3685,39 +3508,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def cast_expression(self,i=3DNone): + def cast_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Cast_expressionCo= ntext) else: - return self.getTypedRuleContext(CParser.Cast_expressionCon= text,i) - + return self.getTypedRuleContext(CParser.Cast_expressionCon= text, i) =20 def getRuleIndex(self): return CParser.RULE_multiplicative_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMultiplicative_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterMultiplicative_expression"): listener.enterMultiplicative_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMultiplicative_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitMultiplicative_expression"): listener.exitMultiplicative_expression(self) =20 - - - def multiplicative_expression(self): =20 - localctx =3D CParser.Multiplicative_expressionContext(self, self._= ctx, self.state) + localctx =3D CParser.Multiplicative_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 74, self.RULE_multiplicative_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 532 @@ -3766,38 +3586,32 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def type_name(self): - return self.getTypedRuleContext(CParser.Type_nameContext,0) - + return self.getTypedRuleContext(CParser.Type_nameContext, 0) =20 def cast_expression(self): - return self.getTypedRuleContext(CParser.Cast_expressionContext= ,0) - + return self.getTypedRuleContext(CParser.Cast_expressionContext= , 0) =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_cast_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterCast_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterCast_expression"): listener.enterCast_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitCast_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitCast_expression"): listener.exitCast_expression(self) =20 - - - def cast_expression(self): =20 localctx =3D CParser.Cast_expressionContext(self, self._ctx, self.= state) @@ -3805,7 +3619,7 @@ class CParser ( Parser ): try: self.state =3D 550 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,70,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 70, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 544 @@ -3824,7 +3638,6 @@ class CParser ( Parser ): self.unary_expression() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3837,46 +3650,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def postfix_expression(self): - return self.getTypedRuleContext(CParser.Postfix_expressionCont= ext,0) - + return self.getTypedRuleContext(CParser.Postfix_expressionCont= ext, 0) =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def unary_operator(self): - return self.getTypedRuleContext(CParser.Unary_operatorContext,= 0) - + return self.getTypedRuleContext(CParser.Unary_operatorContext,= 0) =20 def cast_expression(self): - return self.getTypedRuleContext(CParser.Cast_expressionContext= ,0) - + return self.getTypedRuleContext(CParser.Cast_expressionContext= , 0) =20 def type_name(self): - return self.getTypedRuleContext(CParser.Type_nameContext,0) - + return self.getTypedRuleContext(CParser.Type_nameContext, 0) =20 def getRuleIndex(self): return CParser.RULE_unary_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterUnary_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterUnary_expression"): listener.enterUnary_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitUnary_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitUnary_expression"): listener.exitUnary_expression(self) =20 - - - def unary_expression(self): =20 localctx =3D CParser.Unary_expressionContext(self, self._ctx, self= .state) @@ -3884,7 +3689,7 @@ class CParser ( Parser ): try: self.state =3D 567 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,71,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 71, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 552 @@ -3935,7 +3740,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -3948,48 +3752,44 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser self.FuncCallText =3D '' - self.p =3D None # Primary_expressionContext - self.a =3D None # Token - self.c =3D None # Argument_expression_listContext - self.b =3D None # Token - self.x =3D None # Token - self.y =3D None # Token - self.z =3D None # Token + self.p =3D None # Primary_expressionContext + self.a =3D None # Token + self.c =3D None # Argument_expression_listContext + self.b =3D None # Token + self.x =3D None # Token + self.y =3D None # Token + self.z =3D None # Token =20 def primary_expression(self): - return self.getTypedRuleContext(CParser.Primary_expressionCont= ext,0) - + return self.getTypedRuleContext(CParser.Primary_expressionCont= ext, 0) =20 # @param i=3DNone Type: int - def expression(self,i=3DNone): + def expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.ExpressionContext) else: - return self.getTypedRuleContext(CParser.ExpressionContext,= i) - + return self.getTypedRuleContext(CParser.ExpressionContext,= i) =20 # @param i=3DNone Type: int - def macro_parameter_list(self,i=3DNone): + def macro_parameter_list(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Macro_parameter_l= istContext) else: - return self.getTypedRuleContext(CParser.Macro_parameter_li= stContext,i) - + return self.getTypedRuleContext(CParser.Macro_parameter_li= stContext, i) =20 # @param i=3DNone Type: int - def argument_expression_list(self,i=3DNone): + def argument_expression_list(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Argument_expressi= on_listContext) else: - return self.getTypedRuleContext(CParser.Argument_expressio= n_listContext,i) - + return self.getTypedRuleContext(CParser.Argument_expressio= n_listContext, i) =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: @@ -3999,38 +3799,38 @@ class CParser ( Parser ): return CParser.RULE_postfix_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPostfix_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterPostfix_expression"): listener.enterPostfix_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPostfix_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitPostfix_expression"): listener.exitPostfix_expression(self) =20 - - - def postfix_expression(self): =20 - localctx =3D CParser.Postfix_expressionContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Postfix_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 80, self.RULE_postfix_expression) =20 - self.FuncCallText=3D'' + self.FuncCallText =3D '' =20 try: self.enterOuterAlt(localctx, 1) self.state =3D 569 localctx.p =3D self.primary_expression() - self.FuncCallText +=3D (None if localctx.p is None else self._= input.getText((localctx.p.start,localctx.p.stop))) + self.FuncCallText +=3D (None if localctx.p is None else self._= input.getText( + (localctx.p.start, localctx.p.stop))) self.state =3D 600 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,73,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 73, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 598 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,72,se= lf._ctx) + la_ =3D self._interp.adaptivePredict( + self._input, 72, self._ctx) if la_ =3D=3D 1: self.state =3D 571 self.match(CParser.T__39) @@ -4045,7 +3845,8 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 576 localctx.a =3D self.match(CParser.T__38) - self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, (0 if localctx.a is None else localctx.a.line), localctx.a= .column, self.FuncCallText, '') + self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, ( + 0 if localctx.a is None else localctx.a.line),= localctx.a.column, self.FuncCallText, '') pass =20 elif la_ =3D=3D 3: @@ -4055,7 +3856,8 @@ class CParser ( Parser ): localctx.c =3D self.argument_expression_list() self.state =3D 580 localctx.b =3D self.match(CParser.T__38) - self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, (0 if localctx.b is None else localctx.b.line), localctx.b= .column, self.FuncCallText, (None if localctx.c is None else self._input.ge= tText((localctx.c.start,localctx.c.stop)))) + self.StoreFunctionCalling((None if localctx.p is N= one else localctx.p.start).line, (None if localctx.p is None else localctx.= p.start).column, ( + 0 if localctx.b is None else localctx.b.line),= localctx.b.column, self.FuncCallText, (None if localctx.c is None else sel= f._input.getText((localctx.c.start, localctx.c.stop)))) pass =20 elif la_ =3D=3D 4: @@ -4072,7 +3874,8 @@ class CParser ( Parser ): self.match(CParser.T__50) self.state =3D 588 localctx.x =3D self.match(CParser.IDENTIFIER) - self.FuncCallText +=3D '.' + (None if localctx.x i= s None else localctx.x.text) + self.FuncCallText +=3D '.' + \ + (None if localctx.x is None else localctx.x.te= xt) pass =20 elif la_ =3D=3D 6: @@ -4080,7 +3883,8 @@ class CParser ( Parser ): self.match(CParser.T__41) self.state =3D 591 localctx.y =3D self.match(CParser.IDENTIFIER) - self.FuncCallText =3D (None if localctx.y is None = else localctx.y.text) + self.FuncCallText =3D ( + None if localctx.y is None else localctx.y.tex= t) pass =20 elif la_ =3D=3D 7: @@ -4088,7 +3892,8 @@ class CParser ( Parser ): self.match(CParser.T__51) self.state =3D 594 localctx.z =3D self.match(CParser.IDENTIFIER) - self.FuncCallText +=3D '->' + (None if localctx.z = is None else localctx.z.text) + self.FuncCallText +=3D '->' + \ + (None if localctx.z is None else localctx.z.te= xt) pass =20 elif la_ =3D=3D 8: @@ -4101,10 +3906,9 @@ class CParser ( Parser ): self.match(CParser.T__48) pass =20 - self.state =3D 602 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,73,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 73, sel= f._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -4118,39 +3922,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def parameter_declaration(self,i=3DNone): + def parameter_declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Parameter_declara= tionContext) else: - return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext,i) - + return self.getTypedRuleContext(CParser.Parameter_declarat= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_macro_parameter_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMacro_parameter_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterMacro_parameter_list"): listener.enterMacro_parameter_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMacro_parameter_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitMacro_parameter_list"): listener.exitMacro_parameter_list(self) =20 - - - def macro_parameter_list(self): =20 - localctx =3D CParser.Macro_parameter_listContext(self, self._ctx, = self.state) + localctx =3D CParser.Macro_parameter_listContext( + self, self._ctx, self.state) self.enterRule(localctx, 82, self.RULE_macro_parameter_list) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 603 @@ -4158,7 +3959,7 @@ class CParser ( Parser ): self.state =3D 608 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 604 self.match(CParser.T__3) self.state =3D 605 @@ -4179,32 +3980,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_unary_operator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterUnary_operator" ): + def enterRule(self, listener): + if hasattr(listener, "enterUnary_operator"): listener.enterUnary_operator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitUnary_operator" ): + def exitRule(self, listener): + if hasattr(listener, "exitUnary_operator"): listener.exitUnary_operator(self) =20 - - - def unary_operator(self): =20 localctx =3D CParser.Unary_operatorContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 84, self.RULE_unary_operator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 611 @@ -4226,7 +4023,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -4234,37 +4031,33 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def constant(self): - return self.getTypedRuleContext(CParser.ConstantContext,0) - + return self.getTypedRuleContext(CParser.ConstantContext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_primary_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterPrimary_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterPrimary_expression"): listener.enterPrimary_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitPrimary_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitPrimary_expression"): listener.exitPrimary_expression(self) =20 - - - def primary_expression(self): =20 - localctx =3D CParser.Primary_expressionContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Primary_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 86, self.RULE_primary_expression) try: self.state =3D 619 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,75,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 75, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 613 @@ -4287,7 +4080,6 @@ class CParser ( Parser ): self.match(CParser.T__38) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -4300,7 +4092,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -4317,14 +4109,14 @@ class CParser ( Parser ): return self.getToken(CParser.CHARACTER_LITERAL, 0) =20 # @param i=3DNone Type: int - def IDENTIFIER(self,i=3DNone): + def IDENTIFIER(self, i=3DNone): if i is None: return self.getTokens(CParser.IDENTIFIER) else: return self.getToken(CParser.IDENTIFIER, i) =20 # @param i=3DNone Type: int - def STRING_LITERAL(self,i=3DNone): + def STRING_LITERAL(self, i=3DNone): if i is None: return self.getTokens(CParser.STRING_LITERAL) else: @@ -4337,23 +4129,20 @@ class CParser ( Parser ): return CParser.RULE_constant =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConstant" ): + def enterRule(self, listener): + if hasattr(listener, "enterConstant"): listener.enterConstant(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConstant" ): + def exitRule(self, listener): + if hasattr(listener, "exitConstant"): listener.exitConstant(self) =20 - - - def constant(self): =20 localctx =3D CParser.ConstantContext(self, self._ctx, self.state) self.enterRule(localctx, 88, self.RULE_constant) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.state =3D 647 self._errHandler.sync(self) @@ -4383,12 +4172,12 @@ class CParser ( Parser ): self.state =3D 636 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 628 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.IDENTIFIER: + while _la =3D=3D CParser.IDENTIFIER: self.state =3D 625 self.match(CParser.IDENTIFIER) self.state =3D 630 @@ -4398,7 +4187,7 @@ class CParser ( Parser ): self.state =3D 632 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NU= MBER: if _alt =3D=3D 1: self.state =3D 631 self.match(CParser.STRING_LITERAL) @@ -4407,19 +4196,20 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 634 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._in= put,77,self._ctx) - + _alt =3D self._interp.adaptivePredict( + self._input, 77, self._ctx) =20 else: raise NoViableAltException(self) self.state =3D 638 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,78,s= elf._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 78, self._ctx) =20 self.state =3D 643 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.IDENTIFIER: + while _la =3D=3D CParser.IDENTIFIER: self.state =3D 640 self.match(CParser.IDENTIFIER) self.state =3D 645 @@ -4447,39 +4237,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def assignment_expression(self,i=3DNone): + def assignment_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Assignment_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Assignment_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Assignment_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExpression" ): + def enterRule(self, listener): + if hasattr(listener, "enterExpression"): listener.enterExpression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExpression" ): + def exitRule(self, listener): + if hasattr(listener, "exitExpression"): listener.exitExpression(self) =20 - - - def expression(self): =20 localctx =3D CParser.ExpressionContext(self, self._ctx, self.state) self.enterRule(localctx, 90, self.RULE_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 649 @@ -4487,7 +4273,7 @@ class CParser ( Parser ): self.state =3D 654 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__3: + while _la =3D=3D CParser.T__3: self.state =3D 650 self.match(CParser.T__3) self.state =3D 651 @@ -4508,33 +4294,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_constant_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConstant_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterConstant_expression"): listener.enterConstant_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConstant_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitConstant_expression"): listener.exitConstant_expression(self) =20 - - - def constant_expression(self): =20 - localctx =3D CParser.Constant_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Constant_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 92, self.RULE_constant_expression) try: self.enterOuterAlt(localctx, 1) @@ -4552,50 +4335,44 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def lvalue(self): - return self.getTypedRuleContext(CParser.LvalueContext,0) - + return self.getTypedRuleContext(CParser.LvalueContext, 0) =20 def assignment_operator(self): - return self.getTypedRuleContext(CParser.Assignment_operatorCon= text,0) - + return self.getTypedRuleContext(CParser.Assignment_operatorCon= text, 0) =20 def assignment_expression(self): - return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Assignment_expressionC= ontext, 0) =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_assignment_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAssignment_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAssignment_expression"): listener.enterAssignment_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAssignment_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAssignment_expression"): listener.exitAssignment_expression(self) =20 - - - def assignment_expression(self): =20 - localctx =3D CParser.Assignment_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Assignment_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 94, self.RULE_assignment_expression) try: self.state =3D 664 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,82,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 82, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 659 @@ -4612,7 +4389,6 @@ class CParser ( Parser ): self.conditional_expression() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -4625,30 +4401,26 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def unary_expression(self): - return self.getTypedRuleContext(CParser.Unary_expressionContex= t,0) - + return self.getTypedRuleContext(CParser.Unary_expressionContex= t, 0) =20 def getRuleIndex(self): return CParser.RULE_lvalue =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLvalue" ): + def enterRule(self, listener): + if hasattr(listener, "enterLvalue"): listener.enterLvalue(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLvalue" ): + def exitRule(self, listener): + if hasattr(listener, "exitLvalue"): listener.exitLvalue(self) =20 - - - def lvalue(self): =20 localctx =3D CParser.LvalueContext(self, self._ctx, self.state) @@ -4669,32 +4441,29 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_assignment_operator =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAssignment_operator" ): + def enterRule(self, listener): + if hasattr(listener, "enterAssignment_operator"): listener.enterAssignment_operator(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAssignment_operator" ): + def exitRule(self, listener): + if hasattr(listener, "exitAssignment_operator"): listener.exitAssignment_operator(self) =20 - - - def assignment_operator(self): =20 - localctx =3D CParser.Assignment_operatorContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Assignment_operatorContext( + self, self._ctx, self.state) self.enterRule(localctx, 98, self.RULE_assignment_operator) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 668 @@ -4716,44 +4485,39 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # Logical_or_expressionContext + self.e =3D None # Logical_or_expressionContext =20 def logical_or_expression(self): - return self.getTypedRuleContext(CParser.Logical_or_expressionC= ontext,0) - + return self.getTypedRuleContext(CParser.Logical_or_expressionC= ontext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def conditional_expression(self): - return self.getTypedRuleContext(CParser.Conditional_expression= Context,0) - + return self.getTypedRuleContext(CParser.Conditional_expression= Context, 0) =20 def getRuleIndex(self): return CParser.RULE_conditional_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterConditional_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterConditional_expression"): listener.enterConditional_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitConditional_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitConditional_expression"): listener.exitConditional_expression(self) =20 - - - def conditional_expression(self): =20 - localctx =3D CParser.Conditional_expressionContext(self, self._ctx= , self.state) + localctx =3D CParser.Conditional_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 100, self.RULE_conditional_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 670 @@ -4761,7 +4525,7 @@ class CParser ( Parser ): self.state =3D 677 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__65: + if _la =3D=3D CParser.T__65: self.state =3D 671 self.match(CParser.T__65) self.state =3D 672 @@ -4770,8 +4534,8 @@ class CParser ( Parser ): self.match(CParser.T__22) self.state =3D 674 self.conditional_expression() - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) - + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) =20 except RecognitionException as re: localctx.exception =3D re @@ -4785,39 +4549,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def logical_and_expression(self,i=3DNone): + def logical_and_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Logical_and_expre= ssionContext) else: - return self.getTypedRuleContext(CParser.Logical_and_expres= sionContext,i) - + return self.getTypedRuleContext(CParser.Logical_and_expres= sionContext, i) =20 def getRuleIndex(self): return CParser.RULE_logical_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLogical_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterLogical_or_expression"): listener.enterLogical_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLogical_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitLogical_or_expression"): listener.exitLogical_or_expression(self) =20 - - - def logical_or_expression(self): =20 - localctx =3D CParser.Logical_or_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Logical_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 102, self.RULE_logical_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 679 @@ -4825,7 +4586,7 @@ class CParser ( Parser ): self.state =3D 684 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__66: + while _la =3D=3D CParser.T__66: self.state =3D 680 self.match(CParser.T__66) self.state =3D 681 @@ -4846,39 +4607,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def inclusive_or_expression(self,i=3DNone): + def inclusive_or_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Inclusive_or_expr= essionContext) else: - return self.getTypedRuleContext(CParser.Inclusive_or_expre= ssionContext,i) - + return self.getTypedRuleContext(CParser.Inclusive_or_expre= ssionContext, i) =20 def getRuleIndex(self): return CParser.RULE_logical_and_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLogical_and_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterLogical_and_expression"): listener.enterLogical_and_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLogical_and_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitLogical_and_expression"): listener.exitLogical_and_expression(self) =20 - - - def logical_and_expression(self): =20 - localctx =3D CParser.Logical_and_expressionContext(self, self._ctx= , self.state) + localctx =3D CParser.Logical_and_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 104, self.RULE_logical_and_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 687 @@ -4886,7 +4644,7 @@ class CParser ( Parser ): self.state =3D 692 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__67: + while _la =3D=3D CParser.T__67: self.state =3D 688 self.match(CParser.T__67) self.state =3D 689 @@ -4907,39 +4665,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def exclusive_or_expression(self,i=3DNone): + def exclusive_or_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Exclusive_or_expr= essionContext) else: - return self.getTypedRuleContext(CParser.Exclusive_or_expre= ssionContext,i) - + return self.getTypedRuleContext(CParser.Exclusive_or_expre= ssionContext, i) =20 def getRuleIndex(self): return CParser.RULE_inclusive_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterInclusive_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterInclusive_or_expression"): listener.enterInclusive_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitInclusive_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitInclusive_or_expression"): listener.exitInclusive_or_expression(self) =20 - - - def inclusive_or_expression(self): =20 - localctx =3D CParser.Inclusive_or_expressionContext(self, self._ct= x, self.state) + localctx =3D CParser.Inclusive_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 106, self.RULE_inclusive_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 695 @@ -4947,7 +4702,7 @@ class CParser ( Parser ): self.state =3D 700 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__68: + while _la =3D=3D CParser.T__68: self.state =3D 696 self.match(CParser.T__68) self.state =3D 697 @@ -4968,39 +4723,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def and_expression(self,i=3DNone): + def and_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.And_expressionCon= text) else: - return self.getTypedRuleContext(CParser.And_expressionCont= ext,i) - + return self.getTypedRuleContext(CParser.And_expressionCont= ext, i) =20 def getRuleIndex(self): return CParser.RULE_exclusive_or_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExclusive_or_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterExclusive_or_expression"): listener.enterExclusive_or_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExclusive_or_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitExclusive_or_expression"): listener.exitExclusive_or_expression(self) =20 - - - def exclusive_or_expression(self): =20 - localctx =3D CParser.Exclusive_or_expressionContext(self, self._ct= x, self.state) + localctx =3D CParser.Exclusive_or_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 108, self.RULE_exclusive_or_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 703 @@ -5008,7 +4760,7 @@ class CParser ( Parser ): self.state =3D 708 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__69: + while _la =3D=3D CParser.T__69: self.state =3D 704 self.match(CParser.T__69) self.state =3D 705 @@ -5029,39 +4781,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def equality_expression(self,i=3DNone): + def equality_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Equality_expressi= onContext) else: - return self.getTypedRuleContext(CParser.Equality_expressio= nContext,i) - + return self.getTypedRuleContext(CParser.Equality_expressio= nContext, i) =20 def getRuleIndex(self): return CParser.RULE_and_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAnd_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterAnd_expression"): listener.enterAnd_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAnd_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitAnd_expression"): listener.exitAnd_expression(self) =20 - - - def and_expression(self): =20 localctx =3D CParser.And_expressionContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 110, self.RULE_and_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 711 @@ -5069,7 +4817,7 @@ class CParser ( Parser ): self.state =3D 716 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__52: + while _la =3D=3D CParser.T__52: self.state =3D 712 self.match(CParser.T__52) self.state =3D 713 @@ -5090,39 +4838,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def relational_expression(self,i=3DNone): + def relational_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Relational_expres= sionContext) else: - return self.getTypedRuleContext(CParser.Relational_express= ionContext,i) - + return self.getTypedRuleContext(CParser.Relational_express= ionContext, i) =20 def getRuleIndex(self): return CParser.RULE_equality_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterEquality_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterEquality_expression"): listener.enterEquality_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitEquality_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitEquality_expression"): listener.exitEquality_expression(self) =20 - - - def equality_expression(self): =20 - localctx =3D CParser.Equality_expressionContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Equality_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 112, self.RULE_equality_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 719 @@ -5130,10 +4875,10 @@ class CParser ( Parser ): self.state =3D 724 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__70 or _la=3D=3DCParser.T__71: + while _la =3D=3D CParser.T__70 or _la =3D=3D CParser.T__71: self.state =3D 720 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__70 or _la=3D=3DCParser.T__71): + if not(_la =3D=3D CParser.T__70 or _la =3D=3D CParser.T__7= 1): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5156,39 +4901,36 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def shift_expression(self,i=3DNone): + def shift_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Shift_expressionC= ontext) else: - return self.getTypedRuleContext(CParser.Shift_expressionCo= ntext,i) - + return self.getTypedRuleContext(CParser.Shift_expressionCo= ntext, i) =20 def getRuleIndex(self): return CParser.RULE_relational_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterRelational_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterRelational_expression"): listener.enterRelational_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitRelational_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitRelational_expression"): listener.exitRelational_expression(self) =20 - - - def relational_expression(self): =20 - localctx =3D CParser.Relational_expressionContext(self, self._ctx,= self.state) + localctx =3D CParser.Relational_expressionContext( + self, self._ctx, self.state) self.enterRule(localctx, 114, self.RULE_relational_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 727 @@ -5222,39 +4964,35 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def additive_expression(self,i=3DNone): + def additive_expression(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.Additive_expressi= onContext) else: - return self.getTypedRuleContext(CParser.Additive_expressio= nContext,i) - + return self.getTypedRuleContext(CParser.Additive_expressio= nContext, i) =20 def getRuleIndex(self): return CParser.RULE_shift_expression =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterShift_expression" ): + def enterRule(self, listener): + if hasattr(listener, "enterShift_expression"): listener.enterShift_expression(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitShift_expression" ): + def exitRule(self, listener): + if hasattr(listener, "exitShift_expression"): listener.exitShift_expression(self) =20 - - - def shift_expression(self): =20 localctx =3D CParser.Shift_expressionContext(self, self._ctx, self= .state) self.enterRule(localctx, 116, self.RULE_shift_expression) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 735 @@ -5262,10 +5000,10 @@ class CParser ( Parser ): self.state =3D 740 self._errHandler.sync(self) _la =3D self._input.LA(1) - while _la=3D=3DCParser.T__76 or _la=3D=3DCParser.T__77: + while _la =3D=3D CParser.T__76 or _la =3D=3D CParser.T__77: self.state =3D 736 _la =3D self._input.LA(1) - if not(_la=3D=3DCParser.T__76 or _la=3D=3DCParser.T__77): + if not(_la =3D=3D CParser.T__76 or _la =3D=3D CParser.T__7= 7): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5288,70 +5026,56 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def labeled_statement(self): - return self.getTypedRuleContext(CParser.Labeled_statementConte= xt,0) - + return self.getTypedRuleContext(CParser.Labeled_statementConte= xt, 0) =20 def compound_statement(self): - return self.getTypedRuleContext(CParser.Compound_statementCont= ext,0) - + return self.getTypedRuleContext(CParser.Compound_statementCont= ext, 0) =20 def expression_statement(self): - return self.getTypedRuleContext(CParser.Expression_statementCo= ntext,0) - + return self.getTypedRuleContext(CParser.Expression_statementCo= ntext, 0) =20 def selection_statement(self): - return self.getTypedRuleContext(CParser.Selection_statementCon= text,0) - + return self.getTypedRuleContext(CParser.Selection_statementCon= text, 0) =20 def iteration_statement(self): - return self.getTypedRuleContext(CParser.Iteration_statementCon= text,0) - + return self.getTypedRuleContext(CParser.Iteration_statementCon= text, 0) =20 def jump_statement(self): - return self.getTypedRuleContext(CParser.Jump_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Jump_statementContext,= 0) =20 def macro_statement(self): - return self.getTypedRuleContext(CParser.Macro_statementContext= ,0) - + return self.getTypedRuleContext(CParser.Macro_statementContext= , 0) =20 def asm2_statement(self): - return self.getTypedRuleContext(CParser.Asm2_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Asm2_statementContext,= 0) =20 def asm1_statement(self): - return self.getTypedRuleContext(CParser.Asm1_statementContext,= 0) - + return self.getTypedRuleContext(CParser.Asm1_statementContext,= 0) =20 def asm_statement(self): - return self.getTypedRuleContext(CParser.Asm_statementContext,0) - + return self.getTypedRuleContext(CParser.Asm_statementContext, = 0) =20 def declaration(self): - return self.getTypedRuleContext(CParser.DeclarationContext,0) - + return self.getTypedRuleContext(CParser.DeclarationContext, 0) =20 def getRuleIndex(self): return CParser.RULE_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStatement" ): + def enterRule(self, listener): + if hasattr(listener, "enterStatement"): listener.enterStatement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStatement" ): + def exitRule(self, listener): + if hasattr(listener, "exitStatement"): listener.exitStatement(self) =20 - - - def statement(self): =20 localctx =3D CParser.StatementContext(self, self._ctx, self.state) @@ -5359,7 +5083,7 @@ class CParser ( Parser ): try: self.state =3D 754 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,92,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 92, self._ct= x) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 743 @@ -5426,7 +5150,6 @@ class CParser ( Parser ): self.declaration() pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -5439,7 +5162,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5450,52 +5173,48 @@ class CParser ( Parser ): return CParser.RULE_asm2_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm2_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm2_statement"): listener.enterAsm2_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm2_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm2_statement"): listener.exitAsm2_statement(self) =20 - - - def asm2_statement(self): =20 localctx =3D CParser.Asm2_statementContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 120, self.RULE_asm2_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 757 self._errHandler.sync(self) _la =3D self._input.LA(1) - if _la=3D=3DCParser.T__78: + if _la =3D=3D CParser.T__78: self.state =3D 756 self.match(CParser.T__78) =20 - self.state =3D 759 self.match(CParser.IDENTIFIER) self.state =3D 760 self.match(CParser.T__37) self.state =3D 764 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,94,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 94, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 761 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__1: + if _la <=3D 0 or _la =3D=3D CParser.T__1: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() self.state =3D 766 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,94,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 94, sel= f._ctx) =20 self.state =3D 767 self.match(CParser.T__38) @@ -5513,32 +5232,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_asm1_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm1_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm1_statement"): listener.enterAsm1_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm1_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm1_statement"): listener.exitAsm1_statement(self) =20 - - - def asm1_statement(self): =20 localctx =3D CParser.Asm1_statementContext(self, self._ctx, self.s= tate) self.enterRule(localctx, 122, self.RULE_asm1_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 770 @@ -5551,7 +5266,7 @@ class CParser ( Parser ): while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__0) | (1 << CParser.T__1) | (1 << CParser.T__2) | (1 << CParser.T__3) = | (1 << CParser.T__4) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << C= Parser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T_= _10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) |= (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 <<= CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CPars= er.T__21) | (1 << CParser.T__22) | (1 << CParser.T__23) | (1 << CParser.T__= 24) | (1 << CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | = (1 << CParser.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << = CParser.T__31) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParse= r.T__34) | (1 << CParser.T__35) | (1 << CParser.T__36) | (1 << CParser.T__3= 7) | (1 << CParser.T__38) | (1 << CParser.T__39) | (1 << CParser.T__40) | (= 1 << CParser.T__41) | (1 << CParser.T__42) | (1 << CParser.T__43) | (1 << C= Parser.T__44) | (1 << CParser.T__45) | (1 << CParser.T__46) | (1 << CParser= .T__47) | (1 << CParser.T__48) | (1 << CParser.T__49) | (1 << CParser.T__50= ) | (1 << CParser.T__51) | (1 << CParser.T__52) | (1 << CParser.T__53) | (1= << CParser.T__54) | (1 << CParser.T__55) | (1 << CParser.T__56) | (1 << CP= arser.T__57) | (1 << CParser.T__58) | (1 << CParser.T__59) | (1 << CParser.= T__60) | (1 << CParser.T__61) | (1 << CParser.T__62))) !=3D 0) or ((((_la -= 64)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 64)) & ((1 << (CParser.T__63 - 64= )) | (1 << (CParser.T__64 - 64)) | (1 << (CParser.T__65 - 64)) | (1 << (CPa= rser.T__66 - 64)) | (1 << (CParser.T__67 - 64)) | (1 << (CParser.T__68 - 64= )) | (1 << (CParser.T__69 - 64)) | (1 << (CParser.T__70 - 64)) | (1 << (CPa= rser.T__71 - 64)) | (1 << (CParser.T__72 - 64)) | (1 << (CParser.T__73 - 64= )) | (1 << (CParser.T__74 - 64)) | (1 << (CParser.T__75 - 64)) | (1 << (CPa= rser.T__76 - 64)) | (1 << (CParser.T__77 - 64)) | (1 << (CParser.T__78 - 64= )) | (1 << (CParser.T__79 - 64)) | (1 << (CParser.T__80 - 64)) | (1 << (CPa= rser.T__81 - 64)) | (1 << (CParser.T__82 - 64)) | (1 << (CParser.T__83 - 64= )) | (1 << (CParser.T__84 - 64)) | (1 << (CParser.T__85 - 64)) | (1 << (CPa= rser.T__86 - 64)) | (1 << (CParser.T__87 - 64)) | (1 << (CParser.T__88 - 64= )) | (1 << (CParser.T__89 - 64)) | (1 << (CParser.T__90 - 64)) | (1 << (CPa= rser.T__91 - 64)) | (1 << (CParser.IDENTIFIER - 64)) | (1 << (CParser.CHARA= CTER_LITERAL - 64)) | (1 << (CParser.STRING_LITERAL - 64)) | (1 << (CParser= .HEX_LITERAL - 64)) | (1 << (CParser.DECIMAL_LITERAL - 64)) | (1 << (CParse= r.OCTAL_LITERAL - 64)) | (1 << (CParser.FLOATING_POINT_LITERAL - 64)) | (1 = << (CParser.WS - 64)) | (1 << (CParser.BS - 64)) | (1 << (CParser.UnicodeVo= cabulary - 64)) | (1 << (CParser.COMMENT - 64)) | (1 << (CParser.LINE_COMME= NT - 64)) | (1 << (CParser.LINE_COMMAND - 64)))) !=3D 0): self.state =3D 772 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__19: + if _la <=3D 0 or _la =3D=3D CParser.T__19: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5574,32 +5289,28 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 - def getRuleIndex(self): return CParser.RULE_asm_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterAsm_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterAsm_statement"): listener.enterAsm_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitAsm_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitAsm_statement"): listener.exitAsm_statement(self) =20 - - - def asm_statement(self): =20 localctx =3D CParser.Asm_statementContext(self, self._ctx, self.st= ate) self.enterRule(localctx, 124, self.RULE_asm_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 780 @@ -5612,7 +5323,7 @@ class CParser ( Parser ): while (((_la) & ~0x3f) =3D=3D 0 and ((1 << _la) & ((1 << CPars= er.T__0) | (1 << CParser.T__1) | (1 << CParser.T__2) | (1 << CParser.T__3) = | (1 << CParser.T__4) | (1 << CParser.T__5) | (1 << CParser.T__6) | (1 << C= Parser.T__7) | (1 << CParser.T__8) | (1 << CParser.T__9) | (1 << CParser.T_= _10) | (1 << CParser.T__11) | (1 << CParser.T__12) | (1 << CParser.T__13) |= (1 << CParser.T__14) | (1 << CParser.T__15) | (1 << CParser.T__16) | (1 <<= CParser.T__17) | (1 << CParser.T__18) | (1 << CParser.T__20) | (1 << CPars= er.T__21) | (1 << CParser.T__22) | (1 << CParser.T__23) | (1 << CParser.T__= 24) | (1 << CParser.T__25) | (1 << CParser.T__26) | (1 << CParser.T__27) | = (1 << CParser.T__28) | (1 << CParser.T__29) | (1 << CParser.T__30) | (1 << = CParser.T__31) | (1 << CParser.T__32) | (1 << CParser.T__33) | (1 << CParse= r.T__34) | (1 << CParser.T__35) | (1 << CParser.T__36) | (1 << CParser.T__3= 7) | (1 << CParser.T__38) | (1 << CParser.T__39) | (1 << CParser.T__40) | (= 1 << CParser.T__41) | (1 << CParser.T__42) | (1 << CParser.T__43) | (1 << C= Parser.T__44) | (1 << CParser.T__45) | (1 << CParser.T__46) | (1 << CParser= .T__47) | (1 << CParser.T__48) | (1 << CParser.T__49) | (1 << CParser.T__50= ) | (1 << CParser.T__51) | (1 << CParser.T__52) | (1 << CParser.T__53) | (1= << CParser.T__54) | (1 << CParser.T__55) | (1 << CParser.T__56) | (1 << CP= arser.T__57) | (1 << CParser.T__58) | (1 << CParser.T__59) | (1 << CParser.= T__60) | (1 << CParser.T__61) | (1 << CParser.T__62))) !=3D 0) or ((((_la -= 64)) & ~0x3f) =3D=3D 0 and ((1 << (_la - 64)) & ((1 << (CParser.T__63 - 64= )) | (1 << (CParser.T__64 - 64)) | (1 << (CParser.T__65 - 64)) | (1 << (CPa= rser.T__66 - 64)) | (1 << (CParser.T__67 - 64)) | (1 << (CParser.T__68 - 64= )) | (1 << (CParser.T__69 - 64)) | (1 << (CParser.T__70 - 64)) | (1 << (CPa= rser.T__71 - 64)) | (1 << (CParser.T__72 - 64)) | (1 << (CParser.T__73 - 64= )) | (1 << (CParser.T__74 - 64)) | (1 << (CParser.T__75 - 64)) | (1 << (CPa= rser.T__76 - 64)) | (1 << (CParser.T__77 - 64)) | (1 << (CParser.T__78 - 64= )) | (1 << (CParser.T__79 - 64)) | (1 << (CParser.T__80 - 64)) | (1 << (CPa= rser.T__81 - 64)) | (1 << (CParser.T__82 - 64)) | (1 << (CParser.T__83 - 64= )) | (1 << (CParser.T__84 - 64)) | (1 << (CParser.T__85 - 64)) | (1 << (CPa= rser.T__86 - 64)) | (1 << (CParser.T__87 - 64)) | (1 << (CParser.T__88 - 64= )) | (1 << (CParser.T__89 - 64)) | (1 << (CParser.T__90 - 64)) | (1 << (CPa= rser.T__91 - 64)) | (1 << (CParser.IDENTIFIER - 64)) | (1 << (CParser.CHARA= CTER_LITERAL - 64)) | (1 << (CParser.STRING_LITERAL - 64)) | (1 << (CParser= .HEX_LITERAL - 64)) | (1 << (CParser.DECIMAL_LITERAL - 64)) | (1 << (CParse= r.OCTAL_LITERAL - 64)) | (1 << (CParser.FLOATING_POINT_LITERAL - 64)) | (1 = << (CParser.WS - 64)) | (1 << (CParser.BS - 64)) | (1 << (CParser.UnicodeVo= cabulary - 64)) | (1 << (CParser.COMMENT - 64)) | (1 << (CParser.LINE_COMME= NT - 64)) | (1 << (CParser.LINE_COMMAND - 64)))) !=3D 0): self.state =3D 782 _la =3D self._input.LA(1) - if _la <=3D 0 or _la=3D=3DCParser.T__19: + if _la <=3D 0 or _la =3D=3D CParser.T__19: self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -5635,7 +5346,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5643,42 +5354,36 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def statement_list(self): - return self.getTypedRuleContext(CParser.Statement_listContext,= 0) - + return self.getTypedRuleContext(CParser.Statement_listContext,= 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_macro_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterMacro_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterMacro_statement"): listener.enterMacro_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitMacro_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitMacro_statement"): listener.exitMacro_statement(self) =20 - - - def macro_statement(self): =20 localctx =3D CParser.Macro_statementContext(self, self._ctx, self.= state) self.enterRule(localctx, 126, self.RULE_macro_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 790 @@ -5687,23 +5392,22 @@ class CParser ( Parser ): self.match(CParser.T__37) self.state =3D 795 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,97,self._ctx) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 97, self._c= tx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 792 self.declaration() self.state =3D 797 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,97,self.= _ctx) + _alt =3D self._interp.adaptivePredict(self._input, 97, sel= f._ctx) =20 self.state =3D 799 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,98,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 98, self._ct= x) if la_ =3D=3D 1: self.state =3D 798 self.statement_list() =20 - self.state =3D 802 self._errHandler.sync(self) _la =3D self._input.LA(1) @@ -5711,7 +5415,6 @@ class CParser ( Parser ): self.state =3D 801 self.expression() =20 - self.state =3D 804 self.match(CParser.T__38) except RecognitionException as re: @@ -5726,7 +5429,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -5734,32 +5437,28 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def statement(self): - return self.getTypedRuleContext(CParser.StatementContext,0) - + return self.getTypedRuleContext(CParser.StatementContext, 0) =20 def constant_expression(self): - return self.getTypedRuleContext(CParser.Constant_expressionCon= text,0) - + return self.getTypedRuleContext(CParser.Constant_expressionCon= text, 0) =20 def getRuleIndex(self): return CParser.RULE_labeled_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterLabeled_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterLabeled_statement"): listener.enterLabeled_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitLabeled_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitLabeled_statement"): listener.exitLabeled_statement(self) =20 - - - def labeled_statement(self): =20 - localctx =3D CParser.Labeled_statementContext(self, self._ctx, sel= f.state) + localctx =3D CParser.Labeled_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 128, self.RULE_labeled_statement) try: self.state =3D 817 @@ -5809,57 +5508,54 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def declaration(self,i=3DNone): + def declaration(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.DeclarationContex= t) else: - return self.getTypedRuleContext(CParser.DeclarationContext= ,i) - + return self.getTypedRuleContext(CParser.DeclarationContext= , i) =20 def statement_list(self): - return self.getTypedRuleContext(CParser.Statement_listContext,= 0) - + return self.getTypedRuleContext(CParser.Statement_listContext,= 0) =20 def getRuleIndex(self): return CParser.RULE_compound_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterCompound_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterCompound_statement"): listener.enterCompound_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitCompound_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitCompound_statement"): listener.exitCompound_statement(self) =20 - - - def compound_statement(self): =20 - localctx =3D CParser.Compound_statementContext(self, self._ctx, se= lf.state) + localctx =3D CParser.Compound_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 130, self.RULE_compound_statement) - self._la =3D 0 # Token type + self._la =3D 0 # Token type try: self.enterOuterAlt(localctx, 1) self.state =3D 819 self.match(CParser.T__0) self.state =3D 823 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,101,self._ct= x) - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: - if _alt=3D=3D1: + _alt =3D self._interp.adaptivePredict(self._input, 101, self._= ctx) + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: + if _alt =3D=3D 1: self.state =3D 820 self.declaration() self.state =3D 825 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,101,self= ._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 101, self._ctx) =20 self.state =3D 827 self._errHandler.sync(self) @@ -5868,7 +5564,6 @@ class CParser ( Parser ): self.state =3D 826 self.statement_list() =20 - self.state =3D 829 self.match(CParser.T__19) except RecognitionException as re: @@ -5883,34 +5578,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 # @param i=3DNone Type: int - def statement(self,i=3DNone): + def statement(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.StatementContext) else: - return self.getTypedRuleContext(CParser.StatementContext,i) - + return self.getTypedRuleContext(CParser.StatementContext, = i) =20 def getRuleIndex(self): return CParser.RULE_statement_list =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterStatement_list" ): + def enterRule(self, listener): + if hasattr(listener, "enterStatement_list"): listener.enterStatement_list(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitStatement_list" ): + def exitRule(self, listener): + if hasattr(listener, "exitStatement_list"): listener.exitStatement_list(self) =20 - - - def statement_list(self): =20 localctx =3D CParser.Statement_listContext(self, self._ctx, self.s= tate) @@ -5920,7 +5611,7 @@ class CParser ( Parser ): self.state =3D 832 self._errHandler.sync(self) _alt =3D 1 - while _alt!=3D2 and _alt!=3DATN.INVALID_ALT_NUMBER: + while _alt !=3D 2 and _alt !=3D ATN.INVALID_ALT_NUMBER: if _alt =3D=3D 1: self.state =3D 831 self.statement() @@ -5929,7 +5620,8 @@ class CParser ( Parser ): raise NoViableAltException(self) self.state =3D 834 self._errHandler.sync(self) - _alt =3D self._interp.adaptivePredict(self._input,103,self= ._ctx) + _alt =3D self._interp.adaptivePredict( + self._input, 103, self._ctx) =20 except RecognitionException as re: localctx.exception =3D re @@ -5943,33 +5635,30 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_expression_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterExpression_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterExpression_statement"): listener.enterExpression_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitExpression_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitExpression_statement"): listener.exitExpression_statement(self) =20 - - - def expression_statement(self): =20 - localctx =3D CParser.Expression_statementContext(self, self._ctx, = self.state) + localctx =3D CParser.Expression_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 134, self.RULE_expression_statement) try: self.state =3D 840 @@ -6002,42 +5691,38 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # ExpressionContext + self.e =3D None # ExpressionContext =20 # @param i=3DNone Type: int - def statement(self,i=3DNone): + def statement(self, i=3DNone): if i is None: return self.getTypedRuleContexts(CParser.StatementContext) else: - return self.getTypedRuleContext(CParser.StatementContext,i) - + return self.getTypedRuleContext(CParser.StatementContext, = i) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_selection_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterSelection_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterSelection_statement"): listener.enterSelection_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitSelection_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitSelection_statement"): listener.exitSelection_statement(self) =20 - - - def selection_statement(self): =20 - localctx =3D CParser.Selection_statementContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Selection_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 136, self.RULE_selection_statement) try: self.state =3D 858 @@ -6053,19 +5738,19 @@ class CParser ( Parser ): localctx.e =3D self.expression() self.state =3D 845 self.match(CParser.T__38) - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) self.state =3D 847 self.statement() self.state =3D 850 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,105,self.= _ctx) + la_ =3D self._interp.adaptivePredict(self._input, 105, sel= f._ctx) if la_ =3D=3D 1: self.state =3D 848 self.match(CParser.T__84) self.state =3D 849 self.statement() =20 - pass elif token in [CParser.T__85]: self.enterOuterAlt(localctx, 2) @@ -6095,38 +5780,34 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser - self.e =3D None # ExpressionContext + self.e =3D None # ExpressionContext =20 def statement(self): - return self.getTypedRuleContext(CParser.StatementContext,0) - + return self.getTypedRuleContext(CParser.StatementContext, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_iteration_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterIteration_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterIteration_statement"): listener.enterIteration_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitIteration_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitIteration_statement"): listener.exitIteration_statement(self) =20 - - - def iteration_statement(self): =20 - localctx =3D CParser.Iteration_statementContext(self, self._ctx, s= elf.state) + localctx =3D CParser.Iteration_statementContext( + self, self._ctx, self.state) self.enterRule(localctx, 138, self.RULE_iteration_statement) try: self.state =3D 876 @@ -6144,7 +5825,8 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state =3D 864 self.statement() - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) pass elif token in [CParser.T__87]: self.enterOuterAlt(localctx, 2) @@ -6162,7 +5844,8 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state =3D 873 self.match(CParser.T__1) - self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, (None = if localctx.e is None else localctx.e.stop).column, (None if localctx.e is = None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None = else localctx.e.start).line, (None if localctx.e is None else localctx.e.st= art).column, (None if localctx.e is None else localctx.e.stop).line, ( + None if localctx.e is None else localctx.e.stop).colum= n, (None if localctx.e is None else self._input.getText((localctx.e.start, = localctx.e.stop)))) pass else: raise NoViableAltException(self) @@ -6179,7 +5862,7 @@ class CParser ( Parser ): =20 # @param parent=3DNone Type: ParserRuleContext # @param invokingState=3D-1 Type: int - def __init__(self,parser,parent=3DNone,invokingState=3D-1): + def __init__(self, parser, parent=3DNone, invokingState=3D-1): super().__init__(parent, invokingState) self.parser =3D parser =20 @@ -6187,25 +5870,21 @@ class CParser ( Parser ): return self.getToken(CParser.IDENTIFIER, 0) =20 def expression(self): - return self.getTypedRuleContext(CParser.ExpressionContext,0) - + return self.getTypedRuleContext(CParser.ExpressionContext, 0) =20 def getRuleIndex(self): return CParser.RULE_jump_statement =20 # @param listener Type: ParseTreeListener - def enterRule(self,listener): - if hasattr( listener, "enterJump_statement" ): + def enterRule(self, listener): + if hasattr(listener, "enterJump_statement"): listener.enterJump_statement(self) =20 # @param listener Type: ParseTreeListener - def exitRule(self,listener): - if hasattr( listener, "exitJump_statement" ): + def exitRule(self, listener): + if hasattr(listener, "exitJump_statement"): listener.exitJump_statement(self) =20 - - - def jump_statement(self): =20 localctx =3D CParser.Jump_statementContext(self, self._ctx, self.s= tate) @@ -6213,7 +5892,7 @@ class CParser ( Parser ): try: self.state =3D 891 self._errHandler.sync(self) - la_ =3D self._interp.adaptivePredict(self._input,108,self._ctx) + la_ =3D self._interp.adaptivePredict(self._input, 108, self._c= tx) if la_ =3D=3D 1: self.enterOuterAlt(localctx, 1) self.state =3D 878 @@ -6258,7 +5937,6 @@ class CParser ( Parser ): self.match(CParser.T__1) pass =20 - except RecognitionException as re: localctx.exception =3D re self._errHandler.reportError(self, re) @@ -6266,8 +5944,3 @@ class CParser ( Parser ): finally: self.exitRule() return localctx - - - - - diff --git a/BaseTools/Source/Python/Eot/CodeFragment.py b/BaseTools/Source= /Python/Eot/CodeFragment.py index 94c3f52d5c20..5ef7cb3557f4 100644 --- a/BaseTools/Source/Python/Eot/CodeFragment.py +++ b/BaseTools/Source/Python/Eot/CodeFragment.py @@ -1,4 +1,4 @@ -## @file +# @file # fragments of source file # # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
        @@ -7,11 +7,11 @@ # =20 =20 -## The description of comment contents and start & end position +# The description of comment contents and start & end position # # -class Comment : - ## The constructor +class Comment: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -25,11 +25,13 @@ class Comment : self.EndPos =3D End self.Type =3D CommentType =20 -## The description of preprocess directives and start & end position +# The description of preprocess directives and start & end position # # -class PP_Directive : - ## The constructor + + +class PP_Directive: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -41,11 +43,13 @@ class PP_Directive : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of assignment expression and start & end position +# The description of assignment expression and start & end position # # -class AssignmentExpression : - ## The constructor + + +class AssignmentExpression: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -59,11 +63,13 @@ class AssignmentExpression : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of predicate expression and start & end position +# The description of predicate expression and start & end position # # -class PredicateExpression : - ## The constructor + + +class PredicateExpression: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -75,11 +81,13 @@ class PredicateExpression : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of function definition and start & end position +# The description of function definition and start & end position # # -class FunctionDefinition : - ## The constructor + + +class FunctionDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -95,11 +103,13 @@ class FunctionDefinition : self.LeftBracePos =3D LBPos self.NamePos =3D NamePos =20 -## The description of variable declaration and start & end position +# The description of variable declaration and start & end position # # -class VariableDeclaration : - ## The constructor + + +class VariableDeclaration: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -112,11 +122,13 @@ class VariableDeclaration : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of enum definition and start & end position +# The description of enum definition and start & end position # # -class EnumerationDefinition : - ## The constructor + + +class EnumerationDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -128,11 +140,13 @@ class EnumerationDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of struct/union definition and start & end position +# The description of struct/union definition and start & end position # # -class StructUnionDefinition : - ## The constructor + + +class StructUnionDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -144,11 +158,13 @@ class StructUnionDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of 'Typedef' definition and start & end position +# The description of 'Typedef' definition and start & end position # # -class TypedefDefinition : - ## The constructor + + +class TypedefDefinition: + # The constructor # # @param self The object pointer # @param Str The message to record @@ -161,11 +177,13 @@ class TypedefDefinition : self.StartPos =3D Begin self.EndPos =3D End =20 -## The description of function calling definition and start & end position +# The description of function calling definition and start & end position # # + + class FunctionCalling: - ## The constructor + # The constructor # # @param self The object pointer # @param Str The message to record diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseToo= ls/Source/Python/Eot/CodeFragmentCollector.py index a5c1ceeaea32..a9e2d18567a9 100644 --- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py @@ -1,4 +1,4 @@ -## @file +# @file # preprocess source file # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -30,21 +30,21 @@ from Eot.CodeFragment import PP_Directive from Eot.ParserWarning import Warning =20 =20 -##define T_CHAR_SPACE ' ' -##define T_CHAR_NULL '\0' -##define T_CHAR_CR '\r' -##define T_CHAR_TAB '\t' -##define T_CHAR_LF '\n' -##define T_CHAR_SLASH '/' -##define T_CHAR_BACKSLASH '\\' -##define T_CHAR_DOUBLE_QUOTE '\"' -##define T_CHAR_SINGLE_QUOTE '\'' -##define T_CHAR_STAR '*' -##define T_CHAR_HASH '#' +# define T_CHAR_SPACE ' ' +# define T_CHAR_NULL '\0' +# define T_CHAR_CR '\r' +# define T_CHAR_TAB '\t' +# define T_CHAR_LF '\n' +# define T_CHAR_SLASH '/' +# define T_CHAR_BACKSLASH '\\' +# define T_CHAR_DOUBLE_QUOTE '\"' +# define T_CHAR_SINGLE_QUOTE '\'' +# define T_CHAR_STAR '*' +# define T_CHAR_HASH '#' =20 -(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH= , \ -T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T= _CHAR_HASH) =3D \ -(' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') +(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH, + T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, = T_CHAR_HASH) =3D \ + (' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#') =20 SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}') =20 @@ -52,15 +52,17 @@ SEPERATOR_TUPLE =3D ('=3D', '|', ',', '{', '}') =20 (T_PP_INCLUDE, T_PP_DEFINE, T_PP_OTHERS) =3D (0, 1, 2) =20 -## The collector for source code fragments. +# The collector for source code fragments. # # PreprocessFile method should be called prior to ParseFile # # GetNext*** procedures mean these procedures will get next token first, t= hen make judgement. # Get*** procedures mean these procedures will make judgement on current t= oken only. # + + class CodeFragmentCollector: - ## The constructor + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed @@ -75,7 +77,7 @@ class CodeFragmentCollector: self.__Token =3D "" self.__SkippedChars =3D "" =20 - ## __EndOfFile() method + # __EndOfFile() method # # Judge current buffer pos is at file end # @@ -93,7 +95,7 @@ class CodeFragmentCollector: else: return False =20 - ## __EndOfLine() method + # __EndOfLine() method # # Judge current buffer pos is at line end # @@ -102,13 +104,14 @@ class CodeFragmentCollector: # @retval False Current File buffer position is NOT at line end # def __EndOfLine(self): - SizeOfCurrentLine =3D len(self.Profile.FileLinesList[self.CurrentL= ineNumber - 1]) + SizeOfCurrentLine =3D len( + self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if self.CurrentOffsetWithinLine >=3D SizeOfCurrentLine - 1: return True else: return False =20 - ## Rewind() method + # Rewind() method # # Reset file data buffer to the initial state # @@ -118,7 +121,7 @@ class CodeFragmentCollector: self.CurrentLineNumber =3D 1 self.CurrentOffsetWithinLine =3D 0 =20 - ## __UndoOneChar() method + # __UndoOneChar() method # # Go back one char in the file buffer # @@ -137,7 +140,7 @@ class CodeFragmentCollector: self.CurrentOffsetWithinLine -=3D 1 return True =20 - ## __GetOneChar() method + # __GetOneChar() method # # Move forward one char in the file buffer # @@ -145,12 +148,12 @@ class CodeFragmentCollector: # def __GetOneChar(self): if self.CurrentOffsetWithinLine =3D=3D len(self.Profile.FileLinesL= ist[self.CurrentLineNumber - 1]) - 1: - self.CurrentLineNumber +=3D 1 - self.CurrentOffsetWithinLine =3D 0 + self.CurrentLineNumber +=3D 1 + self.CurrentOffsetWithinLine =3D 0 else: - self.CurrentOffsetWithinLine +=3D 1 + self.CurrentOffsetWithinLine +=3D 1 =20 - ## __CurrentChar() method + # __CurrentChar() method # # Get the char pointed to by the file buffer pointer # @@ -158,11 +161,12 @@ class CodeFragmentCollector: # @retval Char Current char # def __CurrentChar(self): - CurrentChar =3D self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine] + CurrentChar =3D self.Profile.FileLinesList[self.CurrentLineNumber - + 1][self.CurrentOffsetWith= inLine] =20 return CurrentChar =20 - ## __NextChar() method + # __NextChar() method # # Get the one char pass the char pointed to by the file buffer point= er # @@ -175,7 +179,7 @@ class CodeFragmentCollector: else: return self.Profile.FileLinesList[self.CurrentLineNumber - 1][= self.CurrentOffsetWithinLine + 1] =20 - ## __SetCurrentCharValue() method + # __SetCurrentCharValue() method # # Modify the value of current char # @@ -183,9 +187,10 @@ class CodeFragmentCollector: # @param Value The new value of current char # def __SetCurrentCharValue(self, Value): - self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.Curren= tOffsetWithinLine] =3D Value + self.Profile.FileLinesList[self.CurrentLineNumber - + 1][self.CurrentOffsetWithinLine] =3D Va= lue =20 - ## __SetCharValue() method + # __SetCharValue() method # # Modify the value of current char # @@ -195,7 +200,7 @@ class CodeFragmentCollector: def __SetCharValue(self, Line, Offset, Value): self.Profile.FileLinesList[Line - 1][Offset] =3D Value =20 - ## __CurrentLine() method + # __CurrentLine() method # # Get the list that contains current line contents # @@ -205,7 +210,7 @@ class CodeFragmentCollector: def __CurrentLine(self): return self.Profile.FileLinesList[self.CurrentLineNumber - 1] =20 - ## __InsertComma() method + # __InsertComma() method # # Insert ',' to replace PP # @@ -214,9 +219,9 @@ class CodeFragmentCollector: # def __InsertComma(self, Line): =20 - if self.Profile.FileLinesList[Line - 1][0] !=3D T_CHAR_HASH: - BeforeHashPart =3D str(self.Profile.FileLinesList[Line - 1]).s= plit(T_CHAR_HASH)[0] + BeforeHashPart =3D str( + self.Profile.FileLinesList[Line - 1]).split(T_CHAR_HASH)[0] if BeforeHashPart.rstrip().endswith(T_CHAR_COMMA) or BeforeHas= hPart.rstrip().endswith(';'): return =20 @@ -229,9 +234,10 @@ class CodeFragmentCollector: if str(self.Profile.FileLinesList[Line]).lstrip().startswith(',') = or str(self.Profile.FileLinesList[Line]).lstrip().startswith(';'): return =20 - self.Profile.FileLinesList[Line - 1].insert(self.CurrentOffsetWith= inLine, ',') + self.Profile.FileLinesList[Line - + 1].insert(self.CurrentOffsetWithinLine,= ',') =20 - ## PreprocessFileWithClear() method + # PreprocessFileWithClear() method # # Run a preprocess for the file to clean all comments # @@ -249,7 +255,8 @@ class CodeFragmentCollector: InString =3D False InCharLiteral =3D False =20 - self.Profile.FileLinesList =3D [list(s) for s in self.Profile.File= LinesListFromFile] + self.Profile.FileLinesList =3D [ + list(s) for s in self.Profile.FileLinesListFromFile] while not self.__EndOfFile(): =20 if not InComment and self.__CurrentChar() =3D=3D T_CHAR_DOUBLE= _QUOTE: @@ -266,7 +273,8 @@ class CodeFragmentCollector: else: PPExtend =3D False =20 - EndLinePos =3D (self.CurrentLineNumber, self.CurrentOffset= WithinLine) + EndLinePos =3D (self.CurrentLineNumber, + self.CurrentOffsetWithinLine) =20 if InComment and DoubleSlashComment: InComment =3D False @@ -284,7 +292,8 @@ class CodeFragmentCollector: CurrentLine =3D "".join(self.__CurrentLine()) if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).end= swith(T_CHAR_BACKSLASH): SlashIndex =3D CurrentLine.rindex(T_CHAR_BACKSLASH) - self.__SetCharValue(self.CurrentLineNumber, SlashI= ndex, T_CHAR_SPACE) + self.__SetCharValue( + self.CurrentLineNumber, SlashIndex, T_CHAR_SPA= CE) =20 self.CurrentLineNumber +=3D 1 self.CurrentOffsetWithinLine =3D 0 @@ -303,7 +312,8 @@ class CodeFragmentCollector: if self.__CurrentChar() =3D=3D T_CHAR_SLASH and self._= _NextChar() =3D=3D T_CHAR_SLASH: InComment =3D False HashComment =3D False - PPDirectiveObj.EndPos =3D (self.CurrentLineNumber,= self.CurrentOffsetWithinLine - 1) + PPDirectiveObj.EndPos =3D ( + self.CurrentLineNumber, self.CurrentOffsetWith= inLine - 1) FileProfile.PPDirectiveList.append(PPDirectiveObj) PPDirectiveObj =3D None continue @@ -321,13 +331,14 @@ class CodeFragmentCollector: elif self.__CurrentChar() =3D=3D T_CHAR_HASH and not InString = and not InCharLiteral: InComment =3D True HashComment =3D True - PPDirectiveObj =3D PP_Directive('', (self.CurrentLineNumbe= r, self.CurrentOffsetWithinLine), None) + PPDirectiveObj =3D PP_Directive( + '', (self.CurrentLineNumber, self.CurrentOffsetWithinL= ine), None) # check for /* comment start elif self.__CurrentChar() =3D=3D T_CHAR_SLASH and self.__NextC= har() =3D=3D T_CHAR_STAR: =20 - self.__SetCurrentCharValue( T_CHAR_SPACE) + self.__SetCurrentCharValue(T_CHAR_SPACE) self.__GetOneChar() - self.__SetCurrentCharValue( T_CHAR_SPACE) + self.__SetCurrentCharValue(T_CHAR_SPACE) self.__GetOneChar() InComment =3D True else: @@ -340,7 +351,7 @@ class CodeFragmentCollector: FileProfile.PPDirectiveList.append(PPDirectiveObj) self.Rewind() =20 - ## ParseFile() method + # ParseFile() method # # Parse the file profile buffer to extract fd, fv ... information # Exception will be raised if syntax error found @@ -350,7 +361,8 @@ class CodeFragmentCollector: def ParseFile(self): self.PreprocessFileWithClear() # restore from ListOfList to ListOfString - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] + self.Profile.FileLinesList =3D [ + "".join(list) for list in self.Profile.FileLinesList] FileStringContents =3D '' for fileLine in self.Profile.FileLinesList: FileStringContents +=3D fileLine @@ -360,7 +372,7 @@ class CodeFragmentCollector: parser =3D CParser(tStream) parser.translation_unit() =20 - ## CleanFileProfileBuffer() method + # CleanFileProfileBuffer() method # # Reset all contents of the profile of a file # @@ -375,7 +387,7 @@ class CodeFragmentCollector: FileProfile.TypedefDefinitionList =3D [] FileProfile.FunctionCallingList =3D [] =20 - ## PrintFragments() method + # PrintFragments() method # # Print the contents of the profile of a file # @@ -387,7 +399,8 @@ class CodeFragmentCollector: print('/************** ASSIGNMENTS *************/') print('/****************************************/') for assign in FileProfile.AssignmentExpressionList: - print(str(assign.StartPos) + assign.Name + assign.Operator + a= ssign.Value) + print(str(assign.StartPos) + assign.Name + + assign.Operator + assign.Value) =20 print('/****************************************/') print('/********* PREPROCESS DIRECTIVES ********/') @@ -399,13 +412,14 @@ class CodeFragmentCollector: print('/********* VARIABLE DECLARATIONS ********/') print('/****************************************/') for var in FileProfile.VariableDeclarationList: - print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator) + print(str(var.StartPos) + var.Modifier + ' ' + var.Declarator) =20 print('/****************************************/') print('/********* FUNCTION DEFINITIONS *********/') print('/****************************************/') for func in FileProfile.FunctionDefinitionList: - print(str(func.StartPos) + func.Modifier + ' '+ func.Declarato= r + ' ' + str(func.NamePos)) + print(str(func.StartPos) + func.Modifier + ' ' + + func.Declarator + ' ' + str(func.NamePos)) =20 print('/****************************************/') print('/************ ENUMERATIONS **************/') @@ -425,6 +439,7 @@ class CodeFragmentCollector: for typedef in FileProfile.TypedefDefinitionList: print(str(typedef.StartPos) + typedef.ToType) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Eot/Database.py b/BaseTools/Source/Pyt= hon/Eot/Database.py index fca08b96bbdf..46d2773272c9 100644 --- a/BaseTools/Source/Python/Eot/Database.py +++ b/BaseTools/Source/Python/Eot/Database.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by EOT tool # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
        @@ -9,7 +9,8 @@ # Import Modules # import sqlite3 -import Common.LongFilePathOs as os, time +import Common.LongFilePathOs as os +import time =20 import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass @@ -30,14 +31,16 @@ from Table.TableQuery import TableQuery # DATABASE_PATH =3D "Eot.db" =20 -## Database class +# Database class # # This class defined the EOT database # During the phase of initialization, the database will create all tables = and # insert all records of table DataModel # + + class Database(object): - ## The constructor + # The constructor # # @param self: The object pointer # @param DbPath: The file path of the database @@ -58,7 +61,7 @@ class Database(object): self.TblQuery =3D None self.TblQuery2 =3D None =20 - ## InitDatabase() method + # InitDatabase() method # 1. Delete all old existing tables # 2. Create new tables # 3. Initialize table DataModel @@ -66,7 +69,7 @@ class Database(object): # @param self: The object pointer # @param NewDatabase: Check if it needs to create a new database # - def InitDatabase(self, NewDatabase =3D True): + def InitDatabase(self, NewDatabase=3DTrue): EdkLogger.verbose("\nInitialize EOT database started ...") # # Drop all old existing tables @@ -74,7 +77,7 @@ class Database(object): if NewDatabase: if os.path.exists(self.DbPath): os.remove(self.DbPath) - self.Conn =3D sqlite3.connect(self.DbPath, isolation_level =3D 'DE= FERRED') + self.Conn =3D sqlite3.connect(self.DbPath, isolation_level=3D'DEFE= RRED') self.Conn.execute("PRAGMA page_size=3D8192") self.Conn.execute("PRAGMA synchronous=3DOFF") # to avoid non-ascii character conversion error @@ -129,7 +132,7 @@ class Database(object): =20 EdkLogger.verbose("Initialize EOT database ... DONE!") =20 - ## QueryTable() method + # QueryTable() method # # Query a table # @@ -139,7 +142,7 @@ class Database(object): def QueryTable(self, Table): Table.Query() =20 - ## Close() method + # Close() method # # Commit all first # Close the connection and cursor @@ -152,7 +155,7 @@ class Database(object): self.Cur.close() self.Conn.close() =20 - ## InsertOneFile() method + # InsertOneFile() method # # Insert one file's information to the database # 1. Create a record in TableFile @@ -167,37 +170,40 @@ class Database(object): # def InsertOneFile(self, File): # Insert a record for file - FileID =3D self.TblFile.Insert(File.Name, File.ExtName, File.Path,= File.FullPath, Model =3D File.Model, TimeStamp =3D File.TimeStamp) + FileID =3D self.TblFile.Insert( + File.Name, File.ExtName, File.Path, File.FullPath, Model=3DFil= e.Model, TimeStamp=3DFile.TimeStamp) IdTable =3D TableIdentifier(self.Cur) IdTable.Table =3D "Identifier%s" % FileID IdTable.Create() =20 # Insert function of file for Function in File.FunctionList: - FunctionID =3D self.TblFunction.Insert(Function.Header, Functi= on.Modifier, Function.Name, Function.ReturnStatement, \ - Function.StartLine, Function.StartColu= mn, Function.EndLine, Function.EndColumn, \ - Function.BodyStartLine, Function.BodyS= tartColumn, FileID, \ - Function.FunNameStartLine, Function.Fu= nNameStartColumn) + FunctionID =3D self.TblFunction.Insert(Function.Header, Functi= on.Modifier, Function.Name, Function.ReturnStatement, + Function.StartLine, Funct= ion.StartColumn, Function.EndLine, Function.EndColumn, + Function.BodyStartLine, F= unction.BodyStartColumn, FileID, + Function.FunNameStartLine= , Function.FunNameStartColumn) =20 # Insert Identifier of function for Identifier in Function.IdentifierList: - IdentifierID =3D IdTable.Insert(Identifier.Modifier, Ident= ifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \ - FileID, FunctionID, Identifier.Sta= rtLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn) + IdentifierID =3D IdTable.Insert(Identifier.Modifier, Ident= ifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, + FileID, FunctionID, Identifi= er.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndCol= umn) # Insert Identifier of file for Identifier in File.IdentifierList: - IdentifierID =3D IdTable.Insert(Identifier.Modifier, Identifie= r.Type, Identifier.Name, Identifier.Value, Identifier.Model, \ - FileID, -1, Identifier.StartLine, Iden= tifier.StartColumn, Identifier.EndLine, Identifier.EndColumn) + IdentifierID =3D IdTable.Insert(Identifier.Modifier, Identifie= r.Type, Identifier.Name, Identifier.Value, Identifier.Model, + FileID, -1, Identifier.StartLine= , Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn) =20 - EdkLogger.verbose("Insert information from file %s ... DONE!" % Fi= le.FullPath) + EdkLogger.verbose( + "Insert information from file %s ... DONE!" % File.FullPath) =20 - ## UpdateIdentifierBelongsToFunction() method + # UpdateIdentifierBelongsToFunction() method # # Update the field "BelongsToFunction" for each Identifier # # @param self: The object pointer # def UpdateIdentifierBelongsToFunction(self): - EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers star= ted ...") + EdkLogger.verbose( + "Update 'BelongsToFunction' for Identifiers started ...") =20 SqlCommand =3D """select ID, BelongsToFile, StartLine, EndLine fro= m Function""" Records =3D self.TblFunction.Exec(SqlCommand) @@ -210,11 +216,12 @@ class Database(object): EndLine =3D Record[3] =20 SqlCommand =3D """Update Identifier%s set BelongsToFunction = =3D %s where BelongsToFile =3D %s and StartLine > %s and EndLine < %s""" % \ - (BelongsToFile, FunctionID, BelongsToFile, StartLi= ne, EndLine) + (BelongsToFile, FunctionID, BelongsToFile, StartLine, EndL= ine) self.TblIdentifier.Exec(SqlCommand) =20 SqlCommand =3D """Update Identifier%s set BelongsToFunction = =3D %s, Model =3D %s where BelongsToFile =3D %s and Model =3D %s and EndLin= e =3D %s""" % \ - (BelongsToFile, FunctionID, DataClass.MODEL_IDENT= IFIER_FUNCTION_HEADER, BelongsToFile, DataClass.MODEL_IDENTIFIER_COMMENT, S= tartLine - 1) + (BelongsToFile, FunctionID, DataClass.MODEL_IDENT= IFIER_FUNCTION_HEADER, + BelongsToFile, DataClass.MODEL_IDENTIFIER_COMMEN= T, StartLine - 1) self.TblIdentifier.Exec(SqlCommand) =20 =20 @@ -226,18 +233,25 @@ class Database(object): if __name__ =3D=3D '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.DEBUG_0) - EdkLogger.verbose("Start at " + time.strftime('%H:%M:%S', time.localti= me())) + EdkLogger.verbose( + "Start at " + time.strftime('%H:%M:%S', time.localtime())) =20 Db =3D Database(DATABASE_PATH) Db.InitDatabase() Db.QueryTable(Db.TblDataModel) =20 - identifier1 =3D DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', D= ataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 32, 43, 54, 43) - identifier2 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', Dat= aClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 15, 43, 20, 43) - identifier3 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', Dat= aClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 55, 43, 58, 43) - identifier4 =3D DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', Da= taClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 77, 43, 88, 43) - fun1 =3D DataClass.FunctionClass(-1, '', '', 'fun1', '', 21, 2, 60, 4= 5, 1, 23, 0, [], []) - file =3D DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', Data= Class.MODEL_FILE_C, '2007-12-28', [fun1], [identifier1, identifier2, identi= fier3, identifier4], []) + identifier1 =3D DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 32, 43, 54, 43) + identifier2 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 15, 43, 20, 43) + identifier3 =3D DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 55, 43, 58, 43) + identifier4 =3D DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', + DataClass.MODEL_IDENTIFIER_COM= MENT, 1, -1, 77, 43, 88, 43) + fun1 =3D DataClass.FunctionClass(-1, '', '', + 'fun1', '', 21, 2, 60, 45, 1, 23, 0, [= ], []) + file =3D DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', Data= Class.MODEL_FILE_C, + '2007-12-28', [fun1], [identifier1, identif= ier2, identifier3, identifier4], []) Db.InsertOneFile(file) =20 Db.QueryTable(Db.TblFile) @@ -246,4 +260,3 @@ if __name__ =3D=3D '__main__': =20 Db.Close() EdkLogger.verbose("End at " + time.strftime('%H:%M:%S', time.localtime= ())) - diff --git a/BaseTools/Source/Python/Eot/EotGlobalData.py b/BaseTools/Sourc= e/Python/Eot/EotGlobalData.py index 3218f86f441c..be9783707d61 100644 --- a/BaseTools/Source/Python/Eot/EotGlobalData.py +++ b/BaseTools/Source/Python/Eot/EotGlobalData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to save global datas # # Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
        @@ -44,7 +44,8 @@ gOP_UN_DISPATCHED =3D open(gUN_DISPATCHED_LOG, 'w+') =20 # Log file for unmatched variables in function calling gUN_MATCHED_IN_LIBRARY_CALLING_LOG =3D 'Log_UnMatchedInLibraryCalling.log' -gOP_UN_MATCHED_IN_LIBRARY_CALLING =3D open(gUN_MATCHED_IN_LIBRARY_CALLING_= LOG, 'w+') +gOP_UN_MATCHED_IN_LIBRARY_CALLING =3D open( + gUN_MATCHED_IN_LIBRARY_CALLING_LOG, 'w+') =20 # Log file for order of dispatched PEIM/DRIVER gDISPATCH_ORDER_LOG =3D 'Log_DispatchOrder.log' diff --git a/BaseTools/Source/Python/Eot/EotMain.py b/BaseTools/Source/Pyth= on/Eot/EotMain.py index 791fcdfeaed8..f9989bc3de54 100644 --- a/BaseTools/Source/Python/Eot/EotMain.py +++ b/BaseTools/Source/Python/Eot/EotMain.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to be the main entrance of EOT tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -9,7 +9,9 @@ # Import Modules # from __future__ import absolute_import -import Common.LongFilePathOs as os, time, glob +import Common.LongFilePathOs as os +import time +import glob import Common.EdkLogger as EdkLogger import Eot.EotGlobalData as EotGlobalData from optparse import OptionParser @@ -36,6 +38,7 @@ from GenFds.AprioriSection import DXE_APRIORI_GUID, PEI_A= PRIORI_GUID gGuidStringFormat =3D "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X" gIndention =3D -4 =20 + class Image(array): _HEADER_ =3D struct.Struct("") _HEADER_SIZE_ =3D _HEADER_.size @@ -52,7 +55,7 @@ class Image(array): self._LEN_ =3D None self._OFF_ =3D None =20 - self._SubImages =3D sdict() # {offset: Image()} + self._SubImages =3D sdict() # {offset: Image()} =20 array.__init__(self) =20 @@ -66,7 +69,7 @@ class Image(array): return Len =20 def _Unpack(self): - self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + self._LEN_]) return len(self) =20 def _Pack(self, PadByte=3D0xFF): @@ -106,18 +109,20 @@ class Image(array): =20 Data =3D property(_GetData, _SetData) =20 -## CompressedImage() class +# CompressedImage() class # # A class for Compressed Image # + + class CompressedImage(Image): # UncompressedLength =3D 4-byte # CompressionType =3D 1-byte _HEADER_ =3D struct.Struct("1I 1B") _HEADER_SIZE_ =3D _HEADER_.size =20 - _ORIG_SIZE_ =3D struct.Struct("1I") - _CMPRS_TYPE_ =3D struct.Struct("4x 1B") + _ORIG_SIZE_ =3D struct.Struct("1I") + _CMPRS_TYPE_ =3D struct.Struct("4x 1B") =20 def __init__(self, CompressedData=3DNone, CompressionType=3DNone, Unco= mpressedLength=3DNone): Image.__init__(self) @@ -130,7 +135,8 @@ class CompressedImage(Image): =20 def __str__(self): global gIndention - S =3D "algorithm=3D%s uncompressed=3D%x" % (self.CompressionType, = self.UncompressedLength) + S =3D "algorithm=3D%s uncompressed=3D%x" % ( + self.CompressionType, self.UncompressedLength) for Sec in self.Sections: S +=3D '\n' + str(Sec) =20 @@ -175,10 +181,12 @@ class CompressedImage(Image): CompressionType =3D property(_GetCompressionType, _SetCompressionType) Sections =3D property(_GetSections) =20 -## Ui() class +# Ui() class # # A class for Ui # + + class Ui(Image): _HEADER_ =3D struct.Struct("") _HEADER_SIZE_ =3D 0 @@ -192,7 +200,7 @@ class Ui(Image): def _Unpack(self): # keep header in this Image object self.empty() - self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + self._LEN_]) return len(self) =20 def _GetUiString(self): @@ -200,42 +208,44 @@ class Ui(Image): =20 String =3D property(_GetUiString) =20 -## Depex() class +# Depex() class # # A class for Depex # + + class Depex(Image): _HEADER_ =3D struct.Struct("") _HEADER_SIZE_ =3D 0 =20 - _GUID_ =3D struct.Struct("1I2H8B") - _OPCODE_ =3D struct.Struct("1B") + _GUID_ =3D struct.Struct("1I2H8B") + _OPCODE_ =3D struct.Struct("1B") =20 _OPCODE_STRING_ =3D { - 0x00 : "BEFORE", - 0x01 : "AFTER", - 0x02 : "PUSH", - 0x03 : "AND", - 0x04 : "OR", - 0x05 : "NOT", - 0x06 : "TRUE", - 0x07 : "FALSE", - 0x08 : "END", - 0x09 : "SOR" + 0x00: "BEFORE", + 0x01: "AFTER", + 0x02: "PUSH", + 0x03: "AND", + 0x04: "OR", + 0x05: "NOT", + 0x06: "TRUE", + 0x07: "FALSE", + 0x08: "END", + 0x09: "SOR" } =20 _NEXT_ =3D { - -1 : _OPCODE_, # first one in depex must be an opcdoe - 0x00 : _GUID_, #"BEFORE", - 0x01 : _GUID_, #"AFTER", - 0x02 : _GUID_, #"PUSH", - 0x03 : _OPCODE_, #"AND", - 0x04 : _OPCODE_, #"OR", - 0x05 : _OPCODE_, #"NOT", - 0x06 : _OPCODE_, #"TRUE", - 0x07 : _OPCODE_, #"FALSE", - 0x08 : None, #"END", - 0x09 : _OPCODE_, #"SOR" + -1: _OPCODE_, # first one in depex must be an opcdoe + 0x00: _GUID_, # "BEFORE", + 0x01: _GUID_, # "AFTER", + 0x02: _GUID_, # "PUSH", + 0x03: _OPCODE_, # "AND", + 0x04: _OPCODE_, # "OR", + 0x05: _OPCODE_, # "NOT", + 0x06: _OPCODE_, # "TRUE", + 0x07: _OPCODE_, # "FALSE", + 0x08: None, # "END", + 0x09: _OPCODE_, # "SOR" } =20 def __init__(self): @@ -260,7 +270,7 @@ class Depex(Image): def _Unpack(self): # keep header in this Image object self.empty() - self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + self._LEN_]) return len(self) =20 def _GetExpression(self): @@ -289,6 +299,8 @@ class Depex(Image): # # A class for Firmware Volume # + + class FirmwareVolume(Image): # Read FvLength, Attributes, HeaderLength, Checksum _HEADER_ =3D struct.Struct("16x 1I2H8B 1Q 4x 1I 1H 1H") @@ -351,11 +363,15 @@ class FirmwareVolume(Image): DepexList.append(Guid) continue elif Item =3D=3D 0x03 or Item =3D=3D 0x04: - DepexStack.append(eval(str(DepexStack.pop()) + ' ' + Depex= ._OPCODE_STRING_[Item].lower() + ' ' + str(DepexStack.pop()))) - DepexList.append(str(DepexList.pop()) + ' ' + Depex._OPCOD= E_STRING_[Item].upper() + ' ' + str(DepexList.pop())) + DepexStack.append(eval(str(DepexStack.pop( + )) + ' ' + Depex._OPCODE_STRING_[Item].lower() + ' ' + str= (DepexStack.pop()))) + DepexList.append(str(DepexList.pop( + )) + ' ' + Depex._OPCODE_STRING_[Item].upper() + ' ' + str= (DepexList.pop())) elif Item =3D=3D 0x05: - DepexStack.append(eval(Depex._OPCODE_STRING_[Item].lower()= + ' ' + str(DepexStack.pop()))) - DepexList.append(Depex._OPCODE_STRING_[Item].lower() + ' '= + str(DepexList.pop())) + DepexStack.append( + eval(Depex._OPCODE_STRING_[Item].lower() + ' ' + str(D= epexStack.pop()))) + DepexList.append(Depex._OPCODE_STRING_[ + Item].lower() + ' ' + str(DepexList.pop()= )) elif Item =3D=3D 0x06: DepexStack.append(True) DepexList.append('TRUE') @@ -405,12 +421,14 @@ class FirmwareVolume(Image): =20 # Parse SEC_CORE first if FfsSecCoreGuid is not None: - self.OrderedFfsDict[FfsSecCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop(FfsSecCoreGuid) + self.OrderedFfsDict[FfsSecCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop( + FfsSecCoreGuid) self.LoadPpi(Db, FfsSecCoreGuid) =20 # Parse PEI first if FfsPeiCoreGuid is not None: - self.OrderedFfsDict[FfsPeiCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop(FfsPeiCoreGuid) + self.OrderedFfsDict[FfsPeiCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop( + FfsPeiCoreGuid) self.LoadPpi(Db, FfsPeiCoreGuid) if FfsPeiPrioriGuid is not None: # Load PEIM described in priori file @@ -421,18 +439,21 @@ class FirmwareVolume(Image): GuidStruct =3D struct.Struct('1I2H8B') Start =3D 4 while len(Section) > Start: - Guid =3D GuidStruct.unpack_from(Section[Start = : Start + 16]) + Guid =3D GuidStruct.unpack_from( + Section[Start: Start + 16]) GuidString =3D gGuidStringFormat % Guid Start =3D Start + 16 if GuidString in self.UnDispatchedFfsDict: - self.OrderedFfsDict[GuidString] =3D self.U= nDispatchedFfsDict.pop(GuidString) + self.OrderedFfsDict[GuidString] =3D self.U= nDispatchedFfsDict.pop( + GuidString) self.LoadPpi(Db, GuidString) =20 self.DisPatchPei(Db) =20 # Parse DXE then if FfsDxeCoreGuid is not None: - self.OrderedFfsDict[FfsDxeCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop(FfsDxeCoreGuid) + self.OrderedFfsDict[FfsDxeCoreGuid] =3D self.UnDispatchedFfsDi= ct.pop( + FfsDxeCoreGuid) self.LoadProtocol(Db, FfsDxeCoreGuid) if FfsDxePrioriGuid is not None: # Load PEIM described in priori file @@ -443,11 +464,13 @@ class FirmwareVolume(Image): GuidStruct =3D struct.Struct('1I2H8B') Start =3D 4 while len(Section) > Start: - Guid =3D GuidStruct.unpack_from(Section[Start = : Start + 16]) + Guid =3D GuidStruct.unpack_from( + Section[Start: Start + 16]) GuidString =3D gGuidStringFormat % Guid Start =3D Start + 16 if GuidString in self.UnDispatchedFfsDict: - self.OrderedFfsDict[GuidString] =3D self.U= nDispatchedFfsDict.pop(GuidString) + self.OrderedFfsDict[GuidString] =3D self.U= nDispatchedFfsDict.pop( + GuidString) self.LoadProtocol(Db, GuidString) =20 self.DisPatchDxe(Db) @@ -503,21 +526,24 @@ class FirmwareVolume(Image): # Find Depex if Section.Type =3D=3D 0x13: IsFoundDepex =3D True - CouldBeLoaded, DepexString, FileDepex =3D self.Par= seDepex(Section._SubImages[4], 'Protocol') + CouldBeLoaded, DepexString, FileDepex =3D self.Par= seDepex( + Section._SubImages[4], 'Protocol') break if Section.Type =3D=3D 0x01: CompressSections =3D Section._SubImages[4] for CompressSection in CompressSections.Sections: if CompressSection.Type =3D=3D 0x13: IsFoundDepex =3D True - CouldBeLoaded, DepexString, FileDepex =3D = self.ParseDepex(CompressSection._SubImages[4], 'Protocol') + CouldBeLoaded, DepexString, FileDepex =3D = self.ParseDepex( + CompressSection._SubImages[4], 'Protoc= ol') break if CompressSection.Type =3D=3D 0x02: NewSections =3D CompressSection._SubImages= [4] for NewSection in NewSections.Sections: if NewSection.Type =3D=3D 0x13: IsFoundDepex =3D True - CouldBeLoaded, DepexString, FileDe= pex =3D self.ParseDepex(NewSection._SubImages[4], 'Protocol') + CouldBeLoaded, DepexString, FileDe= pex =3D self.ParseDepex( + NewSection._SubImages[4], 'Pro= tocol') break =20 # Not find Depex @@ -532,7 +558,8 @@ class FirmwareVolume(Image): NewFfs =3D self.UnDispatchedFfsDict.pop(FfsID) NewFfs.Depex =3D DepexString if FileDepex is not None: - ScheduleList.insert(FileDepex[1], FfsID, NewFfs, F= ileDepex[0]) + ScheduleList.insert( + FileDepex[1], FfsID, NewFfs, FileDepex[0]) else: ScheduleList[FfsID] =3D NewFfs else: @@ -565,19 +592,22 @@ class FirmwareVolume(Image): # Get Depex for Section in Ffs.Sections.values(): if Section.Type =3D=3D 0x1B: - CouldBeLoaded, DepexString, FileDepex =3D self.Par= seDepex(Section._SubImages[4], 'Ppi') + CouldBeLoaded, DepexString, FileDepex =3D self.Par= seDepex( + Section._SubImages[4], 'Ppi') break if Section.Type =3D=3D 0x01: CompressSections =3D Section._SubImages[4] for CompressSection in CompressSections.Sections: if CompressSection.Type =3D=3D 0x1B: - CouldBeLoaded, DepexString, FileDepex =3D = self.ParseDepex(CompressSection._SubImages[4], 'Ppi') + CouldBeLoaded, DepexString, FileDepex =3D = self.ParseDepex( + CompressSection._SubImages[4], 'Ppi') break if CompressSection.Type =3D=3D 0x02: NewSections =3D CompressSection._SubImages= [4] for NewSection in NewSections.Sections: if NewSection.Type =3D=3D 0x1B: - CouldBeLoaded, DepexString, FileDe= pex =3D self.ParseDepex(NewSection._SubImages[4], 'Ppi') + CouldBeLoaded, DepexString, FileDe= pex =3D self.ParseDepex( + NewSection._SubImages[4], 'Ppi= ') break =20 # Append New Ffs @@ -593,13 +623,14 @@ class FirmwareVolume(Image): if IsInstalled: self.DisPatchPei(Db) =20 - def __str__(self): global gIndention gIndention +=3D 4 FvInfo =3D '\n' + ' ' * gIndention - FvInfo +=3D "[FV:%s] file_system=3D%s size=3D%x checksum=3D%s\n" %= (self.Name, self.FileSystemGuid, self.Size, self.Checksum) - FfsInfo =3D "\n".join([str(self.FfsDict[FfsId]) for FfsId in self.= FfsDict]) + FvInfo +=3D "[FV:%s] file_system=3D%s size=3D%x checksum=3D%s\n" %= ( + self.Name, self.FileSystemGuid, self.Size, self.Checksum) + FfsInfo =3D "\n".join([str(self.FfsDict[FfsId]) + for FfsId in self.FfsDict]) gIndention -=3D 4 return FvInfo + FfsInfo =20 @@ -617,18 +648,20 @@ class FirmwareVolume(Image): FfsObj.frombuffer(self, FfsStartAddress) FfsId =3D repr(FfsObj) if ((self.Attributes & 0x00000800) !=3D 0 and len(FfsObj) =3D= =3D 0xFFFFFF) \ - or ((self.Attributes & 0x00000800) =3D=3D 0 and len(FfsObj= ) =3D=3D 0): + or ((self.Attributes & 0x00000800) =3D=3D 0 and len(Ff= sObj) =3D=3D 0): if LastFfsObj is not None: - LastFfsObj.FreeSpace =3D EndOfFv - LastFfsObj._OFF_ - = len(LastFfsObj) + LastFfsObj.FreeSpace =3D EndOfFv - \ + LastFfsObj._OFF_ - len(LastFfsObj) else: if FfsId in self.FfsDict: EdkLogger.error("FV", 0, "Duplicate GUID in FFS", - ExtraData=3D"\t%s @ %s\n\t%s @ %s" \ + ExtraData=3D"\t%s @ %s\n\t%s @ %s" % (FfsObj.Guid, FfsObj.Offset, self.FfsDict[FfsId].Guid, self.FfsD= ict[FfsId].Offset)) self.FfsDict[FfsId] =3D FfsObj if LastFfsObj is not None: - LastFfsObj.FreeSpace =3D FfsStartAddress - LastFfsObj.= _OFF_ - len(LastFfsObj) + LastFfsObj.FreeSpace =3D FfsStartAddress - \ + LastFfsObj._OFF_ - len(LastFfsObj) =20 FfsStartAddress +=3D len(FfsObj) # @@ -659,21 +692,23 @@ class FirmwareVolume(Image): HeaderSize =3D property(_GetHeaderLength) FileSystemGuid =3D property(_GetFileSystemGuid) =20 -## GuidDefinedImage() class +# GuidDefinedImage() class # # A class for GUID Defined Image # + + class GuidDefinedImage(Image): _HEADER_ =3D struct.Struct("1I2H8B 1H 1H") _HEADER_SIZE_ =3D _HEADER_.size =20 - _GUID_ =3D struct.Struct("1I2H8B") - _DATA_OFFSET_ =3D struct.Struct("16x 1H") - _ATTR_ =3D struct.Struct("18x 1H") + _GUID_ =3D struct.Struct("1I2H8B") + _DATA_OFFSET_ =3D struct.Struct("16x 1H") + _ATTR_ =3D struct.Struct("18x 1H") =20 - CRC32_GUID =3D "FC1BCDB0-7D31-49AA-936A-A4600D9DD083" + CRC32_GUID =3D "FC1BCDB0-7D31-49AA-936A-A4600D9DD083" TIANO_COMPRESS_GUID =3D 'A31280AD-481E-41B6-95E8-127F4C984779' - LZMA_COMPRESS_GUID =3D 'EE4E5898-3914-4259-9D6E-DC7BD79403CF' + LZMA_COMPRESS_GUID =3D 'EE4E5898-3914-4259-9D6E-DC7BD79403CF' =20 def __init__(self, SectionDefinitionGuid=3DNone, DataOffset=3DNone, At= tributes=3DNone, Data=3DNone): Image.__init__(self) @@ -695,7 +730,7 @@ class GuidDefinedImage(Image): def _Unpack(self): # keep header in this Image object self.empty() - self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + self._LEN_]) return len(self) =20 def _SetAttribute(self, Attribute): @@ -781,35 +816,37 @@ class GuidDefinedImage(Image): DataOffset =3D property(_GetDataOffset, _SetDataOffset) Sections =3D property(_GetSections) =20 -## Section() class +# Section() class # # A class for Section # + + class Section(Image): _TypeName =3D { - 0x00 : "", - 0x01 : "COMPRESSION", - 0x02 : "GUID_DEFINED", - 0x10 : "PE32", - 0x11 : "PIC", - 0x12 : "TE", - 0x13 : "DXE_DEPEX", - 0x14 : "VERSION", - 0x15 : "USER_INTERFACE", - 0x16 : "COMPATIBILITY16", - 0x17 : "FIRMWARE_VOLUME_IMAGE", - 0x18 : "FREEFORM_SUBTYPE_GUID", - 0x19 : "RAW", - 0x1B : "PEI_DEPEX" + 0x00: "", + 0x01: "COMPRESSION", + 0x02: "GUID_DEFINED", + 0x10: "PE32", + 0x11: "PIC", + 0x12: "TE", + 0x13: "DXE_DEPEX", + 0x14: "VERSION", + 0x15: "USER_INTERFACE", + 0x16: "COMPATIBILITY16", + 0x17: "FIRMWARE_VOLUME_IMAGE", + 0x18: "FREEFORM_SUBTYPE_GUID", + 0x19: "RAW", + 0x1B: "PEI_DEPEX" } =20 _SectionSubImages =3D { - 0x01 : CompressedImage, - 0x02 : GuidDefinedImage, - 0x17 : FirmwareVolume, - 0x13 : Depex, - 0x1B : Depex, - 0x15 : Ui + 0x01: CompressedImage, + 0x02: GuidDefinedImage, + 0x17: FirmwareVolume, + 0x13: Depex, + 0x1B: Depex, + 0x15: Ui } =20 # Size =3D 3-byte @@ -819,8 +856,8 @@ class Section(Image): =20 # SubTypeGuid # _FREE_FORM_SUBTYPE_GUID_HEADER_ =3D struct.Struct("1I2H8B") - _SIZE_ =3D struct.Struct("3B") - _TYPE_ =3D struct.Struct("3x 1B") + _SIZE_ =3D struct.Struct("3B") + _TYPE_ =3D struct.Struct("3x 1B") =20 def __init__(self, Type=3DNone, Size=3DNone): Image.__init__(self) @@ -835,9 +872,11 @@ class Section(Image): gIndention +=3D 4 SectionInfo =3D ' ' * gIndention if self.Type in self._TypeName: - SectionInfo +=3D "[SECTION:%s] offset=3D%x size=3D%x" % (self.= _TypeName[self.Type], self._OFF_, self.Size) + SectionInfo +=3D "[SECTION:%s] offset=3D%x size=3D%x" % ( + self._TypeName[self.Type], self._OFF_, self.Size) else: - SectionInfo +=3D "[SECTION:%x] offset=3D%x size=3D%x = " % (self.Type, self._OFF_, self.Size) + SectionInfo +=3D "[SECTION:%x] offset=3D%x size=3D%x = " % ( + self.Type, self._OFF_, self.Size) for Offset in self._SubImages.keys(): SectionInfo +=3D ", " + str(self._SubImages[Offset]) gIndention -=3D 4 @@ -851,10 +890,11 @@ class Section(Image): =20 if Type not in self._SectionSubImages: # no need to extract sub-image, keep all in this Image object - self.extend(self._BUF_[self._OFF_ : self._OFF_ + Size]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + Size]) else: # keep header in this Image object - self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._HEADER_= SIZE_]) + self.extend( + self._BUF_[self._OFF_: self._OFF_ + self._HEADER_SIZE_]) # # use new Image object to represent payload, which may be anot= her kind # of image such as PE32 @@ -862,7 +902,8 @@ class Section(Image): PayloadOffset =3D self._HEADER_SIZE_ PayloadLen =3D self.Size - self._HEADER_SIZE_ Payload =3D self._SectionSubImages[self.Type]() - Payload.frombuffer(self._BUF_, self._OFF_ + self._HEADER_SIZE_= , PayloadLen) + Payload.frombuffer(self._BUF_, self._OFF_ + + self._HEADER_SIZE_, PayloadLen) self._SubImages[PayloadOffset] =3D Payload =20 return Size @@ -907,51 +948,53 @@ class Section(Image): Size =3D property(_GetSize, _SetSize) Alignment =3D property(_GetAlignment, _SetAlignment) =20 -## Ffs() class +# Ffs() class # # A class for Ffs Section # + + class Ffs(Image): _FfsFormat =3D "24B%(payload_size)sB" # skip IntegrityCheck _HEADER_ =3D struct.Struct("1I2H8B 2x 1B 1B 3B 1B") _HEADER_SIZE_ =3D _HEADER_.size =20 - _NAME_ =3D struct.Struct("1I2H8B") + _NAME_ =3D struct.Struct("1I2H8B") _INT_CHECK_ =3D struct.Struct("16x 1H") - _TYPE_ =3D struct.Struct("18x 1B") - _ATTR_ =3D struct.Struct("19x 1B") - _SIZE_ =3D struct.Struct("20x 3B") - _STATE_ =3D struct.Struct("23x 1B") + _TYPE_ =3D struct.Struct("18x 1B") + _ATTR_ =3D struct.Struct("19x 1B") + _SIZE_ =3D struct.Struct("20x 3B") + _STATE_ =3D struct.Struct("23x 1B") =20 - FFS_ATTRIB_FIXED =3D 0x04 - FFS_ATTRIB_DATA_ALIGNMENT =3D 0x38 - FFS_ATTRIB_CHECKSUM =3D 0x40 + FFS_ATTRIB_FIXED =3D 0x04 + FFS_ATTRIB_DATA_ALIGNMENT =3D 0x38 + FFS_ATTRIB_CHECKSUM =3D 0x40 =20 _TypeName =3D { - 0x00 : "", - 0x01 : "RAW", - 0x02 : "FREEFORM", - 0x03 : "SECURITY_CORE", - 0x04 : "PEI_CORE", - 0x05 : "DXE_CORE", - 0x06 : "PEIM", - 0x07 : "DRIVER", - 0x08 : "COMBINED_PEIM_DRIVER", - 0x09 : "APPLICATION", - 0x0A : "SMM", - 0x0B : "FIRMWARE_VOLUME_IMAGE", - 0x0C : "COMBINED_SMM_DXE", - 0x0D : "SMM_CORE", - 0x0E : "MM_STANDALONE", - 0x0F : "MM_CORE_STANDALONE", - 0xc0 : "OEM_MIN", - 0xdf : "OEM_MAX", - 0xe0 : "DEBUG_MIN", - 0xef : "DEBUG_MAX", - 0xf0 : "FFS_MIN", - 0xff : "FFS_MAX", - 0xf0 : "FFS_PAD", + 0x00: "", + 0x01: "RAW", + 0x02: "FREEFORM", + 0x03: "SECURITY_CORE", + 0x04: "PEI_CORE", + 0x05: "DXE_CORE", + 0x06: "PEIM", + 0x07: "DRIVER", + 0x08: "COMBINED_PEIM_DRIVER", + 0x09: "APPLICATION", + 0x0A: "SMM", + 0x0B: "FIRMWARE_VOLUME_IMAGE", + 0x0C: "COMBINED_SMM_DXE", + 0x0D: "SMM_CORE", + 0x0E: "MM_STANDALONE", + 0x0F: "MM_CORE_STANDALONE", + 0xc0: "OEM_MIN", + 0xdf: "OEM_MAX", + 0xe0: "DEBUG_MIN", + 0xef: "DEBUG_MAX", + 0xf0: "FFS_MIN", + 0xff: "FFS_MAX", + 0xf0: "FFS_PAD", } =20 def __init__(self): @@ -968,9 +1011,11 @@ class Ffs(Image): gIndention +=3D 4 Indention =3D ' ' * gIndention FfsInfo =3D Indention - FfsInfo +=3D "[FFS:%s] offset=3D%x size=3D%x guid=3D%s free_space= =3D%x alignment=3D%s\n" % \ - (Ffs._TypeName[self.Type], self._OFF_, self.Size, self= .Guid, self.FreeSpace, self.Alignment) - SectionInfo =3D '\n'.join([str(self.Sections[Offset]) for Offset i= n self.Sections.keys()]) + FfsInfo +=3D "[FFS:%s] offset=3D%x size=3D%x guid=3D%s free_space= =3D%x alignment=3D%s\n" % \ + (Ffs._TypeName[self.Type], self._OFF_, self.Size, + self.Guid, self.FreeSpace, self.Alignment) + SectionInfo =3D '\n'.join([str(self.Sections[Offset]) + for Offset in self.Sections.keys()]) gIndention -=3D 4 return FfsInfo + SectionInfo + "\n" =20 @@ -984,7 +1029,7 @@ class Ffs(Image): Size1, Size2, Size3 =3D self._SIZE_.unpack_from(self._BUF_, self._= OFF_) Size =3D Size1 + (Size2 << 8) + (Size3 << 16) self.empty() - self.extend(self._BUF_[self._OFF_ : self._OFF_ + Size]) + self.extend(self._BUF_[self._OFF_: self._OFF_ + Size]) =20 # Pad FFS may use the same GUID. We need to avoid it. if self.Type =3D=3D 0xf0: @@ -1001,8 +1046,8 @@ class Ffs(Image): SectionObj.frombuffer(self, SectionStartAddress) #f =3D open(repr(SectionObj), 'wb') #SectionObj.Size =3D 0 - #SectionObj.tofile(f) - #f.close() + # SectionObj.tofile(f) + # f.close() self.Sections[SectionStartAddress] =3D SectionObj SectionStartAddress +=3D len(SectionObj) SectionStartAddress =3D (SectionStartAddress + 3) & (~3) @@ -1076,7 +1121,7 @@ class Ffs(Image): State =3D property(_GetState, _SetState) =20 =20 -## MultipleFv() class +# MultipleFv() class # # A class for Multiple FV # @@ -1101,18 +1146,20 @@ class MultipleFv(FirmwareVolume): self.BasicInfo.append([Fv.Name, Fv.FileSystemGuid, Fv.Size]) self.FfsDict.update(Fv.FfsDict) =20 -## Class Eot +# Class Eot # # This class is used to define Eot main entrance # # @param object: Inherited from object class # + + class Eot(object): - ## The constructor + # The constructor # # @param self: The object pointer # - def __init__(self, CommandLineOption=3DTrue, IsInit=3DTrue, SourceFile= List=3DNone, \ + def __init__(self, CommandLineOption=3DTrue, IsInit=3DTrue, SourceFile= List=3DNone, IncludeDirList=3DNone, DecFileList=3DNone, GuidList=3DNon= e, LogFile=3DNone, FvFileList=3D"", MapFileList=3D"", Report=3D'Report.html'= , Dispatch=3DNone): # Version and Copyright @@ -1136,10 +1183,13 @@ class Eot(object): if "EDK_SOURCE" not in os.environ: pass else: - EotGlobalData.gEDK_SOURCE =3D os.path.normpath(os.getenv("= EDK_SOURCE")) + EotGlobalData.gEDK_SOURCE =3D os.path.normpath( + os.getenv("EDK_SOURCE")) else: - EotGlobalData.gEFI_SOURCE =3D os.path.normpath(os.getenv("EFI_= SOURCE")) - EotGlobalData.gEDK_SOURCE =3D os.path.join(EotGlobalData.gEFI_= SOURCE, 'Edk') + EotGlobalData.gEFI_SOURCE =3D os.path.normpath( + os.getenv("EFI_SOURCE")) + EotGlobalData.gEDK_SOURCE =3D os.path.join( + EotGlobalData.gEFI_SOURCE, 'Edk') =20 if "WORKSPACE" not in os.environ: EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE,= "Environment variable not found", @@ -1159,16 +1209,19 @@ class Eot(object): for FvFile in GetSplitValueList(self.FvFileList, ' '): FvFile =3D os.path.normpath(FvFile) if not os.path.isfile(FvFile): - EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not f= ind file %s " % FvFile) + EdkLogger.error("Eot", EdkLogger.EOT_ERROR, + "Can not find file %s " % FvFile) EotGlobalData.gFV_FILE.append(FvFile) else: - EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list = of target platform was not specified") + EdkLogger.error("Eot", EdkLogger.EOT_ERROR, + "The fv file list of target platform was not s= pecified") =20 if self.MapFileList: for MapFile in GetSplitValueList(self.MapFileList, ' '): MapFile =3D os.path.normpath(MapFile) if not os.path.isfile(MapFile): - EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not f= ind file %s " % MapFile) + EdkLogger.error("Eot", EdkLogger.EOT_ERROR, + "Can not find file %s " % MapFile) EotGlobalData.gMAP_FILE.append(MapFile) =20 # Generate source file list @@ -1214,7 +1267,7 @@ class Eot(object): # Close Database EotGlobalData.gDb.Close() =20 - ## ParseDecFile() method + # ParseDecFile() method # # parse DEC file and get all GUID names with GUID values as {GuidName= : GuidValue} # The Dict is stored in EotGlobalData.gGuidDict @@ -1227,17 +1280,18 @@ class Eot(object): path =3D os.path.normpath(DecFileList) lfr =3D open(path, 'rb') for line in lfr: - path =3D os.path.normpath(os.path.join(EotGlobalData.gWORK= SPACE, line.strip())) + path =3D os.path.normpath(os.path.join( + EotGlobalData.gWORKSPACE, line.strip())) if os.path.exists(path): dfr =3D open(path, 'rb') for line in dfr: line =3D CleanString(line) list =3D line.split('=3D') if len(list) =3D=3D 2: - EotGlobalData.gGuidDict[list[0].strip()] =3D G= uidStructureStringToGuidString(list[1].strip()) + EotGlobalData.gGuidDict[list[0].strip( + )] =3D GuidStructureStringToGuidString(list[1]= .strip()) =20 - - ## ParseGuidList() method + # ParseGuidList() method # # Parse Guid list and get all GUID names with GUID values as {GuidNam= e : GuidValue} # The Dict is stored in EotGlobalData.gGuidDict @@ -1245,6 +1299,7 @@ class Eot(object): # @param self: The object pointer # @param GuidList: A list of all GUID and its value # + def ParseGuidList(self, GuidList): Path =3D os.path.join(EotGlobalData.gWORKSPACE, GuidList) if os.path.isfile(Path): @@ -1253,7 +1308,7 @@ class Eot(object): (GuidName, GuidValue) =3D Line.split() EotGlobalData.gGuidDict[GuidName] =3D GuidValue =20 - ## ConvertLogFile() method + # ConvertLogFile() method # # Parse a real running log file to get real dispatch order # The result is saved to old file name + '.new' @@ -1273,11 +1328,11 @@ class Eot(object): line =3D line.replace('.efi', '') index =3D line.find("Loading PEIM at ") if index > -1: - newline.append(line[index + 55 : ]) + newline.append(line[index + 55:]) continue index =3D line.find("Loading driver at ") if index > -1: - newline.append(line[index + 57 : ]) + newline.append(line[index + 57:]) continue =20 for line in newline: @@ -1288,7 +1343,7 @@ class Eot(object): if lfw: lfw.close() =20 - ## GenerateSourceFileList() method + # GenerateSourceFileList() method # # Generate a list of all source files # 1. Search the file list one by one @@ -1314,8 +1369,9 @@ class Eot(object): if SourceFileList: sfl =3D open(SourceFileList, 'r') for line in sfl: - line =3D os.path.normpath(os.path.join(EotGlobalData.gWORK= SPACE, line.strip())) - if line[-2:].upper() =3D=3D '.C' or line[-2:].upper() =3D= =3D '.H': + line =3D os.path.normpath(os.path.join( + EotGlobalData.gWORKSPACE, line.strip())) + if line[-2:].upper() =3D=3D '.C' or line[-2:].upper() =3D= =3D '.H': if line not in mCurrentSourceFileList: mCurrentSourceFileList.append(line) mSourceFileList.append(line) @@ -1324,7 +1380,8 @@ class Eot(object): if mCurrentInfFile !=3D '': mFileList[mCurrentInfFile] =3D mCurrentSourceFileL= ist mCurrentSourceFileList =3D [] - mCurrentInfFile =3D os.path.normpath(os.path.join(EotG= lobalData.gWORKSPACE, line)) + mCurrentInfFile =3D os.path.normpath( + os.path.join(EotGlobalData.gWORKSPACE, line)) EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile) if mCurrentInfFile not in mFileList: mFileList[mCurrentInfFile] =3D mCurrentSourceFileList @@ -1335,13 +1392,15 @@ class Eot(object): for line in ifl: if not line.strip(): continue - newline =3D os.path.normpath(os.path.join(EotGlobalData.gW= ORKSPACE, line.strip())) + newline =3D os.path.normpath(os.path.join( + EotGlobalData.gWORKSPACE, line.strip())) for Root, Dirs, Files in os.walk(str(newline)): for File in Files: FullPath =3D os.path.normpath(os.path.join(Root, F= ile)) if FullPath not in mSourceFileList and File[-2:].u= pper() =3D=3D '.H': mSourceFileList.append(FullPath) - EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % = FullPath) + EotGlobalData.gOP_SOURCE_FILES.write( + '%s\n' % FullPath) if FullPath not in mDecFileList and File.upper().f= ind('.DEC') > -1: mDecFileList.append(FullPath) =20 @@ -1351,7 +1410,7 @@ class Eot(object): EotGlobalData.gINF_FILES =3D mFileList EotGlobalData.gOP_INF.close() =20 - ## GenerateReport() method + # GenerateReport() method # # Generate final HTML report # @@ -1362,7 +1421,7 @@ class Eot(object): Rep =3D Report(self.Report, EotGlobalData.gFV, self.Dispatch) Rep.GenerateReport() =20 - ## LoadMapInfo() method + # LoadMapInfo() method # # Load map files and parse them # @@ -1373,7 +1432,7 @@ class Eot(object): EdkLogger.quiet("Parsing Map file ... ") EotGlobalData.gMap =3D ParseMapFile(EotGlobalData.gMAP_FILE) =20 - ## LoadFvInfo() method + # LoadFvInfo() method # # Load FV binary files and parse them # @@ -1385,9 +1444,10 @@ class Eot(object): EotGlobalData.gFV.Dispatch(EotGlobalData.gDb) =20 for Protocol in EotGlobalData.gProtocolList: - EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %= Protocol) + EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write( + '%s\n' % Protocol) =20 - ## GenerateReportDatabase() method + # GenerateReportDatabase() method # # Generate data for the information needed by report # 1. Update name, macro and value of all found PPI/PROTOCOL GUID @@ -1396,7 +1456,8 @@ class Eot(object): # @param self: The object pointer # def GenerateReportDatabase(self): - EdkLogger.quiet("Generating the cross-reference table of GUID for = Ppi/Protocol ... ") + EdkLogger.quiet( + "Generating the cross-reference table of GUID for Ppi/Protocol= ... ") =20 # Update Protocol/Ppi Guid SqlCommand =3D """select DISTINCT GuidName from Report""" @@ -1410,12 +1471,13 @@ class Eot(object): # Find guid value defined in Dec file if GuidName in EotGlobalData.gGuidDict: GuidValue =3D EotGlobalData.gGuidDict[GuidName] - SqlCommand =3D """update Report set GuidMacro =3D '%s', Gu= idValue =3D '%s' where GuidName =3D '%s'""" %(GuidMacro, GuidValue, GuidNam= e) + SqlCommand =3D """update Report set GuidMacro =3D '%s', Gu= idValue =3D '%s' where GuidName =3D '%s'""" % ( + GuidMacro, GuidValue, GuidName) EotGlobalData.gDb.TblReport.Exec(SqlCommand) continue =20 # Search defined Macros for guid name - SqlCommand =3D"""select DISTINCT Value, Modifier from Query wh= ere Name like '%s'""" % GuidName + SqlCommand =3D """select DISTINCT Value, Modifier from Query w= here Name like '%s'""" % GuidName GuidMacroSet =3D EotGlobalData.gDb.TblReport.Exec(SqlCommand) # Ignore NULL result if not GuidMacroSet: @@ -1424,14 +1486,18 @@ class Eot(object): if not GuidMacro: continue # Find Guid value of Guid Macro - SqlCommand =3D"""select DISTINCT Value from Query2 where Value= like '%%%s%%' and Model =3D %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEF= INE) + SqlCommand =3D """select DISTINCT Value from Query2 where Valu= e like '%%%s%%' and Model =3D %s""" % ( + GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE) GuidValueSet =3D EotGlobalData.gDb.TblReport.Exec(SqlCommand) if GuidValueSet !=3D []: GuidValue =3D GuidValueSet[0][0] - GuidValue =3D GuidValue[GuidValue.find(GuidMacro) + len(Gu= idMacro) :] - GuidValue =3D GuidValue.lower().replace('\\', '').replace(= '\r', '').replace('\n', '').replace('l', '').strip() + GuidValue =3D GuidValue[GuidValue.find( + GuidMacro) + len(GuidMacro):] + GuidValue =3D GuidValue.lower().replace('\\', '').replace( + '\r', '').replace('\n', '').replace('l', '').strip() GuidValue =3D GuidStructureStringToGuidString(GuidValue) - SqlCommand =3D """update Report set GuidMacro =3D '%s', Gu= idValue =3D '%s' where GuidName =3D '%s'""" %(GuidMacro, GuidValue, GuidNam= e) + SqlCommand =3D """update Report set GuidMacro =3D '%s', Gu= idValue =3D '%s' where GuidName =3D '%s'""" % ( + GuidMacro, GuidValue, GuidName) EotGlobalData.gDb.TblReport.Exec(SqlCommand) continue =20 @@ -1444,7 +1510,7 @@ class Eot(object): if Record[1] =3D=3D 'Protocol': EotGlobalData.gProtocolList[Record[0].lower()] =3D -2 =20 - ## GenerateQueryTable() method + # GenerateQueryTable() method # # Generate two tables improve query performance # @@ -1462,7 +1528,7 @@ class Eot(object): % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFIN= E) EotGlobalData.gDb.TblReport.Exec(SqlCommand) =20 - ## ParseExecutionOrder() method + # ParseExecutionOrder() method # # Get final execution order # 1. Search all PPI @@ -1474,7 +1540,7 @@ class Eot(object): EdkLogger.quiet("Searching Ppi/Protocol ... ") for Identifier in EotGlobalData.gIdentifierTableList: ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFull= Path, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, Belongs= ToFunction, Enabled =3D \ - -1, '', '', -1, '', '', '', '', '', '', '', '', 0 + -1, '', '', -1, '', '', '', '', '', '', '', '', 0 =20 SourceFileID =3D Identifier[0].replace('Identifier', '') SourceFileFullPath =3D Identifier[1] @@ -1485,85 +1551,108 @@ class Eot(object): SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ' or Name like '%%%s%%') and Model =3D %s""" \ % (Identifier, '.InstallPpi', '->InstallPpi', = 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFull= Path, ItemMode) + SearchPpi(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode) =20 ItemMode =3D 'Produced' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.ReInstallPpi', '->ReInstallPp= i', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFull= Path, ItemMode, 2) + SearchPpi(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 2) =20 - SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFull= Path, ItemMode) + SearchPpiCallFunction(Identifier, SourceFileID, + SourceFileFullPath, ItemMode) =20 ItemMode =3D 'Consumed' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.LocatePpi', '->LocatePpi', MO= DEL_IDENTIFIER_FUNCTION_CALLING) - SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFull= Path, ItemMode) + SearchPpi(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode) =20 - SearchFunctionCalling(Identifier, SourceFileID, SourceFileFull= Path, 'Ppi', ItemMode) + SearchFunctionCalling(Identifier, SourceFileID, + SourceFileFullPath, 'Ppi', ItemMode) =20 ItemMode =3D 'Callback' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.NotifyPpi', '->NotifyPpi', MO= DEL_IDENTIFIER_FUNCTION_CALLING) - SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFull= Path, ItemMode) + SearchPpi(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode) =20 # Find Protocols ItemMode =3D 'Produced' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ' or Name like '%%%s%%' or Name like '%%%s%%') and Model =3D %s""" \ % (Identifier, '.InstallProtocolInterface', '.= ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProt= ocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFi= leFullPath, ItemMode, 1) + SearchProtocols(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 1) =20 SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.InstallMultipleProtocolInterf= aces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CAL= LING) - SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFi= leFullPath, ItemMode, 2) + SearchProtocols(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 2) =20 - SearchFunctionCalling(Identifier, SourceFileID, SourceFileFull= Path, 'Protocol', ItemMode) + SearchFunctionCalling(Identifier, SourceFileID, + SourceFileFullPath, 'Protocol', ItemMode) =20 ItemMode =3D 'Consumed' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.LocateProtocol', '->LocatePro= tocol', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFi= leFullPath, ItemMode, 0) + SearchProtocols(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 0) =20 SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.HandleProtocol', '->HandlePro= tocol', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFi= leFullPath, ItemMode, 1) + SearchProtocols(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 1) =20 - SearchFunctionCalling(Identifier, SourceFileID, SourceFileFull= Path, 'Protocol', ItemMode) + SearchFunctionCalling(Identifier, SourceFileID, + SourceFileFullPath, 'Protocol', ItemMode) =20 ItemMode =3D 'Callback' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine= , EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%= ') and Model =3D %s""" \ % (Identifier, '.RegisterProtocolNotify', '->R= egisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING) - SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFi= leFullPath, ItemMode, 0) + SearchProtocols(SqlCommand, Identifier, SourceFileID, + SourceFileFullPath, ItemMode, 0) =20 - SearchFunctionCalling(Identifier, SourceFileID, SourceFileFull= Path, 'Protocol', ItemMode) + SearchFunctionCalling(Identifier, SourceFileID, + SourceFileFullPath, 'Protocol', ItemMode) =20 # Hard Code - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gNtFwhPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0) - EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', = 'Produced', 'gPeiCachePpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', + 'Produced', 'gEfiSecPlatformInf= ormationPpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gEfiNtLoadA= sDllPpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gNtPeiLoadF= ileGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gPeiNtAutoS= canPpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', + '', 'Ppi', 'Produced', 'gNtFwhP= piGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gPeiNtThunk= PpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gPeiPlatfor= mTypePpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', + 'Produced', 'gPeiFrequencySelec= tionCpuPpiGuid', '', '', '', 0) + EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', + 'Ppi', 'Produced', 'gPeiCachePp= iGuid', '', '', '', 0) =20 EotGlobalData.gDb.Conn.commit() =20 - - ## BuildDatabase() methoc + # BuildDatabase() methoc # # Build the database for target # # @param self: The object pointer # + def BuildDatabase(self): # Clean report table EotGlobalData.gDb.TblReport.Drop() @@ -1576,9 +1665,10 @@ class Eot(object): c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES) EdkLogger.quiet("Building database for source code done!") =20 - EotGlobalData.gIdentifierTableList =3D GetTableList((MODEL_FILE_C,= MODEL_FILE_H), 'Identifier', EotGlobalData.gDb) + EotGlobalData.gIdentifierTableList =3D GetTableList( + (MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb) =20 - ## BuildMetaDataFileDatabase() method + # BuildMetaDataFileDatabase() method # # Build the database for meta data files # @@ -1590,13 +1680,13 @@ class Eot(object): for InfFile in Inf_Files: if not InfFile: continue - EdkLogger.quiet("Parsing %s ..." % str(InfFile)) + EdkLogger.quiet("Parsing %s ..." % str(InfFile)) EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile]) =20 EotGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!") =20 - ## ParseOption() method + # ParseOption() method # # Parse command line options # @@ -1632,7 +1722,7 @@ class Eot(object): if Options.keepdatabase: self.IsInit =3D False =20 - ## SetLogLevel() method + # SetLogLevel() method # # Set current log level of the tool based on args # @@ -1649,7 +1739,7 @@ class Eot(object): else: EdkLogger.SetLevel(EdkLogger.INFO) =20 - ## EotOptionParser() method + # EotOptionParser() method # # Using standard Python module optparse to parse command line option = of this tool. # @@ -1659,38 +1749,43 @@ class Eot(object): # @retval Args Target of build command # def EotOptionParser(self): - Parser =3D OptionParser(description =3D self.Copyright, version = =3D self.Version, prog =3D "Eot.exe", usage =3D "%prog [options]") + Parser =3D OptionParser(description=3Dself.Copyright, + version=3Dself.Version, prog=3D"Eot.exe", us= age=3D"%prog [options]") Parser.add_option("-m", "--makefile filename", action=3D"store", t= ype=3D"string", dest=3D'MakeFile', - help=3D"Specify a makefile for the platform.") + help=3D"Specify a makefile for the platform.") Parser.add_option("-c", "--dsc filename", action=3D"store", type= =3D"string", dest=3D"DscFile", - help=3D"Specify a dsc file for the platform.") + help=3D"Specify a dsc file for the platform.") Parser.add_option("-f", "--fv filename", action=3D"store", type=3D= "string", dest=3D"FvFileList", - help=3D"Specify fv file list, quoted by \"\".") + help=3D"Specify fv file list, quoted by \"\".") Parser.add_option("-a", "--map filename", action=3D"store", type= =3D"string", dest=3D"MapFileList", - help=3D"Specify map file list, quoted by \"\".") + help=3D"Specify map file list, quoted by \"\".") Parser.add_option("-s", "--source files", action=3D"store", type= =3D"string", dest=3D"SourceFileList", - help=3D"Specify source file list by a file") + help=3D"Specify source file list by a file") Parser.add_option("-i", "--include dirs", action=3D"store", type= =3D"string", dest=3D"IncludeDirList", - help=3D"Specify include dir list by a file") + help=3D"Specify include dir list by a file") Parser.add_option("-e", "--dec files", action=3D"store", type=3D"s= tring", dest=3D"DecFileList", - help=3D"Specify dec file list by a file") + help=3D"Specify dec file list by a file") Parser.add_option("-g", "--guid list", action=3D"store", type=3D"s= tring", dest=3D"GuidList", - help=3D"Specify guid file list by a file") + help=3D"Specify guid file list by a file") Parser.add_option("-l", "--log filename", action=3D"store", type= =3D"string", dest=3D"LogFile", - help=3D"Specify real execution log file") + help=3D"Specify real execution log file") =20 - Parser.add_option("-k", "--keepdatabase", action=3D"store_true", t= ype=3DNone, help=3D"The existing Eot database will not be cleaned except re= port information if this option is specified.") + Parser.add_option("-k", "--keepdatabase", action=3D"store_true", t= ype=3DNone, + help=3D"The existing Eot database will not be cl= eaned except report information if this option is specified.") =20 - Parser.add_option("-q", "--quiet", action=3D"store_true", type=3DN= one, help=3D"Disable all messages except FATAL ERRORS.") - Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , "\ - = "including library instances selected, final dependency expression= , "\ - = "and warning messages, etc.") - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int",= help=3D"Enable debug messages at specified level.") + Parser.add_option("-q", "--quiet", action=3D"store_true", + type=3DNone, help=3D"Disable all messages except= FATAL ERRORS.") + Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , " + "including library instances selected, final dep= endency expression, " + "and warning messages, etc.") + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + help=3D"Enable debug messages at specified level= .") =20 - (Opt, Args)=3DParser.parse_args() + (Opt, Args) =3D Parser.parse_args() =20 return (Opt, Args) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -1700,7 +1795,8 @@ if __name__ =3D=3D '__main__': # Initialize log system EdkLogger.Initialize() EdkLogger.IsRaiseError =3D False - EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime())= + "[00:00]" + "\n") + EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", + time.localtime()) + "[00:00]" + "\n") =20 StartTime =3D time.clock() Eot =3D Eot(CommandLineOption=3DFalse, @@ -1709,5 +1805,7 @@ if __name__ =3D=3D '__main__': FvFileList=3Dr'C:\TestEot\FVRECOVERY.Fv') FinishTime =3D time.clock() =20 - BuildDuration =3D time.strftime("%M:%S", time.gmtime(int(round(FinishT= ime - StartTime)))) - EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", tim= e.localtime()), BuildDuration)) + BuildDuration =3D time.strftime( + "%M:%S", time.gmtime(int(round(FinishTime - StartTime)))) + EdkLogger.quiet("\n%s [%s]" % (time.strftime( + "%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration)) diff --git a/BaseTools/Source/Python/Eot/EotToolError.py b/BaseTools/Source= /Python/Eot/EotToolError.py index d4f4f3a18664..6dc146abbf20 100644 --- a/BaseTools/Source/Python/Eot/EotToolError.py +++ b/BaseTools/Source/Python/Eot/EotToolError.py @@ -1,4 +1,4 @@ -## @file +# @file # Standardized Error Handling infrastructures. # # Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
        @@ -10,6 +10,5 @@ ERROR_1 =3D 1000 =20 # Error message gEccErrorMessage =3D { - ERROR_1 : "RESERVED" - } - + ERROR_1: "RESERVED" +} diff --git a/BaseTools/Source/Python/Eot/FileProfile.py b/BaseTools/Source/= Python/Eot/FileProfile.py index 1f3ec156d06c..1c4145d8dd09 100644 --- a/BaseTools/Source/Python/Eot/FileProfile.py +++ b/BaseTools/Source/Python/Eot/FileProfile.py @@ -1,4 +1,4 @@ -## @file +# @file # fragments of source file # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
        @@ -27,15 +27,17 @@ StructUnionDefinitionList =3D [] TypedefDefinitionList =3D [] FunctionCallingList =3D [] =20 -## Class FileProfile +# Class FileProfile # # record file data when parsing source # # May raise Exception when opening file. # -class FileProfile : =20 - ## The constructor + +class FileProfile: + + # The constructor # # @param self: The object pointer # @param FileName: The file that to be parsed diff --git a/BaseTools/Source/Python/Eot/Identification.py b/BaseTools/Sour= ce/Python/Eot/Identification.py index 31d47602e519..1f5aac258839 100644 --- a/BaseTools/Source/Python/Eot/Identification.py +++ b/BaseTools/Source/Python/Eot/Identification.py @@ -1,10 +1,10 @@ -## @file +# @file # This file is used to define the identification of INF/DEC/DSC files # # Copyright (c) 2007, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent =20 -## Identification +# Identification # # This class defined basic Identification information structure which is u= sed by INF/DEC/DSC files # @@ -22,27 +22,28 @@ class Identification(object): self.FileRelativePath =3D '' self.PackagePath =3D '' =20 - ## GetFileName + # GetFileName # # Reserved # def GetFileName(self, FileFullPath, FileRelativePath): pass =20 - ## GetFileName + # GetFileName # # Reserved # def GetFileFullPath(self, FileName, FileRelativePath): pass =20 - ## GetFileName + # GetFileName # # Reserved # def GetFileRelativePath(self, FileName, FileFullPath): pass =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Sourc= e/Python/Eot/InfParserLite.py index 2c6bc50b6cd0..10ca7ad3a471 100644 --- a/BaseTools/Source/Python/Eot/InfParserLite.py +++ b/BaseTools/Source/Python/Eot/InfParserLite.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse INF file of EDK project # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -21,21 +21,23 @@ from Eot.Parser import * from Eot import Database from Eot import EotGlobalData =20 -## EdkInfParser() class +# EdkInfParser() class # # This class defined basic INF object which is used by inheriting # # @param object: Inherited from object class # + + class EdkInfParser(object): - ## The constructor + # The constructor # # @param self: The object pointer # @param Filename: INF file name # @param Database: Eot database # @param SourceFileList: A list for all source file belonging this I= NF file # - def __init__(self, Filename =3D None, Database =3D None, SourceFileLis= t =3D None): + def __init__(self, Filename=3DNone, Database=3DNone, SourceFileList=3D= None): self.Identification =3D Identification() self.Sources =3D [] self.Macros =3D {} @@ -51,27 +53,30 @@ class EdkInfParser(object): =20 if SourceFileList: for Item in SourceFileList: - self.TblInf.Insert(MODEL_EFI_SOURCE_FILE, Item, '', '', ''= , '', 'COMMON', -1, self.FileID, -1, -1, -1, -1, 0) + self.TblInf.Insert(MODEL_EFI_SOURCE_FILE, Item, '', '', + '', '', 'COMMON', -1, self.FileID, -1, = -1, -1, -1, 0) =20 - - ## LoadInffile() method + # LoadInffile() method # # Load INF file and insert a record in database # # @param self: The object pointer # @param Filename: Input value for filename of Inf file # - def LoadInfFile(self, Filename =3D None): + + def LoadInfFile(self, Filename=3DNone): # Insert a record for file Filename =3D NormPath(Filename) self.Identification.FileFullPath =3D Filename - (self.Identification.FileRelativePath, self.Identification.FileNam= e) =3D os.path.split(Filename) + (self.Identification.FileRelativePath, + self.Identification.FileName) =3D os.path.split(Filename) =20 self.FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_INF) =20 - self.ParseInf(PreProcess(Filename, False), self.Identification.Fil= eRelativePath, Filename) + self.ParseInf(PreProcess(Filename, False), + self.Identification.FileRelativePath, Filename) =20 - ## ParserSource() method + # ParserSource() method # # Parse Source section and insert records in database # @@ -91,9 +96,10 @@ class EdkInfParser(object): for Item in SectionItemList: if CurrentSection.upper() =3D=3D 'defines'.upper(): (Name, Value) =3D AddToSelfMacro(self.Macros, Item[0]) - self.TblInf.Insert(MODEL_META_DATA_HEADER, Name, Value= , Third, '', '', Arch, -1, self.FileID, Item[1], -1, Item[1], -1, 0) + self.TblInf.Insert(MODEL_META_DATA_HEADER, Name, Value= , Third, + '', '', Arch, -1, self.FileID, Item= [1], -1, Item[1], -1, 0) =20 - ## ParseInf() method + # ParseInf() method # # Parse INF file and get sections information # @@ -102,9 +108,9 @@ class EdkInfParser(object): # @param FileRelativePath: relative path of the file # @param Filename: file name of INF file # - def ParseInf(self, Lines =3D [], FileRelativePath =3D '', Filename =3D= ''): + def ParseInf(self, Lines=3D[], FileRelativePath=3D'', Filename=3D''): IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, I= ncludeFiles =3D \ - [], [], TAB_UNKNOWN, [], [], [] + [], [], TAB_UNKNOWN, [], [], [] LineNo =3D 0 =20 for Line in Lines: @@ -112,7 +118,8 @@ class EdkInfParser(object): if Line =3D=3D '': continue if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SE= CTION_END): - self.ParserSource(CurrentSection, SectionItemList, ArchLis= t, ThirdList) + self.ParserSource( + CurrentSection, SectionItemList, ArchList, ThirdList) =20 # Parse the new section SectionItemList =3D [] @@ -120,18 +127,21 @@ class EdkInfParser(object): ThirdList =3D [] # Parse section name CurrentSection =3D '' - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_START)= :len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) + LineList =3D GetSplitValueList(Line[len(TAB_SECTION_START)= :len( + Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) for Item in LineList: ItemList =3D GetSplitValueList(Item, TAB_SPLIT) if CurrentSection =3D=3D '': CurrentSection =3D ItemList[0] else: if CurrentSection !=3D ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Diffe= rent section names '%s' and '%s' are found in one section definition, this = is not allowed." % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DL= ineNo) + EdkLogger.error("Parser", PARSER_ERROR, "Diffe= rent section names '%s' and '%s' are found in one section definition, this = is not allowed." % ( + CurrentSection, ItemList[0]), File=3DFilen= ame, Line=3DLineNo) ItemList.append('') ItemList.append('') if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) + RaiseParserError(Line, CurrentSection, + Filename, '', LineNo) else: ArchList.append(ItemList[1].upper()) ThirdList.append(ItemList[2]) @@ -143,6 +153,4 @@ class EdkInfParser(object): # End of parse =20 self.ParserSource(CurrentSection, SectionItemList, ArchList, Third= List) - #End of For - - + # End of For diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Pytho= n/Eot/Parser.py index f204051d01f7..e02c2267dafa 100644 --- a/BaseTools/Source/Python/Eot/Parser.py +++ b/BaseTools/Source/Python/Eot/Parser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common parsing related functions used in par= sing # Inf/Dsc/Makefile process # @@ -10,7 +10,8 @@ # Import Modules # from __future__ import absolute_import -import Common.LongFilePathOs as os, re +import Common.LongFilePathOs as os +import re import Common.EdkLogger as EdkLogger from Common.DataType import * from CommonDataClass.DataClass import * @@ -21,10 +22,12 @@ from Common.LongFilePathSupport import OpenLongFilePath= as open =20 import subprocess =20 -## DeCompress +# DeCompress # # Call external decompress tool to decompress the fv section # + + def DeCompress(Method, Input): # Write the input to a temp file open('_Temp.bin', 'wb').write(Input) @@ -37,7 +40,8 @@ def DeCompress(Method, Input): cmd =3D r'TianoCompress -d -o _New.bin _Temp.bin' =20 # Call tool to create the decompressed output file - Process =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE, stderr=3Ds= ubprocess.STDOUT) + Process =3D subprocess.Popen( + cmd, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.STDOUT) Process.communicate()[0] =20 # Return the beffer of New.bin @@ -45,7 +49,7 @@ def DeCompress(Method, Input): return open('_New.bin', 'rb').read() =20 =20 -## PreProcess() method +# PreProcess() method # # Pre process a file # @@ -58,7 +62,7 @@ def DeCompress(Method, Input): # # @return Lines: The file contents after removing comments # -def PreProcess(Filename, MergeMultipleLines =3D True, LineNo =3D -1): +def PreProcess(Filename, MergeMultipleLines=3DTrue, LineNo=3D-1): Lines =3D [] Filename =3D os.path.normpath(Filename) if not os.path.isfile(Filename): @@ -100,7 +104,8 @@ def PreProcess(Filename, MergeMultipleLines =3D True, L= ineNo =3D -1): IsFindBlockCode =3D False continue if Line[-1] =3D=3D TAB_SLASH: - ReservedLine =3D ReservedLine + TAB_SPACE_SPLIT + Line[0:= -1].strip() + ReservedLine =3D ReservedLine + \ + TAB_SPACE_SPLIT + Line[0:-1].strip() ReservedLineLength =3D ReservedLineLength + 1 IsFindBlockCode =3D True continue @@ -109,18 +114,20 @@ def PreProcess(Filename, MergeMultipleLines =3D True,= LineNo =3D -1): =20 return Lines =20 -## AddToGlobalMacro() method +# AddToGlobalMacro() method # # Add a macro to EotGlobalData.gMACRO # # @param Name: Name of the macro # @param Value: Value of the macro # + + def AddToGlobalMacro(Name, Value): Value =3D ReplaceMacro(Value, EotGlobalData.gMACRO, True) EotGlobalData.gMACRO[Name] =3D Value =20 -## AddToSelfMacro() method +# AddToSelfMacro() method # # Parse a line of macro definition and add it to a macro set # @@ -130,6 +137,8 @@ def AddToGlobalMacro(Name, Value): # @return Name: Name of macro # @return Value: Value of macro # + + def AddToSelfMacro(SelfMacro, Line): Name, Value =3D '', '' List =3D GetSplitValueList(Line, TAB_EQUAL_SPLIT, 1) @@ -142,7 +151,7 @@ def AddToSelfMacro(SelfMacro, Line): =20 return (Name, Value) =20 -## GetIncludeListOfFile() method +# GetIncludeListOfFile() method # # Get the include path list for a source file # @@ -156,6 +165,8 @@ def AddToSelfMacro(SelfMacro, Line): # # @return IncludeList: A list of include directories # + + def GetIncludeListOfFile(WorkSpace, Filepath, Db): IncludeList =3D [] Filepath =3D os.path.normpath(Filepath) @@ -179,7 +190,7 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db): =20 return IncludeList =20 -## GetTableList() method +# GetTableList() method # # Search table file and find all small tables # @@ -189,9 +200,12 @@ def GetIncludeListOfFile(WorkSpace, Filepath, Db): # # @return TableList: A list of tables # + + def GetTableList(FileModelList, Table, Db): TableList =3D [] - SqlCommand =3D """select ID, FullPath from File where Model in %s""" %= str(FileModelList) + SqlCommand =3D """select ID, FullPath from File where Model in %s""" %= str( + FileModelList) RecordSet =3D Db.TblFile.Exec(SqlCommand) for Record in RecordSet: TableName =3D Table + str(Record[0]) @@ -199,7 +213,7 @@ def GetTableList(FileModelList, Table, Db): =20 return TableList =20 -## GetAllIncludeDir() method +# GetAllIncludeDir() method # # Find all Include directories # @@ -207,6 +221,8 @@ def GetTableList(FileModelList, Table, Db): # # @return IncludeList: A list of include directories # + + def GetAllIncludeDirs(Db): IncludeList =3D [] SqlCommand =3D """select distinct Value1 from Inf where Model =3D %s o= rder by Value1""" % MODEL_EFI_INCLUDE @@ -217,7 +233,7 @@ def GetAllIncludeDirs(Db): =20 return IncludeList =20 -## GetAllIncludeFiles() method +# GetAllIncludeFiles() method # # Find all Include files # @@ -225,6 +241,8 @@ def GetAllIncludeDirs(Db): # # @return IncludeFileList: A list of include files # + + def GetAllIncludeFiles(Db): IncludeList =3D GetAllIncludeDirs(Db) IncludeFileList =3D [] @@ -238,7 +256,7 @@ def GetAllIncludeFiles(Db): =20 return IncludeFileList =20 -## GetAllSourceFiles() method +# GetAllSourceFiles() method # # Find all source files # @@ -246,6 +264,8 @@ def GetAllIncludeFiles(Db): # # @return SourceFileList: A list of source files # + + def GetAllSourceFiles(Db): SourceFileList =3D [] SqlCommand =3D """select distinct Value1 from Inf where Model =3D %s o= rder by Value1""" % MODEL_EFI_SOURCE_FILE @@ -256,7 +276,7 @@ def GetAllSourceFiles(Db): =20 return SourceFileList =20 -## GetAllFiles() method +# GetAllFiles() method # # Find all files, both source files and include files # @@ -264,6 +284,8 @@ def GetAllSourceFiles(Db): # # @return FileList: A list of files # + + def GetAllFiles(Db): FileList =3D [] IncludeFileList =3D GetAllIncludeFiles(Db) @@ -277,7 +299,7 @@ def GetAllFiles(Db): =20 return FileList =20 -## ParseConditionalStatement() method +# ParseConditionalStatement() method # # Parse conditional statement # @@ -288,10 +310,13 @@ def GetAllFiles(Db): # @retval True: Find keyword of conditional statement # @retval False: Not find keyword of conditional statement # + + def ParseConditionalStatement(Line, Macros, StatusSet): NewLine =3D Line.upper() if NewLine.find(TAB_IF_EXIST.upper()) > -1: - IfLine =3D Line[NewLine.find(TAB_IF_EXIST) + len(TAB_IF_EXIST) + 1= :].strip() + IfLine =3D Line[NewLine.find(TAB_IF_EXIST) + + len(TAB_IF_EXIST) + 1:].strip() IfLine =3D ReplaceMacro(IfLine, EotGlobalData.gMACRO, True) IfLine =3D ReplaceMacro(IfLine, Macros, True) IfLine =3D IfLine.replace("\"", '') @@ -308,7 +333,8 @@ def ParseConditionalStatement(Line, Macros, StatusSet): StatusSet.append([Status]) return True if NewLine.find(TAB_IF_N_DEF.upper()) > -1: - IfLine =3D Line[NewLine.find(TAB_IF_N_DEF) + len(TAB_IF_N_DEF) + 1= :].strip() + IfLine =3D Line[NewLine.find(TAB_IF_N_DEF) + + len(TAB_IF_N_DEF) + 1:].strip() Status =3D False if IfLine not in Macros and IfLine not in EotGlobalData.gMACRO: Status =3D True @@ -320,7 +346,8 @@ def ParseConditionalStatement(Line, Macros, StatusSet): StatusSet.append([Status]) return True if NewLine.find(TAB_ELSE_IF.upper()) > -1: - IfLine =3D Line[NewLine.find(TAB_ELSE_IF) + len(TAB_ELSE_IF) + 1:]= .strip() + IfLine =3D Line[NewLine.find(TAB_ELSE_IF) + + len(TAB_ELSE_IF) + 1:].strip() Status =3D ParseConditionalStatementMacros(IfLine, Macros) StatusSet[-1].append(Status) return True @@ -336,7 +363,7 @@ def ParseConditionalStatement(Line, Macros, StatusSet): =20 return False =20 -## ParseConditionalStatement() method +# ParseConditionalStatement() method # # Parse conditional statement with Macros # @@ -345,6 +372,8 @@ def ParseConditionalStatement(Line, Macros, StatusSet): # # @return Line: New line after replacing macros # + + def ParseConditionalStatementMacros(Line, Macros): if Line.upper().find('DEFINED(') > -1 or Line.upper().find('EXIST') > = -1: return False @@ -354,7 +383,7 @@ def ParseConditionalStatementMacros(Line, Macros): Line =3D Line.replace("||", "or") return eval(Line) =20 -## GetConditionalStatementStatus() method +# GetConditionalStatementStatus() method # # 1. Assume the latest status as True # 2. Pop the top status of status set, previous status @@ -364,6 +393,8 @@ def ParseConditionalStatementMacros(Line, Macros): # # @return Status: The final status # + + def GetConditionalStatementStatus(StatusSet): Status =3D True for Item in StatusSet: @@ -371,7 +402,7 @@ def GetConditionalStatementStatus(StatusSet): =20 return Status =20 -## SearchBelongsToFunction() method +# SearchBelongsToFunction() method # # Search all functions belong to the file # @@ -381,15 +412,18 @@ def GetConditionalStatementStatus(StatusSet): # # @return: The found function # + + def SearchBelongsToFunction(BelongsToFile, StartLine, EndLine): - SqlCommand =3D """select ID, Name from Function where BelongsToFile = =3D %s and StartLine <=3D %s and EndLine >=3D %s""" %(BelongsToFile, StartL= ine, EndLine) + SqlCommand =3D """select ID, Name from Function where BelongsToFile = =3D %s and StartLine <=3D %s and EndLine >=3D %s""" % ( + BelongsToFile, StartLine, EndLine) RecordSet =3D EotGlobalData.gDb.TblFunction.Exec(SqlCommand) if RecordSet !=3D []: return RecordSet[0][0], RecordSet[0][1] else: return -1, '' =20 -## SearchPpiCallFunction() method +# SearchPpiCallFunction() method # # Search all used PPI calling function 'PeiServicesReInstallPpi' and 'Pei= ServicesInstallPpi' # Store the result to database @@ -399,6 +433,8 @@ def SearchBelongsToFunction(BelongsToFile, StartLine, E= ndLine): # @param SourceFileFullPath: Source file full path # @param ItemMode: Mode of the item # + + def SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, It= emMode): ItemName, ItemType, GuidName, GuidMacro, GuidValue =3D '', 'Ppi', '', = '', '' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine, EndLin= e from %s @@ -410,13 +446,15 @@ def SearchPpiCallFunction(Identifier, SourceFileID, S= ourceFileFullPath, ItemMode for Record in RecordSet: Index =3D 0 BelongsToFile, StartLine, EndLine =3D Record[2], Record[3], Record= [4] - BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction= (BelongsToFile, StartLine, EndLine) + BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction( + BelongsToFile, StartLine, EndLine) VariableList =3D Record[0].split(',') for Variable in VariableList: Variable =3D Variable.strip() # Get index of the variable if Variable.find('[') > -1: - Index =3D int(Variable[Variable.find('[') + 1 : Variable.f= ind(']')]) + Index =3D int(Variable[Variable.find( + '[') + 1: Variable.find(']')]) Variable =3D Variable[:Variable.find('[')] # Get variable name if Variable.startswith('&'): @@ -434,10 +472,12 @@ def SearchPpiCallFunction(Identifier, SourceFileID, S= ourceFileFullPath, ItemMode if len(NewVariableValueList) > 1: NewVariableValue =3D NewVariableValueList[1].strip= () if NewVariableValue.startswith('&'): - Db.Insert(-1, '', '', SourceFileID, SourceFile= FullPath, ItemName, ItemType, ItemMode, NewVariableValue[1:], GuidMacro, Gu= idValue, BelongsToFunction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFile= FullPath, ItemName, ItemType, + ItemMode, NewVariableValue[1:], Guid= Macro, GuidValue, BelongsToFunction, 0) continue else: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s= , %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, St= artLine, NewParameter)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s= , %s, %s, %s\n' % ( + ItemType, ItemMode, SourceFileID, SourceFi= leFullPath, StartLine, NewParameter)) =20 ItemName, ItemType, GuidName, GuidMacro, GuidValue =3D '', 'Ppi', '', = '', '' SqlCommand =3D """select Value, Name, BelongsToFile, StartLine, EndLin= e from %s @@ -458,12 +498,14 @@ def SearchPpiCallFunction(Identifier, SourceFileID, S= ourceFileFullPath, ItemMode continue Index =3D 0 BelongsToFile, StartLine, EndLine =3D Record[2], Record[3], Record= [4] - BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction= (BelongsToFile, StartLine, EndLine) - Variable =3D Record[0].replace('PeiServicesInstallPpi', '').replac= e('(', '').replace(')', '').replace('&', '').strip() + BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction( + BelongsToFile, StartLine, EndLine) + Variable =3D Record[0].replace('PeiServicesInstallPpi', '').replac= e( + '(', '').replace(')', '').replace('&', '').strip() Variable =3D Variable[Variable.find(',') + 1:].strip() # Get index of the variable if Variable.find('[') > -1: - Index =3D int(Variable[Variable.find('[') + 1 : Variable.find(= ']')]) + Index =3D int(Variable[Variable.find('[') + 1: Variable.find('= ]')]) Variable =3D Variable[:Variable.find('[')] # Get variable name if Variable.startswith('&'): @@ -480,12 +522,14 @@ def SearchPpiCallFunction(Identifier, SourceFileID, S= ourceFileFullPath, ItemMode if len(NewVariableValueList) > 1: NewVariableValue =3D NewVariableValueList[1].strip() if NewVariableValue.startswith('&'): - Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, ItemMode, NewVariableValue[1:], GuidMacro, GuidVa= lue, BelongsToFunction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, + ItemMode, NewVariableValue[1:], GuidMacr= o, GuidValue, BelongsToFunction, 0) continue else: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s= , %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartL= ine, NewParameter)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s= , %s, %s\n' % ( + ItemType, ItemMode, SourceFileID, SourceFileFu= llPath, StartLine, NewParameter)) =20 -## SearchPpis() method +# SearchPpis() method # # Search all used PPI calling function # Store the result to database @@ -497,7 +541,9 @@ def SearchPpiCallFunction(Identifier, SourceFileID, Sou= rceFileFullPath, ItemMode # @param ItemMode: Mode of the item # @param PpiMode: Mode of PPI # -def SearchPpi(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMod= e, PpiMode =3D 1): + + +def SearchPpi(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMod= e, PpiMode=3D1): ItemName, ItemType, GuidName, GuidMacro, GuidValue =3D '', 'Ppi', '', = '', '' BelongsToFunctionID, BelongsToFunction =3D -1, '' Db =3D EotGlobalData.gDb.TblReport @@ -506,7 +552,8 @@ def SearchPpi(SqlCommand, Table, SourceFileID, SourceFi= leFullPath, ItemMode, Ppi Parameter =3D GetPpiParameter(Record[0], PpiMode) BelongsToFile, StartLine, EndLine =3D Record[2], Record[3], Record= [4] # Get BelongsToFunction - BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction= (BelongsToFile, StartLine, EndLine) + BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction( + BelongsToFile, StartLine, EndLine) =20 # Default is Not Found IsFound =3D False @@ -514,29 +561,34 @@ def SearchPpi(SqlCommand, Table, SourceFileID, Source= FileFullPath, ItemMode, Ppi # For Consumed Ppi if ItemMode =3D=3D 'Consumed': if Parameter.startswith('g'): - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, ItemMode, Parameter, GuidMacro, GuidValue, BelongsToFunct= ion, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, + ItemMode, Parameter, GuidMacro, GuidValue, Belon= gsToFunction, 0) else: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Par= ameter)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % ( + ItemType, ItemMode, SourceFileID, SourceFileFullPath, = StartLine, Parameter)) continue =20 # Direct Parameter.Guid - SqlCommand =3D """select Value from %s where (Name like '%%%s.Guid= %%' or Name like '%%%s->Guid%%') and Model =3D %s""" % (Table, Parameter, P= arameter, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION) + SqlCommand =3D """select Value from %s where (Name like '%%%s.Guid= %%' or Name like '%%%s->Guid%%') and Model =3D %s""" % ( + Table, Parameter, Parameter, MODEL_IDENTIFIER_ASSIGNMENT_EXPRE= SSION) NewRecordSet =3D Db.Exec(SqlCommand) for NewRecord in NewRecordSet: GuidName =3D GetParameterName(NewRecord[0]) - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemNa= me, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, = 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemNa= me, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue, BelongsToF= unction, 0) IsFound =3D True =20 # Defined Parameter if not IsFound: Key =3D Parameter if Key.rfind(' ') > -1: - Key =3D Key[Key.rfind(' ') : ].strip().replace('&', '') + Key =3D Key[Key.rfind(' '):].strip().replace('&', '') Value =3D FindKeyValue(EotGlobalData.gDb.TblFile, Table, Key) List =3D GetSplitValueList(Value.replace('\n', ''), TAB_COMMA_= SPLIT) if len(List) > 1: GuidName =3D GetParameterName(List[1]) - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFuncti= on, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue, Belong= sToFunction, 0) IsFound =3D True =20 # A list Parameter @@ -545,14 +597,18 @@ def SearchPpi(SqlCommand, Table, SourceFileID, Source= FileFullPath, ItemMode, Ppi End =3D Parameter.find(']') if Start > -1 and End > -1 and Start < End: try: - Index =3D int(Parameter[Start + 1 : End]) - Parameter =3D Parameter[0 : Start] - SqlCommand =3D """select Value from %s where Name =3D = '%s' and Model =3D %s""" % (Table, Parameter, MODEL_IDENTIFIER_VARIABLE) + Index =3D int(Parameter[Start + 1: End]) + Parameter =3D Parameter[0: Start] + SqlCommand =3D """select Value from %s where Name =3D = '%s' and Model =3D %s""" % ( + Table, Parameter, MODEL_IDENTIFIER_VARIABLE) NewRecordSet =3D Db.Exec(SqlCommand) for NewRecord in NewRecordSet: - NewParameter =3D GetSplitValueList(NewRecord[0], '= }')[Index] - GuidName =3D GetPpiParameter(NewParameter[NewParam= eter.find('{') : ]) - Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, Belongs= ToFunction, 0) + NewParameter =3D GetSplitValueList( + NewRecord[0], '}')[Index] + GuidName =3D GetPpiParameter( + NewParameter[NewParameter.find('{'):]) + Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue= , BelongsToFunction, 0) IsFound =3D True except Exception: pass @@ -565,19 +621,22 @@ def SearchPpi(SqlCommand, Table, SourceFileID, Source= FileFullPath, ItemMode, Ppi NewRecordSet =3D Db.Exec(SqlCommand) for NewRecord in NewRecordSet: Table =3D 'Identifier' + str(NewRecord[0]) - SqlCommand =3D """select Value from %s where Name =3D '%s'= and Modifier =3D 'EFI_PEI_PPI_DESCRIPTOR' and Model =3D %s""" % (Table, Pa= rameter, MODEL_IDENTIFIER_VARIABLE) + SqlCommand =3D """select Value from %s where Name =3D '%s'= and Modifier =3D 'EFI_PEI_PPI_DESCRIPTOR' and Model =3D %s""" % ( + Table, Parameter, MODEL_IDENTIFIER_VARIABLE) PpiSet =3D Db.Exec(SqlCommand) if PpiSet !=3D []: GuidName =3D GetPpiParameter(PpiSet[0][0]) if GuidName !=3D '': - Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, Belongs= ToFunction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue= , BelongsToFunction, 0) IsFound =3D True break =20 if not IsFound: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' = % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Paramet= er)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' = % ( + ItemType, ItemMode, SourceFileID, SourceFileFullPath, Star= tLine, Parameter)) =20 -## SearchProtocols() method +# SearchProtocols() method # # Search all used PROTOCOL calling function # Store the result to database @@ -589,6 +648,8 @@ def SearchPpi(SqlCommand, Table, SourceFileID, SourceFi= leFullPath, ItemMode, Ppi # @param ItemMode: Mode of the item # @param ProtocolMode: Mode of PROTOCOL # + + def SearchProtocols(SqlCommand, Table, SourceFileID, SourceFileFullPath, I= temMode, ProtocolMode): ItemName, ItemType, GuidName, GuidMacro, GuidValue =3D '', 'Protocol',= '', '', '' BelongsToFunctionID, BelongsToFunction =3D -1, '' @@ -598,7 +659,8 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, So= urceFileFullPath, ItemMod Parameter =3D '' BelongsToFile, StartLine, EndLine =3D Record[2], Record[3], Record= [4] # Get BelongsToFunction - BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction= (BelongsToFile, StartLine, EndLine) + BelongsToFunctionID, BelongsToFunction =3D SearchBelongsToFunction( + BelongsToFile, StartLine, EndLine) =20 # Default is Not Found IsFound =3D False @@ -607,7 +669,8 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, So= urceFileFullPath, ItemMod Parameter =3D GetProtocolParameter(Record[0], ProtocolMode) if Parameter.startswith('g') or Parameter.endswith('Guid') or = Parameter =3D=3D 'ShellEnvProtocol' or Parameter =3D=3D 'ShellInterfaceProt= ocol': GuidName =3D GetParameterName(Parameter) - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFuncti= on, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, It= emName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue, Belong= sToFunction, 0) IsFound =3D True =20 if ProtocolMode =3D=3D 2: @@ -615,22 +678,27 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, = SourceFileFullPath, ItemMod for Protocol in Protocols: if Protocol.startswith('&') and Protocol.endswith('Guid'): GuidName =3D GetParameterName(Protocol) - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath= , ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFu= nction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath= , ItemName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue, Be= longsToFunction, 0) IsFound =3D True else: - NewValue =3D FindKeyValue(EotGlobalData.gDb.TblFile, T= able, Protocol) + NewValue =3D FindKeyValue( + EotGlobalData.gDb.TblFile, Table, Protocol) if Protocol !=3D NewValue and NewValue.endswith('Guid'= ): GuidName =3D GetParameterName(NewValue) - Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, Belongs= ToFunction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFull= Path, ItemName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue= , BelongsToFunction, 0) IsFound =3D True =20 if not IsFound: if BelongsToFunction in EotGlobalData.gProducedProtocolLibrary= or BelongsToFunction in EotGlobalData.gConsumedProtocolLibrary: - EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s,= %s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileF= ullPath, StartLine, Parameter, BelongsToFunction)) + EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s,= %s, %s, %s, %s, %s, %s\n' % ( + ItemType, ItemMode, SourceFileID, SourceFileFullPath, = StartLine, Parameter, BelongsToFunction)) else: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Par= ameter)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % ( + ItemType, ItemMode, SourceFileID, SourceFileFullPath, = StartLine, Parameter)) =20 -## SearchFunctionCalling() method +# SearchFunctionCalling() method # # Search all used PPI/PROTOCOL calling function by library # Store the result to database @@ -642,6 +710,8 @@ def SearchProtocols(SqlCommand, Table, SourceFileID, So= urceFileFullPath, ItemMod # @param ItemType: Type of the item, PPI or PROTOCOL # @param ItemMode: Mode of item # + + def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemTyp= e, ItemMode): LibraryList =3D {} Db =3D EotGlobalData.gDb.TblReport @@ -675,13 +745,15 @@ def SearchFunctionCalling(Table, SourceFileID, Source= FileFullPath, ItemType, Ite for Parameter in Parameters: if Parameter.startswith('g') or Parameter.endswith('Guid')= or Parameter =3D=3D 'ShellEnvProtocol' or Parameter =3D=3D 'ShellInterface= Protocol': GuidName =3D GetParameterName(Parameter) - Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath= , ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFu= nction, 0) + Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath= , ItemName, ItemType, + ItemMode, GuidName, GuidMacro, GuidValue, Be= longsToFunction, 0) IsFound =3D True =20 if not IsFound: - EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Par= ameter)) + EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s= \n' % ( + ItemType, ItemMode, SourceFileID, SourceFileFullPath, = StartLine, Parameter)) =20 -## FindProtocols() method +# FindProtocols() method # # Find defined protocols # @@ -693,14 +765,14 @@ def SearchFunctionCalling(Table, SourceFileID, Source= FileFullPath, ItemType, Ite # @param ItemType: Type of the item, PPI or PROTOCOL # @param ItemMode: Mode of item # -#def FindProtocols(Db, SqlCommand, Table, SourceFileID, SourceFileFullPath= , ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue): +# def FindProtocols(Db, SqlCommand, Table, SourceFileID, SourceFileFullPat= h, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue): # BelongsToFunction =3D '' # RecordSet =3D Db.Exec(SqlCommand) # for Record in RecordSet: # IsFound =3D True # Parameter =3D GetProtocolParameter(Record[0]) =20 -## GetProtocolParameter() method +# GetProtocolParameter() method # # Parse string of protocol and find parameters # @@ -709,10 +781,12 @@ def SearchFunctionCalling(Table, SourceFileID, Source= FileFullPath, ItemType, Ite # # @return: call common GetParameter # -def GetProtocolParameter(Parameter, Index =3D 1): + + +def GetProtocolParameter(Parameter, Index=3D1): return GetParameter(Parameter, Index) =20 -## GetPpiParameter() method +# GetPpiParameter() method # # Parse string of ppi and find parameters # @@ -721,10 +795,12 @@ def GetProtocolParameter(Parameter, Index =3D 1): # # @return: call common GetParameter # -def GetPpiParameter(Parameter, Index =3D 1): + + +def GetPpiParameter(Parameter, Index=3D1): return GetParameter(Parameter, Index) =20 -## GetParameter() method +# GetParameter() method # # Get a parameter by index # @@ -733,7 +809,9 @@ def GetPpiParameter(Parameter, Index =3D 1): # # @return Parameter: The found parameter # -def GetParameter(Parameter, Index =3D 1): + + +def GetParameter(Parameter, Index=3D1): ParameterList =3D GetSplitValueList(Parameter, TAB_COMMA_SPLIT) if len(ParameterList) > Index: Parameter =3D GetParameterName(ParameterList[Index]) @@ -742,7 +820,7 @@ def GetParameter(Parameter, Index =3D 1): =20 return '' =20 -## GetParameterName() method +# GetParameterName() method # # Get a parameter name # @@ -750,13 +828,15 @@ def GetParameter(Parameter, Index =3D 1): # # @return: The name of parameter # + + def GetParameterName(Parameter): if isinstance(Parameter, type('')) and Parameter.startswith('&'): return Parameter[1:].replace('{', '').replace('}', '').replace('\r= ', '').replace('\n', '').strip() else: return Parameter.strip() =20 -## FindKeyValue() method +# FindKeyValue() method # # Find key value of a variable # @@ -766,8 +846,11 @@ def GetParameterName(Parameter): # # @return Value: The value of the keyword # + + def FindKeyValue(Db, Table, Key): - SqlCommand =3D """select Value from %s where Name =3D '%s' and (Model = =3D %s or Model =3D %s)""" % (Table, Key, MODEL_IDENTIFIER_VARIABLE, MODEL_= IDENTIFIER_ASSIGNMENT_EXPRESSION) + SqlCommand =3D """select Value from %s where Name =3D '%s' and (Model = =3D %s or Model =3D %s)""" % ( + Table, Key, MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT= _EXPRESSION) RecordSet =3D Db.Exec(SqlCommand) Value =3D '' for Record in RecordSet: @@ -779,7 +862,7 @@ def FindKeyValue(Db, Table, Key): else: return Key =20 -## ParseMapFile() method +# ParseMapFile() method # # Parse map files to get a dict of 'ModuleName' : {FunName : FunAddress} # @@ -787,6 +870,8 @@ def FindKeyValue(Db, Table, Key): # # @return AllMaps: An object of all map files # + + def ParseMapFile(Files): AllMaps =3D {} CurrentModule =3D '' @@ -819,7 +904,7 @@ def ParseMapFile(Files): =20 return AllMaps =20 -## ConvertGuid +# ConvertGuid # # Convert a GUID to a GUID with all upper letters # @@ -827,6 +912,8 @@ def ParseMapFile(Files): # # @param newGuid: The GUID with all upper letters. # + + def ConvertGuid(guid): numList =3D ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] newGuid =3D '' @@ -844,7 +931,7 @@ def ConvertGuid(guid): =20 return newGuid =20 -## ConvertGuid2() method +# ConvertGuid2() method # # Convert a GUID to a GUID with new string instead of old string # @@ -854,12 +941,15 @@ def ConvertGuid(guid): # # @param newGuid: The GUID after replacement # + + def ConvertGuid2(guid, old, new): newGuid =3D ConvertGuid(guid) newGuid =3D newGuid.replace(old, new) =20 return newGuid =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Eot/ParserWarning.py b/BaseTools/Sourc= e/Python/Eot/ParserWarning.py index e84990a4909c..bbee973c96c9 100644 --- a/BaseTools/Source/Python/Eot/ParserWarning.py +++ b/BaseTools/Source/Python/Eot/ParserWarning.py @@ -1,4 +1,4 @@ -## @file +# @file # Warning information of Eot # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -6,14 +6,14 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # class Warning (Exception): - ## The constructor + # The constructor # # @param self The object pointer # @param Str The message to record # @param File The FDF name # @param Line The Line number that error occurs # - def __init__(self, Str, File =3D None, Line =3D None): + def __init__(self, Str, File=3DNone, Line=3DNone): self.message =3D Str self.FileName =3D File self.LineNumber =3D Line diff --git a/BaseTools/Source/Python/Eot/Report.py b/BaseTools/Source/Pytho= n/Eot/Report.py index 9d99fe22a0f1..4e39e1b072f6 100644 --- a/BaseTools/Source/Python/Eot/Report.py +++ b/BaseTools/Source/Python/Eot/Report.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create report for Eot tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -13,20 +13,22 @@ import Common.LongFilePathOs as os from . import EotGlobalData from Common.LongFilePathSupport import OpenLongFilePath as open =20 -## Report() class +# Report() class # # This class defined Report # # @param object: Inherited from object class # + + class Report(object): - ## The constructor + # The constructor # # @param self: The object pointer # @param ReportName: name of the report # @param FvObj: FV object after parsing FV images # - def __init__(self, ReportName =3D 'Report.html', FvObj =3D None, Dispa= tchName=3DNone): + def __init__(self, ReportName=3D'Report.html', FvObj=3DNone, DispatchN= ame=3DNone): self.ReportName =3D ReportName self.Op =3D open(ReportName, 'w+') self.DispatchList =3D None @@ -39,7 +41,7 @@ class Report(object): if EotGlobalData.gMACRO['EFI_SOURCE'] =3D=3D '': EotGlobalData.gMACRO['EFI_SOURCE'] =3D EotGlobalData.gMACRO['E= DK_SOURCE'] =20 - ## WriteLn() method + # WriteLn() method # # Write a line in the report # @@ -49,7 +51,7 @@ class Report(object): def WriteLn(self, Line): self.Op.write('%s\n' % Line) =20 - ## GenerateReport() method + # GenerateReport() method # # A caller to generate report # @@ -62,7 +64,7 @@ class Report(object): self.Op.close() self.GenerateUnDispatchedList() =20 - ## GenerateUnDispatchedList() method + # GenerateUnDispatchedList() method # # Create a list for not dispatched items # @@ -72,9 +74,10 @@ class Report(object): FvObj =3D self.FvObj EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.Name) for Item in FvObj.UnDispatchedFfsDict.keys(): - EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.UnDispatc= hedFfsDict[Item]) + EotGlobalData.gOP_UN_DISPATCHED.write( + '%s\n' % FvObj.UnDispatchedFfsDict[Item]) =20 - ## GenerateFv() method + # GenerateFv() method # # Generate FV information # @@ -98,7 +101,7 @@ class Report(object): %s %s %s - """ % (FvName, FvGuid, FvSize) + """ % (FvName, FvGuid, FvSize) self.WriteLn(Content) =20 Content =3D """ @@ -125,7 +128,7 @@ class Report(object): """ self.WriteLn(Content) =20 - ## GenerateDepex() method + # GenerateDepex() method # # Generate Depex information # @@ -138,7 +141,8 @@ class Report(object): DepexString =3D '' for Item in ItemList: if Item not in NonGuidList: - SqlCommand =3D """select DISTINCT GuidName from Report whe= re GuidValue like '%s' and ItemMode =3D 'Produced' group by GuidName""" % (= Item) + SqlCommand =3D """select DISTINCT GuidName from Report whe= re GuidValue like '%s' and ItemMode =3D 'Produced' group by GuidName""" % ( + Item) RecordSet =3D EotGlobalData.gDb.TblReport.Exec(SqlCommand) if RecordSet !=3D []: Item =3D RecordSet[0][0] @@ -149,7 +153,7 @@ class Report(object): """ % (DepexString) self.WriteLn(Content) =20 - ## GeneratePpi() method + # GeneratePpi() method # # Generate PPI information # @@ -161,7 +165,7 @@ class Report(object): def GeneratePpi(self, Name, Guid, Type): self.GeneratePpiProtocol('Ppi', Name, Guid, Type, self.PpiIndex) =20 - ## GenerateProtocol() method + # GenerateProtocol() method # # Generate PROTOCOL information # @@ -171,9 +175,10 @@ class Report(object): # @param Type: Type of a GUID # def GenerateProtocol(self, Name, Guid, Type): - self.GeneratePpiProtocol('Protocol', Name, Guid, Type, self.Protoc= olIndex) + self.GeneratePpiProtocol( + 'Protocol', Name, Guid, Type, self.ProtocolIndex) =20 - ## GeneratePpiProtocol() method + # GeneratePpiProtocol() method # # Generate PPI/PROTOCOL information # @@ -201,7 +206,8 @@ class Report(object): select DISTINCT BelongsToFile from Inf where Value1 like '%s')""" % Record[0] ModuleSet =3D EotGlobalData.gDb.TblReport.Exec(SqlCommand) - Inf =3D ModuleSet[0][0].replace(EotGlobalData.gMACRO['WORK= SPACE'], '.') + Inf =3D ModuleSet[0][0].replace( + EotGlobalData.gMACRO['WORKSPACE'], '.') Function =3D Record[1] Address =3D '' for Item in EotGlobalData.gMap: @@ -220,7 +226,7 @@ class Report(object): """ % ('Callback', Inf, Function, Address) self.WriteLn(Content) =20 - ## GenerateFfs() method + # GenerateFfs() method # # Generate FFS information # @@ -274,13 +280,15 @@ class Report(object): =20 if self.DispatchList: if FfsObj.Type in [0x04, 0x06]: - self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "P= ", FfsName, FfsPath)) + self.DispatchList.write("%s %s %s %s\n" % ( + FfsGuid, "P", FfsName, FfsPath)) if FfsObj.Type in [0x05, 0x07, 0x08, 0x0A]: - self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "D= ", FfsName, FfsPath)) + self.DispatchList.write("%s %s %s %s\n" % ( + FfsGuid, "D", FfsName, FfsPath)) =20 self.WriteLn(Content) =20 - EotGlobalData.gOP_DISPATCH_ORDER.write('%s\n' %FfsName) + EotGlobalData.gOP_DISPATCH_ORDER.write('%s\n' % FfsName) =20 if FfsObj.Depex !=3D '': Content =3D """ @@ -321,12 +329,13 @@ class Report(object): CName =3D Record[4] Guid =3D Record[3] Type =3D Record[1] - self.GeneratePpiProtocol(Type, Name, Guid, 'Consumed',= CName) + self.GeneratePpiProtocol( + Type, Name, Guid, 'Consumed', CName) =20 Content =3D """
        """ self.WriteLn(Content) - #End of Consumed Ppi/Protocol + # End of Consumed Ppi/Protocol =20 # Find Produced Ppi/Protocol SqlCommand =3D """select ModuleName, ItemType, GuidName, GuidV= alue, GuidMacro from Report @@ -354,7 +363,8 @@ class Report(object): CName =3D Record[4] Guid =3D Record[3] Type =3D Record[1] - self.GeneratePpiProtocol(Type, Name, Guid, 'Produced',= CName) + self.GeneratePpiProtocol( + Type, Name, Guid, 'Produced', CName) =20 Content =3D """ """ @@ -366,7 +376,7 @@ class Report(object): """ self.WriteLn(Content) =20 - ## GenerateTail() method + # GenerateTail() method # # Generate end tags of HTML report # @@ -378,7 +388,7 @@ class Report(object): """ self.WriteLn(Tail) =20 - ## GenerateHeader() method + # GenerateHeader() method # # Generate start tags of HTML report # @@ -446,6 +456,7 @@ function funOnMouseOut() """ self.WriteLn(Header) =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/Eot/__init__.py b/BaseTools/Source/Pyt= hon/Eot/__init__.py index ba0b8c81fa30..0a328824eb9f 100644 --- a/BaseTools/Source/Python/Eot/__init__.py +++ b/BaseTools/Source/Python/Eot/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Eot' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot= /c.py index dd9530fed6d0..95d396a0cde9 100644 --- a/BaseTools/Source/Python/Eot/c.py +++ b/BaseTools/Source/Python/Eot/c.py @@ -1,4 +1,4 @@ -## @file +# @file # preprocess source file # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
        @@ -27,46 +27,55 @@ IncludePathListDict =3D {} ComplexTypeDict =3D {} SUDict =3D {} =20 -## GetFuncDeclPattern() method +# GetFuncDeclPattern() method # # Get the pattern of function declaration # # @return p: the pattern of function declaration # + + def GetFuncDeclPattern(): - p =3D re.compile(r'(EFIAPI|EFI_BOOT_SERVICE|EFI_RUNTIME_SERVICE)?\s*[_= \w]+\s*\(.*\).*', re.DOTALL) + p =3D re.compile( + r'(EFIAPI|EFI_BOOT_SERVICE|EFI_RUNTIME_SERVICE)?\s*[_\w]+\s*\(.*\)= .*', re.DOTALL) return p =20 -## GetArrayPattern() method +# GetArrayPattern() method # # Get the pattern of array # # @return p: the pattern of array # + + def GetArrayPattern(): p =3D re.compile(r'[_\w]*\s*[\[.*\]]+') return p =20 -## GetTypedefFuncPointerPattern() method +# GetTypedefFuncPointerPattern() method # # Get the pattern of function pointer # # @return p: the pattern of function pointer # + + def GetTypedefFuncPointerPattern(): p =3D re.compile('[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOT= ALL) return p =20 -## GetDB() method +# GetDB() method # # Get global database instance # # @return EotGlobalData.gDb: the global database instance # + + def GetDB(): return EotGlobalData.gDb =20 -## PrintErrorMsg() method +# PrintErrorMsg() method # # print error message # @@ -75,6 +84,8 @@ def GetDB(): # @param TableName: table name of error found # @param ItemId: id of item # + + def PrintErrorMsg(ErrorType, Msg, TableName, ItemId): Msg =3D Msg.replace('\n', '').replace('\r', '') MsgPartList =3D Msg.split() @@ -82,9 +93,10 @@ def PrintErrorMsg(ErrorType, Msg, TableName, ItemId): for Part in MsgPartList: Msg +=3D Part Msg +=3D ' ' - GetDB().TblReport.Insert(ErrorType, OtherMsg =3D Msg, BelongsToTable = =3D TableName, BelongsToItem =3D ItemId) + GetDB().TblReport.Insert(ErrorType, OtherMsg=3DMsg, + BelongsToTable=3DTableName, BelongsToItem=3DI= temId) =20 -## GetIdType() method +# GetIdType() method # # Find type of input string # @@ -92,6 +104,8 @@ def PrintErrorMsg(ErrorType, Msg, TableName, ItemId): # # @return Type: The type of the string # + + def GetIdType(Str): Type =3D DataClass.MODEL_UNKNOWN Str =3D Str.replace('#', '# ') @@ -112,22 +126,26 @@ def GetIdType(Str): Type =3D DataClass.MODEL_UNKNOWN return Type =20 -## GetIdentifierList() method +# GetIdentifierList() method # # Get id of all files # # @return IdList: The list of all id of files # + + def GetIdentifierList(): IdList =3D [] =20 for pp in FileProfile.PPDirectiveList: Type =3D GetIdType(pp.Content) - IdPP =3D DataClass.IdentifierClass(-1, '', '', '', pp.Content, Typ= e, -1, -1, pp.StartPos[0], pp.StartPos[1], pp.EndPos[0], pp.EndPos[1]) + IdPP =3D DataClass.IdentifierClass(-1, '', '', '', pp.Content, Typ= e, - + 1, -1, pp.StartPos[0], pp.StartPo= s[1], pp.EndPos[0], pp.EndPos[1]) IdList.append(IdPP) =20 for ae in FileProfile.AssignmentExpressionList: - IdAE =3D DataClass.IdentifierClass(-1, ae.Operator, '', ae.Name, a= e.Value, DataClass.MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION, -1, -1, ae.Start= Pos[0], ae.StartPos[1], ae.EndPos[0], ae.EndPos[1]) + IdAE =3D DataClass.IdentifierClass(-1, ae.Operator, '', ae.Name, a= e.Value, DataClass.MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION, - + 1, -1, ae.StartPos[0], ae.StartPo= s[1], ae.EndPos[0], ae.EndPos[1]) IdList.append(IdAE) =20 FuncDeclPattern =3D GetFuncDeclPattern() @@ -147,9 +165,11 @@ def GetIdentifierList(): Index =3D 0 while Index < len(FuncNamePartList) - 1: var.Modifier +=3D ' ' + FuncNamePartList[Index] - var.Declarator =3D var.Declarator.lstrip().lstrip(Func= NamePartList[Index]) + var.Declarator =3D var.Declarator.lstrip().lstrip( + FuncNamePartList[Index]) Index +=3D 1 - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', var.= Declarator, '', DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, -1, -1, va= r.StartPos[0], var.StartPos[1], var.EndPos[0], var.EndPos[1]) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', var.= Declarator, '', DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, - + 1, -1, var.StartPos[0], var.= StartPos[1], var.EndPos[0], var.EndPos[1]) IdList.append(IdVar) continue =20 @@ -162,7 +182,8 @@ def GetIdentifierList(): var.Modifier +=3D ' ' + Name[LSBPos:] Name =3D Name[0:LSBPos] =20 - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', = Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDEN= TIFIER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], var.EndPos[0], v= ar.EndPos[1]) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', = Name, (len(DeclList) > 1 and [DeclList[1]] or [''])[ + 0], DataClass.MODEL_IDEN= TIFIER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], var.EndPos[0], v= ar.EndPos[1]) IdList.append(IdVar) else: DeclList =3D var.Declarator.split('=3D') @@ -171,7 +192,8 @@ def GetIdentifierList(): LSBPos =3D var.Declarator.find('[') var.Modifier +=3D ' ' + Name[LSBPos:] Name =3D Name[0:LSBPos] - IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', Name= , (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFI= ER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], var.EndPos[0], var.E= ndPos[1]) + IdVar =3D DataClass.IdentifierClass(-1, var.Modifier, '', Name= , (len(DeclList) > 1 and [DeclList[1]] or [''])[ + 0], DataClass.MODEL_IDENTIFI= ER_VARIABLE, -1, -1, var.StartPos[0], var.StartPos[1], var.EndPos[0], var.E= ndPos[1]) IdList.append(IdVar) =20 for enum in FileProfile.EnumerationDefinitionList: @@ -179,7 +201,8 @@ def GetIdentifierList(): RBPos =3D enum.Content.find('}') Name =3D enum.Content[4:LBPos].strip() Value =3D enum.Content[LBPos+1:RBPos] - IdEnum =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Data= Class.MODEL_IDENTIFIER_ENUMERATE, -1, -1, enum.StartPos[0], enum.StartPos[1= ], enum.EndPos[0], enum.EndPos[1]) + IdEnum =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Data= Class.MODEL_IDENTIFIER_ENUMERATE, - + 1, -1, enum.StartPos[0], enum.S= tartPos[1], enum.EndPos[0], enum.EndPos[1]) IdList.append(IdEnum) =20 for su in FileProfile.StructUnionDefinitionList: @@ -196,7 +219,8 @@ def GetIdentifierList(): else: Name =3D su.Content[SkipLen:LBPos].strip() Value =3D su.Content[LBPos+1:RBPos] - IdPE =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Type, = -1, -1, su.StartPos[0], su.StartPos[1], su.EndPos[0], su.EndPos[1]) + IdPE =3D DataClass.IdentifierClass(-1, '', '', Name, Value, Type, - + 1, -1, su.StartPos[0], su.StartPo= s[1], su.EndPos[0], su.EndPos[1]) IdList.append(IdPE) =20 TdFuncPointerPattern =3D GetTypedefFuncPointerPattern() @@ -219,15 +243,17 @@ def GetIdentifierList(): Name =3D TmpStr[0:RBPos] Value =3D 'FP' + TmpStr[RBPos + 1:] =20 - IdTd =3D DataClass.IdentifierClass(-1, Modifier, '', Name, Value, = DataClass.MODEL_IDENTIFIER_TYPEDEF, -1, -1, td.StartPos[0], td.StartPos[1],= td.EndPos[0], td.EndPos[1]) + IdTd =3D DataClass.IdentifierClass(-1, Modifier, '', Name, Value, = DataClass.MODEL_IDENTIFIER_TYPEDEF, - + 1, -1, td.StartPos[0], td.StartPo= s[1], td.EndPos[0], td.EndPos[1]) IdList.append(IdTd) =20 for funcCall in FileProfile.FunctionCallingList: - IdFC =3D DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, = funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, -1, -1, fu= ncCall.StartPos[0], funcCall.StartPos[1], funcCall.EndPos[0], funcCall.EndP= os[1]) + IdFC =3D DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, = funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, - + 1, -1, funcCall.StartPos[0], func= Call.StartPos[1], funcCall.EndPos[0], funcCall.EndPos[1]) IdList.append(IdFC) return IdList =20 -## GetParamList() method +# GetParamList() method # # Get a list of parameters # @@ -237,7 +263,9 @@ def GetIdentifierList(): # # @return ParamIdList: A list of parameters # -def GetParamList(FuncDeclarator, FuncNameLine =3D 0, FuncNameOffset =3D 0): + + +def GetParamList(FuncDeclarator, FuncNameLine=3D0, FuncNameOffset=3D0): ParamIdList =3D [] DeclSplitList =3D FuncDeclarator.split('(') if len(DeclSplitList) < 2: @@ -253,7 +281,7 @@ def GetParamList(FuncDeclarator, FuncNameLine =3D 0, Fu= ncNameOffset =3D 0): Start +=3D FuncName.find('\n', Start) Start +=3D 1 OffsetSkipped +=3D len(FuncName[Start:]) - OffsetSkipped +=3D 1 #skip '(' + OffsetSkipped +=3D 1 # skip '(' ParamBeginLine =3D FuncNameLine + LineSkipped ParamBeginOffset =3D OffsetSkipped for p in ParamStr.split(','): @@ -289,19 +317,22 @@ def GetParamList(FuncDeclarator, FuncNameLine =3D 0, = FuncNameOffset =3D 0): =20 ParamEndLine =3D ParamBeginLine + LineSkipped ParamEndOffset =3D OffsetSkipped - IdParam =3D DataClass.IdentifierClass(-1, ParamModifier, '', Param= Name, '', DataClass.MODEL_IDENTIFIER_PARAMETER, -1, -1, ParamBeginLine, Par= amBeginOffset, ParamEndLine, ParamEndOffset) + IdParam =3D DataClass.IdentifierClass(-1, ParamModifier, '', Param= Name, '', DataClass.MODEL_IDENTIFIER_PARAMETER, - + 1, -1, ParamBeginLine, ParamBe= ginOffset, ParamEndLine, ParamEndOffset) ParamIdList.append(IdParam) ParamBeginLine =3D ParamEndLine - ParamBeginOffset =3D OffsetSkipped + 1 #skip ',' + ParamBeginOffset =3D OffsetSkipped + 1 # skip ',' =20 return ParamIdList =20 -## GetFunctionList() +# GetFunctionList() # # Get a list of functions # # @return FuncObjList: A list of function objects # + + def GetFunctionList(): FuncObjList =3D [] for FuncDef in FileProfile.FunctionDefinitionList: @@ -325,17 +356,20 @@ def GetFunctionList(): FuncDef.Modifier +=3D ' ' + FuncNamePartList[Index] Index +=3D 1 =20 - FuncObj =3D DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDe= f.Modifier, FuncName.strip(), '', FuncDef.StartPos[0], FuncDef.StartPos[1],= FuncDef.EndPos[0], FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.Lef= tBracePos[1], -1, ParamIdList, []) + FuncObj =3D DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDe= f.Modifier, FuncName.strip( + ), '', FuncDef.StartPos[0], FuncDef.StartPos[1], FuncDef.EndPos[0]= , FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.LeftBracePos[1], -1, = ParamIdList, []) FuncObjList.append(FuncObj) =20 return FuncObjList =20 -## CreateCCodeDB() method +# CreateCCodeDB() method # # Create database for all c code # # @param FileNameList: A list of all c code file names # + + def CreateCCodeDB(FileNameList): FileObjList =3D [] ParseErrorFileList =3D [] @@ -346,7 +380,8 @@ def CreateCCodeDB(FileNameList): continue ParsedFiles[FullName.lower()] =3D 1 EdkLogger.info("Parsing " + FullName) - model =3D FullName.endswith('c') and DataClass.MODEL_FILE_C or= DataClass.MODEL_FILE_H + model =3D FullName.endswith( + 'c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H collector =3D CodeFragmentCollector.CodeFragmentCollector(Full= Name) try: collector.ParseFile() @@ -356,12 +391,14 @@ def CreateCCodeDB(FileNameList): DirName =3D os.path.dirname(FullName) Ext =3D os.path.splitext(BaseName)[1].lstrip('.') ModifiedTime =3D os.path.getmtime(FullName) - FileObj =3D DataClass.FileClass(-1, BaseName, Ext, DirName, Fu= llName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), []) + FileObj =3D DataClass.FileClass(-1, BaseName, Ext, DirName, Fu= llName, + model, ModifiedTime, GetFunction= List(), GetIdentifierList(), []) FileObjList.append(FileObj) collector.CleanFileProfileBuffer() =20 if len(ParseErrorFileList) > 0: - EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n"= % "\n\t".join(ParseErrorFileList)) + EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n"= % + "\n\t".join(ParseErrorFileList)) =20 Db =3D EotGlobalData.gDb for file in FileObjList: @@ -369,6 +406,7 @@ def CreateCCodeDB(FileNameList): =20 Db.UpdateIdentifierBelongsToFunction() =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another diff --git a/BaseTools/Source/Python/FMMT/FMMT.py b/BaseTools/Source/Python= /FMMT/FMMT.py index 10800e776a72..e566df65e5fa 100644 --- a/BaseTools/Source/Python/FMMT/FMMT.py +++ b/BaseTools/Source/Python/FMMT/FMMT.py @@ -41,35 +41,37 @@ parser.add_argument("-c", "--ConfigFilePath", dest=3D"C= onfigFilePath", nargs=3D'+', If do not provide, FMMT tool will search the input= file folder for FmmtConf.ini firstly, if not found,\ the FmmtConf.ini saved in FMMT tool's folder will = be used as default.") =20 + def print_banner(): print("") =20 + class FMMT(): def __init__(self) -> None: self.firmware_packet =3D {} =20 - def SetConfigFilePath(self, configfilepath:str) -> str: + def SetConfigFilePath(self, configfilepath: str) -> str: os.environ['FmmtConfPath'] =3D os.path.abspath(configfilepath) =20 - def SetDestPath(self, inputfile:str) -> str: + def SetDestPath(self, inputfile: str) -> str: os.environ['FmmtConfPath'] =3D '' self.dest_path =3D os.path.dirname(os.path.abspath(inputfile)) old_env =3D os.environ['PATH'] os.environ['PATH'] =3D self.dest_path + os.pathsep + old_env =20 - def CheckFfsName(self, FfsName:str) -> str: + def CheckFfsName(self, FfsName: str) -> str: try: return uuid.UUID(FfsName) except: return FfsName =20 - def GetFvName(self, FvName:str) -> str: + def GetFvName(self, FvName: str) -> str: try: return uuid.UUID(FvName) except: return FvName =20 - def View(self, inputfile: str, layoutfilename: str=3DNone, outputfile:= str=3DNone) -> None: + def View(self, inputfile: str, layoutfilename: str =3D None, outputfil= e: str =3D None) -> None: # ViewFile(inputfile, ROOT_TYPE, logfile, outputfile) self.SetDestPath(inputfile) filetype =3D os.path.splitext(inputfile)[1].lower() @@ -85,38 +87,43 @@ class FMMT(): ROOT_TYPE =3D ROOT_TREE ViewFile(inputfile, ROOT_TYPE, layoutfilename, outputfile) =20 - def Delete(self, inputfile: str, TargetFfs_name: str, outputfile: str,= Fv_name: str=3DNone) -> None: + def Delete(self, inputfile: str, TargetFfs_name: str, outputfile: str,= Fv_name: str =3D None) -> None: self.SetDestPath(inputfile) if Fv_name: - DeleteFfs(inputfile, self.CheckFfsName(TargetFfs_name), output= file, self.GetFvName(Fv_name)) + DeleteFfs(inputfile, self.CheckFfsName(TargetFfs_name), + outputfile, self.GetFvName(Fv_name)) else: DeleteFfs(inputfile, self.CheckFfsName(TargetFfs_name), output= file) =20 - def Extract(self, inputfile: str, Ffs_name: str, outputfile: str, Fv_n= ame: str=3DNone) -> None: + def Extract(self, inputfile: str, Ffs_name: str, outputfile: str, Fv_n= ame: str =3D None) -> None: self.SetDestPath(inputfile) if Fv_name: - ExtractFfs(inputfile, self.CheckFfsName(Ffs_name), outputfile,= self.GetFvName(Fv_name)) + ExtractFfs(inputfile, self.CheckFfsName(Ffs_name), + outputfile, self.GetFvName(Fv_name)) else: ExtractFfs(inputfile, self.CheckFfsName(Ffs_name), outputfile) =20 def Add(self, inputfile: str, Fv_name: str, newffsfile: str, outputfil= e: str) -> None: self.SetDestPath(inputfile) - AddNewFfs(inputfile, self.CheckFfsName(Fv_name), newffsfile, outpu= tfile) + AddNewFfs(inputfile, self.CheckFfsName( + Fv_name), newffsfile, outputfile) =20 - def Replace(self,inputfile: str, Ffs_name: str, newffsfile: str, outpu= tfile: str, Fv_name: str=3DNone) -> None: + def Replace(self, inputfile: str, Ffs_name: str, newffsfile: str, outp= utfile: str, Fv_name: str =3D None) -> None: self.SetDestPath(inputfile) if Fv_name: - ReplaceFfs(inputfile, self.CheckFfsName(Ffs_name), newffsfile,= outputfile, self.GetFvName(Fv_name)) + ReplaceFfs(inputfile, self.CheckFfsName(Ffs_name), + newffsfile, outputfile, self.GetFvName(Fv_name)) else: - ReplaceFfs(inputfile, self.CheckFfsName(Ffs_name), newffsfile,= outputfile) + ReplaceFfs(inputfile, self.CheckFfsName( + Ffs_name), newffsfile, outputfile) =20 =20 def main(): - args=3Dparser.parse_args() - status=3D0 + args =3D parser.parse_args() + status =3D 0 =20 try: - fmmt=3DFMMT() + fmmt =3D FMMT() if args.ConfigFilePath: fmmt.SetConfigFilePath(args.ConfigFilePath[0]) if args.View: @@ -126,21 +133,25 @@ def main(): fmmt.View(args.View[0]) elif args.Delete: if len(args.Delete) =3D=3D 4: - fmmt.Delete(args.Delete[0],args.Delete[2],args.Delete[3],a= rgs.Delete[1]) + fmmt.Delete(args.Delete[0], args.Delete[2], + args.Delete[3], args.Delete[1]) else: - fmmt.Delete(args.Delete[0],args.Delete[1],args.Delete[2]) + fmmt.Delete(args.Delete[0], args.Delete[1], args.Delete[2]) elif args.Extract: if len(args.Extract) =3D=3D 4: - fmmt.Extract(args.Extract[0],args.Extract[2],args.Extract[= 3], args.Extract[1]) + fmmt.Extract(args.Extract[0], args.Extract[2], + args.Extract[3], args.Extract[1]) else: - fmmt.Extract(args.Extract[0],args.Extract[1],args.Extract[= 2]) + fmmt.Extract(args.Extract[0], args.Extract[1], args.Extrac= t[2]) elif args.Add: - fmmt.Add(args.Add[0],args.Add[1],args.Add[2],args.Add[3]) + fmmt.Add(args.Add[0], args.Add[1], args.Add[2], args.Add[3]) elif args.Replace: if len(args.Replace) =3D=3D 5: - fmmt.Replace(args.Replace[0],args.Replace[2],args.Replace[= 3],args.Replace[4],args.Replace[1]) + fmmt.Replace(args.Replace[0], args.Replace[2], + args.Replace[3], args.Replace[4], args.Replac= e[1]) else: - fmmt.Replace(args.Replace[0],args.Replace[1],args.Replace[= 2],args.Replace[3]) + fmmt.Replace(args.Replace[0], args.Replace[1], + args.Replace[2], args.Replace[3]) else: parser.print_help() except Exception as e: diff --git a/BaseTools/Source/Python/FMMT/__init__.py b/BaseTools/Source/Py= thon/FMMT/__init__.py index 04e6ec098d0e..ed81c69d67b0 100644 --- a/BaseTools/Source/Python/FMMT/__init__.py +++ b/BaseTools/Source/Python/FMMT/__init__.py @@ -1,6 +1,6 @@ -## @file +# @file # This file is used to define the FMMT dependent external tool. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent -## \ No newline at end of file +## diff --git a/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py b/Ba= seTools/Source/Python/FMMT/core/BinaryFactoryProduct.py index 2d4e6d9276d7..16a3ddbc0ae6 100644 --- a/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py +++ b/BaseTools/Source/Python/FMMT/core/BinaryFactoryProduct.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to implement of the various bianry parser. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -29,19 +29,23 @@ SEC_FV_TREE =3D 'SEC_FV_IMAGE' BINARY_DATA =3D 'BINARY' Fv_count =3D 0 =20 -## Abstract factory +# Abstract factory + + class BinaryFactory(): - type:list =3D [] + type: list =3D [] =20 def Create_Product(): pass =20 + class BinaryProduct(): - ## Use GuidTool to decompress data. + # Use GuidTool to decompress data. def DeCompressData(self, GuidTool, Section_Data: bytes, FileName) -> b= ytes: guidtool =3D GUIDTools().__getitem__(struct2stream(GuidTool)) if not guidtool.ifexist: - logger.error("GuidTool {} is not found when decompressing {} f= ile.\n".format(guidtool.command, FileName)) + logger.error("GuidTool {} is not found when decompressing {} f= ile.\n".format( + guidtool.command, FileName)) raise Exception("Process Failed: GuidTool not found!") DecompressedData =3D guidtool.unpack(Section_Data) return DecompressedData @@ -49,33 +53,38 @@ class BinaryProduct(): def ParserData(): pass =20 + class SectionFactory(BinaryFactory): type =3D [SECTION_TREE] =20 def Create_Product(): return SectionProduct() =20 + class FfsFactory(BinaryFactory): type =3D [ROOT_SECTION_TREE, FFS_TREE] =20 def Create_Product(): return FfsProduct() =20 + class FvFactory(BinaryFactory): type =3D [ROOT_FFS_TREE, FV_TREE, SEC_FV_TREE] =20 def Create_Product(): return FvProduct() =20 + class FdFactory(BinaryFactory): type =3D [ROOT_FV_TREE, ROOT_TREE] =20 def Create_Product(): return FdProduct() =20 + class SectionProduct(BinaryProduct): - ## Decompress the compressed section. - def ParserData(self, Section_Tree, whole_Data: bytes, Rel_Whole_Offset= : int=3D0) -> None: + # Decompress the compressed section. + def ParserData(self, Section_Tree, whole_Data: bytes, Rel_Whole_Offset= : int =3D 0) -> None: if Section_Tree.Data.Type =3D=3D 0x01: Section_Tree.Data.OriData =3D Section_Tree.Data.Data self.ParserSection(Section_Tree, b'') @@ -83,8 +92,10 @@ class SectionProduct(BinaryProduct): elif Section_Tree.Data.Type =3D=3D 0x02: Section_Tree.Data.OriData =3D Section_Tree.Data.Data DeCompressGuidTool =3D Section_Tree.Data.ExtHeader.SectionDefi= nitionGuid - Section_Tree.Data.Data =3D self.DeCompressData(DeCompressGuidT= ool, Section_Tree.Data.Data, Section_Tree.Parent.Data.Name) - Section_Tree.Data.Size =3D len(Section_Tree.Data.Data) + Secti= on_Tree.Data.HeaderLength + Section_Tree.Data.Data =3D self.DeCompressData( + DeCompressGuidTool, Section_Tree.Data.Data, Section_Tree.P= arent.Data.Name) + Section_Tree.Data.Size =3D len( + Section_Tree.Data.Data) + Section_Tree.Data.HeaderLength self.ParserSection(Section_Tree, b'') elif Section_Tree.Data.Type =3D=3D 0x03: Section_Tree.Data.OriData =3D Section_Tree.Data.Data @@ -93,16 +104,17 @@ class SectionProduct(BinaryProduct): elif Section_Tree.Data.Type =3D=3D 0x17: global Fv_count Sec_Fv_Info =3D FvNode(Fv_count, Section_Tree.Data.Data) - Sec_Fv_Tree =3D BIOSTREE('FV'+ str(Fv_count)) + Sec_Fv_Tree =3D BIOSTREE('FV' + str(Fv_count)) Sec_Fv_Tree.type =3D SEC_FV_TREE Sec_Fv_Tree.Data =3D Sec_Fv_Info Sec_Fv_Tree.Data.HOffset =3D Section_Tree.Data.DOffset - Sec_Fv_Tree.Data.DOffset =3D Sec_Fv_Tree.Data.HOffset + Sec_Fv= _Tree.Data.Header.HeaderLength + Sec_Fv_Tree.Data.DOffset =3D Sec_Fv_Tree.Data.HOffset + \ + Sec_Fv_Tree.Data.Header.HeaderLength Sec_Fv_Tree.Data.Data =3D Section_Tree.Data.Data[Sec_Fv_Tree.D= ata.Header.HeaderLength:] Section_Tree.insertChild(Sec_Fv_Tree) Fv_count +=3D 1 =20 - def ParserSection(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: = int=3D0) -> None: + def ParserSection(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: = int =3D 0) -> None: Rel_Offset =3D 0 Section_Offset =3D 0 # Get the Data from parent tree, if do not have the tree then get = it from the whole_data. @@ -118,8 +130,10 @@ class SectionProduct(BinaryProduct): Section_Info =3D SectionNode(Whole_Data[Rel_Offset:]) Section_Tree =3D BIOSTREE(Section_Info.Name) Section_Tree.type =3D SECTION_TREE - Section_Info.Data =3D Whole_Data[Rel_Offset+Section_Info.Heade= rLength: Rel_Offset+Section_Info.Size] - Section_Info.DOffset =3D Section_Offset + Section_Info.HeaderL= ength + Rel_Whole_Offset + Section_Info.Data =3D Whole_Data[Rel_Offset + + Section_Info.HeaderLength: Rel_= Offset+Section_Info.Size] + Section_Info.DOffset =3D Section_Offset + \ + Section_Info.HeaderLength + Rel_Whole_Offset Section_Info.HOffset =3D Section_Offset + Rel_Whole_Offset Section_Info.ROffset =3D Rel_Offset if Section_Info.Header.Type =3D=3D 0: @@ -127,11 +141,14 @@ class SectionProduct(BinaryProduct): # The final Section in parent Section does not need to add pad= ding, else must be 4-bytes align with parent Section start offset Pad_Size =3D 0 if (Rel_Offset+Section_Info.HeaderLength+len(Section_Info.Data= ) !=3D Data_Size): - Pad_Size =3D GetPadSize(Section_Info.Size, SECTION_COMMON_= ALIGNMENT) + Pad_Size =3D GetPadSize( + Section_Info.Size, SECTION_COMMON_ALIGNMENT) Section_Info.PadData =3D Pad_Size * b'\x00' if Section_Info.Header.Type =3D=3D 0x02: - Section_Info.DOffset =3D Section_Offset + Section_Info.Ext= Header.DataOffset + Rel_Whole_Offset - Section_Info.Data =3D Whole_Data[Rel_Offset+Section_Info.E= xtHeader.DataOffset: Rel_Offset+Section_Info.Size] + Section_Info.DOffset =3D Section_Offset + \ + Section_Info.ExtHeader.DataOffset + Rel_Whole_Offset + Section_Info.Data =3D Whole_Data[Rel_Offset + + Section_Info.ExtHeader.Data= Offset: Rel_Offset+Section_Info.Size] if Section_Info.Header.Type =3D=3D 0x14: ParTree.Data.Version =3D Section_Info.ExtHeader.GetVersion= String() if Section_Info.Header.Type =3D=3D 0x15: @@ -144,9 +161,10 @@ class SectionProduct(BinaryProduct): Section_Tree.Data =3D Section_Info ParTree.insertChild(Section_Tree) =20 + class FfsProduct(BinaryProduct): # ParserFFs / GetSection - def ParserData(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: int= =3D0) -> None: + def ParserData(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: int= =3D 0) -> None: Rel_Offset =3D 0 Section_Offset =3D 0 # Get the Data from parent tree, if do not have the tree then get = it from the whole_data. @@ -162,8 +180,10 @@ class FfsProduct(BinaryProduct): Section_Info =3D SectionNode(Whole_Data[Rel_Offset:]) Section_Tree =3D BIOSTREE(Section_Info.Name) Section_Tree.type =3D SECTION_TREE - Section_Info.Data =3D Whole_Data[Rel_Offset+Section_Info.Heade= rLength: Rel_Offset+Section_Info.Size] - Section_Info.DOffset =3D Section_Offset + Section_Info.HeaderL= ength + Rel_Whole_Offset + Section_Info.Data =3D Whole_Data[Rel_Offset + + Section_Info.HeaderLength: Rel_= Offset+Section_Info.Size] + Section_Info.DOffset =3D Section_Offset + \ + Section_Info.HeaderLength + Rel_Whole_Offset Section_Info.HOffset =3D Section_Offset + Rel_Whole_Offset Section_Info.ROffset =3D Rel_Offset if Section_Info.Header.Type =3D=3D 0: @@ -171,11 +191,14 @@ class FfsProduct(BinaryProduct): # The final Section in Ffs does not need to add padding, else = must be 4-bytes align with Ffs start offset Pad_Size =3D 0 if (Rel_Offset+Section_Info.HeaderLength+len(Section_Info.Data= ) !=3D Data_Size): - Pad_Size =3D GetPadSize(Section_Info.Size, SECTION_COMMON_= ALIGNMENT) + Pad_Size =3D GetPadSize( + Section_Info.Size, SECTION_COMMON_ALIGNMENT) Section_Info.PadData =3D Pad_Size * b'\x00' if Section_Info.Header.Type =3D=3D 0x02: - Section_Info.DOffset =3D Section_Offset + Section_Info.Ext= Header.DataOffset + Rel_Whole_Offset - Section_Info.Data =3D Whole_Data[Rel_Offset+Section_Info.E= xtHeader.DataOffset: Rel_Offset+Section_Info.Size] + Section_Info.DOffset =3D Section_Offset + \ + Section_Info.ExtHeader.DataOffset + Rel_Whole_Offset + Section_Info.Data =3D Whole_Data[Rel_Offset + + Section_Info.ExtHeader.Data= Offset: Rel_Offset+Section_Info.Size] # If Section is Version or UI type, it saves the version and U= I info of its parent Ffs. if Section_Info.Header.Type =3D=3D 0x14: ParTree.Data.Version =3D Section_Info.ExtHeader.GetVersion= String() @@ -189,9 +212,10 @@ class FfsProduct(BinaryProduct): Section_Tree.Data =3D Section_Info ParTree.insertChild(Section_Tree) =20 + class FvProduct(BinaryProduct): ## ParserFv / GetFfs - def ParserData(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: int= =3D0) -> None: + def ParserData(self, ParTree, Whole_Data: bytes, Rel_Whole_Offset: int= =3D 0) -> None: Ffs_Offset =3D 0 Rel_Offset =3D 0 # Get the Data from parent tree, if do not have the tree then get = it from the whole_data. @@ -221,8 +245,10 @@ class FvProduct(BinaryProduct): Ffs_Info.ROffset =3D Rel_Offset if Ffs_Info.Name =3D=3D PADVECTOR: Ffs_Tree.type =3D FFS_PAD - Ffs_Info.Data =3D Whole_Data[Rel_Offset+Ffs_Info.Heade= r.HeaderLength: Rel_Offset+Ffs_Info.Size] - Ffs_Info.Size =3D len(Ffs_Info.Data) + Ffs_Info.Header= .HeaderLength + Ffs_Info.Data =3D Whole_Data[Rel_Offset + + Ffs_Info.Header.HeaderLengt= h: Rel_Offset+Ffs_Info.Size] + Ffs_Info.Size =3D len(Ffs_Info.Data) + \ + Ffs_Info.Header.HeaderLength # if current Ffs is the final ffs of Fv and full of b'= \xff', define it with Free_Space if struct2stream(Ffs_Info.Header).replace(b'\xff', b''= ) =3D=3D b'': Ffs_Tree.type =3D FFS_FREE_SPACE @@ -231,7 +257,8 @@ class FvProduct(BinaryProduct): ParTree.Data.Free_Space =3D Ffs_Info.Size else: Ffs_Tree.type =3D FFS_TREE - Ffs_Info.Data =3D Whole_Data[Rel_Offset+Ffs_Info.Heade= r.HeaderLength: Rel_Offset+Ffs_Info.Size] + Ffs_Info.Data =3D Whole_Data[Rel_Offset + + Ffs_Info.Header.HeaderLengt= h: Rel_Offset+Ffs_Info.Size] # The final Ffs in Fv does not need to add padding, else m= ust be 8-bytes align with Fv start offset Pad_Size =3D 0 if Ffs_Tree.type !=3D FFS_FREE_SPACE and (Rel_Offset+Ffs_I= nfo.Header.HeaderLength+len(Ffs_Info.Data) !=3D Data_Size): @@ -242,11 +269,12 @@ class FvProduct(BinaryProduct): Ffs_Tree.Data =3D Ffs_Info ParTree.insertChild(Ffs_Tree) =20 + class FdProduct(BinaryProduct): type =3D [ROOT_FV_TREE, ROOT_TREE] =20 - ## Create DataTree with first level /fv Info, then parser each Fv. - def ParserData(self, WholeFvTree, whole_data: bytes=3Db'', offset: int= =3D0) -> None: + # Create DataTree with first level /fv Info, then parser each Fv. + def ParserData(self, WholeFvTree, whole_data: bytes =3D b'', offset: i= nt =3D 0) -> None: # Get all Fv image in Fd with offset and length Fd_Struct =3D self.GetFvFromFd(whole_data) data_size =3D len(whole_data) @@ -254,7 +282,7 @@ class FdProduct(BinaryProduct): global Fv_count # If the first Fv image is the Binary Fv, add it into the tree. if Fd_Struct[0][1] !=3D 0: - Binary_node =3D BIOSTREE('BINARY'+ str(Binary_count)) + Binary_node =3D BIOSTREE('BINARY' + str(Binary_count)) Binary_node.type =3D BINARY_DATA Binary_node.Data =3D BinaryNode(str(Binary_count)) Binary_node.Data.Data =3D whole_data[:Fd_Struct[0][1]] @@ -263,56 +291,66 @@ class FdProduct(BinaryProduct): WholeFvTree.insertChild(Binary_node) Binary_count +=3D 1 # Add the first collected Fv image into the tree. - Cur_node =3D BIOSTREE(Fd_Struct[0][0]+ str(Fv_count)) + Cur_node =3D BIOSTREE(Fd_Struct[0][0] + str(Fv_count)) Cur_node.type =3D Fd_Struct[0][0] - Cur_node.Data =3D FvNode(Fv_count, whole_data[Fd_Struct[0][1]:Fd_S= truct[0][1]+Fd_Struct[0][2][0]]) + Cur_node.Data =3D FvNode( + Fv_count, whole_data[Fd_Struct[0][1]:Fd_Struct[0][1]+Fd_Struct= [0][2][0]]) Cur_node.Data.HOffset =3D Fd_Struct[0][1] + offset Cur_node.Data.DOffset =3D Cur_node.Data.HOffset+Cur_node.Data.Head= er.HeaderLength - Cur_node.Data.Data =3D whole_data[Fd_Struct[0][1]+Cur_node.Data.He= ader.HeaderLength:Fd_Struct[0][1]+Cur_node.Data.Size] + Cur_node.Data.Data =3D whole_data[Fd_Struct[0][1] + + Cur_node.Data.Header.HeaderLength:= Fd_Struct[0][1]+Cur_node.Data.Size] WholeFvTree.insertChild(Cur_node) Fv_count +=3D 1 Fv_num =3D len(Fd_Struct) # Add all the collected Fv image and the Binary Fv image between t= hem into the tree. for i in range(Fv_num-1): if Fd_Struct[i][1]+Fd_Struct[i][2][0] !=3D Fd_Struct[i+1][1]: - Binary_node =3D BIOSTREE('BINARY'+ str(Binary_count)) + Binary_node =3D BIOSTREE('BINARY' + str(Binary_count)) Binary_node.type =3D BINARY_DATA Binary_node.Data =3D BinaryNode(str(Binary_count)) - Binary_node.Data.Data =3D whole_data[Fd_Struct[i][1]+Fd_St= ruct[i][2][0]:Fd_Struct[i+1][1]] + Binary_node.Data.Data =3D whole_data[Fd_Struct[i] + [1]+Fd_Struct[i][2][0]:= Fd_Struct[i+1][1]] Binary_node.Data.Size =3D len(Binary_node.Data.Data) - Binary_node.Data.HOffset =3D Fd_Struct[i][1]+Fd_Struct[i][= 2][0] + offset + Binary_node.Data.HOffset =3D Fd_Struct[i][1] + \ + Fd_Struct[i][2][0] + offset WholeFvTree.insertChild(Binary_node) Binary_count +=3D 1 - Cur_node =3D BIOSTREE(Fd_Struct[i+1][0]+ str(Fv_count)) + Cur_node =3D BIOSTREE(Fd_Struct[i+1][0] + str(Fv_count)) Cur_node.type =3D Fd_Struct[i+1][0] - Cur_node.Data =3D FvNode(Fv_count, whole_data[Fd_Struct[i+1][1= ]:Fd_Struct[i+1][1]+Fd_Struct[i+1][2][0]]) + Cur_node.Data =3D FvNode( + Fv_count, whole_data[Fd_Struct[i+1][1]:Fd_Struct[i+1][1]+F= d_Struct[i+1][2][0]]) Cur_node.Data.HOffset =3D Fd_Struct[i+1][1] + offset Cur_node.Data.DOffset =3D Cur_node.Data.HOffset+Cur_node.Data.= Header.HeaderLength - Cur_node.Data.Data =3D whole_data[Fd_Struct[i+1][1]+Cur_node.D= ata.Header.HeaderLength:Fd_Struct[i+1][1]+Cur_node.Data.Size] + Cur_node.Data.Data =3D whole_data[Fd_Struct[i+1][1] + + Cur_node.Data.Header.HeaderLen= gth:Fd_Struct[i+1][1]+Cur_node.Data.Size] WholeFvTree.insertChild(Cur_node) Fv_count +=3D 1 # If the final Fv image is the Binary Fv, add it into the tree if Fd_Struct[-1][1] + Fd_Struct[-1][2][0] !=3D data_size: - Binary_node =3D BIOSTREE('BINARY'+ str(Binary_count)) + Binary_node =3D BIOSTREE('BINARY' + str(Binary_count)) Binary_node.type =3D BINARY_DATA Binary_node.Data =3D BinaryNode(str(Binary_count)) - Binary_node.Data.Data =3D whole_data[Fd_Struct[-1][1]+Fd_Struc= t[-1][2][0]:] + Binary_node.Data.Data =3D whole_data[Fd_Struct[-1] + [1]+Fd_Struct[-1][2][0]:] Binary_node.Data.Size =3D len(Binary_node.Data.Data) - Binary_node.Data.HOffset =3D Fd_Struct[-1][1]+Fd_Struct[-1][2]= [0] + offset + Binary_node.Data.HOffset =3D Fd_Struct[-1][1] + \ + Fd_Struct[-1][2][0] + offset WholeFvTree.insertChild(Binary_node) Binary_count +=3D 1 =20 - ## Get the first level Fv from Fd file. - def GetFvFromFd(self, whole_data: bytes=3Db'') -> list: + # Get the first level Fv from Fd file. + def GetFvFromFd(self, whole_data: bytes =3D b'') -> list: Fd_Struct =3D [] data_size =3D len(whole_data) cur_index =3D 0 # Get all the EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE FV image offset = and length. while cur_index < data_size: if EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE in whole_data[cur_index= :]: - target_index =3D whole_data[cur_index:].index(EFI_FIRMWARE= _FILE_SYSTEM2_GUID_BYTE) + cur_index + target_index =3D whole_data[cur_index:].index( + EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE) + cur_index if whole_data[target_index+24:target_index+28] =3D=3D FVH_= SIGNATURE: - Fd_Struct.append([FV_TREE, target_index - 16, unpack("= Q", whole_data[target_index+16:target_index+24])]) + Fd_Struct.append( + [FV_TREE, target_index - 16, unpack("Q", whole_dat= a[target_index+16:target_index+24])]) cur_index =3D Fd_Struct[-1][1] + Fd_Struct[-1][2][0] else: cur_index =3D target_index + 16 @@ -322,9 +360,11 @@ class FdProduct(BinaryProduct): # Get all the EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE FV image offset = and length. while cur_index < data_size: if EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE in whole_data[cur_index= :]: - target_index =3D whole_data[cur_index:].index(EFI_FIRMWARE= _FILE_SYSTEM3_GUID_BYTE) + cur_index + target_index =3D whole_data[cur_index:].index( + EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE) + cur_index if whole_data[target_index+24:target_index+28] =3D=3D FVH_= SIGNATURE: - Fd_Struct.append([FV_TREE, target_index - 16, unpack("= Q", whole_data[target_index+16:target_index+24])]) + Fd_Struct.append( + [FV_TREE, target_index - 16, unpack("Q", whole_dat= a[target_index+16:target_index+24])]) cur_index =3D Fd_Struct[-1][1] + Fd_Struct[-1][2][0] else: cur_index =3D target_index + 16 @@ -334,28 +374,31 @@ class FdProduct(BinaryProduct): # Get all the EFI_SYSTEM_NVDATA_FV_GUID_BYTE FV image offset and l= ength. while cur_index < data_size: if EFI_SYSTEM_NVDATA_FV_GUID_BYTE in whole_data[cur_index:]: - target_index =3D whole_data[cur_index:].index(EFI_SYSTEM_N= VDATA_FV_GUID_BYTE) + cur_index + target_index =3D whole_data[cur_index:].index( + EFI_SYSTEM_NVDATA_FV_GUID_BYTE) + cur_index if whole_data[target_index+24:target_index+28] =3D=3D FVH_= SIGNATURE: - Fd_Struct.append([DATA_FV_TREE, target_index - 16, unp= ack("Q", whole_data[target_index+16:target_index+24])]) + Fd_Struct.append( + [DATA_FV_TREE, target_index - 16, unpack("Q", whol= e_data[target_index+16:target_index+24])]) cur_index =3D Fd_Struct[-1][1] + Fd_Struct[-1][2][0] else: cur_index =3D target_index + 16 else: cur_index =3D data_size # Sort all the collect Fv image with offset. - Fd_Struct.sort(key=3Dlambda x:x[1]) + Fd_Struct.sort(key=3Dlambda x: x[1]) tmp_struct =3D copy.deepcopy(Fd_Struct) tmp_index =3D 0 Fv_num =3D len(Fd_Struct) # Remove the Fv image included in another Fv image. - for i in range(1,Fv_num): + for i in range(1, Fv_num): if tmp_struct[i][1]+tmp_struct[i][2][0] < tmp_struct[i-1][1]+t= mp_struct[i-1][2][0]: Fd_Struct.remove(Fd_Struct[i-tmp_index]) tmp_index +=3D 1 return Fd_Struct =20 + class ParserEntry(): - FactoryTable:dict =3D { + FactoryTable: dict =3D { SECTION_TREE: SectionFactory, ROOT_SECTION_TREE: FfsFactory, FFS_TREE: FfsFactory, @@ -377,4 +420,4 @@ class ParserEntry(): def DataParser(self, Tree, Data: bytes, Offset: int) -> None: TargetFactory =3D self.GetTargetFactory(Tree.type) if TargetFactory: - self.Generate_Product(TargetFactory, Tree, Data, Offset) \ No newline at end of file + self.Generate_Product(TargetFactory, Tree, Data, Offset) diff --git a/BaseTools/Source/Python/FMMT/core/BiosTree.py b/BaseTools/Sour= ce/Python/FMMT/core/BiosTree.py index d8fa4743354a..ab9cc6995e12 100644 --- a/BaseTools/Source/Python/FMMT/core/BiosTree.py +++ b/BaseTools/Source/Python/FMMT/core/BiosTree.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the Bios layout tree structure and related o= perations. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -27,6 +27,7 @@ FvType =3D [FV_TREE, SEC_FV_TREE] FfsType =3D FFS_TREE SecType =3D SECTION_TREE =20 + class BIOSTREE: def __init__(self, NodeName: str) -> None: self.key =3D NodeName @@ -52,7 +53,7 @@ class BIOSTREE: return False =20 # FvTree.insertChild() - def insertChild(self, newNode, pos: int=3DNone) -> None: + def insertChild(self, newNode, pos: int =3D None) -> None: if len(self.Child) =3D=3D 0: self.Child.append(newNode) else: @@ -112,39 +113,48 @@ class BIOSTREE: self =3D self.Parent return BiosTreePath =20 - def parserTree(self, TargetDict: dict=3DNone, Info: list=3DNone, space= : int=3D0, ParFvId=3D"") -> None: + def parserTree(self, TargetDict: dict =3D None, Info: list =3D None, s= pace: int =3D 0, ParFvId=3D"") -> None: Key =3D list(TargetDict.keys())[0] if TargetDict[Key]["Type"] in RootType: Info.append("Image File: {}".format(Key)) - Info.append("FilesNum: {}".format(TargetDict.get(Key).get('Fil= esNum'))) + Info.append("FilesNum: {}".format( + TargetDict.get(Key).get('FilesNum'))) Info.append("\n") elif TargetDict[Key]["Type"] in FvType: space +=3D 2 if TargetDict[Key]["Type"] =3D=3D SEC_FV_TREE: - Info.append("{}Child FV named {} of {}".format(space*" ", = Key, ParFvId)) + Info.append("{}Child FV named {} of {}".format( + space*" ", Key, ParFvId)) space +=3D 2 else: Info.append("FvId: {}".format(Key)) ParFvId =3D Key - Info.append("{}FvNameGuid: {}".format(space*" ", TargetDict.ge= t(Key).get('FvNameGuid'))) - Info.append("{}Attributes: {}".format(space*" ", TargetDict.ge= t(Key).get('Attributes'))) - Info.append("{}Total Volume Size: {}".format(space*" ", Target= Dict.get(Key).get('Size'))) - Info.append("{}Free Volume Size: {}".format(space*" ", TargetD= ict.get(Key).get('FreeSize'))) - Info.append("{}Volume Offset: {}".format(space*" ", TargetDict= .get(Key).get('Offset'))) - Info.append("{}FilesNum: {}".format(space*" ", TargetDict.get(= Key).get('FilesNum'))) + Info.append("{}FvNameGuid: {}".format( + space*" ", TargetDict.get(Key).get('FvNameGuid'))) + Info.append("{}Attributes: {}".format( + space*" ", TargetDict.get(Key).get('Attributes'))) + Info.append("{}Total Volume Size: {}".format( + space*" ", TargetDict.get(Key).get('Size'))) + Info.append("{}Free Volume Size: {}".format( + space*" ", TargetDict.get(Key).get('FreeSize'))) + Info.append("{}Volume Offset: {}".format( + space*" ", TargetDict.get(Key).get('Offset'))) + Info.append("{}FilesNum: {}".format( + space*" ", TargetDict.get(Key).get('FilesNum'))) elif TargetDict[Key]["Type"] in FfsType: space +=3D 2 if TargetDict.get(Key).get('UiName') !=3D "b''": - Info.append("{}File: {} / {}".format(space*" ", Key, Targe= tDict.get(Key).get('UiName'))) + Info.append("{}File: {} / {}".format(space*" ", + Key, TargetDict.get(Key).get('UiName'))) else: Info.append("{}File: {}".format(space*" ", Key)) if "Files" in list(TargetDict[Key].keys()): for item in TargetDict[Key]["Files"]: self.parserTree(item, Info, space, ParFvId) =20 - def ExportTree(self,TreeInfo: dict=3DNone) -> dict: + def ExportTree(self, TreeInfo: dict =3D None) -> dict: if TreeInfo is None: - TreeInfo =3Dcollections.OrderedDict() + TreeInfo =3D collections.OrderedDict() =20 if self.type =3D=3D ROOT_TREE or self.type =3D=3D ROOT_FV_TREE or = self.type =3D=3D ROOT_FFS_TREE or self.type =3D=3D ROOT_SECTION_TREE: key =3D str(self.key) @@ -152,7 +162,7 @@ class BIOSTREE: TreeInfo[self.key]["Name"] =3D key TreeInfo[self.key]["Type"] =3D self.type TreeInfo[self.key]["FilesNum"] =3D len(self.Child) - elif self.type =3D=3D FV_TREE or self.type =3D=3D SEC_FV_TREE: + elif self.type =3D=3D FV_TREE or self.type =3D=3D SEC_FV_TREE: key =3D str(self.Data.FvId) TreeInfo[key] =3D collections.OrderedDict() TreeInfo[key]["Name"] =3D key @@ -179,7 +189,8 @@ class BIOSTREE: TreeInfo[key] =3D collections.OrderedDict() TreeInfo[key]["Name"] =3D key TreeInfo[key]["Type"] =3D self.type - TreeInfo[key]["Size"] =3D hex(len(self.Data.OriData) + self.Da= ta.HeaderLength) + TreeInfo[key]["Size"] =3D hex( + len(self.Data.OriData) + self.Data.HeaderLength) TreeInfo[key]["DecompressedSize"] =3D hex(self.Data.Size) TreeInfo[key]["Offset"] =3D hex(self.Data.HOffset) TreeInfo[key]["FilesNum"] =3D len(self.Child) @@ -193,6 +204,6 @@ class BIOSTREE: TreeInfo[key]["FilesNum"] =3D len(self.Child) =20 for item in self.Child: - TreeInfo[key].setdefault('Files',[]).append( item.ExportTree()) + TreeInfo[key].setdefault('Files', []).append(item.ExportTree()) =20 - return TreeInfo \ No newline at end of file + return TreeInfo diff --git a/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py b/BaseTools/= Source/Python/FMMT/core/BiosTreeNode.py index 20447766c821..360d9477d79a 100644 --- a/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py +++ b/BaseTools/Source/Python/FMMT/core/BiosTreeNode.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the BIOS Tree Node. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -12,24 +12,25 @@ from utils.FmmtLogger import FmmtLogger as logger import uuid =20 SectionHeaderType =3D { - 0x01:'EFI_COMPRESSION_SECTION', - 0x02:'EFI_GUID_DEFINED_SECTION', - 0x03:'EFI_SECTION_DISPOSABLE', - 0x10:'EFI_SECTION_PE32', - 0x11:'EFI_SECTION_PIC', - 0x12:'EFI_SECTION_TE', - 0x13:'EFI_SECTION_DXE_DEPEX', - 0x14:'EFI_SECTION_VERSION', - 0x15:'EFI_SECTION_USER_INTERFACE', - 0x16:'EFI_SECTION_COMPATIBILITY16', - 0x17:'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', - 0x18:'EFI_FREEFORM_SUBTYPE_GUID_SECTION', - 0x19:'EFI_SECTION_RAW', - 0x1B:'EFI_SECTION_PEI_DEPEX', - 0x1C:'EFI_SECTION_MM_DEPEX' + 0x01: 'EFI_COMPRESSION_SECTION', + 0x02: 'EFI_GUID_DEFINED_SECTION', + 0x03: 'EFI_SECTION_DISPOSABLE', + 0x10: 'EFI_SECTION_PE32', + 0x11: 'EFI_SECTION_PIC', + 0x12: 'EFI_SECTION_TE', + 0x13: 'EFI_SECTION_DXE_DEPEX', + 0x14: 'EFI_SECTION_VERSION', + 0x15: 'EFI_SECTION_USER_INTERFACE', + 0x16: 'EFI_SECTION_COMPATIBILITY16', + 0x17: 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', + 0x18: 'EFI_FREEFORM_SUBTYPE_GUID_SECTION', + 0x19: 'EFI_SECTION_RAW', + 0x1B: 'EFI_SECTION_PEI_DEPEX', + 0x1C: 'EFI_SECTION_MM_DEPEX' } HeaderType =3D [0x01, 0x02, 0x14, 0x15, 0x18] =20 + class BinaryNode: def __init__(self, name: str) -> None: self.Size =3D 0 @@ -37,6 +38,7 @@ class BinaryNode: self.HOffset =3D 0 self.Data =3D b'' =20 + class FvNode: def __init__(self, name, buffer: bytes) -> None: self.Header =3D EFI_FIRMWARE_VOLUME_HEADER.from_buffer_copy(buffer) @@ -45,21 +47,27 @@ class FvNode: self.FvId =3D "FV" + str(name) self.Name =3D "FV" + str(name) if self.Header.ExtHeaderOffset: - self.ExtHeader =3D EFI_FIRMWARE_VOLUME_EXT_HEADER.from_buffer_= copy(buffer[self.Header.ExtHeaderOffset:]) - self.Name =3D uuid.UUID(bytes_le=3Dstruct2stream(self.ExtHead= er.FvName)) + self.ExtHeader =3D EFI_FIRMWARE_VOLUME_EXT_HEADER.from_buffer_= copy( + buffer[self.Header.ExtHeaderOffset:]) + self.Name =3D uuid.UUID( + bytes_le=3Dstruct2stream(self.ExtHeader.FvName)) self.ExtEntryOffset =3D self.Header.ExtHeaderOffset + 20 if self.ExtHeader.ExtHeaderSize !=3D 20: self.ExtEntryExist =3D 1 - self.ExtEntry =3D EFI_FIRMWARE_VOLUME_EXT_ENTRY.from_buffe= r_copy(buffer[self.ExtEntryOffset:]) + self.ExtEntry =3D EFI_FIRMWARE_VOLUME_EXT_ENTRY.from_buffe= r_copy( + buffer[self.ExtEntryOffset:]) self.ExtTypeExist =3D 1 if self.ExtEntry.ExtEntryType =3D=3D 0x01: nums =3D (self.ExtEntry.ExtEntrySize - 8) // 16 - self.ExtEntry =3D Refine_FV_EXT_ENTRY_OEM_TYPE_Header(= nums).from_buffer_copy(buffer[self.ExtEntryOffset:]) + self.ExtEntry =3D Refine_FV_EXT_ENTRY_OEM_TYPE_Header( + nums).from_buffer_copy(buffer[self.ExtEntryOffset:= ]) elif self.ExtEntry.ExtEntryType =3D=3D 0x02: nums =3D self.ExtEntry.ExtEntrySize - 20 - self.ExtEntry =3D Refine_FV_EXT_ENTRY_GUID_TYPE_Header= (nums).from_buffer_copy(buffer[self.ExtEntryOffset:]) + self.ExtEntry =3D Refine_FV_EXT_ENTRY_GUID_TYPE_Header( + nums).from_buffer_copy(buffer[self.ExtEntryOffset:= ]) elif self.ExtEntry.ExtEntryType =3D=3D 0x03: - self.ExtEntry =3D EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_S= IZE_TYPE.from_buffer_copy(buffer[self.ExtEntryOffset:]) + self.ExtEntry =3D EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_S= IZE_TYPE.from_buffer_copy( + buffer[self.ExtEntryOffset:]) else: self.ExtTypeExist =3D 0 else: @@ -71,7 +79,8 @@ class FvNode: self.ROffset =3D 0 self.Data =3D b'' if self.Header.Signature !=3D 1213613663: - logger.error('Invalid Fv Header! Fv {} signature {} is not "_F= VH".'.format(struct2stream(self.Header), self.Header.Signature)) + logger.error('Invalid Fv Header! Fv {} signature {} is not "_F= VH".'.format( + struct2stream(self.Header), self.Header.Signature)) raise Exception("Process Failed: Fv Header Signature!") self.PadData =3D b'' self.Free_Space =3D 0 @@ -85,7 +94,8 @@ class FvNode: for i in range(Size): Sum +=3D int(Header[i*2: i*2 + 2].hex(), 16) if Sum & 0xffff: - self.Header.Checksum =3D 0x10000 - (Sum - self.Header.Checksum= ) % 0x10000 + self.Header.Checksum =3D 0x10000 - \ + (Sum - self.Header.Checksum) % 0x10000 =20 def ModFvExt(self) -> None: # If used space changes and self.ExtEntry.UsedSize exists, self.Ex= tEntry.UsedSize need to be changed. @@ -103,18 +113,22 @@ class FvNode: if self.Header.ExtHeaderOffset: ExtHeaderData =3D struct2stream(self.ExtHeader) ExtHeaderDataOffset =3D self.Header.ExtHeaderOffset - self.Hea= derLength - self.Data =3D self.Data[:ExtHeaderDataOffset] + ExtHeaderData = + self.Data[ExtHeaderDataOffset+20:] + self.Data =3D self.Data[:ExtHeaderDataOffset] + \ + ExtHeaderData + self.Data[ExtHeaderDataOffset+20:] if self.Header.ExtHeaderOffset and self.ExtEntryExist: ExtHeaderEntryData =3D struct2stream(self.ExtEntry) ExtHeaderEntryDataOffset =3D self.Header.ExtHeaderOffset + 20 = - self.HeaderLength - self.Data =3D self.Data[:ExtHeaderEntryDataOffset] + ExtHeader= EntryData + self.Data[ExtHeaderEntryDataOffset+len(ExtHeaderEntryData):] + self.Data =3D self.Data[:ExtHeaderEntryDataOffset] + ExtHeader= EntryData + \ + self.Data[ExtHeaderEntryDataOffset+len(ExtHeaderEntryData)= :] + =20 class FfsNode: def __init__(self, buffer: bytes) -> None: self.Header =3D EFI_FFS_FILE_HEADER.from_buffer_copy(buffer) # self.Attributes =3D unpack(" None: if buffer[0:3] !=3D b'\xff\xff\xff': @@ -154,7 +169,8 @@ class SectionNode: else: self.Name =3D "SECTION" if self.Header.Type in HeaderType: - self.ExtHeader =3D self.GetExtHeader(self.Header.Type, buffer[= self.Header.Common_Header_Size():], (self.Header.SECTION_SIZE-self.Header.C= ommon_Header_Size())) + self.ExtHeader =3D self.GetExtHeader(self.Header.Type, buffer[= self.Header.Common_Header_Size( + ):], (self.Header.SECTION_SIZE-self.Header.Common_Header_Size(= ))) self.HeaderLength =3D self.Header.Common_Header_Size() + self.= ExtHeader.ExtHeaderSize() else: self.ExtHeader =3D None @@ -171,7 +187,7 @@ class SectionNode: self.IsPadSection =3D False self.SectionMaxAlignment =3D SECTION_COMMON_ALIGNMENT # 4-align =20 - def GetExtHeader(self, Type: int, buffer: bytes, nums: int=3D0) -> Non= e: + def GetExtHeader(self, Type: int, buffer: bytes, nums: int =3D 0) -> N= one: if Type =3D=3D 0x01: return EFI_COMPRESSION_SECTION.from_buffer_copy(buffer) elif Type =3D=3D 0x02: @@ -183,6 +199,7 @@ class SectionNode: elif Type =3D=3D 0x18: return EFI_FREEFORM_SUBTYPE_GUID_SECTION.from_buffer_copy(buff= er) =20 + class FreeSpaceNode: def __init__(self, buffer: bytes) -> None: self.Name =3D 'Free_Space' @@ -191,4 +208,4 @@ class FreeSpaceNode: self.HOffset =3D 0 self.DOffset =3D 0 self.ROffset =3D 0 - self.PadData =3D b'' \ No newline at end of file + self.PadData =3D b'' diff --git a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py b/BaseTools= /Source/Python/FMMT/core/FMMTOperation.py index c2cc2e246740..19fb9177e6bf 100644 --- a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py +++ b/BaseTools/Source/Python/FMMT/core/FMMTOperation.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the functions to operate bios binary file. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -13,7 +13,9 @@ global Fv_count Fv_count =3D 0 =20 # The ROOT_TYPE can be 'ROOT_TREE', 'ROOT_FV_TREE', 'ROOT_FFS_TREE', 'ROOT= _SECTION_TREE' -def ViewFile(inputfile: str, ROOT_TYPE: str, layoutfile: str=3DNone, outpu= tfile: str=3DNone) -> None: + + +def ViewFile(inputfile: str, ROOT_TYPE: str, layoutfile: str =3D None, out= putfile: str =3D None) -> None: if not os.path.exists(inputfile): logger.error("Invalid inputfile, can not open {}.".format(inputfil= e)) raise Exception("Process Failed: Invalid inputfile!") @@ -36,9 +38,11 @@ def ViewFile(inputfile: str, ROOT_TYPE: str, layoutfile:= str=3DNone, outputfile: s layoutfilename =3D layoutfile layoutfileformat =3D os.path.splitext(layoutfile)[1][1:].lower= () else: - layoutfilename =3D "Layout_{}{}".format(os.path.basename(input= file),".{}".format(layoutfile.lower())) + layoutfilename =3D "Layout_{}{}".format(os.path.basename( + inputfile), ".{}".format(layoutfile.lower())) layoutfileformat =3D layoutfile.lower() - GetFormatter(layoutfileformat).dump(InfoDict, FmmtParser.BinaryInf= o, layoutfilename) + GetFormatter(layoutfileformat).dump( + InfoDict, FmmtParser.BinaryInfo, layoutfilename) # 4. Data Encapsulation if outputfile: logger.debug('Start encapsulating data......') @@ -47,7 +51,8 @@ def ViewFile(inputfile: str, ROOT_TYPE: str, layoutfile: = str=3DNone, outputfile: s f.write(FmmtParser.FinalData) logger.debug('Encapsulated data is saved in {}.'.format(outputfile= )) =20 -def DeleteFfs(inputfile: str, TargetFfs_name: str, outputfile: str, Fv_nam= e: str=3DNone) -> None: + +def DeleteFfs(inputfile: str, TargetFfs_name: str, outputfile: str, Fv_nam= e: str =3D None) -> None: if not os.path.exists(inputfile): logger.error("Invalid inputfile, can not open {}.".format(inputfil= e)) raise Exception("Process Failed: Invalid inputfile!") @@ -60,7 +65,8 @@ def DeleteFfs(inputfile: str, TargetFfs_name: str, output= file: str, Fv_name: str FmmtParser.ParserFromRoot(FmmtParser.WholeFvTree, whole_data) logger.debug('Done!') # 3. Data Modify - FmmtParser.WholeFvTree.FindNode(TargetFfs_name, FmmtParser.WholeFvTree= .Findlist) + FmmtParser.WholeFvTree.FindNode( + TargetFfs_name, FmmtParser.WholeFvTree.Findlist) # Choose the Specfic DeleteFfs with Fv info if Fv_name: for item in FmmtParser.WholeFvTree.Findlist: @@ -81,6 +87,7 @@ def DeleteFfs(inputfile: str, TargetFfs_name: str, output= file: str, Fv_name: str f.write(FmmtParser.FinalData) logger.debug('Encapsulated data is saved in {}.'.format(outputfile= )) =20 + def AddNewFfs(inputfile: str, Fv_name: str, newffsfile: str, outputfile: s= tr) -> None: if not os.path.exists(inputfile): logger.error("Invalid inputfile, can not open {}.".format(inputfil= e)) @@ -109,11 +116,14 @@ def AddNewFfs(inputfile: str, Fv_name: str, newffsfil= e: str, outputfile: str) -> TargetFfsPad =3D TargetFv.Child[-1] logger.debug('Parsing newffsfile data......') if TargetFfsPad.type =3D=3D FFS_FREE_SPACE: - NewFmmtParser.ParserFromRoot(NewFmmtParser.WholeFvTree, ne= w_ffs_data, TargetFfsPad.Data.HOffset) + NewFmmtParser.ParserFromRoot( + NewFmmtParser.WholeFvTree, new_ffs_data, TargetFfsPad.= Data.HOffset) else: - NewFmmtParser.ParserFromRoot(NewFmmtParser.WholeFvTree, ne= w_ffs_data, TargetFfsPad.Data.HOffset+TargetFfsPad.Data.Size) + NewFmmtParser.ParserFromRoot( + NewFmmtParser.WholeFvTree, new_ffs_data, TargetFfsPad.= Data.HOffset+TargetFfsPad.Data.Size) logger.debug('Done!') - FfsMod =3D FvHandler(NewFmmtParser.WholeFvTree.Child[0], Targe= tFfsPad) + FfsMod =3D FvHandler( + NewFmmtParser.WholeFvTree.Child[0], TargetFfsPad) Status =3D FfsMod.AddFfs() else: logger.error('Target Fv not found!!!') @@ -125,7 +135,8 @@ def AddNewFfs(inputfile: str, Fv_name: str, newffsfile:= str, outputfile: str) -> f.write(FmmtParser.FinalData) logger.debug('Encapsulated data is saved in {}.'.format(outputfile= )) =20 -def ReplaceFfs(inputfile: str, Ffs_name: str, newffsfile: str, outputfile:= str, Fv_name: str=3DNone) -> None: + +def ReplaceFfs(inputfile: str, Ffs_name: str, newffsfile: str, outputfile:= str, Fv_name: str =3D None) -> None: if not os.path.exists(inputfile): logger.error("Invalid inputfile, can not open {}.".format(inputfil= e)) raise Exception("Process Failed: Invalid inputfile!") @@ -146,7 +157,8 @@ def ReplaceFfs(inputfile: str, Ffs_name: str, newffsfil= e: str, outputfile: str, Status =3D False # 3. Data Modify new_ffs =3D newFmmtParser.WholeFvTree.Child[0] - new_ffs.Data.PadData =3D GetPadSize(new_ffs.Data.Size, FFS_COMMON_ALIG= NMENT) * b'\xff' + new_ffs.Data.PadData =3D GetPadSize( + new_ffs.Data.Size, FFS_COMMON_ALIGNMENT) * b'\xff' FmmtParser.WholeFvTree.FindNode(Ffs_name, FmmtParser.WholeFvTree.Findl= ist) if Fv_name: for item in FmmtParser.WholeFvTree.Findlist: @@ -166,7 +178,8 @@ def ReplaceFfs(inputfile: str, Ffs_name: str, newffsfil= e: str, outputfile: str, f.write(FmmtParser.FinalData) logger.debug('Encapsulated data is saved in {}.'.format(outputfile= )) =20 -def ExtractFfs(inputfile: str, Ffs_name: str, outputfile: str, Fv_name: st= r=3DNone) -> None: + +def ExtractFfs(inputfile: str, Ffs_name: str, outputfile: str, Fv_name: st= r =3D None) -> None: if not os.path.exists(inputfile): logger.error("Invalid inputfile, can not open {}.".format(inputfil= e)) raise Exception("Process Failed: Invalid inputfile!") @@ -189,7 +202,8 @@ def ExtractFfs(inputfile: str, Ffs_name: str, outputfil= e: str, Fv_name: str=3DNone if TargetFv.Data.Header.Attributes & EFI_FVB2_ERASE_POLARITY: TargetNode.Data.Header.State =3D c_uint8( ~TargetNode.Data.Header.State) - FinalData =3D struct2stream(TargetNode.Data.Header) + TargetNode.D= ata.Data + FinalData =3D struct2stream( + TargetNode.Data.Header) + TargetNode.Data.Data with open(outputfile, "wb") as f: f.write(FinalData) logger.debug('Extract ffs data is saved in {}.'.format(outputfile)) diff --git a/BaseTools/Source/Python/FMMT/core/FMMTParser.py b/BaseTools/So= urce/Python/FMMT/core/FMMTParser.py index e76ac5118509..cd275801ba0c 100644 --- a/BaseTools/Source/Python/FMMT/core/FMMTParser.py +++ b/BaseTools/Source/Python/FMMT/core/FMMTParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the interface of Bios Parser. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -11,6 +11,7 @@ from core.BiosTree import * from core.GuidTools import * from utils.FmmtLogger import FmmtLogger as logger =20 + class FMMTParser: def __init__(self, name: str, TYPE: str) -> None: self.WholeFvTree =3D BIOSTREE(name) @@ -18,8 +19,8 @@ class FMMTParser: self.FinalData =3D b'' self.BinaryInfo =3D [] =20 - ## Parser the nodes in WholeTree. - def ParserFromRoot(self, WholeFvTree=3DNone, whole_data: bytes=3Db'', = Reloffset: int=3D0) -> None: + # Parser the nodes in WholeTree. + def ParserFromRoot(self, WholeFvTree=3DNone, whole_data: bytes =3D b''= , Reloffset: int =3D 0) -> None: if WholeFvTree.type =3D=3D ROOT_TREE or WholeFvTree.type =3D=3D RO= OT_FV_TREE: ParserEntry().DataParser(self.WholeFvTree, whole_data, Reloffs= et) else: @@ -27,7 +28,7 @@ class FMMTParser: for Child in WholeFvTree.Child: self.ParserFromRoot(Child, "") =20 - ## Encapuslation all the data in tree into self.FinalData + # Encapuslation all the data in tree into self.FinalData def Encapsulation(self, rootTree, CompressStatus: bool) -> None: # If current node is Root node, skip it. if rootTree.type =3D=3D ROOT_TREE or rootTree.type =3D=3D ROOT_FV_= TREE or rootTree.type =3D=3D ROOT_FFS_TREE or rootTree.type =3D=3D ROOT_SEC= TION_TREE: @@ -38,7 +39,8 @@ class FMMTParser: rootTree.Child =3D [] # If current node do not have Child and ExtHeader, just add its He= ader and Data. elif rootTree.type =3D=3D DATA_FV_TREE or rootTree.type =3D=3D FFS= _PAD: - self.FinalData +=3D struct2stream(rootTree.Data.Header) + root= Tree.Data.Data + rootTree.Data.PadData + self.FinalData +=3D struct2stream(rootTree.Data.Header) + \ + rootTree.Data.Data + rootTree.Data.PadData if rootTree.isFinalChild(): ParTree =3D rootTree.Parent if ParTree.type !=3D 'ROOT': @@ -49,7 +51,8 @@ class FMMTParser: if rootTree.HasChild(): self.FinalData +=3D struct2stream(rootTree.Data.Header) else: - self.FinalData +=3D struct2stream(rootTree.Data.Header) + = rootTree.Data.Data + rootTree.Data.PadData + self.FinalData +=3D struct2stream(rootTree.Data.Header) + \ + rootTree.Data.Data + rootTree.Data.PadData if rootTree.isFinalChild(): ParTree =3D rootTree.Parent if ParTree.type !=3D 'ROOT': @@ -60,15 +63,18 @@ class FMMTParser: if rootTree.Data.OriData =3D=3D b'' or (rootTree.Data.OriData = !=3D b'' and CompressStatus): if rootTree.HasChild(): if rootTree.Data.ExtHeader: - self.FinalData +=3D struct2stream(rootTree.Data.He= ader) + struct2stream(rootTree.Data.ExtHeader) + self.FinalData +=3D struct2stream( + rootTree.Data.Header) + struct2stream(rootTree= .Data.ExtHeader) else: self.FinalData +=3D struct2stream(rootTree.Data.He= ader) else: Data =3D rootTree.Data.Data if rootTree.Data.ExtHeader: - self.FinalData +=3D struct2stream(rootTree.Data.He= ader) + struct2stream(rootTree.Data.ExtHeader) + Data + rootTree.Data.PadDa= ta + self.FinalData +=3D struct2stream(rootTree.Data.He= ader) + struct2stream( + rootTree.Data.ExtHeader) + Data + rootTree.Dat= a.PadData else: - self.FinalData +=3D struct2stream(rootTree.Data.He= ader) + Data + rootTree.Data.PadData + self.FinalData +=3D struct2stream( + rootTree.Data.Header) + Data + rootTree.Data.P= adData if rootTree.isFinalChild(): ParTree =3D rootTree.Parent self.FinalData +=3D ParTree.Data.PadData @@ -77,9 +83,11 @@ class FMMTParser: Data =3D rootTree.Data.OriData rootTree.Child =3D [] if rootTree.Data.ExtHeader: - self.FinalData +=3D struct2stream(rootTree.Data.Header= ) + struct2stream(rootTree.Data.ExtHeader) + Data + rootTree.Data.PadData + self.FinalData +=3D struct2stream(rootTree.Data.Header= ) + struct2stream( + rootTree.Data.ExtHeader) + Data + rootTree.Data.Pa= dData else: - self.FinalData +=3D struct2stream(rootTree.Data.Header= ) + Data + rootTree.Data.PadData + self.FinalData +=3D struct2stream( + rootTree.Data.Header) + Data + rootTree.Data.PadDa= ta if rootTree.isFinalChild(): ParTree =3D rootTree.Parent self.FinalData +=3D ParTree.Data.PadData diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Sou= rce/Python/FMMT/core/FvHandler.py index c81541ec18b1..1a59767afd2f 100644 --- a/BaseTools/Source/Python/FMMT/core/FvHandler.py +++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to the implementation of Bios layout handler. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -13,7 +13,8 @@ from utils.FmmtLogger import FmmtLogger as logger =20 EFI_FVB2_ERASE_POLARITY =3D 0x00000800 =20 -def ChangeSize(TargetTree, size_delta: int=3D0) -> None: + +def ChangeSize(TargetTree, size_delta: int =3D 0) -> None: # If Size increase delta, then should be: size_delta =3D -delta if type(TargetTree.Data.Header) =3D=3D type(EFI_FFS_FILE_HEADER2()) or= type(TargetTree.Data.Header) =3D=3D type(EFI_COMMON_SECTION_HEADER2()): TargetTree.Data.Size -=3D size_delta @@ -22,14 +23,16 @@ def ChangeSize(TargetTree, size_delta: int=3D0) -> None: OriSize =3D TargetTree.Data.Header.SECTION_SIZE OriSize -=3D size_delta TargetTree.Data.Header.Size[0] =3D OriSize % (16**2) - TargetTree.Data.Header.Size[1] =3D OriSize % (16**4) //(16**2) + TargetTree.Data.Header.Size[1] =3D OriSize % (16**4) // (16**2) TargetTree.Data.Header.Size[2] =3D OriSize // (16**4) else: TargetTree.Data.Size -=3D size_delta TargetTree.Data.Header.Size[0] =3D TargetTree.Data.Size % (16**2) - TargetTree.Data.Header.Size[1] =3D TargetTree.Data.Size % (16**4) = //(16**2) + TargetTree.Data.Header.Size[1] =3D TargetTree.Data.Size % ( + 16**4) // (16**2) TargetTree.Data.Header.Size[2] =3D TargetTree.Data.Size // (16**4) =20 + def ModifyFfsType(TargetFfs) -> None: if type(TargetFfs.Data.Header) =3D=3D type(EFI_FFS_FILE_HEADER()) and = TargetFfs.Data.Size > 0xFFFFFF: ExtendSize =3D TargetFfs.Data.Header.FFS_FILE_SIZE + 8 @@ -37,10 +40,12 @@ def ModifyFfsType(TargetFfs) -> None: New_Header.Name =3D TargetFfs.Data.Header.Name New_Header.IntegrityCheck =3D TargetFfs.Data.Header.IntegrityCheck New_Header.Type =3D TargetFfs.Data.Header.Type - New_Header.Attributes =3D TargetFfs.Data.Header.Attributes | 0x01 = # set the Attribute with FFS_ATTRIB_LARGE_FILE (0x01) + # set the Attribute with FFS_ATTRIB_LARGE_FILE (0x01) + New_Header.Attributes =3D TargetFfs.Data.Header.Attributes | 0x01 NewSize =3D 0 - New_Header.Size[0] =3D NewSize % (16**2) # minus the delta size= of Header - New_Header.Size[1] =3D NewSize % (16**4) //(16**2) + # minus the delta size of Header + New_Header.Size[0] =3D NewSize % (16**2) + New_Header.Size[1] =3D NewSize % (16**4) // (16**2) New_Header.Size[2] =3D NewSize // (16**4) New_Header.State =3D TargetFfs.Data.Header.State New_Header.ExtendedSize =3D ExtendSize @@ -53,9 +58,11 @@ def ModifyFfsType(TargetFfs) -> None: New_Header.Name =3D TargetFfs.Data.Header.Name New_Header.IntegrityCheck =3D TargetFfs.Data.Header.IntegrityCheck New_Header.Type =3D TargetFfs.Data.Header.Type - New_Header.Attributes =3D TargetFfs.Data.Header.Attributes - 1 # = remove the FFS_ATTRIB_LARGE_FILE (0x01) from Attribute - New_Header.Size[0] =3D (TargetFfs.Data.Size - 8) % (16**2) # mi= nus the delta size of Header - New_Header.Size[1] =3D (TargetFfs.Data.Size - 8) % (16**4) //(16**= 2) + # remove the FFS_ATTRIB_LARGE_FILE (0x01) from Attribute + New_Header.Attributes =3D TargetFfs.Data.Header.Attributes - 1 + # minus the delta size of Header + New_Header.Size[0] =3D (TargetFfs.Data.Size - 8) % (16**2) + New_Header.Size[1] =3D (TargetFfs.Data.Size - 8) % (16**4) // (16*= *2) New_Header.Size[2] =3D (TargetFfs.Data.Size - 8) // (16**4) New_Header.State =3D TargetFfs.Data.Header.State TargetFfs.Data.Header =3D New_Header @@ -68,19 +75,24 @@ def ModifyFfsType(TargetFfs) -> None: if type(item.Data.Header) =3D=3D type(EFI_FFS_FILE_HEADER2= ()): NeedChange =3D False if NeedChange: - TargetFfs.Parent.Data.Header.FileSystemGuid =3D ModifyGuid= Format("8c8ce578-8a3d-4f1c-9935-896185c32dd3") + TargetFfs.Parent.Data.Header.FileSystemGuid =3D ModifyGuid= Format( + "8c8ce578-8a3d-4f1c-9935-896185c32dd3") =20 if type(TargetFfs.Data.Header) =3D=3D type(EFI_FFS_FILE_HEADER2()): TarParent =3D TargetFfs.Parent while TarParent: if TarParent.type =3D=3D FV_TREE and struct2stream(TarParent.D= ata.Header.FileSystemGuid) =3D=3D EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE: - TarParent.Data.Header.FileSystemGuid =3D ModifyGuidFormat(= "5473C07A-3DCB-4dca-BD6F-1E9689E7349A") + TarParent.Data.Header.FileSystemGuid =3D ModifyGuidFormat( + "5473C07A-3DCB-4dca-BD6F-1E9689E7349A") TarParent =3D TarParent.Parent =20 + def PadSectionModify(PadSection, Offset) -> None: # Offset > 0, Size decrease; Offset < 0, Size increase; ChangeSize(PadSection, Offset) - PadSection.Data.Data =3D (PadSection.Data.Size - PadSection.Data.Heade= rLength) * b'\xff' + PadSection.Data.Data =3D (PadSection.Data.Size - + PadSection.Data.HeaderLength) * b'\xff' + =20 def ModifySectionType(TargetSection) -> None: # If Section Size is increased larger than 0xFFFFFF, need modify Secti= on Header from EFI_COMMON_SECTION_HEADER to EFI_COMMON_SECTION_HEADER2. @@ -88,8 +100,9 @@ def ModifySectionType(TargetSection) -> None: New_Header =3D EFI_COMMON_SECTION_HEADER2() New_Header.Type =3D TargetSection.Data.Header.Type NewSize =3D 0xFFFFFF - New_Header.Size[0] =3D NewSize % (16**2) # minus the delta size= of Header - New_Header.Size[1] =3D NewSize % (16**4) //(16**2) + # minus the delta size of Header + New_Header.Size[0] =3D NewSize % (16**2) + New_Header.Size[1] =3D NewSize % (16**4) // (16**2) New_Header.Size[2] =3D NewSize // (16**4) New_Header.ExtendedSize =3D TargetSection.Data.Size + 4 TargetSection.Data.Header =3D New_Header @@ -106,8 +119,9 @@ def ModifySectionType(TargetSection) -> None: elif type(TargetSection.Data.Header) =3D=3D type(EFI_COMMON_SECTION_HE= ADER2()) and TargetSection.Data.Size < 0xFFFFFF: New_Header =3D EFI_COMMON_SECTION_HEADER() New_Header.Type =3D TargetSection.Data.Header.Type - New_Header.Size[0] =3D (TargetSection.Data.Size - 4) % (16**2) = # minus the delta size of Header - New_Header.Size[1] =3D (TargetSection.Data.Size - 4) % (16**4) //(= 16**2) + # minus the delta size of Header + New_Header.Size[0] =3D (TargetSection.Data.Size - 4) % (16**2) + New_Header.Size[1] =3D (TargetSection.Data.Size - 4) % (16**4) // = (16**2) New_Header.Size[2] =3D (TargetSection.Data.Size - 4) // (16**4) TargetSection.Data.Header =3D New_Header TargetSection.Data.Size =3D TargetSection.Data.Header.SECTION_SIZE @@ -120,6 +134,7 @@ def ModifySectionType(TargetSection) -> None: NewPadSection =3D SectionNode(b'\x00\x00\x00\x19') SecParent.insertChild(NewPadSection, Target_index) =20 + def ModifyFvExtData(TreeNode) -> None: FvExtData =3D b'' if TreeNode.Data.Header.ExtHeaderOffset: @@ -130,19 +145,24 @@ def ModifyFvExtData(TreeNode) -> None: FvExtData +=3D FvExtEntry if FvExtData: InfoNode =3D TreeNode.Child[0] - InfoNode.Data.Data =3D FvExtData + InfoNode.Data.Data[TreeNode.Dat= a.ExtHeader.ExtHeaderSize:] + InfoNode.Data.Data =3D FvExtData + \ + InfoNode.Data.Data[TreeNode.Data.ExtHeader.ExtHeaderSize:] InfoNode.Data.ModCheckSum() =20 + def ModifyFvSystemGuid(TargetFv) -> None: if struct2stream(TargetFv.Data.Header.FileSystemGuid) =3D=3D EFI_FIRMW= ARE_FILE_SYSTEM2_GUID_BYTE: - TargetFv.Data.Header.FileSystemGuid =3D ModifyGuidFormat("5473C07A= -3DCB-4dca-BD6F-1E9689E7349A") + TargetFv.Data.Header.FileSystemGuid =3D ModifyGuidFormat( + "5473C07A-3DCB-4dca-BD6F-1E9689E7349A") TargetFv.Data.ModCheckSum() TargetFv.Data.Data =3D b'' for item in TargetFv.Child: if item.type =3D=3D FFS_FREE_SPACE: TargetFv.Data.Data +=3D item.Data.Data + item.Data.PadData else: - TargetFv.Data.Data +=3D struct2stream(item.Data.Header)+ item.= Data.Data + item.Data.PadData + TargetFv.Data.Data +=3D struct2stream(item.Data.Header) + \ + item.Data.Data + item.Data.PadData + =20 class FvHandler: def __init__(self, NewFfs, TargetFfs) -> None: @@ -151,7 +171,7 @@ class FvHandler: self.Status =3D False self.Remain_New_Free_Space =3D 0 =20 - ## Use for Compress the Section Data + # Use for Compress the Section Data def CompressData(self, TargetTree) -> None: TreePath =3D TargetTree.GetTreePath() pos =3D len(TreePath) @@ -159,7 +179,8 @@ class FvHandler: while pos: if not self.Status: if TreePath[pos-1].type =3D=3D SECTION_TREE and TreePath[p= os-1].Data.Type =3D=3D 0x02: - self.CompressSectionData(TreePath[pos-1], None, TreePa= th[pos-1].Data.ExtHeader.SectionDefinitionGuid) + self.CompressSectionData( + TreePath[pos-1], None, TreePath[pos-1].Data.ExtHea= der.SectionDefinitionGuid) else: if pos =3D=3D len(TreePath): self.CompressSectionData(TreePath[pos-1], pos) @@ -174,15 +195,19 @@ class FvHandler: # Update current node data as adding all the header and data o= f its child node. for item in temp_save_child: if item.type =3D=3D SECTION_TREE and not item.Data.OriData= and item.Data.ExtHeader: - NewData +=3D struct2stream(item.Data.Header) + struct2= stream(item.Data.ExtHeader) + item.Data.Data + item.Data.PadData + NewData +=3D struct2stream(item.Data.Header) + struct2= stream( + item.Data.ExtHeader) + item.Data.Data + item.Data.= PadData elif item.type =3D=3D SECTION_TREE and item.Data.OriData a= nd not item.Data.ExtHeader: - NewData +=3D struct2stream(item.Data.Header) + item.Da= ta.OriData + item.Data.PadData + NewData +=3D struct2stream(item.Data.Header) + \ + item.Data.OriData + item.Data.PadData elif item.type =3D=3D SECTION_TREE and item.Data.OriData a= nd item.Data.ExtHeader: - NewData +=3D struct2stream(item.Data.Header) + struct2= stream(item.Data.ExtHeader) + item.Data.OriData + item.Data.PadData + NewData +=3D struct2stream(item.Data.Header) + struct2= stream( + item.Data.ExtHeader) + item.Data.OriData + item.Da= ta.PadData elif item.type =3D=3D FFS_FREE_SPACE: NewData +=3D item.Data.Data + item.Data.PadData else: - NewData +=3D struct2stream(item.Data.Header) + item.Da= ta.Data + item.Data.PadData + NewData +=3D struct2stream(item.Data.Header) + \ + item.Data.Data + item.Data.PadData # If node is FFS_TREE, update Pad data and Header info. # Remain_New_Free_Space is used for move more free space into = lst level Fv. if TargetTree.type =3D=3D FFS_TREE: @@ -205,11 +230,13 @@ class FvHandler: TargetTree.Data.Data +=3D self.Remain_New_Free_Spa= ce * b'\xff' New_Free_Space =3D BIOSTREE('FREE_SPACE') New_Free_Space.type =3D FFS_FREE_SPACE - New_Free_Space.Data =3D FreeSpaceNode(b'\xff' * se= lf.Remain_New_Free_Space) + New_Free_Space.Data =3D FreeSpaceNode( + b'\xff' * self.Remain_New_Free_Space) TargetTree.insertChild(New_Free_Space) self.Remain_New_Free_Space =3D 0 if TargetTree.type =3D=3D SEC_FV_TREE: - Size_delta =3D len(NewData) + self.Remain_New_Free_Spa= ce - len(TargetTree.Data.Data) + Size_delta =3D len( + NewData) + self.Remain_New_Free_Space - len(Target= Tree.Data.Data) TargetTree.Data.Header.FvLength +=3D Size_delta TargetTree.Data.ModFvExt() TargetTree.Data.ModFvSize() @@ -223,32 +250,39 @@ class FvHandler: Size_delta =3D len(NewData) - len(TargetTree.Data.Data) ChangeSize(TargetTree, -Size_delta) if TargetTree.NextRel: - Delta_Pad_Size =3D len(TargetTree.Data.PadData) - New_= Pad_Size + Delta_Pad_Size =3D len( + TargetTree.Data.PadData) - New_Pad_Size self.Remain_New_Free_Space +=3D Delta_Pad_Size TargetTree.Data.PadData =3D b'\x00' * New_Pad_Size TargetTree.Data.Data =3D NewData if GuidTool: guidtool =3D GUIDTools().__getitem__(struct2stream(GuidTool)) if not guidtool.ifexist: - logger.error("GuidTool {} is not found when decompressing = {} file.\n".format(guidtool.command, TargetTree.Parent.Data.Name)) + logger.error("GuidTool {} is not found when decompressing = {} file.\n".format( + guidtool.command, TargetTree.Parent.Data.Name)) raise Exception("Process Failed: GuidTool not found!") CompressedData =3D guidtool.pack(TargetTree.Data.Data) if len(CompressedData) < len(TargetTree.Data.OriData): - New_Pad_Size =3D GetPadSize(len(CompressedData), SECTION_C= OMMON_ALIGNMENT) + New_Pad_Size =3D GetPadSize( + len(CompressedData), SECTION_COMMON_ALIGNMENT) Size_delta =3D len(CompressedData) - len(TargetTree.Data.O= riData) ChangeSize(TargetTree, -Size_delta) if TargetTree.NextRel: TargetTree.Data.PadData =3D b'\x00' * New_Pad_Size - self.Remain_New_Free_Space =3D len(TargetTree.Data.Ori= Data) + len(TargetTree.Data.PadData) - len(CompressedData) - New_Pad_Size + self.Remain_New_Free_Space =3D len(TargetTree.Data.Ori= Data) + len( + TargetTree.Data.PadData) - len(CompressedData) - N= ew_Pad_Size else: TargetTree.Data.PadData =3D b'' - self.Remain_New_Free_Space =3D len(TargetTree.Data.Ori= Data) - len(CompressedData) + self.Remain_New_Free_Space =3D len( + TargetTree.Data.OriData) - len(CompressedData) TargetTree.Data.OriData =3D CompressedData elif len(CompressedData) =3D=3D len(TargetTree.Data.OriData): TargetTree.Data.OriData =3D CompressedData elif len(CompressedData) > len(TargetTree.Data.OriData): - New_Pad_Size =3D GetPadSize(len(CompressedData), SECTION_C= OMMON_ALIGNMENT) - self.Remain_New_Free_Space =3D len(CompressedData) + New_P= ad_Size - len(TargetTree.Data.OriData) - len(TargetTree.Data.PadData) + New_Pad_Size =3D GetPadSize( + len(CompressedData), SECTION_COMMON_ALIGNMENT) + self.Remain_New_Free_Space =3D len(CompressedData) + New_P= ad_Size - len( + TargetTree.Data.OriData) - len(TargetTree.Data.PadData) self.ModifyTest(TargetTree, self.Remain_New_Free_Space) self.Status =3D True =20 @@ -271,7 +305,7 @@ class FvHandler: self.Status =3D False else: BlockSize =3D ParTree.Data.Header.BlockMap[0].Leng= th - New_Add_Len =3D BlockSize - Needed_Space%BlockSize + New_Add_Len =3D BlockSize - Needed_Space % BlockSi= ze if New_Add_Len % BlockSize: ParTree.Child[-1].Data.Data =3D b'\xff' * New_= Add_Len ParTree.Data.Free_Space =3D New_Add_Len @@ -286,7 +320,8 @@ class FvHandler: if item.type =3D=3D FFS_FREE_SPACE: ParTree.Data.Data +=3D item.Data.Data + item.Data.= PadData else: - ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der)+ item.Data.Data + item.Data.PadData + ParTree.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.Data= .PadData ParTree.Data.ModFvExt() ParTree.Data.ModFvSize() ParTree.Data.ModExtHeaderData() @@ -300,22 +335,28 @@ class FvHandler: for item in ParTree.Child: if item.Data.OriData: if item.Data.ExtHeader: - ParTree.Data.Data +=3D struct2stream(item.Data= .Header) + struct2stream(item.Data.ExtHeader) + item.Data.OriData + item.Da= ta.PadData + ParTree.Data.Data +=3D struct2stream(item.Data= .Header) + struct2stream( + item.Data.ExtHeader) + item.Data.OriData += item.Data.PadData else: - ParTree.Data.Data +=3D struct2stream(item.Data= .Header)+ item.Data.OriData + item.Data.PadData + ParTree.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.OriData + it= em.Data.PadData else: if item.Data.ExtHeader: - ParTree.Data.Data +=3D struct2stream(item.Data= .Header) + struct2stream(item.Data.ExtHeader) + item.Data.Data + item.Data.= PadData + ParTree.Data.Data +=3D struct2stream(item.Data= .Header) + struct2stream( + item.Data.ExtHeader) + item.Data.Data + it= em.Data.PadData else: - ParTree.Data.Data +=3D struct2stream(item.Data= .Header)+ item.Data.Data + item.Data.PadData + ParTree.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.= Data.PadData ChangeSize(ParTree, -Needed_Space) ModifyFfsType(ParTree) # Recalculate pad data, update needed space with Delta_Pad= _Size. Needed_Space +=3D ParTree.Data.HeaderLength - OriHeaderLen - New_Pad_Size =3D GetPadSize(ParTree.Data.Size, FFS_COMMON_= ALIGNMENT) + New_Pad_Size =3D GetPadSize( + ParTree.Data.Size, FFS_COMMON_ALIGNMENT) Delta_Pad_Size =3D New_Pad_Size - len(ParTree.Data.PadData) Needed_Space +=3D Delta_Pad_Size - ParTree.Data.PadData =3D b'\xff' * GetPadSize(ParTree.Data= .Size, FFS_COMMON_ALIGNMENT) + ParTree.Data.PadData =3D b'\xff' * \ + GetPadSize(ParTree.Data.Size, FFS_COMMON_ALIGNMENT) ParTree.Data.ModCheckSum() # If current node is a Section node elif ParTree.type =3D=3D SECTION_TREE: @@ -325,50 +366,61 @@ class FvHandler: # Update its data as adding all the header and data of its= child node. for item in ParTree.Child: if item.type =3D=3D SECTION_TREE and item.Data.ExtHead= er and item.Data.Type !=3D 0x02: - ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der) + struct2stream(item.Data.ExtHeader) + item.Data.Data + item.Data.PadD= ata + ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der) + struct2stream( + item.Data.ExtHeader) + item.Data.Data + item.D= ata.PadData elif item.type =3D=3D SECTION_TREE and item.Data.ExtHe= ader and item.Data.Type =3D=3D 0x02: - ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der) + struct2stream(item.Data.ExtHeader) + item.Data.OriData + item.Data.P= adData + ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der) + struct2stream( + item.Data.ExtHeader) + item.Data.OriData + ite= m.Data.PadData else: - ParTree.Data.Data +=3D struct2stream(item.Data.Hea= der) + item.Data.Data + item.Data.PadData + ParTree.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.Data= .PadData # If the current section is guided section if ParTree.Data.Type =3D=3D 0x02: - guidtool =3D GUIDTools().__getitem__(struct2stream(Par= Tree.Data.ExtHeader.SectionDefinitionGuid)) + guidtool =3D GUIDTools().__getitem__(struct2stream( + ParTree.Data.ExtHeader.SectionDefinitionGuid)) if not guidtool.ifexist: - logger.error("GuidTool {} is not found when decomp= ressing {} file.\n".format(guidtool.command, ParTree.Parent.Data.Name)) + logger.error("GuidTool {} is not found when decomp= ressing {} file.\n".format( + guidtool.command, ParTree.Parent.Data.Name)) raise Exception("Process Failed: GuidTool not foun= d!") # Recompress current data, and recalculate the needed = space CompressedData =3D guidtool.pack(ParTree.Data.Data) - Needed_Space =3D len(CompressedData) - len(ParTree.Dat= a.OriData) + Needed_Space =3D len(CompressedData) - \ + len(ParTree.Data.OriData) ParTree.Data.OriData =3D CompressedData New_Size =3D ParTree.Data.HeaderLength + len(Compresse= dData) ParTree.Data.Header.Size[0] =3D New_Size % (16**2) - ParTree.Data.Header.Size[1] =3D New_Size % (16**4) //(= 16**2) + ParTree.Data.Header.Size[1] =3D New_Size % (16**4) // = (16**2) ParTree.Data.Header.Size[2] =3D New_Size // (16**4) ParTree.Data.Size =3D ParTree.Data.Header.SECTION_SIZE ModifySectionType(ParTree) Needed_Space +=3D ParTree.Data.HeaderLength - OriHeade= rLen # Update needed space with Delta_Pad_Size if ParTree.NextRel: - New_Pad_Size =3D GetPadSize(ParTree.Data.Size, SEC= TION_COMMON_ALIGNMENT) - Delta_Pad_Size =3D New_Pad_Size - len(ParTree.Data= .PadData) + New_Pad_Size =3D GetPadSize( + ParTree.Data.Size, SECTION_COMMON_ALIGNMENT) + Delta_Pad_Size =3D New_Pad_Size - \ + len(ParTree.Data.PadData) ParTree.Data.PadData =3D b'\x00' * New_Pad_Size Needed_Space +=3D Delta_Pad_Size else: ParTree.Data.PadData =3D b'' if Needed_Space < 0: - self.Remain_New_Free_Space =3D len(ParTree.Data.Or= iData) - len(CompressedData) + self.Remain_New_Free_Space =3D len( + ParTree.Data.OriData) - len(CompressedData) # If current section is not guided section elif Needed_Space: ChangeSize(ParTree, -Needed_Space) ModifySectionType(ParTree) # Update needed space with Delta_Pad_Size Needed_Space +=3D ParTree.Data.HeaderLength - OriHeade= rLen - New_Pad_Size =3D GetPadSize(ParTree.Data.Size, SECTION= _COMMON_ALIGNMENT) + New_Pad_Size =3D GetPadSize( + ParTree.Data.Size, SECTION_COMMON_ALIGNMENT) Delta_Pad_Size =3D New_Pad_Size - len(ParTree.Data.Pad= Data) Needed_Space +=3D Delta_Pad_Size ParTree.Data.PadData =3D b'\x00' * New_Pad_Size NewParTree =3D ParTree.Parent - ROOT_TYPE =3D [ROOT_FV_TREE, ROOT_FFS_TREE, ROOT_SECTION_TREE,= ROOT_TREE] + ROOT_TYPE =3D [ROOT_FV_TREE, ROOT_FFS_TREE, + ROOT_SECTION_TREE, ROOT_TREE] if NewParTree and NewParTree.type not in ROOT_TYPE: self.ModifyTest(NewParTree, Needed_Space) # If current node have enough space, will recompress all the relat= ed node data, return true. @@ -381,16 +433,20 @@ class FvHandler: TargetFv =3D self.TargetFfs.Parent # If the Fv Header Attributes is EFI_FVB2_ERASE_POLARITY, Child Ff= s Header State need be reversed. if TargetFv.Data.Header.Attributes & EFI_FVB2_ERASE_POLARITY: - self.NewFfs.Data.Header.State =3D c_uint8( - ~self.NewFfs.Data.Header.State) + self.NewFfs.Data.Header.State =3D c_uint8( + ~self.NewFfs.Data.Header.State) # NewFfs parsing will not calculate the PadSize, thus recalculate. - self.NewFfs.Data.PadData =3D b'\xff' * GetPadSize(self.NewFfs.Data= .Size, FFS_COMMON_ALIGNMENT) + self.NewFfs.Data.PadData =3D b'\xff' * \ + GetPadSize(self.NewFfs.Data.Size, FFS_COMMON_ALIGNMENT) if self.NewFfs.Data.Size >=3D self.TargetFfs.Data.Size: - Needed_Space =3D self.NewFfs.Data.Size + len(self.NewFfs.Data.= PadData) - self.TargetFfs.Data.Size - len(self.TargetFfs.Data.PadData) + Needed_Space =3D self.NewFfs.Data.Size + \ + len(self.NewFfs.Data.PadData) - self.TargetFfs.Data.Size -= \ + len(self.TargetFfs.Data.PadData) # If TargetFv have enough free space, just move part of the fr= ee space to NewFfs. if TargetFv.Data.Free_Space >=3D Needed_Space: # Modify TargetFv Child info and BiosTree. - TargetFv.Child[-1].Data.Data =3D b'\xff' * (TargetFv.Data.= Free_Space - Needed_Space) + TargetFv.Child[-1].Data.Data =3D b'\xff' * \ + (TargetFv.Data.Free_Space - Needed_Space) TargetFv.Data.Free_Space -=3D Needed_Space Target_index =3D TargetFv.Child.index(self.TargetFfs) TargetFv.Child.remove(self.TargetFfs) @@ -413,7 +469,7 @@ class FvHandler: # Recalculate TargetFv needed space to keep it match t= he BlockSize setting. Needed_Space -=3D TargetFv.Data.Free_Space BlockSize =3D TargetFv.Data.Header.BlockMap[0].Length - New_Add_Len =3D BlockSize - Needed_Space%BlockSize + New_Add_Len =3D BlockSize - Needed_Space % BlockSize Target_index =3D TargetFv.Child.index(self.TargetFfs) if New_Add_Len % BlockSize: TargetFv.Child[-1].Data.Data =3D b'\xff' * New_Add= _Len @@ -431,7 +487,8 @@ class FvHandler: if item.type =3D=3D FFS_FREE_SPACE: TargetFv.Data.Data +=3D item.Data.Data + item.= Data.PadData else: - TargetFv.Data.Data +=3D struct2stream(item.Dat= a.Header)+ item.Data.Data + item.Data.PadData + TargetFv.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.= Data.PadData TargetFv.Data.Size +=3D Needed_Space # Modify TargetFv Data Header and ExtHeader info. TargetFv.Data.Header.FvLength =3D TargetFv.Data.Size @@ -477,9 +534,12 @@ class FvHandler: def AddFfs(self) -> bool: logger.debug('Start Adding Process......') # NewFfs parsing will not calculate the PadSize, thus recalculate. - self.NewFfs.Data.PadData =3D b'\xff' * GetPadSize(self.NewFfs.Data= .Size, FFS_COMMON_ALIGNMENT) + self.NewFfs.Data.PadData =3D b'\xff' * \ + GetPadSize(self.NewFfs.Data.Size, FFS_COMMON_ALIGNMENT) if self.TargetFfs.type =3D=3D FFS_FREE_SPACE: - TargetLen =3D self.NewFfs.Data.Size + len(self.NewFfs.Data.Pad= Data) - self.TargetFfs.Data.Size - len(self.TargetFfs.Data.PadData) + TargetLen =3D self.NewFfs.Data.Size + \ + len(self.NewFfs.Data.PadData) - self.TargetFfs.Data.Size -= \ + len(self.TargetFfs.Data.PadData) TargetFv =3D self.TargetFfs.Parent # If the Fv Header Attributes is EFI_FVB2_ERASE_POLARITY, Chil= d Ffs Header State need be reversed. if TargetFv.Data.Header.Attributes & EFI_FVB2_ERASE_POLARITY: @@ -512,7 +572,7 @@ class FvHandler: elif TargetFv.type =3D=3D SEC_FV_TREE: # Recalculate TargetFv needed space to keep it match t= he BlockSize setting. BlockSize =3D TargetFv.Data.Header.BlockMap[0].Length - New_Add_Len =3D BlockSize - TargetLen%BlockSize + New_Add_Len =3D BlockSize - TargetLen % BlockSize if New_Add_Len % BlockSize: self.TargetFfs.Data.Data =3D b'\xff' * New_Add_Len self.TargetFfs.Data.Size =3D New_Add_Len @@ -530,7 +590,8 @@ class FvHandler: if item.type =3D=3D FFS_FREE_SPACE: TargetFv.Data.Data +=3D item.Data.Data + item.= Data.PadData else: - TargetFv.Data.Data +=3D struct2stream(item.Dat= a.Header)+ item.Data.Data + item.Data.PadData + TargetFv.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.= Data.PadData # Encapsulate the Fv Data for update. TargetFv.Data.Size +=3D TargetLen TargetFv.Data.Header.FvLength =3D TargetFv.Data.Size @@ -552,7 +613,7 @@ class FvHandler: self.Status =3D False elif TargetFv.type =3D=3D SEC_FV_TREE: BlockSize =3D TargetFv.Data.Header.BlockMap[0].Length - New_Add_Len =3D BlockSize - TargetLen%BlockSize + New_Add_Len =3D BlockSize - TargetLen % BlockSize if New_Add_Len % BlockSize: New_Free_Space =3D BIOSTREE('FREE_SPACE') New_Free_Space.type =3D FFS_FREE_SPACE @@ -570,7 +631,8 @@ class FvHandler: if item.type =3D=3D FFS_FREE_SPACE: TargetFv.Data.Data +=3D item.Data.Data + item.Data= .PadData else: - TargetFv.Data.Data +=3D struct2stream(item.Data.He= ader)+ item.Data.Data + item.Data.PadData + TargetFv.Data.Data +=3D struct2stream( + item.Data.Header) + item.Data.Data + item.Data= .PadData TargetFv.Data.Size +=3D TargetLen TargetFv.Data.Header.FvLength =3D TargetFv.Data.Size TargetFv.Data.ModFvExt() @@ -596,7 +658,8 @@ class FvHandler: Used_Size =3D Delete_Fv.Data.Size - Delete_Fv.Data.Free_Sp= ace - Add_Free_Space BlockSize =3D Delete_Fv.Data.Header.BlockMap[0].Length New_Free_Space =3D BlockSize - Used_Size % BlockSize - self.Remain_New_Free_Space +=3D Delete_Fv.Data.Free_Space = + Add_Free_Space - New_Free_Space + self.Remain_New_Free_Space +=3D Delete_Fv.Data.Free_Space = + \ + Add_Free_Space - New_Free_Space Delete_Fv.Child[-1].Data.Data =3D New_Free_Space * b'\xff' Delete_Fv.Data.Free_Space =3D New_Free_Space # If Fv is lst level Fv, new free space will be merged with or= igin free space. diff --git a/BaseTools/Source/Python/FMMT/core/GuidTools.py b/BaseTools/Sou= rce/Python/FMMT/core/GuidTools.py index a25681709bc8..ea196daa9c8a 100644 --- a/BaseTools/Source/Python/FMMT/core/GuidTools.py +++ b/BaseTools/Source/Python/FMMT/core/GuidTools.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the FMMT dependent external tool management = class. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -15,8 +15,10 @@ from FirmwareStorageFormat.Common import * from utils.FmmtLogger import FmmtLogger as logger import subprocess =20 + def ExecuteCommand(cmd: list) -> None: - subprocess.run(cmd,stdout=3Dsubprocess.DEVNULL) + subprocess.run(cmd, stdout=3Dsubprocess.DEVNULL) + =20 class GUIDTool: def __init__(self, guid: str, short_name: str, command: str) -> None: @@ -39,7 +41,7 @@ class GUIDTool: file.write(buffer) file.close() command =3D [tool, '-e', '-o', ToolOuputFile, - ToolInputFile] + ToolInputFile] ExecuteCommand(command) buf =3D open(ToolOuputFile, "rb") res_buffer =3D buf.read() @@ -57,7 +59,6 @@ class GUIDTool: logger.info("Its GUID is: %s" % self.guid) return "" =20 - def unpack(self, buffer: bytes) -> bytes: """ buffer: remove common header @@ -85,10 +86,12 @@ class GUIDTool: shutil.rmtree(tmp) return res_buffer else: - logger.error("Error parsing section: EFI_SECTION_GUID_DEFINED = cannot be parsed at this time.") + logger.error( + "Error parsing section: EFI_SECTION_GUID_DEFINED cannot be= parsed at this time.") logger.info("Its GUID is: %s" % self.guid) return "" =20 + class GUIDTools: ''' GUIDTools is responsible for reading FMMTConfig.ini, verify the tools = and provide interfaces to access those tools. @@ -101,19 +104,22 @@ class GUIDTools: struct2stream(ModifyGuidFormat("3d532050-5cda-4fd0-879e-0f7f630d5a= fb")): GUIDTool("3d532050-5cda-4fd0-879e-0f7f630d5afb", "BROTLI", "BrotliCo= mpress"), } =20 - def __init__(self, tooldef_file: str=3DNone) -> None: + def __init__(self, tooldef_file: str =3D None) -> None: self.dir =3D os.path.join(os.path.dirname(__file__), "..") - self.tooldef_file =3D tooldef_file if tooldef_file else os.path.jo= in(self.dir, "FmmtConf.ini") + self.tooldef_file =3D tooldef_file if tooldef_file else os.path.jo= in( + self.dir, "FmmtConf.ini") self.tooldef =3D dict() =20 def SetConfigFile(self) -> None: if os.environ['FmmtConfPath']: - self.tooldef_file =3D os.path.join(os.environ['FmmtConfPath'],= 'FmmtConf.ini') + self.tooldef_file =3D os.path.join( + os.environ['FmmtConfPath'], 'FmmtConf.ini') else: PathList =3D os.environ['PATH'] for CurrentPath in PathList: if os.path.exists(os.path.join(CurrentPath, 'FmmtConf.ini'= )): - self.tooldef_file =3D os.path.join(CurrentPath, 'FmmtC= onf.ini') + self.tooldef_file =3D os.path.join( + CurrentPath, 'FmmtConf.ini') break =20 def VerifyTools(self, guidtool) -> None: @@ -128,10 +134,13 @@ class GUIDTools: if os.path.isabs(cmd): if not os.path.exists(cmd): if guidtool not in self.default_tools: - logger.error("Tool Not found %s, which causes compress= /uncompress process error." % cmd) - logger.error("Please goto edk2 repo in current console= , run 'edksetup.bat rebuild' command, and try again.\n") + logger.error( + "Tool Not found %s, which causes compress/uncompre= ss process error." % cmd) + logger.error( + "Please goto edk2 repo in current console, run 'ed= ksetup.bat rebuild' command, and try again.\n") else: - logger.error("Tool Not found %s, which causes compress= /uncompress process error." % cmd) + logger.error( + "Tool Not found %s, which causes compress/uncompre= ss process error." % cmd) else: guidtool.ifexist =3D True else: @@ -141,10 +150,13 @@ class GUIDTools: break else: if guidtool not in self.default_tools: - logger.error("Tool Not found %s, which causes compress= /uncompress process error." % cmd) - logger.error("Please goto edk2 repo in current console= , run 'edksetup.bat rebuild' command, and try again.\n") + logger.error( + "Tool Not found %s, which causes compress/uncompre= ss process error." % cmd) + logger.error( + "Please goto edk2 repo in current console, run 'ed= ksetup.bat rebuild' command, and try again.\n") else: - logger.error("Tool Not found %s, which causes compress= /uncompress process error." % cmd) + logger.error( + "Tool Not found %s, which causes compress/uncompre= ss process error." % cmd) =20 def LoadingTools(self) -> None: self.SetConfigFile() @@ -155,7 +167,8 @@ class GUIDTools: try: if not line.startswith("#"): guid, short_name, command =3D line.split() - new_format_guid =3D struct2stream(ModifyGuidFormat= (guid.strip())) + new_format_guid =3D struct2stream( + ModifyGuidFormat(guid.strip())) self.tooldef[new_format_guid] =3D GUIDTool( guid.strip(), short_name.strip(), command.stri= p()) except: @@ -175,5 +188,5 @@ class GUIDTools: logger.error("{} GuidTool is not defined!".format(guid)) raise Exception("Process Failed: is not defined!") =20 + guidtools =3D GUIDTools() - diff --git a/BaseTools/Source/Python/FMMT/utils/FmmtLogger.py b/BaseTools/S= ource/Python/FMMT/utils/FmmtLogger.py index 385f098310a0..df2c30477bfb 100644 --- a/BaseTools/Source/Python/FMMT/utils/FmmtLogger.py +++ b/BaseTools/Source/Python/FMMT/utils/FmmtLogger.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the Fmmt Logger. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -17,12 +17,12 @@ if os.path.exists(logfile): FmmtLogger =3D logging.getLogger('FMMT') FmmtLogger.setLevel(logging.DEBUG) =20 -log_stream_handler=3Dlogging.StreamHandler(sys.stdout) -log_file_handler=3Dlogging.FileHandler(logfile) +log_stream_handler =3D logging.StreamHandler(sys.stdout) +log_file_handler =3D logging.FileHandler(logfile) log_stream_handler.setLevel(logging.INFO) =20 -stream_format=3Dlogging.Formatter("%(levelname)-8s: %(message)s") -file_format=3Dlogging.Formatter("%(levelname)-8s: %(message)s") +stream_format =3D logging.Formatter("%(levelname)-8s: %(message)s") +file_format =3D logging.Formatter("%(levelname)-8s: %(message)s") =20 log_stream_handler.setFormatter(stream_format) log_file_handler.setFormatter(file_format) diff --git a/BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py b/BaseTool= s/Source/Python/FMMT/utils/FvLayoutPrint.py index 7dafcae3b583..eadef2766380 100644 --- a/BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py +++ b/BaseTools/Source/Python/FMMT/utils/FvLayoutPrint.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the printer for Bios layout. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -6,6 +6,7 @@ ## from utils.FmmtLogger import FmmtLogger as logger =20 + def GetFormatter(layout_format: str): if layout_format =3D=3D 'json': return JsonFormatter() @@ -16,12 +17,14 @@ def GetFormatter(layout_format: str): else: return TxtFormatter() =20 + class Formatter(object): - def dump(self, layoutdict, layoutlist, outputfile: str=3DNone) -> None: + def dump(self, layoutdict, layoutlist, outputfile: str =3D None) -> No= ne: raise NotImplemented =20 + class JsonFormatter(Formatter): - def dump(self,layoutdict: dict, layoutlist: list, outputfile: str=3DNo= ne) -> None: + def dump(self, layoutdict: dict, layoutlist: list, outputfile: str =3D= None) -> None: try: import json except: @@ -29,27 +32,31 @@ class JsonFormatter(Formatter): return print(outputfile) if outputfile: - with open(outputfile,"w") as fw: + with open(outputfile, "w") as fw: json.dump(layoutdict, fw, indent=3D2) else: - print(json.dumps(layoutdict,indent=3D2)) + print(json.dumps(layoutdict, indent=3D2)) + =20 class TxtFormatter(Formatter): - def LogPrint(self,layoutlist: list) -> None: + def LogPrint(self, layoutlist: list) -> None: for item in layoutlist: print(item) print('\n') =20 - def dump(self,layoutdict: dict, layoutlist: list, outputfile: str=3DNo= ne) -> None: - logger.info('Binary Layout Info is saved in {} file.'.format(outpu= tfile)) + def dump(self, layoutdict: dict, layoutlist: list, outputfile: str =3D= None) -> None: + logger.info( + 'Binary Layout Info is saved in {} file.'.format(outputfile)) with open(outputfile, "w") as f: for item in layoutlist: f.writelines(item + '\n') =20 + class YamlFormatter(Formatter): - def dump(self,layoutdict, layoutlist, outputfile =3D None): + def dump(self, layoutdict, layoutlist, outputfile=3DNone): TxtFormatter().dump(layoutdict, layoutlist, outputfile) =20 + class HtmlFormatter(Formatter): - def dump(self,layoutdict, layoutlist, outputfile =3D None): - TxtFormatter().dump(layoutdict, layoutlist, outputfile) \ No newline at end of file + def dump(self, layoutdict, layoutlist, outputfile=3DNone): + TxtFormatter().dump(layoutdict, layoutlist, outputfile) diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/Common.py b/Base= Tools/Source/Python/FirmwareStorageFormat/Common.py index 5082268a0063..f45df799cd0b 100644 --- a/BaseTools/Source/Python/FirmwareStorageFormat/Common.py +++ b/BaseTools/Source/Python/FirmwareStorageFormat/Common.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the common C struct and functions. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -12,24 +12,28 @@ import uuid # EFI_FIRMWARE_FILE_SYSTEM3_GUID =3D uuid.UUID('{5473C07A-3DCB-4dca-BD6F-1= E9689E7349A}') # EFI_FFS_VOLUME_TOP_FILE_GUID =3D uuid.UUID('{1BA0062E-C779-4582-8566-336= AE8F78F09}') =20 -EFI_FIRMWARE_FILE_SYSTEM2_GUID =3D uuid.UUID("8c8ce578-8a3d-4f1c-9935-8961= 85c32dd3") +EFI_FIRMWARE_FILE_SYSTEM2_GUID =3D uuid.UUID( + "8c8ce578-8a3d-4f1c-9935-896185c32dd3") EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE =3D b'x\xe5\x8c\x8c=3D\x8a\x1cO\x995\x= 89a\x85\xc3-\xd3' # EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE =3D EFI_FIRMWARE_FILE_SYSTEM2_GUID.b= ytes -EFI_FIRMWARE_FILE_SYSTEM3_GUID =3D uuid.UUID("5473C07A-3DCB-4dca-BD6F-1E96= 89E7349A") +EFI_FIRMWARE_FILE_SYSTEM3_GUID =3D uuid.UUID( + "5473C07A-3DCB-4dca-BD6F-1E9689E7349A") # EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE =3D b'x\xe5\x8c\x8c=3D\x8a\x1cO\x995= \x89a\x85\xc3-\xd3' EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE =3D b'z\xc0sT\xcb=3D\xcaM\xbdo\x1e\x96= \x89\xe74\x9a' EFI_SYSTEM_NVDATA_FV_GUID =3D uuid.UUID("fff12b8d-7696-4c8b-a985-2747075b4= f50") EFI_SYSTEM_NVDATA_FV_GUID_BYTE =3D b"\x8d+\xf1\xff\x96v\x8bL\xa9\x85'G\x07= [OP" -EFI_FFS_VOLUME_TOP_FILE_GUID =3D uuid.UUID("1ba0062e-c779-4582-8566-336ae8= f78f09") +EFI_FFS_VOLUME_TOP_FILE_GUID =3D uuid.UUID( + "1ba0062e-c779-4582-8566-336ae8f78f09") EFI_FFS_VOLUME_TOP_FILE_GUID_BYTE =3D b'.\x06\xa0\x1by\xc7\x82E\x85f3j\xe8= \xf7\x8f\t' ZEROVECTOR_BYTE =3D b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00= \x00\x00\x00' PADVECTOR =3D uuid.UUID("ffffffff-ffff-ffff-ffff-ffffffffffff") FVH_SIGNATURE =3D b'_FVH' =20 -#Alignment +# Alignment SECTION_COMMON_ALIGNMENT =3D 4 FFS_COMMON_ALIGNMENT =3D 8 =20 + class GUID(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -56,11 +60,12 @@ class GUID(Structure): rt =3D rt & (self.Guid4[i] =3D=3D otherguid.Guid4[i]) return rt =20 + def ModifyGuidFormat(target_guid: str) -> GUID: target_guid =3D target_guid.replace('-', '') target_list =3D [] - start =3D [0,8,12,16,18,20,22,24,26,28,30] - end =3D [8,12,16,18,20,22,24,26,28,30,32] + start =3D [0, 8, 12, 16, 18, 20, 22, 24, 26, 28, 30] + end =3D [8, 12, 16, 18, 20, 22, 24, 26, 28, 30, 32] num =3D len(start) for pos in range(num): new_value =3D int(target_guid[start[pos]:end[pos]], 16) @@ -77,7 +82,6 @@ def struct2stream(s) -> bytes: return p.contents.raw =20 =20 - def GetPadSize(Size: int, alignment: int) -> int: if Size % alignment =3D=3D 0: return 0 diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py= b/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py index e9c619d2240e..2b37dc8b797b 100644 --- a/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py +++ b/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the Ffs Header C Struct. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -11,6 +11,7 @@ from FirmwareStorageFormat.Common import * EFI_FFS_FILE_HEADER_LEN =3D 24 EFI_FFS_FILE_HEADER2_LEN =3D 32 =20 + class CHECK_SUM(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -18,6 +19,7 @@ class CHECK_SUM(Structure): ('File', c_uint8), ] =20 + class EFI_FFS_INTEGRITY_CHECK(Union): _pack_ =3D 1 _fields_ =3D [ @@ -45,6 +47,7 @@ class EFI_FFS_FILE_HEADER(Structure): def HeaderLength(self) -> int: return 24 =20 + class EFI_FFS_FILE_HEADER2(Structure): _pack_ =3D 1 _fields_ =3D [ diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py b/Ba= seTools/Source/Python/FirmwareStorageFormat/FvHeader.py index 078beda9e5c1..e293da55b5f3 100644 --- a/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py +++ b/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the FV Header C Struct. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -9,6 +9,7 @@ from struct import * from ctypes import * from FirmwareStorageFormat.Common import * =20 + class EFI_FV_BLOCK_MAP_ENTRY(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -30,7 +31,8 @@ class EFI_FIRMWARE_VOLUME_HEADER(Structure): ('Reserved', c_uint8), ('Revision', c_uint8), ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, 1)), - ] + ] + =20 def Refine_FV_Header(nums): class EFI_FIRMWARE_VOLUME_HEADER(Structure): @@ -46,33 +48,38 @@ def Refine_FV_Header(nums): ('Reserved', c_uint8), ('Revision', c_uint8), ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, nums)), - ] + ] return EFI_FIRMWARE_VOLUME_HEADER =20 + class EFI_FIRMWARE_VOLUME_EXT_HEADER(Structure): _fields_ =3D [ ('FvName', GUID), ('ExtHeaderSize', c_uint32) - ] + ] + =20 class EFI_FIRMWARE_VOLUME_EXT_ENTRY(Structure): _fields_ =3D [ ('ExtEntrySize', c_uint16), ('ExtEntryType', c_uint16) - ] + ] + =20 class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE_0(Structure): _fields_ =3D [ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY), ('TypeMask', c_uint32) - ] + ] + =20 class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure): _fields_ =3D [ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY), ('TypeMask', c_uint32), ('Types', ARRAY(GUID, 1)) - ] + ] + =20 def Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_= EXT_ENTRY_OEM_TYPE: class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure): @@ -83,18 +90,21 @@ def Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums: int) -> E= FI_FIRMWARE_VOLUME_EXT_EN ] return EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure) =20 + class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE_0(Structure): _fields_ =3D [ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY), ('FormatType', GUID) - ] + ] + =20 class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure): _fields_ =3D [ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY), ('FormatType', GUID), ('Data', ARRAY(c_uint8, 1)) - ] + ] + =20 def Refine_FV_EXT_ENTRY_GUID_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME= _EXT_ENTRY_GUID_TYPE: class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure): @@ -105,8 +115,9 @@ def Refine_FV_EXT_ENTRY_GUID_TYPE_Header(nums: int) -> = EFI_FIRMWARE_VOLUME_EXT_E ] return EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure) =20 + class EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE(Structure): _fields_ =3D [ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY), ('UsedSize', c_uint32) - ] + ] diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py= b/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py index ee6a63679d89..f22e86f19365 100644 --- a/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py +++ b/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define the Section Header C Struct. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        @@ -11,6 +11,7 @@ from FirmwareStorageFormat.Common import * EFI_COMMON_SECTION_HEADER_LEN =3D 4 EFI_COMMON_SECTION_HEADER2_LEN =3D 8 =20 + class EFI_COMMON_SECTION_HEADER(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -25,6 +26,7 @@ class EFI_COMMON_SECTION_HEADER(Structure): def Common_Header_Size(self) -> int: return 4 =20 + class EFI_COMMON_SECTION_HEADER2(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -40,6 +42,7 @@ class EFI_COMMON_SECTION_HEADER2(Structure): def Common_Header_Size(self) -> int: return 8 =20 + class EFI_COMPRESSION_SECTION(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -50,6 +53,7 @@ class EFI_COMPRESSION_SECTION(Structure): def ExtHeaderSize(self) -> int: return 5 =20 + class EFI_FREEFORM_SUBTYPE_GUID_SECTION(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -59,6 +63,7 @@ class EFI_FREEFORM_SUBTYPE_GUID_SECTION(Structure): def ExtHeaderSize(self) -> int: return 16 =20 + class EFI_GUID_DEFINED_SECTION(Structure): _pack_ =3D 1 _fields_ =3D [ @@ -70,6 +75,7 @@ class EFI_GUID_DEFINED_SECTION(Structure): def ExtHeaderSize(self) -> int: return 20 =20 + def Get_USER_INTERFACE_Header(nums: int): class EFI_SECTION_USER_INTERFACE(Structure): _pack_ =3D 1 @@ -89,6 +95,7 @@ def Get_USER_INTERFACE_Header(nums: int): =20 return EFI_SECTION_USER_INTERFACE =20 + def Get_VERSION_Header(nums: int): class EFI_SECTION_VERSION(Structure): _pack_ =3D 1 diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/__init__.py b/Ba= seTools/Source/Python/FirmwareStorageFormat/__init__.py index 335653c6cc60..94330f5ae148 100644 --- a/BaseTools/Source/Python/FirmwareStorageFormat/__init__.py +++ b/BaseTools/Source/Python/FirmwareStorageFormat/__init__.py @@ -1,6 +1,6 @@ -## @file +# @file # This file is used to define the Firmware Storage Format. # # Copyright (c) 2021-, Intel Corporation. All rights reserved.
        # SPDX-License-Identifier: BSD-2-Clause-Patent -## \ No newline at end of file +## diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/S= ource/Python/GenFds/AprioriSection.py index 9f64c613eb8f..c1432394335e 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process APRIORI file data and generate PEI/DXE APRIORI file # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -24,11 +24,13 @@ from Common.DataType import TAB_COMMON DXE_APRIORI_GUID =3D "FC510EE7-FFDC-11D4-BD41-0080C73C8881" PEI_APRIORI_GUID =3D "1B45CC0A-156A-428A-AF62-49864DA0E6E6" =20 -## process APRIORI file data and generate PEI/DXE APRIORI file +# process APRIORI file data and generate PEI/DXE APRIORI file # # + + class AprioriSection (object): - ## The constructor + # The constructor # # @param self The object pointer # @@ -37,7 +39,7 @@ class AprioriSection (object): self.FfsList =3D [] self.AprioriType =3D "" =20 - ## GenFfs() method + # GenFfs() method # # Generate FFS for APRIORI file # @@ -46,7 +48,7 @@ class AprioriSection (object): # @param Dict dictionary contains macro and its value # @retval string Generated file name # - def GenFfs (self, FvName, Dict =3D None, IsMakefile =3D False): + def GenFfs(self, FvName, Dict=3DNone, IsMakefile=3DFalse): if Dict is None: Dict =3D {} Buffer =3D BytesIO() @@ -55,16 +57,16 @@ class AprioriSection (object): else: AprioriFileGuid =3D DXE_APRIORI_GUID =20 - OutputAprFilePath =3D os.path.join (GenFdsGlobalVariable.WorkSpace= Dir, \ - GenFdsGlobalVariable.FfsDir,\ - AprioriFileGuid + FvName) + OutputAprFilePath =3D os.path.join(GenFdsGlobalVariable.WorkSpaceD= ir, + GenFdsGlobalVariable.FfsDir, + AprioriFileGuid + FvName) if not os.path.exists(OutputAprFilePath): os.makedirs(OutputAprFilePath) =20 - OutputAprFileName =3D os.path.join( OutputAprFilePath, \ - AprioriFileGuid + FvName + '.Apri' ) - AprFfsFileName =3D os.path.join (OutputAprFilePath,\ - AprioriFileGuid + FvName + '.Ffs') + OutputAprFileName =3D os.path.join(OutputAprFilePath, + AprioriFileGuid + FvName + '.Apri= ') + AprFfsFileName =3D os.path.join(OutputAprFilePath, + AprioriFileGuid + FvName + '.Ffs') =20 Dict.update(self.DefineVarDict) InfFileName =3D None @@ -78,19 +80,22 @@ class AprioriSection (object): =20 if Arch: Dict['$(ARCH)'] =3D Arch - InfFileName =3D GenFdsGlobalVariable.MacroExtend(InfFileNa= me, Dict, Arch) + InfFileName =3D GenFdsGlobalVariable.MacroExtend( + InfFileName, Dict, Arch) =20 if Arch: - Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), Arch, GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass( + InfFileName, GenFdsGlobalVariable.WorkSpaceDir), A= rch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] Guid =3D Inf.Guid else: - Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), TAB_COMMON, GenFdsG= lobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass( + InfFileName, GenFdsGlobalVariable.WorkSpaceDir), T= AB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainT= ag] Guid =3D Inf.Guid =20 if not Inf.Module.Binaries: EdkLoggerError("GenFds", RESOURCE_NOT_AVAILABLE, - "INF %s not found in build ARCH %s= !" \ - % (InfFileName, GenFdsGlobalVariab= le.ArchList)) + "INF %s not found in build ARCH %s!" + % (InfFileName, GenFdsGlobalVariabl= e.ArchList)) =20 GuidPart =3D Guid.split('-') Buffer.write(pack('I', int(GuidPart[0], 16))) @@ -107,15 +112,16 @@ class AprioriSection (object): =20 SaveFileOnChange(OutputAprFileName, Buffer.getvalue()) =20 - RawSectionFileName =3D os.path.join( OutputAprFilePath, \ - AprioriFileGuid + FvName + '.raw' ) + RawSectionFileName =3D os.path.join(OutputAprFilePath, + AprioriFileGuid + FvName + '.raw= ') MakefilePath =3D None if IsMakefile: if not InfFileName: return None MakefilePath =3D InfFileName, Arch - GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAp= rFileName], 'EFI_SECTION_RAW', IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [ + OutputAprFileName], 'EFI_SECT= ION_RAW', IsMakefile=3DIsMakefile) GenFdsGlobalVariable.GenerateFfs(AprFfsFileName, [RawSectionFileNa= me], - 'EFI_FV_FILETYPE_FREEFORM', Aprior= iFileGuid, MakefilePath=3DMakefilePath) + 'EFI_FV_FILETYPE_FREEFORM', Aprio= riFileGuid, MakefilePath=3DMakefilePath) =20 return AprFfsFileName diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/P= ython/GenFds/Capsule.py index f4bfc74e551c..50fa5722fc91 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -1,4 +1,4 @@ -## @file +# @file # generate capsule # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -24,13 +24,16 @@ from Common.DataType import TAB_LINE_BREAK WIN_CERT_REVISION =3D 0x0200 WIN_CERT_TYPE_EFI_GUID =3D 0x0EF1 EFI_CERT_TYPE_PKCS7_GUID =3D uuid.UUID('{4aafd29d-68df-49ee-8aa9-347d37566= 5a7}') -EFI_CERT_TYPE_RSA2048_SHA256_GUID =3D uuid.UUID('{a7717414-c616-4977-9420-= 844712a735bf}') +EFI_CERT_TYPE_RSA2048_SHA256_GUID =3D uuid.UUID( + '{a7717414-c616-4977-9420-844712a735bf}') =20 -## create inf file describes what goes into capsule and call GenFv to gene= rate capsule +# create inf file describes what goes into capsule and call GenFv to gener= ate capsule # # + + class Capsule (CapsuleClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -42,7 +45,7 @@ class Capsule (CapsuleClassObject): self.BlockNum =3D None self.CapsuleName =3D None =20 - ## Generate FMP capsule + # Generate FMP capsule # # @retval string Generated Capsule file path # @@ -60,10 +63,12 @@ class Capsule (CapsuleClassObject): # # Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A # - Header.write(PackGUID('6DCBD5ED-E82D-4C44-BDA1-7194199AD92A'.split= ('-'))) + Header.write( + PackGUID('6DCBD5ED-E82D-4C44-BDA1-7194199AD92A'.split('-'))) HdrSize =3D 0 if 'CAPSULE_HEADER_SIZE' in self.TokensDict: - Header.write(pack('=3DI', int(self.TokensDict['CAPSULE_HEADER_= SIZE'], 16))) + Header.write( + pack('=3DI', int(self.TokensDict['CAPSULE_HEADER_SIZE'], 1= 6))) HdrSize =3D int(self.TokensDict['CAPSULE_HEADER_SIZE'], 16) else: Header.write(pack('=3DI', 0x20)) @@ -89,11 +94,14 @@ class Capsule (CapsuleClassObject): # FwMgrHdr =3D BytesIO() if 'CAPSULE_HEADER_INIT_VERSION' in self.TokensDict: - FwMgrHdr.write(pack('=3DI', int(self.TokensDict['CAPSULE_HEADE= R_INIT_VERSION'], 16))) + FwMgrHdr.write( + pack('=3DI', int(self.TokensDict['CAPSULE_HEADER_INIT_VERS= ION'], 16))) else: FwMgrHdr.write(pack('=3DI', 0x00000001)) - FwMgrHdr.write(pack('=3DHH', len(self.CapsuleDataList), len(self.F= mpPayloadList))) - FwMgrHdrSize =3D 4+2+2+8*(len(self.CapsuleDataList)+len(self.FmpPa= yloadList)) + FwMgrHdr.write(pack('=3DHH', len(self.CapsuleDataList), + len(self.FmpPayloadList))) + FwMgrHdrSize =3D 4+2+2+8 * \ + (len(self.CapsuleDataList)+len(self.FmpPayloadList)) =20 # # typedef struct _WIN_CERTIFICATE { @@ -143,27 +151,37 @@ class Capsule (CapsuleClassObject): for Obj in fmp.VendorCodeFile: fmp.VendorCodeFile =3D Obj.GenCapsuleSubItem() if fmp.Certificate_Guid: - ExternalTool, ExternalOption =3D FindExtendTool([], GenFds= GlobalVariable.ArchList, fmp.Certificate_Guid) + ExternalTool, ExternalOption =3D FindExtendTool( + [], GenFdsGlobalVariable.ArchList, fmp.Certificate_Gui= d) CmdOption =3D '' CapInputFile =3D fmp.ImageFile if not os.path.isabs(fmp.ImageFile): - CapInputFile =3D os.path.join(GenFdsGlobalVariable.Wor= kSpaceDir, fmp.ImageFile) - CapOutputTmp =3D os.path.join(GenFdsGlobalVariable.FvDir, = self.UiCapsuleName) + '.tmp' + CapInputFile =3D os.path.join( + GenFdsGlobalVariable.WorkSpaceDir, fmp.ImageFile) + CapOutputTmp =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.UiCapsuleName) + '.tm= p' if ExternalTool is None: - EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found= with GUID %s" % fmp.Certificate_Guid) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "No tool found with GUID %= s" % fmp.Certificate_Guid) else: CmdOption +=3D ExternalTool if ExternalOption: CmdOption =3D CmdOption + ' ' + ExternalOption - CmdOption +=3D ' -e ' + ' --monotonic-count ' + str(fmp.Mo= notonicCount) + ' -o ' + CapOutputTmp + ' ' + CapInputFile + CmdOption +=3D ' -e ' + ' --monotonic-count ' + \ + str(fmp.MonotonicCount) + ' -o ' + \ + CapOutputTmp + ' ' + CapInputFile CmdList =3D CmdOption.split() - GenFdsGlobalVariable.CallExternalTool(CmdList, "Failed to = generate FMP auth capsule") + GenFdsGlobalVariable.CallExternalTool( + CmdList, "Failed to generate FMP auth capsule") if uuid.UUID(fmp.Certificate_Guid) =3D=3D EFI_CERT_TYPE_PK= CS7_GUID: - dwLength =3D 4 + 2 + 2 + 16 + os.path.getsize(CapOutpu= tTmp) - os.path.getsize(CapInputFile) + dwLength =3D 4 + 2 + 2 + 16 + \ + os.path.getsize(CapOutputTmp) - \ + os.path.getsize(CapInputFile) else: dwLength =3D 4 + 2 + 2 + 16 + 16 + 256 + 256 fmp.ImageFile =3D CapOutputTmp - AuthData =3D [fmp.MonotonicCount, dwLength, WIN_CERT_REVIS= ION, WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid] + AuthData =3D [fmp.MonotonicCount, dwLength, WIN_CERT_REVIS= ION, + WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid] fmp.Buffer =3D fmp.GenCapsuleSubItem(AuthData) else: fmp.Buffer =3D fmp.GenCapsuleSubItem() @@ -181,11 +199,12 @@ class Capsule (CapsuleClassObject): # # Generate FMP capsule file # - CapOutputFile =3D os.path.join(GenFdsGlobalVariable.FvDir, self.Ui= CapsuleName) + '.Cap' + CapOutputFile =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.UiCapsuleName) + '.Cap' SaveFileOnChange(CapOutputFile, Header.getvalue(), True) return CapOutputFile =20 - ## Generate capsule + # Generate capsule # # @param self The object pointer # @retval string Generated Capsule file path @@ -194,9 +213,10 @@ class Capsule (CapsuleClassObject): if self.UiCapsuleName.upper() + 'cap' in GenFdsGlobalVariable.Imag= eBinDict: return GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.up= per() + 'cap'] =20 - GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCa= psuleName) + GenFdsGlobalVariable.InfLogger( + "\nGenerate %s Capsule" % self.UiCapsuleName) if ('CAPSULE_GUID' in self.TokensDict and - uuid.UUID(self.TokensDict['CAPSULE_GUID']) =3D=3D uuid.UUID('6= DCBD5ED-E82D-4C44-BDA1-7194199AD92A')): + uuid.UUID(self.TokensDict['CAPSULE_GUID']) =3D=3D uuid.UUI= D('6DCBD5ED-E82D-4C44-BDA1-7194199AD92A')): return self.GenFmpCapsule() =20 CapInfFile =3D self.GenCapInf() @@ -207,44 +227,47 @@ class Capsule (CapsuleClassObject): FileName =3D CapsuleDataObj.GenCapsuleSubItem() CapsuleDataObj.CapsuleName =3D None CapFileList.append(FileName) - CapInfFile.append("EFI_FILE_NAME =3D " + \ - FileName + \ - TAB_LINE_BREAK) + CapInfFile.append("EFI_FILE_NAME =3D " + + FileName + + TAB_LINE_BREAK) SaveFileOnChange(self.CapInfFileName, ''.join(CapInfFile), False) # # Call GenFv tool to generate capsule # - CapOutputFile =3D os.path.join(GenFdsGlobalVariable.FvDir, self.Ui= CapsuleName) + CapOutputFile =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.UiCapsuleName) CapOutputFile =3D CapOutputFile + '.Cap' GenFdsGlobalVariable.GenerateFirmwareVolume( - CapOutputFile, - [self.CapInfFileName], - Capsule=3DTrue, - FfsList=3DCapFileList - ) + CapOutputFile, + [self.CapInfFileName], + Capsule=3DTrue, + FfsList=3DCapFileList + ) =20 - GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Success= fully" %self.UiCapsuleName) + GenFdsGlobalVariable.VerboseLogger( + "\nGenerate %s Capsule Successfully" % self.UiCapsuleName) GenFdsGlobalVariable.SharpCounter =3D 0 - GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'ca= p'] =3D CapOutputFile + GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper( + ) + 'cap'] =3D CapOutputFile return CapOutputFile =20 - ## Generate inf file for capsule + # Generate inf file for capsule # # @param self The object pointer # @retval file inf file object # def GenCapInf(self): self.CapInfFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, - self.UiCapsuleName + "_Cap" + '.inf') + self.UiCapsuleName + "_Cap" + '= .inf') CapInfFile =3D [] =20 CapInfFile.append("[options]" + TAB_LINE_BREAK) =20 for Item in self.TokensDict: - CapInfFile.append("EFI_" + \ - Item + \ - ' =3D ' + \ - self.TokensDict[Item] + \ - TAB_LINE_BREAK) + CapInfFile.append("EFI_" + + Item + + ' =3D ' + + self.TokensDict[Item] + + TAB_LINE_BREAK) =20 return CapInfFile diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Sour= ce/Python/GenFds/CapsuleData.py index ebbde7f8708c..f9b1569635aa 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -1,4 +1,4 @@ -## @file +# @file # generate capsule # # Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
        @@ -17,35 +17,39 @@ import os from Common.Misc import SaveFileOnChange import uuid =20 -## base class for capsule data +# base class for capsule data # # + + class CapsuleData: - ## The constructor + # The constructor # # @param self The object pointer def __init__(self): pass =20 - ## generate capsule data + # generate capsule data # # @param self The object pointer def GenCapsuleSubItem(self): pass =20 -## FFS class for capsule data +# FFS class for capsule data # # + + class CapsuleFfs (CapsuleData): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self) : + def __init__(self): self.Ffs =3D None self.FvName =3D None =20 - ## generate FFS capsule data + # generate FFS capsule data # # @param self The object pointer # @retval string Generated file name @@ -54,20 +58,22 @@ class CapsuleFfs (CapsuleData): FfsFile =3D self.Ffs.GenFfs() return FfsFile =20 -## FV class for capsule data +# FV class for capsule data # # + + class CapsuleFv (CapsuleData): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self) : + def __init__(self): self.Ffs =3D None self.FvName =3D None self.CapsuleName =3D None =20 - ## generate FV capsule data + # generate FV capsule data # # @param self The object pointer # @retval string Generated file name @@ -75,7 +81,8 @@ class CapsuleFv (CapsuleData): def GenCapsuleSubItem(self): if self.FvName.find('.fv') =3D=3D -1: if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FvDict: - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[se= lf.FvName.upper()] + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[se= lf.FvName.upper( + )] FdBuffer =3D BytesIO() FvObj.CapsuleName =3D self.CapsuleName FvFile =3D FvObj.AddToBuffer(FdBuffer) @@ -86,20 +93,22 @@ class CapsuleFv (CapsuleData): FvFile =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvN= ame) return FvFile =20 -## FD class for capsule data +# FD class for capsule data # # + + class CapsuleFd (CapsuleData): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self) : + def __init__(self): self.Ffs =3D None self.FdName =3D None self.CapsuleName =3D None =20 - ## generate FD capsule data + # generate FD capsule data # # @param self The object pointer # @retval string Generated file name @@ -107,26 +116,29 @@ class CapsuleFd (CapsuleData): def GenCapsuleSubItem(self): if self.FdName.find('.fd') =3D=3D -1: if self.FdName.upper() in GenFdsGlobalVariable.FdfParser.Profi= le.FdDict: - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[se= lf.FdName.upper()] + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[se= lf.FdName.upper( + )] FdFile =3D FdObj.GenFd() return FdFile else: FdFile =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FdN= ame) return FdFile =20 -## AnyFile class for capsule data +# AnyFile class for capsule data # # + + class CapsuleAnyFile (CapsuleData): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self) : + def __init__(self): self.Ffs =3D None self.FileName =3D None =20 - ## generate AnyFile capsule data + # generate AnyFile capsule data # # @param self The object pointer # @retval string Generated file name @@ -134,19 +146,21 @@ class CapsuleAnyFile (CapsuleData): def GenCapsuleSubItem(self): return self.FileName =20 -## Afile class for capsule data +# Afile class for capsule data # # + + class CapsuleAfile (CapsuleData): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self) : + def __init__(self): self.Ffs =3D None self.FileName =3D None =20 - ## generate Afile capsule data + # generate Afile capsule data # # @param self The object pointer # @retval string Generated file name @@ -154,6 +168,7 @@ class CapsuleAfile (CapsuleData): def GenCapsuleSubItem(self): return self.FileName =20 + class CapsulePayload(CapsuleData): '''Generate payload file, the header is defined below: #pragma pack(1) @@ -167,6 +182,7 @@ class CapsulePayload(CapsuleData): UINT64 UpdateHardwareInstance; //Introduced in v2 } EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER; ''' + def __init__(self): self.UiName =3D None self.Version =3D None @@ -201,28 +217,29 @@ class CapsulePayload(CapsuleData): # Guid =3D self.ImageTypeId.split('-') Buffer =3D pack('=3DILHHBBBBBBBBBBBBIIQ', - int(self.Version, 16), - int(Guid[0], 16), - int(Guid[1], 16), - int(Guid[2], 16), - int(Guid[3][-4:-2], 16), - int(Guid[3][-2:], 16), - int(Guid[4][-12:-10], 16), - int(Guid[4][-10:-8], 16), - int(Guid[4][-8:-6], 16), - int(Guid[4][-6:-4], 16), - int(Guid[4][-4:-2], 16), - int(Guid[4][-2:], 16), - int(self.ImageIndex, 16), - 0, - 0, - 0, - ImageFileSize, - VendorFileSize, - int(self.HardwareInstance, 16) - ) + int(self.Version, 16), + int(Guid[0], 16), + int(Guid[1], 16), + int(Guid[2], 16), + int(Guid[3][-4:-2], 16), + int(Guid[3][-2:], 16), + int(Guid[4][-12:-10], 16), + int(Guid[4][-10:-8], 16), + int(Guid[4][-8:-6], 16), + int(Guid[4][-6:-4], 16), + int(Guid[4][-4:-2], 16), + int(Guid[4][-2:], 16), + int(self.ImageIndex, 16), + 0, + 0, + 0, + ImageFileSize, + VendorFileSize, + int(self.HardwareInstance, 16) + ) if AuthData: - Buffer +=3D pack('QIHH', AuthData[0], AuthData[1], AuthData[2]= , AuthData[3]) + Buffer +=3D pack('QIHH', AuthData[0], + AuthData[1], AuthData[2], AuthData[3]) Buffer +=3D uuid.UUID(AuthData[4]).bytes_le =20 # diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/= Source/Python/GenFds/CompressSection.py index e62280fc16c2..f248cb4ceaa1 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process compress section generation # # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
        @@ -18,25 +18,27 @@ from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import CompressSectionClassObject from Common.DataType import * =20 -## generate compress section +# generate compress section # # -class CompressSection (CompressSectionClassObject) : =20 - ## compress types: PI standard and non PI standard + +class CompressSection (CompressSectionClassObject): + + # compress types: PI standard and non PI standard CompTypeDict =3D { - 'PI_STD' : 'PI_STD', - 'PI_NONE' : 'PI_NONE' + 'PI_STD': 'PI_STD', + 'PI_NONE': 'PI_NONE' } =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): CompressSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate compressed section # @@ -49,7 +51,7 @@ class CompressSection (CompressSectionClassObject) : # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D None, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): =20 if FfsInf is not None: self.CompType =3D FfsInf.__ExtendMacro__(self.CompType) @@ -63,12 +65,13 @@ class CompressSection (CompressSectionClassObject) : Dict =3D {} for Sect in self.SectionList: Index =3D Index + 1 - SecIndex =3D '%s.%d' %(SecNum, Index) - ReturnSectList, AlignValue =3D Sect.GenSection(OutputPath, Mod= uleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) + SecIndex =3D '%s.%d' % (SecNum, Index) + ReturnSectList, AlignValue =3D Sect.GenSection( + OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, D= ict, IsMakefile=3DIsMakefile) if AlignValue is not None: if MaxAlign is None: MaxAlign =3D AlignValue - if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFds= GlobalVariable.GetAlignment (MaxAlign): + if GenFdsGlobalVariable.GetAlignment(AlignValue) > GenFdsG= lobalVariable.GetAlignment(MaxAlign): MaxAlign =3D AlignValue if ReturnSectList !=3D []: if AlignValue is None: @@ -78,19 +81,18 @@ class CompressSection (CompressSectionClassObject) : SectAlign.append(AlignValue) =20 OutputFile =3D OutputPath + \ - os.sep + \ - ModuleName + \ - SUP_MODULE_SEC + \ - SecNum + \ - SectionSuffix['COMPRESS'] + os.sep + \ + ModuleName + \ + SUP_MODULE_SEC + \ + SecNum + \ + SectionSuffix['COMPRESS'] OutputFile =3D os.path.normpath(OutputFile) DummyFile =3D OutputFile + '.dummy' - GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAl= ign=3DSectAlign, IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection( + DummyFile, SectFiles, InputAlign=3DSectAlign, IsMakefile=3DIsM= akefile) =20 GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Sect= ion.Section.SectionType['COMPRESS'], CompressionType=3Dself.CompTy= peDict[self.CompType], IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment - - diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Sour= ce/Python/GenFds/DataSection.py index 5af3ee7b7f7c..d7c859649863 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process data section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -20,18 +20,20 @@ from Common.Misc import PeImageClass from Common.LongFilePathSupport import CopyLongFilePath from Common.DataType import * =20 -## generate data section +# generate data section # # + + class DataSection (DataSectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): DataSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate compressed section # @@ -44,24 +46,28 @@ class DataSection (DataSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D None, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile=3DNone, Dict=3DNone, IsMakefile=3DFalse): # # Prepare the parameter of GenSection # if Dict is None: Dict =3D {} if FfsFile is not None: - self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro(self.SectFileName) - self.SectFileName =3D GenFdsGlobalVariable.MacroExtend(self.Se= ctFileName, Dict, FfsFile.CurrentArch) + self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro( + self.SectFileName) + self.SectFileName =3D GenFdsGlobalVariable.MacroExtend( + self.SectFileName, Dict, FfsFile.CurrentArch) else: - self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro(self.SectFileName) - self.SectFileName =3D GenFdsGlobalVariable.MacroExtend(self.Se= ctFileName, Dict) + self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro( + self.SectFileName) + self.SectFileName =3D GenFdsGlobalVariable.MacroExtend( + self.SectFileName, Dict) =20 """Check Section file exist or not !""" =20 if not os.path.exists(self.SectFileName): - self.SectFileName =3D os.path.join (GenFdsGlobalVariable.WorkS= paceDir, - self.SectFileName) + self.SectFileName =3D os.path.join(GenFdsGlobalVariable.WorkSp= aceDir, + self.SectFileName) =20 """Copy Map file to Ffs output""" Filename =3D GenFdsGlobalVariable.MacroExtend(self.SectFileName) @@ -72,13 +78,14 @@ class DataSection (DataSectionClassObject): if GenFdsGlobalVariable.CopyList =3D=3D []: GenFdsGlobalVariable.CopyList =3D [(MapFile, CopyMapFi= le)] else: - GenFdsGlobalVariable.CopyList.append((MapFile, CopyMap= File)) + GenFdsGlobalVariable.CopyList.append( + (MapFile, CopyMapFile)) else: if os.path.exists(MapFile): if not os.path.exists(CopyMapFile) or (os.path.getmtim= e(MapFile) > os.path.getmtime(CopyMapFile)): CopyLongFilePath(MapFile, CopyMapFile) =20 - #Get PE Section alignment when align is set to AUTO + # Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and self.SecType in (BINARY_FILE_T= YPE_TE, BINARY_FILE_TYPE_PE32): self.Alignment =3D "0" NoStrip =3D True @@ -89,29 +96,31 @@ class DataSection (DataSectionClassObject): if not NoStrip: FileBeforeStrip =3D os.path.join(OutputPath, ModuleName + '.ef= i') if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(self.SectFileName) > os.path.getmtime(Fi= leBeforeStrip)): + (os.path.getmtime(self.SectFileName) > os.path.getmtim= e(FileBeforeStrip)): CopyLongFilePath(self.SectFileName, FileBeforeStrip) StrippedFile =3D os.path.join(OutputPath, ModuleName + '.strip= ped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], - Strip=3DTrue, - IsMakefile =3D IsMakefile - ) + StrippedFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)= ], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) self.SectFileName =3D StrippedFile =20 if self.SecType =3D=3D BINARY_FILE_TYPE_TE: - TeFile =3D os.path.join( OutputPath, ModuleName + 'Te.raw') + TeFile =3D os.path.join(OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], - Type=3D'te', - IsMakefile =3D IsMakefile - ) + TeFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)= ], + Type=3D'te', + IsMakefile=3DIsMakefile + ) self.SectFileName =3D TeFile =20 - OutputFile =3D os.path.join (OutputPath, ModuleName + SUP_MODULE_S= EC + SecNum + SectionSuffix.get(self.SecType)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + SectionSuff= ix.get(self.SecType)) OutputFile =3D os.path.normpath(OutputFile) - GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], Section.Section.SectionType.get(self.SecType), IsMakefile =3D IsMakefil= e) + GenFdsGlobalVariable.GenerateSection(OutputFile, [ + self.SectFileName], Section.S= ection.SectionType.get(self.SecType), IsMakefile=3DIsMakefile) FileList =3D [OutputFile] return FileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Sou= rce/Python/GenFds/DepexSection.py index 6cabac38c496..fabbcba79e37 100644 --- a/BaseTools/Source/Python/GenFds/DepexSection.py +++ b/BaseTools/Source/Python/GenFds/DepexSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process depex section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -20,11 +20,13 @@ from Common.BuildToolError import * from Common.Misc import PathClass from Common.DataType import * =20 -## generate data section +# generate data section # # + + class DepexSection (DepexSectionClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -39,11 +41,11 @@ class DepexSection (DepexSectionClassObject): GenFds= GlobalVariable.ToolChainTag) for Inf in GenFdsGlobalVariable.FdfParser.Profile.InfList: ModuleData =3D GenFdsGlobalVariable.WorkSpace.BuildObject[ - PathClass(Inf,= GenFdsGlobalVariable.WorkSpaceDir), - Arch, - GenFdsGlobalVa= riable.TargetName, - GenFdsGlobalVa= riable.ToolChainTag - ] + PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir), + Arch, + GenFdsGlobalVariable.TargetName, + GenFdsGlobalVariable.ToolChainTag + ] for Pkg in ModuleData.Packages: if Pkg not in PkgList: PkgList.append(Pkg) @@ -56,7 +58,7 @@ class DepexSection (DepexSectionClassObject): return PkgDb.Guids[CName] return None =20 - ## GenSection() method + # GenSection() method # # Generate compressed section # @@ -69,9 +71,10 @@ class DepexSection (DepexSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D None, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile=3DNone, Dict=3DNone, IsMakefile=3DFalse): if self.ExpressionProcessed =3D=3D False: - self.Expression =3D self.Expression.replace("\n", " ").replace= ("\r", " ") + self.Expression =3D self.Expression.replace( + "\n", " ").replace("\r", " ") ExpList =3D self.Expression.split() =20 for Exp in ExpList: @@ -88,24 +91,27 @@ class DepexSection (DepexSectionClassObject): =20 if self.DepexType =3D=3D 'PEI_DEPEX_EXP': ModuleType =3D SUP_MODULE_PEIM - SecType =3D BINARY_FILE_TYPE_PEI_DEPEX + SecType =3D BINARY_FILE_TYPE_PEI_DEPEX elif self.DepexType =3D=3D 'DXE_DEPEX_EXP': ModuleType =3D SUP_MODULE_DXE_DRIVER - SecType =3D BINARY_FILE_TYPE_DXE_DEPEX + SecType =3D BINARY_FILE_TYPE_DXE_DEPEX elif self.DepexType =3D=3D 'SMM_DEPEX_EXP': ModuleType =3D SUP_MODULE_DXE_SMM_DRIVER - SecType =3D BINARY_FILE_TYPE_SMM_DEPEX + SecType =3D BINARY_FILE_TYPE_SMM_DEPEX else: EdkLogger.error("GenFds", FORMAT_INVALID, "Depex type %s is not valid for module %s" % (= self.DepexType, ModuleName)) =20 - InputFile =3D os.path.join (OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + '.depex') + InputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.depex') InputFile =3D os.path.normpath(InputFile) Depex =3D DependencyExpression(self.Expression, ModuleType) Depex.Generate(InputFile) =20 - OutputFile =3D os.path.join (OutputPath, ModuleName + SUP_MODULE_S= EC + SecNum + '.dpx') + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.dpx') OutputFile =3D os.path.normpath(OutputFile) =20 - GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Sect= ion.Section.SectionType.get (SecType), IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection(OutputFile, [ + InputFile], Section.Section.S= ectionType.get(SecType), IsMakefile=3DIsMakefile) return [OutputFile], self.Alignment diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Sourc= e/Python/GenFds/EfiSection.py index fd58391dac99..8db984e83c71 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process rule section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -24,19 +24,21 @@ from Common.LongFilePathSupport import OpenLongFilePath= as open from Common.LongFilePathSupport import CopyLongFilePath from Common.DataType import * =20 -## generate rule section +# generate rule section # # + + class EfiSection (EfiSectionClassObject): =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): - EfiSectionClassObject.__init__(self) + EfiSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate rule section # @@ -49,12 +51,12 @@ class EfiSection (EfiSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D None, IsMakefile =3D False) : + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): =20 if self.FileName is not None and self.FileName.startswith('PCD('): self.FileName =3D GenFdsGlobalVariable.GetPcdValue(self.FileNa= me) """Prepare the parameter of GenSection""" - if FfsInf is not None : + if FfsInf is not None: InfFileName =3D FfsInf.InfFileName SectionType =3D FfsInf.__ExtendMacro__(self.SectionType) Filename =3D FfsInf.__ExtendMacro__(self.FileName) @@ -72,7 +74,8 @@ class EfiSection (EfiSectionClassObject): elif FfsInf.ShadowFromInfFile is not None: NoStrip =3D FfsInf.ShadowFromInfFile else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s apply rule = for None!" %ModuleName) + EdkLogger.error("GenFds", GENFDS_ERROR, + "Module %s apply rule for None!" % ModuleName) =20 """If the file name was pointed out, add it in FileList""" FileList =3D [] @@ -84,7 +87,8 @@ class EfiSection (EfiSectionClassObject): if os.path.isabs(Filename): Filename =3D os.path.normpath(Filename) else: - Filename =3D os.path.normpath(os.path.join(FfsInf.EfiOutpu= tPath, Filename)) + Filename =3D os.path.normpath( + os.path.join(FfsInf.EfiOutputPath, Filename)) =20 if not self.Optional: FileList.append(Filename) @@ -95,8 +99,9 @@ class EfiSection (EfiSectionClassObject): if '.depex' in SuffixMap: FileList.append(Filename) else: - FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FileType, self.FileExtension, Dict, IsMakefile=3DIsMakefile, SectionType=3D= SectionType) - if IsSect : + FileList, IsSect =3D Section.Section.GetFileList( + FfsInf, self.FileType, self.FileExtension, Dict, IsMakefil= e=3DIsMakefile, SectionType=3DSectionType) + if IsSect: return FileList, self.Alignment =20 Index =3D 0 @@ -120,18 +125,20 @@ class EfiSection (EfiSectionClassObject): BuildNumTuple =3D tuple() =20 Num =3D SecNum - OutputFile =3D os.path.join( OutputPath, ModuleName + SUP_= MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + S= ectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DStringData, - Ver=3DBuildNum, - IsMakefile=3DIsMakefil= e) + # Ui=3DStringData, + Ver=3DBuildNum, + IsMakefile=3DIsMakefi= le) OutputFileList.append(OutputFile) =20 elif FileList !=3D []: for File in FileList: Index =3D Index + 1 - Num =3D '%s.%d' %(SecNum, Index) - OutputFile =3D os.path.join(OutputPath, ModuleName + S= UP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) + Num =3D '%s.%d' % (SecNum, Index) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + Num + Se= ctionSuffix.get(SectionType)) f =3D open(File, 'r') VerString =3D f.read() f.close() @@ -139,9 +146,9 @@ class EfiSection (EfiSectionClassObject): if BuildNum is not None and BuildNum !=3D '': BuildNumTuple =3D ('-j', BuildNum) GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_VERSION', - #Ui=3DVerString, - Ver=3DBuildNum, - IsMakefile=3DIsMak= efile) + # Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMa= kefile) OutputFileList.append(OutputFile) =20 else: @@ -152,19 +159,22 @@ class EfiSection (EfiSectionClassObject): BuildNumTuple =3D tuple() BuildNumString =3D ' ' + ' '.join(BuildNumTuple) =20 - #if VerString =3D=3D '' and + # if VerString =3D=3D '' and if BuildNumString =3D=3D '': - if self.Optional =3D=3D True : - GenFdsGlobalVariable.VerboseLogger( "Optional Sect= ion don't exist!") + if self.Optional =3D=3D True: + GenFdsGlobalVariable.VerboseLogger( + "Optional Section don't exist!") return [], None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss Version Section value" %InfFileName) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "File: %s miss Version= Section value" % InfFileName) Num =3D SecNum - OutputFile =3D os.path.join( OutputPath, ModuleName + SUP_= MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + S= ectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DVerString, - Ver=3DBuildNum, - IsMakefile=3DIsMakefil= e) + # Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMakefi= le) OutputFileList.append(OutputFile) =20 # @@ -181,7 +191,8 @@ class EfiSection (EfiSectionClassObject): Num =3D SecNum if IsMakefile and StringData =3D=3D ModuleNameStr: StringData =3D "$(MODULE_NAME)" - OutputFile =3D os.path.join( OutputPath, ModuleName + SUP_= MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + S= ectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) @@ -189,15 +200,16 @@ class EfiSection (EfiSectionClassObject): elif FileList !=3D []: for File in FileList: Index =3D Index + 1 - Num =3D '%s.%d' %(SecNum, Index) - OutputFile =3D os.path.join(OutputPath, ModuleName + S= UP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) + Num =3D '%s.%d' % (SecNum, Index) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + Num + Se= ctionSuffix.get(SectionType)) f =3D open(File, 'r') UiString =3D f.read() f.close() if IsMakefile and UiString =3D=3D ModuleNameStr: UiString =3D "$(MODULE_NAME)" GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_USER_INTERFACE', - Ui=3DUiString, IsM= akefile=3DIsMakefile) + Ui=3DUiString, Is= Makefile=3DIsMakefile) OutputFileList.append(OutputFile) else: if StringData is not None and len(StringData) > 0: @@ -205,16 +217,19 @@ class EfiSection (EfiSectionClassObject): else: UiTuple =3D tuple() =20 - if self.Optional =3D=3D True : - GenFdsGlobalVariable.VerboseLogger( "Optional Sect= ion don't exist!") + if self.Optional =3D=3D True: + GenFdsGlobalVariable.VerboseLogger( + "Optional Section don't exist!") return '', None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss UI Section value" %InfFileName) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "File: %s miss UI Sect= ion value" % InfFileName) =20 Num =3D SecNum if IsMakefile and StringData =3D=3D ModuleNameStr: StringData =3D "$(MODULE_NAME)" - OutputFile =3D os.path.join( OutputPath, ModuleName + SUP_= MODULE_SEC + str(Num) + SectionSuffix.get(SectionType)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + S= ectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) @@ -226,15 +241,17 @@ class EfiSection (EfiSectionClassObject): """If File List is empty""" if FileList =3D=3D []: if self.Optional =3D=3D True: - GenFdsGlobalVariable.VerboseLogger("Optional Section d= on't exist!") + GenFdsGlobalVariable.VerboseLogger( + "Optional Section don't exist!") return [], None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Output file f= or %s section could not be found for %s" % (SectionType, InfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "Output file f= or %s section could not be found for %s" % ( + SectionType, InfFileName)) =20 elif len(FileList) > 1: EdkLogger.error("GenFds", GENFDS_ERROR, "Files suffixed with %s are not allowed to= have more than one file in %s[Binaries] section" % ( - self.FileExtension, InfFileName)) + self.FileExtension, InfFileName)) else: for File in FileList: File =3D GenFdsGlobalVariable.MacroExtend(File, Dict) @@ -242,77 +259,89 @@ class EfiSection (EfiSectionClassObject): =20 else: """If File List is empty""" - if FileList =3D=3D [] : + if FileList =3D=3D []: if self.Optional =3D=3D True: - GenFdsGlobalVariable.VerboseLogger("Optional Section d= on't exist!") + GenFdsGlobalVariable.VerboseLogger( + "Optional Section don't exist!") return [], None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Output file f= or %s section could not be found for %s" % (SectionType, InfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "Output file f= or %s section could not be found for %s" % ( + SectionType, InfFileName)) =20 else: """Convert the File to Section file one by one """ for File in FileList: """ Copy Map file to FFS output path """ Index =3D Index + 1 - Num =3D '%s.%d' %(SecNum, Index) - OutputFile =3D os.path.join( OutputPath, ModuleName + = SUP_MODULE_SEC + Num + SectionSuffix.get(SectionType)) + Num =3D '%s.%d' % (SecNum, Index) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + Num + Se= ctionSuffix.get(SectionType)) File =3D GenFdsGlobalVariable.MacroExtend(File, Dict) =20 - #Get PE Section alignment when align is set to AUTO + # Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and (SectionType =3D= =3D BINARY_FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): Align =3D "0" if File[(len(File)-4):] =3D=3D '.efi' and FfsInf.InfMo= dule.BaseName =3D=3D os.path.basename(File)[:-4]: MapFile =3D File.replace('.efi', '.map') - CopyMapFile =3D os.path.join(OutputPath, ModuleNam= e + '.map') + CopyMapFile =3D os.path.join( + OutputPath, ModuleName + '.map') if IsMakefile: if GenFdsGlobalVariable.CopyList =3D=3D []: - GenFdsGlobalVariable.CopyList =3D [(MapFil= e, CopyMapFile)] + GenFdsGlobalVariable.CopyList =3D [ + (MapFile, CopyMapFile)] else: - GenFdsGlobalVariable.CopyList.append((MapF= ile, CopyMapFile)) + GenFdsGlobalVariable.CopyList.append( + (MapFile, CopyMapFile)) else: if os.path.exists(MapFile): if not os.path.exists(CopyMapFile) or \ - (os.path.getmtime(MapFile) > os.pat= h.getmtime(CopyMapFile)): + (os.path.getmtime(MapFile) > os.pa= th.getmtime(CopyMapFile)): CopyLongFilePath(MapFile, CopyMapFile) =20 if not NoStrip: - FileBeforeStrip =3D os.path.join(OutputPath, Modul= eName + '.efi') + FileBeforeStrip =3D os.path.join( + OutputPath, ModuleName + '.efi') if IsMakefile: if GenFdsGlobalVariable.CopyList =3D=3D []: - GenFdsGlobalVariable.CopyList =3D [(File, = FileBeforeStrip)] + GenFdsGlobalVariable.CopyList =3D [ + (File, FileBeforeStrip)] else: - GenFdsGlobalVariable.CopyList.append((File= , FileBeforeStrip)) + GenFdsGlobalVariable.CopyList.append( + (File, FileBeforeStrip)) else: if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(File) > os.path.getmtime= (FileBeforeStrip)): + (os.path.getmtime(File) > os.path.getm= time(FileBeforeStrip)): CopyLongFilePath(File, FileBeforeStrip) - StrippedFile =3D os.path.join(OutputPath, ModuleNa= me + '.stripped') + StrippedFile =3D os.path.join( + OutputPath, ModuleName + '.stripped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue, - IsMakefile =3D IsMakefile - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) File =3D StrippedFile =20 """For TE Section call GenFw to generate TE image""" =20 if SectionType =3D=3D BINARY_FILE_TYPE_TE: - TeFile =3D os.path.join( OutputPath, ModuleName + = 'Te.raw') + TeFile =3D os.path.join( + OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te', - IsMakefile =3D IsMakefile - ) + TeFile, + [File], + Type=3D'te', + IsMakefile=3DIsMakefile + ) File =3D TeFile =20 """Call GenSection""" GenFdsGlobalVariable.GenerateSection(OutputFile, - [File], - Section.Section.Se= ctionType.get (SectionType), - IsMakefile=3DIsMak= efile - ) + [File], + Section.Section.S= ectionType.get( + SectionType), + IsMakefile=3DIsMa= kefile + ) OutputFileList.append(OutputFile) =20 return OutputFileList, Align diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python= /GenFds/Fd.py index 973936b6f273..03196f8b0d60 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -1,4 +1,4 @@ -## @file +# @file # process FD generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -23,40 +23,46 @@ from Common.BuildToolError import * from Common.Misc import SaveFileOnChange from Common.DataType import BINARY_FILE_TYPE_FV =20 -## generate FD +# generate FD # # + + class FD(FDClassObject): - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): FDClassObject.__init__(self) =20 - ## GenFd() method + # GenFd() method # # Generate FD # # @retval string Generated FD file name # - def GenFd (self, Flag =3D False): + def GenFd(self, Flag=3DFalse): if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDi= ct: return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper()= + 'fd'] =20 # # Print Information # - FdFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, self.FdUiN= ame + '.fd') + FdFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.FdUiName + '.fd') if not Flag: - GenFdsGlobalVariable.InfLogger("\nFd File Name:%s (%s)" %(self= .FdUiName, FdFileName)) + GenFdsGlobalVariable.InfLogger( + "\nFd File Name:%s (%s)" % (self.FdUiName, FdFileName)) =20 Offset =3D 0x00 for item in self.BlockSizeList: - Offset =3D Offset + item[0] * item[1] + Offset =3D Offset + item[0] * item[1] if Offset !=3D self.Size: - EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s Size not consis= tent with block array' % self.FdUiName) - GenFdsGlobalVariable.VerboseLogger('Following Fv will be add to Fd= !!!') + EdkLogger.error( + "GenFds", GENFDS_ERROR, 'FD %s Size not consistent with bl= ock array' % self.FdUiName) + GenFdsGlobalVariable.VerboseLogger( + 'Following Fv will be add to Fd !!!') for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict: GenFdsGlobalVariable.VerboseLogger(FvObj) =20 @@ -70,21 +76,23 @@ class FD(FDClassObject): PreviousRegionStart =3D -1 PreviousRegionSize =3D 1 =20 - for RegionObj in self.RegionList : + for RegionObj in self.RegionList: if RegionObj.RegionType =3D=3D 'CAPSULE': continue if RegionObj.Offset + RegionObj.Size <=3D PreviousRegionSt= art: pass - elif RegionObj.Offset <=3D PreviousRegionStart or (RegionO= bj.Offset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStar= t + PreviousRegionSize): + elif RegionObj.Offset <=3D PreviousRegionStart or (RegionO= bj.Offset >=3D PreviousRegionStart and RegionObj.Offset < PreviousRegionSta= rt + PreviousRegionSize): pass elif RegionObj.Offset > PreviousRegionStart + PreviousRegi= onSize: if not Flag: - GenFdsGlobalVariable.InfLogger('Padding region sta= rting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousReg= ionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + GenFdsGlobalVariable.InfLogger('Padding region sta= rting from offset 0x%X, with size 0x%X' % ( + PreviousRegionStart + PreviousRegionSize, Regi= onObj.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousReg= ionSize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset if not Flag: - PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDi= ct, self.DefineVarDict) + PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, + self.ErasePolarity, GenFdsGl= obalVariable.ImageBinDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # @@ -92,29 +100,33 @@ class FD(FDClassObject): # if PreviousRegionSize > self.Size: pass - GenFdsGlobalVariable.VerboseLogger('Call each region\'s Ad= dToBuffer function') - RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, sel= f.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, sel= f.DefineVarDict) + GenFdsGlobalVariable.VerboseLogger( + 'Call each region\'s AddToBuffer function') + RegionObj.AddToBuffer(TempFdBuffer, self.BaseAddress, self= .BlockSizeList, + self.ErasePolarity, GenFdsGlobalVari= able.ImageBinDict, self.DefineVarDict) =20 FdBuffer =3D BytesIO() PreviousRegionStart =3D -1 PreviousRegionSize =3D 1 - for RegionObj in self.RegionList : + for RegionObj in self.RegionList: if RegionObj.Offset + RegionObj.Size <=3D PreviousRegionStart: EdkLogger.error("GenFds", GENFDS_ERROR, - 'Region offset 0x%X in wrong order with Re= gion starting from 0x%X, size 0x%X\nRegions in FDF must have offsets appear= in ascending order.'\ + 'Region offset 0x%X in wrong order with Re= gion starting from 0x%X, size 0x%X\nRegions in FDF must have offsets appear= in ascending order.' % (RegionObj.Offset, PreviousRegionStart, = PreviousRegionSize)) - elif RegionObj.Offset <=3D PreviousRegionStart or (RegionObj.O= ffset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStart + = PreviousRegionSize): + elif RegionObj.Offset <=3D PreviousRegionStart or (RegionObj.O= ffset >=3D PreviousRegionStart and RegionObj.Offset < PreviousRegionStart += PreviousRegionSize): EdkLogger.error("GenFds", GENFDS_ERROR, - 'Region offset 0x%X overlaps with Region s= tarting from 0x%X, size 0x%X' \ + 'Region offset 0x%X overlaps with Region s= tarting from 0x%X, size 0x%X' % (RegionObj.Offset, PreviousRegionStart, = PreviousRegionSize)) elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSi= ze: if not Flag: - GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionS= ize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' % ( + PreviousRegionStart + PreviousRegionSize, RegionOb= j.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousRegionS= ize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset if not Flag: - PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self= .DefineVarDict) + PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, + self.ErasePolarity, GenFdsGlobal= Variable.ImageBinDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # @@ -127,29 +139,25 @@ class FD(FDClassObject): # # Call each region's AddToBuffer function # - GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToB= uffer function') - RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.Define= VarDict, Flag=3DFlag) + GenFdsGlobalVariable.VerboseLogger( + 'Call each region\'s AddToBuffer function') + RegionObj.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSi= zeList, self.ErasePolarity, + GenFdsGlobalVariable.ImageBinDict, self.= DefineVarDict, Flag=3DFlag) # # Write the buffer contents to Fd file # - GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to F= d file') + GenFdsGlobalVariable.VerboseLogger( + 'Write the buffer contents to Fd file') if not Flag: SaveFileOnChange(FdFileName, FdBuffer.getvalue()) FdBuffer.close() - GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd'] = =3D FdFileName + GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper( + ) + 'fd'] =3D FdFileName return FdFileName =20 - ## generate flash map file + # generate flash map file # # @param self The object pointer # - def GenFlashMap (self): + def GenFlashMap(self): pass - - - - - - - - diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 5c8263f9bcc9..0b83d3b98c50 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1,4 +1,4 @@ -## @file +# @file # parse FDF file # # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
        @@ -58,37 +58,47 @@ T_CHAR_DOUBLE_QUOTE =3D '\"' T_CHAR_SINGLE_QUOTE =3D '\'' T_CHAR_BRACE_R =3D '}' =20 -SEPARATORS =3D {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', T_= CHAR_BRACE_R} +SEPARATORS =3D {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, + TAB_COMMA_SPLIT, '{', T_CHAR_BRACE_R} ALIGNMENTS =3D {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "= 32K", "64K", "128K", - "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"} + "256K", "512K", "1M", "2M", "4M", "8M", "16M"} ALIGNMENT_NOAUTO =3D ALIGNMENTS - {"Auto"} CR_LB_SET =3D {T_CHAR_CR, TAB_LINE_BREAK} =20 -RegionSizePattern =3D compile("\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*= (?P(?:0x|0X)?[a-fA-F0-9]+)\s*") -RegionSizeGuidPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s= *(?P\w+\.\w+[\.\w\[\]]*)\s*") +RegionSizePattern =3D compile( + "\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P(?:0x|0X)?[a-fA-F= 0-9]+)\s*") +RegionSizeGuidPattern =3D compile( + "\s*(?P\w+\.\w+[\.\w\[\]]*)\s*\|\s*(?P\w+\.\w+[\.\w\[\]]*)= \s*") RegionOffsetPcdPattern =3D compile("\s*(?P\w+\.\w+[\.\w\[\]]*)\s*$") -ShortcutPcdPattern =3D compile("\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-F= 0-9]+)\s*\|\s*(?P\w+\.\w+)\s*") +ShortcutPcdPattern =3D compile( + "\s*\w+\s*=3D\s*(?P(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P\w+\= .\w+)\s*") BaseAddrValuePattern =3D compile('^0[xX][0-9a-fA-F]+') FileExtensionPattern =3D compile(r'([a-zA-Z][a-zA-Z0-9]*)') -TokenFindPattern =3D compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-= 9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') +TokenFindPattern =3D compile( + r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\= )|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)') AllIncludeFileList =3D [] =20 # Get the closest parent -def GetParentAtLine (Line): + + +def GetParentAtLine(Line): for Profile in AllIncludeFileList: if Profile.IsLineInFile(Line): return Profile return None =20 # Check include loop -def IsValidInclude (File, Line): + + +def IsValidInclude(File, Line): for Profile in AllIncludeFileList: if Profile.IsLineInFile(Line) and Profile.FileName =3D=3D File: return False =20 return True =20 -def GetRealFileLine (File, Line): + +def GetRealFileLine(File, Line): InsertedLines =3D 0 for Profile in AllIncludeFileList: if Profile.IsLineInFile(Line): @@ -98,19 +108,21 @@ def GetRealFileLine (File, Line): =20 return (File, Line - InsertedLines) =20 -## The exception class that used to report error messages when parsing FDF +# The exception class that used to report error messages when parsing FDF # # Currently the "ToolName" is set to be "FdfParser". # + + class Warning (Exception): - ## The constructor + # The constructor # # @param self The object pointer # @param Str The message to record # @param File The FDF name # @param Line The Line number that error occurs # - def __init__(self, Str, File =3D None, Line =3D None): + def __init__(self, Str, File=3DNone, Line=3DNone): FileLineTuple =3D GetRealFileLine(File, Line) self.FileName =3D FileLineTuple[0] self.LineNumber =3D FileLineTuple[1] @@ -126,25 +138,31 @@ class Warning (Exception): @staticmethod def Expected(Str, File, Line): return Warning("expected {}".format(Str), File, Line) + @staticmethod def ExpectedEquals(File, Line): return Warning.Expected("'=3D'", File, Line) + @staticmethod def ExpectedCurlyOpen(File, Line): return Warning.Expected("'{'", File, Line) + @staticmethod def ExpectedCurlyClose(File, Line): return Warning.Expected("'}'", File, Line) + @staticmethod def ExpectedBracketClose(File, Line): return Warning.Expected("']'", File, Line) =20 -## The Include file content class that used to record file data when parsi= ng include file +# The Include file content class that used to record file data when parsin= g include file # # May raise Exception when opening file. # + + class IncludeFileProfile: - ## The constructor + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed @@ -164,7 +182,7 @@ class IncludeFileProfile: self.InsertStartLineNumber =3D None self.InsertAdjust =3D 0 self.IncludeFileList =3D [] - self.Level =3D 1 # first level include file + self.Level =3D 1 # first level include file =20 def GetTotalLines(self): TotalLines =3D self.InsertAdjust + len(self.FileLinesList) @@ -181,7 +199,7 @@ class IncludeFileProfile: return False =20 def GetLineInFile(self, Line): - if not self.IsLineInFile (Line): + if not self.IsLineInFile(Line): return (self.FileName, -1) =20 InsertedLines =3D self.InsertStartLineNumber @@ -194,12 +212,14 @@ class IncludeFileProfile: =20 return (self.FileName, Line - InsertedLines + 1) =20 -## The FDF content class that used to record file data when parsing FDF +# The FDF content class that used to record file data when parsing FDF # # May raise Exception when opening file. # + + class FileProfile: - ## The constructor + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed @@ -217,7 +237,7 @@ class FileProfile: self.PcdDict =3D OrderedDict() self.PcdLocalDict =3D OrderedDict() self.InfList =3D [] - self.InfDict =3D {'ArchTBD':[]} + self.InfDict =3D {'ArchTBD': []} # ECC will use this Dict and List information self.PcdFileLineDict =3D {} self.InfFileLineList =3D [] @@ -230,7 +250,7 @@ class FileProfile: self.OptRomDict =3D {} self.FmpPayloadDict =3D {} =20 -## The syntax parser for FDF +# The syntax parser for FDF # # PreprocessFile method should be called prior to ParseFile # CycleReferenceCheck method can detect cycles in FDF contents @@ -238,8 +258,10 @@ class FileProfile: # GetNext*** procedures mean these procedures will get next token first, t= hen make judgement. # Get*** procedures mean these procedures will make judgement on current t= oken only. # + + class FdfParser: - ## The constructor + # The constructor # # @param self The object pointer # @param FileName The file that to be parsed @@ -266,7 +288,7 @@ class FdfParser: if GenFdsGlobalVariable.WorkSpaceDir =3D=3D '': GenFdsGlobalVariable.WorkSpaceDir =3D os.getenv("WORKSPACE") =20 - ## _SkipWhiteSpace() method + # _SkipWhiteSpace() method # # Skip white spaces from current char. # @@ -281,7 +303,7 @@ class FdfParser: return return =20 - ## _EndOfFile() method + # _EndOfFile() method # # Judge current buffer pos is at file end # @@ -298,7 +320,7 @@ class FdfParser: return True return False =20 - ## _EndOfLine() method + # _EndOfLine() method # # Judge current buffer pos is at line end # @@ -309,12 +331,13 @@ class FdfParser: def _EndOfLine(self): if self.CurrentLineNumber > len(self.Profile.FileLinesList): return True - SizeOfCurrentLine =3D len(self.Profile.FileLinesList[self.CurrentL= ineNumber - 1]) + SizeOfCurrentLine =3D len( + self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if self.CurrentOffsetWithinLine >=3D SizeOfCurrentLine: return True return False =20 - ## Rewind() method + # Rewind() method # # Reset file data buffer to the initial state # @@ -322,11 +345,11 @@ class FdfParser: # @param DestLine Optional new destination line number. # @param DestOffset Optional new destination offset. # - def Rewind(self, DestLine =3D 1, DestOffset =3D 0): + def Rewind(self, DestLine=3D1, DestOffset=3D0): self.CurrentLineNumber =3D DestLine self.CurrentOffsetWithinLine =3D DestOffset =20 - ## _UndoOneChar() method + # _UndoOneChar() method # # Go back one char in the file buffer # @@ -344,7 +367,7 @@ class FdfParser: self.CurrentOffsetWithinLine -=3D 1 return True =20 - ## _GetOneChar() method + # _GetOneChar() method # # Move forward one char in the file buffer # @@ -357,7 +380,7 @@ class FdfParser: else: self.CurrentOffsetWithinLine +=3D 1 =20 - ## _CurrentChar() method + # _CurrentChar() method # # Get the char pointed to by the file buffer pointer # @@ -367,7 +390,7 @@ class FdfParser: def _CurrentChar(self): return self.Profile.FileLinesList[self.CurrentLineNumber - 1][self= .CurrentOffsetWithinLine] =20 - ## _NextChar() method + # _NextChar() method # # Get the one char pass the char pointed to by the file buffer point= er # @@ -379,7 +402,7 @@ class FdfParser: return self.Profile.FileLinesList[self.CurrentLineNumber][0] return self.Profile.FileLinesList[self.CurrentLineNumber - 1][self= .CurrentOffsetWithinLine + 1] =20 - ## _SetCurrentCharValue() method + # _SetCurrentCharValue() method # # Modify the value of current char # @@ -387,9 +410,10 @@ class FdfParser: # @param Value The new value of current char # def _SetCurrentCharValue(self, Value): - self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.Curren= tOffsetWithinLine] =3D Value + self.Profile.FileLinesList[self.CurrentLineNumber - + 1][self.CurrentOffsetWithinLine] =3D Va= lue =20 - ## _CurrentLine() method + # _CurrentLine() method # # Get the list that contains current line contents # @@ -400,12 +424,14 @@ class FdfParser: return self.Profile.FileLinesList[self.CurrentLineNumber - 1] =20 def _StringToList(self): - self.Profile.FileLinesList =3D [list(s) for s in self.Profile.File= LinesList] + self.Profile.FileLinesList =3D [list(s) + for s in self.Profile.FileLinesList] if not self.Profile.FileLinesList: - EdkLogger.error('FdfParser', FILE_READ_FAILURE, 'The file is e= mpty!', File=3Dself.FileName) + EdkLogger.error('FdfParser', FILE_READ_FAILURE, + 'The file is empty!', File=3Dself.FileName) self.Profile.FileLinesList[-1].append(' ') =20 - def _ReplaceFragment(self, StartPos, EndPos, Value =3D ' '): + def _ReplaceFragment(self, StartPos, EndPos, Value=3D' '): if StartPos[0] =3D=3D EndPos[0]: Offset =3D StartPos[1] while Offset <=3D EndPos[1]: @@ -437,9 +463,11 @@ class FdfParser: =20 MacroDict =3D {} if not self._MacroDict[self._CurSection[0], self._CurSection[1], s= elf._CurSection[2]]: - self._MacroDict[self._CurSection[0], self._CurSection[1], self= ._CurSection[2]] =3D MacroDict + self._MacroDict[self._CurSection[0], + self._CurSection[1], self._CurSection[2]] =3D = MacroDict else: - MacroDict =3D self._MacroDict[self._CurSection[0], self._CurSe= ction[1], self._CurSection[2]] + MacroDict =3D self._MacroDict[self._CurSection[0], + self._CurSection[1], self._CurSect= ion[2]] MacroDict[Macro] =3D Value =20 def _GetMacroValue(self, Macro): @@ -451,9 +479,9 @@ class FdfParser: =20 if self._CurSection: MacroDict =3D self._MacroDict[ - self._CurSection[0], - self._CurSection[1], - self._CurSection[2] + self._CurSection[0], + self._CurSection[1], + self._CurSection[2] ] if MacroDict and Macro in MacroDict: return MacroDict[Macro] @@ -471,7 +499,8 @@ class FdfParser: # [Rule]: don't take rule section into account, macro is not allow= ed in this section # [OptionRom.DriverName] self._CurSection =3D [] - Section =3D Section.strip()[1:-1].upper().replace(' ', '').strip(T= AB_SPLIT) + Section =3D Section.strip( + )[1:-1].upper().replace(' ', '').strip(TAB_SPLIT) ItemList =3D Section.split(TAB_SPLIT) Item =3D ItemList[0] if Item =3D=3D '' or Item =3D=3D 'RULE': @@ -484,7 +513,7 @@ class FdfParser: elif len(ItemList) > 0: self._CurSection =3D [ItemList[0], 'DUMMY', TAB_COMMON] =20 - ## PreprocessFile() method + # PreprocessFile() method # # Preprocess file contents, replace comments with spaces. # In the end, rewind the file buffer pointer to the beginning @@ -545,10 +574,11 @@ class FdfParser: self._GetOneChar() =20 # restore from ListOfList to ListOfString - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] + self.Profile.FileLinesList =3D [ + "".join(list) for list in self.Profile.FileLinesList] self.Rewind() =20 - ## PreprocessIncludeFile() method + # PreprocessIncludeFile() method # # Preprocess file contents, replace !include statements with file co= ntents. # In the end, rewind the file buffer pointer to the beginning @@ -563,10 +593,12 @@ class FdfParser: =20 if self._Token =3D=3D TAB_DEFINE: if not self._GetNextToken(): - raise Warning.Expected("Macro name", self.FileName, se= lf.CurrentLineNumber) + raise Warning.Expected( + "Macro name", self.FileName, self.CurrentLineNumbe= r) Macro =3D self._Token if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) Value =3D self._GetExpression() MacroDict[Macro] =3D Value =20 @@ -575,7 +607,8 @@ class FdfParser: IncludeLine =3D self.CurrentLineNumber IncludeOffset =3D self.CurrentOffsetWithinLine - len(TAB_I= NCLUDE) if not self._GetNextToken(): - raise Warning.Expected("include file name", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "include file name", self.FileName, self.CurrentLi= neNumber) IncFileName =3D self._Token PreIndex =3D 0 StartPos =3D IncFileName.find('$(', PreIndex) @@ -587,13 +620,15 @@ class FdfParser: if Macro in MacroDict: MacroVal =3D MacroDict[Macro] if MacroVal is not None: - IncFileName =3D IncFileName.replace('$(' + Macro += ')', MacroVal, 1) + IncFileName =3D IncFileName.replace( + '$(' + Macro + ')', MacroVal, 1) if MacroVal.find('$(') !=3D -1: PreIndex =3D StartPos else: PreIndex =3D StartPos + len(MacroVal) else: - raise Warning("The Macro %s is not defined" %Macro= , self.FileName, self.CurrentLineNumber) + raise Warning("The Macro %s is not defined" % + Macro, self.FileName, self.CurrentLi= neNumber) StartPos =3D IncFileName.find('$(', PreIndex) EndPos =3D IncFileName.find(')', StartPos+2) =20 @@ -601,7 +636,8 @@ class FdfParser: # # First search the include file under the same directory a= s FDF file # - IncludedFile1 =3D PathClass(IncludedFile, os.path.dirname(= self.FileName)) + IncludedFile1 =3D PathClass( + IncludedFile, os.path.dirname(self.FileName)) ErrorCode =3D IncludedFile1.Validate()[0] if ErrorCode !=3D 0: # @@ -618,14 +654,16 @@ class FdfParser: # # Also search file under the WORKSPACE directory # - IncludedFile1 =3D PathClass(IncludedFile, GlobalDa= ta.gWorkspace) + IncludedFile1 =3D PathClass( + IncludedFile, GlobalData.gWorkspace) ErrorCode =3D IncludedFile1.Validate()[0] if ErrorCode !=3D 0: - raise Warning("The include file does not exist= under below directories: \n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), = PlatformDir, GlobalData.gWorkspace), + raise Warning("The include file does not exist= under below directories: \n%s\n%s\n%s\n" % (os.path.dirname(self.FileName)= , PlatformDir, GlobalData.gWorkspace), self.FileName, self.CurrentLineN= umber) =20 - if not IsValidInclude (IncludedFile1.Path, self.CurrentLin= eNumber): - raise Warning("The include file {0} is causing a inclu= de loop.\n".format (IncludedFile1.Path), self.FileName, self.CurrentLineNum= ber) + if not IsValidInclude(IncludedFile1.Path, self.CurrentLine= Number): + raise Warning("The include file {0} is causing a inclu= de loop.\n".format( + IncludedFile1.Path), self.FileName, self.CurrentLi= neNumber) =20 IncFileProfile =3D IncludeFileProfile(IncludedFile1.Path) =20 @@ -633,7 +671,7 @@ class FdfParser: CurrentOffset =3D self.CurrentOffsetWithinLine # list index of the insertion, note that line number is 'C= urrentLine + 1' InsertAtLine =3D CurrentLine - ParentProfile =3D GetParentAtLine (CurrentLine) + ParentProfile =3D GetParentAtLine(CurrentLine) if ParentProfile is not None: ParentProfile.IncludeFileList.insert(0, IncFileProfile) IncFileProfile.Level =3D ParentProfile.Level + 1 @@ -642,7 +680,8 @@ class FdfParser: if self._GetNextToken(): if self.CurrentLineNumber =3D=3D CurrentLine: RemainingLine =3D self._CurrentLine()[CurrentOffse= t:] - self.Profile.FileLinesList.insert(self.CurrentLine= Number, RemainingLine) + self.Profile.FileLinesList.insert( + self.CurrentLineNumber, RemainingLine) IncFileProfile.InsertAdjust +=3D 1 self.CurrentLineNumber +=3D 1 self.CurrentOffsetWithinLine =3D 0 @@ -659,8 +698,8 @@ class FdfParser: TempList =3D list(self.Profile.FileLinesList[IncludeLine -= 1]) TempList.insert(IncludeOffset, TAB_COMMENT_SPLIT) self.Profile.FileLinesList[IncludeLine - 1] =3D ''.join(Te= mpList) - if Processed: # Nested and back-to-back support - self.Rewind(DestLine =3D IncFileProfile.InsertStartLineNum= ber - 1) + if Processed: # Nested and back-to-back support + self.Rewind(DestLine=3DIncFileProfile.InsertStartLineNumbe= r - 1) Processed =3D False # Preprocess done. self.Rewind() @@ -676,7 +715,7 @@ class FdfParser: =20 return True =20 - ## PreprocessConditionalStatement() method + # PreprocessConditionalStatement() method # # Preprocess conditional statement. # In the end, rewind the file buffer pointer to the beginning @@ -697,7 +736,8 @@ class FdfParser: self._SkipToToken(TAB_SECTION_END) Header +=3D self._SkippedChars if Header.find('$(') !=3D -1: - raise Warning("macro cannot be used in section hea= der", self.FileName, self.CurrentLineNumber) + raise Warning( + "macro cannot be used in section header", self= .FileName, self.CurrentLineNumber) self._SectionHeaderParser(Header) continue # Replace macros except in RULE section or out of section @@ -712,7 +752,8 @@ class FdfParser: MacroName =3D CurLine[StartPos+2: EndPos] MacroValue =3D self._GetMacroValue(MacroName) if MacroValue is not None: - CurLine =3D CurLine.replace('$(' + MacroName += ')', MacroValue, 1) + CurLine =3D CurLine.replace( + '$(' + MacroName + ')', MacroValue, 1) if MacroValue.find('$(') !=3D -1: PreIndex =3D StartPos else: @@ -727,18 +768,23 @@ class FdfParser: if self._Token =3D=3D TAB_DEFINE: if self._GetIfListCurrentItemStat(IfList): if not self._CurSection: - raise Warning("macro cannot be defined in Rule sec= tion or out of section", self.FileName, self.CurrentLineNumber) + raise Warning( + "macro cannot be defined in Rule section or ou= t of section", self.FileName, self.CurrentLineNumber) DefineLine =3D self.CurrentLineNumber - 1 - DefineOffset =3D self.CurrentOffsetWithinLine - len(TA= B_DEFINE) + DefineOffset =3D self.CurrentOffsetWithinLine - \ + len(TAB_DEFINE) if not self._GetNextToken(): - raise Warning.Expected("Macro name", self.FileName= , self.CurrentLineNumber) + raise Warning.Expected( + "Macro name", self.FileName, self.CurrentLineN= umber) Macro =3D self._Token if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 Value =3D self._GetExpression() self._SetMacroValue(Macro, Value) - self._WipeOffArea.append(((DefineLine, DefineOffset), = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + ((DefineLine, DefineOffset), (self.CurrentLineNumb= er - 1, self.CurrentOffsetWithinLine - 1))) elif self._Token =3D=3D 'SET': if not self._GetIfListCurrentItemStat(IfList): continue @@ -747,91 +793,115 @@ class FdfParser: PcdPair =3D self._GetNextPcdSettings() PcdName =3D "%s.%s" % (PcdPair[1], PcdPair[0]) if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 Value =3D self._GetExpression() - Value =3D self._EvaluateConditional(Value, self.CurrentLin= eNumber, 'eval', True) + Value =3D self._EvaluateConditional( + Value, self.CurrentLineNumber, 'eval', True) =20 self._PcdDict[PcdName] =3D Value =20 self.Profile.PcdDict[PcdPair] =3D Value self.SetPcdLocalation(PcdPair) - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[PcdPair] =3D FileLineTuple =20 - self._WipeOffArea.append(((SetLine, SetOffset), (self.Curr= entLineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + ((SetLine, SetOffset), (self.CurrentLineNumber - 1, se= lf.CurrentOffsetWithinLine - 1))) elif self._Token in {TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF}: - IfStartPos =3D (self.CurrentLineNumber - 1, self.CurrentOf= fsetWithinLine - len(self._Token)) + IfStartPos =3D (self.CurrentLineNumber - 1, + self.CurrentOffsetWithinLine - len(self._Tok= en)) IfList.append([IfStartPos, None, None]) =20 CondLabel =3D self._Token Expression =3D self._GetExpression() =20 if CondLabel =3D=3D TAB_IF: - ConditionSatisfied =3D self._EvaluateConditional(Expre= ssion, IfList[-1][0][0] + 1, 'eval') + ConditionSatisfied =3D self._EvaluateConditional( + Expression, IfList[-1][0][0] + 1, 'eval') else: - ConditionSatisfied =3D self._EvaluateConditional(Expre= ssion, IfList[-1][0][0] + 1, 'in') + ConditionSatisfied =3D self._EvaluateConditional( + Expression, IfList[-1][0][0] + 1, 'in') if CondLabel =3D=3D TAB_IF_N_DEF: ConditionSatisfied =3D not ConditionSatisfied =20 BranchDetermined =3D ConditionSatisfied - IfList[-1] =3D [IfList[-1][0], ConditionSatisfied, BranchD= etermined] + IfList[-1] =3D [IfList[-1][0], + ConditionSatisfied, BranchDetermined] if ConditionSatisfied: - self._WipeOffArea.append((IfList[-1][0], (self.Current= LineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + (IfList[-1][0], (self.CurrentLineNumber - 1, self.= CurrentOffsetWithinLine - 1))) elif self._Token in {TAB_ELSE_IF, TAB_ELSE}: - ElseStartPos =3D (self.CurrentLineNumber - 1, self.Current= OffsetWithinLine - len(self._Token)) + ElseStartPos =3D (self.CurrentLineNumber - 1, + self.CurrentOffsetWithinLine - len(self._T= oken)) if len(IfList) <=3D 0: - raise Warning("Missing !if statement", self.FileName, = self.CurrentLineNumber) + raise Warning("Missing !if statement", + self.FileName, self.CurrentLineNumber) =20 if IfList[-1][1]: IfList[-1] =3D [ElseStartPos, False, True] - self._WipeOffArea.append((ElseStartPos, (self.CurrentL= ineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + (ElseStartPos, (self.CurrentLineNumber - 1, self.C= urrentOffsetWithinLine - 1))) else: self._WipeOffArea.append((IfList[-1][0], ElseStartPos)) IfList[-1] =3D [ElseStartPos, True, IfList[-1][2]] if self._Token =3D=3D TAB_ELSE_IF: Expression =3D self._GetExpression() - ConditionSatisfied =3D self._EvaluateConditional(E= xpression, IfList[-1][0][0] + 1, 'eval') - IfList[-1] =3D [IfList[-1][0], ConditionSatisfied,= IfList[-1][2]] + ConditionSatisfied =3D self._EvaluateConditional( + Expression, IfList[-1][0][0] + 1, 'eval') + IfList[-1] =3D [IfList[-1][0], + ConditionSatisfied, IfList[-1][2]] =20 if IfList[-1][1]: if IfList[-1][2]: IfList[-1][1] =3D False else: IfList[-1][2] =3D True - self._WipeOffArea.append((IfList[-1][0], (self= .CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + (IfList[-1][0], (self.CurrentLineNumber - = 1, self.CurrentOffsetWithinLine - 1))) elif self._Token =3D=3D '!endif': if len(IfList) <=3D 0: - raise Warning("Missing !if statement", self.FileName, = self.CurrentLineNumber) + raise Warning("Missing !if statement", + self.FileName, self.CurrentLineNumber) if IfList[-1][1]: - self._WipeOffArea.append(((self.CurrentLineNumber - 1,= self.CurrentOffsetWithinLine - len('!endif')), (self.CurrentLineNumber - 1= , self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append(((self.CurrentLineNumber - 1,= self.CurrentOffsetWithinLine - len( + '!endif')), (self.CurrentLineNumber - 1, self.Curr= entOffsetWithinLine - 1))) else: - self._WipeOffArea.append((IfList[-1][0], (self.Current= LineNumber - 1, self.CurrentOffsetWithinLine - 1))) + self._WipeOffArea.append( + (IfList[-1][0], (self.CurrentLineNumber - 1, self.= CurrentOffsetWithinLine - 1))) =20 IfList.pop() elif not IfList: # Don't use PCDs inside conditional direct= ive if self.CurrentLineNumber <=3D RegionLayoutLine: # Don't try the same line twice continue - SetPcd =3D ShortcutPcdPattern.match(self.Profile.FileLines= List[self.CurrentLineNumber - 1]) + SetPcd =3D ShortcutPcdPattern.match( + self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if SetPcd: self._PcdDict[SetPcd.group('name')] =3D SetPcd.group('= value') RegionLayoutLine =3D self.CurrentLineNumber continue - RegionSize =3D RegionSizePattern.match(self.Profile.FileLi= nesList[self.CurrentLineNumber - 1]) + RegionSize =3D RegionSizePattern.match( + self.Profile.FileLinesList[self.CurrentLineNumber - 1]) if not RegionSize: RegionLayoutLine =3D self.CurrentLineNumber continue - RegionSizeGuid =3D RegionSizeGuidPattern.match(self.Profil= e.FileLinesList[self.CurrentLineNumber]) + RegionSizeGuid =3D RegionSizeGuidPattern.match( + self.Profile.FileLinesList[self.CurrentLineNumber]) if not RegionSizeGuid: RegionLayoutLine =3D self.CurrentLineNumber + 1 continue - self._PcdDict[RegionSizeGuid.group('base')] =3D RegionSize= .group('base') - self._PcdDict[RegionSizeGuid.group('size')] =3D RegionSize= .group('size') + self._PcdDict[RegionSizeGuid.group( + 'base')] =3D RegionSize.group('base') + self._PcdDict[RegionSizeGuid.group( + 'size')] =3D RegionSize.group('size') RegionLayoutLine =3D self.CurrentLineNumber + 1 =20 if IfList: - raise Warning("Missing !endif", self.FileName, self.CurrentLin= eNumber) + raise Warning("Missing !endif", self.FileName, + self.CurrentLineNumber) self.Rewind() =20 def _CollectMacroPcd(self): @@ -852,9 +922,9 @@ class FdfParser: =20 # Section macro ScopeMacro =3D self._MacroDict[ - self._CurSection[0], - self._CurSection[1], - self._CurSection[2] + self._CurSection[0], + self._CurSection[1], + self._CurSection[2] ] if ScopeMacro: MacroDict.update(ScopeMacro) @@ -871,7 +941,7 @@ class FdfParser: =20 return MacroDict =20 - def _EvaluateConditional(self, Expression, Line, Op =3D None, Value = =3D None): + def _EvaluateConditional(self, Expression, Line, Op=3DNone, Value=3DNo= ne): MacroPcdDict =3D self._CollectMacroPcd() if Op =3D=3D 'eval': try: @@ -885,8 +955,8 @@ class FdfParser: # the precise number of line and return the evaluation res= ult # EdkLogger.warn('Parser', "Suspicious expression: %s" % str= (Excpt), - File=3Dself.FileName, ExtraData=3Dself._Cu= rrentLine(), - Line=3DLine) + File=3Dself.FileName, ExtraData=3Dself._Cur= rentLine(), + Line=3DLine) return Excpt.result except Exception as Excpt: if hasattr(Excpt, 'Pcd'): @@ -895,7 +965,8 @@ class FdfParser: raise Warning("Cannot use this PCD (%s) in an expr= ession as" " it must be defined in a [PcdsFixed= AtBuild] or [PcdsFeatureFlag] section" " of the DSC file (%s), and it is cu= rrently defined in this section:" - " %s, line #: %d." % (Excpt.Pcd, Glo= balData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]), + " %s, line #: %d." % ( + Excpt.Pcd, GlobalData.gPlatformO= therPcds['DSCFILE'], Info[0], Info[1]), self.FileName, Line) else: raise Warning("PCD (%s) is not defined in DSC file= (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']), @@ -907,7 +978,7 @@ class FdfParser: Expression =3D Expression[2:-1] return Expression in MacroPcdDict =20 - ## _IsToken() method + # _IsToken() method # # Check whether input string is found from current char position alo= ng # If found, the string value is put into self._Token @@ -918,23 +989,26 @@ class FdfParser: # @retval True Successfully find string, file buffer pointer = moved forward # @retval False Not able to find string, file buffer pointer n= ot changed # - def _IsToken(self, String, IgnoreCase =3D False): + def _IsToken(self, String, IgnoreCase=3DFalse): self._SkipWhiteSpace() =20 # Only consider the same line, no multi-line token allowed StartPos =3D self.CurrentOffsetWithinLine index =3D -1 if IgnoreCase: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].= upper().find(String.upper()) + index =3D self._CurrentLine()[self.CurrentOffsetWithinLine:].u= pper().find( + String.upper()) else: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].= find(String) + index =3D self._CurrentLine( + )[self.CurrentOffsetWithinLine:].find(String) if index =3D=3D 0: self.CurrentOffsetWithinLine +=3D len(String) - self._Token =3D self._CurrentLine()[StartPos: self.CurrentOffs= etWithinLine] + self._Token =3D self._CurrentLine( + )[StartPos: self.CurrentOffsetWithinLine] return True return False =20 - ## _IsKeyword() method + # _IsKeyword() method # # Check whether input keyword is found from current char position al= ong, whole word only! # If found, the string value is put into self._Token @@ -945,22 +1019,26 @@ class FdfParser: # @retval True Successfully find string, file buffer pointer = moved forward # @retval False Not able to find string, file buffer pointer n= ot changed # - def _IsKeyword(self, KeyWord, IgnoreCase =3D False): + def _IsKeyword(self, KeyWord, IgnoreCase=3DFalse): self._SkipWhiteSpace() =20 # Only consider the same line, no multi-line token allowed StartPos =3D self.CurrentOffsetWithinLine index =3D -1 if IgnoreCase: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].= upper().find(KeyWord.upper()) + index =3D self._CurrentLine()[self.CurrentOffsetWithinLine:].u= pper().find( + KeyWord.upper()) else: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].= find(KeyWord) + index =3D self._CurrentLine( + )[self.CurrentOffsetWithinLine:].find(KeyWord) if index =3D=3D 0: - followingChar =3D self._CurrentLine()[self.CurrentOffsetWithin= Line + len(KeyWord)] + followingChar =3D self._CurrentLine( + )[self.CurrentOffsetWithinLine + len(KeyWord)] if not str(followingChar).isspace() and followingChar not in S= EPARATORS: return False self.CurrentOffsetWithinLine +=3D len(KeyWord) - self._Token =3D self._CurrentLine()[StartPos: self.CurrentOffs= etWithinLine] + self._Token =3D self._CurrentLine( + )[StartPos: self.CurrentOffsetWithinLine] return True return False =20 @@ -969,12 +1047,13 @@ class FdfParser: Index =3D len(Line) - 1 while Line[Index] in CR_LB_SET: Index -=3D 1 - ExpressionString =3D self.Profile.FileLinesList[self.CurrentLineNu= mber - 1][self.CurrentOffsetWithinLine:Index+1] + ExpressionString =3D self.Profile.FileLinesList[self.CurrentLineNu= mber - + 1][self.CurrentOffse= tWithinLine:Index+1] self.CurrentOffsetWithinLine +=3D len(ExpressionString) ExpressionString =3D ExpressionString.strip() return ExpressionString =20 - ## _GetNextWord() method + # _GetNextWord() method # # Get next C name from file lines # If found, the string value is put into self._Token @@ -995,13 +1074,14 @@ class FdfParser: while not self._EndOfLine(): TempChar =3D self._CurrentChar() if (TempChar >=3D 'a' and TempChar <=3D 'z') or (TempChar = >=3D 'A' and TempChar <=3D 'Z') \ - or (TempChar >=3D '0' and TempChar <=3D '9') or TempChar = =3D=3D '_' or TempChar =3D=3D '-': + or (TempChar >=3D '0' and TempChar <=3D '9') or Te= mpChar =3D=3D '_' or TempChar =3D=3D '-': self._GetOneChar() =20 else: break =20 - self._Token =3D self._CurrentLine()[StartPos: self.CurrentOffs= etWithinLine] + self._Token =3D self._CurrentLine( + )[StartPos: self.CurrentOffsetWithinLine] return True =20 return False @@ -1018,18 +1098,19 @@ class FdfParser: while not self._EndOfLine(): TempChar =3D self._CurrentChar() if (TempChar >=3D 'a' and TempChar <=3D 'z') or (TempChar = >=3D 'A' and TempChar <=3D 'Z') \ - or (TempChar >=3D '0' and TempChar <=3D '9') or TempChar = =3D=3D '_' or TempChar =3D=3D '-' or TempChar =3D=3D TAB_SECTION_START or T= empChar =3D=3D TAB_SECTION_END: + or (TempChar >=3D '0' and TempChar <=3D '9') or Te= mpChar =3D=3D '_' or TempChar =3D=3D '-' or TempChar =3D=3D TAB_SECTION_STA= RT or TempChar =3D=3D TAB_SECTION_END: self._GetOneChar() =20 else: break =20 - self._Token =3D self._CurrentLine()[StartPos: self.CurrentOffs= etWithinLine] + self._Token =3D self._CurrentLine( + )[StartPos: self.CurrentOffsetWithinLine] return True =20 return False =20 - ## _GetNextToken() method + # _GetNextToken() method # # Get next token unit before a separator # If found, the string value is put into self._Token @@ -1073,7 +1154,7 @@ class FdfParser: else: return False =20 - ## _GetNextGuid() method + # _GetNextGuid() method # # Get next token unit before a separator # If found, the GUID string is put into self._Token @@ -1103,14 +1184,17 @@ class FdfParser: try: ValueNumber =3D int(Value, 0) except: - EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not= valid dec or hex number for %s." % Name) + EdkLogger.error("FdfParser", FORMAT_INVALID, + "The value is not valid dec or hex number for = %s." % Name) if ValueNumber < 0: - EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't = be set to negative value for %s." % Name) + EdkLogger.error("FdfParser", FORMAT_INVALID, + "The value can't be set to negative value for = %s." % Name) if ValueNumber > MAX_VAL_TYPE[Scope]: - EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value = for %s." % Name) + EdkLogger.error("FdfParser", FORMAT_INVALID, + "Too large value for %s." % Name) return True =20 - ## _UndoToken() method + # _UndoToken() method # # Go back one token unit in file buffer # @@ -1123,7 +1207,6 @@ class FdfParser: self._GetOneChar() return =20 - StartPos =3D self.CurrentOffsetWithinLine CurrentLine =3D self.CurrentLineNumber while CurrentLine =3D=3D self.CurrentLineNumber: @@ -1143,7 +1226,7 @@ class FdfParser: =20 self._GetOneChar() =20 - ## _GetNextHexNumber() method + # _GetNextHexNumber() method # # Get next HEX data before a separator # If found, the HEX data is put into self._Token @@ -1161,7 +1244,7 @@ class FdfParser: self._UndoToken() return False =20 - ## _GetNextDecimalNumber() method + # _GetNextDecimalNumber() method # # Get next decimal data before a separator # If found, the decimal data is put into self._Token @@ -1181,25 +1264,28 @@ class FdfParser: =20 def _GetNextPcdSettings(self): if not self._GetNextWord(): - raise Warning.Expected("", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "", self.FileName, self.CurrentLineNum= ber) pcdTokenSpaceCName =3D self._Token =20 if not self._IsToken(TAB_SPLIT): raise Warning.Expected(".", self.FileName, self.CurrentLineNum= ber) =20 if not self._GetNextWord(): - raise Warning.Expected("", self.FileName, self.Curre= ntLineNumber) + raise Warning.Expected( + "", self.FileName, self.CurrentLineNumber) pcdCName =3D self._Token =20 Fields =3D [] while self._IsToken(TAB_SPLIT): if not self._GetNextPcdWord(): - raise Warning.Expected("Pcd Fields", self.FileName, self.C= urrentLineNumber) + raise Warning.Expected( + "Pcd Fields", self.FileName, self.CurrentLineNumber) Fields.append(self._Token) =20 - return (pcdCName, pcdTokenSpaceCName,TAB_SPLIT.join(Fields)) + return (pcdCName, pcdTokenSpaceCName, TAB_SPLIT.join(Fields)) =20 - ## _GetStringData() method + # _GetStringData() method # # Get string contents quoted in "" # If found, the decimal data is put into self._Token @@ -1228,7 +1314,7 @@ class FdfParser: self._Token =3D self._SkippedChars.rstrip(QuoteToUse) return True =20 - ## _SkipToToken() method + # _SkipToToken() method # # Search forward in file buffer for the string # The skipped chars are put into self._SkippedChars @@ -1239,16 +1325,18 @@ class FdfParser: # @retval True Successfully find the string, file buffer poin= ter moved forward # @retval False Not able to find the string, file buffer point= er not changed # - def _SkipToToken(self, String, IgnoreCase =3D False): + def _SkipToToken(self, String, IgnoreCase=3DFalse): StartPos =3D self.GetFileBufferPos() =20 self._SkippedChars =3D "" while not self._EndOfFile(): index =3D -1 if IgnoreCase: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine= : ].upper().find(String.upper()) + index =3D self._CurrentLine()[self.CurrentOffsetWithinLine= :].upper().find( + String.upper()) else: - index =3D self._CurrentLine()[self.CurrentOffsetWithinLine= : ].find(String) + index =3D self._CurrentLine( + )[self.CurrentOffsetWithinLine:].find(String) if index =3D=3D 0: self.CurrentOffsetWithinLine +=3D len(String) self._SkippedChars +=3D String @@ -1260,7 +1348,7 @@ class FdfParser: self._SkippedChars =3D "" return False =20 - ## GetFileBufferPos() method + # GetFileBufferPos() method # # Return the tuple of current line and offset within the line # @@ -1270,7 +1358,7 @@ class FdfParser: def GetFileBufferPos(self): return (self.CurrentLineNumber, self.CurrentOffsetWithinLine) =20 - ## SetFileBufferPos() method + # SetFileBufferPos() method # # Restore the file buffer position # @@ -1280,7 +1368,7 @@ class FdfParser: def SetFileBufferPos(self, Pos): (self.CurrentLineNumber, self.CurrentOffsetWithinLine) =3D Pos =20 - ## Preprocess() method + # Preprocess() method # # Preprocess comment, conditional directive, include directive, repl= ace macro. # Exception will be raised if syntax error found @@ -1297,12 +1385,13 @@ class FdfParser: self._StringToList() for Pos in self._WipeOffArea: self._ReplaceFragment(Pos[0], Pos[1]) - self.Profile.FileLinesList =3D ["".join(list) for list in self.Pro= file.FileLinesList] + self.Profile.FileLinesList =3D [ + "".join(list) for list in self.Profile.FileLinesList] =20 while self._GetDefines(): pass =20 - ## ParseFile() method + # ParseFile() method # # Parse the file profile buffer to extract fd, fv ... information # Exception will be raised if syntax error found @@ -1321,19 +1410,20 @@ class FdfParser: =20 except Warning as X: self._UndoToken() - #'\n\tGot Token: \"%s\" from File %s\n' % (self._Token, FileLi= neTuple[0]) + \ + # '\n\tGot Token: \"%s\" from File %s\n' % (self._Token, FileL= ineTuple[0]) + \ # At this point, the closest parent would be the included file= itself Profile =3D GetParentAtLine(X.OriginalLineNumber) if Profile is not None: X.Message +=3D ' near line %d, column %d: %s' \ - % (X.LineNumber, 0, Profile.FileLinesList[X.LineNumber-1]) + % (X.LineNumber, 0, Profile.FileLinesList[X.LineNumber= -1]) else: - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) X.Message +=3D ' near line %d, column %d: %s' \ - % (FileLineTuple[1], self.CurrentOffsetWithinLine + 1, sel= f.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithi= nLine:].rstrip(TAB_LINE_BREAK).rstrip(T_CHAR_CR)) + % (FileLineTuple[1], self.CurrentOffsetWithinLine + 1,= self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetW= ithinLine:].rstrip(TAB_LINE_BREAK).rstrip(T_CHAR_CR)) raise =20 - ## SectionParser() method + # SectionParser() method # # Parse the file section info # Exception will be raised if syntax error found @@ -1344,10 +1434,11 @@ class FdfParser: def SectionParser(self, section): S =3D section.upper() if not S.startswith("[DEFINES") and not S.startswith("[FD.") and n= ot S.startswith("[FV.") and not S.startswith("[CAPSULE.") \ - and not S.startswith("[RULE.") and not S.startswith("[OPTIONR= OM.") and not S.startswith('[FMPPAYLOAD.'): - raise Warning("Unknown section or section appear sequence erro= r (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [Rul= e.], [OptionRom.], [FMPPAYLOAD.])", self.FileName, self.CurrentLineNumber) + and not S.startswith("[RULE.") and not S.startswith("[OPTI= ONROM.") and not S.startswith('[FMPPAYLOAD.'): + raise Warning( + "Unknown section or section appear sequence error (The cor= rect sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [Rule.], [Opti= onRom.], [FMPPAYLOAD.])", self.FileName, self.CurrentLineNumber) =20 - ## _GetDefines() method + # _GetDefines() method # # Get Defines section contents and store its data into AllMacrosList # @@ -1367,13 +1458,16 @@ class FdfParser: =20 self._UndoToken() if not self._IsToken("[DEFINES", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) + # print 'Parsing String: %s in File %s, At line: %d, Offset Wi= thin Line: %d' \ # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine:], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning.Expected("[DEFINES", self.FileName, self.Current= LineNumber) + raise Warning.Expected( + "[DEFINES", self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 while self._GetNextWord(): # handle the SET statement @@ -1385,25 +1479,28 @@ class FdfParser: Macro =3D self._Token =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken() or self._Token.startswith(TAB_SECT= ION_START): - raise Warning.Expected("MACRO value", self.FileName, self.= CurrentLineNumber) + raise Warning.Expected( + "MACRO value", self.FileName, self.CurrentLineNumber) Value =3D self._Token =20 return False =20 - ##_GetError() method + # _GetError() method def _GetError(self): - #save the Current information + # save the Current information CurrentLine =3D self.CurrentLineNumber CurrentOffset =3D self.CurrentOffsetWithinLine while self._GetNextToken(): if self._Token =3D=3D TAB_ERROR: - EdkLogger.error('FdfParser', ERROR_STATEMENT, self._Curren= tLine().replace(TAB_ERROR, '', 1), File=3Dself.FileName, Line=3Dself.Curren= tLineNumber) + EdkLogger.error('FdfParser', ERROR_STATEMENT, self._Curren= tLine().replace( + TAB_ERROR, '', 1), File=3Dself.FileName, Line=3Dself.C= urrentLineNumber) self.CurrentLineNumber =3D CurrentLine self.CurrentOffsetWithinLine =3D CurrentOffset =20 - ## _GetFd() method + # _GetFd() method # # Get FD section contents and store its data into FD dictionary of s= elf.Profile # @@ -1418,52 +1515,61 @@ class FdfParser: S =3D self._Token.upper() if S.startswith(TAB_SECTION_START) and not S.startswith("[FD."): if not S.startswith("[FV.") and not S.startswith('[FMPPAYLOAD.= ') and not S.startswith("[CAPSULE.") \ - and not S.startswith("[RULE.") and not S.startswith("[OPTI= ONROM."): - raise Warning("Unknown section", self.FileName, self.Curre= ntLineNumber) + and not S.startswith("[RULE.") and not S.startswith("[= OPTIONROM."): + raise Warning("Unknown section", self.FileName, + self.CurrentLineNumber) self._UndoToken() return False =20 self._UndoToken() if not self._IsToken("[FD.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) + # print 'Parsing String: %s in File %s, At line: %d, Offset Wi= thin Line: %d' \ # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine:], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning.Expected("[FD.]", self.FileName, self.CurrentLin= eNumber) + raise Warning.Expected( + "[FD.]", self.FileName, self.CurrentLineNumber) =20 FdName =3D self._GetUiName() if FdName =3D=3D "": - if len (self.Profile.FdDict) =3D=3D 0: + if len(self.Profile.FdDict) =3D=3D 0: FdName =3D GenFdsGlobalVariable.PlatformName if FdName =3D=3D "" and GlobalData.gActivePlatform: FdName =3D GlobalData.gActivePlatform.PlatformName self.Profile.FdNameNotSet =3D True else: - raise Warning.Expected("FdName in [FD.] section", self.Fil= eName, self.CurrentLineNumber) + raise Warning.Expected( + "FdName in [FD.] section", self.FileName, self.Current= LineNumber) self.CurrentFdName =3D FdName.upper() =20 if self.CurrentFdName in self.Profile.FdDict: - raise Warning("Unexpected the same FD name", self.FileName, se= lf.CurrentLineNumber) + raise Warning("Unexpected the same FD name", + self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 FdObj =3D FD() FdObj.FdUiName =3D self.CurrentFdName self.Profile.FdDict[self.CurrentFdName] =3D FdObj =20 - if len (self.Profile.FdDict) > 1 and self.Profile.FdNameNotSet: - raise Warning.Expected("all FDs have their name", self.FileNam= e, self.CurrentLineNumber) + if len(self.Profile.FdDict) > 1 and self.Profile.FdNameNotSet: + raise Warning.Expected( + "all FDs have their name", self.FileName, self.CurrentLine= Number) =20 Status =3D self._GetCreateFile(FdObj) if not Status: - raise Warning("FD name error", self.FileName, self.CurrentLine= Number) + raise Warning("FD name error", self.FileName, + self.CurrentLineNumber) =20 while self._GetTokenStatements(FdObj): pass for Attr in ("BaseAddress", "Size", "ErasePolarity"): if getattr(FdObj, Attr) is None: self._GetNextToken() - raise Warning("Keyword %s missing" % Attr, self.FileName, = self.CurrentLineNumber) + raise Warning("Keyword %s missing" % + Attr, self.FileName, self.CurrentLineNumber) =20 if not FdObj.BlockSizeList: FdObj.BlockSizeList.append((1, FdObj.Size, None)) @@ -1473,13 +1579,14 @@ class FdfParser: self._GetSetStatements(FdObj) =20 if not self._GetRegionLayout(FdObj): - raise Warning.Expected("region layout", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "region layout", self.FileName, self.CurrentLineNumber) =20 while self._GetRegionLayout(FdObj): pass return True =20 - ## _GetUiName() method + # _GetUiName() method # # Return the UI name of a section # @@ -1493,7 +1600,7 @@ class FdfParser: =20 return Name =20 - ## _GetCreateFile() method + # _GetCreateFile() method # # Return the output file name of object # @@ -1504,20 +1611,23 @@ class FdfParser: def _GetCreateFile(self, Obj): if self._IsKeyword("CREATE_FILE"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("file name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "file name", self.FileName, self.CurrentLineNumber) =20 FileName =3D self._Token Obj.CreateFileName =3D FileName =20 return True =20 - def SetPcdLocalation(self,pcdpair): - self.Profile.PcdLocalDict[pcdpair] =3D (self.Profile.FileName,self= .CurrentLineNumber) + def SetPcdLocalation(self, pcdpair): + self.Profile.PcdLocalDict[pcdpair] =3D ( + self.Profile.FileName, self.CurrentLineNumber) =20 - ## _GetTokenStatements() method + # _GetTokenStatements() method # # Get token statements # @@ -1527,10 +1637,12 @@ class FdfParser: def _GetTokenStatements(self, Obj): if self._IsKeyword("BaseAddress"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextHexNumber(): - raise Warning.Expected("Hex base address", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "Hex base address", self.FileName, self.CurrentLineNum= ber) =20 Obj.BaseAddress =3D self._Token =20 @@ -1539,16 +1651,19 @@ class FdfParser: Obj.BaseAddressPcd =3D pcdPair self.Profile.PcdDict[pcdPair] =3D Obj.BaseAddress self.SetPcdLocalation(pcdPair) - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[pcdPair] =3D FileLineTuple return True =20 if self._IsKeyword("Size"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextHexNumber(): - raise Warning.Expected("Hex size", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "Hex size", self.FileName, self.CurrentLineNumber) =20 Size =3D self._Token if self._IsToken(TAB_VALUE_SPLIT): @@ -1556,27 +1671,31 @@ class FdfParser: Obj.SizePcd =3D pcdPair self.Profile.PcdDict[pcdPair] =3D Size self.SetPcdLocalation(pcdPair) - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[pcdPair] =3D FileLineTuple Obj.Size =3D int(Size, 0) return True =20 if self._IsKeyword("ErasePolarity"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("Erase Polarity", self.FileName, se= lf.CurrentLineNumber) + raise Warning.Expected( + "Erase Polarity", self.FileName, self.CurrentLineNumbe= r) =20 if not self._Token in {"1", "0"}: - raise Warning.Expected("1 or 0 Erase Polarity", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "1 or 0 Erase Polarity", self.FileName, self.CurrentLi= neNumber) =20 Obj.ErasePolarity =3D self._Token return True =20 return self._GetBlockStatements(Obj) =20 - ## _GetAddressStatements() method + # _GetAddressStatements() method # # Get address statements # @@ -1588,25 +1707,29 @@ class FdfParser: def _GetAddressStatements(self, Obj): if self._IsKeyword("BsBaseAddress"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextDecimalNumber() and not self._GetNextHexNu= mber(): - raise Warning.Expected("address", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "address", self.FileName, self.CurrentLineNumber) =20 BsAddress =3D int(self._Token, 0) Obj.BsBaseAddress =3D BsAddress =20 if self._IsKeyword("RtBaseAddress"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextDecimalNumber() and not self._GetNextHexNu= mber(): - raise Warning.Expected("address", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "address", self.FileName, self.CurrentLineNumber) =20 RtAddress =3D int(self._Token, 0) Obj.RtBaseAddress =3D RtAddress =20 - ## _GetBlockStatements() method + # _GetBlockStatements() method # # Get block statements # @@ -1620,10 +1743,11 @@ class FdfParser: =20 Item =3D Obj.BlockSizeList[-1] if Item[0] is None or Item[1] is None: - raise Warning.Expected("block statement", self.FileName, s= elf.CurrentLineNumber) + raise Warning.Expected( + "block statement", self.FileName, self.CurrentLineNumb= er) return IsBlock =20 - ## _GetBlockStatement() method + # _GetBlockStatement() method # # Get block statement # @@ -1640,7 +1764,8 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextHexNumber() and not self._GetNextDecimalNumber= (): - raise Warning.Expected("Hex or Integer block size", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "Hex or Integer block size", self.FileName, self.CurrentLi= neNumber) =20 BlockSize =3D self._Token BlockSizePcd =3D None @@ -1649,24 +1774,27 @@ class FdfParser: BlockSizePcd =3D PcdPair self.Profile.PcdDict[PcdPair] =3D BlockSize self.SetPcdLocalation(PcdPair) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[PcdPair] =3D FileLineTuple BlockSize =3D int(BlockSize, 0) =20 BlockNumber =3D None if self._IsKeyword("NumBlocks"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextDecimalNumber() and not self._GetNextHexNu= mber(): - raise Warning.Expected("block numbers", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected( + "block numbers", self.FileName, self.CurrentLineNumber) =20 BlockNumber =3D int(self._Token, 0) =20 Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd)) return True =20 - ## _GetDefineStatements() method + # _GetDefineStatements() method # # Get define statements # @@ -1679,7 +1807,7 @@ class FdfParser: while self._GetDefineStatement(Obj): pass =20 - ## _GetDefineStatement() method + # _GetDefineStatement() method # # Get define statement # @@ -1693,10 +1821,12 @@ class FdfParser: self._GetNextToken() Macro =3D self._Token if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("value", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "value", self.FileName, self.CurrentLineNumber) =20 Value =3D self._Token Macro =3D '$(' + Macro + ')' @@ -1705,7 +1835,7 @@ class FdfParser: =20 return False =20 - ## _GetSetStatements() method + # _GetSetStatements() method # # Get set statements # @@ -1718,7 +1848,7 @@ class FdfParser: while self._GetSetStatement(Obj): pass =20 - ## _GetSetStatement() method + # _GetSetStatement() method # # Get set statement # @@ -1732,22 +1862,25 @@ class FdfParser: PcdPair =3D self._GetNextPcdSettings() =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 Value =3D self._GetExpression() - Value =3D self._EvaluateConditional(Value, self.CurrentLineNum= ber, 'eval', True) + Value =3D self._EvaluateConditional( + Value, self.CurrentLineNumber, 'eval', True) =20 if Obj: Obj.SetVarDict[PcdPair] =3D Value self.Profile.PcdDict[PcdPair] =3D Value self.SetPcdLocalation(PcdPair) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[PcdPair] =3D FileLineTuple return True =20 return False =20 - ## _CalcRegionExpr(self) + # _CalcRegionExpr(self) # # Calculate expression for offset or size of a region # @@ -1778,7 +1911,7 @@ class FdfParser: self.SetFileBufferPos(StartPos) return None =20 - ## _GetRegionLayout() method + # _GetRegionLayout() method # # Get region layout for FD # @@ -1797,11 +1930,13 @@ class FdfParser: theFd.RegionList.append(RegionObj) =20 if not self._IsToken(TAB_VALUE_SPLIT): - raise Warning.Expected("'|'", self.FileName, self.CurrentLineN= umber) + raise Warning.Expected("'|'", self.FileName, + self.CurrentLineNumber) =20 Size =3D self._CalcRegionExpr() if Size is None: - raise Warning.Expected("Region Size", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "Region Size", self.FileName, self.CurrentLineNumber) RegionObj.Size =3D Size =20 if not self._GetNextWord(): @@ -1818,17 +1953,22 @@ class FdfParser: RegionOffsetPcdPattern.match(self._CurrentLine(= )[self.CurrentOffsetWithinLine:])) if IsRegionPcd: RegionObj.PcdOffset =3D self._GetNextPcdSettings() - self.Profile.PcdDict[RegionObj.PcdOffset] =3D "0x%08X" % (= RegionObj.Offset + int(theFd.BaseAddress, 0)) + self.Profile.PcdDict[RegionObj.PcdOffset] =3D "0x%08X" % ( + RegionObj.Offset + int(theFd.BaseAddress, 0)) self.SetPcdLocalation(RegionObj.PcdOffset) - self._PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj= .PcdOffset[0])] =3D "0x%x" % RegionObj.Offset - FileLineTuple =3D GetRealFileLine(self.FileName, self.Curr= entLineNumber) + self._PcdDict['%s.%s' % ( + RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] =3D "= 0x%x" % RegionObj.Offset + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[RegionObj.PcdOffset] =3D File= LineTuple if self._IsToken(TAB_VALUE_SPLIT): RegionObj.PcdSize =3D self._GetNextPcdSettings() self.Profile.PcdDict[RegionObj.PcdSize] =3D "0x%08X" %= RegionObj.Size self.SetPcdLocalation(RegionObj.PcdSize) - self._PcdDict['%s.%s' % (RegionObj.PcdSize[1], RegionO= bj.PcdSize[0])] =3D "0x%x" % RegionObj.Size - FileLineTuple =3D GetRealFileLine(self.FileName, self.= CurrentLineNumber) + self._PcdDict['%s.%s' % ( + RegionObj.PcdSize[1], RegionObj.PcdSize[0])] =3D "= 0x%x" % RegionObj.Size + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.PcdFileLineDict[RegionObj.PcdSize] =3D Fi= leLineTuple =20 if not self._GetNextWord(): @@ -1875,7 +2015,7 @@ class FdfParser: =20 return True =20 - ## _GetRegionFvType() method + # _GetRegionFvType() method # # Get region fv data for region # @@ -1884,13 +2024,15 @@ class FdfParser: # def _GetRegionFvType(self, RegionObj): if not self._IsKeyword(BINARY_FILE_TYPE_FV): - raise Warning.Expected("'FV'", self.FileName, self.CurrentLine= Number) + raise Warning.Expected("'FV'", self.FileName, + self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("FV name", self.FileName, self.CurrentL= ineNumber) + raise Warning.Expected( + "FV name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionType =3D BINARY_FILE_TYPE_FV RegionObj.RegionDataList.append((self._Token).upper()) @@ -1898,14 +2040,16 @@ class FdfParser: while self._IsKeyword(BINARY_FILE_TYPE_FV): =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("FV name", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "FV name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionDataList.append((self._Token).upper()) =20 - ## _GetRegionCapType() method + # _GetRegionCapType() method # # Get region capsule data for region # @@ -1914,13 +2058,15 @@ class FdfParser: # def _GetRegionCapType(self, RegionObj): if not self._IsKeyword("CAPSULE"): - raise Warning.Expected("'CAPSULE'", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "'CAPSULE'", self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("CAPSULE name", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "CAPSULE name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionType =3D "CAPSULE" RegionObj.RegionDataList.append(self._Token) @@ -1928,14 +2074,16 @@ class FdfParser: while self._IsKeyword("CAPSULE"): =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("CAPSULE name", self.FileName, self= .CurrentLineNumber) + raise Warning.Expected( + "CAPSULE name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionDataList.append(self._Token) =20 - ## _GetRegionFileType() method + # _GetRegionFileType() method # # Get region file data for region # @@ -1944,13 +2092,15 @@ class FdfParser: # def _GetRegionFileType(self, RegionObj): if not self._IsKeyword("FILE"): - raise Warning.Expected("'FILE'", self.FileName, self.CurrentLi= neNumber) + raise Warning.Expected( + "'FILE'", self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("File name", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "File name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionType =3D "FILE" RegionObj.RegionDataList.append(self._Token) @@ -1958,14 +2108,16 @@ class FdfParser: while self._IsKeyword("FILE"): =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("FILE name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "FILE name", self.FileName, self.CurrentLineNumber) =20 RegionObj.RegionDataList.append(self._Token) =20 - ## _GetRegionDataType() method + # _GetRegionDataType() method # # Get region array data for region # @@ -1974,41 +2126,49 @@ class FdfParser: # def _GetRegionDataType(self, RegionObj): if not self._IsKeyword("DATA"): - raise Warning.Expected("Region Data type", self.FileName, self= .CurrentLineNumber) + raise Warning.Expected( + "Region Data type", self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLin= eNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextHexNumber(): - raise Warning.Expected("Hex byte", self.FileName, self.Current= LineNumber) + raise Warning.Expected( + "Hex byte", self.FileName, self.CurrentLineNumber) =20 if len(self._Token) > 18: - raise Warning("Hex string can't be converted to a valid UINT64= value", self.FileName, self.CurrentLineNumber) + raise Warning("Hex string can't be converted to a valid UINT64= value", + self.FileName, self.CurrentLineNumber) =20 # convert hex string value to byte hex string array AllString =3D self._Token - AllStrLen =3D len (AllString) + AllStrLen =3D len(AllString) DataString =3D "" while AllStrLen > 4: - DataString =3D DataString + "0x" + AllString[AllStrLen - 2: Al= lStrLen] + TAB_COMMA_SPLIT - AllStrLen =3D AllStrLen - 2 + DataString =3D DataString + "0x" + \ + AllString[AllStrLen - 2: AllStrLen] + TAB_COMMA_SPLIT + AllStrLen =3D AllStrLen - 2 DataString =3D DataString + AllString[:AllStrLen] + TAB_COMMA_SPLIT =20 # byte value array - if len (self._Token) <=3D 4: + if len(self._Token) <=3D 4: while self._IsToken(TAB_COMMA_SPLIT): if not self._GetNextHexNumber(): - raise Warning("Invalid Hex number", self.FileName, sel= f.CurrentLineNumber) + raise Warning("Invalid Hex number", + self.FileName, self.CurrentLineNumber) if len(self._Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long", s= elf.FileName, self.CurrentLineNumber) + raise Warning("Hex byte(must be 2 digits) too long", + self.FileName, self.CurrentLineNumber) DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) RegionObj.RegionType =3D "DATA" @@ -2017,43 +2177,51 @@ class FdfParser: while self._IsKeyword("DATA"): =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextHexNumber(): - raise Warning.Expected("Hex byte", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "Hex byte", self.FileName, self.CurrentLineNumber) =20 if len(self._Token) > 18: - raise Warning("Hex string can't be converted to a valid UI= NT64 value", self.FileName, self.CurrentLineNumber) + raise Warning("Hex string can't be converted to a valid UI= NT64 value", + self.FileName, self.CurrentLineNumber) =20 # convert hex string value to byte hex string array AllString =3D self._Token - AllStrLen =3D len (AllString) + AllStrLen =3D len(AllString) DataString =3D "" while AllStrLen > 4: - DataString =3D DataString + "0x" + AllString[AllStrLen - 2= : AllStrLen] + TAB_COMMA_SPLIT - AllStrLen =3D AllStrLen - 2 + DataString =3D DataString + "0x" + \ + AllString[AllStrLen - 2: AllStrLen] + TAB_COMMA_SPLIT + AllStrLen =3D AllStrLen - 2 DataString =3D DataString + AllString[:AllStrLen] + TAB_COMMA_= SPLIT =20 # byte value array - if len (self._Token) <=3D 4: + if len(self._Token) <=3D 4: while self._IsToken(TAB_COMMA_SPLIT): if not self._GetNextHexNumber(): - raise Warning("Invalid Hex number", self.FileName,= self.CurrentLineNumber) + raise Warning("Invalid Hex number", + self.FileName, self.CurrentLineNumbe= r) if len(self._Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long= ", self.FileName, self.CurrentLineNumber) + raise Warning("Hex byte(must be 2 digits) too long= ", + self.FileName, self.CurrentLineNumbe= r) DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) RegionObj.RegionDataList.append(DataString) =20 - ## _GetFv() method + # _GetFv() method # # Get FV section contents and store its data into FV dictionary of s= elf.Profile # @@ -2073,23 +2241,27 @@ class FdfParser: =20 self._UndoToken() if not self._IsToken("[FV.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) + # print 'Parsing String: %s in File %s, At line: %d, Offset Wi= thin Line: %d' \ # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine:], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning("Unknown Keyword '%s'" % self._Token, self.FileN= ame, self.CurrentLineNumber) + raise Warning("Unknown Keyword '%s'" % self._Token, + self.FileName, self.CurrentLineNumber) =20 FvName =3D self._GetUiName() self.CurrentFvName =3D FvName.upper() =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 FvObj =3D FV(Name=3Dself.CurrentFvName) self.Profile.FvDict[self.CurrentFvName] =3D FvObj =20 Status =3D self._GetCreateFile(FvObj) if not Status: - raise Warning("FV name error", self.FileName, self.CurrentLine= Number) + raise Warning("FV name error", self.FileName, + self.CurrentLineNumber) =20 self._GetDefineStatements(FvObj) =20 @@ -2099,13 +2271,14 @@ class FdfParser: self._GetSetStatements(FvObj) =20 if not (self._GetBlockStatement(FvObj) or self._GetFvBaseAddre= ss(FvObj) or - self._GetFvForceRebase(FvObj) or self._GetFvAlignment(FvOb= j) or - self._GetFvAttributes(FvObj) or self._GetFvNameGuid(FvObj)= or - self._GetFvExtEntryStatement(FvObj) or self._GetFvNameStri= ng(FvObj)): + self._GetFvForceRebase(FvObj) or self._GetFvAlignment(= FvObj) or + self._GetFvAttributes(FvObj) or self._GetFvNameGuid(Fv= Obj) or + self._GetFvExtEntryStatement(FvObj) or self._GetFvName= String(FvObj)): break =20 if FvObj.FvNameString =3D=3D 'TRUE' and not FvObj.FvNameGuid: - raise Warning("FvNameString found but FvNameGuid was not found= ", self.FileName, self.CurrentLineNumber) + raise Warning("FvNameString found but FvNameGuid was not found= ", + self.FileName, self.CurrentLineNumber) =20 self._GetAprioriSection(FvObj) self._GetAprioriSection(FvObj) @@ -2118,7 +2291,7 @@ class FdfParser: =20 return True =20 - ## _GetFvAlignment() method + # _GetFvAlignment() method # # Get alignment for FV # @@ -2135,17 +2308,19 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("alignment value", self.FileName, self.= CurrentLineNumber) + raise Warning.Expected( + "alignment value", self.FileName, self.CurrentLineNumber) =20 - if self._Token.upper() not in {"1", "2", "4", "8", "16", "32", "64= ", "128", "256", "512", \ - "1K", "2K", "4K", "8K", "16K", "32= K", "64K", "128K", "256K", "512K", \ - "1M", "2M", "4M", "8M", "16M", "32= M", "64M", "128M", "256M", "512M", \ - "1G", "2G"}: - raise Warning("Unknown alignment value '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) + if self._Token.upper() not in {"1", "2", "4", "8", "16", "32", "64= ", "128", "256", "512", + "1K", "2K", "4K", "8K", "16K", "32K= ", "64K", "128K", "256K", "512K", + "1M", "2M", "4M", "8M", "16M", "32M= ", "64M", "128M", "256M", "512M", + "1G", "2G"}: + raise Warning("Unknown alignment value '%s'" % + self._Token, self.FileName, self.CurrentLineNumb= er) Obj.FvAlignment =3D self._Token return True =20 - ## _GetFvBaseAddress() method + # _GetFvBaseAddress() method # # Get BaseAddress for FV # @@ -2162,14 +2337,16 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("FV base address value", self.FileName,= self.CurrentLineNumber) + raise Warning.Expected( + "FV base address value", self.FileName, self.CurrentLineNu= mber) =20 if not BaseAddrValuePattern.match(self._Token.upper()): - raise Warning("Unknown FV base address value '%s'" % self._Tok= en, self.FileName, self.CurrentLineNumber) + raise Warning("Unknown FV base address value '%s'" % + self._Token, self.FileName, self.CurrentLineNumb= er) Obj.FvBaseAddress =3D self._Token return True =20 - ## _GetFvForceRebase() method + # _GetFvForceRebase() method # # Get FvForceRebase for FV # @@ -2186,10 +2363,12 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("FvForceRebase value", self.FileName, s= elf.CurrentLineNumber) + raise Warning.Expected("FvForceRebase value", + self.FileName, self.CurrentLineNumber) =20 if self._Token.upper() not in {"TRUE", "FALSE", "0", "0X0", "0X00"= , "1", "0X1", "0X01"}: - raise Warning("Unknown FvForceRebase value '%s'" % self._Token= , self.FileName, self.CurrentLineNumber) + raise Warning("Unknown FvForceRebase value '%s'" % + self._Token, self.FileName, self.CurrentLineNumb= er) =20 if self._Token.upper() in {"TRUE", "1", "0X1", "0X01"}: Obj.FvForceRebase =3D True @@ -2200,8 +2379,7 @@ class FdfParser: =20 return True =20 - - ## _GetFvAttributes() method + # _GetFvAttributes() method # # Get attributes for FV # @@ -2209,31 +2387,34 @@ class FdfParser: # @param Obj for whom attribute is got # @retval None # + def _GetFvAttributes(self, FvObj): IsWordToken =3D False while self._GetNextWord(): IsWordToken =3D True name =3D self._Token - if name not in {"ERASE_POLARITY", "MEMORY_MAPPED", \ - "STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WRI= TE_ENABLED_CAP", \ - "WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENA= BLED_CAP", \ - "READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_= CAP", \ - "READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LO= CK_STATUS", \ - "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "FvU= sedSizeEnable"}: + if name not in {"ERASE_POLARITY", "MEMORY_MAPPED", + "STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WR= ITE_ENABLED_CAP", + "WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_EN= ABLED_CAP", + "READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK= _CAP", + "READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_L= OCK_STATUS", + "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "Fv= UsedSizeEnable"}: self._UndoToken() return False =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken() or self._Token.upper() not in {"TR= UE", "FALSE", "1", "0"}: - raise Warning.Expected("TRUE/FALSE (1/0)", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "TRUE/FALSE (1/0)", self.FileName, self.CurrentLineNum= ber) =20 FvObj.FvAttributeDict[name] =3D self._Token =20 return IsWordToken =20 - ## _GetFvNameGuid() method + # _GetFvNameGuid() method # # Get FV GUID for FV # @@ -2249,9 +2430,11 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextGuid(): - raise Warning.Expected("GUID value", self.FileName, self.Curre= ntLineNumber) + raise Warning.Expected( + "GUID value", self.FileName, self.CurrentLineNumber) if self._Token in GlobalData.gGuidDict: - self._Token =3D GuidStructureStringToGuidString(GlobalData.gGu= idDict[self._Token]).upper() + self._Token =3D GuidStructureStringToGuidString( + GlobalData.gGuidDict[self._Token]).upper() =20 FvObj.FvNameGuid =3D self._Token =20 @@ -2265,7 +2448,8 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken() or self._Token.upper() not in {'TRUE',= 'FALSE'}: - raise Warning.Expected("TRUE or FALSE for FvNameString", self.= FileName, self.CurrentLineNumber) + raise Warning.Expected( + "TRUE or FALSE for FvNameString", self.FileName, self.Curr= entLineNumber) =20 FvObj.FvNameString =3D self._Token =20 @@ -2275,73 +2459,88 @@ class FdfParser: if not (self._IsKeyword("FV_EXT_ENTRY") or self._IsKeyword("FV_EXT= _ENTRY_TYPE")): return False =20 - if not self._IsKeyword ("TYPE"): - raise Warning.Expected("'TYPE'", self.FileName, self.CurrentLi= neNumber) + if not self._IsKeyword("TYPE"): + raise Warning.Expected( + "'TYPE'", self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextHexNumber() and not self._GetNextDecimalNumber= (): - raise Warning.Expected("Hex FV extension entry type value At L= ine ", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "Hex FV extension entry type value At Line ", self.FileNam= e, self.CurrentLineNumber) =20 FvObj.FvExtEntryTypeValue.append(self._Token) =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLin= eNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 if not self._IsKeyword("FILE") and not self._IsKeyword("DATA"): - raise Warning.Expected("'FILE' or 'DATA'", self.FileName, self= .CurrentLineNumber) + raise Warning.Expected( + "'FILE' or 'DATA'", self.FileName, self.CurrentLineNumber) =20 FvObj.FvExtEntryType.append(self._Token) =20 if self._Token =3D=3D 'DATA': if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextHexNumber(): - raise Warning.Expected("Hex byte", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "Hex byte", self.FileName, self.CurrentLineNumber) =20 if len(self._Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long", self.= FileName, self.CurrentLineNumber) + raise Warning("Hex byte(must be 2 digits) too long", + self.FileName, self.CurrentLineNumber) =20 DataString =3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 while self._IsToken(TAB_COMMA_SPLIT): if not self._GetNextHexNumber(): - raise Warning("Invalid Hex number", self.FileName, sel= f.CurrentLineNumber) + raise Warning("Invalid Hex number", + self.FileName, self.CurrentLineNumber) if len(self._Token) > 4: - raise Warning("Hex byte(must be 2 digits) too long", s= elf.FileName, self.CurrentLineNumber) + raise Warning("Hex byte(must be 2 digits) too long", + self.FileName, self.CurrentLineNumber) DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) FvObj.FvExtEntryData.append(DataString) =20 if self._Token =3D=3D 'FILE': if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("FV Extension Entry file path At Li= ne ", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "FV Extension Entry file path At Line ", self.FileName= , self.CurrentLineNumber) =20 FvObj.FvExtEntryData.append(self._Token) =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 return True =20 - ## _GetAprioriSection() method + # _GetAprioriSection() method # # Get token statements # @@ -2355,11 +2554,13 @@ class FdfParser: return False =20 if not self._IsKeyword("PEI") and not self._IsKeyword("DXE"): - raise Warning.Expected("Apriori file type", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected("Apriori file type", + self.FileName, self.CurrentLineNumber) AprType =3D self._Token =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLin= eNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 AprSectionObj =3D AprioriSection() AprSectionObj.AprioriType =3D AprType @@ -2373,7 +2574,8 @@ class FdfParser: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 FvObj.AprioriSectionList.append(AprSectionObj) return True @@ -2386,36 +2588,42 @@ class FdfParser: self._GetInfOptions(ffsInf) =20 if not self._GetNextToken(): - raise Warning.Expected("INF file path", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "INF file path", self.FileName, self.CurrentLineNumber) ffsInf.InfFileName =3D self._Token if not ffsInf.InfFileName.endswith('.inf'): - raise Warning.Expected(".inf file path", self.FileName, self.C= urrentLineNumber) + raise Warning.Expected( + ".inf file path", self.FileName, self.CurrentLineNumber) =20 ffsInf.CurrentLineNum =3D self.CurrentLineNumber ffsInf.CurrentLineContent =3D self._CurrentLine() =20 - #Replace $(SAPCE) with real space + # Replace $(SAPCE) with real space ffsInf.InfFileName =3D ffsInf.InfFileName.replace('$(SPACE)', ' ') =20 if ffsInf.InfFileName.replace(TAB_WORKSPACE, '').find('$') =3D=3D = -1: - #do case sensitive check for file path - ErrorCode, ErrorInfo =3D PathClass(NormPath(ffsInf.InfFileName= ), GenFdsGlobalVariable.WorkSpaceDir).Validate() + # do case sensitive check for file path + ErrorCode, ErrorInfo =3D PathClass( + NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpa= ceDir).Validate() if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) =20 NewFileName =3D ffsInf.InfFileName if ffsInf.OverrideGuid: - NewFileName =3D ProcessDuplicatedInf(PathClass(ffsInf.InfFileN= ame,GenFdsGlobalVariable.WorkSpaceDir), ffsInf.OverrideGuid, GenFdsGlobalVa= riable.WorkSpaceDir).Path + NewFileName =3D ProcessDuplicatedInf(PathClass( + ffsInf.InfFileName, GenFdsGlobalVariable.WorkSpaceDir), ff= sInf.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir).Path =20 if not NewFileName in self.Profile.InfList: self.Profile.InfList.append(NewFileName) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.InfFileLineList.append(FileLineTuple) if ffsInf.UseArch: if ffsInf.UseArch not in self.Profile.InfDict: self.Profile.InfDict[ffsInf.UseArch] =3D [ffsInf.InfFi= leName] else: - self.Profile.InfDict[ffsInf.UseArch].append(ffsInf.Inf= FileName) + self.Profile.InfDict[ffsInf.UseArch].append( + ffsInf.InfFileName) else: self.Profile.InfDict['ArchTBD'].append(ffsInf.InfFileName) =20 @@ -2425,10 +2633,11 @@ class FdfParser: elif self._IsKeyword('RELOCS_RETAINED'): ffsInf.KeepReloc =3D True else: - raise Warning("Unknown reloc strip flag '%s'" % self._Toke= n, self.FileName, self.CurrentLineNumber) + raise Warning("Unknown reloc strip flag '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) return ffsInf =20 - ## _GetInfStatement() method + # _GetInfStatement() method # # Get INF statements # @@ -2450,7 +2659,7 @@ class FdfParser: Obj.FfsList.append(ffsInf) return True =20 - ## _GetInfOptions() method + # _GetInfOptions() method # # Get options for INF # @@ -2460,48 +2669,59 @@ class FdfParser: def _GetInfOptions(self, FfsInfObj): if self._IsKeyword("FILE_GUID"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextGuid(): - raise Warning.Expected("GUID value", self.FileName, self.C= urrentLineNumber) + raise Warning.Expected( + "GUID value", self.FileName, self.CurrentLineNumber) if self._Token in GlobalData.gGuidDict: - self._Token =3D GuidStructureStringToGuidString(GlobalData= .gGuidDict[self._Token]).upper() + self._Token =3D GuidStructureStringToGuidString( + GlobalData.gGuidDict[self._Token]).upper() FfsInfObj.OverrideGuid =3D self._Token =20 if self._IsKeyword("RuleOverride"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("Rule name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "Rule name", self.FileName, self.CurrentLineNumber) FfsInfObj.Rule =3D self._Token =20 if self._IsKeyword("VERSION"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("Version", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "Version", self.FileName, self.CurrentLineNumber) =20 if self._GetStringData(): FfsInfObj.Version =3D self._Token =20 if self._IsKeyword(BINARY_FILE_TYPE_UI): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("UI name", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "UI name", self.FileName, self.CurrentLineNumber) =20 if self._GetStringData(): FfsInfObj.Ui =3D self._Token =20 if self._IsKeyword("USE"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("ARCH name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "ARCH name", self.FileName, self.CurrentLineNumber) FfsInfObj.UseArch =3D self._Token =20 - if self._GetNextToken(): - p =3D compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-= ]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\))') + p =3D compile( + r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOO= L_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\))') if p.match(self._Token) and p.match(self._Token).span()[1] =3D= =3D len(self._Token): FfsInfObj.KeyStringList.append(self._Token) if not self._IsToken(TAB_COMMA_SPLIT): @@ -2512,13 +2732,14 @@ class FdfParser: =20 while self._GetNextToken(): if not p.match(self._Token): - raise Warning.Expected("KeyString \"Target_Tag_Arch\""= , self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "KeyString \"Target_Tag_Arch\"", self.FileName, se= lf.CurrentLineNumber) FfsInfObj.KeyStringList.append(self._Token) =20 if not self._IsToken(TAB_COMMA_SPLIT): break =20 - ## _GetFileStatement() method + # _GetFileStatement() method # # Get FILE statements # @@ -2527,12 +2748,13 @@ class FdfParser: # @retval True Successfully find FILE statement # @retval False Not able to find FILE statement # - def _GetFileStatement(self, Obj, ForCapsule =3D False): + def _GetFileStatement(self, Obj, ForCapsule=3DFalse): if not self._IsKeyword("FILE"): return False =20 if not self._GetNextWord(): - raise Warning.Expected("FFS type", self.FileName, self.Current= LineNumber) + raise Warning.Expected( + "FFS type", self.FileName, self.CurrentLineNumber) =20 if ForCapsule and self._Token =3D=3D 'DATA': self._UndoToken() @@ -2547,17 +2769,21 @@ class FdfParser: =20 if not self._GetNextGuid(): if not self._GetNextWord(): - raise Warning.Expected("File GUID", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "File GUID", self.FileName, self.CurrentLineNumber) if self._Token =3D=3D 'PCD': if not self._IsToken("("): - raise Warning.Expected("'('", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "'('", self.FileName, self.CurrentLineNumber) PcdPair =3D self._GetNextPcdSettings() if not self._IsToken(")"): - raise Warning.Expected("')'", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "')'", self.FileName, self.CurrentLineNumber) self._Token =3D 'PCD('+PcdPair[1]+TAB_SPLIT+PcdPair[0]+')' =20 if self._Token in GlobalData.gGuidDict: - self._Token =3D GuidStructureStringToGuidString(GlobalData.gGu= idDict[self._Token]).upper() + self._Token =3D GuidStructureStringToGuidString( + GlobalData.gGuidDict[self._Token]).upper() FfsFileObj.NameGuid =3D self._Token =20 self._GetFilePart(FfsFileObj) @@ -2571,7 +2797,7 @@ class FdfParser: =20 return True =20 - ## _FileCouldHaveRelocFlag() method + # _FileCouldHaveRelocFlag() method # # Check whether reloc strip flag can be set for a file type. # @@ -2580,13 +2806,13 @@ class FdfParser: # @retval False No way to have it # @staticmethod - def _FileCouldHaveRelocFlag (FileType): + def _FileCouldHaveRelocFlag(FileType): if FileType in {SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PE= IM, SUP_MODULE_MM_CORE_STANDALONE, 'PEI_DXE_COMBO'}: return True else: return False =20 - ## _SectionCouldHaveRelocFlag() method + # _SectionCouldHaveRelocFlag() method # # Check whether reloc strip flag can be set for a section type. # @@ -2595,13 +2821,13 @@ class FdfParser: # @retval False No way to have it # @staticmethod - def _SectionCouldHaveRelocFlag (SectionType): + def _SectionCouldHaveRelocFlag(SectionType): if SectionType in {BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32}: return True else: return False =20 - ## _GetFilePart() method + # _GetFilePart() method # # Get components for FILE statement # @@ -2619,26 +2845,33 @@ class FdfParser: else: FfsFileObj.KeepReloc =3D True else: - raise Warning("File type %s could not have reloc strip= flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, = self.CurrentLineNumber) + raise Warning("File type %s could not have reloc strip= flag%d" % ( + FfsFileObj.FvFileType, self.CurrentLineNumber), se= lf.FileName, self.CurrentLineNumber) =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("File name or section data", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "File name or section data", self.FileName, self.CurrentLi= neNumber) =20 if self._Token =3D=3D BINARY_FILE_TYPE_FV: if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("FV name", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "FV name", self.FileName, self.CurrentLineNumber) FfsFileObj.FvName =3D self._Token =20 elif self._Token =3D=3D "FD": if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("FD name", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "FD name", self.FileName, self.CurrentLineNumber) FfsFileObj.FdName =3D self._Token =20 elif self._Token in {TAB_DEFINE, "APRIORI", "SECTION"}: @@ -2656,9 +2889,10 @@ class FdfParser: self._VerifyFile(FfsFileObj.FileName) =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 - ## _GetRAWData() method + # _GetRAWData() method # # Get RAW data for FILE statement # @@ -2672,20 +2906,24 @@ class FdfParser: AlignValue =3D None if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token= , self.FileName, self.CurrentLineNumber) - #For FFS, Auto is default option same to "" + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.Current= LineNumber) + # For FFS, Auto is default option same to "" if not self._Token =3D=3D "Auto": AlignValue =3D self._Token if not self._GetNextToken(): - raise Warning.Expected("Filename value", self.FileName, se= lf.CurrentLineNumber) + raise Warning.Expected( + "Filename value", self.FileName, self.CurrentLineNumbe= r) =20 FileName =3D self._Token.replace('$(SPACE)', ' ') if FileName =3D=3D T_CHAR_BRACE_R: self._UndoToken() - raise Warning.Expected("Filename value", self.FileName, se= lf.CurrentLineNumber) + raise Warning.Expected( + "Filename value", self.FileName, self.CurrentLineNumbe= r) =20 self._VerifyFile(FileName) - File =3D PathClass(NormPath(FileName), GenFdsGlobalVariable.Wo= rkSpaceDir) + File =3D PathClass(NormPath(FileName), + GenFdsGlobalVariable.WorkSpaceDir) FfsFileObj.FileName.append(File.Path) FfsFileObj.SubAlignment.append(AlignValue) =20 @@ -2698,7 +2936,7 @@ class FdfParser: if len(FfsFileObj.FileName) =3D=3D 1: FfsFileObj.FileName =3D FfsFileObj.FileName[0] =20 - ## _GetFileOpts() method + # _GetFileOpts() method # # Get options for FILE statement # @@ -2712,7 +2950,8 @@ class FdfParser: if self._IsToken(TAB_COMMA_SPLIT): while self._GetNextToken(): if not TokenFindPattern.match(self._Token): - raise Warning.Expected("KeyString \"Target_Tag= _Arch\"", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "KeyString \"Target_Tag_Arch\"", self.File= Name, self.CurrentLineNumber) FfsFileObj.KeyStringList.append(self._Token) =20 if not self._IsToken(TAB_COMMA_SPLIT): @@ -2729,12 +2968,13 @@ class FdfParser: =20 if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) - #For FFS, Auto is default option same to "" + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) + # For FFS, Auto is default option same to "" if not self._Token =3D=3D "Auto": FfsFileObj.Alignment =3D self._Token =20 - ## _GetAlignment() method + # _GetAlignment() method # # Return the alignment value # @@ -2745,15 +2985,17 @@ class FdfParser: def _GetAlignment(self): if self._IsKeyword("Align", True): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("alignment value", self.FileName, s= elf.CurrentLineNumber) + raise Warning.Expected( + "alignment value", self.FileName, self.CurrentLineNumb= er) return True =20 return False =20 - ## _GetSectionData() method + # _GetSectionData() method # # Get section data for FILE statement # @@ -2769,7 +3011,7 @@ class FdfParser: if not IsLeafSection and not IsEncapSection: break =20 - ## _GetLeafSection() method + # _GetLeafSection() method # # Get leaf section for Obj # @@ -2783,33 +3025,40 @@ class FdfParser: =20 if not self._IsKeyword("SECTION"): if len(Obj.SectionList) =3D=3D 0: - raise Warning.Expected("SECTION", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "SECTION", self.FileName, self.CurrentLineNumber) else: return False =20 AlignValue =3D None if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) AlignValue =3D self._Token =20 BuildNum =3D None if self._IsKeyword("BUILD_NUM"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("Build number value", self.FileName= , self.CurrentLineNumber) + raise Warning.Expected( + "Build number value", self.FileName, self.CurrentLineN= umber) =20 BuildNum =3D self._Token =20 if self._IsKeyword("VERSION"): if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("version", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "version", self.FileName, self.CurrentLineNumber) VerSectionObj =3D VerSection() VerSectionObj.Alignment =3D AlignValue VerSectionObj.BuildNum =3D BuildNum @@ -2821,11 +3070,14 @@ class FdfParser: =20 elif self._IsKeyword(BINARY_FILE_TYPE_UI): if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("UI", self.FileName, self.CurrentLi= neNumber) + raise Warning.Expected( + "UI", self.FileName, self.CurrentLineNumber) UiSectionObj =3D UiSection() UiSectionObj.Alignment =3D AlignValue if self._GetStringData(): @@ -2836,11 +3088,14 @@ class FdfParser: =20 elif self._IsKeyword("FV_IMAGE"): if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("FV name or FV file path", self.Fil= eName, self.CurrentLineNumber) + raise Warning.Expected( + "FV name or FV file path", self.FileName, self.Current= LineNumber) =20 FvName =3D self._Token FvObj =3D None @@ -2862,7 +3117,8 @@ class FdfParser: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 FvImageSectionObj =3D FvImageSection() FvImageSectionObj.Alignment =3D AlignValue @@ -2877,35 +3133,43 @@ class FdfParser: =20 elif self._IsKeyword("PEI_DEPEX_EXP") or self._IsKeyword("DXE_DEPE= X_EXP") or self._IsKeyword("SMM_DEPEX_EXP"): if AlignValue =3D=3D 'Auto': - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) DepexSectionObj =3D DepexSection() DepexSectionObj.Alignment =3D AlignValue DepexSectionObj.DepexType =3D self._Token =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) if not self._SkipToToken(T_CHAR_BRACE_R): - raise Warning.Expected("Depex expression ending '}'", self= .FileName, self.CurrentLineNumber) + raise Warning.Expected( + "Depex expression ending '}'", self.FileName, self.Cur= rentLineNumber) =20 - DepexSectionObj.Expression =3D self._SkippedChars.rstrip(T_CHA= R_BRACE_R) + DepexSectionObj.Expression =3D self._SkippedChars.rstrip( + T_CHAR_BRACE_R) Obj.SectionList.append(DepexSectionObj) =20 else: if not self._GetNextWord(): - raise Warning.Expected("section type", self.FileName, self= .CurrentLineNumber) + raise Warning.Expected( + "section type", self.FileName, self.CurrentLineNumber) =20 # Encapsulation section appear, UndoToken and return if self._Token =3D=3D "COMPRESS" or self._Token =3D=3D "GUIDED= ": self.SetFileBufferPos(OldPos) return False =20 - if self._Token not in {"COMPAT16", BINARY_FILE_TYPE_PE32, BINA= RY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_= DXE_DEPEX,\ - BINARY_FILE_TYPE_UI, "VERSION", BINARY_FILE= _TYPE_PEI_DEPEX, "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX}: - raise Warning("Unknown section type '%s'" % self._Token, s= elf.FileName, self.CurrentLineNumber) - if AlignValue =3D=3D 'Auto'and (not self._Token =3D=3D BINARY_= FILE_TYPE_PE32) and (not self._Token =3D=3D BINARY_FILE_TYPE_TE): - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + if self._Token not in {"COMPAT16", BINARY_FILE_TYPE_PE32, BINA= RY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_= DXE_DEPEX, + BINARY_FILE_TYPE_UI, "VERSION", BINARY_= FILE_TYPE_PEI_DEPEX, "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX}: + raise Warning("Unknown section type '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) + if AlignValue =3D=3D 'Auto' and (not self._Token =3D=3D BINARY= _FILE_TYPE_PE32) and (not self._Token =3D=3D BINARY_FILE_TYPE_TE): + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) =20 # DataSection DataSectionObj =3D DataSection() @@ -2919,11 +3183,13 @@ class FdfParser: else: DataSectionObj.KeepReloc =3D True else: - raise Warning("File type %s, section type %s, could no= t have reloc strip flag%d" % (Obj.FvFileType, DataSectionObj.SecType, self.= CurrentLineNumber), self.FileName, self.CurrentLineNumber) + raise Warning("File type %s, section type %s, could no= t have reloc strip flag%d" % ( + Obj.FvFileType, DataSectionObj.SecType, self.Curre= ntLineNumber), self.FileName, self.CurrentLineNumber) =20 if self._IsToken(TAB_EQUAL_SPLIT): if not self._GetNextToken(): - raise Warning.Expected("section file path", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "section file path", self.FileName, self.CurrentLi= neNumber) DataSectionObj.SectFileName =3D self._Token self._VerifyFile(DataSectionObj.SectFileName) else: @@ -2934,7 +3200,7 @@ class FdfParser: =20 return True =20 - ## _VerifyFile + # _VerifyFile # # Check if file exists or not: # If current phase if GenFds, the file must exist; @@ -2945,11 +3211,12 @@ class FdfParser: if FileName.replace(TAB_WORKSPACE, '').find('$') !=3D -1: return if not GlobalData.gAutoGenPhase or not self._GetMacroValue(TAB_DSC= _DEFINES_OUTPUT_DIRECTORY) in FileName: - ErrorCode, ErrorInfo =3D PathClass(NormPath(FileName), GenFdsG= lobalVariable.WorkSpaceDir).Validate() + ErrorCode, ErrorInfo =3D PathClass( + NormPath(FileName), GenFdsGlobalVariable.WorkSpaceDir).Val= idate() if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) =20 - ## _GetCglSection() method + # _GetCglSection() method # # Get compressed or GUIDed section for Obj # @@ -2959,7 +3226,7 @@ class FdfParser: # @retval True Successfully find section statement # @retval False Not able to find section statement # - def _GetCglSection(self, Obj, AlignValue =3D None): + def _GetCglSection(self, Obj, AlignValue=3DNone): =20 if self._IsKeyword("COMPRESS"): type =3D "PI_STD" @@ -2967,7 +3234,8 @@ class FdfParser: type =3D self._Token =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 CompressSectionObj =3D CompressSection() CompressSectionObj.Alignment =3D AlignValue @@ -2979,9 +3247,9 @@ class FdfParser: if not IsLeafSection and not IsEncapSection: break =20 - if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) Obj.SectionList.append(CompressSectionObj) return True =20 @@ -2989,12 +3257,14 @@ class FdfParser: GuidValue =3D None if self._GetNextGuid(): if self._Token in GlobalData.gGuidDict: - self._Token =3D GuidStructureStringToGuidString(Global= Data.gGuidDict[self._Token]).upper() + self._Token =3D GuidStructureStringToGuidString( + GlobalData.gGuidDict[self._Token]).upper() GuidValue =3D self._Token =20 AttribDict =3D self._GetGuidAttrib() if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) GuidSectionObj =3D GuidSection() GuidSectionObj.Alignment =3D AlignValue GuidSectionObj.NameGuid =3D GuidValue @@ -3010,14 +3280,15 @@ class FdfParser: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) Obj.SectionList.append(GuidSectionObj) =20 return True =20 return False =20 - ## _GetGuidAttri() method + # _GetGuidAttri() method # # Get attributes for GUID section # @@ -3030,14 +3301,16 @@ class FdfParser: AttribDict["AUTH_STATUS_VALID"] =3D "NONE" AttribDict["EXTRA_HEADER_SIZE"] =3D -1 while self._IsKeyword("PROCESSING_REQUIRED") or self._IsKeyword("A= UTH_STATUS_VALID") \ - or self._IsKeyword("EXTRA_HEADER_SIZE"): + or self._IsKeyword("EXTRA_HEADER_SIZE"): AttribKey =3D self._Token =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("TRUE(1)/FALSE(0)/Number", self.Fil= eName, self.CurrentLineNumber) + raise Warning.Expected( + "TRUE(1)/FALSE(0)/Number", self.FileName, self.Current= LineNumber) elif AttribKey =3D=3D "EXTRA_HEADER_SIZE": Base =3D 10 if self._Token[0:2].upper() =3D=3D "0X": @@ -3046,14 +3319,16 @@ class FdfParser: AttribDict[AttribKey] =3D int(self._Token, Base) continue except ValueError: - raise Warning.Expected("Number", self.FileName, self.C= urrentLineNumber) + raise Warning.Expected( + "Number", self.FileName, self.CurrentLineNumber) elif self._Token.upper() not in {"TRUE", "FALSE", "1", "0"}: - raise Warning.Expected("TRUE/FALSE (1/0)", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "TRUE/FALSE (1/0)", self.FileName, self.CurrentLineNum= ber) AttribDict[AttribKey] =3D self._Token =20 return AttribDict =20 - ## _GetEncapsulationSec() method + # _GetEncapsulationSec() method # # Get encapsulation section for FILE # @@ -3066,14 +3341,16 @@ class FdfParser: OldPos =3D self.GetFileBufferPos() if not self._IsKeyword("SECTION"): if len(FfsFileObj.SectionList) =3D=3D 0: - raise Warning.Expected("SECTION", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "SECTION", self.FileName, self.CurrentLineNumber) else: return False =20 AlignValue =3D None if self._GetAlignment(): if self._Token not in ALIGNMENT_NOAUTO: - raise Warning("Incorrect alignment '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) AlignValue =3D self._Token =20 if not self._GetCglSection(FfsFileObj, AlignValue): @@ -3095,35 +3372,44 @@ class FdfParser: self._SkipToToken("[FMPPAYLOAD.", True) FmpUiName =3D self._GetUiName().upper() if FmpUiName in self.Profile.FmpPayloadDict: - raise Warning("Duplicated FMP UI name found: %s" % FmpUiName, = self.FileName, self.CurrentLineNumber) + raise Warning("Duplicated FMP UI name found: %s" % + FmpUiName, self.FileName, self.CurrentLineNumber) =20 FmpData =3D CapsulePayload() FmpData.UiName =3D FmpUiName =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning("The FMP payload section is empty!", self.FileNa= me, self.CurrentLineNumber) - FmpKeyList =3D ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', 'IMA= GE_INDEX', 'HARDWARE_INSTANCE', 'CERTIFICATE_GUID', 'MONOTONIC_COUNT'] + raise Warning("The FMP payload section is empty!", + self.FileName, self.CurrentLineNumber) + FmpKeyList =3D ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', 'IMA= GE_INDEX', + 'HARDWARE_INSTANCE', 'CERTIFICATE_GUID', 'MONOTONIC_= COUNT'] while self._Token in FmpKeyList: Name =3D self._Token FmpKeyList.remove(Name) if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if Name =3D=3D 'IMAGE_TYPE_ID': if not self._GetNextGuid(): - raise Warning.Expected("GUID value for IMAGE_TYPE_ID."= , self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "GUID value for IMAGE_TYPE_ID.", self.FileName, se= lf.CurrentLineNumber) FmpData.ImageTypeId =3D self._Token elif Name =3D=3D 'CERTIFICATE_GUID': if not self._GetNextGuid(): - raise Warning.Expected("GUID value for CERTIFICATE_GUI= D.", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "GUID value for CERTIFICATE_GUID.", self.FileName,= self.CurrentLineNumber) FmpData.Certificate_Guid =3D self._Token if UUID(FmpData.Certificate_Guid) !=3D EFI_CERT_TYPE_RSA20= 48_SHA256_GUID and UUID(FmpData.Certificate_Guid) !=3D EFI_CERT_TYPE_PKCS7_= GUID: - raise Warning("Only support EFI_CERT_TYPE_RSA2048_SHA2= 56_GUID or EFI_CERT_TYPE_PKCS7_GUID for CERTIFICATE_GUID.", self.FileName, = self.CurrentLineNumber) + raise Warning("Only support EFI_CERT_TYPE_RSA2048_SHA2= 56_GUID or EFI_CERT_TYPE_PKCS7_GUID for CERTIFICATE_GUID.", + self.FileName, self.CurrentLineNumber) else: if not self._GetNextToken(): - raise Warning.Expected("value of %s" % Name, self.File= Name, self.CurrentLineNumber) + raise Warning.Expected( + "value of %s" % Name, self.FileName, self.CurrentL= ineNumber) Value =3D self._Token if Name =3D=3D 'IMAGE_HEADER_INIT_VERSION': if FdfParser._Verify(Name, Value, 'UINT8'): @@ -3138,31 +3424,37 @@ class FdfParser: if FdfParser._Verify(Name, Value, 'UINT64'): FmpData.MonotonicCount =3D Value if FmpData.MonotonicCount.upper().startswith('0X'): - FmpData.MonotonicCount =3D int(FmpData.Monoton= icCount, 16) + FmpData.MonotonicCount =3D int( + FmpData.MonotonicCount, 16) else: - FmpData.MonotonicCount =3D int(FmpData.Monoton= icCount) + FmpData.MonotonicCount =3D int( + FmpData.MonotonicCount) if not self._GetNextToken(): break else: self._UndoToken() =20 if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or (n= ot FmpData.MonotonicCount and FmpData.Certificate_Guid): - EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GUID= and MONOTONIC_COUNT must be work as a pair.") + EdkLogger.error("FdfParser", FORMAT_INVALID, + "CERTIFICATE_GUID and MONOTONIC_COUNT must be = work as a pair.") =20 # Only the IMAGE_TYPE_ID is required item if FmpKeyList and 'IMAGE_TYPE_ID' in FmpKeyList: - raise Warning("'IMAGE_TYPE_ID' in FMP payload section.", self.= FileName, self.CurrentLineNumber) + raise Warning("'IMAGE_TYPE_ID' in FMP payload section.", + self.FileName, self.CurrentLineNumber) # get the Image file and Vendor code file self._GetFMPCapsuleData(FmpData) if not FmpData.ImageFile: - raise Warning("Missing image file in FMP payload section.", se= lf.FileName, self.CurrentLineNumber) + raise Warning("Missing image file in FMP payload section.", + self.FileName, self.CurrentLineNumber) # check whether more than one Vendor code file if len(FmpData.VendorCodeFile) > 1: - raise Warning("Vendor code file max of 1 per FMP payload secti= on.", self.FileName, self.CurrentLineNumber) + raise Warning("Vendor code file max of 1 per FMP payload secti= on.", + self.FileName, self.CurrentLineNumber) self.Profile.FmpPayloadDict[FmpUiName] =3D FmpData return True =20 - ## _GetCapsule() method + # _GetCapsule() method # # Get capsule section contents and store its data into capsule list = of self.Profile # @@ -3182,28 +3474,34 @@ class FdfParser: =20 self._UndoToken() if not self._IsToken("[CAPSULE.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) + # print 'Parsing String: %s in File %s, At line: %d, Offset Wi= thin Line: %d' \ # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine:], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning.Expected("[Capsule.]", self.FileName, self.Curre= ntLineNumber) + raise Warning.Expected( + "[Capsule.]", self.FileName, self.CurrentLineNumber) =20 CapsuleObj =3D Capsule() =20 CapsuleName =3D self._GetUiName() if not CapsuleName: - raise Warning.Expected("capsule name", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "capsule name", self.FileName, self.CurrentLineNumber) =20 CapsuleObj.UiCapsuleName =3D CapsuleName.upper() =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 if self._IsKeyword("CREATE_FILE"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("file name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "file name", self.FileName, self.CurrentLineNumber) =20 CapsuleObj.CreateFile =3D self._Token =20 @@ -3211,7 +3509,7 @@ class FdfParser: self.Profile.CapsuleDict[CapsuleObj.UiCapsuleName] =3D CapsuleObj return True =20 - ## _GetCapsuleStatements() method + # _GetCapsuleStatements() method # # Get statements for capsule # @@ -3224,7 +3522,7 @@ class FdfParser: self._GetSetStatements(Obj) self._GetCapsuleData(Obj) =20 - ## _GetCapsuleTokens() method + # _GetCapsuleTokens() method # # Get token statements for capsule # @@ -3237,30 +3535,38 @@ class FdfParser: while self._Token in {"CAPSULE_GUID", "CAPSULE_HEADER_SIZE", "CAPS= ULE_FLAGS", "OEM_CAPSULE_FLAGS", "CAPSULE_HEADER_INIT_VERSION"}: Name =3D self._Token.strip() if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("value", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "value", self.FileName, self.CurrentLineNumber) if Name =3D=3D 'CAPSULE_FLAGS': if not self._Token in {"PersistAcrossReset", "PopulateSyst= emTable", "InitiateReset"}: - raise Warning.Expected("PersistAcrossReset, PopulateSy= stemTable, or InitiateReset", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "PersistAcrossReset, PopulateSystemTable, or Initi= ateReset", self.FileName, self.CurrentLineNumber) Value =3D self._Token.strip() while self._IsToken(TAB_COMMA_SPLIT): Value +=3D TAB_COMMA_SPLIT if not self._GetNextToken(): - raise Warning.Expected("value", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected( + "value", self.FileName, self.CurrentLineNumber) if not self._Token in {"PersistAcrossReset", "Populate= SystemTable", "InitiateReset"}: - raise Warning.Expected("PersistAcrossReset, Popula= teSystemTable, or InitiateReset", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "PersistAcrossReset, PopulateSystemTable, or I= nitiateReset", self.FileName, self.CurrentLineNumber) Value +=3D self._Token.strip() elif Name =3D=3D 'OEM_CAPSULE_FLAGS': Value =3D self._Token.strip() if not Value.upper().startswith('0X'): - raise Warning.Expected("hex value starting with 0x", s= elf.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "hex value starting with 0x", self.FileName, self.= CurrentLineNumber) try: Value =3D int(Value, 0) except ValueError: - raise Warning.Expected("hex string failed to convert t= o value", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "hex string failed to convert to value", self.File= Name, self.CurrentLineNumber) if not 0x0000 <=3D Value <=3D 0xFFFF: - raise Warning.Expected("hex value between 0x0000 and 0= xFFFF", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "hex value between 0x0000 and 0xFFFF", self.FileNa= me, self.CurrentLineNumber) Value =3D self._Token.strip() else: Value =3D self._Token.strip() @@ -3269,7 +3575,7 @@ class FdfParser: return False self._UndoToken() =20 - ## _GetCapsuleData() method + # _GetCapsuleData() method # # Get capsule data for capsule # @@ -3288,7 +3594,7 @@ class FdfParser: if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAfil= e or IsFmp): break =20 - ## _GetFMPCapsuleData() method + # _GetFMPCapsuleData() method # # Get capsule data for FMP capsule # @@ -3303,7 +3609,7 @@ class FdfParser: if not (IsFv or IsFd or IsAnyFile): break =20 - ## _GetFvStatement() method + # _GetFvStatement() method # # Get FV for capsule # @@ -3312,7 +3618,7 @@ class FdfParser: # @retval True Successfully find a FV statement # @retval False Not able to find a FV statement # - def _GetFvStatement(self, CapsuleObj, FMPCapsule =3D False): + def _GetFvStatement(self, CapsuleObj, FMPCapsule=3DFalse): if not self._IsKeyword(BINARY_FILE_TYPE_FV): return False =20 @@ -3320,10 +3626,12 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("FV name", self.FileName, self.CurrentL= ineNumber) + raise Warning.Expected( + "FV name", self.FileName, self.CurrentLineNumber) =20 if self._Token.upper() not in self.Profile.FvDict: - raise Warning("FV name does not exist", self.FileName, self.Cu= rrentLineNumber) + raise Warning("FV name does not exist", + self.FileName, self.CurrentLineNumber) =20 myCapsuleFv =3D CapsuleFv() myCapsuleFv.FvName =3D self._Token @@ -3336,7 +3644,7 @@ class FdfParser: CapsuleObj.CapsuleDataList.append(myCapsuleFv) return True =20 - ## _GetFdStatement() method + # _GetFdStatement() method # # Get FD for capsule # @@ -3345,7 +3653,7 @@ class FdfParser: # @retval True Successfully find a FD statement # @retval False Not able to find a FD statement # - def _GetFdStatement(self, CapsuleObj, FMPCapsule =3D False): + def _GetFdStatement(self, CapsuleObj, FMPCapsule=3DFalse): if not self._IsKeyword("FD"): return False =20 @@ -3353,10 +3661,12 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("FD name", self.FileName, self.CurrentL= ineNumber) + raise Warning.Expected( + "FD name", self.FileName, self.CurrentLineNumber) =20 if self._Token.upper() not in self.Profile.FdDict: - raise Warning("FD name does not exist", self.FileName, self.Cu= rrentLineNumber) + raise Warning("FD name does not exist", + self.FileName, self.CurrentLineNumber) =20 myCapsuleFd =3D CapsuleFd() myCapsuleFd.FdName =3D self._Token @@ -3382,10 +3692,12 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("payload name after FMP_PAYLOAD =3D", s= elf.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "payload name after FMP_PAYLOAD =3D", self.FileName, self.= CurrentLineNumber) Payload =3D self._Token.upper() if Payload not in self.Profile.FmpPayloadDict: - raise Warning("This FMP Payload does not exist: %s" % self._To= ken, self.FileName, self.CurrentLineNumber) + raise Warning("This FMP Payload does not exist: %s" % + self._Token, self.FileName, self.CurrentLineNumb= er) CapsuleObj.FmpPayloadList.append(self.Profile.FmpPayloadDict[Paylo= ad]) return True =20 @@ -3401,17 +3713,19 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("File name", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "File name", self.FileName, self.CurrentLineNumber) =20 AnyFileName =3D self._Token self._VerifyFile(AnyFileName) =20 if not os.path.isabs(AnyFileName): - AnyFileName =3D mws.join(GenFdsGlobalVariable.WorkSpaceDir, An= yFileName) + AnyFileName =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, AnyFileName) =20 return AnyFileName =20 - ## _GetAnyFileStatement() method + # _GetAnyFileStatement() method # # Get AnyFile for capsule # @@ -3420,7 +3734,7 @@ class FdfParser: # @retval True Successfully find a Anyfile statement # @retval False Not able to find a AnyFile statement # - def _GetAnyFileStatement(self, CapsuleObj, FMPCapsule =3D False): + def _GetAnyFileStatement(self, CapsuleObj, FMPCapsule=3DFalse): AnyFileName =3D self._ParseRawFileStatement() if not AnyFileName: return False @@ -3436,7 +3750,7 @@ class FdfParser: CapsuleObj.CapsuleDataList.append(myCapsuleAnyFile) return True =20 - ## _GetAfileStatement() method + # _GetAfileStatement() method # # Get Afile for capsule # @@ -3453,13 +3767,14 @@ class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._GetNextToken(): - raise Warning.Expected("Afile name", self.FileName, self.Curre= ntLineNumber) + raise Warning.Expected( + "Afile name", self.FileName, self.CurrentLineNumber) =20 AfileName =3D self._Token AfileBaseName =3D os.path.basename(AfileName) =20 - if os.path.splitext(AfileBaseName)[1] not in {".bin", ".BIN", ".B= in", ".dat", ".DAT", ".Dat", ".data", ".DATA", ".Data"}: - raise Warning('invalid binary file type, should be one of "bin= ",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"', \ + if os.path.splitext(AfileBaseName)[1] not in {".bin", ".BIN", ".Bi= n", ".dat", ".DAT", ".Dat", ".data", ".DATA", ".Data"}: + raise Warning('invalid binary file type, should be one of "bin= ",BINARY_FILE_TYPE_BIN,"Bin","dat","DAT","Dat","data","DATA","Data"', self.FileName, self.CurrentLineNumber) =20 if not os.path.isabs(AfileName): @@ -3467,7 +3782,8 @@ class FdfParser: self._VerifyFile(AfileName) else: if not os.path.exists(AfileName): - raise Warning('%s does not exist' % AfileName, self.FileNa= me, self.CurrentLineNumber) + raise Warning('%s does not exist' % AfileName, + self.FileName, self.CurrentLineNumber) else: pass =20 @@ -3476,7 +3792,7 @@ class FdfParser: CapsuleObj.CapsuleDataList.append(myCapsuleAfile) return True =20 - ## _GetRule() method + # _GetRule() method # # Get Rule section contents and store its data into rule list of sel= f.Profile # @@ -3495,13 +3811,16 @@ class FdfParser: return False self._UndoToken() if not self._IsToken("[Rule.", True): - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) - #print 'Parsing String: %s in File %s, At line: %d, Offset Wit= hin Line: %d' \ + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) + # print 'Parsing String: %s in File %s, At line: %d, Offset Wi= thin Line: %d' \ # % (self.Profile.FileLinesList[self.CurrentLineNumber = - 1][self.CurrentOffsetWithinLine:], FileLineTuple[0], FileLineTuple[1], se= lf.CurrentOffsetWithinLine) - raise Warning.Expected("[Rule.]", self.FileName, self.CurrentL= ineNumber) + raise Warning.Expected( + "[Rule.]", self.FileName, self.CurrentLineNumber) =20 if not self._SkipToToken(TAB_SPLIT): - raise Warning.Expected("'.'", self.FileName, self.CurrentLineN= umber) + raise Warning.Expected("'.'", self.FileName, + self.CurrentLineNumber) =20 Arch =3D self._SkippedChars.rstrip(TAB_SPLIT) =20 @@ -3510,33 +3829,35 @@ class FdfParser: TemplateName =3D "" if self._IsToken(TAB_SPLIT): if not self._GetNextWord(): - raise Warning.Expected("template name", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected( + "template name", self.FileName, self.CurrentLineNumber) TemplateName =3D self._Token =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 RuleObj =3D self._GetRuleFileStatements() RuleObj.Arch =3D Arch.upper() RuleObj.ModuleType =3D ModuleType RuleObj.TemplateName =3D TemplateName if TemplateName =3D=3D '': - self.Profile.RuleDict['RULE' + \ - TAB_SPLIT + \ - Arch.upper() + \ - TAB_SPLIT + \ - ModuleType.upper() ] =3D RuleObj + self.Profile.RuleDict['RULE' + + TAB_SPLIT + + Arch.upper() + + TAB_SPLIT + + ModuleType.upper()] =3D RuleObj else: - self.Profile.RuleDict['RULE' + \ - TAB_SPLIT + \ - Arch.upper() + \ - TAB_SPLIT + \ - ModuleType.upper() + \ - TAB_SPLIT + \ - TemplateName.upper() ] =3D RuleObj + self.Profile.RuleDict['RULE' + + TAB_SPLIT + + Arch.upper() + + TAB_SPLIT + + ModuleType.upper() + + TAB_SPLIT + + TemplateName.upper()] =3D RuleObj return True =20 - ## _GetModuleType() method + # _GetModuleType() method # # Return the module type # @@ -3545,7 +3866,8 @@ class FdfParser: # def _GetModuleType(self): if not self._GetNextWord(): - raise Warning.Expected("Module type", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "Module type", self.FileName, self.CurrentLineNumber) if self._Token.upper() not in { SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, @@ -3562,10 +3884,11 @@ class FdfParser: EDK_COMPONENT_TYPE_APPLICATION, "ACPITABLE", SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE}: - raise Warning("Unknown Module type '%s'" % self._Token, self.F= ileName, self.CurrentLineNumber) + raise Warning("Unknown Module type '%s'" % + self._Token, self.FileName, self.CurrentLineNumb= er) return self._Token =20 - ## _GetFileExtension() method + # _GetFileExtension() method # # Return the file extension # @@ -3574,7 +3897,8 @@ class FdfParser: # def _GetFileExtension(self): if not self._IsToken(TAB_SPLIT): - raise Warning.Expected("'.'", self.FileName, self.CurrentLineN= umber) + raise Warning.Expected("'.'", self.FileName, + self.CurrentLineNumber) =20 Ext =3D "" if self._GetNextToken(): @@ -3582,12 +3906,14 @@ class FdfParser: Ext =3D self._Token return TAB_SPLIT + Ext else: - raise Warning("Unknown file extension '%s'" % self._Token,= self.FileName, self.CurrentLineNumber) + raise Warning("Unknown file extension '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) =20 else: - raise Warning.Expected("file extension", self.FileName, self.C= urrentLineNumber) + raise Warning.Expected( + "file extension", self.FileName, self.CurrentLineNumber) =20 - ## _GetRuleFileStatement() method + # _GetRuleFileStatement() method # # Get rule contents # @@ -3596,35 +3922,42 @@ class FdfParser: # def _GetRuleFileStatements(self): if not self._IsKeyword("FILE"): - raise Warning.Expected("FILE", self.FileName, self.CurrentLine= Number) + raise Warning.Expected("FILE", self.FileName, + self.CurrentLineNumber) =20 if not self._GetNextWord(): - raise Warning.Expected("FFS type", self.FileName, self.Current= LineNumber) + raise Warning.Expected( + "FFS type", self.FileName, self.CurrentLineNumber) =20 Type =3D self._Token.strip().upper() if Type not in {"RAW", "FREEFORM", SUP_MODULE_SEC, SUP_MODULE_PEI_= CORE, SUP_MODULE_PEIM, "PEI_DXE_COMBO", "DRIVER", SUP_MODULE_DXE_CORE, ED= K_COMPONENT_TYPE_APPLICATION, "FV_IMAGE", "SMM", SUP_MODULE_SMM_CORE, SUP_MODULE= _MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE}: - raise Warning("Unknown FV type '%s'" % self._Token, self.FileN= ame, self.CurrentLineNumber) + raise Warning("Unknown FV type '%s'" % self._Token, + self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNu= mber) =20 if not self._IsKeyword("$(NAMED_GUID)"): if not self._GetNextWord(): - NamedGuid =3D self._CurrentLine()[self.CurrentOffsetWithin= Line:].split()[0].strip() + NamedGuid =3D self._CurrentLine()[self.CurrentOffsetWithin= Line:].split()[ + 0].strip() if GlobalData.gGuidPatternEnd.match(NamedGuid): self.CurrentOffsetWithinLine +=3D len(NamedGuid) self._Token =3D NamedGuid else: - raise Warning.Expected("$(NAMED_GUID)", self.FileName,= self.CurrentLineNumber) + raise Warning.Expected( + "$(NAMED_GUID)", self.FileName, self.CurrentLineNu= mber) if self._Token =3D=3D 'PCD': if not self._IsToken("("): - raise Warning.Expected("'('", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "'('", self.FileName, self.CurrentLineNumber) PcdPair =3D self._GetNextPcdSettings() if not self._IsToken(")"): - raise Warning.Expected("')'", self.FileName, self.Curr= entLineNumber) + raise Warning.Expected( + "')'", self.FileName, self.CurrentLineNumber) self._Token =3D 'PCD('+PcdPair[1]+TAB_SPLIT+PcdPair[0]+')' =20 NameGuid =3D self._Token @@ -3637,7 +3970,8 @@ class FdfParser: else: KeepReloc =3D True else: - raise Warning("File type %s could not have reloc strip fla= g%d" % (Type, self.CurrentLineNumber), self.FileName, self.CurrentLineNumbe= r) + raise Warning("File type %s could not have reloc strip fla= g%d" % ( + Type, self.CurrentLineNumber), self.FileName, self.Cur= rentLineNumber) =20 KeyStringList =3D [] if self._GetNextToken(): @@ -3646,7 +3980,8 @@ class FdfParser: if self._IsToken(TAB_COMMA_SPLIT): while self._GetNextToken(): if not TokenFindPattern.match(self._Token): - raise Warning.Expected("KeyString \"Target_Tag= _Arch\"", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "KeyString \"Target_Tag_Arch\"", self.File= Name, self.CurrentLineNumber) KeyStringList.append(self._Token) =20 if not self._IsToken(TAB_COMMA_SPLIT): @@ -3655,7 +3990,6 @@ class FdfParser: else: self._UndoToken() =20 - Fixed =3D False if self._IsKeyword("Fixed", True): Fixed =3D True @@ -3667,8 +4001,9 @@ class FdfParser: AlignValue =3D "" if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) - #For FFS, Auto is default option same to "" + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) + # For FFS, Auto is default option same to "" if not self._Token =3D=3D "Auto": AlignValue =3D self._Token =20 @@ -3691,25 +4026,27 @@ class FdfParser: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) =20 return NewRule =20 else: # Simple file rule expected if not self._GetNextWord(): - raise Warning.Expected("leaf section type", self.FileName,= self.CurrentLineNumber) + raise Warning.Expected( + "leaf section type", self.FileName, self.CurrentLineNu= mber) =20 SectionName =3D self._Token =20 if SectionName not in { "COMPAT16", BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", - "RAW",BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, + "RAW", BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", BINARY_FILE_TYPE_SMM_DEPEX}: - raise Warning("Unknown leaf section name '%s'" % SectionNa= me, self.FileName, self.CurrentLineNumber) - + raise Warning("Unknown leaf section name '%s'" % + SectionName, self.FileName, self.CurrentLine= Number) =20 if self._IsKeyword("Fixed", True): Fixed =3D True @@ -3720,16 +4057,19 @@ class FdfParser: SectAlignment =3D "" if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token= , self.FileName, self.CurrentLineNumber) + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.Current= LineNumber) if self._Token =3D=3D 'Auto' and (not SectionName =3D=3D B= INARY_FILE_TYPE_PE32) and (not SectionName =3D=3D BINARY_FILE_TYPE_TE): - raise Warning("Auto alignment can only be used in PE32= or TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32= or TE section ", + self.FileName, self.CurrentLineNumber) SectAlignment =3D self._Token =20 Ext =3D None if self._IsToken(TAB_VALUE_SPLIT): Ext =3D self._GetFileExtension() elif not self._GetNextToken(): - raise Warning.Expected("File name", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "File name", self.FileName, self.CurrentLineNumber) =20 NewRule =3D RuleSimpleFile() NewRule.SectionType =3D SectionName @@ -3746,7 +4086,7 @@ class FdfParser: NewRule.FileName =3D self._Token return NewRule =20 - ## _GetEfiSection() method + # _GetEfiSection() method # # Get section list for Rule # @@ -3759,7 +4099,8 @@ class FdfParser: OldPos =3D self.GetFileBufferPos() EfiSectionObj =3D EfiSection() if not self._GetNextWord(): - CurrentLine =3D self._CurrentLine()[self.CurrentOffsetWithinLi= ne:].split()[0].strip() + CurrentLine =3D self._CurrentLine()[self.CurrentOffsetWithinLi= ne:].split()[ + 0].strip() if self._Token =3D=3D '{' and Obj.FvFileType =3D=3D "RAW" and = TAB_SPLIT in CurrentLine: if self._IsToken(TAB_VALUE_SPLIT): EfiSectionObj.FileExtension =3D self._GetFileExtension= () @@ -3773,11 +4114,11 @@ class FdfParser: SectionName =3D self._Token =20 if SectionName not in { - "COMPAT16", BINARY_FILE_TYPE_PE32, - BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", - "RAW",BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, - BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", - BINARY_FILE_TYPE_SMM_DEPEX, BINARY_FILE_TYPE_GUID}: + "COMPAT16", BINARY_FILE_TYPE_PE32, + BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", + "RAW", BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, + BINARY_FILE_TYPE_PEI_DEPEX, "VERSION", "SUBTYPE_GUID", + BINARY_FILE_TYPE_SMM_DEPEX, BINARY_FILE_TYPE_GUID}: self._UndoToken() return False =20 @@ -3802,18 +4143,21 @@ class FdfParser: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) FvImageSectionObj.Fv =3D FvObj FvImageSectionObj.FvName =3D None =20 else: if not self._IsKeyword(BINARY_FILE_TYPE_FV): - raise Warning.Expected("'FV'", self.FileName, self.Cur= rentLineNumber) + raise Warning.Expected( + "'FV'", self.FileName, self.CurrentLineNumber) FvImageSectionObj.FvFileType =3D self._Token =20 if self._GetAlignment(): if self._Token not in ALIGNMENT_NOAUTO: - raise Warning("Incorrect alignment '%s'" % self._T= oken, self.FileName, self.CurrentLineNumber) + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.Cur= rentLineNumber) FvImageSectionObj.Alignment =3D self._Token =20 if self._IsToken(TAB_VALUE_SPLIT): @@ -3830,7 +4174,8 @@ class FdfParser: else: self._UndoToken() else: - raise Warning.Expected("FV file name", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "FV file name", self.FileName, self.CurrentLineNum= ber) =20 Obj.SectionList.append(FvImageSectionObj) return True @@ -3838,55 +4183,69 @@ class FdfParser: EfiSectionObj.SectionType =3D SectionName =20 if not self._GetNextToken(): - raise Warning.Expected("file type", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "file type", self.FileName, self.CurrentLineNumber) =20 if self._Token =3D=3D "STRING": if not self._RuleSectionCouldHaveString(EfiSectionObj.SectionT= ype): - raise Warning("%s section could NOT have string data%d" % = (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.Cu= rrentLineNumber) + raise Warning("%s section could NOT have string data%d" % ( + EfiSectionObj.SectionType, self.CurrentLineNumber), se= lf.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) =20 if not self._GetNextToken(): - raise Warning.Expected("Quoted String", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected( + "Quoted String", self.FileName, self.CurrentLineNumber) =20 if self._GetStringData(): EfiSectionObj.StringData =3D self._Token =20 if self._IsKeyword("BUILD_NUM"): if not self._RuleSectionCouldHaveBuildNum(EfiSectionObj.Se= ctionType): - raise Warning("%s section could NOT have BUILD_NUM%d" = % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.= CurrentLineNumber) + raise Warning("%s section could NOT have BUILD_NUM%d" = % ( + EfiSectionObj.SectionType, self.CurrentLineNumber)= , self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("Build number", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "Build number", self.FileName, self.CurrentLineNum= ber) EfiSectionObj.BuildNum =3D self._Token =20 else: EfiSectionObj.FileType =3D self._Token - self._CheckRuleSectionFileType(EfiSectionObj.SectionType, EfiS= ectionObj.FileType) + self._CheckRuleSectionFileType( + EfiSectionObj.SectionType, EfiSectionObj.FileType) =20 if self._IsKeyword("Optional"): if not self._RuleSectionCouldBeOptional(EfiSectionObj.SectionT= ype): - raise Warning("%s section could NOT be optional%d" % (EfiS= ectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.Current= LineNumber) + raise Warning("%s section could NOT be optional%d" % ( + EfiSectionObj.SectionType, self.CurrentLineNumber), se= lf.FileName, self.CurrentLineNumber) EfiSectionObj.Optional =3D True =20 if self._IsKeyword("BUILD_NUM"): if not self._RuleSectionCouldHaveBuildNum(EfiSectionObj.Se= ctionType): - raise Warning("%s section could NOT have BUILD_NUM%d" = % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.= CurrentLineNumber) + raise Warning("%s section could NOT have BUILD_NUM%d" = % ( + EfiSectionObj.SectionType, self.CurrentLineNumber)= , self.FileName, self.CurrentLineNumber) =20 if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("Build number", self.FileName, = self.CurrentLineNumber) + raise Warning.Expected( + "Build number", self.FileName, self.CurrentLineNum= ber) EfiSectionObj.BuildNum =3D self._Token =20 if self._GetAlignment(): if self._Token not in ALIGNMENTS: - raise Warning("Incorrect alignment '%s'" % self._Token, se= lf.FileName, self.CurrentLineNumber) + raise Warning("Incorrect alignment '%s'" % + self._Token, self.FileName, self.CurrentLine= Number) if self._Token =3D=3D 'Auto' and (not SectionName =3D=3D BINAR= Y_FILE_TYPE_PE32) and (not SectionName =3D=3D BINARY_FILE_TYPE_TE): - raise Warning("Auto alignment can only be used in PE32 or = TE section ", self.FileName, self.CurrentLineNumber) + raise Warning("Auto alignment can only be used in PE32 or = TE section ", + self.FileName, self.CurrentLineNumber) EfiSectionObj.Alignment =3D self._Token =20 if self._IsKeyword('RELOCS_STRIPPED') or self._IsKeyword('RELOCS_R= ETAINED'): @@ -3896,10 +4255,11 @@ class FdfParser: else: EfiSectionObj.KeepReloc =3D True if Obj.KeepReloc is not None and Obj.KeepReloc !=3D EfiSec= tionObj.KeepReloc: - raise Warning("Section type %s has reloc strip flag co= nflict with Rule" % EfiSectionObj.SectionType, self.FileName, self.CurrentL= ineNumber) + raise Warning("Section type %s has reloc strip flag co= nflict with Rule" % + EfiSectionObj.SectionType, self.FileName= , self.CurrentLineNumber) else: - raise Warning("Section type %s could not have reloc strip = flag" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber) - + raise Warning("Section type %s could not have reloc strip = flag" % + EfiSectionObj.SectionType, self.FileName, se= lf.CurrentLineNumber) =20 if self._IsToken(TAB_VALUE_SPLIT): EfiSectionObj.FileExtension =3D self._GetFileExtension() @@ -3918,23 +4278,27 @@ class FdfParser: =20 if self._Token =3D=3D 'PCD': if not self._IsToken("("): - raise Warning.Expected("'('", self.FileName, s= elf.CurrentLineNumber) + raise Warning.Expected( + "'('", self.FileName, self.CurrentLineNumb= er) PcdPair =3D self._GetNextPcdSettings() if not self._IsToken(")"): - raise Warning.Expected("')'", self.FileName, s= elf.CurrentLineNumber) - self._Token =3D 'PCD('+PcdPair[1]+TAB_SPLIT+PcdPai= r[0]+')' + raise Warning.Expected( + "')'", self.FileName, self.CurrentLineNumb= er) + self._Token =3D 'PCD(' + \ + PcdPair[1]+TAB_SPLIT+PcdPair[0]+')' =20 EfiSectionObj.FileName =3D self._Token =20 else: self._UndoToken() else: - raise Warning.Expected("section file name", self.FileName, sel= f.CurrentLineNumber) + raise Warning.Expected("section file name", + self.FileName, self.CurrentLineNumber) =20 Obj.SectionList.append(EfiSectionObj) return True =20 - ## _RuleSectionCouldBeOptional() method + # _RuleSectionCouldBeOptional() method # # Get whether a section could be optional # @@ -3949,7 +4313,7 @@ class FdfParser: else: return False =20 - ## _RuleSectionCouldHaveBuildNum() method + # _RuleSectionCouldHaveBuildNum() method # # Get whether a section could have build number information # @@ -3964,7 +4328,7 @@ class FdfParser: else: return False =20 - ## _RuleSectionCouldHaveString() method + # _RuleSectionCouldHaveString() method # # Get whether a section could have string # @@ -3979,7 +4343,7 @@ class FdfParser: else: return False =20 - ## _CheckRuleSectionFileType() method + # _CheckRuleSectionFileType() method # # Get whether a section matches a file type # @@ -3991,36 +4355,46 @@ class FdfParser: WarningString =3D "Incorrect section file type '%s'" if SectionType =3D=3D "COMPAT16": if FileType not in {"COMPAT16", "SEC_COMPAT16"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_PE32: if FileType not in {BINARY_FILE_TYPE_PE32, "SEC_PE32"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_PIC: if FileType not in {BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_PIC= }: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_TE: if FileType not in {BINARY_FILE_TYPE_TE, "SEC_TE"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D "RAW": if FileType not in {BINARY_FILE_TYPE_BIN, "SEC_BIN", "RAW", "A= SL", "ACPI"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_DXE_DEPEX or SectionType = =3D=3D BINARY_FILE_TYPE_SMM_DEPEX: if FileType not in {BINARY_FILE_TYPE_DXE_DEPEX, "SEC_DXE_DEPEX= ", BINARY_FILE_TYPE_SMM_DEPEX}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_UI: if FileType not in {BINARY_FILE_TYPE_UI, "SEC_UI"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D "VERSION": if FileType not in {"VERSION", "SEC_VERSION"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_PEI_DEPEX: if FileType not in {BINARY_FILE_TYPE_PEI_DEPEX, "SEC_PEI_DEPEX= "}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) elif SectionType =3D=3D BINARY_FILE_TYPE_GUID: if FileType not in {BINARY_FILE_TYPE_PE32, "SEC_GUID"}: - raise Warning(WarningString % FileType, self.FileName, sel= f.CurrentLineNumber) + raise Warning(WarningString % + FileType, self.FileName, self.CurrentLineNum= ber) =20 - ## _GetRuleEncapsulationSection() method + # _GetRuleEncapsulationSection() method # # Get encapsulation section for Rule # @@ -4036,20 +4410,23 @@ class FdfParser: Type =3D self._Token =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) =20 CompressSectionObj =3D CompressSection() =20 CompressSectionObj.CompType =3D Type # Recursive sections... while True: - IsEncapsulate =3D self._GetRuleEncapsulationSection(Compre= ssSectionObj) + IsEncapsulate =3D self._GetRuleEncapsulationSection( + CompressSectionObj) IsLeaf =3D self._GetEfiSection(CompressSectionObj) if not IsEncapsulate and not IsLeaf: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) theRule.SectionList.append(CompressSectionObj) =20 return True @@ -4058,7 +4435,8 @@ class FdfParser: GuidValue =3D None if self._GetNextGuid(): if self._Token in GlobalData.gGuidDict: - self._Token =3D GuidStructureStringToGuidString(Global= Data.gGuidDict[self._Token]).upper() + self._Token =3D GuidStructureStringToGuidString( + GlobalData.gGuidDict[self._Token]).upper() GuidValue =3D self._Token =20 if self._IsKeyword("$(NAMED_GUID)"): @@ -4067,7 +4445,8 @@ class FdfParser: AttribDict =3D self._GetGuidAttrib() =20 if not self._IsToken("{"): - raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) + raise Warning.ExpectedCurlyOpen( + self.FileName, self.CurrentLineNumber) GuidSectionObj =3D GuidSection() GuidSectionObj.NameGuid =3D GuidValue GuidSectionObj.SectionType =3D "GUIDED" @@ -4077,20 +4456,22 @@ class FdfParser: =20 # Efi sections... while True: - IsEncapsulate =3D self._GetRuleEncapsulationSection(GuidSe= ctionObj) + IsEncapsulate =3D self._GetRuleEncapsulationSection( + GuidSectionObj) IsLeaf =3D self._GetEfiSection(GuidSectionObj) if not IsEncapsulate and not IsLeaf: break =20 if not self._IsToken(T_CHAR_BRACE_R): - raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) + raise Warning.ExpectedCurlyClose( + self.FileName, self.CurrentLineNumber) theRule.SectionList.append(GuidSectionObj) =20 return True =20 return False =20 - ## _GetOptionRom() method + # _GetOptionRom() method # # Get OptionROM section contents and store its data into OptionROM l= ist of self.Profile # @@ -4110,12 +4491,14 @@ class FdfParser: =20 self._UndoToken() if not self._IsToken("[OptionRom.", True): - raise Warning("Unknown Keyword '%s'" % self._Token, self.FileN= ame, self.CurrentLineNumber) + raise Warning("Unknown Keyword '%s'" % self._Token, + self.FileName, self.CurrentLineNumber) =20 OptRomName =3D self._GetUiName() =20 if not self._IsToken(TAB_SECTION_END): - raise Warning.ExpectedBracketClose(self.FileName, self.Current= LineNumber) + raise Warning.ExpectedBracketClose( + self.FileName, self.CurrentLineNumber) =20 OptRomObj =3D OPTIONROM(OptRomName) self.Profile.OptRomDict[OptRomName] =3D OptRomObj @@ -4128,7 +4511,7 @@ class FdfParser: =20 return True =20 - ## _GetOptRomInfStatement() method + # _GetOptRomInfStatement() method # # Get INF statements # @@ -4145,37 +4528,41 @@ class FdfParser: self._GetInfOptions(ffsInf) =20 if not self._GetNextToken(): - raise Warning.Expected("INF file path", self.FileName, self.Cu= rrentLineNumber) + raise Warning.Expected( + "INF file path", self.FileName, self.CurrentLineNumber) ffsInf.InfFileName =3D self._Token if ffsInf.InfFileName.replace(TAB_WORKSPACE, '').find('$') =3D=3D = -1: - #check for file path - ErrorCode, ErrorInfo =3D PathClass(NormPath(ffsInf.InfFileName= ), GenFdsGlobalVariable.WorkSpaceDir).Validate() + # check for file path + ErrorCode, ErrorInfo =3D PathClass( + NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpa= ceDir).Validate() if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) =20 NewFileName =3D ffsInf.InfFileName if ffsInf.OverrideGuid: - NewFileName =3D ProcessDuplicatedInf(PathClass(ffsInf.InfFileN= ame,GenFdsGlobalVariable.WorkSpaceDir), ffsInf.OverrideGuid, GenFdsGlobalVa= riable.WorkSpaceDir).Path + NewFileName =3D ProcessDuplicatedInf(PathClass( + ffsInf.InfFileName, GenFdsGlobalVariable.WorkSpaceDir), ff= sInf.OverrideGuid, GenFdsGlobalVariable.WorkSpaceDir).Path =20 if not NewFileName in self.Profile.InfList: self.Profile.InfList.append(NewFileName) - FileLineTuple =3D GetRealFileLine(self.FileName, self.CurrentL= ineNumber) + FileLineTuple =3D GetRealFileLine( + self.FileName, self.CurrentLineNumber) self.Profile.InfFileLineList.append(FileLineTuple) if ffsInf.UseArch: if ffsInf.UseArch not in self.Profile.InfDict: self.Profile.InfDict[ffsInf.UseArch] =3D [ffsInf.InfFi= leName] else: - self.Profile.InfDict[ffsInf.UseArch].append(ffsInf.Inf= FileName) + self.Profile.InfDict[ffsInf.UseArch].append( + ffsInf.InfFileName) else: self.Profile.InfDict['ArchTBD'].append(ffsInf.InfFileName) =20 - - self._GetOptRomOverrides (ffsInf) + self._GetOptRomOverrides(ffsInf) =20 Obj.FfsList.append(ffsInf) return True =20 - ## _GetOptRomOverrides() method + # _GetOptRomOverrides() method # # Get overrides for OptROM INF & FILE # @@ -4188,55 +4575,67 @@ class FdfParser: while True: if self._IsKeyword("PCI_VENDOR_ID"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextHexNumber(): - raise Warning.Expected("Hex vendor id", self.FileN= ame, self.CurrentLineNumber) + raise Warning.Expected( + "Hex vendor id", self.FileName, self.CurrentLi= neNumber) Overrides.PciVendorId =3D self._Token continue =20 if self._IsKeyword("PCI_CLASS_CODE"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextHexNumber(): - raise Warning.Expected("Hex class code", self.File= Name, self.CurrentLineNumber) + raise Warning.Expected( + "Hex class code", self.FileName, self.CurrentL= ineNumber) Overrides.PciClassCode =3D self._Token continue =20 if self._IsKeyword("PCI_DEVICE_ID"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) # Get a list of PCI IDs Overrides.PciDeviceId =3D "" while (self._GetNextHexNumber()): - Overrides.PciDeviceId =3D "{} {}".format(Overrides= .PciDeviceId, self._Token) + Overrides.PciDeviceId =3D "{} {}".format( + Overrides.PciDeviceId, self._Token) if not Overrides.PciDeviceId: - raise Warning.Expected("one or more Hex device ids= ", self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "one or more Hex device ids", self.FileName, s= elf.CurrentLineNumber) continue =20 if self._IsKeyword("PCI_REVISION"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextHexNumber(): - raise Warning.Expected("Hex revision", self.FileNa= me, self.CurrentLineNumber) + raise Warning.Expected( + "Hex revision", self.FileName, self.CurrentLin= eNumber) Overrides.PciRevision =3D self._Token continue =20 if self._IsKeyword("PCI_COMPRESS"): if not self._IsToken(TAB_EQUAL_SPLIT): - raise Warning.ExpectedEquals(self.FileName, self.C= urrentLineNumber) + raise Warning.ExpectedEquals( + self.FileName, self.CurrentLineNumber) if not self._GetNextToken(): - raise Warning.Expected("TRUE/FALSE for compress", = self.FileName, self.CurrentLineNumber) + raise Warning.Expected( + "TRUE/FALSE for compress", self.FileName, self= .CurrentLineNumber) Overrides.NeedCompress =3D self._Token.upper() =3D=3D = 'TRUE' continue =20 if self._IsToken(T_CHAR_BRACE_R): break else: - EdkLogger.error("FdfParser", FORMAT_INVALID, File=3Dse= lf.FileName, Line=3Dself.CurrentLineNumber) + EdkLogger.error("FdfParser", FORMAT_INVALID, + File=3Dself.FileName, Line=3Dself.Curr= entLineNumber) =20 Obj.OverrideAttribs =3D Overrides =20 - ## _GetOptRomFileStatement() method + # _GetOptRomFileStatement() method # # Get FILE statements # @@ -4252,15 +4651,18 @@ class FdfParser: FfsFileObj =3D OptRomFileStatement() =20 if not self._IsKeyword("EFI") and not self._IsKeyword(BINARY_FILE_= TYPE_BIN): - raise Warning.Expected("Binary type (EFI/BIN)", self.FileName,= self.CurrentLineNumber) + raise Warning.Expected( + "Binary type (EFI/BIN)", self.FileName, self.CurrentLineNu= mber) FfsFileObj.FileType =3D self._Token =20 if not self._GetNextToken(): - raise Warning.Expected("File path", self.FileName, self.Curren= tLineNumber) + raise Warning.Expected( + "File path", self.FileName, self.CurrentLineNumber) FfsFileObj.FileName =3D self._Token if FfsFileObj.FileName.replace(TAB_WORKSPACE, '').find('$') =3D=3D= -1: - #check for file path - ErrorCode, ErrorInfo =3D PathClass(NormPath(FfsFileObj.FileNam= e), GenFdsGlobalVariable.WorkSpaceDir).Validate() + # check for file path + ErrorCode, ErrorInfo =3D PathClass( + NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSp= aceDir).Validate() if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) =20 @@ -4271,7 +4673,7 @@ class FdfParser: =20 return True =20 - ## _GetCapInFd() method + # _GetCapInFd() method # # Get Cap list contained in FD # @@ -4279,7 +4681,7 @@ class FdfParser: # @param FdName FD name # @retval CapList List of Capsule in FD # - def _GetCapInFd (self, FdName): + def _GetCapInFd(self, FdName): CapList =3D [] if FdName.upper() in self.Profile.FdDict: FdObj =3D self.Profile.FdDict[FdName.upper()] @@ -4292,7 +4694,7 @@ class FdfParser: CapList.append(elementRegionData.upper()) return CapList =20 - ## _GetReferencedFdCapTuple() method + # _GetReferencedFdCapTuple() method # # Get FV and FD list referenced by a capsule image # @@ -4301,12 +4703,12 @@ class FdfParser: # @param RefFdList referenced FD by section # @param RefFvList referenced FV by section # - def _GetReferencedFdCapTuple(self, CapObj, RefFdList =3D [], RefFvList= =3D []): + def _GetReferencedFdCapTuple(self, CapObj, RefFdList=3D[], RefFvList= =3D[]): for CapsuleDataObj in CapObj.CapsuleDataList: if hasattr(CapsuleDataObj, 'FvName') and CapsuleDataObj.FvName= is not None and CapsuleDataObj.FvName.upper() not in RefFvList: - RefFvList.append (CapsuleDataObj.FvName.upper()) + RefFvList.append(CapsuleDataObj.FvName.upper()) elif hasattr(CapsuleDataObj, 'FdName') and CapsuleDataObj.FdNa= me is not None and CapsuleDataObj.FdName.upper() not in RefFdList: - RefFdList.append (CapsuleDataObj.FdName.upper()) + RefFdList.append(CapsuleDataObj.FdName.upper()) elif CapsuleDataObj.Ffs is not None: if isinstance(CapsuleDataObj.Ffs, FileStatement): if CapsuleDataObj.Ffs.FvName is not None and CapsuleDa= taObj.Ffs.FvName.upper() not in RefFvList: @@ -4314,9 +4716,10 @@ class FdfParser: elif CapsuleDataObj.Ffs.FdName is not None and Capsule= DataObj.Ffs.FdName.upper() not in RefFdList: RefFdList.append(CapsuleDataObj.Ffs.FdName.upper()) else: - self._GetReferencedFdFvTupleFromSection(CapsuleDat= aObj.Ffs, RefFdList, RefFvList) + self._GetReferencedFdFvTupleFromSection( + CapsuleDataObj.Ffs, RefFdList, RefFvList) =20 - ## _GetFvInFd() method + # _GetFvInFd() method # # Get FV list contained in FD # @@ -4324,7 +4727,7 @@ class FdfParser: # @param FdName FD name # @retval FvList list of FV in FD # - def _GetFvInFd (self, FdName): + def _GetFvInFd(self, FdName): FvList =3D [] if FdName.upper() in self.Profile.FdDict: FdObj =3D self.Profile.FdDict[FdName.upper()] @@ -4337,7 +4740,7 @@ class FdfParser: FvList.append(elementRegionData.upper()) return FvList =20 - ## _GetReferencedFdFvTuple() method + # _GetReferencedFdFvTuple() method # # Get FD and FV list referenced by a FFS file # @@ -4346,7 +4749,7 @@ class FdfParser: # @param RefFdList referenced FD by section # @param RefFvList referenced FV by section # - def _GetReferencedFdFvTuple(self, FvObj, RefFdList =3D [], RefFvList = =3D []): + def _GetReferencedFdFvTuple(self, FvObj, RefFdList=3D[], RefFvList=3D[= ]): for FfsObj in FvObj.FfsList: if isinstance(FfsObj, FileStatement): if FfsObj.FvName is not None and FfsObj.FvName.upper() not= in RefFvList: @@ -4354,9 +4757,10 @@ class FdfParser: elif FfsObj.FdName is not None and FfsObj.FdName.upper() n= ot in RefFdList: RefFdList.append(FfsObj.FdName.upper()) else: - self._GetReferencedFdFvTupleFromSection(FfsObj, RefFdL= ist, RefFvList) + self._GetReferencedFdFvTupleFromSection( + FfsObj, RefFdList, RefFvList) =20 - ## _GetReferencedFdFvTupleFromSection() method + # _GetReferencedFdFvTupleFromSection() method # # Get FD and FV list referenced by a FFS section # @@ -4365,7 +4769,7 @@ class FdfParser: # @param FdList referenced FD by section # @param FvList referenced FV by section # - def _GetReferencedFdFvTupleFromSection(self, FfsFile, FdList =3D [], F= vList =3D []): + def _GetReferencedFdFvTupleFromSection(self, FfsFile, FdList=3D[], FvL= ist=3D[]): SectionStack =3D list(FfsFile.SectionList) while SectionStack !=3D []: SectionObj =3D SectionStack.pop() @@ -4379,7 +4783,7 @@ class FdfParser: if isinstance(SectionObj, CompressSection) or isinstance(Secti= onObj, GuidSection): SectionStack.extend(SectionObj.SectionList) =20 - ## CycleReferenceCheck() method + # CycleReferenceCheck() method # # Check whether cycle reference exists in FDF # @@ -4391,7 +4795,7 @@ class FdfParser: # # Check the cycle between FV and FD image # - MaxLength =3D len (self.Profile.FvDict) + MaxLength =3D len(self.Profile.FvDict) for FvName in self.Profile.FvDict: LogStr =3D "\nCycle Reference Checking for FV: %s\n" % FvName RefFvStack =3D set(FvName) @@ -4414,11 +4818,13 @@ class FdfParser: if RefFdName in FdAnalyzedList: continue =20 - LogStr +=3D "FV %s contains FD %s\n" % (FvNameFromStac= k, RefFdName) + LogStr +=3D "FV %s contains FD %s\n" % ( + FvNameFromStack, RefFdName) FvInFdList =3D self._GetFvInFd(RefFdName) if FvInFdList !=3D []: for FvNameInFd in FvInFdList: - LogStr +=3D "FD %s contains FV %s\n" % (RefFdN= ame, FvNameInFd) + LogStr +=3D "FD %s contains FV %s\n" % ( + RefFdName, FvNameInFd) if FvNameInFd not in RefFvStack: RefFvStack.add(FvNameInFd) =20 @@ -4428,7 +4834,8 @@ class FdfParser: FdAnalyzedList.add(RefFdName) =20 for RefFvName in RefFvList: - LogStr +=3D "FV %s contains FV %s\n" % (FvNameFromStac= k, RefFvName) + LogStr +=3D "FV %s contains FV %s\n" % ( + FvNameFromStack, RefFvName) if RefFvName not in RefFvStack: RefFvStack.add(RefFvName) =20 @@ -4439,7 +4846,7 @@ class FdfParser: # # Check the cycle between Capsule and FD image # - MaxLength =3D len (self.Profile.CapsuleDict) + MaxLength =3D len(self.Profile.CapsuleDict) for CapName in self.Profile.CapsuleDict: # # Capsule image to be checked. @@ -4464,14 +4871,16 @@ class FdfParser: =20 FvListLength =3D 0 FdListLength =3D 0 - while FvListLength < len (RefFvList) or FdListLength < len= (RefFdList): + while FvListLength < len(RefFvList) or FdListLength < len(= RefFdList): for RefFdName in RefFdList: if RefFdName in FdAnalyzedList: continue =20 - LogStr +=3D "Capsule %s contains FD %s\n" % (CapNa= meFromStack, RefFdName) + LogStr +=3D "Capsule %s contains FD %s\n" % ( + CapNameFromStack, RefFdName) for CapNameInFd in self._GetCapInFd(RefFdName): - LogStr +=3D "FD %s contains Capsule %s\n" % (R= efFdName, CapNameInFd) + LogStr +=3D "FD %s contains Capsule %s\n" % ( + RefFdName, CapNameInFd) if CapNameInFd not in RefCapStack: RefCapStack.append(CapNameInFd) =20 @@ -4480,7 +4889,8 @@ class FdfParser: return True =20 for FvNameInFd in self._GetFvInFd(RefFdName): - LogStr +=3D "FD %s contains FV %s\n" % (RefFdN= ame, FvNameInFd) + LogStr +=3D "FD %s contains FV %s\n" % ( + RefFdName, FvNameInFd) if FvNameInFd not in RefFvList: RefFvList.append(FvNameInFd) =20 @@ -4488,25 +4898,28 @@ class FdfParser: # # the number of the parsed FV and FD image # - FvListLength =3D len (RefFvList) - FdListLength =3D len (RefFdList) + FvListLength =3D len(RefFvList) + FdListLength =3D len(RefFdList) for RefFvName in RefFvList: if RefFvName in FvAnalyzedList: continue - LogStr +=3D "Capsule %s contains FV %s\n" % (CapNa= meFromStack, RefFvName) + LogStr +=3D "Capsule %s contains FV %s\n" % ( + CapNameFromStack, RefFvName) if RefFvName.upper() in self.Profile.FvDict: FvObj =3D self.Profile.FvDict[RefFvName.upper(= )] else: continue - self._GetReferencedFdFvTuple(FvObj, RefFdList, Ref= FvList) + self._GetReferencedFdFvTuple( + FvObj, RefFdList, RefFvList) FvAnalyzedList.add(RefFvName) =20 return False =20 - def GetAllIncludedFile (self): + def GetAllIncludedFile(self): global AllIncludeFileList return AllIncludeFileList =20 + if __name__ =3D=3D "__main__": import sys try: @@ -4523,4 +4936,3 @@ if __name__ =3D=3D "__main__": print(str(X)) else: print("Success!") - diff --git a/BaseTools/Source/Python/GenFds/Ffs.py b/BaseTools/Source/Pytho= n/GenFds/Ffs.py index 4e58df279b14..272fabc41e03 100644 --- a/BaseTools/Source/Python/GenFds/Ffs.py +++ b/BaseTools/Source/Python/GenFds/Ffs.py @@ -1,4 +1,4 @@ -## @file +# @file # process FFS generation # # Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
        @@ -13,37 +13,37 @@ from Common.DataType import * =20 # mapping between FILE type in FDF and file type for GenFfs FdfFvFileTypeToFileType =3D { - SUP_MODULE_SEC : 'EFI_FV_FILETYPE_SECURITY_CORE', - SUP_MODULE_PEI_CORE : 'EFI_FV_FILETYPE_PEI_CORE', - SUP_MODULE_PEIM : 'EFI_FV_FILETYPE_PEIM', - SUP_MODULE_DXE_CORE : 'EFI_FV_FILETYPE_DXE_CORE', - 'FREEFORM' : 'EFI_FV_FILETYPE_FREEFORM', - 'DRIVER' : 'EFI_FV_FILETYPE_DRIVER', - 'APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION', - 'FV_IMAGE' : 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE', - 'RAW' : 'EFI_FV_FILETYPE_RAW', - 'PEI_DXE_COMBO' : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER', - 'SMM' : 'EFI_FV_FILETYPE_SMM', - SUP_MODULE_SMM_CORE : 'EFI_FV_FILETYPE_SMM_CORE', - SUP_MODULE_MM_STANDALONE : 'EFI_FV_FILETYPE_MM_STANDALONE', - SUP_MODULE_MM_CORE_STANDALONE : 'EFI_FV_FILETYPE_MM_CORE_STANDALONE' + SUP_MODULE_SEC: 'EFI_FV_FILETYPE_SECURITY_CORE', + SUP_MODULE_PEI_CORE: 'EFI_FV_FILETYPE_PEI_CORE', + SUP_MODULE_PEIM: 'EFI_FV_FILETYPE_PEIM', + SUP_MODULE_DXE_CORE: 'EFI_FV_FILETYPE_DXE_CORE', + 'FREEFORM': 'EFI_FV_FILETYPE_FREEFORM', + 'DRIVER': 'EFI_FV_FILETYPE_DRIVER', + 'APPLICATION': 'EFI_FV_FILETYPE_APPLICATION', + 'FV_IMAGE': 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE', + 'RAW': 'EFI_FV_FILETYPE_RAW', + 'PEI_DXE_COMBO': 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER', + 'SMM': 'EFI_FV_FILETYPE_SMM', + SUP_MODULE_SMM_CORE: 'EFI_FV_FILETYPE_SMM_CORE', + SUP_MODULE_MM_STANDALONE: 'EFI_FV_FILETYPE_MM_STANDALONE', + SUP_MODULE_MM_CORE_STANDALONE: 'EFI_FV_FILETYPE_MM_CORE_STANDALONE' } =20 # mapping between section type in FDF and file suffix SectionSuffix =3D { - BINARY_FILE_TYPE_PE32 : '.pe32', - BINARY_FILE_TYPE_PIC : '.pic', - BINARY_FILE_TYPE_TE : '.te', - BINARY_FILE_TYPE_DXE_DEPEX : '.dpx', - 'VERSION' : '.ver', - BINARY_FILE_TYPE_UI : '.ui', - 'COMPAT16' : '.com16', - 'RAW' : '.raw', + BINARY_FILE_TYPE_PE32: '.pe32', + BINARY_FILE_TYPE_PIC: '.pic', + BINARY_FILE_TYPE_TE: '.te', + BINARY_FILE_TYPE_DXE_DEPEX: '.dpx', + 'VERSION': '.ver', + BINARY_FILE_TYPE_UI: '.ui', + 'COMPAT16': '.com16', + 'RAW': '.raw', 'FREEFORM_SUBTYPE_GUID': '.guid', - 'SUBTYPE_GUID' : '.guid', - 'FV_IMAGE' : 'fv.sec', - 'COMPRESS' : '.com', - 'GUIDED' : '.guided', - BINARY_FILE_TYPE_PEI_DEPEX : '.dpx', - BINARY_FILE_TYPE_SMM_DEPEX : '.dpx' + 'SUBTYPE_GUID': '.guid', + 'FV_IMAGE': 'fv.sec', + 'COMPRESS': '.com', + 'GUIDED': '.guided', + BINARY_FILE_TYPE_PEI_DEPEX: '.dpx', + BINARY_FILE_TYPE_SMM_DEPEX: '.dpx' } diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools= /Source/Python/GenFds/FfsFileStatement.py index 1c6e59bac75c..92758df91e5a 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -1,4 +1,4 @@ -## @file +# @file # process FFS generation from FILE statement # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -23,11 +23,13 @@ from .Ffs import FdfFvFileTypeToFileType from .GenFdsGlobalVariable import GenFdsGlobalVariable import shutil =20 -## generate FFS from FILE +# generate FFS from FILE # # + + class FileStatement (FileStatementClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -39,7 +41,7 @@ class FileStatement (FileStatementClassObject): self.InfFileName =3D None self.SubAlignment =3D None =20 - ## GenFfs() method + # GenFfs() method # # Generate FFS # @@ -49,19 +51,19 @@ class FileStatement (FileStatementClassObject): # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D None, FvChildAddr=3D[], FvParentAddr=3DNone,= IsMakefile=3DFalse, FvName=3DNone): + def GenFfs(self, Dict=3DNone, FvChildAddr=3D[], FvParentAddr=3DNone, I= sMakefile=3DFalse, FvName=3DNone): =20 if self.NameGuid and self.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(self.NameGuid) if len(PcdValue) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ - % (self.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' + % (self.NameGuid)) if PcdValue.startswith('{'): PcdValue =3D GuidStructureByteArrayToGuidString(PcdValue) RegistryGuidStr =3D PcdValue if len(RegistryGuidStr) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' \ - % (self.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' + % (self.NameGuid)) self.NameGuid =3D RegistryGuidStr =20 Str =3D self.NameGuid @@ -81,15 +83,19 @@ class FileStatement (FileStatementClassObject): if self.FvName: Buffer =3D BytesIO() if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FvDict: - EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT de= scribed in FDF file!" % (self.FvName)) - Fv =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.= FvName.upper()) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "FV (%s) is NOT described in F= DF file!" % (self.FvName)) + Fv =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get( + self.FvName.upper()) FileName =3D Fv.AddToBuffer(Buffer) SectionFiles =3D [FileName] =20 elif self.FdName: if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.P= rofile.FdDict: - EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT de= scribed in FDF file!" % (self.FdName)) - Fd =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.= FdName.upper()) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "FD (%s) is NOT described in F= DF file!" % (self.FdName)) + Fd =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict.get( + self.FdName.upper()) FileName =3D Fd.GenFd() SectionFiles =3D [FileName] =20 @@ -103,37 +109,44 @@ class FileStatement (FileStatementClassObject): try: f =3D open(File, 'rb') except: - GenFdsGlobalVariable.ErrorLogger("Error openin= g RAW file %s." % (File)) + GenFdsGlobalVariable.ErrorLogger( + "Error opening RAW file %s." % (File)) Content =3D f.read() f.close() AlignValue =3D 1 if self.SubAlignment[Index]: - AlignValue =3D GenFdsGlobalVariable.GetAlignme= nt(self.SubAlignment[Index]) + AlignValue =3D GenFdsGlobalVariable.GetAlignme= nt( + self.SubAlignment[Index]) if AlignValue > MaxAlignValue: MaxAlignIndex =3D Index MaxAlignValue =3D AlignValue FileContent.write(Content) if len(FileContent.getvalue()) % AlignValue !=3D 0: - Size =3D AlignValue - len(FileContent.getvalue= ()) % AlignValue + Size =3D AlignValue - \ + len(FileContent.getvalue()) % AlignValue for i in range(0, Size): FileContent.write(pack('B', 0xFF)) =20 if FileContent.getvalue() !=3D b'': - OutputRAWFile =3D os.path.join(GenFdsGlobalVariabl= e.FfsDir, self.NameGuid, self.NameGuid + '.raw') - SaveFileOnChange(OutputRAWFile, FileContent.getval= ue(), True) + OutputRAWFile =3D os.path.join( + GenFdsGlobalVariable.FfsDir, self.NameGuid, se= lf.NameGuid + '.raw') + SaveFileOnChange( + OutputRAWFile, FileContent.getvalue(), True) self.FileName =3D OutputRAWFile self.SubAlignment =3D self.SubAlignment[MaxAlignIn= dex] =20 if self.Alignment and self.SubAlignment: - if GenFdsGlobalVariable.GetAlignment (self.Alignment) = < GenFdsGlobalVariable.GetAlignment (self.SubAlignment): + if GenFdsGlobalVariable.GetAlignment(self.Alignment) <= GenFdsGlobalVariable.GetAlignment(self.SubAlignment): self.Alignment =3D self.SubAlignment elif self.SubAlignment: self.Alignment =3D self.SubAlignment =20 - self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.FileName) - #Replace $(SAPCE) with real space + self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + self.FileName) + # Replace $(SAPCE) with real space self.FileName =3D self.FileName.replace('$(SPACE)', ' ') - SectionFiles =3D [GenFdsGlobalVariable.MacroExtend(self.FileNa= me, Dict)] + SectionFiles =3D [ + GenFdsGlobalVariable.MacroExtend(self.FileName, Dict)] =20 else: SectionFiles =3D [] @@ -141,7 +154,7 @@ class FileStatement (FileStatementClassObject): SectionAlignments =3D [] for section in self.SectionList: Index =3D Index + 1 - SecIndex =3D '%d' %Index + SecIndex =3D '%d' % Index # process the inside FvImage from FvSection or GuidSection if FvChildAddr !=3D []: if isinstance(section, FvImageSection): @@ -153,7 +166,8 @@ class FileStatement (FileStatementClassObject): =20 if self.KeepReloc =3D=3D False: section.KeepReloc =3D False - sectList, align =3D section.GenSection(OutputDir, self.Nam= eGuid, SecIndex, self.KeyStringList, None, Dict) + sectList, align =3D section.GenSection( + OutputDir, self.NameGuid, SecIndex, self.KeyStringList= , None, Dict) if sectList !=3D []: for sect in sectList: SectionFiles.append(sect) @@ -164,12 +178,13 @@ class FileStatement (FileStatementClassObject): # FfsFileOutput =3D os.path.join(OutputDir, self.NameGuid + '.ffs') GenFdsGlobalVariable.GenerateFfs(FfsFileOutput, SectionFiles, - FdfFvFileTypeToFileType.get(self.= FvFileType), + FdfFvFileTypeToFileType.get( + self.FvFileType), self.NameGuid, Fixed=3Dself.Fixed, CheckSum=3Dself.CheckSum, Align=3Dself.Alignment, SectionAlign=3DSectionAlignments - ) + ) =20 return FfsFileOutput diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index 568efb6d7685..17095e5edf1d 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -1,4 +1,4 @@ -## @file +# @file # process FFS generation from INF statement # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -16,7 +16,7 @@ import Common.LongFilePathOs as os from io import BytesIO from struct import * from .GenFdsGlobalVariable import GenFdsGlobalVariable -from .Ffs import SectionSuffix,FdfFvFileTypeToFileType +from .Ffs import SectionSuffix, FdfFvFileTypeToFileType import subprocess import sys from . import Section @@ -46,11 +46,13 @@ from Common.Misc import SaveFileOnChange from Common.Expression import * from Common.DataType import * =20 -## generate FFS from INF +# generate FFS from INF # # + + class FfsInfStatement(FfsInfStatementClassObject): - ## The constructor + # The constructor # # @param self The object pointer # @@ -73,22 +75,25 @@ class FfsInfStatement(FfsInfStatementClassObject): self.MacroDict =3D {} self.Depex =3D False =20 - ## GetFinalTargetSuffixMap() method + # GetFinalTargetSuffixMap() method # # Get final build target list def GetFinalTargetSuffixMap(self): if not self.InfModule or not self.CurrentArch: return [] if not self.FinalTargetSuffixMap: - FinalBuildTargetList =3D GenFdsGlobalVariable.GetModuleCodaTar= getList(self.InfModule, self.CurrentArch) + FinalBuildTargetList =3D GenFdsGlobalVariable.GetModuleCodaTar= getList( + self.InfModule, self.CurrentArch) for File in FinalBuildTargetList: - self.FinalTargetSuffixMap.setdefault(os.path.splitext(File= )[1], []).append(File) + self.FinalTargetSuffixMap.setdefault( + os.path.splitext(File)[1], []).append(File) =20 # Check if current INF module has DEPEX if '.depex' not in self.FinalTargetSuffixMap and self.InfModul= e.ModuleType !=3D SUP_MODULE_USER_DEFINED and self.InfModule.ModuleType != =3D SUP_MODULE_HOST_APPLICATION \ - and not self.InfModule.DxsFile and not self.InfModule.Libr= aryClass: + and not self.InfModule.DxsFile and not self.InfModule.= LibraryClass: ModuleType =3D self.InfModule.ModuleType - PlatformDataBase =3D GenFdsGlobalVariable.WorkSpace.BuildO= bject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVa= riable.TargetName, GenFdsGlobalVariable.ToolChainTag] + PlatformDataBase =3D GenFdsGlobalVariable.WorkSpace.BuildO= bject[GenFdsGlobalVariable.ActivePlatform, + = self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable= .ToolChainTag] =20 if ModuleType !=3D SUP_MODULE_USER_DEFINED and ModuleType = !=3D SUP_MODULE_HOST_APPLICATION: for LibraryClass in PlatformDataBase.LibraryClasses.Ge= tKeys(): @@ -131,31 +136,34 @@ class FfsInfStatement(FfsInfStatementClassObject): LibraryPath =3D Module.LibraryClasses[LibName] if not LibraryPath: continue - LibraryModule =3D GenFdsGlobalVariable.WorkSpace.B= uildObject[LibraryPath, self.CurrentArch, GenFdsGlobalVariable.TargetName, = GenFdsGlobalVariable.ToolChainTag] + LibraryModule =3D GenFdsGlobalVariable.WorkSpace.B= uildObject[LibraryPath, + = self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVar= iable.ToolChainTag] LibraryInstance[LibName] =3D LibraryModule DependencyList.append(LibraryModule) if DepexList: Dpx =3D DependencyExpression(DepexList, ModuleType, Tr= ue) if len(Dpx.PostfixNotation) !=3D 0: # It means this module has DEPEX - self.FinalTargetSuffixMap['.depex'] =3D [os.path.j= oin(self.EfiOutputPath, self.BaseName) + '.depex'] + self.FinalTargetSuffixMap['.depex'] =3D [os.path.j= oin( + self.EfiOutputPath, self.BaseName) + '.depex'] return self.FinalTargetSuffixMap =20 - ## __InfParse() method + # __InfParse() method # # Parse inf file to get module information # # @param self The object pointer # @param Dict dictionary contains macro and value pair # - def __InfParse__(self, Dict =3D None, IsGenFfs=3DFalse): + def __InfParse__(self, Dict=3DNone, IsGenFfs=3DFalse): =20 - GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s= " %self.InfFileName) + GenFdsGlobalVariable.VerboseLogger( + " Begine parsing INf file : %s" % self.InfFileName) =20 self.InfFileName =3D self.InfFileName.replace('$(WORKSPACE)', '') if len(self.InfFileName) > 1 and self.InfFileName[0] =3D=3D '\\' a= nd self.InfFileName[1] =3D=3D '\\': pass - elif self.InfFileName[0] =3D=3D '\\' or self.InfFileName[0] =3D=3D= '/' : + elif self.InfFileName[0] =3D=3D '\\' or self.InfFileName[0] =3D=3D= '/': self.InfFileName =3D self.InfFileName[1:] =20 if self.InfFileName.find('$') =3D=3D -1: @@ -163,14 +171,16 @@ class FfsInfStatement(FfsInfStatementClassObject): if not os.path.exists(InfPath): InfPath =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(Inf= Path) if not os.path.exists(InfPath): - EdkLogger.error("GenFds", GENFDS_ERROR, "Non-existant = Module %s !" % (self.InfFileName)) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "Non-existant Module %s !"= % (self.InfFileName)) =20 self.CurrentArch =3D self.GetCurrentArch() # # Get the InfClass object # =20 - PathClassObj =3D PathClass(self.InfFileName, GenFdsGlobalVariable.= WorkSpaceDir) + PathClassObj =3D PathClass( + self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir) ErrorCode, ErrorInfo =3D PathClassObj.Validate(".inf") if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) @@ -180,10 +190,12 @@ class FfsInfStatement(FfsInfStatementClassObject): # InfLowerPath =3D str(PathClassObj).lower() if self.OverrideGuid: - PathClassObj =3D ProcessDuplicatedInf(PathClassObj, self.Overr= ideGuid, GenFdsGlobalVariable.WorkSpaceDir) + PathClassObj =3D ProcessDuplicatedInf( + PathClassObj, self.OverrideGuid, GenFdsGlobalVariable.Work= SpaceDir) if self.CurrentArch is not None: =20 - Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassOb= j, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.= ToolChainTag] + Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassOb= j, self.CurrentArch, + GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag] # # Set Ffs BaseName, ModuleGuid, ModuleType, Version, OutputPath # @@ -201,7 +213,8 @@ class FfsInfStatement(FfsInfStatementClassObject): self.ShadowFromInfFile =3D Inf.Shadow =20 else: - Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassOb= j, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolCh= ainTag] + Inf =3D GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassOb= j, TAB_COMMON, + GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag] self.BaseName =3D Inf.BaseName self.ModuleGuid =3D Inf.Guid self.ModuleType =3D Inf.ModuleType @@ -212,27 +225,31 @@ class FfsInfStatement(FfsInfStatementClassObject): self.SourceFileList =3D Inf.Sources if self.BinFileList =3D=3D []: EdkLogger.error("GenFds", GENFDS_ERROR, - "INF %s specified in FDF could not be foun= d in build ARCH %s!" \ + "INF %s specified in FDF could not be foun= d in build ARCH %s!" % (self.InfFileName, GenFdsGlobalVariable.= ArchList)) =20 if self.OverrideGuid: self.ModuleGuid =3D self.OverrideGuid =20 if len(self.SourceFileList) !=3D 0 and not self.InDsc: - EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in= DSC file; Is it really a binary module?" % (self.InfFileName)) + EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in= DSC file; Is it really a binary module?" % ( + self.InfFileName)) =20 if self.ModuleType =3D=3D SUP_MODULE_SMM_CORE and int(self.PiSpecV= ersion, 16) < 0x0001000A: - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE modu= le type can't be used in the module with PI_SPECIFICATION_VERSION less than= 0x0001000A", File=3Dself.InfFileName) + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "SMM_CORE module type can't be used in the mod= ule with PI_SPECIFICATION_VERSION less than 0x0001000A", File=3Dself.InfFil= eName) =20 if self.ModuleType =3D=3D SUP_MODULE_MM_CORE_STANDALONE and int(se= lf.PiSpecVersion, 16) < 0x00010032: - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "MM_CORE_STAND= ALONE module type can't be used in the module with PI_SPECIFICATION_VERSION= less than 0x00010032", File=3Dself.InfFileName) + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "MM_CORE_STANDALONE module type can't be used = in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=3Ds= elf.InfFileName) =20 if Inf._Defs is not None and len(Inf._Defs) > 0: self.OptRomDefs.update(Inf._Defs) =20 self.PatchPcds =3D [] InfPcds =3D Inf.Pcds - Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetNam= e, GenFdsGlobalVariable.ToolChainTag] + Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, + self.Current= Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] FdfPcdDict =3D GenFdsGlobalVariable.FdfParser.Profile.PcdDict PlatformPcds =3D Platform.Pcds =20 @@ -282,15 +299,19 @@ class FfsInfStatement(FfsInfStatementClassObject): # Support Flexible PCD format if DefaultValue: try: - DefaultValue =3D ValueExpressionEx(DefaultValue, Pcd.D= atumType, Platform._GuidDict)(True) + DefaultValue =3D ValueExpressionEx( + DefaultValue, Pcd.DatumType, Platform._GuidDict)(T= rue) except BadExpression: - EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValue), File= =3Dself.InfFileName) + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultVa= lue), File=3Dself.InfFileName) =20 if Pcd.InfDefaultValue: try: - Pcd.InfDefaultValue =3D ValueExpressionEx(Pcd.InfDefau= ltValue, Pcd.DatumType, Platform._GuidDict)(True) + Pcd.InfDefaultValue =3D ValueExpressionEx( + Pcd.InfDefaultValue, Pcd.DatumType, Platform._Guid= Dict)(True) except BadExpression: - EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue), Fi= le=3Dself.InfFileName) + EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] V= alue "%s"' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.Defau= ltValue), File=3Dself.InfFileName) =20 # Check value, if value are equal, no need to patch if Pcd.DatumType =3D=3D TAB_VOID: @@ -325,12 +346,12 @@ class FfsInfStatement(FfsInfStatementClassObject): # Check the Pcd size and data type if Pcd.DatumType =3D=3D TAB_VOID: if int(MaxDatumSize) > int(Pcd.MaxDatumSize): - EdkLogger.error("GenFds", GENFDS_ERROR, "The size of V= OID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ + EdkLogger.error("GenFds", GENFDS_ERROR, "The size of V= OID* type PCD '%s.%s' exceeds its maximum size %d bytes." % (Pcd.TokenSpaceGuidCName, Pcd.TokenC= Name, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) else: if PcdValueInDscOrFdf > MAX_VAL_TYPE[Pcd.DatumType] \ - or PcdValueInImg > MAX_VAL_TYPE[Pcd.DatumType]: - EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %= s type PCD '%s.%s' doesn't match its data type." \ + or PcdValueInImg > MAX_VAL_TYPE[Pcd.DatumType]: + EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %= s type PCD '%s.%s' doesn't match its data type." % (Pcd.DatumType, Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName)) self.PatchPcds.append((Pcd, DefaultValue)) =20 @@ -343,8 +364,10 @@ class FfsInfStatement(FfsInfStatementClassObject): GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName) GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" % self.Module= Guid) GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" % self.Module= Type) - GenFdsGlobalVariable.VerboseLogger("VersionString : %s" % self.Ver= sionString) - GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" % self.InfFil= eName) + GenFdsGlobalVariable.VerboseLogger( + "VersionString : %s" % self.VersionString) + GenFdsGlobalVariable.VerboseLogger( + "InfFileName :%s" % self.InfFileName) =20 # # Set OutputPath =3D ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${Mo= duleName}\ @@ -353,15 +376,16 @@ class FfsInfStatement(FfsInfStatementClassObject): Rule =3D self.__GetRule__() if GlobalData.gGuidPatternEnd.match(Rule.NameGuid): self.ModuleGuid =3D Rule.NameGuid - self.OutputPath =3D os.path.join(GenFdsGlobalVariable.FfsDir, \ + self.OutputPath =3D os.path.join(GenFdsGlobalVariable.FfsDir, self.ModuleGuid + self.BaseName) - if not os.path.exists(self.OutputPath) : + if not os.path.exists(self.OutputPath): os.makedirs(self.OutputPath) =20 self.EfiOutputPath, self.EfiDebugPath =3D self.__GetEFIOutPutPath_= _() - GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOu= tputPath) + GenFdsGlobalVariable.VerboseLogger( + "ModuelEFIPath: " + self.EfiOutputPath) =20 - ## PatchEfiFile + # PatchEfiFile # # Patch EFI file with patch PCD # @@ -386,13 +410,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # Generate path to patched output file # Basename =3D os.path.basename(EfiFile) - Output =3D os.path.normpath (os.path.join(self.OutputPath, Basenam= e)) + Output =3D os.path.normpath(os.path.join(self.OutputPath, Basename= )) =20 # # If this file has already been patched, then return the path to t= he patched file # if self.PatchedBinFile =3D=3D Output: - return Output + return Output =20 # # If a different file from the same module has already been patche= d, then generate an error @@ -401,7 +425,8 @@ class FfsInfStatement(FfsInfStatementClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, 'Only one binary file can be patched:\n' ' a binary file has been patched: %s\n' - ' current file: %s' % (self.PatchedBinFile, E= fiFile), + ' current file: %s' % ( + self.PatchedBinFile, EfiFile), File=3Dself.InfFileName) =20 # @@ -413,9 +438,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # Apply patches to patched output file # for Pcd, Value in self.PatchPcds: - RetVal, RetStr =3D PatchBinaryFile(Output, int(Pcd.Offset, 0),= Pcd.DatumType, Value, Pcd.MaxDatumSize) + RetVal, RetStr =3D PatchBinaryFile(Output, int( + Pcd.Offset, 0), Pcd.DatumType, Value, Pcd.MaxDatumSize) if RetVal: - EdkLogger.error("GenFds", GENFDS_ERROR, RetStr, File=3Dsel= f.InfFileName) + EdkLogger.error("GenFds", GENFDS_ERROR, + RetStr, File=3Dself.InfFileName) =20 # # Save the path of the patched output file @@ -427,7 +454,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # return Output =20 - ## GenFfs() method + # GenFfs() method # # Generate FFS # @@ -437,7 +464,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D None, FvChildAddr =3D [], FvParentAddr=3DNon= e, IsMakefile=3DFalse, FvName=3DNone): + def GenFfs(self, Dict=3DNone, FvChildAddr=3D[], FvParentAddr=3DNone, I= sMakefile=3DFalse, FvName=3DNone): # # Parse Inf file get Module related information # @@ -445,8 +472,8 @@ class FfsInfStatement(FfsInfStatementClassObject): Dict =3D {} self.__InfParse__(Dict, IsGenFfs=3DTrue) Arch =3D self.GetCurrentArch() - SrcFile =3D mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfF= ileName); - DestFile =3D os.path.join( self.OutputPath, self.ModuleGuid + '.ff= s') + SrcFile =3D mws.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFi= leName) + DestFile =3D os.path.join(self.OutputPath, self.ModuleGuid + '.ffs= ') =20 SrcFileDir =3D "." SrcPath =3D os.path.dirname(SrcFile) @@ -457,18 +484,18 @@ class FfsInfStatement(FfsInfStatementClassObject): DestFileBase, DestFileExt =3D os.path.splitext(DestFileName) self.MacroDict =3D { # source file - "${src}" : SrcFile, - "${s_path}" : SrcPath, - "${s_dir}" : SrcFileDir, - "${s_name}" : SrcFileName, - "${s_base}" : SrcFileBase, - "${s_ext}" : SrcFileExt, + "${src}": SrcFile, + "${s_path}": SrcPath, + "${s_dir}": SrcFileDir, + "${s_name}": SrcFileName, + "${s_base}": SrcFileBase, + "${s_ext}": SrcFileExt, # destination file - "${dst}" : DestFile, - "${d_path}" : DestPath, - "${d_name}" : DestFileName, - "${d_base}" : DestFileBase, - "${d_ext}" : DestFileExt + "${dst}": DestFile, + "${d_path}": DestPath, + "${d_name}": DestFileName, + "${d_base}": DestFileBase, + "${d_ext}": DestFileExt } # # Allow binary type module not specify override rule in FDF file. @@ -483,7 +510,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # Get the rule of how to generate Ffs file # Rule =3D self.__GetRule__() - GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf fil= e : %s" %self.InfFileName) + GenFdsGlobalVariable.VerboseLogger( + "Packing binaries from inf file : %s" % self.InfFileName) # # Convert Fv File Type for PI1.1 SMM driver. # @@ -495,7 +523,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(self.P= iSpecVersion, 16) < 0x0001000A: if Rule.FvFileType =3D=3D 'SMM' or Rule.FvFileType =3D=3D SUP_= MODULE_SMM_CORE: - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework= SMM module doesn't support SMM or SMM_CORE FV file type", File=3Dself.InfF= ileName) + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "Framework SMM module doesn't support SMM = or SMM_CORE FV file type", File=3Dself.InfFileName) # # For the rule only has simpleFile # @@ -503,23 +532,29 @@ class FfsInfStatement(FfsInfStatementClassObject): if self.IsBinaryModule: IsMakefile =3D False if IsMakefile: - PathClassObj =3D PathClass(self.InfFileName, GenFdsGlobalVaria= ble.WorkSpaceDir) + PathClassObj =3D PathClass( + self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir) if self.OverrideGuid: - PathClassObj =3D ProcessDuplicatedInf(PathClassObj, self.O= verrideGuid, GenFdsGlobalVariable.WorkSpaceDir) + PathClassObj =3D ProcessDuplicatedInf( + PathClassObj, self.OverrideGuid, GenFdsGlobalVariable.= WorkSpaceDir) MakefilePath =3D PathClassObj.Path, Arch - if isinstance (Rule, RuleSimpleFile.RuleSimpleFile): - SectionOutputList =3D self.__GenSimpleFileSection__(Rule, IsMa= kefile=3DIsMakefile) - FfsOutput =3D self.__GenSimpleFileFfs__(Rule, SectionOutputLis= t, MakefilePath=3DMakefilePath) + if isinstance(Rule, RuleSimpleFile.RuleSimpleFile): + SectionOutputList =3D self.__GenSimpleFileSection__( + Rule, IsMakefile=3DIsMakefile) + FfsOutput =3D self.__GenSimpleFileFfs__( + Rule, SectionOutputList, MakefilePath=3DMakefilePath) return FfsOutput # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__(Rule, FvChildAddr, FvParentAddr, IsMakefile=3DIsMakefile) - FfsOutput =3D self.__GenComplexFileFfs__(Rule, InputSectList, = InputSectAlignments, MakefilePath=3DMakefilePath) + InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__( + Rule, FvChildAddr, FvParentAddr, IsMakefile=3DIsMakefile) + FfsOutput =3D self.__GenComplexFileFfs__( + Rule, InputSectList, InputSectAlignments, MakefilePath=3DM= akefilePath) return FfsOutput =20 - ## __ExtendMacro__() method + # __ExtendMacro__() method # # Replace macro with its value # @@ -527,26 +562,26 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param String The string to be replaced # @retval string Macro replaced string # - def __ExtendMacro__ (self, String): + def __ExtendMacro__(self, String): MacroDict =3D { - '$(INF_OUTPUT)' : self.EfiOutputPath, - '$(MODULE_NAME)' : self.BaseName, + '$(INF_OUTPUT)': self.EfiOutputPath, + '$(MODULE_NAME)': self.BaseName, '$(BUILD_NUMBER)': self.BuildNum, - '$(INF_VERSION)' : self.VersionString, - '$(NAMED_GUID)' : self.ModuleGuid + '$(INF_VERSION)': self.VersionString, + '$(NAMED_GUID)': self.ModuleGuid } String =3D GenFdsGlobalVariable.MacroExtend(String, MacroDict) String =3D GenFdsGlobalVariable.MacroExtend(String, self.MacroDict) return String =20 - ## __GetRule__() method + # __GetRule__() method # # Get correct rule for generating FFS for this INF # # @param self The object pointer # @retval Rule Rule object # - def __GetRule__ (self) : + def __GetRule__(self): CurrentArchList =3D [] if self.CurrentArch is None: CurrentArchList =3D ['common'] @@ -554,44 +589,48 @@ class FfsInfStatement(FfsInfStatementClassObject): CurrentArchList.append(self.CurrentArch) =20 for CurrentArch in CurrentArchList: - RuleName =3D 'RULE' + \ - '.' + \ + RuleName =3D 'RULE' + \ + '.' + \ CurrentArch.upper() + \ - '.' + \ + '.' + \ self.ModuleType.upper() if self.Rule is not None: RuleName =3D RuleName + \ - '.' + \ - self.Rule.upper() + '.' + \ + self.Rule.upper() =20 - Rule =3D GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(R= uleName) + Rule =3D GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get( + RuleName) if Rule is not None: - GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Nam= e is : " + RuleName) + GenFdsGlobalVariable.VerboseLogger( + "Want To Find Rule Name is : " + RuleName) return Rule =20 - RuleName =3D 'RULE' + \ - '.' + \ - TAB_COMMON + \ - '.' + \ + RuleName =3D 'RULE' + \ + '.' + \ + TAB_COMMON + \ + '.' + \ self.ModuleType.upper() =20 if self.Rule is not None: RuleName =3D RuleName + \ - '.' + \ - self.Rule.upper() + '.' + \ + self.Rule.upper() =20 - GenFdsGlobalVariable.VerboseLogger ('Trying to apply common rule %= s for INF %s' % (RuleName, self.InfFileName)) + GenFdsGlobalVariable.VerboseLogger( + 'Trying to apply common rule %s for INF %s' % (RuleName, self.= InfFileName)) =20 Rule =3D GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleN= ame) if Rule is not None: - GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is= : " + RuleName) + GenFdsGlobalVariable.VerboseLogger( + "Want To Find Rule Name is : " + RuleName) return Rule =20 - if Rule is None : - EdkLogger.error("GenFds", GENFDS_ERROR, 'Don\'t Find common ru= le %s for INF %s' \ + if Rule is None: + EdkLogger.error("GenFds", GENFDS_ERROR, 'Don\'t Find common ru= le %s for INF %s' % (RuleName, self.InfFileName)) =20 - ## __GetPlatformArchList__() method + # __GetPlatformArchList__() method # # Get Arch list this INF built under # @@ -600,13 +639,15 @@ class FfsInfStatement(FfsInfStatementClassObject): # def __GetPlatformArchList__(self): =20 - InfFileKey =3D os.path.normpath(mws.join(GenFdsGlobalVariable.Work= SpaceDir, self.InfFileName)) + InfFileKey =3D os.path.normpath( + mws.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName)) DscArchList =3D [] - for Arch in GenFdsGlobalVariable.ArchList : - PlatformDataBase =3D GenFdsGlobalVariable.WorkSpace.BuildObjec= t[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetNam= e, GenFdsGlobalVariable.ToolChainTag] - if PlatformDataBase is not None: + for Arch in GenFdsGlobalVariable.ArchList: + PlatformDataBase =3D GenFdsGlobalVariable.WorkSpace.BuildObjec= t[GenFdsGlobalVariable.ActivePlatform, + = Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + if PlatformDataBase is not None: if InfFileKey in PlatformDataBase.Modules: - DscArchList.append (Arch) + DscArchList.append(Arch) else: # # BaseTools support build same module more than once, = the module path with FILE_GUID overridden has @@ -615,19 +656,19 @@ class FfsInfStatement(FfsInfStatementClassObject): # for key in PlatformDataBase.Modules: if InfFileKey =3D=3D str((PlatformDataBase.Modules= [key]).MetaFile.Path): - DscArchList.append (Arch) + DscArchList.append(Arch) break =20 return DscArchList =20 - ## GetCurrentArch() method + # GetCurrentArch() method # # Get Arch list of the module from this INF is to be placed into fla= sh # # @param self The object pointer # @retval list Arch list # - def GetCurrentArch(self) : + def GetCurrentArch(self): =20 TargetArchList =3D GenFdsGlobalVariable.ArchList =20 @@ -635,8 +676,9 @@ class FfsInfStatement(FfsInfStatementClassObject): =20 CurArchList =3D TargetArchList if PlatformArchList !=3D []: - CurArchList =3D list(set (TargetArchList) & set (PlatformArchL= ist)) - GenFdsGlobalVariable.VerboseLogger ("Valid target architecture(s) = is : " + " ".join(CurArchList)) + CurArchList =3D list(set(TargetArchList) & set(PlatformArchLis= t)) + GenFdsGlobalVariable.VerboseLogger( + "Valid target architecture(s) is : " + " ".join(CurArchList)) =20 ArchList =3D [] if self.KeyStringList !=3D []: @@ -654,12 +696,13 @@ class FfsInfStatement(FfsInfStatementClassObject): if self.UseArch is not None: UseArchList =3D [] UseArchList.append(self.UseArch) - ArchList =3D list(set (UseArchList) & set (ArchList)) + ArchList =3D list(set(UseArchList) & set(ArchList)) =20 self.InfFileName =3D NormPath(self.InfFileName) if len(PlatformArchList) =3D=3D 0: self.InDsc =3D False - PathClassObj =3D PathClass(self.InfFileName, GenFdsGlobalVaria= ble.WorkSpaceDir) + PathClassObj =3D PathClass( + self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir) ErrorCode, ErrorInfo =3D PathClassObj.Validate(".inf") if ErrorCode !=3D 0: EdkLogger.error("GenFds", ErrorCode, ExtraData=3DErrorInfo) @@ -668,14 +711,16 @@ class FfsInfStatement(FfsInfStatementClassObject): return Arch elif len(ArchList) > 1: if len(PlatformArchList) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, "GenFds command li= ne option has multiple ARCHs %s. Not able to determine which ARCH is valid = for Module %s !" % (str(ArchList), self.InfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "GenFds command li= ne option has multiple ARCHs %s. Not able to determine which ARCH is valid = for Module %s !" % ( + str(ArchList), self.InfFileName)) else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Module built unde= r multiple ARCHs %s. Not able to determine which output to put into flash f= or Module %s !" % (str(ArchList), self.InfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "Module built unde= r multiple ARCHs %s. Not able to determine which output to put into flash f= or Module %s !" % ( + str(ArchList), self.InfFileName)) else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s appears und= er ARCH %s in platform %s, but current deduced ARCH is %s, so NO build outp= ut could be put into flash." \ - % (self.InfFileName, str(PlatformArchList), Ge= nFdsGlobalVariable.ActivePlatform, str(set (UseArchList) & set (TargetArchL= ist)))) + EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s appears und= er ARCH %s in platform %s, but current deduced ARCH is %s, so NO build outp= ut could be put into flash." + % (self.InfFileName, str(PlatformArchList), Ge= nFdsGlobalVariable.ActivePlatform, str(set(UseArchList) & set(TargetArchLis= t)))) =20 - ## __GetEFIOutPutPath__() method + # __GetEFIOutPutPath__() method # # Get the output path for generated files # @@ -702,16 +747,16 @@ class FfsInfStatement(FfsInfStatementClassObject): 'OUTPUT' ) DebugPath =3D os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch= ], - Arch, - ModulePath, - FileName, - 'DEBUG' - ) + Arch, + ModulePath, + FileName, + 'DEBUG' + ) OutputPath =3D os.path.abspath(OutputPath) DebugPath =3D os.path.abspath(DebugPath) return OutputPath, DebugPath =20 - ## __GenSimpleFileSection__() method + # __GenSimpleFileSection__() method # # Generate section by specified file name or a list of files with fi= le extension # @@ -719,7 +764,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): + def __GenSimpleFileSection__(self, Rule, IsMakefile=3DFalse): # # Prepare the parameter of GenSection # @@ -731,9 +776,11 @@ class FfsInfStatement(FfsInfStatementClassObject): if os.path.isabs(GenSecInputFile): GenSecInputFile =3D os.path.normpath(GenSecInputFile) else: - GenSecInputFile =3D os.path.normpath(os.path.join(self.Efi= OutputPath, GenSecInputFile)) + GenSecInputFile =3D os.path.normpath( + os.path.join(self.EfiOutputPath, GenSecInputFile)) else: - FileList, IsSect =3D Section.Section.GetFileList(self, '', Rul= e.FileExtension) + FileList, IsSect =3D Section.Section.GetFileList( + self, '', Rule.FileExtension) =20 Index =3D 1 SectionType =3D Rule.SectionType @@ -748,7 +795,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(self.P= iSpecVersion, 16) < 0x0001000A: if SectionType =3D=3D BINARY_FILE_TYPE_SMM_DEPEX: - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework= SMM module doesn't support SMM_DEPEX section type", File=3Dself.InfFileNam= e) + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "Framework SMM module doesn't support SMM_= DEPEX section type", File=3Dself.InfFileName) NoStrip =3D True if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MO= DULE_PEIM): if self.KeepReloc is not None: @@ -758,98 +806,112 @@ class FfsInfStatement(FfsInfStatementClassObject): elif self.ShadowFromInfFile is not None: NoStrip =3D self.ShadowFromInfFile =20 - if FileList !=3D [] : + if FileList !=3D []: for File in FileList: =20 - SecNum =3D '%d' %Index - GenSecOutputFile=3D self.__ExtendMacro__(Rule.NameGuid) + \ - SectionSuffix[SectionType] + SUP_MODULE_SEC = + SecNum + SecNum =3D '%d' % Index + GenSecOutputFile =3D self.__ExtendMacro__(Rule.NameGuid) += \ + SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum Index =3D Index + 1 OutputFile =3D os.path.join(self.OutputPath, GenSecOutputF= ile) - File =3D GenFdsGlobalVariable.MacroExtend(File, Dict, self= .CurrentArch) + File =3D GenFdsGlobalVariable.MacroExtend( + File, Dict, self.CurrentArch) =20 - #Get PE Section alignment when align is set to AUTO + # Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D BI= NARY_FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): - ImageObj =3D PeImageClass (File) + ImageObj =3D PeImageClass(File) if ImageObj.SectionAlignment < 0x400: - self.Alignment =3D str (ImageObj.SectionAlignment) + self.Alignment =3D str(ImageObj.SectionAlignment) elif ImageObj.SectionAlignment < 0x100000: - self.Alignment =3D str (ImageObj.SectionAlignment = // 0x400) + 'K' + self.Alignment =3D str( + ImageObj.SectionAlignment // 0x400) + 'K' else: - self.Alignment =3D str (ImageObj.SectionAlignment = // 0x100000) + 'M' + self.Alignment =3D str( + ImageObj.SectionAlignment // 0x100000) + 'M' =20 if not NoStrip: - FileBeforeStrip =3D os.path.join(self.OutputPath, Modu= leName + '.reloc') + FileBeforeStrip =3D os.path.join( + self.OutputPath, ModuleName + '.reloc') if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(File) > os.path.getmtime(File= BeforeStrip)): + (os.path.getmtime(File) > os.path.getmtime(Fil= eBeforeStrip)): CopyLongFilePath(File, FileBeforeStrip) - StrippedFile =3D os.path.join(self.OutputPath, ModuleN= ame + '.stipped') + StrippedFile =3D os.path.join( + self.OutputPath, ModuleName + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue, - IsMakefile=3DIsMakefile - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) File =3D StrippedFile =20 if SectionType =3D=3D BINARY_FILE_TYPE_TE: - TeFile =3D os.path.join( self.OutputPath, self.ModuleG= uid + 'Te.raw') + TeFile =3D os.path.join( + self.OutputPath, self.ModuleGuid + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te', - IsMakefile=3DIsMakefile - ) + TeFile, + [File], + Type=3D'te', + IsMakefile=3DIsMakefile + ) File =3D TeFile - GenFdsGlobalVariable.GenerateSection(OutputFile, [File], S= ection.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection( + OutputFile, [File], Section.Section.SectionType[Sectio= nType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) else: - SecNum =3D '%d' %Index - GenSecOutputFile=3D self.__ExtendMacro__(Rule.NameGuid) + \ - SectionSuffix[SectionType] + SUP_MODULE_SEC = + SecNum + SecNum =3D '%d' % Index + GenSecOutputFile =3D self.__ExtendMacro__(Rule.NameGuid) + \ + SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum OutputFile =3D os.path.join(self.OutputPath, GenSecOutputFile) - GenSecInputFile =3D GenFdsGlobalVariable.MacroExtend(GenSecInp= utFile, Dict, self.CurrentArch) + GenSecInputFile =3D GenFdsGlobalVariable.MacroExtend( + GenSecInputFile, Dict, self.CurrentArch) =20 - #Get PE Section alignment when align is set to AUTO + # Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and (SectionType =3D=3D BINARY= _FILE_TYPE_PE32 or SectionType =3D=3D BINARY_FILE_TYPE_TE): - ImageObj =3D PeImageClass (GenSecInputFile) + ImageObj =3D PeImageClass(GenSecInputFile) if ImageObj.SectionAlignment < 0x400: - self.Alignment =3D str (ImageObj.SectionAlignment) + self.Alignment =3D str(ImageObj.SectionAlignment) elif ImageObj.SectionAlignment < 0x100000: - self.Alignment =3D str (ImageObj.SectionAlignment // 0= x400) + 'K' + self.Alignment =3D str( + ImageObj.SectionAlignment // 0x400) + 'K' else: - self.Alignment =3D str (ImageObj.SectionAlignment // 0= x100000) + 'M' + self.Alignment =3D str( + ImageObj.SectionAlignment // 0x100000) + 'M' =20 if not NoStrip: - FileBeforeStrip =3D os.path.join(self.OutputPath, ModuleNa= me + '.reloc') + FileBeforeStrip =3D os.path.join( + self.OutputPath, ModuleName + '.reloc') if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(GenSecInputFile) > os.path.getmti= me(FileBeforeStrip)): + (os.path.getmtime(GenSecInputFile) > os.path.getmt= ime(FileBeforeStrip)): CopyLongFilePath(GenSecInputFile, FileBeforeStrip) =20 - StrippedFile =3D os.path.join(self.OutputPath, ModuleName = + '.stipped') + StrippedFile =3D os.path.join( + self.OutputPath, ModuleName + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenSecInputFile], - Strip=3DTrue, - IsMakefile=3DIsMakefile - ) + StrippedFile, + [GenSecInputFile], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D StrippedFile =20 if SectionType =3D=3D BINARY_FILE_TYPE_TE: - TeFile =3D os.path.join( self.OutputPath, self.ModuleGuid = + 'Te.raw') + TeFile =3D os.path.join( + self.OutputPath, self.ModuleGuid + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenSecInputFile], - Type=3D'te', - IsMakefile=3DIsMakefile - ) + TeFile, + [GenSecInputFile], + Type=3D'te', + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D TeFile - GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputF= ile], Section.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection(OutputFile, [ + GenSecInputFile], Section= .Section.SectionType[SectionType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList =20 - ## __GenSimpleFileFfs__() method + # __GenSimpleFileFfs__() method # # Generate FFS # @@ -858,11 +920,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenSimpleFileFfs__(self, Rule, InputFileList, MakefilePath =3D N= one): - FfsOutput =3D self.OutputPath + \ - os.sep + \ - self.__ExtendMacro__(Rule.NameGuid) + \ - '.ffs' + def __GenSimpleFileFfs__(self, Rule, InputFileList, MakefilePath=3DNon= e): + FfsOutput =3D self.OutputPath + \ + os.sep + \ + self.__ExtendMacro__(Rule.NameGuid) + \ + '.ffs' =20 GenFdsGlobalVariable.VerboseLogger(self.__ExtendMacro__(Rule.NameG= uid)) InputSection =3D [] @@ -874,14 +936,14 @@ class FfsInfStatement(FfsInfStatementClassObject): if Rule.NameGuid is not None and Rule.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid) if len(PcdValue) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ - % (Rule.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' + % (Rule.NameGuid)) if PcdValue.startswith('{'): PcdValue =3D GuidStructureByteArrayToGuidString(PcdValue) RegistryGuidStr =3D PcdValue if len(RegistryGuidStr) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' \ - % (Rule.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' + % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, @@ -893,7 +955,7 @@ class FfsInfStatement(FfsInfStatementClassObject): ) return FfsOutput =20 - ## __GenComplexFileSection__() method + # __GenComplexFileSection__() method # # Generate section by sections in Rule # @@ -903,7 +965,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param FvParentAddr Parent Fv base address # @retval string File name of the generated section file # - def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, I= sMakefile =3D False): + def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, I= sMakefile=3DFalse): if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MO= DULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE): if Rule.KeepReloc is not None: self.KeepRelocFromRule =3D Rule.KeepReloc @@ -913,33 +975,39 @@ class FfsInfStatement(FfsInfStatementClassObject): HasGeneratedFlag =3D False if self.PcdIsDriver =3D=3D 'PEI_PCD_DRIVER': if self.IsBinaryModule: - PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "PEIPcdDataBase.raw") + PcdExDbFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, "PEIPcdDataBase.raw") else: - PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "PEIP= cdDataBase.raw") - PcdExDbSecName =3D os.path.join(self.OutputPath, "PEIPcdDataBa= seSec.raw") + PcdExDbFileName =3D os.path.join( + self.EfiOutputPath, "PEIPcdDataBase.raw") + PcdExDbSecName =3D os.path.join( + self.OutputPath, "PEIPcdDataBaseSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, [PcdExDbFileName], "EFI_SECTION_RAW", - IsMakefile =3D IsMakefile + IsMakefile=3DIsMakefile ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) elif self.PcdIsDriver =3D=3D 'DXE_PCD_DRIVER': if self.IsBinaryModule: - PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "DXEPcdDataBase.raw") + PcdExDbFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, "DXEPcdDataBase.raw") else: - PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "DXEP= cdDataBase.raw") - PcdExDbSecName =3D os.path.join(self.OutputPath, "DXEPcdDataBa= seSec.raw") + PcdExDbFileName =3D os.path.join( + self.EfiOutputPath, "DXEPcdDataBase.raw") + PcdExDbSecName =3D os.path.join( + self.OutputPath, "DXEPcdDataBaseSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, - [PcdExDbFileName], - "EFI_SECTION_RAW", - IsMakefile =3D IsMakefile - ) + [PcdExDbFileName], + "EFI_SECTION_RAW", + IsMakefile=3DIsMakefile + ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) for Sect in Rule.SectionList: - SecIndex =3D '%d' %Index - SectList =3D [] + SecIndex =3D '%d' % Index + SectList =3D [] # # Convert Fv Section Type for PI1.1 SMM driver. # @@ -951,7 +1019,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # if self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER and int(se= lf.PiSpecVersion, 16) < 0x0001000A: if Sect.SectionType =3D=3D BINARY_FILE_TYPE_SMM_DEPEX: - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Frame= work SMM module doesn't support SMM_DEPEX section type", File=3Dself.InfFil= eName) + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "Framework SMM module doesn't support = SMM_DEPEX section type", File=3Dself.InfFileName) # # process the inside FvImage from FvSection or GuidSection # @@ -964,75 +1033,89 @@ class FfsInfStatement(FfsInfStatementClassObject): Sect.FvParentAddr =3D FvParentAddr =20 if Rule.KeyStringList !=3D []: - SectList, Align =3D Sect.GenSection(self.OutputPath, self.= ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile =3D IsMakefile) - else : - SectList, Align =3D Sect.GenSection(self.OutputPath, self.= ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile =3D IsMakefile) + SectList, Align =3D Sect.GenSection( + self.OutputPath, self.ModuleGuid, SecIndex, Rule.KeySt= ringList, self, IsMakefile=3DIsMakefile) + else: + SectList, Align =3D Sect.GenSection( + self.OutputPath, self.ModuleGuid, SecIndex, self.KeySt= ringList, self, IsMakefile=3DIsMakefile) =20 if not HasGeneratedFlag: UniVfrOffsetFileSection =3D "" - ModuleFileName =3D mws.join(GenFdsGlobalVariable.WorkSpace= Dir, self.InfFileName) - InfData =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass(ModuleFileName), self.CurrentArch] + ModuleFileName =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName) + InfData =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass( + ModuleFileName), self.CurrentArch] # # Search the source list in InfData to find if there are .= vfr file exist. # VfrUniBaseName =3D {} VfrUniOffsetList =3D [] for SourceFile in InfData.Sources: - if SourceFile.Type.upper() =3D=3D ".VFR" : + if SourceFile.Type.upper() =3D=3D ".VFR": # # search the .map file to find the offset of vfr b= inary in the PE32+/TE file. # - VfrUniBaseName[SourceFile.BaseName] =3D (SourceFil= e.BaseName + "Bin") - if SourceFile.Type.upper() =3D=3D ".UNI" : + VfrUniBaseName[SourceFile.BaseName] =3D ( + SourceFile.BaseName + "Bin") + if SourceFile.Type.upper() =3D=3D ".UNI": # # search the .map file to find the offset of Uni s= trings binary in the PE32+/TE file. # - VfrUniBaseName["UniOffsetName"] =3D (self.BaseName= + "Strings") - + VfrUniBaseName["UniOffsetName"] =3D ( + self.BaseName + "Strings") =20 if len(VfrUniBaseName) > 0: if IsMakefile: if InfData.BuildType !=3D 'UEFI_HII': - UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') - UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') + UniVfrOffsetFileName =3D os.path.join( + self.OutputPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join( + self.OutputPath, self.BaseName + 'Offset' = + '.raw') UniVfrOffsetFileNameList =3D [] - UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) - TrimCmd =3D "Trim --Vfr-Uni-Offset -o %s --Mod= uleName=3D%s --DebugDir=3D%s " % (UniVfrOffsetFileName, self.BaseName, self= .EfiDebugPath) + UniVfrOffsetFileNameList.append( + UniVfrOffsetFileName) + TrimCmd =3D "Trim --Vfr-Uni-Offset -o %s --Mod= uleName=3D%s --DebugDir=3D%s " % ( + UniVfrOffsetFileName, self.BaseName, self.= EfiDebugPath) GenFdsGlobalVariable.SecCmdList.append(TrimCmd) GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, - [UniVfrOff= setFileName], - "EFI_SECTI= ON_RAW", - IsMakefile= =3D True - ) + [UniVfrOf= fsetFileName], + "EFI_SECT= ION_RAW", + IsMakefil= e=3DTrue + ) else: - VfrUniOffsetList =3D self.__GetBuildOutputMapFileV= frUniInfo(VfrUniBaseName) + VfrUniOffsetList =3D self.__GetBuildOutputMapFileV= frUniInfo( + VfrUniBaseName) # # Generate the Raw data of raw section # if VfrUniOffsetList: - UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') - UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') - FfsInfStatement.__GenUniVfrOffsetFile (VfrUniO= ffsetList, UniVfrOffsetFileName) + UniVfrOffsetFileName =3D os.path.join( + self.OutputPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join( + self.OutputPath, self.BaseName + 'Offset' = + '.raw') + FfsInfStatement.__GenUniVfrOffsetFile( + VfrUniOffsetList, UniVfrOffsetFileName) UniVfrOffsetFileNameList =3D [] - UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) + UniVfrOffsetFileNameList.append( + UniVfrOffsetFileName) """Call GenSection""" =20 GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, UniVfrOff= setFileNameList, "EFI_SECT= ION_RAW" ) - #os.remove(UniVfrOffsetFileName) + # os.remove(UniVfrOffsetFileName) if UniVfrOffsetFileSection: SectList.append(UniVfrOffsetFileSection) HasGeneratedFlag =3D True =20 - for SecName in SectList : + for SecName in SectList: SectFiles.append(SecName) SectAlignments.append(Align) Index =3D Index + 1 return SectFiles, SectAlignments =20 - ## __GenComplexFileFfs__() method + # __GenComplexFileFfs__() method # # Generate FFS # @@ -1041,32 +1124,32 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenComplexFileFfs__(self, Rule, InputFile, Alignments, MakefileP= ath =3D None): + def __GenComplexFileFfs__(self, Rule, InputFile, Alignments, MakefileP= ath=3DNone): =20 if Rule.NameGuid is not None and Rule.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid) if len(PcdValue) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ - % (Rule.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' + % (Rule.NameGuid)) if PcdValue.startswith('{'): PcdValue =3D GuidStructureByteArrayToGuidString(PcdValue) RegistryGuidStr =3D PcdValue if len(RegistryGuidStr) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' \ - % (Rule.NameGuid)) + EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' + % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 - FfsOutput =3D os.path.join( self.OutputPath, self.ModuleGuid + '.f= fs') + FfsOutput =3D os.path.join(self.OutputPath, self.ModuleGuid + '.ff= s') GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile, - FdfFvFileTypeToFileType[Rule.= FvFileType], - self.ModuleGuid, Fixed=3DRule= .Fixed, - CheckSum=3DRule.CheckSum, Ali= gn=3DRule.Alignment, - SectionAlign=3DAlignments, - MakefilePath=3DMakefilePath - ) + FdfFvFileTypeToFileType[Rule.FvFi= leType], + self.ModuleGuid, Fixed=3DRule.Fix= ed, + CheckSum=3DRule.CheckSum, Align= =3DRule.Alignment, + SectionAlign=3DAlignments, + MakefilePath=3DMakefilePath + ) return FfsOutput =20 - ## __GetBuildOutputMapFileVfrUniInfo() method + # __GetBuildOutputMapFileVfrUniInfo() method # # Find the offset of UNI/INF object offset in the EFI image file. # @@ -1079,7 +1162,7 @@ class FfsInfStatement(FfsInfStatementClassObject): EfiFileName =3D os.path.join(self.EfiOutputPath, self.BaseName + "= .efi") return GetVariableOffset(MapFileName, EfiFileName, list(VfrUniBase= Name.values())) =20 - ## __GenUniVfrOffsetFile() method + # __GenUniVfrOffsetFile() method # # Generate the offset file for the module which contain VFR or UNI f= ile. # @@ -1101,8 +1184,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # UniGuid =3D b'\xe0\xc5\x13\x89\xf63\x86M\x9b\xf1C\xef\x89\= xfc\x06f' fStringIO.write(UniGuid) - UniValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (UniValue) + UniValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(UniValue) else: # # VFR binary offset in image. @@ -1111,18 +1194,17 @@ class FfsInfStatement(FfsInfStatementClassObject): # VfrGuid =3D b'\xb4|\xbc\xd0Gj_I\xaa\x11q\x07F\xda\x06\xa2' fStringIO.write(VfrGuid) - type (Item[1]) - VfrValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (VfrValue) + type(Item[1]) + VfrValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(VfrValue) =20 # # write data into file. # - try : + try: SaveFileOnChange(UniVfrOffsetFileName, fStringIO.getvalue()) except: - EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to f= ile %s failed, please check whether the file been locked or using by other = applications." %UniVfrOffsetFileName, None) - - fStringIO.close () - + EdkLogger.error("GenFds", FILE_WRITE_FAILURE, + "Write data to file %s failed, please check wh= ether the file been locked or using by other applications." % UniVfrOffsetF= ileName, None) =20 + fStringIO.close() diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 16c944a0bd79..578b1ad0e196 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -1,4 +1,4 @@ -## @file +# @file # process FV generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -23,11 +23,13 @@ from Common.DataType import * =20 FV_UI_EXT_ENTY_GUID =3D 'A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C' =20 -## generate FV +# generate FV # # + + class FV (object): - ## The constructor + # The constructor # # @param self The object pointer # @@ -58,7 +60,7 @@ class FV (object): self.FvExtEntryTypeValue =3D [] self.FvExtEntryType =3D [] self.FvExtEntryData =3D [] - ## AddToBuffer() + # AddToBuffer() # # Generate Fv and add it to the Buffer # @@ -71,7 +73,8 @@ class FV (object): # @param MacroDict macro value pair # @retval string Generated FV file path # - def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', MacroDict =3D None, Flag=3DFalse): + + def AddToBuffer(self, Buffer, BaseAddress=3DNone, BlockSize=3DNone, Bl= ockNum=3DNone, ErasePloarity=3D'1', MacroDict=3DNone, Flag=3DFalse): if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsG= lobalVariable.ImageBinDict: return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper()= + 'fv'] if MacroDict is None: @@ -91,16 +94,19 @@ class FV (object): elif RegionData.upper() + 'fv' in GenFdsGlobal= Variable.ImageBinDict: continue elif self.UiFvName.upper() =3D=3D RegionData.u= pper(): - GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, s= elf.UiFvName.upper())) + GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % ( + self.CapsuleName, self.UiFvName.upper(= ))) if not Flag: - GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiF= vName) + GenFdsGlobalVariable.InfLogger( + "\nGenerating %s FV" % self.UiFvName) GenFdsGlobalVariable.LargeFileInFvFlags.append(False) FFSGuid =3D None =20 if self.FvBaseAddress is not None: BaseAddress =3D self.FvBaseAddress if not Flag: - self._InitializeInf(BaseAddress, BlockSize, BlockNum, ErasePlo= arity) + self._InitializeInf(BaseAddress, BlockSize, + BlockNum, ErasePloarity) # # First Process the Apriori section # @@ -109,13 +115,14 @@ class FV (object): GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !') FfsFileList =3D [] for AprSection in self.AprioriSectionList: - FileName =3D AprSection.GenFfs (self.UiFvName, MacroDict, IsMa= kefile=3DFlag) + FileName =3D AprSection.GenFfs( + self.UiFvName, MacroDict, IsMakefile=3DFlag) FfsFileList.append(FileName) # Add Apriori file name to Inf file if not Flag: - self.FvInfFile.append("EFI_FILE_NAME =3D " + \ - FileName + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_FILE_NAME =3D " + + FileName + + TAB_LINE_BREAK) =20 # Process Modules in FfsList for FfsFile in self.FfsList: @@ -124,12 +131,13 @@ class FV (object): continue if GenFdsGlobalVariable.EnableGenfdsMultiThread and GenFdsGlob= alVariable.ModuleFile and GenFdsGlobalVariable.ModuleFile.Path.find(os.path= .normpath(FfsFile.InfFileName)) =3D=3D -1: continue - FileName =3D FfsFile.GenFfs(MacroDict, FvParentAddr=3DBaseAddr= ess, IsMakefile=3DFlag, FvName=3Dself.UiFvName) + FileName =3D FfsFile.GenFfs( + MacroDict, FvParentAddr=3DBaseAddress, IsMakefile=3DFlag, = FvName=3Dself.UiFvName) FfsFileList.append(FileName) if not Flag: - self.FvInfFile.append("EFI_FILE_NAME =3D " + \ - FileName + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_FILE_NAME =3D " + + FileName + + TAB_LINE_BREAK) if not Flag: FvInfFile =3D ''.join(self.FvInfFile) SaveFileOnChange(self.InfFileName, FvInfFile, False) @@ -143,28 +151,31 @@ class FV (object): FvOutputFile =3D self.CreateFileName =20 if Flag: - GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'= ] =3D FvOutputFile + GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper( + ) + 'fv'] =3D FvOutputFile return FvOutputFile =20 - FvInfoFileName =3D os.path.join(GenFdsGlobalVariable.FfsDir, self.= UiFvName + '.inf') + FvInfoFileName =3D os.path.join( + GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf') if not Flag: - CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInf= oFileName) + CopyLongFilePath( + GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName) OrigFvInfo =3D None - if os.path.exists (FvInfoFileName): + if os.path.exists(FvInfoFileName): OrigFvInfo =3D open(FvInfoFileName, 'r').read() if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3= _GUID GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileName, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForceRebase, - FileSystemGuid=3DFFSGuid - ) + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileName, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForceRebase, + FileSystemGuid=3DFFSGuid + ) =20 NewFvInfo =3D None - if os.path.exists (FvInfoFileName): + if os.path.exists(FvInfoFileName): NewFvInfo =3D open(FvInfoFileName, 'r').read() if NewFvInfo is not None and NewFvInfo !=3D OrigFvInfo: FvChildAddr =3D [] @@ -173,28 +184,29 @@ class FV (object): AddrKeyFound =3D False for AddrString in AddrStrings: if AddrKeyFound: - #get base address for the inside FvImage - FvChildAddr.append (AddrString) - elif AddrString.find ("[FV_BASE_ADDRESS]") !=3D -1: + # get base address for the inside FvImage + FvChildAddr.append(AddrString) + elif AddrString.find("[FV_BASE_ADDRESS]") !=3D -1: AddrKeyFound =3D True AddFileObj.close() =20 if FvChildAddr !=3D []: # Update Ffs again for FfsFile in self.FfsList: - FileName =3D FfsFile.GenFfs(MacroDict, FvChildAddr= , BaseAddress, IsMakefile=3DFlag, FvName=3Dself.UiFvName) + FileName =3D FfsFile.GenFfs( + MacroDict, FvChildAddr, BaseAddress, IsMakefil= e=3DFlag, FvName=3Dself.UiFvName) =20 if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: - FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE= _SYSTEM3_GUID; - #Update GenFv again + FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE= _SYSTEM3_GUID + # Update GenFv again GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileNa= me, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForce= Rebase, - FileSystemGuid=3DFFSGuid - ) + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileName, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForceRebase, + FileSystemGuid=3DFFSGuid + ) =20 # # Write the Fv contents to Buffer @@ -205,35 +217,42 @@ class FV (object): FvHeaderBuffer =3D FvFileObj.read(0x48) Signature =3D FvHeaderBuffer[0x28:0x32] if Signature and Signature.startswith(b'_FVH'): - GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV S= uccessfully" % self.UiFvName) + GenFdsGlobalVariable.VerboseLogger( + "\nGenerate %s FV Successfully" % self.UiFvName) GenFdsGlobalVariable.SharpCounter =3D 0 =20 FvFileObj.seek(0) Buffer.write(FvFileObj.read()) # FV alignment position. - FvAlignmentValue =3D 1 << (ord(FvHeaderBuffer[0x2E:0x2= F]) & 0x1F) + FvAlignmentValue =3D 1 << ( + ord(FvHeaderBuffer[0x2E:0x2F]) & 0x1F) if FvAlignmentValue >=3D 0x400: if FvAlignmentValue >=3D 0x100000: if FvAlignmentValue >=3D 0x1000000: - #The max alignment supported by FFS is 16M. + # The max alignment supported by FFS is 16= M. self.FvAlignment =3D "16M" else: - self.FvAlignment =3D str(FvAlignmentValue = // 0x100000) + "M" + self.FvAlignment =3D str( + FvAlignmentValue // 0x100000) + "M" else: - self.FvAlignment =3D str(FvAlignmentValue // 0= x400) + "K" + self.FvAlignment =3D str( + FvAlignmentValue // 0x400) + "K" else: # FvAlignmentValue is less than 1K - self.FvAlignment =3D str (FvAlignmentValue) + self.FvAlignment =3D str(FvAlignmentValue) FvFileObj.close() - GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper(= ) + 'fv'] =3D FvOutputFile + GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper( + ) + 'fv'] =3D FvOutputFile GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: - GenFdsGlobalVariable.ErrorLogger("Invalid FV file %s."= % self.UiFvName) + GenFdsGlobalVariable.ErrorLogger( + "Invalid FV file %s." % self.UiFvName) else: - GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV= file." %self.UiFvName) + GenFdsGlobalVariable.ErrorLogger( + "Failed to generate %s FV file." % self.UiFvName) return FvOutputFile =20 - ## _GetBlockSize() + # _GetBlockSize() # # Calculate FV's block size # Inherit block size from FD if no block size specified in FV @@ -256,7 +275,7 @@ class FV (object): return True return False =20 - ## _InitializeInf() + # _InitializeInf() # # Initialize the inf file to create FV # @@ -266,12 +285,12 @@ class FV (object): # @param BlockNum How many blocks in FV # @param ErasePolarity Flash erase polarity # - def _InitializeInf (self, BaseAddress =3D None, BlockSize=3D None, Blo= ckNum =3D None, ErasePloarity=3D'1'): + def _InitializeInf(self, BaseAddress=3DNone, BlockSize=3DNone, BlockNu= m=3DNone, ErasePloarity=3D'1'): # # Create FV inf file # self.InfFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, - self.UiFvName + '.inf') + self.UiFvName + '.inf') self.FvInfFile =3D [] =20 # @@ -279,79 +298,81 @@ class FV (object): # self.FvInfFile.append("[options]" + TAB_LINE_BREAK) if BaseAddress is not None: - self.FvInfFile.append("EFI_BASE_ADDRESS =3D " + \ - BaseAddress + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_BASE_ADDRESS =3D " + + BaseAddress + + TAB_LINE_BREAK) =20 if BlockSize is not None: - self.FvInfFile.append("EFI_BLOCK_SIZE =3D " + \ - '0x%X' %BlockSize + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_BLOCK_SIZE =3D " + + '0x%X' % BlockSize + + TAB_LINE_BREAK) if BlockNum is not None: - self.FvInfFile.append("EFI_NUM_BLOCKS =3D " + \ - ' 0x%X' %BlockNum + \ + self.FvInfFile.append("EFI_NUM_BLOCKS =3D " + + ' 0x%X' % BlockNum + TAB_LINE_BREAK) else: if self.BlockSizeList =3D=3D []: if not self._GetBlockSize(): - #set default block size is 1 - self.FvInfFile.append("EFI_BLOCK_SIZE =3D 0x1" + TAB_= LINE_BREAK) + # set default block size is 1 + self.FvInfFile.append( + "EFI_BLOCK_SIZE =3D 0x1" + TAB_LINE_BREAK) =20 for BlockSize in self.BlockSizeList: if BlockSize[0] is not None: - self.FvInfFile.append("EFI_BLOCK_SIZE =3D " + \ - '0x%X' %BlockSize[0] + \ + self.FvInfFile.append("EFI_BLOCK_SIZE =3D " + + '0x%X' % BlockSize[0] + TAB_LINE_BREAK) =20 if BlockSize[1] is not None: - self.FvInfFile.append("EFI_NUM_BLOCKS =3D " + \ - ' 0x%X' %BlockSize[1] + \ + self.FvInfFile.append("EFI_NUM_BLOCKS =3D " + + ' 0x%X' % BlockSize[1] + TAB_LINE_BREAK) =20 if self.BsBaseAddress is not None: - self.FvInfFile.append('EFI_BOOT_DRIVER_BASE_ADDRESS =3D ' + \ - '0x%X' %self.BsBaseAddress) + self.FvInfFile.append('EFI_BOOT_DRIVER_BASE_ADDRESS =3D ' + + '0x%X' % self.BsBaseAddress) if self.RtBaseAddress is not None: - self.FvInfFile.append('EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D ' += \ - '0x%X' %self.RtBaseAddress) + self.FvInfFile.append('EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D ' + + '0x%X' % self.RtBaseAddress) # # Add attribute # self.FvInfFile.append("[attributes]" + TAB_LINE_BREAK) =20 - self.FvInfFile.append("EFI_ERASE_POLARITY =3D " + \ - ' %s' %ErasePloarity + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_ERASE_POLARITY =3D " + + ' %s' % ErasePloarity + + TAB_LINE_BREAK) if not (self.FvAttributeDict is None): for FvAttribute in self.FvAttributeDict.keys(): if FvAttribute =3D=3D "FvUsedSizeEnable": if self.FvAttributeDict[FvAttribute].upper() in ('TRUE= ', '1'): self.UsedSizeEnable =3D True continue - self.FvInfFile.append("EFI_" + \ - FvAttribute + \ - ' =3D ' + \ - self.FvAttributeDict[FvAttribute= ] + \ - TAB_LINE_BREAK ) + self.FvInfFile.append("EFI_" + + FvAttribute + + ' =3D ' + + self.FvAttributeDict[FvAttribute] + + TAB_LINE_BREAK) if self.FvAlignment is not None: - self.FvInfFile.append("EFI_FVB2_ALIGNMENT_" + \ - self.FvAlignment.strip() + \ - " =3D TRUE" + \ - TAB_LINE_BREAK) + self.FvInfFile.append("EFI_FVB2_ALIGNMENT_" + + self.FvAlignment.strip() + + " =3D TRUE" + + TAB_LINE_BREAK) =20 # # Generate FV extension header file # if not self.FvNameGuid: if len(self.FvExtEntryType) > 0 or self.UsedSizeEnable: - GenFdsGlobalVariable.ErrorLogger("FV Extension Header Entr= ies declared for %s with no FvNameGuid declaration." % (self.UiFvName)) + GenFdsGlobalVariable.ErrorLogger( + "FV Extension Header Entries declared for %s with no F= vNameGuid declaration." % (self.UiFvName)) else: TotalSize =3D 16 + 4 Buffer =3D bytearray() if self.UsedSizeEnable: TotalSize +=3D (4 + 4) - ## define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03 - #typedef struct + # define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03 + # typedef struct # { # EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr; # UINT32 UsedSize; @@ -376,34 +397,41 @@ class FV (object): + PackGUID(Guid) + self.UiFvName.encode('utf-8')) =20 - for Index in range (0, len(self.FvExtEntryType)): + for Index in range(0, len(self.FvExtEntryType)): if self.FvExtEntryType[Index] =3D=3D 'FILE': # check if the path is absolute or relative if os.path.isabs(self.FvExtEntryData[Index]): - FileFullPath =3D os.path.normpath(self.FvExtEntryD= ata[Index]) + FileFullPath =3D os.path.normpath( + self.FvExtEntryData[Index]) else: - FileFullPath =3D os.path.normpath(os.path.join(Gen= FdsGlobalVariable.WorkSpaceDir, self.FvExtEntryData[Index])) + FileFullPath =3D os.path.normpath(os.path.join( + GenFdsGlobalVariable.WorkSpaceDir, self.FvExtE= ntryData[Index])) # check if the file path exists or not if not os.path.isfile(FileFullPath): - GenFdsGlobalVariable.ErrorLogger("Error opening FV= Extension Header Entry file %s." % (self.FvExtEntryData[Index])) - FvExtFile =3D open (FileFullPath, 'rb') + GenFdsGlobalVariable.ErrorLogger( + "Error opening FV Extension Header Entry file = %s." % (self.FvExtEntryData[Index])) + FvExtFile =3D open(FileFullPath, 'rb') FvExtFile.seek(0, 2) Size =3D FvExtFile.tell() if Size >=3D 0x10000: - GenFdsGlobalVariable.ErrorLogger("The size of FV E= xtension Header Entry file %s exceeds 0x10000." % (self.FvExtEntryData[Inde= x])) + GenFdsGlobalVariable.ErrorLogger( + "The size of FV Extension Header Entry file %s= exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize +=3D (Size + 4) FvExtFile.seek(0) - Buffer +=3D pack('HH', (Size + 4), int(self.FvExtEntry= TypeValue[Index], 16)) + Buffer +=3D pack('HH', (Size + 4), + int(self.FvExtEntryTypeValue[Index], 16= )) Buffer +=3D FvExtFile.read() FvExtFile.close() if self.FvExtEntryType[Index] =3D=3D 'DATA': ByteList =3D self.FvExtEntryData[Index].split(',') - Size =3D len (ByteList) + Size =3D len(ByteList) if Size >=3D 0x10000: - GenFdsGlobalVariable.ErrorLogger("The size of FV E= xtension Header Entry data %s exceeds 0x10000." % (self.FvExtEntryData[Inde= x])) + GenFdsGlobalVariable.ErrorLogger( + "The size of FV Extension Header Entry data %s= exceeds 0x10000." % (self.FvExtEntryData[Index])) TotalSize +=3D (Size + 4) - Buffer +=3D pack('HH', (Size + 4), int(self.FvExtEntry= TypeValue[Index], 16)) - for Index1 in range (0, Size): + Buffer +=3D pack('HH', (Size + 4), + int(self.FvExtEntryTypeValue[Index], 16= )) + for Index1 in range(0, Size): Buffer +=3D pack('B', int(ByteList[Index1], 16)) =20 Guid =3D self.FvNameGuid.split('-') @@ -413,17 +441,19 @@ class FV (object): # Generate FV extension header file if the total size is not z= ero # if TotalSize > 0: - FvExtHeaderFileName =3D os.path.join(GenFdsGlobalVariable.= FvDir, self.UiFvName + '.ext') + FvExtHeaderFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext') FvExtHeaderFile =3D BytesIO() FvExtHeaderFile.write(Buffer) - Changed =3D SaveFileOnChange(FvExtHeaderFileName, FvExtHea= derFile.getvalue(), True) + Changed =3D SaveFileOnChange( + FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True) FvExtHeaderFile.close() if Changed: - if os.path.exists (self.InfFileName): - os.remove (self.InfFileName) - self.FvInfFile.append("EFI_FV_EXT_HEADER_FILE_NAME =3D " = + \ - FvExtHeaderFileName = + \ - TAB_LINE_BREAK) + if os.path.exists(self.InfFileName): + os.remove(self.InfFileName) + self.FvInfFile.append("EFI_FV_EXT_HEADER_FILE_NAME =3D " + + FvExtHeaderFileName + + TAB_LINE_BREAK) =20 # # Add [Files] diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/S= ource/Python/GenFds/FvImageSection.py index ff2d5ca3c053..4fade8d888ea 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process FV image section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -22,19 +22,21 @@ from Common import EdkLogger from Common.BuildToolError import * from Common.DataType import * =20 -## generate FV image section +# generate FV image section # # + + class FvImageSection(FvImageSectionClassObject): =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): FvImageSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate FV image section # @@ -47,14 +49,15 @@ class FvImageSection(FvImageSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D None, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): =20 OutputFileList =3D [] if Dict is None: Dict =3D {} if self.FvFileType is not None: - FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FvFileType, self.FvFileExtension) - if IsSect : + FileList, IsSect =3D Section.Section.GetFileList( + FfsInf, self.FvFileType, self.FvFileExtension) + if IsSect: return FileList, self.Alignment =20 Num =3D SecNum @@ -63,36 +66,39 @@ class FvImageSection(FvImageSectionClassObject): for FvFileName in FileList: FvAlignmentValue =3D 0 if os.path.isfile(FvFileName): - FvFileObj =3D open (FvFileName, 'rb') + FvFileObj =3D open(FvFileName, 'rb') FvFileObj.seek(0) # PI FvHeader is 0x48 byte FvHeaderBuffer =3D FvFileObj.read(0x48) # FV alignment position. if isinstance(FvHeaderBuffer[0x2E], str): - FvAlignmentValue =3D 1 << (ord(FvHeaderBuffer[0x2E= ]) & 0x1F) + FvAlignmentValue =3D 1 << ( + ord(FvHeaderBuffer[0x2E]) & 0x1F) else: FvAlignmentValue =3D 1 << (FvHeaderBuffer[0x2E] & = 0x1F) FvFileObj.close() if FvAlignmentValue > MaxFvAlignment: MaxFvAlignment =3D FvAlignmentValue =20 - OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_M= ODULE_SEC + Num + SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileNa= me], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + Num + Sectio= nSuffix.get("FV_IMAGE")) + GenFdsGlobalVariable.GenerateSection( + OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME= _IMAGE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 # MaxFvAlignment is larger than or equal to 1K if MaxFvAlignment >=3D 0x400: if MaxFvAlignment >=3D 0x100000: - #The max alignment supported by FFS is 16M. + # The max alignment supported by FFS is 16M. if MaxFvAlignment >=3D 0x1000000: self.Alignment =3D "16M" else: self.Alignment =3D str(MaxFvAlignment // 0x100000)= + "M" else: - self.Alignment =3D str (MaxFvAlignment // 0x400) + "K" + self.Alignment =3D str(MaxFvAlignment // 0x400) + "K" else: # MaxFvAlignment is less than 1K - self.Alignment =3D str (MaxFvAlignment) + self.Alignment =3D str(MaxFvAlignment) =20 return OutputFileList, self.Alignment # @@ -105,54 +111,65 @@ class FvImageSection(FvImageSectionClassObject): self.Fv =3D Fv if not self.FvAddr and self.Fv.BaseAddress: self.FvAddr =3D self.Fv.BaseAddress - FvFileName =3D Fv.AddToBuffer(Buffer, self.FvAddr, MacroDi= ct =3D Dict, Flag=3DIsMakefile) + FvFileName =3D Fv.AddToBuffer( + Buffer, self.FvAddr, MacroDict=3DDict, Flag=3DIsMakefi= le) if Fv.FvAlignment is not None: if self.Alignment is None: self.Alignment =3D Fv.FvAlignment else: - if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignme= nt) > GenFdsGlobalVariable.GetAlignment (self.Alignment): + if GenFdsGlobalVariable.GetAlignment(Fv.FvAlignmen= t) > GenFdsGlobalVariable.GetAlignment(self.Alignment): self.Alignment =3D Fv.FvAlignment else: if self.FvFileName is not None: - FvFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMa= cro(self.FvFileName) + FvFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMa= cro( + self.FvFileName) if os.path.isfile(FvFileName): - FvFileObj =3D open (FvFileName, 'rb') + FvFileObj =3D open(FvFileName, 'rb') FvFileObj.seek(0) # PI FvHeader is 0x48 byte FvHeaderBuffer =3D FvFileObj.read(0x48) # FV alignment position. if isinstance(FvHeaderBuffer[0x2E], str): - FvAlignmentValue =3D 1 << (ord(FvHeaderBuffer[= 0x2E]) & 0x1F) + FvAlignmentValue =3D 1 << ( + ord(FvHeaderBuffer[0x2E]) & 0x1F) else: - FvAlignmentValue =3D 1 << (FvHeaderBuffer[0x2E= ] & 0x1F) + FvAlignmentValue =3D 1 << ( + FvHeaderBuffer[0x2E] & 0x1F) # FvAlignmentValue is larger than or equal to 1K if FvAlignmentValue >=3D 0x400: if FvAlignmentValue >=3D 0x100000: - #The max alignment supported by FFS is 16M. + # The max alignment supported by FFS is 16= M. if FvAlignmentValue >=3D 0x1000000: self.Alignment =3D "16M" else: - self.Alignment =3D str(FvAlignmentValu= e // 0x100000) + "M" + self.Alignment =3D str( + FvAlignmentValue // 0x100000) + "M" else: - self.Alignment =3D str (FvAlignmentValue /= / 0x400) + "K" + self.Alignment =3D str( + FvAlignmentValue // 0x400) + "K" else: # FvAlignmentValue is less than 1K - self.Alignment =3D str (FvAlignmentValue) + self.Alignment =3D str(FvAlignmentValue) FvFileObj.close() else: - if len (mws.getPkgPath()) =3D=3D 0: - EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s = is not found in WORKSPACE: %s" % self.FvFileName, GenFdsGlobalVariable.Work= SpaceDir) + if len(mws.getPkgPath()) =3D=3D 0: + EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s = is not found in WORKSPACE: %s" % + self.FvFileName, GenFdsGlobalV= ariable.WorkSpaceDir) else: - EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s = is not found in packages path:\n\t%s" % (self.FvFileName, '\n\t'.join(mws.g= etPkgPath()))) + EdkLogger.error("GenFds", FILE_NOT_FOUND, "%s = is not found in packages path:\n\t%s" % ( + self.FvFileName, '\n\t'.join(mws.getPkgPat= h()))) =20 else: - EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSectio= n Failed! %s NOT found in FDF" % self.FvName) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "FvImageSection Failed! %s= NOT found in FDF" % self.FvName) =20 # # Prepare the parameter of GenSection # - OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODUL= E_SEC + SecNum + SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],= 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Section= Suffix.get("FV_IMAGE")) + GenFdsGlobalVariable.GenerateSection( + OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMA= GE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 17b71b7cd347..856d4c84c435 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -1,4 +1,4 @@ -## @file +# @file # generate flash image # # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
        @@ -20,7 +20,7 @@ from linecache import getlines from io import BytesIO =20 import Common.LongFilePathOs as os -from Common.TargetTxtClassObject import TargetTxtDict,gDefaultTargetTxtFile +from Common.TargetTxtClassObject import TargetTxtDict, gDefaultTargetTxtFi= le from Common.DataType import * import Common.GlobalData as GlobalData from Common import EdkLogger @@ -43,7 +43,7 @@ versionNumber =3D "1.0" + ' ' + gBUILD_VERSION __version__ =3D "%prog Version " + versionNumber __copyright__ =3D "Copyright (c) 2007 - 2018, Intel Corporation All right= s reserved." =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -52,12 +52,15 @@ __copyright__ =3D "Copyright (c) 2007 - 2018, Intel Cor= poration All rights reserv # @retval 0 Tool was successful # @retval 1 Tool failed # + + def main(): global Options Options =3D myOptionParser() EdkLogger.Initialize() return GenFdsApi(OptionsToCommandDict(Options)) =20 + def resetFdsGlobalVariable(): GenFdsGlobalVariable.FvDir =3D '' GenFdsGlobalVariable.OutputDirDict =3D {} @@ -91,7 +94,7 @@ def resetFdsGlobalVariable(): GenFdsGlobalVariable.GuidToolDefinition =3D {} GenFdsGlobalVariable.FfsCmdDict =3D {} GenFdsGlobalVariable.SecCmdList =3D [] - GenFdsGlobalVariable.CopyList =3D [] + GenFdsGlobalVariable.CopyList =3D [] GenFdsGlobalVariable.ModuleFile =3D '' GenFdsGlobalVariable.EnableGenfdsMultiThread =3D True =20 @@ -104,6 +107,7 @@ def resetFdsGlobalVariable(): # FvName, FdName, CapName in FDF, Image file name GenFdsGlobalVariable.ImageBinDict =3D {} =20 + def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): global Workspace Workspace =3D "" @@ -127,17 +131,19 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): else: EdkLogger.SetLevel(EdkLogger.INFO) =20 - if not FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE')): + if not FdsCommandDict.get("Workspace", os.environ.get('WORKSPACE')= ): EdkLogger.error("GenFds", OPTION_MISSING, "WORKSPACE not defin= ed", ExtraData=3D"Please use '-w' switch to pass it= or set the WORKSPACE environment variable.") - elif not os.path.exists(FdsCommandDict.get("Workspace",os.environ.= get('WORKSPACE'))): + elif not os.path.exists(FdsCommandDict.get("Workspace", os.environ= .get('WORKSPACE'))): EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is inv= alid", ExtraData=3D"Please use '-w' switch to pass it= or set the WORKSPACE environment variable.") else: - Workspace =3D os.path.normcase(FdsCommandDict.get("Workspace",= os.environ.get('WORKSPACE'))) + Workspace =3D os.path.normcase(FdsCommandDict.get( + "Workspace", os.environ.get('WORKSPACE'))) GenFdsGlobalVariable.WorkSpaceDir =3D Workspace if FdsCommandDict.get("debug"): - GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Wo= rkspace) + GenFdsGlobalVariable.VerboseLogger( + "Using Workspace:" + Workspace) if FdsCommandDict.get("GenfdsMultiThread"): GenFdsGlobalVariable.EnableGenfdsMultiThread =3D True else: @@ -150,46 +156,58 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): =20 if FdsCommandDict.get("fdf_file"): FdfFilename =3D FdsCommandDict.get("fdf_file")[0].Path - FdfFilename =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(Fdf= Filename) + FdfFilename =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + FdfFilename) =20 if FdfFilename[0:2] =3D=3D '..': FdfFilename =3D os.path.abspath(FdfFilename) if not os.path.isabs(FdfFilename): - FdfFilename =3D mws.join(GenFdsGlobalVariable.WorkSpaceDir= , FdfFilename) + FdfFilename =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): - EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=3DFdfF= ilename) + EdkLogger.error("GenFds", FILE_NOT_FOUND, + ExtraData=3DFdfFilename) =20 GenFdsGlobalVariable.FdfFile =3D FdfFilename - GenFdsGlobalVariable.FdfFileTimeStamp =3D os.path.getmtime(Fdf= Filename) + GenFdsGlobalVariable.FdfFileTimeStamp =3D os.path.getmtime( + FdfFilename) else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filenam= e") =20 if FdsCommandDict.get("build_target"): - GenFdsGlobalVariable.TargetName =3D FdsCommandDict.get("build_= target") + GenFdsGlobalVariable.TargetName =3D FdsCommandDict.get( + "build_target") =20 if FdsCommandDict.get("toolchain_tag"): - GenFdsGlobalVariable.ToolChainTag =3D FdsCommandDict.get("tool= chain_tag") + GenFdsGlobalVariable.ToolChainTag =3D FdsCommandDict.get( + "toolchain_tag") =20 if FdsCommandDict.get("active_platform"): ActivePlatform =3D FdsCommandDict.get("active_platform") - ActivePlatform =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(= ActivePlatform) + ActivePlatform =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + ActivePlatform) =20 if ActivePlatform[0:2] =3D=3D '..': ActivePlatform =3D os.path.abspath(ActivePlatform) =20 - if not os.path.isabs (ActivePlatform): - ActivePlatform =3D mws.join(GenFdsGlobalVariable.WorkSpace= Dir, ActivePlatform) + if not os.path.isabs(ActivePlatform): + ActivePlatform =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) =20 if not os.path.exists(ActivePlatform): - EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform = doesn't exist!") + EdkLogger.error("GenFds", FILE_NOT_FOUND, + "ActivePlatform doesn't exist!") else: - EdkLogger.error("GenFds", OPTION_MISSING, "Missing active plat= form") + EdkLogger.error("GenFds", OPTION_MISSING, + "Missing active platform") =20 - GenFdsGlobalVariable.ActivePlatform =3D PathClass(NormPath(ActiveP= latform)) + GenFdsGlobalVariable.ActivePlatform =3D PathClass( + NormPath(ActivePlatform)) =20 if FdsCommandDict.get("conf_directory"): # Get alternate Conf location, if it is absolute, then just us= e the absolute directory name - ConfDirectoryPath =3D os.path.normpath(FdsCommandDict.get("con= f_directory")) + ConfDirectoryPath =3D os.path.normpath( + FdsCommandDict.get("conf_directory")) if ConfDirectoryPath.startswith('"'): ConfDirectoryPath =3D ConfDirectoryPath[1:] if ConfDirectoryPath.endswith('"'): @@ -197,17 +215,20 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alte= rnate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory = in the workspace. Using --conf=3DConf - ConfDirectoryPath =3D os.path.join(GenFdsGlobalVariable.Wo= rkSpaceDir, ConfDirectoryPath) + ConfDirectoryPath =3D os.path.join( + GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: if "CONF_PATH" in os.environ: ConfDirectoryPath =3D os.path.normcase(os.environ["CONF_PA= TH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to th= e WORKSPACE/Conf - ConfDirectoryPath =3D mws.join(GenFdsGlobalVariable.WorkSp= aceDir, 'Conf') + ConfDirectoryPath =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir =3D ConfDirectoryPath if not GlobalData.gConfDirectory: GlobalData.gConfDirectory =3D GenFdsGlobalVariable.ConfDir - BuildConfigurationFile =3D os.path.normpath(os.path.join(ConfDirec= toryPath, gDefaultTargetTxtFile)) + BuildConfigurationFile =3D os.path.normpath( + os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile)) if os.path.isfile(BuildConfigurationFile) =3D=3D True: # if no build target given in command line, get it from target= .txt TargetObj =3D TargetTxtDict() @@ -215,21 +236,25 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): if not GenFdsGlobalVariable.TargetName: BuildTargetList =3D TargetTxt.TargetTxtDictionary[TAB_TAT_= DEFINES_TARGET] if len(BuildTargetList) !=3D 1: - EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraD= ata=3D"Only allows one instance for Target.") + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, + ExtraData=3D"Only allows one instance = for Target.") GenFdsGlobalVariable.TargetName =3D BuildTargetList[0] =20 # if no tool chain given in command line, get it from target.t= xt if not GenFdsGlobalVariable.ToolChainTag: ToolChainList =3D TargetTxt.TargetTxtDictionary[TAB_TAT_DE= FINES_TOOL_CHAIN_TAG] if ToolChainList is None or len(ToolChainList) =3D=3D 0: - EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, Extr= aData=3D"No toolchain given. Don't know how to build.") + EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, + ExtraData=3D"No toolchain given. Don't= know how to build.") if len(ToolChainList) !=3D 1: - EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraD= ata=3D"Only allows one instance for ToolChain.") + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, + ExtraData=3D"Only allows one instance = for ToolChain.") GenFdsGlobalVariable.ToolChainTag =3D ToolChainList[0] else: - EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=3DBuildCon= figurationFile) + EdkLogger.error("GenFds", FILE_NOT_FOUND, + ExtraData=3DBuildConfigurationFile) =20 - #Set global flag for build mode + # Set global flag for build mode GlobalData.gIgnoreSource =3D FdsCommandDict.get("IgnoreSources") =20 if FdsCommandDict.get("macro"): @@ -241,11 +266,14 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): List =3D Pair.split('=3D') if len(List) =3D=3D 2: if not List[1].strip(): - EdkLogger.error("GenFds", OPTION_VALUE_INVALID, Ex= traData=3D"No Value given for Macro %s" %List[0]) + EdkLogger.error( + "GenFds", OPTION_VALUE_INVALID, ExtraData=3D"N= o Value given for Macro %s" % List[0]) if List[0].strip() in ["WORKSPACE", "TARGET", "TOOLCHA= IN"]: - GlobalData.gGlobalDefines[List[0].strip()] =3D Lis= t[1].strip() + GlobalData.gGlobalDefines[List[0].strip( + )] =3D List[1].strip() else: - GlobalData.gCommandLineDefines[List[0].strip()] = =3D List[1].strip() + GlobalData.gCommandLineDefines[List[0].strip( + )] =3D List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] =3D "T= RUE" os.environ["WORKSPACE"] =3D Workspace @@ -259,7 +287,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] =3D GenFdsGlobalVa= riable.ToolChainTag =20 """call Workspace build create database""" - GlobalData.gDatabasePath =3D os.path.normpath(os.path.join(ConfDir= ectoryPath, GlobalData.gDatabasePath)) + GlobalData.gDatabasePath =3D os.path.normpath( + os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) =20 if WorkSpaceDataBase: BuildWorkSpace =3D WorkSpaceDataBase @@ -274,27 +303,35 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): if FdsCommandDict.get("build_architecture_list"): ArchList =3D FdsCommandDict.get("build_architecture_list").spl= it(',') else: - ArchList =3D BuildWorkSpace.BuildObject[GenFdsGlobalVariable.A= ctivePlatform, TAB_COMMON, FdsCommandDict.get("build_target"), FdsCommandDi= ct.get("toolchain_tag")].SupArchList + ArchList =3D BuildWorkSpace.BuildObject[GenFdsGlobalVariable.A= ctivePlatform, TAB_COMMON, FdsCommandDict.get( + "build_target"), FdsCommandDict.get("toolchain_tag")].SupA= rchList =20 - TargetArchList =3D set(BuildWorkSpace.BuildObject[GenFdsGlobalVari= able.ActivePlatform, TAB_COMMON, FdsCommandDict.get("build_target"), FdsCom= mandDict.get("toolchain_tag")].SupArchList) & set(ArchList) + TargetArchList =3D set(BuildWorkSpace.BuildObject[GenFdsGlobalVari= able.ActivePlatform, TAB_COMMON, FdsCommandDict.get( + "build_target"), FdsCommandDict.get("toolchain_tag")].SupArchL= ist) & set(ArchList) if len(TargetArchList) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in= platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObje= ct[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList))) + EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in= platform supported ARCH %s" % (str( + ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVari= able.ActivePlatform, TAB_COMMON].SupArchList))) =20 for Arch in ArchList: - GenFdsGlobalVariable.OutputDirFromDscDict[Arch] =3D NormPath(B= uildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, FdsCom= mandDict.get("build_target"), FdsCommandDict.get("toolchain_tag")].OutputDi= rectory) + GenFdsGlobalVariable.OutputDirFromDscDict[Arch] =3D NormPath(B= uildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, FdsCom= mandDict.get( + "build_target"), FdsCommandDict.get("toolchain_tag")].Outp= utDirectory) =20 # assign platform name based on last entry in ArchList - GenFdsGlobalVariable.PlatformName =3D BuildWorkSpace.BuildObject[G= enFdsGlobalVariable.ActivePlatform, ArchList[-1], FdsCommandDict.get("build= _target"), FdsCommandDict.get("toolchain_tag")].PlatformName + GenFdsGlobalVariable.PlatformName =3D BuildWorkSpace.BuildObject[G= enFdsGlobalVariable.ActivePlatform, + Arc= hList[-1], FdsCommandDict.get("build_target"), FdsCommandDict.get("toolchai= n_tag")].PlatformName =20 if FdsCommandDict.get("platform_build_directory"): - OutputDirFromCommandLine =3D GenFdsGlobalVariable.ReplaceWorks= paceMacro(FdsCommandDict.get("platform_build_directory")) - if not os.path.isabs (OutputDirFromCommandLine): - OutputDirFromCommandLine =3D os.path.join(GenFdsGlobalVari= able.WorkSpaceDir, OutputDirFromCommandLine) + OutputDirFromCommandLine =3D GenFdsGlobalVariable.ReplaceWorks= paceMacro( + FdsCommandDict.get("platform_build_directory")) + if not os.path.isabs(OutputDirFromCommandLine): + OutputDirFromCommandLine =3D os.path.join( + GenFdsGlobalVariable.WorkSpaceDir, OutputDirFromComman= dLine) for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] =3D OutputDirFrom= CommandLine else: for Arch in ArchList: - GenFdsGlobalVariable.OutputDirDict[Arch] =3D os.path.join(= GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.Targe= tName + '_' + GenFdsGlobalVariable.ToolChainTag) + GenFdsGlobalVariable.OutputDirDict[Arch] =3D os.path.join( + GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFd= sGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag) =20 for Key in GenFdsGlobalVariable.OutputDirDict: OutputDir =3D GenFdsGlobalVariable.OutputDirDict[Key] @@ -302,7 +339,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): OutputDir =3D os.path.abspath(OutputDir) =20 if OutputDir[1] !=3D ':': - OutputDir =3D os.path.join (GenFdsGlobalVariable.WorkSpace= Dir, OutputDir) + OutputDir =3D os.path.join( + GenFdsGlobalVariable.WorkSpaceDir, OutputDir) =20 if not os.path.exists(OutputDir): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=3DOutp= utDir) @@ -316,7 +354,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): FdfParserObj.ParseFile() =20 if FdfParserObj.CycleReferenceCheck(): - EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Referen= ce Detected in FDF file") + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, + "Cycle Reference Detected in FDF file") =20 if FdsCommandDict.get("fd"): if FdsCommandDict.get("fd")[0].upper() in FdfParserObj.Profile= .FdDict: @@ -347,7 +386,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): =20 """Modify images from build output if the feature of loading drive= r at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: - GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.Ac= tivePlatform) + GenFds.PreprocessImage( + BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform) =20 # Record the FV Region info that may specific in the FD if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict: @@ -359,13 +399,16 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() =3D=3D RegionData.up= per(): if not FvObj.BaseAddress: - FvObj.BaseAddress =3D '0x%x' % (int(Fd= Obj.BaseAddress, 0) + RegionObj.Offset) + FvObj.BaseAddress =3D '0x%x' % ( + int(FdObj.BaseAddress, 0) + Region= Obj.Offset) if FvObj.FvRegionInFD: if FvObj.FvRegionInFD !=3D RegionObj.S= ize: - EdkLogger.error("GenFds", FORMAT_I= NVALID, "The FV %s's region is specified in multiple FD with different valu= e." %FvObj.UiFvName) + EdkLogger.error( + "GenFds", FORMAT_INVALID, "The= FV %s's region is specified in multiple FD with different value." % FvObj.= UiFvName) else: FvObj.FvRegionInFD =3D RegionObj.Size - RegionObj.BlockInfoOfRegion(FdObj.Bloc= kSizeList, FvObj) + RegionObj.BlockInfoOfRegion( + FdObj.BlockSizeList, FvObj) =20 """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) @@ -377,7 +420,8 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNone): GenFds.DisplayFvSpaceInfo(FdfParserObj) =20 except Warning as X: - EdkLogger.error(X.ToolName, FORMAT_INVALID, File=3DX.FileName, Lin= e=3DX.LineNumber, ExtraData=3DX.Message, RaiseError=3DFalse) + EdkLogger.error(X.ToolName, FORMAT_INVALID, File=3DX.FileName, + Line=3DX.LineNumber, ExtraData=3DX.Message, RaiseE= rror=3DFalse) ReturnCode =3D FORMAT_INVALID except FatalError as X: if FdsCommandDict.get("debug") is not None: @@ -387,18 +431,19 @@ def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=3DNon= e): except: import traceback EdkLogger.error( - "\nPython", - CODE_ERROR, - "Tools code failure", - ExtraData=3D"Please send email to %s for help, attachi= ng following call stack trace!\n" % MSG_EDKII_MAIL_ADDR, - RaiseError=3DFalse - ) + "\nPython", + CODE_ERROR, + "Tools code failure", + ExtraData=3D"Please send email to %s for help, attaching follo= wing call stack trace!\n" % MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) EdkLogger.quiet(traceback.format_exc()) ReturnCode =3D CODE_ERROR finally: ClearDuplicatedInf() return ReturnCode =20 + def OptionsToCommandDict(Options): FdsCommandDict =3D {} FdsCommandDict["verbose"] =3D Options.verbose @@ -407,7 +452,8 @@ def OptionsToCommandDict(Options): FdsCommandDict["debug"] =3D Options.debug FdsCommandDict["Workspace"] =3D Options.Workspace FdsCommandDict["GenfdsMultiThread"] =3D not Options.NoGenfdsMultiThread - FdsCommandDict["fdf_file"] =3D [PathClass(Options.filename)] if Option= s.filename else [] + FdsCommandDict["fdf_file"] =3D [ + PathClass(Options.filename)] if Options.filename else [] FdsCommandDict["build_target"] =3D Options.BuildTarget FdsCommandDict["toolchain_tag"] =3D Options.ToolChain FdsCommandDict["active_platform"] =3D Options.activePlatform @@ -424,65 +470,88 @@ def OptionsToCommandDict(Options): =20 =20 gParamCheck =3D [] + + def SingleCheckCallback(option, opt_str, value, parser): if option not in gParamCheck: setattr(parser.values, option.dest, value) gParamCheck.append(option) else: - parser.error("Option %s only allows one instance in command line!"= % option) + parser.error( + "Option %s only allows one instance in command line!" % option) =20 -## Parse command line options +# Parse command line options # # Using standard Python module optparse to parse command line option of th= is tool. # # @retval Opt A optparse.Values object containing the parsed options # + + def myOptionParser(): usage =3D "%prog [options] -f input_file -a arch_list -b build_target = -p active_platform -t tool_chain_tag -D \"MacroName [=3D MacroValue]\"" - Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, ve= rsion=3D"%prog " + str(versionNumber)) - Parser.add_option("-f", "--file", dest=3D"filename", type=3D"string", = help=3D"Name of FDF file to convert", action=3D"callback", callback=3DSingl= eCheckCallback) - Parser.add_option("-a", "--arch", dest=3D"archList", help=3D"comma sep= arated list containing one or more of: IA32, X64, IPF, ARM, AARCH64 or EBC = which should be built, overrides target.txt?s TARGET_ARCH") - Parser.add_option("-q", "--quiet", action=3D"store_true", type=3DNone,= help=3D"Disable all messages except FATAL ERRORS.") - Parser.add_option("-v", "--verbose", action=3D"store_true", type=3DNon= e, help=3D"Turn on verbose output with informational messages printed.") - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", hel= p=3D"Enable debug messages at specified level.") + Parser =3D OptionParser(usage=3Dusage, description=3D__copyright__, + version=3D"%prog " + str(versionNumber)) + Parser.add_option("-f", "--file", dest=3D"filename", type=3D"string", + help=3D"Name of FDF file to convert", action=3D"call= back", callback=3DSingleCheckCallback) + Parser.add_option("-a", "--arch", dest=3D"archList", + help=3D"comma separated list containing one or more = of: IA32, X64, IPF, ARM, AARCH64 or EBC which should be built, overrides ta= rget.txt?s TARGET_ARCH") + Parser.add_option("-q", "--quiet", action=3D"store_true", + type=3DNone, help=3D"Disable all messages except FAT= AL ERRORS.") + Parser.add_option("-v", "--verbose", action=3D"store_true", type=3DNon= e, + help=3D"Turn on verbose output with informational me= ssages printed.") + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + help=3D"Enable debug messages at specified level.") Parser.add_option("-p", "--platform", type=3D"string", dest=3D"activeP= latform", help=3D"Set the ACTIVE_PLATFORM, overrides target.txt ACTIVE_PLAT= FORM setting.", action=3D"callback", callback=3DSingleCheckCallback) Parser.add_option("-w", "--workspace", type=3D"string", dest=3D"Worksp= ace", default=3Dos.environ.get('WORKSPACE'), help=3D"Set the WORKSPACE", action=3D"callback", callback=3DSingleCheckCallback) Parser.add_option("-o", "--outputDir", type=3D"string", dest=3D"output= Dir", help=3D"Name of Build Output directory", action=3D"callback", callback=3DSingleCheckCallback) - Parser.add_option("-r", "--rom_image", dest=3D"uiFdName", help=3D"Buil= d the image using the [FD] section named by FdUiName.") - Parser.add_option("-i", "--FvImage", dest=3D"uiFvName", help=3D"Build = the FV image using the [FV] section named by UiFvName") - Parser.add_option("-C", "--CapsuleImage", dest=3D"uiCapName", help=3D"= Build the Capsule image using the [Capsule] section named by UiCapName") + Parser.add_option("-r", "--rom_image", dest=3D"uiFdName", + help=3D"Build the image using the [FD] section named= by FdUiName.") + Parser.add_option("-i", "--FvImage", dest=3D"uiFvName", + help=3D"Build the FV image using the [FV] section na= med by UiFvName") + Parser.add_option("-C", "--CapsuleImage", dest=3D"uiCapName", + help=3D"Build the Capsule image using the [Capsule] = section named by UiCapName") Parser.add_option("-b", "--buildtarget", type=3D"string", dest=3D"Buil= dTarget", help=3D"Set the build TARGET, overrides target.txt TARGET setting= .", action=3D"callback", callback=3DSingleCheckCallback) Parser.add_option("-t", "--tagname", type=3D"string", dest=3D"ToolChai= n", help=3D"Using the tools: TOOL_CHAIN_TAG name to build the platform.", action=3D"callback", callback=3DSingleCheckCallback) - Parser.add_option("-D", "--define", action=3D"append", type=3D"string"= , dest=3D"Macros", help=3D"Macro: \"Name [=3D Value]\".") - Parser.add_option("-s", "--specifyaddress", dest=3D"FixedAddress", act= ion=3D"store_true", type=3DNone, help=3D"Specify driver load address.") - Parser.add_option("--conf", action=3D"store", type=3D"string", dest=3D= "ConfDirectory", help=3D"Specify the customized Conf directory.") - Parser.add_option("--ignore-sources", action=3D"store_true", dest=3D"I= gnoreSources", default=3DFalse, help=3D"Focus to a binary build and ignore = all source files") - Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", help= =3D"Set PCD value by command line. Format: \"PcdName=3DValue\" ") - Parser.add_option("--genfds-multi-thread", action=3D"store_true", dest= =3D"GenfdsMultiThread", default=3DTrue, help=3D"Enable GenFds multi thread = to generate ffs file.") - Parser.add_option("--no-genfds-multi-thread", action=3D"store_true", d= est=3D"NoGenfdsMultiThread", default=3DFalse, help=3D"Disable GenFds multi = thread to generate ffs file.") + Parser.add_option("-D", "--define", action=3D"append", type=3D"string", + dest=3D"Macros", help=3D"Macro: \"Name [=3D Value]\"= .") + Parser.add_option("-s", "--specifyaddress", dest=3D"FixedAddress", + action=3D"store_true", type=3DNone, help=3D"Specify = driver load address.") + Parser.add_option("--conf", action=3D"store", type=3D"string", + dest=3D"ConfDirectory", help=3D"Specify the customiz= ed Conf directory.") + Parser.add_option("--ignore-sources", action=3D"store_true", dest=3D"I= gnoreSources", + default=3DFalse, help=3D"Focus to a binary build and= ignore all source files") + Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", + help=3D"Set PCD value by command line. Format: \"Pcd= Name=3DValue\" ") + Parser.add_option("--genfds-multi-thread", action=3D"store_true", dest= =3D"GenfdsMultiThread", + default=3DTrue, help=3D"Enable GenFds multi thread t= o generate ffs file.") + Parser.add_option("--no-genfds-multi-thread", action=3D"store_true", d= est=3D"NoGenfdsMultiThread", + default=3DFalse, help=3D"Disable GenFds multi thread= to generate ffs file.") =20 Options, _ =3D Parser.parse_args() return Options =20 -## The class implementing the EDK2 flash image generation process +# The class implementing the EDK2 flash image generation process # # This process includes: # 1. Collect workspace information, includes platform and module inf= ormation # 2. Call methods of Fd class to generate FD # 3. Call methods of Fv class to generate FV that not belong to FD # + + class GenFds(object): FdfParsef =3D None OnlyGenerateThisFd =3D None OnlyGenerateThisFv =3D None OnlyGenerateThisCap =3D None =20 - ## GenFd() + # GenFd() # # @param OutputDir Output directory # @param FdfParserObject FDF contents parser @@ -490,18 +559,21 @@ class GenFds(object): # @param ArchList The Arch list of platform # @staticmethod - def GenFd (OutputDir, FdfParserObject, WorkSpace, ArchList): - GenFdsGlobalVariable.SetDir ('', FdfParserObject, WorkSpace, ArchL= ist) + def GenFd(OutputDir, FdfParserObject, WorkSpace, ArchList): + GenFdsGlobalVariable.SetDir('', FdfParserObject, WorkSpace, ArchLi= st) =20 - GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and th= eir required FV and Capsule images!") + GenFdsGlobalVariable.VerboseLogger( + " Generate all Fd images and their required FV and Capsule ima= ges!") if GenFds.OnlyGenerateThisCap is not None and GenFds.OnlyGenerateT= hisCap.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict: - CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Profile.CapsuleD= ict[GenFds.OnlyGenerateThisCap.upper()] + CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Profile.CapsuleD= ict[GenFds.OnlyGenerateThisCap.upper( + )] if CapsuleObj is not None: CapsuleObj.GenCapsule() return =20 if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper()] + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper( + )] if FdObj is not None: FdObj.GenFd() return @@ -511,7 +583,8 @@ class GenFds(object): =20 GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ") if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateTh= isFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict: - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds= .OnlyGenerateThisFv.upper()] + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds= .OnlyGenerateThisFv.upper( + )] if FvObj is not None: Buffer =3D BytesIO() FvObj.AddToBuffer(Buffer) @@ -525,18 +598,21 @@ class GenFds(object): =20 if GenFds.OnlyGenerateThisFv is None and GenFds.OnlyGenerateThisFd= is None and GenFds.OnlyGenerateThisCap is None: if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict !=3D {}: - GenFdsGlobalVariable.VerboseLogger("\n Generate other Caps= ule images!") + GenFdsGlobalVariable.VerboseLogger( + "\n Generate other Capsule images!") for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.C= apsuleDict.values(): CapsuleObj.GenCapsule() =20 if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: - GenFdsGlobalVariable.VerboseLogger("\n Generate all Option= ROM!") + GenFdsGlobalVariable.VerboseLogger( + "\n Generate all Option ROM!") for OptRomObj in GenFdsGlobalVariable.FdfParser.Profile.Op= tRomDict.values(): OptRomObj.AddToBuffer(None) =20 @staticmethod def GenFfsMakefile(OutputDir, FdfParserObject, WorkSpace, ArchList, Gl= obalData): - GenFdsGlobalVariable.SetEnv(FdfParserObject, WorkSpace, ArchList, = GlobalData) + GenFdsGlobalVariable.SetEnv( + FdfParserObject, WorkSpace, ArchList, GlobalData) for FdObj in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values(= ): FdObj.GenFd(Flag=3DTrue) =20 @@ -549,7 +625,7 @@ class GenFds(object): =20 return GenFdsGlobalVariable.FfsCmdDict =20 - ## GetFvBlockSize() + # GetFvBlockSize() # # @param FvObj Whose block size to get # @retval int Block size value @@ -559,7 +635,8 @@ class GenFds(object): DefaultBlockSize =3D 0x1 FdObj =3D None if GenFds.OnlyGenerateThisFd is not None and GenFds.OnlyGenerateTh= isFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict: - FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper()] + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds= .OnlyGenerateThisFd.upper( + )] if FdObj is None: for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict= .values(): for ElementRegion in ElementFd.RegionList: @@ -575,16 +652,16 @@ class GenFds(object): return DefaultBlockSize else: for ElementRegion in FdObj.RegionList: - if ElementRegion.RegionType =3D=3D BINARY_FILE_TYPE_FV: - for ElementRegionData in ElementRegion.RegionDataL= ist: - if ElementRegionData is not None and ElementRe= gionData.upper() =3D=3D FvObj.UiFvName: - if FvObj.BlockSizeList !=3D []: - return FvObj.BlockSizeList[0][0] - else: - return ElementRegion.BlockSizeOfRegion= (ElementFd.BlockSizeList) + if ElementRegion.RegionType =3D=3D BINARY_FILE_TYPE_FV: + for ElementRegionData in ElementRegion.RegionDataList: + if ElementRegionData is not None and ElementRegion= Data.upper() =3D=3D FvObj.UiFvName: + if FvObj.BlockSizeList !=3D []: + return FvObj.BlockSizeList[0][0] + else: + return ElementRegion.BlockSizeOfRegion(Ele= mentFd.BlockSizeList) return DefaultBlockSize =20 - ## DisplayFvSpaceInfo() + # DisplayFvSpaceInfo() # # @param FvObj Whose block size to get # @retval None @@ -597,7 +674,8 @@ class GenFds(object): for FvName in FdfParserObject.Profile.FvDict: if len(FvName) > MaxFvNameLength: MaxFvNameLength =3D len(FvName) - FvSpaceInfoFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, FvName.upper() + '.Fv.map') + FvSpaceInfoFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, FvName.upper() + '.Fv.map') if os.path.exists(FvSpaceInfoFileName): FileLinesList =3D getlines(FvSpaceInfoFileName) TotalFound =3D False @@ -631,14 +709,18 @@ class GenFds(object): if UsedSizeValue =3D=3D TotalSizeValue: Percentage =3D '100' else: - Percentage =3D str((UsedSizeValue + 0.0) / TotalSizeValue)= [0:4].lstrip('0.') + Percentage =3D str((UsedSizeValue + 0.0) / + TotalSizeValue)[0:4].lstrip('0.') =20 - GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage += '%Full] '\ - + str(TotalSizeValue) + ' (' + = hex(TotalSizeValue) + ')' + ' total, '\ - + str(UsedSizeValue) + ' (' + h= ex(UsedSizeValue) + ')' + ' used, '\ + GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage += '%Full] ' + + str(TotalSizeValue) + ' (' + + hex(TotalSizeValue) + + ')' + ' total, ' + + str(UsedSizeValue) + ' (' + + hex(UsedSizeValue) + ')' + ' us= ed, ' + str(FreeSizeValue) + ' (' + h= ex(FreeSizeValue) + ')' + ' free') =20 - ## PreprocessImage() + # PreprocessImage() # # @param BuildDb Database from build meta data files # @param DscFile modules from dsc file will be preprocessed @@ -646,7 +728,8 @@ class GenFds(object): # @staticmethod def PreprocessImage(BuildDb, DscFile): - PcdDict =3D BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalV= ariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Pcds + PcdDict =3D BuildDb.BuildObject[DscFile, TAB_COMMON, + GenFdsGlobalVariable.TargetName, Gen= FdsGlobalVariable.ToolChainTag].Pcds PcdValue =3D '' for Key in PcdDict: PcdObj =3D PcdDict[Key] @@ -665,14 +748,17 @@ class GenFds(object): if Int64PcdValue > 0: TopAddress =3D Int64PcdValue =20 - ModuleDict =3D BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlob= alVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules + ModuleDict =3D BuildDb.BuildObject[DscFile, TAB_COMMON, + GenFdsGlobalVariable.TargetName, = GenFdsGlobalVariable.ToolChainTag].Modules for Key in ModuleDict: - ModuleObj =3D BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGloba= lVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + ModuleObj =3D BuildDb.BuildObject[Key, TAB_COMMON, + GenFdsGlobalVariable.TargetNam= e, GenFdsGlobalVariable.ToolChainTag] print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType) =20 @staticmethod def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj): - GuidXRefFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, "Gui= d.xref") + GuidXRefFileName =3D os.path.join( + GenFdsGlobalVariable.FvDir, "Guid.xref") GuidXRefFile =3D [] PkgGuidDict =3D {} GuidDict =3D {} @@ -680,8 +766,10 @@ class GenFds(object): FileGuidList =3D [] VariableGuidSet =3D set() for Arch in ArchList: - PlatformDataBase =3D BuildDb.BuildObject[GenFdsGlobalVariable.= ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable= .ToolChainTag] - PkgList =3D GenFdsGlobalVariable.WorkSpace.GetPackageList(GenF= dsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, Gen= FdsGlobalVariable.ToolChainTag) + PlatformDataBase =3D BuildDb.BuildObject[GenFdsGlobalVariable.= ActivePlatform, + Arch, GenFdsGlobalVaria= ble.TargetName, GenFdsGlobalVariable.ToolChainTag] + PkgList =3D GenFdsGlobalVariable.WorkSpace.GetPackageList( + GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVar= iable.TargetName, GenFdsGlobalVariable.ToolChainTag) for P in PkgList: PkgGuidDict.update(P.Guids) for Name, Guid in PlatformDataBase.Pcds: @@ -689,33 +777,40 @@ class GenFds(object): if Pcd.Type in [TAB_PCDS_DYNAMIC_HII, TAB_PCDS_DYNAMIC_EX_= HII]: for SkuId in Pcd.SkuInfoList: Sku =3D Pcd.SkuInfoList[SkuId] - if Sku.VariableGuid in VariableGuidSet:continue + if Sku.VariableGuid in VariableGuidSet: + continue VariableGuidSet.add(Sku.VariableGuid) if Sku.VariableGuid and Sku.VariableGuid in PkgGui= dDict.keys(): GuidDict[Sku.VariableGuid] =3D PkgGuidDict[Sku= .VariableGuid] for ModuleFile in PlatformDataBase.Modules: - Module =3D BuildDb.BuildObject[ModuleFile, Arch, GenFdsGlo= balVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + Module =3D BuildDb.BuildObject[ModuleFile, Arch, + GenFdsGlobalVariable.TargetNa= me, GenFdsGlobalVariable.ToolChainTag] if Module in ModuleList: continue else: ModuleList.append(Module) if GlobalData.gGuidPattern.match(ModuleFile.BaseName): - GuidXRefFile.append("%s %s\n" % (ModuleFile.BaseName, = Module.BaseName)) + GuidXRefFile.append("%s %s\n" % + (ModuleFile.BaseName, Module.BaseN= ame)) else: - GuidXRefFile.append("%s %s\n" % (Module.Guid, Module.B= aseName)) + GuidXRefFile.append("%s %s\n" % + (Module.Guid, Module.BaseName)) GuidDict.update(Module.Protocols) GuidDict.update(Module.Guids) GuidDict.update(Module.Ppis) for FvName in FdfParserObj.Profile.FvDict: for FfsObj in FdfParserObj.Profile.FvDict[FvName].FfsList: if not isinstance(FfsObj, FileStatement): - InfPath =3D PathClass(NormPath(mws.join(GenFdsGlob= alVariable.WorkSpaceDir, FfsObj.InfFileName))) - FdfModule =3D BuildDb.BuildObject[InfPath, Arch, G= enFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] + InfPath =3D PathClass( + NormPath(mws.join(GenFdsGlobalVariable.WorkSpa= ceDir, FfsObj.InfFileName))) + FdfModule =3D BuildDb.BuildObject[InfPath, Arch, + GenFdsGlobalVariab= le.TargetName, GenFdsGlobalVariable.ToolChainTag] if FdfModule in ModuleList: continue else: ModuleList.append(FdfModule) - GuidXRefFile.append("%s %s\n" % (FdfModule.Guid, F= dfModule.BaseName)) + GuidXRefFile.append("%s %s\n" % ( + FdfModule.Guid, FdfModule.BaseName)) GuidDict.update(FdfModule.Protocols) GuidDict.update(FdfModule.Guids) GuidDict.update(FdfModule.Ppis) @@ -726,21 +821,25 @@ class GenFds(object): else: FileGuidList.append(FileStatementGuid) Name =3D [] - FfsPath =3D os.path.join(GenFdsGlobalVariable.FvDi= r, 'Ffs') - FfsPath =3D glob(os.path.join(FfsPath, FileStateme= ntGuid) + TAB_STAR) + FfsPath =3D os.path.join( + GenFdsGlobalVariable.FvDir, 'Ffs') + FfsPath =3D glob(os.path.join( + FfsPath, FileStatementGuid) + TAB_STAR) if not FfsPath: continue if not os.path.exists(FfsPath[0]): continue MatchDict =3D {} - ReFileEnds =3D compile('\S+(.ui)$|\S+(fv.sec.txt)$= |\S+(.pe32.txt)$|\S+(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$= ') + ReFileEnds =3D compile( + '\S+(.ui)$|\S+(fv.sec.txt)$|\S+(.pe32.txt)$|\S= +(.te.txt)$|\S+(.pic.txt)$|\S+(.raw.txt)$|\S+(.ffs.txt)$') FileList =3D os.listdir(FfsPath[0]) for File in FileList: Match =3D ReFileEnds.search(File) if Match: for Index in range(1, 8): if Match.group(Index) and Match.group(= Index) in MatchDict: - MatchDict[Match.group(Index)].appe= nd(File) + MatchDict[Match.group( + Index)].append(File) elif Match.group(Index): MatchDict[Match.group(Index)] =3D = [File] if not MatchDict: @@ -751,7 +850,8 @@ class GenFds(object): F.read() length =3D F.tell() F.seek(4) - TmpStr =3D unpack('%dh' % ((length - 4= ) // 2), F.read()) + TmpStr =3D unpack( + '%dh' % ((length - 4) // 2), F.rea= d()) Name =3D ''.join(chr(c) for c in TmpSt= r[:-1]) else: FileList =3D [] @@ -775,26 +875,29 @@ class GenFds(object): if not Name: continue =20 - Name =3D ' '.join(Name) if isinstance(Name, type([= ])) else Name - GuidXRefFile.append("%s %s\n" %(FileStatementGuid,= Name)) + Name =3D ' '.join(Name) if isinstance( + Name, type([])) else Name + GuidXRefFile.append("%s %s\n" % + (FileStatementGuid, Name)) =20 # Append GUIDs, Protocols, and PPIs to the Xref file GuidXRefFile.append("\n") for key, item in GuidDict.items(): - GuidXRefFile.append("%s %s\n" % (GuidStructureStringToGuidStri= ng(item).upper(), key)) + GuidXRefFile.append("%s %s\n" % ( + GuidStructureStringToGuidString(item).upper(), key)) =20 if GuidXRefFile: GuidXRefFile =3D ''.join(GuidXRefFile) SaveFileOnChange(GuidXRefFileName, GuidXRefFile, False) - GenFdsGlobalVariable.InfLogger("\nGUID cross reference file ca= n be found at %s" % GuidXRefFileName) + GenFdsGlobalVariable.InfLogger( + "\nGUID cross reference file can be found at %s" % GuidXRe= fFileName) elif os.path.exists(GuidXRefFileName): os.remove(GuidXRefFileName) =20 =20 if __name__ =3D=3D '__main__': r =3D main() - ## 0-127 is a safe return range, and 1 is a standard default error + # 0-127 is a safe return range, and 1 is a standard default error if r < 0 or r > 127: r =3D 1 exit(r) - diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index d7668ba681aa..8b68d60aca68 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -1,4 +1,4 @@ -## @file +# @file # Global variables for GenFds # # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
        @@ -15,28 +15,30 @@ from __future__ import absolute_import import Common.LongFilePathOs as os import sys from sys import stdout -from subprocess import PIPE,Popen +from subprocess import PIPE, Popen from struct import Struct from array import array =20 -from Common.BuildToolError import COMMAND_FAILURE,GENFDS_ERROR +from Common.BuildToolError import COMMAND_FAILURE, GENFDS_ERROR from Common import EdkLogger from Common.Misc import SaveFileOnChange =20 from Common.TargetTxtClassObject import TargetTxtDict -from Common.ToolDefClassObject import ToolDefDict,gDefaultToolsDefFile +from Common.ToolDefClassObject import ToolDefDict, gDefaultToolsDefFile from AutoGen.BuildEngine import ToolBuildRule import Common.DataType as DataType -from Common.Misc import PathClass,CreateDirectory +from Common.Misc import PathClass, CreateDirectory from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws import Common.GlobalData as GlobalData from Common.BuildToolError import * from AutoGen.AutoGen import CalculatePriorityValue =20 -## Global variables +# Global variables # # + + class GenFdsGlobalVariable: FvDir =3D '' OutputDirDict =3D {} @@ -70,7 +72,7 @@ class GenFdsGlobalVariable: GuidToolDefinition =3D {} FfsCmdDict =3D {} SecCmdList =3D [] - CopyList =3D [] + CopyList =3D [] ModuleFile =3D '' EnableGenfdsMultiThread =3D True =20 @@ -92,7 +94,7 @@ class GenFdsGlobalVariable: # FvName, FdName, CapName in FDF, Image file name ImageBinDict =3D {} =20 - ## LoadBuildRule + # LoadBuildRule # @staticmethod def _LoadBuildRule(): @@ -101,24 +103,28 @@ class GenFdsGlobalVariable: BuildRule =3D ToolBuildRule() GenFdsGlobalVariable.__BuildRuleDatabase =3D BuildRule.ToolBuildRu= le TargetObj =3D TargetTxtDict() - ToolDefinitionFile =3D TargetObj.Target.TargetTxtDictionary[DataTy= pe.TAB_TAT_DEFINES_TOOL_CHAIN_CONF] + ToolDefinitionFile =3D TargetObj.Target.TargetTxtDictionary[ + DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF] if ToolDefinitionFile =3D=3D '': - ToolDefinitionFile =3D os.path.join('Conf', gDefaultToolsDefF= ile) + ToolDefinitionFile =3D os.path.join('Conf', gDefaultToolsDefFi= le) if os.path.isfile(ToolDefinitionFile): - ToolDefObj =3D ToolDefDict((os.path.join(os.getenv("WORKSPACE"= ), "Conf"))) + ToolDefObj =3D ToolDefDict( + (os.path.join(os.getenv("WORKSPACE"), "Conf"))) ToolDefinition =3D ToolDefObj.ToolDef.ToolsDefTxtDatabase if DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDefinition \ and GenFdsGlobalVariable.ToolChainTag in ToolDefinition[Dat= aType.TAB_TOD_DEFINES_BUILDRULEFAMILY] \ and ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY= ][GenFdsGlobalVariable.ToolChainTag]: - GenFdsGlobalVariable.BuildRuleFamily =3D ToolDefinition[Da= taType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobalVariable.ToolChainTag] + GenFdsGlobalVariable.BuildRuleFamily =3D ToolDefinition[ + DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobal= Variable.ToolChainTag] =20 if DataType.TAB_TOD_DEFINES_FAMILY in ToolDefinition \ and GenFdsGlobalVariable.ToolChainTag in ToolDefinition[Dat= aType.TAB_TOD_DEFINES_FAMILY] \ and ToolDefinition[DataType.TAB_TOD_DEFINES_FAMILY][GenFdsG= lobalVariable.ToolChainTag]: - GenFdsGlobalVariable.ToolChainFamily =3D ToolDefinition[Da= taType.TAB_TOD_DEFINES_FAMILY][GenFdsGlobalVariable.ToolChainTag] + GenFdsGlobalVariable.ToolChainFamily =3D ToolDefinition[ + DataType.TAB_TOD_DEFINES_FAMILY][GenFdsGlobalVariable.= ToolChainTag] return GenFdsGlobalVariable.__BuildRuleDatabase =20 - ## GetBuildRules + # GetBuildRules # @param Inf: object of InfBuildData # @param Arch: current arch # @@ -144,44 +150,48 @@ class GenFdsGlobalVariable: ) BinDir =3D os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch], = Arch) Macro =3D { - "WORKSPACE":GenFdsGlobalVariable.WorkSpaceDir, - "MODULE_NAME":Inf.BaseName, - "MODULE_GUID":Inf.Guid, - "MODULE_VERSION":Inf.Version, - "MODULE_TYPE":Inf.ModuleType, - "MODULE_FILE":str(PathClassObj), - "MODULE_FILE_BASE_NAME":PathClassObj.BaseName, - "MODULE_RELATIVE_DIR":PathClassObj.SubDir, - "MODULE_DIR":PathClassObj.SubDir, - "BASE_NAME":Inf.BaseName, - "ARCH":Arch, - "TOOLCHAIN":GenFdsGlobalVariable.ToolChainTag, - "TOOLCHAIN_TAG":GenFdsGlobalVariable.ToolChainTag, - "TOOL_CHAIN_TAG":GenFdsGlobalVariable.ToolChainTag, - "TARGET":GenFdsGlobalVariable.TargetName, - "BUILD_DIR":GenFdsGlobalVariable.OutputDirDict[Arch], - "BIN_DIR":BinDir, - "LIB_DIR":BinDir, - "MODULE_BUILD_DIR":BuildDir, - "OUTPUT_DIR":os.path.join(BuildDir, "OUTPUT"), - "DEBUG_DIR":os.path.join(BuildDir, "DEBUG") + "WORKSPACE": GenFdsGlobalVariable.WorkSpaceDir, + "MODULE_NAME": Inf.BaseName, + "MODULE_GUID": Inf.Guid, + "MODULE_VERSION": Inf.Version, + "MODULE_TYPE": Inf.ModuleType, + "MODULE_FILE": str(PathClassObj), + "MODULE_FILE_BASE_NAME": PathClassObj.BaseName, + "MODULE_RELATIVE_DIR": PathClassObj.SubDir, + "MODULE_DIR": PathClassObj.SubDir, + "BASE_NAME": Inf.BaseName, + "ARCH": Arch, + "TOOLCHAIN": GenFdsGlobalVariable.ToolChainTag, + "TOOLCHAIN_TAG": GenFdsGlobalVariable.ToolChainTag, + "TOOL_CHAIN_TAG": GenFdsGlobalVariable.ToolChainTag, + "TARGET": GenFdsGlobalVariable.TargetName, + "BUILD_DIR": GenFdsGlobalVariable.OutputDirDict[Arch], + "BIN_DIR": BinDir, + "LIB_DIR": BinDir, + "MODULE_BUILD_DIR": BuildDir, + "OUTPUT_DIR": os.path.join(BuildDir, "OUTPUT"), + "DEBUG_DIR": os.path.join(BuildDir, "DEBUG") } =20 BuildRules =3D {} for Type in BuildRuleDatabase.FileTypeList: - #first try getting build rule by BuildRuleFamily - RuleObject =3D BuildRuleDatabase[Type, Inf.BuildType, Arch, Ge= nFdsGlobalVariable.BuildRuleFamily] + # first try getting build rule by BuildRuleFamily + RuleObject =3D BuildRuleDatabase[Type, Inf.BuildType, + Arch, GenFdsGlobalVariable.Buil= dRuleFamily] if not RuleObject: # build type is always module type, but ... if Inf.ModuleType !=3D Inf.BuildType: - RuleObject =3D BuildRuleDatabase[Type, Inf.ModuleType,= Arch, GenFdsGlobalVariable.BuildRuleFamily] - #second try getting build rule by ToolChainFamily + RuleObject =3D BuildRuleDatabase[Type, Inf.ModuleType, + Arch, GenFdsGlobalVaria= ble.BuildRuleFamily] + # second try getting build rule by ToolChainFamily if not RuleObject: - RuleObject =3D BuildRuleDatabase[Type, Inf.BuildType, Arch= , GenFdsGlobalVariable.ToolChainFamily] + RuleObject =3D BuildRuleDatabase[Type, Inf.BuildType, + Arch, GenFdsGlobalVariable.= ToolChainFamily] if not RuleObject: # build type is always module type, but ... if Inf.ModuleType !=3D Inf.BuildType: - RuleObject =3D BuildRuleDatabase[Type, Inf.ModuleT= ype, Arch, GenFdsGlobalVariable.ToolChainFamily] + RuleObject =3D BuildRuleDatabase[Type, Inf.ModuleT= ype, + Arch, GenFdsGlobalV= ariable.ToolChainFamily] if not RuleObject: continue RuleObject =3D RuleObject.Instantiate(Macro) @@ -190,7 +200,7 @@ class GenFdsGlobalVariable: BuildRules[Ext] =3D RuleObject return BuildRules =20 - ## GetModuleCodaTargetList + # GetModuleCodaTargetList # # @param Inf: object of InfBuildData # @param Arch: current arch @@ -207,7 +217,7 @@ class GenFdsGlobalVariable: if not Inf.IsBinaryModule: for File in Inf.Sources: if File.TagName in {"", DataType.TAB_STAR, GenFdsGlobalVar= iable.ToolChainTag} and \ - File.ToolChainFamily in {"", DataType.TAB_STAR, GenFds= GlobalVariable.ToolChainFamily}: + File.ToolChainFamily in {"", DataType.TAB_STAR, Ge= nFdsGlobalVariable.ToolChainFamily}: FileList.append((File, DataType.TAB_UNKNOWN_FILE)) =20 for File in Inf.Binaries: @@ -270,7 +280,7 @@ class GenFdsGlobalVariable: =20 return list(TargetList) =20 - ## SetDir() + # SetDir() # # @param OutputDir Output directory # @param FdfParser FDF contents parser @@ -278,21 +288,25 @@ class GenFdsGlobalVariable: # @param ArchList The Arch list of platform # @staticmethod - def SetDir (OutputDir, FdfParser, WorkSpace, ArchList): - GenFdsGlobalVariable.VerboseLogger("GenFdsGlobalVariable.OutputDir= :%s" % OutputDir) + def SetDir(OutputDir, FdfParser, WorkSpace, ArchList): + GenFdsGlobalVariable.VerboseLogger( + "GenFdsGlobalVariable.OutputDir:%s" % OutputDir) GenFdsGlobalVariable.FdfParser =3D FdfParser GenFdsGlobalVariable.WorkSpace =3D WorkSpace - GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) + GenFdsGlobalVariable.FvDir =3D os.path.join( + GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_= FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir): os.makedirs(GenFdsGlobalVariable.FvDir) - GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') + GenFdsGlobalVariable.FfsDir =3D os.path.join( + GenFdsGlobalVariable.FvDir, 'Ffs') if not os.path.exists(GenFdsGlobalVariable.FfsDir): os.makedirs(GenFdsGlobalVariable.FfsDir) =20 # # Create FV Address inf file # - GenFdsGlobalVariable.FvAddressFileName =3D os.path.join(GenFdsGlob= alVariable.FfsDir, 'FvAddress.inf') + GenFdsGlobalVariable.FvAddressFileName =3D os.path.join( + GenFdsGlobalVariable.FfsDir, 'FvAddress.inf') FvAddressFile =3D open(GenFdsGlobalVariable.FvAddressFileName, 'w') # # Add [Options] @@ -301,23 +315,25 @@ class GenFdsGlobalVariable: BsAddress =3D '0' for Arch in ArchList: if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVari= able.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVar= iable.ToolChainTag].BsBaseAddress: - BsAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[G= enFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, = GenFdsGlobalVariable.ToolChainTag].BsBaseAddress + BsAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[G= enFdsGlobalVariable.ActivePlatform, + Arc= h, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].BsBa= seAddress break =20 - FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + \ - BsAddress + \ - DataType.TAB_LINE_BREAK) + FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + + BsAddress + + DataType.TAB_LINE_BREAK) =20 RtAddress =3D '0' for Arch in reversed(ArchList): - temp =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlo= balVariable.ToolChainTag].RtBaseAddress + temp =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, + Arch, GenFds= GlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress if temp: RtAddress =3D temp break =20 - FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + \ - RtAddress + \ - DataType.TAB_LINE_BREAK) + FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + + RtAddress + + DataType.TAB_LINE_BREAK) =20 FvAddressFile.close() =20 @@ -330,31 +346,34 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.ToolChainTag =3D GlobalData.gGlobalDefines["T= OOL_CHAIN_TAG"] GenFdsGlobalVariable.TargetName =3D GlobalData.gGlobalDefines["TAR= GET"] GenFdsGlobalVariable.ActivePlatform =3D GlobalData.gActivePlatform - GenFdsGlobalVariable.ConfDir =3D GlobalData.gConfDirectory + GenFdsGlobalVariable.ConfDir =3D GlobalData.gConfDirectory GenFdsGlobalVariable.EnableGenfdsMultiThread =3D GlobalData.gEnabl= eGenfdsMultiThread for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] =3D os.path.normpath( os.path.join(GlobalData.gWorkspace, WorkSpace.Db.BuildObject[GenFdsGlobalVariable= .ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'], - GlobalData.gGlobalDefines['TOOLCHAIN']].Outpu= tDirectory, - GlobalData.gGlobalDefines['TARGET'] +'_' + Gl= obalData.gGlobalDefines['TOOLCHAIN'])) + GlobalData.gGlobalDe= fines['TOOLCHAIN']].OutputDirectory, + GlobalData.gGlobalDefines['TARGET'] + '_' + G= lobalData.gGlobalDefines['TOOLCHAIN'])) GenFdsGlobalVariable.OutputDirFromDscDict[Arch] =3D os.path.no= rmpath( - WorkSpace.Db.BuildObject[GenFdsGlobalVariable= .ActivePlatform, Arch, - GlobalData.gGlobalDefines['TARGET'], GlobalDa= ta.gGlobalDefines['TOOLCHAIN']].OutputDirectory) + WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatfo= rm, Arch, + GlobalData.gGlobalDefines['TARGET= '], GlobalData.gGlobalDefines['TOOLCHAIN']].OutputDirectory) GenFdsGlobalVariable.PlatformName =3D WorkSpace.Db.BuildObject= [GenFdsGlobalVariable.ActivePlatform, Arch, - Glob= alData.gGlobalDefines['TARGET'], - Glob= alData.gGlobalDefines['TOOLCHAIN']].PlatformName - GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY) + G= lobalData.gGlobalDefines['TARGET'], + G= lobalData.gGlobalDefines['TOOLCHAIN']].PlatformName + GenFdsGlobalVariable.FvDir =3D os.path.join( + GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_= FV_DIRECTORY) if not os.path.exists(GenFdsGlobalVariable.FvDir): os.makedirs(GenFdsGlobalVariable.FvDir) - GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') + GenFdsGlobalVariable.FfsDir =3D os.path.join( + GenFdsGlobalVariable.FvDir, 'Ffs') if not os.path.exists(GenFdsGlobalVariable.FfsDir): os.makedirs(GenFdsGlobalVariable.FfsDir) =20 # # Create FV Address inf file # - GenFdsGlobalVariable.FvAddressFileName =3D os.path.join(GenFdsGlob= alVariable.FfsDir, 'FvAddress.inf') + GenFdsGlobalVariable.FvAddressFileName =3D os.path.join( + GenFdsGlobalVariable.FfsDir, 'FvAddress.inf') FvAddressFile =3D open(GenFdsGlobalVariable.FvAddressFileName, 'w') # # Add [Options] @@ -368,8 +387,8 @@ class GenFdsGlobalVariable: if BsAddress: break =20 - FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + \ - BsAddress + \ + FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + + BsAddress + DataType.TAB_LINE_BREAK) =20 RtAddress =3D '0' @@ -381,13 +400,13 @@ class GenFdsGlobalVariable: RtAddress =3D temp break =20 - FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + \ - RtAddress + \ + FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + + RtAddress + DataType.TAB_LINE_BREAK) =20 FvAddressFile.close() =20 - ## ReplaceWorkspaceMacro() + # ReplaceWorkspaceMacro() # # @param String String that may contain macro # @@ -402,7 +421,7 @@ class GenFdsGlobalVariable: Str =3D mws.join(GenFdsGlobalVariable.WorkSpaceDir, String) return os.path.normpath(Str) =20 - ## Check if the input files are newer than output files + # Check if the input files are newer than output files # # @param Output Path of output file # @param Input Path list of input files @@ -446,10 +465,10 @@ class GenFdsGlobalVariable: Cmd +=3D ("--dummy", DummyFile) if GuidHdrLen: Cmd +=3D ("-l", GuidHdrLen) - #Add each guided attribute + # Add each guided attribute for Attr in GuidAttr: Cmd +=3D ("-r", Attr) - #Section Align is only for dummy section without section type + # Section Align is only for dummy section without section type for SecAlign in InputAlign: Cmd +=3D ("--sectionalign", SecAlign) =20 @@ -462,31 +481,36 @@ class GenFdsGlobalVariable: Cmd +=3D ("-n", '"' + Ui + '"') Cmd +=3D ("-o", Output) if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: - GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + GenFdsGlobalVariable.SecCmdList.append( + ' '.join(Cmd).strip()) else: SectionData =3D array('B', [0, 0, 0, 0]) - SectionData.fromlist(array('B',Ui.encode('utf-16-le')).tol= ist()) + SectionData.fromlist( + array('B', Ui.encode('utf-16-le')).tolist()) SectionData.append(0) SectionData.append(0) Len =3D len(SectionData) - GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, = 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) - + GenFdsGlobalVariable.SectionHeader.pack_into( + SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >>= 16) & 0xff, 0x15) =20 DirName =3D os.path.dirname(Output) if not CreateDirectory(DirName): - EdkLogger.error(None, FILE_CREATE_FAILURE, "Could not = create directory %s" % DirName) + EdkLogger.error(None, FILE_CREATE_FAILURE, + "Could not create directory %s" % DirN= ame) else: if DirName =3D=3D '': DirName =3D os.getcwd() if not os.access(DirName, os.W_OK): - EdkLogger.error(None, PERMISSION_FAILURE, "Do not = have write permission on directory %s" % DirName) + EdkLogger.error( + None, PERMISSION_FAILURE, "Do not have write p= ermission on directory %s" % DirName) =20 try: with open(Output, "wb") as Fd: SectionData.tofile(Fd) Fd.flush() except IOError as X: - EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData= =3D'IOError %s' % X) + EdkLogger.error(None, FILE_CREATE_FAILURE, + ExtraData=3D'IOError %s' % X) =20 elif Ver: Cmd +=3D ("-n", Ver) @@ -497,11 +521,13 @@ class GenFdsGlobalVariable: SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if IsMakefile: if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: - GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + GenFdsGlobalVariable.SecCmdList.append( + ' '.join(Cmd).strip()) else: if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input= ) + [CommandFile]): return - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to generate section") else: Cmd +=3D ("-o", Output) Cmd +=3D Input @@ -513,38 +539,42 @@ class GenFdsGlobalVariable: else: Cmd =3D ['-test', '-e', Input[0], "&&"] + Cmd if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: - GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + GenFdsGlobalVariable.SecCmdList.append( + ' '.join(Cmd).strip()) elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [C= ommandFile]): - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s ne= eds update because of newer %s" % (Output, Input)) - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %= s" % (Output, Input)) + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to generate section") if (os.path.getsize(Output) >=3D GenFdsGlobalVariable.LARG= E_FILE_SIZE and - GenFdsGlobalVariable.LargeFileInFvFlags): + GenFdsGlobalVariable.LargeFileInFvFlags): GenFdsGlobalVariable.LargeFileInFvFlags[-1] =3D True =20 @staticmethod - def GetAlignment (AlignString): + def GetAlignment(AlignString): if not AlignString: return 0 if AlignString.endswith('K'): - return int (AlignString.rstrip('K')) * 1024 + return int(AlignString.rstrip('K')) * 1024 if AlignString.endswith('M'): - return int (AlignString.rstrip('M')) * 1024 * 1024 + return int(AlignString.rstrip('M')) * 1024 * 1024 if AlignString.endswith('G'): - return int (AlignString.rstrip('G')) * 1024 * 1024 * 1024 - return int (AlignString) + return int(AlignString.rstrip('G')) * 1024 * 1024 * 1024 + return int(AlignString) =20 @staticmethod def GenerateFfs(Output, Input, Type, Guid, Fixed=3DFalse, CheckSum=3DF= alse, Align=3DNone, SectionAlign=3DNone, MakefilePath=3DNone): Cmd =3D ["GenFfs", "-t", Type, "-g", Guid] - mFfsValidAlign =3D ["0", "8", "16", "128", "512", "1K", "4K", "32K= ", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"] + mFfsValidAlign =3D ["0", "8", "16", "128", "512", "1K", "4K", "32K= ", + "64K", "128K", "256K", "512K", "1M", "2M", "4M",= "8M", "16M"] if Fixed =3D=3D True: Cmd.append("-x") if CheckSum: Cmd.append("-s") if Align: if Align not in mFfsValidAlign: - Align =3D GenFdsGlobalVariable.GetAlignment (Align) + Align =3D GenFdsGlobalVariable.GetAlignment(Align) for index in range(0, len(mFfsValidAlign) - 1): if ((Align > GenFdsGlobalVariable.GetAlignment(mFfsVal= idAlign[index])) and (Align <=3D GenFdsGlobalVariable.GetAlignment(mFfsVali= dAlign[index + 1]))): break @@ -563,23 +593,27 @@ class GenFdsGlobalVariable: CommandFile =3D Output + '.txt' SaveFileOnChange(CommandFile, ' '.join(Cmd), False) =20 - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Ou= tput, Input)) if MakefilePath: if (tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(= GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict: - GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGl= obalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] =3D Makefil= ePath + GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple( + GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVa= riable.CopyList)] =3D MakefilePath GenFdsGlobalVariable.SecCmdList =3D [] GenFdsGlobalVariable.CopyList =3D [] else: if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + = [CommandFile]): return - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= FFS") + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to generate FFS") =20 @staticmethod def GenerateFirmwareVolume(Output, Input, BaseAddress=3DNone, ForceReb= ase=3DNone, Capsule=3DFalse, Dump=3DFalse, AddressFile=3DNone, MapFile=3DNone, FfsList= =3D[], FileSystemGuid=3DNone): if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList): return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Ou= tput, Input)) =20 Cmd =3D ["GenFv"] if BaseAddress: @@ -612,7 +646,8 @@ class GenFdsGlobalVariable: Align=3DNone, Padding=3DNone, Convert=3DFals= e, IsMakefile=3DFalse): if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Ou= tput, Input)) =20 Cmd =3D ["GenFw"] if Type.lower() =3D=3D "te": @@ -641,11 +676,12 @@ class GenFdsGlobalVariable: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) else: - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= firmware image") + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to generate firmware image") =20 @staticmethod def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=3DFalse,= ClassCode=3DNone, - Revision=3DNone, DeviceId=3DNone, VendorId=3DNone,= IsMakefile=3DFalse): + Revision=3DNone, DeviceId=3DNone, VendorId=3DNon= e, IsMakefile=3DFalse): InputList =3D [] Cmd =3D ["EfiRom"] if EfiInput: @@ -657,18 +693,19 @@ class GenFdsGlobalVariable: =20 for EfiFile in EfiInput: Cmd.append(EfiFile) - InputList.append (EfiFile) + InputList.append(EfiFile) =20 if BinaryInput: Cmd.append("-b") for BinFile in BinaryInput: Cmd.append(BinFile) - InputList.append (BinFile) + InputList.append(BinFile) =20 # Check List if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList) and not= IsMakefile: return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, InputList)) + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Ou= tput, InputList)) =20 if ClassCode: Cmd +=3D ("-l", ClassCode) @@ -684,13 +721,15 @@ class GenFdsGlobalVariable: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) else: - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= option rom") + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to generate option rom") =20 @staticmethod def GuidTool(Output, Input, ToolPath, Options=3D'', returnValue=3D[], = IsMakefile=3DFalse): if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + GenFdsGlobalVariable.DebugLogger( + EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Ou= tput, Input)) =20 Cmd =3D [ToolPath, ] Cmd +=3D Options.split(' ') @@ -700,80 +739,87 @@ class GenFdsGlobalVariable: if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) else: - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " += ToolPath, returnValue) + GenFdsGlobalVariable.CallExternalTool( + Cmd, "Failed to call " + ToolPath, returnValue) =20 @staticmethod - def CallExternalTool (cmd, errorMess, returnValue=3D[]): + def CallExternalTool(cmd, errorMess, returnValue=3D[]): =20 if type(cmd) not in (tuple, list): - GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid paramete= r type in call to CallExternalTool") + GenFdsGlobalVariable.ErrorLogger( + "ToolError! Invalid parameter type in call to CallExterna= lTool") =20 if GenFdsGlobalVariable.DebugLevel !=3D -1: cmd +=3D ('--debug', str(GenFdsGlobalVariable.DebugLevel)) - GenFdsGlobalVariable.InfLogger (cmd) + GenFdsGlobalVariable.InfLogger(cmd) =20 if GenFdsGlobalVariable.VerboseMode: cmd +=3D ('-v',) - GenFdsGlobalVariable.InfLogger (cmd) + GenFdsGlobalVariable.InfLogger(cmd) else: - stdout.write ('#') + stdout.write('#') stdout.flush() GenFdsGlobalVariable.SharpCounter =3D GenFdsGlobalVariable.Sha= rpCounter + 1 if GenFdsGlobalVariable.SharpCounter % GenFdsGlobalVariable.Sh= arpNumberPerLine =3D=3D 0: stdout.write('\n') =20 try: - PopenObject =3D Popen(' '.join(cmd), stdout=3DPIPE, stderr=3DP= IPE, shell=3DTrue) + PopenObject =3D Popen(' '.join(cmd), stdout=3DPIPE, + stderr=3DPIPE, shell=3DTrue) except Exception as X: - EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData=3D"%s: %s= " % (str(X), cmd[0])) + EdkLogger.error("GenFds", COMMAND_FAILURE, + ExtraData=3D"%s: %s" % (str(X), cmd[0])) (out, error) =3D PopenObject.communicate() =20 while PopenObject.returncode is None: PopenObject.wait() if returnValue !=3D [] and returnValue[0] !=3D 0: - #get command return value + # get command return value returnValue[0] =3D PopenObject.returncode return if PopenObject.returncode !=3D 0 or GenFdsGlobalVariable.VerboseMo= de or GenFdsGlobalVariable.DebugLevel !=3D -1: - GenFdsGlobalVariable.InfLogger ("Return Value =3D %d" % PopenO= bject.returncode) - GenFdsGlobalVariable.InfLogger(out.decode(encoding=3D'utf-8', = errors=3D'ignore')) - GenFdsGlobalVariable.InfLogger(error.decode(encoding=3D'utf-8'= , errors=3D'ignore')) + GenFdsGlobalVariable.InfLogger( + "Return Value =3D %d" % PopenObject.returncode) + GenFdsGlobalVariable.InfLogger( + out.decode(encoding=3D'utf-8', errors=3D'ignore')) + GenFdsGlobalVariable.InfLogger( + error.decode(encoding=3D'utf-8', errors=3D'ignore')) if PopenObject.returncode !=3D 0: print("###", cmd) EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess) =20 @staticmethod - def VerboseLogger (msg): + def VerboseLogger(msg): EdkLogger.verbose(msg) =20 @staticmethod - def InfLogger (msg): + def InfLogger(msg): EdkLogger.info(msg) =20 @staticmethod - def ErrorLogger (msg, File=3DNone, Line=3DNone, ExtraData=3DNone): + def ErrorLogger(msg, File=3DNone, Line=3DNone, ExtraData=3DNone): EdkLogger.error('GenFds', GENFDS_ERROR, msg, File, Line, ExtraData) =20 @staticmethod - def DebugLogger (Level, msg): + def DebugLogger(Level, msg): EdkLogger.debug(Level, msg) =20 - ## MacroExtend() + # MacroExtend() # # @param Str String that may contain macro # @param MacroDict Dictionary that contains macro value pair # @staticmethod - def MacroExtend (Str, MacroDict=3DNone, Arch=3DDataType.TAB_COMMON): + def MacroExtend(Str, MacroDict=3DNone, Arch=3DDataType.TAB_COMMON): if Str is None: return None =20 Dict =3D {'$(WORKSPACE)': GenFdsGlobalVariable.WorkSpaceDir, -# '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFrom= Dsc, + # '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariab= le.OutputDirFromDsc, '$(TARGET)': GenFdsGlobalVariable.TargetName, '$(TOOL_CHAIN_TAG)': GenFdsGlobalVariable.ToolChainTag, '$(SPACE)': ' ' - } + } =20 if Arch !=3D DataType.TAB_COMMON and Arch in GenFdsGlobalVariable.= ArchList: OutputDir =3D GenFdsGlobalVariable.OutputDirFromDscDict[Arch] @@ -787,22 +833,23 @@ class GenFdsGlobalVariable: =20 for key in Dict: if Str.find(key) >=3D 0: - Str =3D Str.replace (key, Dict[key]) + Str =3D Str.replace(key, Dict[key]) =20 if Str.find('$(ARCH)') >=3D 0: if len(GenFdsGlobalVariable.ArchList) =3D=3D 1: Str =3D Str.replace('$(ARCH)', GenFdsGlobalVariable.ArchLi= st[0]) else: - EdkLogger.error("GenFds", GENFDS_ERROR, "No way to determi= ne $(ARCH) for %s" % Str) + EdkLogger.error("GenFds", GENFDS_ERROR, + "No way to determine $(ARCH) for %s" % Str) =20 return Str =20 - ## GetPcdValue() + # GetPcdValue() # # @param PcdPattern pattern that labels a PCD. # @staticmethod - def GetPcdValue (PcdPattern): + def GetPcdValue(PcdPattern): if PcdPattern is None: return None if PcdPattern.startswith('PCD('): @@ -813,15 +860,18 @@ class GenFdsGlobalVariable: TokenCName =3D PcdPair[1] =20 for Arch in GenFdsGlobalVariable.ArchList: - Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFds= GlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFd= sGlobalVariable.ToolChainTag] + Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFds= GlobalVariable.ActivePlatform, + Arch, Ge= nFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] PcdDict =3D Platform.Pcds for Key in PcdDict: PcdObj =3D PcdDict[Key] if (PcdObj.TokenCName =3D=3D TokenCName) and (PcdObj.Token= SpaceGuidCName =3D=3D TokenSpace): if PcdObj.Type !=3D DataType.TAB_PCDS_FIXED_AT_BUILD: - EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not= FixedAtBuild type." % PcdPattern) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "%s is not FixedAtBuil= d type." % PcdPattern) if PcdObj.DatumType !=3D DataType.TAB_VOID: - EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not= VOID* datum type." % PcdPattern) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "%s is not VOID* datum= type." % PcdPattern) =20 return PcdObj.DefaultValue =20 @@ -834,15 +884,17 @@ class GenFdsGlobalVariable: PcdObj =3D PcdDict[Key] if (PcdObj.TokenCName =3D=3D TokenCName) and (PcdObj.T= okenSpaceGuidCName =3D=3D TokenSpace): if PcdObj.Type !=3D DataType.TAB_PCDS_FIXED_AT_BUI= LD: - EdkLogger.error("GenFds", GENFDS_ERROR, "%s is= not FixedAtBuild type." % PcdPattern) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "%s is not FixedAt= Build type." % PcdPattern) if PcdObj.DatumType !=3D DataType.TAB_VOID: - EdkLogger.error("GenFds", GENFDS_ERROR, "%s is= not VOID* datum type." % PcdPattern) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "%s is not VOID* d= atum type." % PcdPattern) =20 return PcdObj.DefaultValue =20 return '' =20 -## FindExtendTool() +# FindExtendTool() # # Find location of tools to process data # @@ -850,6 +902,8 @@ class GenFdsGlobalVariable: # @param CurrentArchList Arch list # @param NameGuid The Guid name # + + def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): if GenFdsGlobalVariable.GuidToolDefinition: if NameGuid in GenFdsGlobalVariable.GuidToolDefinition: @@ -863,7 +917,8 @@ def FindExtendTool(KeyStringList, CurrentArchList, Name= Guid): Target =3D GenFdsGlobalVariable.TargetName ToolChain =3D GenFdsGlobalVariable.ToolChainTag if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: - EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external= tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "Can not find external tool becaus= e tool tag %s is not defined in tools_def.txt!" % ToolChain) KeyStringList =3D [Target + '_' + ToolChain + '_' + CurrentArchLis= t[0]] for Arch in CurrentArchList: if Target + '_' + ToolChain + '_' + Arch not in KeyStringList: @@ -876,13 +931,15 @@ def FindExtendTool(KeyStringList, CurrentArchList, Na= meGuid): MatchPathItem =3D None MatchOptionsItem =3D None for KeyString in KeyStringList: - KeyStringBuildTarget, KeyStringToolChain, KeyStringArch =3D Ke= yString.split('_') + KeyStringBuildTarget, KeyStringToolChain, KeyStringArch =3D Ke= yString.split( + '_') if KeyStringArch !=3D Arch: continue for Item in ToolDef.ToolsDefTxtDictionary: if len(Item.split('_')) < 5: continue - ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item.split('_') + ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item.split( + '_') if ItemTarget =3D=3D DataType.TAB_STAR: ItemTarget =3D KeyStringBuildTarget if ItemToolChain =3D=3D DataType.TAB_STAR: @@ -915,7 +972,8 @@ def FindExtendTool(KeyStringList, CurrentArchList, Name= Guid): for Item in ToolDef.ToolsDefTxtDictionary: if len(Item.split('_')) < 5: continue - ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item.split('_') + ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item.split( + '_') if ItemTarget =3D=3D DataType.TAB_STAR: ItemTarget =3D KeyStringBuildTarget if ItemToolChain =3D=3D DataType.TAB_STAR: @@ -952,14 +1010,17 @@ def FindExtendTool(KeyStringList, CurrentArchList, N= ameGuid): MatchPathItem =3D None MatchOptionsItem =3D None for KeyString in KeyStringList: - KeyStringBuildTarget, KeyStringToolChain, KeyStringArch =3D Ke= yString.split('_') + KeyStringBuildTarget, KeyStringToolChain, KeyStringArch =3D Ke= yString.split( + '_') if KeyStringArch !=3D Arch: continue - Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFds= GlobalVariable.ActivePlatform, Arch, KeyStringBuildTarget, KeyStringToolCha= in] + Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[ + GenFdsGlobalVariable.ActivePlatform, Arch, KeyStringBuildT= arget, KeyStringToolChain] for Item in Platform.BuildOptions: if len(Item[1].split('_')) < 5: continue - ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item[1].split('_') + ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item[1].split( + '_') if ItemTarget =3D=3D DataType.TAB_STAR: ItemTarget =3D KeyStringBuildTarget if ItemToolChain =3D=3D DataType.TAB_STAR: @@ -992,7 +1053,8 @@ def FindExtendTool(KeyStringList, CurrentArchList, Nam= eGuid): for Item in Platform.BuildOptions: if len(Item[1].split('_')) < 5: continue - ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item[1].split('_') + ItemTarget, ItemToolChain, ItemArch, ItemTool, ItemAttr = =3D Item[1].split( + '_') if ItemTarget =3D=3D DataType.TAB_STAR: ItemTarget =3D KeyStringBuildTarget if ItemToolChain =3D=3D DataType.TAB_STAR: @@ -1023,5 +1085,6 @@ def FindExtendTool(KeyStringList, CurrentArchList, Na= meGuid): ToolPathTmp =3D Platform.BuildOptions[MatchPathItem] if MatchOptionsItem: ToolOption =3D Platform.BuildOptions[MatchOptionsItem] - GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, To= olOption) + GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D ( + ToolPathTmp, ToolOption) return ToolPathTmp, ToolOption diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Sour= ce/Python/GenFds/GuidSection.py index 8db6e2feb3e4..5efd7c645091 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process GUIDed section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -25,19 +25,21 @@ from .FvImageSection import FvImageSection from Common.LongFilePathSupport import OpenLongFilePath as open from Common.DataType import * =20 -## generate GUIDed section +# generate GUIDed section # # -class GuidSection(GuidSectionClassObject) : =20 - ## The constructor + +class GuidSection(GuidSectionClassObject): + + # The constructor # # @param self The object pointer # def __init__(self): GuidSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate GUIDed section # @@ -75,10 +77,10 @@ class GuidSection(GuidSectionClassObject) : =20 if self.ProcessRequired in ("TRUE", "1"): if self.FvAddr !=3D []: - #no use FvAddr when the image is processed. + # no use FvAddr when the image is processed. self.FvAddr =3D [] if self.FvParentAddr is not None: - #no use Parent Addr when the image is processed. + # no use Parent Addr when the image is processed. self.FvParentAddr =3D None =20 for Sect in self.SectionList: @@ -92,7 +94,8 @@ class GuidSection(GuidSectionClassObject) : elif isinstance(Sect, GuidSection): Sect.FvAddr =3D self.FvAddr Sect.FvParentAddr =3D self.FvParentAddr - ReturnSectList, align =3D Sect.GenSection(OutputPath, ModuleNa= me, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) + ReturnSectList, align =3D Sect.GenSection( + OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, D= ict, IsMakefile=3DIsMakefile) if isinstance(Sect, GuidSection): if Sect.IncludeFvSection: self.IncludeFvSection =3D Sect.IncludeFvSection @@ -100,7 +103,7 @@ class GuidSection(GuidSectionClassObject) : if align is not None: if MaxAlign is None: MaxAlign =3D align - if GenFdsGlobalVariable.GetAlignment (align) > GenFdsGloba= lVariable.GetAlignment (MaxAlign): + if GenFdsGlobalVariable.GetAlignment(align) > GenFdsGlobal= Variable.GetAlignment(MaxAlign): MaxAlign =3D align if ReturnSectList !=3D []: if align is None: @@ -113,50 +116,55 @@ class GuidSection(GuidSectionClassObject) : if self.Alignment is None: self.Alignment =3D MaxAlign else: - if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGl= obalVariable.GetAlignment (self.Alignment): + if GenFdsGlobalVariable.GetAlignment(MaxAlign) > GenFdsGlo= balVariable.GetAlignment(self.Alignment): self.Alignment =3D MaxAlign =20 OutputFile =3D OutputPath + \ - os.sep + \ - ModuleName + \ - SUP_MODULE_SEC + \ - SecNum + \ - SectionSuffix['GUIDED'] + os.sep + \ + ModuleName + \ + SUP_MODULE_SEC + \ + SecNum + \ + SectionSuffix['GUIDED'] OutputFile =3D os.path.normpath(OutputFile) =20 ExternalTool =3D None ExternalOption =3D None if self.NameGuid is not None: - ExternalTool, ExternalOption =3D FindExtendTool(self.KeyString= List, self.CurrentArchList, self.NameGuid) + ExternalTool, ExternalOption =3D FindExtendTool( + self.KeyStringList, self.CurrentArchList, self.NameGuid) =20 # # If not have GUID , call default # GENCRC32 section # - if self.NameGuid is None : - GenFdsGlobalVariable.VerboseLogger("Use GenSection function Ge= nerate CRC32 Section") - GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Sec= tion.Section.SectionType[self.SectionType], InputAlign=3DSectAlign, IsMakef= ile=3DIsMakefile) + if self.NameGuid is None: + GenFdsGlobalVariable.VerboseLogger( + "Use GenSection function Generate CRC32 Section") + GenFdsGlobalVariable.GenerateSection( + OutputFile, SectFile, Section.Section.SectionType[self.Sec= tionType], InputAlign=3DSectAlign, IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment - #or GUID not in External Tool List + # or GUID not in External Tool List elif ExternalTool is None: - EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GU= ID %s" % self.NameGuid) + EdkLogger.error("GenFds", GENFDS_ERROR, + "No tool found with GUID %s" % self.NameGuid) else: DummyFile =3D OutputFile + ".dummy" # # Call GenSection with DUMMY section type. # - GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, Inpu= tAlign=3DSectAlign, IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection( + DummyFile, SectFile, InputAlign=3DSectAlign, IsMakefile=3D= IsMakefile) # # Use external tool process the Output # TempFile =3D OutputPath + \ - os.sep + \ - ModuleName + \ - SUP_MODULE_SEC + \ - SecNum + \ - '.tmp' + os.sep + \ + ModuleName + \ + SUP_MODULE_SEC + \ + SecNum + \ + '.tmp' TempFile =3D os.path.normpath(TempFile) # # Remove temp file if its time stamp is older than dummy file @@ -172,15 +180,16 @@ class GuidSection(GuidSectionClassObject) : CmdOption =3D CmdOption + ' ' + ExternalOption if not GenFdsGlobalVariable.EnableGenfdsMultiThread: if self.ProcessRequired not in ("TRUE", "1") and self.Incl= udeFvSection and not FvAddrIsSet and self.FvParentAddr is not None: - #FirstCall is only set for the encapsulated flash FV i= mage without process required attribute. + # FirstCall is only set for the encapsulated flash FV = image without process required attribute. FirstCall =3D True # # Call external tool # ReturnValue =3D [1] if FirstCall: - #first try to call the guided tool with -z option and = CmdOption for the no process required guided tool. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, '-z' + ' ' + CmdOption, ReturnValue) + # first try to call the guided tool with -z option and= CmdOption for the no process required guided tool. + GenFdsGlobalVariable.GuidTool( + TempFile, [DummyFile], ExternalTool, '-z' + ' ' + = CmdOption, ReturnValue) =20 # # when no call or first call failed, ReturnValue are not 1. @@ -189,14 +198,16 @@ class GuidSection(GuidSectionClassObject) : if ReturnValue[0] !=3D 0: FirstCall =3D False ReturnValue[0] =3D 0 - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, CmdOption) + GenFdsGlobalVariable.GuidTool( + TempFile, [DummyFile], ExternalTool, CmdOption) # # There is external tool which does not follow standard ru= le which return nonzero if tool fails # The output file has to be checked # =20 - if not os.path.exists(TempFile) : - EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to ca= ll %s, no output file was generated' % ExternalTool) + if not os.path.exists(TempFile): + EdkLogger.error( + "GenFds", COMMAND_FAILURE, 'Fail to call %s, no ou= tput file was generated' % ExternalTool) =20 FileHandleIn =3D open(DummyFile, 'rb') FileHandleIn.seek(0, 2) @@ -219,7 +230,7 @@ class GuidSection(GuidSectionClassObject) : BufferOut =3D FileHandleOut.read() if BufferIn =3D=3D BufferOut[TempFileSize - InputF= ileSize:]: HeaderLength =3D str(TempFileSize - InputFileS= ize) - #auto sec guided attribute with process required + # auto sec guided attribute with process required if HeaderLength is None: Attribute.append('PROCESSING_REQUIRED') =20 @@ -228,7 +239,8 @@ class GuidSection(GuidSectionClassObject) : =20 if FirstCall and 'PROCESSING_REQUIRED' in Attribute: # Guided data by -z option on first call is the proces= s required data. Call the guided tool with the real option. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, CmdOption) + GenFdsGlobalVariable.GuidTool( + TempFile, [DummyFile], ExternalTool, CmdOption) =20 # # Call Gensection Add Section Header @@ -243,8 +255,9 @@ class GuidSection(GuidSectionClassObject) : Guid=3Dself.NameGuid,= GuidAttr=3DAttribute, GuidHdrLen=3DHeaderLength) =20 else: - #add input file for GenSec get PROCESSING_REQUIRED - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption, IsMakefile=3DIsMakefile) + # add input file for GenSec get PROCESSING_REQUIRED + GenFdsGlobalVariable.GuidTool( + TempFile, [DummyFile], ExternalTool, CmdOption, IsMake= file=3DIsMakefile) Attribute =3D [] HeaderLength =3D None if self.ExtraHeaderSize !=3D -1: @@ -273,6 +286,3 @@ class GuidSection(GuidSectionClassObject) : if IsMakefile and self.Alignment is not None and self.Alignmen= t.strip() =3D=3D '0': self.Alignment =3D '1' return OutputFileList, self.Alignment - - - diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTo= ols/Source/Python/GenFds/OptRomFileStatement.py index 1bd4d4572a17..0caa55210af1 100644 --- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py @@ -1,4 +1,4 @@ -## @file +# @file # process OptionROM generation from FILE statement # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -16,8 +16,10 @@ from .GenFdsGlobalVariable import GenFdsGlobalVariable ## # # + + class OptRomFileStatement: - ## The constructor + # The constructor # # @param self The object pointer # @@ -26,7 +28,7 @@ class OptRomFileStatement: self.FileType =3D None self.OverrideAttribs =3D None =20 - ## GenFfs() method + # GenFfs() method # # Generate FFS # @@ -34,15 +36,13 @@ class OptRomFileStatement: # @param Dict dictionary contains macro and value pair # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D None, IsMakefile=3DFalse): + def GenFfs(self, Dict=3DNone, IsMakefile=3DFalse): =20 if Dict is None: Dict =3D {} =20 if self.FileName is not None: - self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.FileName) + self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + self.FileName) =20 return self.FileName - - - diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseToo= ls/Source/Python/GenFds/OptRomInfStatement.py index 8b570ed6bcbc..e4b3328d718b 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -1,4 +1,4 @@ -## @file +# @file # process OptionROM generation from INF statement # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -23,8 +23,10 @@ from .GenFdsGlobalVariable import GenFdsGlobalVariable ## # # + + class OptRomInfStatement (FfsInfStatement): - ## The constructor + # The constructor # # @param self The object pointer # @@ -32,7 +34,7 @@ class OptRomInfStatement (FfsInfStatement): FfsInfStatement.__init__(self) self.OverrideAttribs =3D None =20 - ## __GetOptRomParams() method + # __GetOptRomParams() method # # Parse inf file to get option ROM related parameters # @@ -43,31 +45,37 @@ class OptRomInfStatement (FfsInfStatement): self.OverrideAttribs =3D OverrideAttribs() =20 if self.OverrideAttribs.NeedCompress is None: - self.OverrideAttribs.NeedCompress =3D self.OptRomDefs.get ('PC= I_COMPRESS') + self.OverrideAttribs.NeedCompress =3D self.OptRomDefs.get( + 'PCI_COMPRESS') if self.OverrideAttribs.NeedCompress is not None: if self.OverrideAttribs.NeedCompress.upper() not in ('TRUE= ', 'FALSE'): - GenFdsGlobalVariable.ErrorLogger( "Expected TRUE/FALSE= for PCI_COMPRESS: %s" %self.InfFileName) + GenFdsGlobalVariable.ErrorLogger( + "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.= InfFileName) self.OverrideAttribs.NeedCompress =3D \ self.OverrideAttribs.NeedCompress.upper() =3D=3D 'TRUE' =20 if self.OverrideAttribs.PciVendorId is None: - self.OverrideAttribs.PciVendorId =3D self.OptRomDefs.get ('PCI= _VENDOR_ID') + self.OverrideAttribs.PciVendorId =3D self.OptRomDefs.get( + 'PCI_VENDOR_ID') =20 if self.OverrideAttribs.PciClassCode is None: - self.OverrideAttribs.PciClassCode =3D self.OptRomDefs.get ('PC= I_CLASS_CODE') + self.OverrideAttribs.PciClassCode =3D self.OptRomDefs.get( + 'PCI_CLASS_CODE') =20 if self.OverrideAttribs.PciDeviceId is None: - self.OverrideAttribs.PciDeviceId =3D self.OptRomDefs.get ('PCI= _DEVICE_ID') + self.OverrideAttribs.PciDeviceId =3D self.OptRomDefs.get( + 'PCI_DEVICE_ID') =20 if self.OverrideAttribs.PciRevision is None: - self.OverrideAttribs.PciRevision =3D self.OptRomDefs.get ('PCI= _REVISION') + self.OverrideAttribs.PciRevision =3D self.OptRomDefs.get( + 'PCI_REVISION') =20 # InfObj =3D GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathCl= assObj, self.CurrentArch] # RecordList =3D InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Ar= ch, InfObj._Platform] # for Record in RecordList: # Record =3D ReplaceMacros(Record, GlobalData.gEdkGlobal, False) # Name =3D Record[0] - ## GenFfs() method + # GenFfs() method # # Generate FFS # @@ -85,21 +93,24 @@ class OptRomInfStatement (FfsInfStatement): # Get the rule of how to generate Ffs file # Rule =3D self.__GetRule__() - GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf fil= e : %s" %self.InfFileName) + GenFdsGlobalVariable.VerboseLogger( + "Packing binaries from inf file : %s" % self.InfFileName) # # For the rule only has simpleFile # - if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) : - EfiOutputList =3D self.__GenSimpleFileSection__(Rule, IsMakefi= le=3DIsMakefile) + if isinstance(Rule, RuleSimpleFile.RuleSimpleFile): + EfiOutputList =3D self.__GenSimpleFileSection__( + Rule, IsMakefile=3DIsMakefile) return EfiOutputList # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - EfiOutputList =3D self.__GenComplexFileSection__(Rule, IsMakef= ile=3DIsMakefile) + EfiOutputList =3D self.__GenComplexFileSection__( + Rule, IsMakefile=3DIsMakefile) return EfiOutputList =20 - ## __GenSimpleFileSection__() method + # __GenSimpleFileSection__() method # # Get .efi files according to simple rule. # @@ -107,7 +118,7 @@ class OptRomInfStatement (FfsInfStatement): # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): + def __GenSimpleFileSection__(self, Rule, IsMakefile=3DFalse): # # Prepare the parameter of GenSection # @@ -117,12 +128,12 @@ class OptRomInfStatement (FfsInfStatement): GenSecInputFile =3D self.__ExtendMacro__(Rule.FileName) OutputFileList.append(GenSecInputFile) else: - OutputFileList, IsSect =3D Section.Section.GetFileList(self, '= ', Rule.FileExtension) + OutputFileList, IsSect =3D Section.Section.GetFileList( + self, '', Rule.FileExtension) =20 return OutputFileList =20 - - ## __GenComplexFileSection__() method + # __GenComplexFileSection__() method # # Get .efi by sections in complex Rule # @@ -130,6 +141,7 @@ class OptRomInfStatement (FfsInfStatement): # @param Rule The rule object used to generate section # @retval string File name of the generated section file # + def __GenComplexFileSection__(self, Rule, IsMakefile=3DFalse): =20 OutputFileList =3D [] @@ -139,14 +151,16 @@ class OptRomInfStatement (FfsInfStatement): GenSecInputFile =3D self.__ExtendMacro__(Sect.FileName) OutputFileList.append(GenSecInputFile) else: - FileList, IsSect =3D Section.Section.GetFileList(self,= '', Sect.FileExtension) + FileList, IsSect =3D Section.Section.GetFileList( + self, '', Sect.FileExtension) OutputFileList.extend(FileList) =20 return OutputFileList =20 + class OverrideAttribs: =20 - ## The constructor + # The constructor # # @param self The object pointer # diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source= /Python/GenFds/OptionRom.py index 61d669de8d08..f20c08edaf38 100644 --- a/BaseTools/Source/Python/GenFds/OptionRom.py +++ b/BaseTools/Source/Python/GenFds/OptionRom.py @@ -1,4 +1,4 @@ -## @file +# @file # process OptionROM generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -23,16 +23,18 @@ from Common.BuildToolError import * ## # # + + class OPTIONROM (OptionRomClassObject): - ## The constructor + # The constructor # # @param self The object pointer # - def __init__(self, Name =3D ""): + def __init__(self, Name=3D""): OptionRomClassObject.__init__(self) self.DriverName =3D Name =20 - ## AddToBuffer() + # AddToBuffer() # # Generate Option ROM # @@ -40,26 +42,29 @@ class OPTIONROM (OptionRomClassObject): # @param Buffer The buffer generated OptROM data will be put # @retval string Generated OptROM file path # - def AddToBuffer (self, Buffer, Flag=3DFalse) : + def AddToBuffer(self, Buffer, Flag=3DFalse): if not Flag: - GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..= ." %self.DriverName) + GenFdsGlobalVariable.InfLogger( + "\nGenerating %s Option ROM ..." % self.DriverName) =20 EfiFileList =3D [] BinFileList =3D [] =20 # Process Modules in FfsList - for FfsFile in self.FfsList : + for FfsFile in self.FfsList: =20 if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement): FilePathNameList =3D FfsFile.GenFfs(IsMakefile=3DFlag) if len(FilePathNameList) =3D=3D 0: - EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not= produce .efi files, so NO file could be put into option ROM." % (FfsFile.I= nfFileName)) + EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not= produce .efi files, so NO file could be put into option ROM." % ( + FfsFile.InfFileName)) if FfsFile.OverrideAttribs is None: EfiFileList.extend(FilePathNameList) else: FileName =3D os.path.basename(FilePathNameList[0]) - TmpOutputDir =3D os.path.join(GenFdsGlobalVariable.FvD= ir, self.DriverName, FfsFile.CurrentArch) - if not os.path.exists(TmpOutputDir) : + TmpOutputDir =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.DriverName, FfsFi= le.CurrentArch) + if not os.path.exists(TmpOutputDir): os.makedirs(TmpOutputDir) TmpOutputFile =3D os.path.join(TmpOutputDir, FileName+= '.tmp') =20 @@ -71,14 +76,15 @@ class OPTIONROM (OptionRomClassObject): FfsFile.Overrid= eAttribs.PciRevision, FfsFile.Overrid= eAttribs.PciDeviceId, FfsFile.Overrid= eAttribs.PciVendorId, - IsMakefile =3D = Flag) + IsMakefile=3DFl= ag) BinFileList.append(TmpOutputFile) else: FilePathName =3D FfsFile.GenFfs(IsMakefile=3DFlag) if FfsFile.OverrideAttribs is not None: FileName =3D os.path.basename(FilePathName) - TmpOutputDir =3D os.path.join(GenFdsGlobalVariable.FvD= ir, self.DriverName, FfsFile.CurrentArch) - if not os.path.exists(TmpOutputDir) : + TmpOutputDir =3D os.path.join( + GenFdsGlobalVariable.FvDir, self.DriverName, FfsFi= le.CurrentArch) + if not os.path.exists(TmpOutputDir): os.makedirs(TmpOutputDir) TmpOutputFile =3D os.path.join(TmpOutputDir, FileName+= '.tmp') =20 @@ -105,20 +111,22 @@ class OPTIONROM (OptionRomClassObject): OutputFile =3D OutputFile + '.rom' =20 GenFdsGlobalVariable.GenerateOptionRom( - OutputFile, - EfiFileList, - BinFileList, - IsMakefile=3DFlag) + OutputFile, + EfiFileList, + BinFileList, + IsMakefile=3DFlag) =20 if not Flag: - GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Succ= essfully" %self.DriverName) + GenFdsGlobalVariable.InfLogger( + "\nGenerate %s Option ROM Successfully" % self.DriverName) GenFdsGlobalVariable.SharpCounter =3D 0 =20 return OutputFile =20 + class OverrideAttribs: =20 - ## The constructor + # The constructor # # @param self The object pointer # diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/GenFds/Region.py index e95cfcf965d2..67c8879a4f29 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -1,4 +1,4 @@ -## @file +# @file # process FD Region generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -22,12 +22,14 @@ from Common.LongFilePathSupport import OpenLongFilePath= as open from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.DataType import BINARY_FILE_TYPE_FV =20 -## generate Region +# generate Region # # + + class Region(object): =20 - ## The constructor + # The constructor # # @param self The object pointer # @@ -40,7 +42,7 @@ class Region(object): self.RegionType =3D None self.RegionDataList =3D [] =20 - ## PadBuffer() + # PadBuffer() # # Add padding bytes to the Buffer # @@ -52,14 +54,14 @@ class Region(object): =20 def PadBuffer(self, Buffer, ErasePolarity, Size): if Size > 0: - if (ErasePolarity =3D=3D '1') : + if (ErasePolarity =3D=3D '1'): PadByte =3D pack('B', 0xFF) else: PadByte =3D pack('B', 0) for i in range(0, Size): Buffer.write(PadByte) =20 - ## AddToBuffer() + # AddToBuffer() # # Add region data to the Buffer # @@ -78,7 +80,8 @@ class Region(object): if MacroDict is None: MacroDict =3D {} if not Flag: - GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x= %X' % self.Offset) + GenFdsGlobalVariable.InfLogger( + '\nGenerate Region at Offset 0x%X' % self.Offset) GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Siz= e) GenFdsGlobalVariable.SharpCounter =3D 0 if Flag and (self.RegionType !=3D BINARY_FILE_TYPE_FV): @@ -94,13 +97,17 @@ class Region(object): for RegionData in self.RegionDataList: FileName =3D None if RegionData.endswith(".fv"): - RegionData =3D GenFdsGlobalVariable.MacroExtend(Region= Data, MacroDict) + RegionData =3D GenFdsGlobalVariable.MacroExtend( + RegionData, MacroDict) if not Flag: - GenFdsGlobalVariable.InfLogger(' Region FV File = Name =3D .fv : %s' % RegionData) - if RegionData[1] !=3D ':' : - RegionData =3D mws.join (GenFdsGlobalVariable.Work= SpaceDir, RegionData) + GenFdsGlobalVariable.InfLogger( + ' Region FV File Name =3D .fv : %s' % Region= Data) + if RegionData[1] !=3D ':': + RegionData =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, RegionData) if not os.path.exists(RegionData): - EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) + EdkLogger.error("GenFds", FILE_NOT_FOUND, + ExtraData=3DRegionData) =20 FileName =3D RegionData elif RegionData.upper() + 'fv' in ImageBinDict: @@ -113,17 +120,20 @@ class Region(object): # FvObj =3D None if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.FvDict: - FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict[RegionData.upper()] + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict[RegionData.upper( + )] =20 - if FvObj is not None : + if FvObj is not None: if not Flag: - GenFdsGlobalVariable.InfLogger(' Region Name= =3D FV') + GenFdsGlobalVariable.InfLogger( + ' Region Name =3D FV') # # Call GenFv tool # self.BlockInfoOfRegion(BlockSizeList, FvObj) self.FvAddress =3D self.FvAddress + FvOffset - FvAlignValue =3D GenFdsGlobalVariable.GetAlignment= (FvObj.FvAlignment) + FvAlignValue =3D GenFdsGlobalVariable.GetAlignment( + FvObj.FvAlignment) if self.FvAddress % FvAlignValue !=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT %s Aligned!" %= (FvObj.UiFvName, FvObj.FvAlignment)) @@ -131,7 +141,8 @@ class Region(object): FvBaseAddress =3D '0x%X' % self.FvAddress BlockSize =3D None BlockNum =3D None - FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSi= ze, BlockNum, ErasePolarity, Flag=3DFlag) + FvObj.AddToBuffer( + FvBuffer, FvBaseAddress, BlockSize, BlockNum, = ErasePolarity, Flag=3DFlag) if Flag: continue =20 @@ -149,7 +160,8 @@ class Region(object): Size =3D Size - FvBufferLen continue else: - EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) i= s NOT described in FDF file!" % (RegionData)) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "FV (%s) is NOT descri= bed in FDF file!" % (RegionData)) # # Add the exist Fv image into FD buffer # @@ -158,7 +170,7 @@ class Region(object): FileLength =3D os.stat(FileName)[ST_SIZE] if FileLength > Size: EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of FV File (%s) is large= r than Region Size 0x%X specified." \ + "Size of FV File (%s) is large= r than Region Size 0x%X specified." % (RegionData, Size)) BinFile =3D open(FileName, 'rb') Buffer.write(BinFile.read()) @@ -176,12 +188,16 @@ class Region(object): # for RegionData in self.RegionDataList: if RegionData.endswith(".cap"): - RegionData =3D GenFdsGlobalVariable.MacroExtend(Region= Data, MacroDict) - GenFdsGlobalVariable.InfLogger(' Region CAPSULE Imag= e Name =3D .cap : %s' % RegionData) - if RegionData[1] !=3D ':' : - RegionData =3D mws.join (GenFdsGlobalVariable.Work= SpaceDir, RegionData) + RegionData =3D GenFdsGlobalVariable.MacroExtend( + RegionData, MacroDict) + GenFdsGlobalVariable.InfLogger( + ' Region CAPSULE Image Name =3D .cap : %s' % Reg= ionData) + if RegionData[1] !=3D ':': + RegionData =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, RegionData) if not os.path.exists(RegionData): - EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) + EdkLogger.error("GenFds", FILE_NOT_FOUND, + ExtraData=3DRegionData) =20 FileName =3D RegionData elif RegionData.upper() + 'cap' in ImageBinDict: @@ -193,18 +209,21 @@ class Region(object): # CapsuleObj =3D None if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.CapsuleDict: - CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Prof= ile.CapsuleDict[RegionData.upper()] + CapsuleObj =3D GenFdsGlobalVariable.FdfParser.Prof= ile.CapsuleDict[RegionData.upper( + )] =20 - if CapsuleObj is not None : + if CapsuleObj is not None: CapsuleObj.CapsuleName =3D RegionData.upper() - GenFdsGlobalVariable.InfLogger(' Region Name =3D= CAPSULE') + GenFdsGlobalVariable.InfLogger( + ' Region Name =3D CAPSULE') # # Call GenFv tool to generate Capsule Image # FileName =3D CapsuleObj.GenCapsule() CapsuleObj.CapsuleName =3D None else: - EdkLogger.error("GenFds", GENFDS_ERROR, "Capsule (= %s) is NOT described in FDF file!" % (RegionData)) + EdkLogger.error( + "GenFds", GENFDS_ERROR, "Capsule (%s) is NOT d= escribed in FDF file!" % (RegionData)) =20 # # Add the capsule image into FD buffer @@ -212,7 +231,7 @@ class Region(object): FileLength =3D os.stat(FileName)[ST_SIZE] if FileLength > Size: EdkLogger.error("GenFds", GENFDS_ERROR, - "Size 0x%X of Capsule File (%s) is lar= ger than Region Size 0x%X specified." \ + "Size 0x%X of Capsule File (%s) is lar= ger than Region Size 0x%X specified." % (FileLength, RegionData, Size)) BinFile =3D open(FileName, 'rb') Buffer.write(BinFile.read()) @@ -228,24 +247,29 @@ class Region(object): if self.RegionType =3D=3D 'INF': RegionData.__InfParse__(None) if len(RegionData.BinFileList) !=3D 1: - EdkLogger.error('GenFds', GENFDS_ERROR, 'INF in FD= region can only contain one binary: %s' % RegionData) + EdkLogger.error( + 'GenFds', GENFDS_ERROR, 'INF in FD region can = only contain one binary: %s' % RegionData) File =3D RegionData.BinFileList[0] RegionData =3D RegionData.PatchEfiFile(File.Path, File= .Type) else: - RegionData =3D GenFdsGlobalVariable.MacroExtend(Region= Data, MacroDict) - if RegionData[1] !=3D ':' : - RegionData =3D mws.join (GenFdsGlobalVariable.Work= SpaceDir, RegionData) + RegionData =3D GenFdsGlobalVariable.MacroExtend( + RegionData, MacroDict) + if RegionData[1] !=3D ':': + RegionData =3D mws.join( + GenFdsGlobalVariable.WorkSpaceDir, RegionData) if not os.path.exists(RegionData): - EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) + EdkLogger.error("GenFds", FILE_NOT_FOUND, + ExtraData=3DRegionData) # # Add the file image into FD buffer # FileLength =3D os.stat(RegionData)[ST_SIZE] if FileLength > Size: EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of File (%s) is larger than Regi= on Size 0x%X specified." \ + "Size of File (%s) is larger than Regi= on Size 0x%X specified." % (RegionData, Size)) - GenFdsGlobalVariable.InfLogger(' Region File Name =3D %s= ' % RegionData) + GenFdsGlobalVariable.InfLogger( + ' Region File Name =3D %s' % RegionData) BinFile =3D open(RegionData, 'rb') Buffer.write(BinFile.read()) BinFile.close() @@ -255,16 +279,17 @@ class Region(object): # self.PadBuffer(Buffer, ErasePolarity, Size) =20 - if self.RegionType =3D=3D 'DATA' : + if self.RegionType =3D=3D 'DATA': GenFdsGlobalVariable.InfLogger(' Region Name =3D DATA') DataSize =3D 0 for RegionData in self.RegionDataList: Data =3D RegionData.split(',') DataSize =3D DataSize + len(Data) if DataSize > Size: - EdkLogger.error("GenFds", GENFDS_ERROR, "Size of DATA i= s larger than Region Size ") + EdkLogger.error("GenFds", GENFDS_ERROR, + "Size of DATA is larger than Region Si= ze ") else: - for item in Data : + for item in Data: Buffer.write(pack('B', int(item, 16))) Size =3D Size - DataSize # @@ -276,7 +301,7 @@ class Region(object): GenFdsGlobalVariable.InfLogger(' Region Name =3D None') self.PadBuffer(Buffer, ErasePolarity, Size) =20 - ## BlockSizeOfRegion() + # BlockSizeOfRegion() # # @param BlockSizeList List of block information # @param FvObj The object for FV @@ -296,7 +321,8 @@ class Region(object): else: # region ended within current blocks if self.Offset + self.Size <=3D End: - ExpectedList.append((BlockSize, (RemindingSize + Block= Size - 1) // BlockSize)) + ExpectedList.append( + (BlockSize, (RemindingSize + BlockSize - 1) // Blo= ckSize)) break # region not ended yet else: @@ -337,12 +363,9 @@ class Region(object): % FvObj.UiFvName, ExtraData=3DExpected= ListData) elif Item[1] !=3D ExpectedList[Index][1]: if (Item[1] < ExpectedList[Index][1]) and (Index =3D= =3D len(FvObj.BlockSizeList) - 1): - break; + break else: EdkLogger.error("GenFds", GENFDS_ERROR, "BlockStat= ements of FV %s are not align with FD's, suggested FV BlockStatement" % FvObj.UiFvName, ExtraData=3DExpe= ctedListData) else: Index +=3D 1 - - - diff --git a/BaseTools/Source/Python/GenFds/Rule.py b/BaseTools/Source/Pyth= on/GenFds/Rule.py index 6561c0efd80f..79ea99441d90 100644 --- a/BaseTools/Source/Python/GenFds/Rule.py +++ b/BaseTools/Source/Python/GenFds/Rule.py @@ -1,4 +1,4 @@ -## @file +# @file # Rule object for generating FFS # # Copyright (c) 2007, Intel Corporation. All rights reserved.
        @@ -11,11 +11,13 @@ # from CommonDataClass.FdfClass import RuleClassObject =20 -## Rule base class +# Rule base class # # + + class Rule(RuleClassObject): - ## The constructor + # The constructor # # @param self The object pointer # diff --git a/BaseTools/Source/Python/GenFds/RuleComplexFile.py b/BaseTools/= Source/Python/GenFds/RuleComplexFile.py index 198f4f0a9ab3..ed5dd4ee371c 100644 --- a/BaseTools/Source/Python/GenFds/RuleComplexFile.py +++ b/BaseTools/Source/Python/GenFds/RuleComplexFile.py @@ -1,4 +1,4 @@ -## @file +# @file # Complex Rule object for generating FFS # # Copyright (c) 2007, Intel Corporation. All rights reserved.
        @@ -11,13 +11,15 @@ # from __future__ import absolute_import from . import Rule -from CommonDataClass.FdfClass import RuleComplexFileClassObject +from CommonDataClass.FdfClass import RuleComplexFileClassObject =20 -## complex rule +# complex rule # # -class RuleComplexFile(RuleComplexFileClassObject) : - ## The constructor + + +class RuleComplexFile(RuleComplexFileClassObject): + # The constructor # # @param self The object pointer # diff --git a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py b/BaseTools/S= ource/Python/GenFds/RuleSimpleFile.py index 772c768cc982..0b705db8ed1b 100644 --- a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py +++ b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py @@ -1,4 +1,4 @@ -## @file +# @file # Simple Rule object for generating FFS # # Copyright (c) 2007, Intel Corporation. All rights reserved.
        @@ -13,11 +13,13 @@ from __future__ import absolute_import from . import Rule from CommonDataClass.FdfClass import RuleSimpleFileClassObject =20 -## simple rule +# simple rule # # -class RuleSimpleFile (RuleSimpleFileClassObject) : - ## The constructor + + +class RuleSimpleFile (RuleSimpleFileClassObject): + # The constructor # # @param self The object pointer # diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/P= ython/GenFds/Section.py index 447828c8e588..9fa4534f0fde 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,4 +1,4 @@ -## @file +# @file # section base class # # Copyright (c) 2007-2018, Intel Corporation. All rights reserved.
        @@ -12,75 +12,78 @@ from __future__ import absolute_import from CommonDataClass.FdfClass import SectionClassObject from .GenFdsGlobalVariable import GenFdsGlobalVariable -import Common.LongFilePathOs as os, glob +import Common.LongFilePathOs as os +import glob from Common import EdkLogger from Common.BuildToolError import * from Common.DataType import * =20 -## section base class +# section base class # # + + class Section (SectionClassObject): SectionType =3D { - 'RAW' : 'EFI_SECTION_RAW', - 'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', - BINARY_FILE_TYPE_PE32 : 'EFI_SECTION_PE32', - BINARY_FILE_TYPE_PIC : 'EFI_SECTION_PIC', - BINARY_FILE_TYPE_TE : 'EFI_SECTION_TE', - 'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', - BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX', - BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX', - 'GUIDED' : 'EFI_SECTION_GUID_DEFINED', - 'COMPRESS' : 'EFI_SECTION_COMPRESSION', - BINARY_FILE_TYPE_UI : 'EFI_SECTION_USER_INTERFACE', - BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX' + 'RAW': 'EFI_SECTION_RAW', + 'FREEFORM': 'EFI_SECTION_FREEFORM_SUBTYPE_GUID', + BINARY_FILE_TYPE_PE32: 'EFI_SECTION_PE32', + BINARY_FILE_TYPE_PIC: 'EFI_SECTION_PIC', + BINARY_FILE_TYPE_TE: 'EFI_SECTION_TE', + 'FV_IMAGE': 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', + BINARY_FILE_TYPE_DXE_DEPEX: 'EFI_SECTION_DXE_DEPEX', + BINARY_FILE_TYPE_PEI_DEPEX: 'EFI_SECTION_PEI_DEPEX', + 'GUIDED': 'EFI_SECTION_GUID_DEFINED', + 'COMPRESS': 'EFI_SECTION_COMPRESSION', + BINARY_FILE_TYPE_UI: 'EFI_SECTION_USER_INTERFACE', + BINARY_FILE_TYPE_SMM_DEPEX: 'EFI_SECTION_SMM_DEPEX' } =20 BinFileType =3D { - BINARY_FILE_TYPE_GUID : '.guid', - 'ACPI' : '.acpi', - 'ASL' : '.asl' , - BINARY_FILE_TYPE_UEFI_APP : '.app', - BINARY_FILE_TYPE_LIB : '.lib', - BINARY_FILE_TYPE_PE32 : '.pe32', - BINARY_FILE_TYPE_PIC : '.pic', - BINARY_FILE_TYPE_PEI_DEPEX : '.depex', - 'SEC_PEI_DEPEX' : '.depex', - BINARY_FILE_TYPE_TE : '.te', - BINARY_FILE_TYPE_UNI_VER : '.ver', - BINARY_FILE_TYPE_VER : '.ver', - BINARY_FILE_TYPE_UNI_UI : '.ui', - BINARY_FILE_TYPE_UI : '.ui', - BINARY_FILE_TYPE_BIN : '.bin', - 'RAW' : '.raw', - 'COMPAT16' : '.comp16', - BINARY_FILE_TYPE_FV : '.fv' + BINARY_FILE_TYPE_GUID: '.guid', + 'ACPI': '.acpi', + 'ASL': '.asl', + BINARY_FILE_TYPE_UEFI_APP: '.app', + BINARY_FILE_TYPE_LIB: '.lib', + BINARY_FILE_TYPE_PE32: '.pe32', + BINARY_FILE_TYPE_PIC: '.pic', + BINARY_FILE_TYPE_PEI_DEPEX: '.depex', + 'SEC_PEI_DEPEX': '.depex', + BINARY_FILE_TYPE_TE: '.te', + BINARY_FILE_TYPE_UNI_VER: '.ver', + BINARY_FILE_TYPE_VER: '.ver', + BINARY_FILE_TYPE_UNI_UI: '.ui', + BINARY_FILE_TYPE_UI: '.ui', + BINARY_FILE_TYPE_BIN: '.bin', + 'RAW': '.raw', + 'COMPAT16': '.comp16', + BINARY_FILE_TYPE_FV: '.fv' } =20 SectFileType =3D { - 'SEC_GUID' : '.sec' , - 'SEC_PE32' : '.sec' , - 'SEC_PIC' : '.sec', - 'SEC_TE' : '.sec', - 'SEC_VER' : '.sec', - 'SEC_UI' : '.sec', - 'SEC_COMPAT16' : '.sec', - 'SEC_BIN' : '.sec' + 'SEC_GUID': '.sec', + 'SEC_PE32': '.sec', + 'SEC_PIC': '.sec', + 'SEC_TE': '.sec', + 'SEC_VER': '.sec', + 'SEC_UI': '.sec', + 'SEC_COMPAT16': '.sec', + 'SEC_BIN': '.sec' } =20 ToolGuid =3D { - '0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779' : 'TianoCompre= ss', - '0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf' : 'LzmaCompres= s' + '0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779': 'TianoCompres= s', + '0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf': 'LzmaCompress' } =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): SectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # virtual function # @@ -92,10 +95,10 @@ class Section (SectionClassObject): # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # - def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsI= nf =3D None, Dict =3D None): + def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsI= nf=3DNone, Dict=3DNone): pass =20 - ## GetFileList() method + # GetFileList() method # # Generate compressed section # @@ -106,12 +109,12 @@ class Section (SectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (File list, boolean) # - def GetFileList(FfsInf, FileType, FileExtension, Dict =3D None, IsMake= file=3DFalse, SectionType=3DNone): + def GetFileList(FfsInf, FileType, FileExtension, Dict=3DNone, IsMakefi= le=3DFalse, SectionType=3DNone): IsSect =3D FileType in Section.SectFileType =20 if FileExtension is not None: Suffix =3D FileExtension - elif IsSect : + elif IsSect: Suffix =3D Section.SectionType.get(FileType) else: Suffix =3D Section.BinFileType.get(FileType) @@ -122,17 +125,21 @@ class Section (SectionClassObject): if FileType is not None: for File in FfsInf.BinFileList: if File.Arch =3D=3D TAB_ARCH_COMMON or FfsInf.CurrentArch = =3D=3D File.Arch: - if File.Type =3D=3D FileType or (int(FfsInf.PiSpecVers= ion, 16) >=3D 0x0001000A \ + if File.Type =3D=3D FileType or (int(FfsInf.PiSpecVers= ion, 16) >=3D 0x0001000A and FileType =3D=3D 'DXE_= DPEX' and File.Type =3D=3D BINARY_FILE_TYPE_SMM_DEPEX) \ - or (FileType =3D=3D BINAR= Y_FILE_TYPE_TE and File.Type =3D=3D BINARY_FILE_TYPE_PE32): + or (FileType =3D=3D BINARY_FILE_TYPE_TE and Fi= le.Type =3D=3D BINARY_FILE_TYPE_PE32): if TAB_STAR in FfsInf.TargetOverrideList or File.T= arget =3D=3D TAB_STAR or File.Target in FfsInf.TargetOverrideList or FfsInf= .TargetOverrideList =3D=3D []: - FileList.append(FfsInf.PatchEfiFile(File.Path,= File.Type)) + FileList.append( + FfsInf.PatchEfiFile(File.Path, File.Type)) else: - GenFdsGlobalVariable.InfLogger ("\nBuild Targe= t \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %= (File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName)) + GenFdsGlobalVariable.InfLogger("\nBuild Target= \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" % ( + File.Target, File.File, FfsInf.TargetOverr= ideList, FfsInf.InfFileName)) else: - GenFdsGlobalVariable.VerboseLogger ("\nFile Type \= '%s\' of File %s in %s is not same with file type \'%s\' from Rule in FDF" = %(File.Type, File.File, FfsInf.InfFileName, FileType)) + GenFdsGlobalVariable.VerboseLogger("\nFile Type \'= %s\' of File %s in %s is not same with file type \'%s\' from Rule in FDF" %= ( + File.Type, File.File, FfsInf.InfFileName, File= Type)) else: - GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\'= of File %s is not in the Support Arch Scope of %s specified by INF %s in F= DF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName)) + GenFdsGlobalVariable.InfLogger("\nCurrent ARCH \'%s\' = of File %s is not in the Support Arch Scope of %s specified by INF %s in FD= F" % ( + FfsInf.CurrentArch, File.File, File.Arch, FfsInf.I= nfFileName)) =20 elif FileType is None and SectionType =3D=3D BINARY_FILE_TYPE_RAW: for File in FfsInf.BinFileList: @@ -145,8 +152,8 @@ class Section (SectionClassObject): if Suffix in SuffixMap: FileList.extend(SuffixMap[Suffix]) =20 - #Process the file lists is alphabetical for a same section type - if len (FileList) > 1: + # Process the file lists is alphabetical for a same section type + if len(FileList) > 1: FileList.sort() =20 return FileList, IsSect diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source= /Python/GenFds/UiSection.py index f643058bd637..964bf4de9622 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process UI section generation # # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
        @@ -19,19 +19,21 @@ from CommonDataClass.FdfClass import UiSectionClassObje= ct from Common.LongFilePathSupport import OpenLongFilePath as open from Common.DataType import * =20 -## generate UI section +# generate UI section # # + + class UiSection (UiSectionClassObject): =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): UiSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate UI section # @@ -44,7 +46,7 @@ class UiSection (UiSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): # # Prepare the parameter of GenSection # @@ -53,21 +55,24 @@ class UiSection (UiSectionClassObject): self.StringData =3D FfsInf.__ExtendMacro__(self.StringData) self.FileName =3D FfsInf.__ExtendMacro__(self.FileName) =20 - OutputFile =3D os.path.join(OutputPath, ModuleName + SUP_MODULE_SE= C + SecNum + SectionSuffix.get(BINARY_FILE_TYPE_UI)) + OutputFile =3D os.path.join( + OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + SectionSuff= ix.get(BINARY_FILE_TYPE_UI)) =20 - if self.StringData is not None : + if self.StringData is not None: NameString =3D self.StringData elif self.FileName is not None: if Dict is None: Dict =3D {} - FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(sel= f.FileName) + FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + self.FileName) FileNameStr =3D GenFdsGlobalVariable.MacroExtend(FileNameStr, = Dict) FileObj =3D open(FileNameStr, 'r') NameString =3D FileObj.read() FileObj.close() else: NameString =3D '' - GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTIO= N_USER_INTERFACE', Ui=3DNameString, IsMakefile=3DIsMakefile) + GenFdsGlobalVariable.GenerateSection( + OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=3DNameStrin= g, IsMakefile=3DIsMakefile) =20 OutputFileList =3D [] OutputFileList.append(OutputFile) diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Sourc= e/Python/GenFds/VerSection.py index 7280e80cb4ef..7cd2e30d4a2b 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -1,4 +1,4 @@ -## @file +# @file # process Version section generation # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -17,19 +17,21 @@ from CommonDataClass.FdfClass import VerSectionClassObj= ect from Common.LongFilePathSupport import OpenLongFilePath as open from Common.DataType import SUP_MODULE_SEC =20 -## generate version section +# generate version section # # + + class VerSection (VerSectionClassObject): =20 - ## The constructor + # The constructor # # @param self The object pointer # def __init__(self): VerSectionClassObject.__init__(self) =20 - ## GenSection() method + # GenSection() method # # Generate version section # @@ -42,7 +44,7 @@ class VerSection (VerSectionClassObject): # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile =3D False): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3DNone, IsMakefile=3DFalse): # # Prepare the parameter of GenSection # @@ -63,7 +65,8 @@ class VerSection (VerSectionClassObject): elif self.FileName: if Dict is None: Dict =3D {} - FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(sel= f.FileName) + FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro( + self.FileName) FileNameStr =3D GenFdsGlobalVariable.MacroExtend(FileNameStr, = Dict) FileObj =3D open(FileNameStr, 'r') StringData =3D FileObj.read() diff --git a/BaseTools/Source/Python/GenFds/__init__.py b/BaseTools/Source/= Python/GenFds/__init__.py index 09ea47ea5710..083caeeba2d5 100644 --- a/BaseTools/Source/Python/GenFds/__init__.py +++ b/BaseTools/Source/Python/GenFds/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'GenFds' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b= /BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py index d962ab0adda7..e589e7e2db64 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py @@ -1,4 +1,4 @@ -## @file +# @file # Generate PCD table for 'Patchable In Module' type PCD with given .map fi= le. # The Patch PCD table like: # @@ -10,7 +10,7 @@ # # =20 -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D External Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D External Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D from __future__ import print_function import optparse import Common.LongFilePathOs as os @@ -28,10 +28,12 @@ __version_number__ =3D ("0.10" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + __version_number__ __copyright__ =3D "Copyright (c) 2008 - 2018, Intel Corporation. All right= s reserved." =20 -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Internal Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Internal Libraries =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Code =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +symRe =3D re.compile( + '^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+) +([\da-fA-F]+)'= , re.UNICODE) =20 -#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Code =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -symRe =3D re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.\-:\\\\\w\?@\$<>]+= ) +([\da-fA-F]+)', re.UNICODE) =20 def parsePcdInfoFromMapFile(mapfilepath, efifilepath): """ Parse map file to get binary patch pcd information @@ -47,25 +49,28 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath): except: return None =20 - if len(lines) =3D=3D 0: return None + if len(lines) =3D=3D 0: + return None firstline =3D lines[0].strip() if re.match('^\s*Address\s*Size\s*Align\s*Out\s*In\s*Symbol\s*$', firs= tline): return _parseForXcodeAndClang9(lines, efifilepath) if (firstline.startswith("Archive member included ") and - firstline.endswith(" file (symbol)")): + firstline.endswith(" file (symbol)")): return _parseForGCC(lines, efifilepath) if firstline.startswith("# Path:"): return _parseForXcodeAndClang9(lines, efifilepath) return _parseGeneral(lines, efifilepath) =20 + def _parseForXcodeAndClang9(lines, efifilepath): - valuePattern =3D re.compile('^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_Binar= yPatch_([\w]+))') + valuePattern =3D re.compile( + '^([\da-fA-FxX]+)([\s\S]*)([_]*_gPcd_BinaryPatch_([\w]+))') status =3D 0 pcds =3D [] for line in lines: line =3D line.strip() - if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) \ - or line =3D=3D "# Symbols:"): + if status =3D=3D 0 and (re.match('^\s*Address\s*Size\s*Align\s*Out= \s*In\s*Symbol\s*$', line) + or line =3D=3D "# Symbols:"): status =3D 1 continue if status =3D=3D 1 and len(line) !=3D 0: @@ -75,6 +80,7 @@ def _parseForXcodeAndClang9(lines, efifilepath): pcds.append((m.groups(0)[3], int(m.groups(0)[0], 16))) return pcds =20 + def _parseForGCC(lines, efifilepath): """ Parse map file generated by GCC linker """ dataPattern =3D re.compile('^.data._gPcd_BinaryPatch_([\w_\d]+)$') @@ -91,7 +97,7 @@ def _parseForGCC(lines, efifilepath): elif status =3D=3D 1 and line =3D=3D 'Linker script and memory map= ': status =3D 2 continue - elif status =3D=3D2 and line =3D=3D 'START GROUP': + elif status =3D=3D 2 and line =3D=3D 'START GROUP': status =3D 3 continue =20 @@ -107,13 +113,14 @@ def _parseForGCC(lines, efifilepath): PcdName =3D m.groups(0)[0] m =3D pcdPatternGcc.match(lines[index + 1].strip()) if m is not None: - bpcds.append((PcdName, int(m.groups(0)[0], 16), in= t(sections[-1][1], 16), sections[-1][0])) + bpcds.append((PcdName, int(m.groups(0)[0], 16), in= t( + sections[-1][1], 16), sections[-1][0])) =20 # get section information from efi file efisecs =3D PeImageClass(efifilepath).SectionHeaderList if efisecs is None or len(efisecs) =3D=3D 0: return None - #redirection + # redirection redirection =3D 0 for efisec in efisecs: for section in sections: @@ -124,16 +131,18 @@ def _parseForGCC(lines, efifilepath): for efisec in efisecs: if pcd[1] >=3D efisec[1] and pcd[1] < efisec[1]+efisec[3]: #assert efisec[0].strip() =3D=3D pcd[3].strip() and efisec= [1] + redirection =3D=3D pcd[2], "There are some differences between map fi= le and efi file" - pcds.append([pcd[0], efisec[2] + pcd[1] - efisec[1] - redi= rection, efisec[0]]) + pcds.append([pcd[0], efisec[2] + pcd[1] - + efisec[1] - redirection, efisec[0]]) return pcds =20 + def _parseGeneral(lines, efifilepath): """ For MSFT, ICC, EBC @param lines line array for map file =20 @return a list which element hold (PcdName, Offset, SectionName) """ - status =3D 0 #0 - beginning of file; 1 - PE section definition; 2 -= symbol table + status =3D 0 # 0 - beginning of file; 1 - PE section definition; 2 - = symbol table secs =3D [] # key =3D section name bPcds =3D [] symPattern =3D re.compile('^[_]+gPcd_BinaryPatch_([\w]+)') @@ -153,7 +162,8 @@ def _parseGeneral(lines, efifilepath): m =3D secReGeneral.match(line) assert m is not None, "Fail to parse the section in map file ,= line is %s" % line sec_no, sec_start, sec_length, sec_name, sec_class =3D m.group= s(0) - secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_leng= th, 16), sec_name, sec_class]) + secs.append([int(sec_no, 16), int(sec_start, 16), + int(sec_length, 16), sec_name, sec_class]) if status =3D=3D 2 and len(line) !=3D 0: m =3D symRe.match(line) assert m is not None, "Fail to parse the symbol in map file, l= ine is %s" % line @@ -166,9 +176,11 @@ def _parseGeneral(lines, efifilepath): # fond a binary pcd entry in map file for sec in secs: if sec[0] =3D=3D sec_no and (sym_offset >=3D sec[1] an= d sym_offset < sec[1] + sec[2]): - bPcds.append([m2.groups(0)[0], sec[3], sym_offset,= vir_addr, sec_no]) + bPcds.append([m2.groups(0)[0], sec[3], + sym_offset, vir_addr, sec_no]) =20 - if len(bPcds) =3D=3D 0: return None + if len(bPcds) =3D=3D 0: + return None =20 # get section information from efi file efisecs =3D PeImageClass(efifilepath).SectionHeaderList @@ -186,6 +198,7 @@ def _parseGeneral(lines, efifilepath): pcds.append([pcd[0], efisec[2] + pcd[2], efisec[0]]) return pcds =20 + def generatePcdTable(list, pcdpath): try: f =3D open(pcdpath, 'w') @@ -195,15 +208,18 @@ def generatePcdTable(list, pcdpath): f.write('PCD Name Offset Section Name\r\n') =20 for pcditem in list: - f.write('%-30s 0x%-08X %-6s\r\n' % (pcditem[0], pcditem[1], pcdite= m[2])) + f.write('%-30s 0x%-08X %-6s\r\n' % + (pcditem[0], pcditem[1], pcditem[2])) f.close() =20 - #print 'Success to generate Binary Patch PCD table at %s!' % pcdpath + # print 'Success to generate Binary Patch PCD table at %s!' % pcdpath + =20 if __name__ =3D=3D '__main__': UsageString =3D "%prog -m -e -o " AdditionalNotes =3D "\nPCD table is generated in file name with .Binar= yPcdTable.txt postfix" - parser =3D optparse.OptionParser(description=3D__copyright__, version= =3D__version__, usage=3DUsageString) + parser =3D optparse.OptionParser( + description=3D__copyright__, version=3D__version__, usage=3DUsageS= tring) parser.add_option('-m', '--mapfile', action=3D'store', dest=3D'mapfile= ', help=3D'Absolute path of module map file.') parser.add_option('-e', '--efifile', action=3D'store', dest=3D'efifile= ', @@ -221,7 +237,8 @@ if __name__ =3D=3D '__main__': if options.outfile is not None: generatePcdTable(list, options.outfile) else: - generatePcdTable(list, options.mapfile.replace('.map', '.B= inaryPcdTable.txt')) + generatePcdTable(list, options.mapfile.replace( + '.map', '.BinaryPcdTable.txt')) else: print('Fail to generate Patch PCD Table based on map file and = efi file') else: diff --git a/BaseTools/Source/Python/GenPatchPcdTable/__init__.py b/BaseToo= ls/Source/Python/GenPatchPcdTable/__init__.py index 70b46a525de7..6105f5ed5a9f 100644 --- a/BaseTools/Source/Python/GenPatchPcdTable/__init__.py +++ b/BaseTools/Source/Python/GenPatchPcdTable/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'GenPatchPcdTable' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseT= ools/Source/Python/PatchPcdValue/PatchPcdValue.py index d35cd792704c..8ede157c7e5b 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -1,4 +1,4 @@ -## @file +# @file # Patch value into the binary file. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
        @@ -25,7 +25,7 @@ __version_number__ =3D ("0.10" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + __version_number__ __copyright__ =3D "Copyright (c) 2010 - 2018, Intel Corporation. All right= s reserved." =20 -## PatchBinaryFile method +# PatchBinaryFile method # # This method mainly patches the data into binary file. # @@ -38,12 +38,14 @@ __copyright__ =3D "Copyright (c) 2010 - 2018, Intel Cor= poration. All rights reserv # @retval 0 File is updated successfully. # @retval not 0 File is updated failed. # + + def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize= =3D0): # # Length of Binary File # FileHandle =3D open(FileName, 'rb') - FileHandle.seek (0, 2) + FileHandle.seek(0, 2) FileLength =3D FileHandle.tell() FileHandle.close() # @@ -104,7 +106,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, Va= lueString, MaxSize=3D0): ValueNumber =3D 1 elif ValueString =3D=3D 'FALSE': ValueNumber =3D 0 - ValueNumber =3D int (ValueString, 0) + ValueNumber =3D int(ValueString, 0) if ValueNumber !=3D 0: ValueNumber =3D 1 except: @@ -118,7 +120,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, Va= lueString, MaxSize=3D0): # Get PCD value for UINT* data type # try: - ValueNumber =3D int (ValueString, 0) + ValueNumber =3D int(ValueString, 0) except: return PARAMETER_INVALID, "PCD Value %s is not valid dec or he= x string." % (ValueString) # @@ -149,7 +151,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, Va= lueString, MaxSize=3D0): # # Patch {0x1, 0x2, ...} byte by byte # - ValueList =3D ValueString[1 : len(ValueString) - 1].split(',') + ValueList =3D ValueString[1: len(ValueString) - 1].split(',') Index =3D 0 try: for ByteString in ValueList: @@ -191,13 +193,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, = ValueString, MaxSize=3D0): FileHandle.close() return 0, "Patch Value into File %s successfully." % (FileName) =20 -## Parse command line options +# Parse command line options # # Using standard Python module optparse to parse command line option of th= is tool. # # @retval Options A optparse.Values object containing the parsed options # @retval InputFile Path of file to be trimmed # + + def Options(): OptionList =3D [ make_option("-f", "--offset", dest=3D"PcdOffset", action=3D"store"= , type=3D"int", @@ -214,25 +218,28 @@ def Options(): help=3D"Run with debug information"), make_option("-q", "--quiet", dest=3D"LogLevel", action=3D"store_co= nst", const=3DEdkLogger.QUIET, help=3D"Run quietly"), - make_option("-?", action=3D"help", help=3D"show this help message = and exit"), + make_option("-?", action=3D"help", + help=3D"show this help message and exit"), ] =20 # use clearer usage to override default usage message UsageString =3D "%prog -f Offset -u Value -t Type [-s MaxSize] " =20 - Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, option_list=3DOptionList, usage=3DUsageString) + Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, + option_list=3DOptionList, usage=3DUsageString) Parser.set_defaults(LogLevel=3DEdkLogger.INFO) =20 Options, Args =3D Parser.parse_args() =20 # error check if len(Args) =3D=3D 0: - EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData=3DPa= rser.get_usage()) + EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, + ExtraData=3DParser.get_usage()) =20 InputFile =3D Args[len(Args) - 1] return Options, InputFile =20 -## Entrance method +# Entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -241,6 +248,8 @@ def Options(): # @retval 0 Tool was successful # @retval 1 Tool failed # + + def Main(): try: # @@ -252,22 +261,27 @@ def Main(): EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) - if not os.path.exists (InputFile): - EdkLogger.error("PatchPcdValue", FILE_NOT_FOUND, ExtraData=3DI= nputFile) + if not os.path.exists(InputFile): + EdkLogger.error("PatchPcdValue", FILE_NOT_FOUND, + ExtraData=3DInputFile) return 1 if CommandOptions.PcdOffset is None or CommandOptions.PcdValue is = None or CommandOptions.PcdTypeName is None: - EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData=3D"= PcdOffset or PcdValue of PcdTypeName is not specified.") + EdkLogger.error("PatchPcdValue", OPTION_MISSING, + ExtraData=3D"PcdOffset or PcdValue of PcdTypeN= ame is not specified.") return 1 if CommandOptions.PcdTypeName.upper() not in TAB_PCD_NUMERIC_TYPES= _VOID: - EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData= =3D"PCD type %s is not valid." % (CommandOptions.PcdTypeName)) + EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, + ExtraData=3D"PCD type %s is not valid." % (Com= mandOptions.PcdTypeName)) return 1 if CommandOptions.PcdTypeName.upper() =3D=3D TAB_VOID and CommandO= ptions.PcdMaxSize is None: - EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData=3D"= PcdMaxSize is not specified for VOID* type PCD.") + EdkLogger.error("PatchPcdValue", OPTION_MISSING, + ExtraData=3D"PcdMaxSize is not specified for V= OID* type PCD.") return 1 # # Patch value into binary image. # - ReturnValue, ErrorInfo =3D PatchBinaryFile (InputFile, CommandOpti= ons.PcdOffset, CommandOptions.PcdTypeName, CommandOptions.PcdValue, Command= Options.PcdMaxSize) + ReturnValue, ErrorInfo =3D PatchBinaryFile( + InputFile, CommandOptions.PcdOffset, CommandOptions.PcdTypeNam= e, CommandOptions.PcdValue, CommandOptions.PcdMaxSize) if ReturnValue !=3D 0: EdkLogger.error("PatchPcdValue", ReturnValue, ExtraData=3DErro= rInfo) return 1 @@ -275,6 +289,7 @@ def Main(): except: return 1 =20 + if __name__ =3D=3D '__main__': r =3D Main() sys.exit(r) diff --git a/BaseTools/Source/Python/PatchPcdValue/__init__.py b/BaseTools/= Source/Python/PatchPcdValue/__init__.py index 08275ed6ed00..eda5835ac31e 100644 --- a/BaseTools/Source/Python/PatchPcdValue/__init__.py +++ b/BaseTools/Source/Python/PatchPcdValue/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'PatchPcdValue' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Sou= rce/Python/Pkcs7Sign/Pkcs7Sign.py index 5d4c3a8599ff..d13091c042ba 100644 --- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py +++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py @@ -1,4 +1,4 @@ -## @file +# @file # This tool adds EFI_FIRMWARE_IMAGE_AUTHENTICATION for a binary. # # This tool only support CertType - EFI_CERT_TYPE_PKCS7_GUID @@ -27,15 +27,15 @@ from Common.BuildVersion import gBUILD_VERSION # # Globals for help information # -__prog__ =3D 'Pkcs7Sign' -__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) +__prog__ =3D 'Pkcs7Sign' +__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) __copyright__ =3D 'Copyright (c) 2016, Intel Corporation. All rights reser= ved.' -__usage__ =3D '%s -e|-d [options] ' % (__prog__) +__usage__ =3D '%s -e|-d [options] ' % (__prog__) =20 # # GUID for PKCS7 from UEFI Specification # -WIN_CERT_REVISION =3D 0x0200 +WIN_CERT_REVISION =3D 0x0200 WIN_CERT_TYPE_EFI_GUID =3D 0x0EF1 EFI_CERT_TYPE_PKCS7_GUID =3D uuid.UUID('{4aafd29d-68df-49ee-8aa9-347d37566= 5a7}') =20 @@ -67,214 +67,246 @@ TEST_OTHER_PUBLIC_CERT_FILENAME =3D 'TestSub.pub.pem' TEST_TRUSTED_PUBLIC_CERT_FILENAME =3D 'TestRoot.pub.pem' =20 if __name__ =3D=3D '__main__': - # - # Create command line argument parser object - # - parser =3D argparse.ArgumentParser(prog=3D__prog__, usage=3D__usage__, d= escription=3D__copyright__, conflict_handler=3D'resolve') - group =3D parser.add_mutually_exclusive_group(required=3DTrue) - group.add_argument("-e", action=3D"store_true", dest=3D'Encode', help=3D= 'encode file') - group.add_argument("-d", action=3D"store_true", dest=3D'Decode', help=3D= 'decode file') - group.add_argument("--version", action=3D'version', version=3D__version_= _) - parser.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dstr, m= etavar=3D'filename', help=3D"specify the output filename", required=3DTrue) - parser.add_argument("--signer-private-cert", dest=3D'SignerPrivateCertFi= le', type=3Dargparse.FileType('rb'), help=3D"specify the signer private cer= t filename. If not specified, a test signer private cert is used.") - parser.add_argument("--other-public-cert", dest=3D'OtherPublicCertFile',= type=3Dargparse.FileType('rb'), help=3D"specify the other public cert file= name. If not specified, a test other public cert is used.") - parser.add_argument("--trusted-public-cert", dest=3D'TrustedPublicCertFi= le', type=3Dargparse.FileType('rb'), help=3D"specify the trusted public cer= t filename. If not specified, a test trusted public cert is used.") - parser.add_argument("--monotonic-count", dest=3D'MonotonicCountStr', typ= e=3Dstr, help=3D"specify the MonotonicCount in FMP capsule. If not specifi= ed, 0 is used.") - parser.add_argument("--signature-size", dest=3D'SignatureSizeStr', type= =3Dstr, help=3D"specify the signature size for decode process.") - parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") - parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0, 10), default=3D0, help=3D"set debug level") - parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type=3Da= rgparse.FileType('rb'), help=3D"specify the input filename") - - # - # Parse command line arguments - # - args =3D parser.parse_args() - - # - # Generate file path to Open SSL command - # - OpenSslCommand =3D 'openssl' - try: - OpenSslPath =3D os.environ['OPENSSL_PATH'] - OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) - if ' ' in OpenSslCommand: - OpenSslCommand =3D '"' + OpenSslCommand + '"' - except: - pass - - # - # Verify that Open SSL command is available - # - try: - Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - except: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(1) - - Version =3D Process.communicate() - if Process.returncode !=3D 0: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(Process.returncode) - print(Version[0].decode()) - - # - # Read input file into a buffer and save input filename - # - args.InputFileName =3D args.InputFile.name - args.InputFileBuffer =3D args.InputFile.read() - args.InputFile.close() - - # - # Save output filename and check if path exists - # - OutputDir =3D os.path.dirname(args.OutputFile) - if not os.path.exists(OutputDir): - print('ERROR: The output path does not exist: %s' % OutputDir) - sys.exit(1) - args.OutputFileName =3D args.OutputFile - - try: - if args.MonotonicCountStr.upper().startswith('0X'): - args.MonotonicCountValue =3D int(args.MonotonicCountStr, 16) - else: - args.MonotonicCountValue =3D int(args.MonotonicCountStr) - except: - args.MonotonicCountValue =3D int(0) - - if args.Encode: # - # Save signer private cert filename and close private cert file + # Create command line argument parser object # + parser =3D argparse.ArgumentParser( + prog=3D__prog__, usage=3D__usage__, description=3D__copyright__, c= onflict_handler=3D'resolve') + group =3D parser.add_mutually_exclusive_group(required=3DTrue) + group.add_argument("-e", action=3D"store_true", + dest=3D'Encode', help=3D'encode file') + group.add_argument("-d", action=3D"store_true", + dest=3D'Decode', help=3D'decode file') + group.add_argument("--version", action=3D'version', version=3D__versio= n__) + parser.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dstr, + metavar=3D'filename', help=3D"specify the output f= ilename", required=3DTrue) + parser.add_argument("--signer-private-cert", dest=3D'SignerPrivateCert= File', type=3Dargparse.FileType('rb'), + help=3D"specify the signer private cert filename. = If not specified, a test signer private cert is used.") + parser.add_argument("--other-public-cert", dest=3D'OtherPublicCertFile= ', type=3Dargparse.FileType('rb'), + help=3D"specify the other public cert filename. I= f not specified, a test other public cert is used.") + parser.add_argument("--trusted-public-cert", dest=3D'TrustedPublicCert= File', type=3Dargparse.FileType('rb'), + help=3D"specify the trusted public cert filename. = If not specified, a test trusted public cert is used.") + parser.add_argument("--monotonic-count", dest=3D'MonotonicCountStr', t= ype=3Dstr, + help=3D"specify the MonotonicCount in FMP capsule.= If not specified, 0 is used.") + parser.add_argument("--signature-size", dest=3D'SignatureSizeStr', + type=3Dstr, help=3D"specify the signature size for= decode process.") + parser.add_argument("-v", "--verbose", dest=3D'Verbose', + action=3D"store_true", help=3D"increase output mes= sages") + parser.add_argument("-q", "--quiet", dest=3D'Quiet', + action=3D"store_true", help=3D"reduce output messa= ges") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint, + metavar=3D'[0-9]', choices=3Drange(0, 10), default= =3D0, help=3D"set debug level") + parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type= =3Dargparse.FileType( + 'rb'), help=3D"specify the input filename") + + # + # Parse command line arguments + # + args =3D parser.parse_args() + + # + # Generate file path to Open SSL command + # + OpenSslCommand =3D 'openssl' try: - args.SignerPrivateCertFileName =3D args.SignerPrivateCertFile.name - args.SignerPrivateCertFile.close() + OpenSslPath =3D os.environ['OPENSSL_PATH'] + OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) + if ' ' in OpenSslCommand: + OpenSslCommand =3D '"' + OpenSslCommand + '"' except: - try: - # - # Get path to currently executing script or executable - # - if hasattr(sys, 'frozen'): - Pkcs7ToolPath =3D sys.executable - else: - Pkcs7ToolPath =3D sys.argv[0] - if Pkcs7ToolPath.startswith('"'): - Pkcs7ToolPath =3D Pkcs7ToolPath[1:] - if Pkcs7ToolPath.endswith('"'): - Pkcs7ToolPath =3D RsaToolPath[:-1] - args.SignerPrivateCertFileName =3D os.path.join(os.path.dirname(os= .path.realpath(Pkcs7ToolPath)), TEST_SIGNER_PRIVATE_CERT_FILENAME) - args.SignerPrivateCertFile =3D open(args.SignerPrivateCertFileName= , 'rb') - args.SignerPrivateCertFile.close() - except: - print('ERROR: test signer private cert file %s missing' % (args.Si= gnerPrivateCertFileName)) - sys.exit(1) + pass =20 # - # Save other public cert filename and close public cert file + # Verify that Open SSL command is available # try: - args.OtherPublicCertFileName =3D args.OtherPublicCertFile.name - args.OtherPublicCertFile.close() + Process =3D subprocess.Popen('%s version' % ( + OpenSslCommand), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess= .PIPE, shell=3DTrue) except: - try: - # - # Get path to currently executing script or executable - # - if hasattr(sys, 'frozen'): - Pkcs7ToolPath =3D sys.executable - else: - Pkcs7ToolPath =3D sys.argv[0] - if Pkcs7ToolPath.startswith('"'): - Pkcs7ToolPath =3D Pkcs7ToolPath[1:] - if Pkcs7ToolPath.endswith('"'): - Pkcs7ToolPath =3D RsaToolPath[:-1] - args.OtherPublicCertFileName =3D os.path.join(os.path.dirname(os.p= ath.realpath(Pkcs7ToolPath)), TEST_OTHER_PUBLIC_CERT_FILENAME) - args.OtherPublicCertFile =3D open(args.OtherPublicCertFileName, 'r= b') - args.OtherPublicCertFile.close() - except: - print('ERROR: test other public cert file %s missing' % (args.Othe= rPublicCertFileName)) + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') sys.exit(1) =20 - format =3D "%dsQ" % len(args.InputFileBuffer) - FullInputFileBuffer =3D struct.pack(format, args.InputFileBuffer, args= .MonotonicCountValue) - - # - # Sign the input file using the specified private key and capture sign= ature from STDOUT - # - Process =3D subprocess.Popen('%s smime -sign -binary -signer "%s" -out= form DER -md sha256 -certfile "%s"' % (OpenSslCommand, args.SignerPrivateCe= rtFileName, args.OtherPublicCertFileName), stdin=3Dsubprocess.PIPE, stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] + Version =3D Process.communicate() if Process.returncode !=3D 0: - sys.exit(Process.returncode) + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') + sys.exit(Process.returncode) + print(Version[0].decode()) =20 # - # Write output file that contains Signature, and Input data + # Read input file into a buffer and save input filename # - args.OutputFile =3D open(args.OutputFileName, 'wb') - args.OutputFile.write(Signature) - args.OutputFile.write(args.InputFileBuffer) - args.OutputFile.close() + args.InputFileName =3D args.InputFile.name + args.InputFileBuffer =3D args.InputFile.read() + args.InputFile.close() =20 - if args.Decode: # - # Save trusted public cert filename and close public cert file + # Save output filename and check if path exists # + OutputDir =3D os.path.dirname(args.OutputFile) + if not os.path.exists(OutputDir): + print('ERROR: The output path does not exist: %s' % OutputDir) + sys.exit(1) + args.OutputFileName =3D args.OutputFile + try: - args.TrustedPublicCertFileName =3D args.TrustedPublicCertFile.name - args.TrustedPublicCertFile.close() + if args.MonotonicCountStr.upper().startswith('0X'): + args.MonotonicCountValue =3D int(args.MonotonicCountStr, 16) + else: + args.MonotonicCountValue =3D int(args.MonotonicCountStr) except: - try: + args.MonotonicCountValue =3D int(0) + + if args.Encode: # - # Get path to currently executing script or executable + # Save signer private cert filename and close private cert file # - if hasattr(sys, 'frozen'): - Pkcs7ToolPath =3D sys.executable - else: - Pkcs7ToolPath =3D sys.argv[0] - if Pkcs7ToolPath.startswith('"'): - Pkcs7ToolPath =3D Pkcs7ToolPath[1:] - if Pkcs7ToolPath.endswith('"'): - Pkcs7ToolPath =3D RsaToolPath[:-1] - args.TrustedPublicCertFileName =3D os.path.join(os.path.dirname(os= .path.realpath(Pkcs7ToolPath)), TEST_TRUSTED_PUBLIC_CERT_FILENAME) - args.TrustedPublicCertFile =3D open(args.TrustedPublicCertFileName= , 'rb') - args.TrustedPublicCertFile.close() - except: - print('ERROR: test trusted public cert file %s missing' % (args.Tr= ustedPublicCertFileName)) - sys.exit(1) + try: + args.SignerPrivateCertFileName =3D args.SignerPrivateCertFile.= name + args.SignerPrivateCertFile.close() + except: + try: + # + # Get path to currently executing script or executable + # + if hasattr(sys, 'frozen'): + Pkcs7ToolPath =3D sys.executable + else: + Pkcs7ToolPath =3D sys.argv[0] + if Pkcs7ToolPath.startswith('"'): + Pkcs7ToolPath =3D Pkcs7ToolPath[1:] + if Pkcs7ToolPath.endswith('"'): + Pkcs7ToolPath =3D RsaToolPath[:-1] + args.SignerPrivateCertFileName =3D os.path.join(os.path.di= rname( + os.path.realpath(Pkcs7ToolPath)), TEST_SIGNER_PRIVATE_= CERT_FILENAME) + args.SignerPrivateCertFile =3D open( + args.SignerPrivateCertFileName, 'rb') + args.SignerPrivateCertFile.close() + except: + print('ERROR: test signer private cert file %s missing' % + (args.SignerPrivateCertFileName)) + sys.exit(1) =20 - if not args.SignatureSizeStr: - print("ERROR: please use the option --signature-size to specify the = size of the signature data!") - sys.exit(1) - else: - if args.SignatureSizeStr.upper().startswith('0X'): - SignatureSize =3D int(args.SignatureSizeStr, 16) - else: - SignatureSize =3D int(args.SignatureSizeStr) - if SignatureSize < 0: - print("ERROR: The value of option --signature-size can't be set to= negative value!") - sys.exit(1) - elif SignatureSize > len(args.InputFileBuffer): - print("ERROR: The value of option --signature-size is exceed the s= ize of the input file !") - sys.exit(1) + # + # Save other public cert filename and close public cert file + # + try: + args.OtherPublicCertFileName =3D args.OtherPublicCertFile.name + args.OtherPublicCertFile.close() + except: + try: + # + # Get path to currently executing script or executable + # + if hasattr(sys, 'frozen'): + Pkcs7ToolPath =3D sys.executable + else: + Pkcs7ToolPath =3D sys.argv[0] + if Pkcs7ToolPath.startswith('"'): + Pkcs7ToolPath =3D Pkcs7ToolPath[1:] + if Pkcs7ToolPath.endswith('"'): + Pkcs7ToolPath =3D RsaToolPath[:-1] + args.OtherPublicCertFileName =3D os.path.join(os.path.dirn= ame( + os.path.realpath(Pkcs7ToolPath)), TEST_OTHER_PUBLIC_CE= RT_FILENAME) + args.OtherPublicCertFile =3D open( + args.OtherPublicCertFileName, 'rb') + args.OtherPublicCertFile.close() + except: + print('ERROR: test other public cert file %s missing' % + (args.OtherPublicCertFileName)) + sys.exit(1) + + format =3D "%dsQ" % len(args.InputFileBuffer) + FullInputFileBuffer =3D struct.pack( + format, args.InputFileBuffer, args.MonotonicCountValue) =20 - args.SignatureBuffer =3D args.InputFileBuffer[0:SignatureSize] - args.InputFileBuffer =3D args.InputFileBuffer[SignatureSize:] + # + # Sign the input file using the specified private key and capture = signature from STDOUT + # + Process =3D subprocess.Popen('%s smime -sign -binary -signer "%s" = -outform DER -md sha256 -certfile "%s"' % (OpenSslCommand, + args.SignerPrivateCertFileName, args.Ot= herPublicCertFileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, = stderr=3Dsubprocess.PIPE, shell=3DTrue) + Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] + if Process.returncode !=3D 0: + sys.exit(Process.returncode) =20 - format =3D "%dsQ" % len(args.InputFileBuffer) - FullInputFileBuffer =3D struct.pack(format, args.InputFileBuffer, args= .MonotonicCountValue) + # + # Write output file that contains Signature, and Input data + # + args.OutputFile =3D open(args.OutputFileName, 'wb') + args.OutputFile.write(Signature) + args.OutputFile.write(args.InputFileBuffer) + args.OutputFile.close() =20 - # - # Save output file contents from input file - # - open(args.OutputFileName, 'wb').write(FullInputFileBuffer) + if args.Decode: + # + # Save trusted public cert filename and close public cert file + # + try: + args.TrustedPublicCertFileName =3D args.TrustedPublicCertFile.= name + args.TrustedPublicCertFile.close() + except: + try: + # + # Get path to currently executing script or executable + # + if hasattr(sys, 'frozen'): + Pkcs7ToolPath =3D sys.executable + else: + Pkcs7ToolPath =3D sys.argv[0] + if Pkcs7ToolPath.startswith('"'): + Pkcs7ToolPath =3D Pkcs7ToolPath[1:] + if Pkcs7ToolPath.endswith('"'): + Pkcs7ToolPath =3D RsaToolPath[:-1] + args.TrustedPublicCertFileName =3D os.path.join(os.path.di= rname( + os.path.realpath(Pkcs7ToolPath)), TEST_TRUSTED_PUBLIC_= CERT_FILENAME) + args.TrustedPublicCertFile =3D open( + args.TrustedPublicCertFileName, 'rb') + args.TrustedPublicCertFile.close() + except: + print('ERROR: test trusted public cert file %s missing' % + (args.TrustedPublicCertFileName)) + sys.exit(1) + + if not args.SignatureSizeStr: + print( + "ERROR: please use the option --signature-size to specify = the size of the signature data!") + sys.exit(1) + else: + if args.SignatureSizeStr.upper().startswith('0X'): + SignatureSize =3D int(args.SignatureSizeStr, 16) + else: + SignatureSize =3D int(args.SignatureSizeStr) + if SignatureSize < 0: + print( + "ERROR: The value of option --signature-size can't be set = to negative value!") + sys.exit(1) + elif SignatureSize > len(args.InputFileBuffer): + print( + "ERROR: The value of option --signature-size is exceed the= size of the input file !") + sys.exit(1) + + args.SignatureBuffer =3D args.InputFileBuffer[0:SignatureSize] + args.InputFileBuffer =3D args.InputFileBuffer[SignatureSize:] + + format =3D "%dsQ" % len(args.InputFileBuffer) + FullInputFileBuffer =3D struct.pack( + format, args.InputFileBuffer, args.MonotonicCountValue) =20 - # - # Verify signature - # - Process =3D subprocess.Popen('%s smime -verify -inform DER -content %s= -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCert= FileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) - Process.communicate(input=3Dargs.SignatureBuffer)[0] - if Process.returncode !=3D 0: - print('ERROR: Verification failed') - os.remove (args.OutputFileName) - sys.exit(Process.returncode) + # + # Save output file contents from input file + # + open(args.OutputFileName, 'wb').write(FullInputFileBuffer) =20 - open(args.OutputFileName, 'wb').write(args.InputFileBuffer) + # + # Verify signature + # + Process =3D subprocess.Popen('%s smime -verify -inform DER -conten= t %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, + args.TrustedPublicCertFileName), stdin= =3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, she= ll=3DTrue) + Process.communicate(input=3Dargs.SignatureBuffer)[0] + if Process.returncode !=3D 0: + print('ERROR: Verification failed') + os.remove(args.OutputFileName) + sys.exit(Process.returncode) + + open(args.OutputFileName, 'wb').write(args.InputFileBuffer) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.py index 6c9b8c464e4d..abdb99ac4083 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py @@ -1,4 +1,4 @@ -## @file +# @file # This tool can be used to generate new RSA 2048 bit private/public key pa= irs # in a PEM file format using OpenSSL command line utilities that are insta= lled # on the path specified by the system environment variable OPENSSL_PATH. @@ -27,144 +27,159 @@ from Common.BuildVersion import gBUILD_VERSION # # Globals for help information # -__prog__ =3D 'Rsa2048Sha256GenerateKeys' -__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) +__prog__ =3D 'Rsa2048Sha256GenerateKeys' +__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) __copyright__ =3D 'Copyright (c) 2013 - 2018, Intel Corporation. All right= s reserved.' -__usage__ =3D '%s [options]' % (__prog__) +__usage__ =3D '%s [options]' % (__prog__) =20 =20 if __name__ =3D=3D '__main__': - # - # Create command line argument parser object - # - parser =3D argparse.ArgumentParser(prog=3D__prog__, usage=3D__usage__, d= escription=3D__copyright__, conflict_handler=3D'resolve') - group =3D parser.add_mutually_exclusive_group(required=3DTrue) - group.add_argument("--version", action=3D'version', version=3D__version_= _) - group.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dargpars= e.FileType('wb'), metavar=3D'filename', nargs=3D'*', help=3D"specify the ou= tput private key filename in PEM format") - group.add_argument("-i", "--input", dest=3D'InputFile', type=3Dargparse.= FileType('rb'), metavar=3D'filename', nargs=3D'*', help=3D"specify the inpu= t private key filename in PEM format") - parser.add_argument("--public-key-hash", dest=3D'PublicKeyHashFile', typ= e=3Dargparse.FileType('wb'), help=3D"specify the public key hash filename t= hat is SHA 256 hash of 2048 bit RSA public key in binary format") - parser.add_argument("--public-key-hash-c", dest=3D'PublicKeyHashCFile', = type=3Dargparse.FileType('wb'), help=3D"specify the public key hash filenam= e that is SHA 256 hash of 2048 bit RSA public key in C structure format") - parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") - parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0, 10), default=3D0, help=3D"set debug level") + # + # Create command line argument parser object + # + parser =3D argparse.ArgumentParser( + prog=3D__prog__, usage=3D__usage__, description=3D__copyright__, c= onflict_handler=3D'resolve') + group =3D parser.add_mutually_exclusive_group(required=3DTrue) + group.add_argument("--version", action=3D'version', version=3D__versio= n__) + group.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dargpa= rse.FileType('wb'), + metavar=3D'filename', nargs=3D'*', help=3D"specify = the output private key filename in PEM format") + group.add_argument("-i", "--input", dest=3D'InputFile', type=3Dargpars= e.FileType('rb'), + metavar=3D'filename', nargs=3D'*', help=3D"specify = the input private key filename in PEM format") + parser.add_argument("--public-key-hash", dest=3D'PublicKeyHashFile', t= ype=3Dargparse.FileType('wb'), + help=3D"specify the public key hash filename that = is SHA 256 hash of 2048 bit RSA public key in binary format") + parser.add_argument("--public-key-hash-c", dest=3D'PublicKeyHashCFile'= , type=3Dargparse.FileType('wb'), + help=3D"specify the public key hash filename that = is SHA 256 hash of 2048 bit RSA public key in C structure format") + parser.add_argument("-v", "--verbose", dest=3D'Verbose', + action=3D"store_true", help=3D"increase output mes= sages") + parser.add_argument("-q", "--quiet", dest=3D'Quiet', + action=3D"store_true", help=3D"reduce output messa= ges") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint, + metavar=3D'[0-9]', choices=3Drange(0, 10), default= =3D0, help=3D"set debug level") =20 - # - # Parse command line arguments - # - args =3D parser.parse_args() + # + # Parse command line arguments + # + args =3D parser.parse_args() =20 - # - # Generate file path to Open SSL command - # - OpenSslCommand =3D 'openssl' - try: - OpenSslPath =3D os.environ['OPENSSL_PATH'] - OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) - if ' ' in OpenSslCommand: - OpenSslCommand =3D '"' + OpenSslCommand + '"' - except: - pass + # + # Generate file path to Open SSL command + # + OpenSslCommand =3D 'openssl' + try: + OpenSslPath =3D os.environ['OPENSSL_PATH'] + OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) + if ' ' in OpenSslCommand: + OpenSslCommand =3D '"' + OpenSslCommand + '"' + except: + pass =20 - # - # Verify that Open SSL command is available - # - try: - Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - except: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(1) + # + # Verify that Open SSL command is available + # + try: + Process =3D subprocess.Popen('%s version' % ( + OpenSslCommand), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess= .PIPE, shell=3DTrue) + except: + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') + sys.exit(1) =20 - Version =3D Process.communicate() - if Process.returncode !=3D 0: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(Process.returncode) - print(Version[0].decode()) - - args.PemFileName =3D [] - - # - # Check for output file argument - # - if args.OutputFile is not None: - for Item in args.OutputFile: - # - # Save PEM filename and close output file - # - args.PemFileName.append(Item.name) - Item.close() - - # - # Generate private key and save it to output file in a PEM file form= at - # - Process =3D subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslComm= and, Item.name), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) - Process.communicate() - if Process.returncode !=3D 0: - print('ERROR: RSA 2048 key generation failed') + Version =3D Process.communicate() + if Process.returncode !=3D 0: + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') sys.exit(Process.returncode) + print(Version[0].decode()) =20 - # - # Check for input file argument - # - if args.InputFile is not None: - for Item in args.InputFile: - # - # Save PEM filename and close input file - # - args.PemFileName.append(Item.name) - Item.close() + args.PemFileName =3D [] =20 - PublicKeyHash =3D bytearray() - for Item in args.PemFileName: # - # Extract public key from private key into STDOUT + # Check for output file argument # - Process =3D subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSs= lCommand, Item), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell= =3DTrue) - PublicKeyHexString =3D Process.communicate()[0].decode().split(b'=3D')= [1].strip() - if Process.returncode !=3D 0: - print('ERROR: Unable to extract public key from private key') - sys.exit(Process.returncode) - PublicKey =3D bytearray() - for Index in range (0, len(PublicKeyHexString), 2): - PublicKey =3D PublicKey + PublicKeyHexString[Index:Index + 2] + if args.OutputFile is not None: + for Item in args.OutputFile: + # + # Save PEM filename and close output file + # + args.PemFileName.append(Item.name) + Item.close() + + # + # Generate private key and save it to output file in a PEM fil= e format + # + Process =3D subprocess.Popen('%s genrsa -out %s 2048' % ( + OpenSslCommand, Item.name), stdout=3Dsubprocess.PIPE, stde= rr=3Dsubprocess.PIPE, shell=3DTrue) + Process.communicate() + if Process.returncode !=3D 0: + print('ERROR: RSA 2048 key generation failed') + sys.exit(Process.returncode) =20 # - # Generate SHA 256 hash of RSA 2048 bit public key into STDOUT + # Check for input file argument # - Process =3D subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslComma= nd), stdin=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess= .PIPE, shell=3DTrue) - Process.stdin.write (PublicKey) - PublicKeyHash =3D PublicKeyHash + Process.communicate()[0].decode() - if Process.returncode !=3D 0: - print('ERROR: Unable to extract SHA 256 hash of public key') - sys.exit(Process.returncode) + if args.InputFile is not None: + for Item in args.InputFile: + # + # Save PEM filename and close input file + # + args.PemFileName.append(Item.name) + Item.close() + + PublicKeyHash =3D bytearray() + for Item in args.PemFileName: + # + # Extract public key from private key into STDOUT + # + Process =3D subprocess.Popen('%s rsa -in %s -modulus -noout' % ( + OpenSslCommand, Item), stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) + PublicKeyHexString =3D Process.communicate()[0].decode().split(b'= =3D')[ + 1].strip() + if Process.returncode !=3D 0: + print('ERROR: Unable to extract public key from private key') + sys.exit(Process.returncode) + PublicKey =3D bytearray() + for Index in range(0, len(PublicKeyHexString), 2): + PublicKey =3D PublicKey + PublicKeyHexString[Index:Index + 2] =20 - # - # Write SHA 256 hash of 2048 bit binary public key to public key hash fi= le - # - try: - args.PublicKeyHashFile.write (PublicKeyHash) - args.PublicKeyHashFile.close () - except: - pass + # + # Generate SHA 256 hash of RSA 2048 bit public key into STDOUT + # + Process =3D subprocess.Popen('%s dgst -sha256 -binary' % (OpenSslC= ommand), + stdin=3Dsubprocess.PIPE, stdout=3Dsubpr= ocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) + Process.stdin.write(PublicKey) + PublicKeyHash =3D PublicKeyHash + Process.communicate()[0].decode() + if Process.returncode !=3D 0: + print('ERROR: Unable to extract SHA 256 hash of public key') + sys.exit(Process.returncode) =20 - # - # Convert public key hash to a C structure string - # - PublicKeyHashC =3D '{' - for Item in PublicKeyHash: - PublicKeyHashC =3D PublicKeyHashC + '0x%02x, ' % (Item) - PublicKeyHashC =3D PublicKeyHashC[:-2] + '}' + # + # Write SHA 256 hash of 2048 bit binary public key to public key hash = file + # + try: + args.PublicKeyHashFile.write(PublicKeyHash) + args.PublicKeyHashFile.close() + except: + pass =20 - # - # Write SHA 256 of 2048 bit binary public key to public key hash C struc= ture file - # - try: - args.PublicKeyHashCFile.write (bytes(PublicKeyHashC)) - args.PublicKeyHashCFile.close () - except: - pass + # + # Convert public key hash to a C structure string + # + PublicKeyHashC =3D '{' + for Item in PublicKeyHash: + PublicKeyHashC =3D PublicKeyHashC + '0x%02x, ' % (Item) + PublicKeyHashC =3D PublicKeyHashC[:-2] + '}' =20 - # - # If verbose is enabled display the public key in C structure format - # - if args.Verbose: - print('PublicKeySha256 =3D ' + PublicKeyHashC) + # + # Write SHA 256 of 2048 bit binary public key to public key hash C str= ucture file + # + try: + args.PublicKeyHashCFile.write(bytes(PublicKeyHashC)) + args.PublicKeyHashCFile.close() + except: + pass + + # + # If verbose is enabled display the public key in C structure format + # + if args.Verbose: + print('PublicKeySha256 =3D ' + PublicKeyHashC) diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py= b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index df05826282eb..fb224cb83dac 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -1,4 +1,4 @@ -## @file +# @file # This tool encodes and decodes GUIDed FFS sections or FMP capsule for a G= UID type of # EFI_CERT_TYPE_RSA2048_SHA256_GUID defined in the UEFI 2.4 Specification = as # {0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35= , 0xbf}} @@ -25,15 +25,16 @@ from Common.BuildVersion import gBUILD_VERSION # # Globals for help information # -__prog__ =3D 'Rsa2048Sha256Sign' -__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) +__prog__ =3D 'Rsa2048Sha256Sign' +__version__ =3D '%s Version %s' % (__prog__, '0.9 ' + gBUILD_VERSION) __copyright__ =3D 'Copyright (c) 2013 - 2018, Intel Corporation. All right= s reserved.' -__usage__ =3D '%s -e|-d [options] ' % (__prog__) +__usage__ =3D '%s -e|-d [options] ' % (__prog__) =20 # # GUID for SHA 256 Hash Algorithm from UEFI Specification # -EFI_HASH_ALGORITHM_SHA256_GUID =3D uuid.UUID('{51aa59de-fdf2-4ea3-bc63-875= fb7842ee9}') +EFI_HASH_ALGORITHM_SHA256_GUID =3D uuid.UUID( + '{51aa59de-fdf2-4ea3-bc63-875fb7842ee9}') =20 # # Structure definition to unpack EFI_CERT_BLOCK_RSA_2048_SHA256 from UEFI = 2.4 Specification @@ -44,7 +45,8 @@ EFI_HASH_ALGORITHM_SHA256_GUID =3D uuid.UUID('{51aa59de-f= df2-4ea3-bc63-875fb7842ee # UINT8 Signature[256]; # } EFI_CERT_BLOCK_RSA_2048_SHA256; # -EFI_CERT_BLOCK_RSA_2048_SHA256 =3D collections.namedtuple('EFI_CERT= _BLOCK_RSA_2048_SHA256', ['HashType', 'PublicKey', 'Signature']) +EFI_CERT_BLOCK_RSA_2048_SHA256 =3D collections.namedtuple( + 'EFI_CERT_BLOCK_RSA_2048_SHA256', ['HashType', 'PublicKey', 'Signature= ']) EFI_CERT_BLOCK_RSA_2048_SHA256_STRUCT =3D struct.Struct('16s256s256s') =20 # @@ -53,183 +55,205 @@ EFI_CERT_BLOCK_RSA_2048_SHA256_STRUCT =3D struct.Stru= ct('16s256s256s') TEST_SIGNING_PRIVATE_KEY_FILENAME =3D 'TestSigningPrivateKey.pem' =20 if __name__ =3D=3D '__main__': - # - # Create command line argument parser object - # - parser =3D argparse.ArgumentParser(prog=3D__prog__, usage=3D__usage__, d= escription=3D__copyright__, conflict_handler=3D'resolve') - group =3D parser.add_mutually_exclusive_group(required=3DTrue) - group.add_argument("-e", action=3D"store_true", dest=3D'Encode', help=3D= 'encode file') - group.add_argument("-d", action=3D"store_true", dest=3D'Decode', help=3D= 'decode file') - group.add_argument("--version", action=3D'version', version=3D__version_= _) - parser.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dstr, m= etavar=3D'filename', help=3D"specify the output filename", required=3DTrue) - parser.add_argument("--monotonic-count", dest=3D'MonotonicCountStr', typ= e=3Dstr, help=3D"specify the MonotonicCount in FMP capsule.") - parser.add_argument("--private-key", dest=3D'PrivateKeyFile', type=3Darg= parse.FileType('rb'), help=3D"specify the private key filename. If not spe= cified, a test signing key is used.") - parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") - parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0, 10), default=3D0, help=3D"set debug level") - parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type=3Da= rgparse.FileType('rb'), help=3D"specify the input filename") - - # - # Parse command line arguments - # - args =3D parser.parse_args() - - # - # Generate file path to Open SSL command - # - OpenSslCommand =3D 'openssl' - try: - OpenSslPath =3D os.environ['OPENSSL_PATH'] - OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) - if ' ' in OpenSslCommand: - OpenSslCommand =3D '"' + OpenSslCommand + '"' - except: - pass - - # - # Verify that Open SSL command is available - # - try: - Process =3D subprocess.Popen('%s version' % (OpenSslCommand), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - except: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(1) - - Version =3D Process.communicate() - if Process.returncode !=3D 0: - print('ERROR: Open SSL command not available. Please verify PATH or s= et OPENSSL_PATH') - sys.exit(Process.returncode) - print(Version[0].decode('utf-8')) - - # - # Read input file into a buffer and save input filename - # - args.InputFileName =3D args.InputFile.name - args.InputFileBuffer =3D args.InputFile.read() - args.InputFile.close() - - # - # Save output filename and check if path exists - # - OutputDir =3D os.path.dirname(args.OutputFile) - if not os.path.exists(OutputDir): - print('ERROR: The output path does not exist: %s' % OutputDir) - sys.exit(1) - args.OutputFileName =3D args.OutputFile - - # - # Save private key filename and close private key file - # - try: - args.PrivateKeyFileName =3D args.PrivateKeyFile.name - args.PrivateKeyFile.close() - except: - try: - # - # Get path to currently executing script or executable - # - if hasattr(sys, 'frozen'): - RsaToolPath =3D sys.executable - else: - RsaToolPath =3D sys.argv[0] - if RsaToolPath.startswith('"'): - RsaToolPath =3D RsaToolPath[1:] - if RsaToolPath.endswith('"'): - RsaToolPath =3D RsaToolPath[:-1] - args.PrivateKeyFileName =3D os.path.join(os.path.dirname(os.path.rea= lpath(RsaToolPath)), TEST_SIGNING_PRIVATE_KEY_FILENAME) - args.PrivateKeyFile =3D open(args.PrivateKeyFileName, 'rb') - args.PrivateKeyFile.close() - except: - print('ERROR: test signing private key file %s missing' % (args.Priv= ateKeyFileName)) - sys.exit(1) - - # - # Extract public key from private key into STDOUT - # - Process =3D subprocess.Popen('%s rsa -in "%s" -modulus -noout' % (OpenSs= lCommand, args.PrivateKeyFileName), stdout=3Dsubprocess.PIPE, stderr=3Dsubp= rocess.PIPE, shell=3DTrue) - PublicKeyHexString =3D Process.communicate()[0].split(b'=3D')[1].strip() - PublicKeyHexString =3D PublicKeyHexString.decode('utf-8') - PublicKey =3D '' - while len(PublicKeyHexString) > 0: - PublicKey =3D PublicKey + PublicKeyHexString[0:2] - PublicKeyHexString=3DPublicKeyHexString[2:] - if Process.returncode !=3D 0: - sys.exit(Process.returncode) - - if args.MonotonicCountStr: + # + # Create command line argument parser object + # + parser =3D argparse.ArgumentParser( + prog=3D__prog__, usage=3D__usage__, description=3D__copyright__, c= onflict_handler=3D'resolve') + group =3D parser.add_mutually_exclusive_group(required=3DTrue) + group.add_argument("-e", action=3D"store_true", + dest=3D'Encode', help=3D'encode file') + group.add_argument("-d", action=3D"store_true", + dest=3D'Decode', help=3D'decode file') + group.add_argument("--version", action=3D'version', version=3D__versio= n__) + parser.add_argument("-o", "--output", dest=3D'OutputFile', type=3Dstr, + metavar=3D'filename', help=3D"specify the output f= ilename", required=3DTrue) + parser.add_argument("--monotonic-count", dest=3D'MonotonicCountStr', + type=3Dstr, help=3D"specify the MonotonicCount in = FMP capsule.") + parser.add_argument("--private-key", dest=3D'PrivateKeyFile', type=3Da= rgparse.FileType('rb'), + help=3D"specify the private key filename. If not = specified, a test signing key is used.") + parser.add_argument("-v", "--verbose", dest=3D'Verbose', + action=3D"store_true", help=3D"increase output mes= sages") + parser.add_argument("-q", "--quiet", dest=3D'Quiet', + action=3D"store_true", help=3D"reduce output messa= ges") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint, + metavar=3D'[0-9]', choices=3Drange(0, 10), default= =3D0, help=3D"set debug level") + parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type= =3Dargparse.FileType( + 'rb'), help=3D"specify the input filename") + + # + # Parse command line arguments + # + args =3D parser.parse_args() + + # + # Generate file path to Open SSL command + # + OpenSslCommand =3D 'openssl' try: - if args.MonotonicCountStr.upper().startswith('0X'): - args.MonotonicCountValue =3D int(args.MonotonicCountStr, 16) - else: - args.MonotonicCountValue =3D int(args.MonotonicCountStr) + OpenSslPath =3D os.environ['OPENSSL_PATH'] + OpenSslCommand =3D os.path.join(OpenSslPath, OpenSslCommand) + if ' ' in OpenSslCommand: + OpenSslCommand =3D '"' + OpenSslCommand + '"' except: pass =20 - if args.Encode: - FullInputFileBuffer =3D args.InputFileBuffer - if args.MonotonicCountStr: - format =3D "%dsQ" % len(args.InputFileBuffer) - FullInputFileBuffer =3D struct.pack(format, args.InputFileBuffer, ar= gs.MonotonicCountValue) # - # Sign the input file using the specified private key and capture sign= ature from STDOUT + # Verify that Open SSL command is available # - Process =3D subprocess.Popen('%s dgst -sha256 -sign "%s"' % (OpenSslCo= mmand, args.PrivateKeyFileName), stdin=3Dsubprocess.PIPE, stdout=3Dsubproce= ss.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) - Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] + try: + Process =3D subprocess.Popen('%s version' % ( + OpenSslCommand), stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess= .PIPE, shell=3DTrue) + except: + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') + sys.exit(1) + + Version =3D Process.communicate() if Process.returncode !=3D 0: - sys.exit(Process.returncode) + print( + 'ERROR: Open SSL command not available. Please verify PATH or= set OPENSSL_PATH') + sys.exit(Process.returncode) + print(Version[0].decode('utf-8')) =20 # - # Write output file that contains hash GUID, Public Key, Signature, an= d Input data + # Read input file into a buffer and save input filename # - args.OutputFile =3D open(args.OutputFileName, 'wb') - args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.bytes_le) - args.OutputFile.write(bytearray.fromhex(str(PublicKey))) - args.OutputFile.write(Signature) - args.OutputFile.write(args.InputFileBuffer) - args.OutputFile.close() + args.InputFileName =3D args.InputFile.name + args.InputFileBuffer =3D args.InputFile.read() + args.InputFile.close() =20 - if args.Decode: # - # Parse Hash Type, Public Key, and Signature from the section header + # Save output filename and check if path exists # - Header =3D EFI_CERT_BLOCK_RSA_2048_SHA256._make(EFI_CERT_BLOCK_RSA_204= 8_SHA256_STRUCT.unpack_from(args.InputFileBuffer)) - args.InputFileBuffer =3D args.InputFileBuffer[EFI_CERT_BLOCK_RSA_2048_= SHA256_STRUCT.size:] + OutputDir =3D os.path.dirname(args.OutputFile) + if not os.path.exists(OutputDir): + print('ERROR: The output path does not exist: %s' % OutputDir) + sys.exit(1) + args.OutputFileName =3D args.OutputFile =20 # - # Verify that the Hash Type matches the expected SHA256 type - # - if uuid.UUID(bytes_le =3D Header.HashType) !=3D EFI_HASH_ALGORITHM_SHA= 256_GUID: - print('ERROR: unsupport hash GUID') - sys.exit(1) + # Save private key filename and close private key file + # + try: + args.PrivateKeyFileName =3D args.PrivateKeyFile.name + args.PrivateKeyFile.close() + except: + try: + # + # Get path to currently executing script or executable + # + if hasattr(sys, 'frozen'): + RsaToolPath =3D sys.executable + else: + RsaToolPath =3D sys.argv[0] + if RsaToolPath.startswith('"'): + RsaToolPath =3D RsaToolPath[1:] + if RsaToolPath.endswith('"'): + RsaToolPath =3D RsaToolPath[:-1] + args.PrivateKeyFileName =3D os.path.join(os.path.dirname( + os.path.realpath(RsaToolPath)), TEST_SIGNING_PRIVATE_KEY_F= ILENAME) + args.PrivateKeyFile =3D open(args.PrivateKeyFileName, 'rb') + args.PrivateKeyFile.close() + except: + print('ERROR: test signing private key file %s missing' % + (args.PrivateKeyFileName)) + sys.exit(1) =20 # - # Verify the public key + # Extract public key from private key into STDOUT # - if Header.PublicKey !=3D bytearray.fromhex(PublicKey): - print('ERROR: Public key in input file does not match public key fro= m private key file') - sys.exit(1) + Process =3D subprocess.Popen('%s rsa -in "%s" -modulus -noout' % (Open= SslCommand, + args.PrivateKeyFileName), stdout=3Dsubproce= ss.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) + PublicKeyHexString =3D Process.communicate()[0].split(b'=3D')[1].strip= () + PublicKeyHexString =3D PublicKeyHexString.decode('utf-8') + PublicKey =3D '' + while len(PublicKeyHexString) > 0: + PublicKey =3D PublicKey + PublicKeyHexString[0:2] + PublicKeyHexString =3D PublicKeyHexString[2:] + if Process.returncode !=3D 0: + sys.exit(Process.returncode) =20 - FullInputFileBuffer =3D args.InputFileBuffer if args.MonotonicCountStr: - format =3D "%dsQ" % len(args.InputFileBuffer) - FullInputFileBuffer =3D struct.pack(format, args.InputFileBuffer, ar= gs.MonotonicCountValue) + try: + if args.MonotonicCountStr.upper().startswith('0X'): + args.MonotonicCountValue =3D int(args.MonotonicCountStr, 1= 6) + else: + args.MonotonicCountValue =3D int(args.MonotonicCountStr) + except: + pass =20 - # - # Write Signature to output file - # - open(args.OutputFileName, 'wb').write(Header.Signature) + if args.Encode: + FullInputFileBuffer =3D args.InputFileBuffer + if args.MonotonicCountStr: + format =3D "%dsQ" % len(args.InputFileBuffer) + FullInputFileBuffer =3D struct.pack( + format, args.InputFileBuffer, args.MonotonicCountValue) + # + # Sign the input file using the specified private key and capture = signature from STDOUT + # + Process =3D subprocess.Popen('%s dgst -sha256 -sign "%s"' % (OpenS= slCommand, args.PrivateKeyFileName), + stdin=3Dsubprocess.PIPE, stdout=3Dsubpr= ocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) + Signature =3D Process.communicate(input=3DFullInputFileBuffer)[0] + if Process.returncode !=3D 0: + sys.exit(Process.returncode) =20 - # - # Verify signature - # - Process =3D subprocess.Popen('%s dgst -sha256 -prverify "%s" -signatur= e %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), std= in=3Dsubprocess.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, s= hell=3DTrue) - Process.communicate(input=3DFullInputFileBuffer) - if Process.returncode !=3D 0: - print('ERROR: Verification failed') - os.remove (args.OutputFileName) - sys.exit(Process.returncode) + # + # Write output file that contains hash GUID, Public Key, Signature= , and Input data + # + args.OutputFile =3D open(args.OutputFileName, 'wb') + args.OutputFile.write(EFI_HASH_ALGORITHM_SHA256_GUID.bytes_le) + args.OutputFile.write(bytearray.fromhex(str(PublicKey))) + args.OutputFile.write(Signature) + args.OutputFile.write(args.InputFileBuffer) + args.OutputFile.close() =20 - # - # Save output file contents from input file - # - open(args.OutputFileName, 'wb').write(args.InputFileBuffer) + if args.Decode: + # + # Parse Hash Type, Public Key, and Signature from the section head= er + # + Header =3D EFI_CERT_BLOCK_RSA_2048_SHA256._make( + EFI_CERT_BLOCK_RSA_2048_SHA256_STRUCT.unpack_from(args.InputFi= leBuffer)) + args.InputFileBuffer =3D args.InputFileBuffer[EFI_CERT_BLOCK_RSA_2= 048_SHA256_STRUCT.size:] + + # + # Verify that the Hash Type matches the expected SHA256 type + # + if uuid.UUID(bytes_le=3DHeader.HashType) !=3D EFI_HASH_ALGORITHM_S= HA256_GUID: + print('ERROR: unsupport hash GUID') + sys.exit(1) + + # + # Verify the public key + # + if Header.PublicKey !=3D bytearray.fromhex(PublicKey): + print( + 'ERROR: Public key in input file does not match public key= from private key file') + sys.exit(1) + + FullInputFileBuffer =3D args.InputFileBuffer + if args.MonotonicCountStr: + format =3D "%dsQ" % len(args.InputFileBuffer) + FullInputFileBuffer =3D struct.pack( + format, args.InputFileBuffer, args.MonotonicCountValue) + + # + # Write Signature to output file + # + open(args.OutputFileName, 'wb').write(Header.Signature) + + # + # Verify signature + # + Process =3D subprocess.Popen('%s dgst -sha256 -prverify "%s" -sign= ature %s' % (OpenSslCommand, args.PrivateKeyFileName, + args.OutputFileName), stdin=3Dsubproces= s.PIPE, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) + Process.communicate(input=3DFullInputFileBuffer) + if Process.returncode !=3D 0: + print('ERROR: Verification failed') + os.remove(args.OutputFileName) + sys.exit(Process.returncode) + + # + # Save output file contents from input file + # + open(args.OutputFileName, 'wb').write(args.InputFileBuffer) diff --git a/BaseTools/Source/Python/Split/Split.py b/BaseTools/Source/Pyth= on/Split/Split.py index e70d5c22c468..92d3ada0850e 100644 --- a/BaseTools/Source/Python/Split/Split.py +++ b/BaseTools/Source/Python/Split/Split.py @@ -92,16 +92,20 @@ def getFileSize(filename): =20 return length =20 -def getoutputfileabs(inputfile, prefix, outputfile,index): + +def getoutputfileabs(inputfile, prefix, outputfile, index): inputfile =3D os.path.abspath(inputfile) if outputfile is None: if prefix is None: - outputfileabs =3D os.path.join(os.path.dirname(inputfile), "{}= {}".format(os.path.basename(inputfile),index)) + outputfileabs =3D os.path.join(os.path.dirname( + inputfile), "{}{}".format(os.path.basename(inputfile), ind= ex)) else: if os.path.isabs(prefix): - outputfileabs =3D os.path.join(prefix, "{}{}".format(os.pa= th.basename(inputfile),index)) + outputfileabs =3D os.path.join(prefix, "{}{}".format( + os.path.basename(inputfile), index)) else: - outputfileabs =3D os.path.join(os.getcwd(), prefix, "{}{}"= .format(os.path.basename(inputfile),index)) + outputfileabs =3D os.path.join(os.getcwd(), prefix, "{}{}"= .format( + os.path.basename(inputfile), index)) elif not os.path.isabs(outputfile): if prefix is None: outputfileabs =3D os.path.join(os.getcwd(), outputfile) @@ -114,6 +118,7 @@ def getoutputfileabs(inputfile, prefix, outputfile,inde= x): outputfileabs =3D outputfile return outputfileabs =20 + def splitFile(inputfile, position, outputdir=3DNone, outputfile1=3DNone, o= utputfile2=3DNone): ''' Split the inputfile into outputfile1 and outputfile2 from the position. @@ -132,12 +137,12 @@ def splitFile(inputfile, position, outputdir=3DNone, = outputfile1=3DNone, outputfile2 # Create dir for the output files try: =20 - outputfile1 =3D getoutputfileabs(inputfile, outputdir, outputfile1= ,1) + outputfile1 =3D getoutputfileabs(inputfile, outputdir, outputfile1= , 1) outputfolder =3D os.path.dirname(outputfile1) if not os.path.exists(outputfolder): os.makedirs(outputfolder) =20 - outputfile2 =3D getoutputfileabs(inputfile, outputdir, outputfile2= ,2) + outputfile2 =3D getoutputfileabs(inputfile, outputdir, outputfile2= , 2) outputfolder =3D os.path.dirname(outputfile2) if not os.path.exists(outputfolder): os.makedirs(outputfolder) diff --git a/BaseTools/Source/Python/Table/Table.py b/BaseTools/Source/Pyth= on/Table/Table.py index 7a60313e9524..c179334d8fc5 100644 --- a/BaseTools/Source/Python/Table/Table.py +++ b/BaseTools/Source/Python/Table/Table.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase a common table # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -10,7 +10,7 @@ # import Common.EdkLogger as EdkLogger =20 -## TableFile +# TableFile # # This class defined a common table # @@ -19,13 +19,15 @@ import Common.EdkLogger as EdkLogger # @param Cursor: Cursor of the database # @param TableName: Name of the table # + + class Table(object): def __init__(self, Cursor): self.Cur =3D Cursor self.Table =3D '' self.ID =3D 0 =20 - ## Create table + # Create table # # Create a table # @@ -34,14 +36,14 @@ class Table(object): self.ID =3D 0 EdkLogger.verbose(SqlCommand + " ... DONE!") =20 - ## Insert table + # Insert table # # Insert a record into a table # def Insert(self, SqlCommand): self.Exec(SqlCommand) =20 - ## Query table + # Query table # # Query all records of the table # @@ -53,10 +55,11 @@ class Table(object): EdkLogger.verbose(str(Rs)) =20 TotalCount =3D self.GetCount() - EdkLogger.verbose("*** Total %s records in table %s ***" % (TotalC= ount, self.Table) ) + EdkLogger.verbose("*** Total %s records in table %s ***" % + (TotalCount, self.Table)) EdkLogger.verbose("Query tabel %s DONE!" % self.Table) =20 - ## Drop a table + # Drop a table # # Drop the table # @@ -65,7 +68,7 @@ class Table(object): self.Cur.execute(SqlCommand) EdkLogger.verbose("Drop tabel %s ... DONE!" % self.Table) =20 - ## Get count + # Get count # # Get a count of all records of the table # @@ -77,7 +80,7 @@ class Table(object): for Item in self.Cur: return Item[0] =20 - ## Generate ID + # Generate ID # # Generate an ID if input ID is -1 # @@ -91,14 +94,14 @@ class Table(object): =20 return self.ID =20 - ## Init the ID of the table + # Init the ID of the table # # Init the ID of the table # def InitID(self): self.ID =3D self.GetCount() =20 - ## Exec + # Exec # # Exec Sql Command, return result # diff --git a/BaseTools/Source/Python/Table/TableDataModel.py b/BaseTools/So= urce/Python/Table/TableDataModel.py index 3855807452f7..8b609fa2c99b 100644 --- a/BaseTools/Source/Python/Table/TableDataModel.py +++ b/BaseTools/Source/Python/Table/TableDataModel.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for data models # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,19 +14,21 @@ import CommonDataClass.DataClass as DataClass from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableDataModel +# TableDataModel # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableDataModel(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'DataModel' =20 - ## Create table + # Create table # # Create table DataModel # @@ -43,7 +45,7 @@ class TableDataModel(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table DataModel # @@ -55,12 +57,13 @@ class TableDataModel(Table): def Insert(self, CrossIndex, Name, Description): self.ID =3D self.ID + 1 (Name, Description) =3D ConvertToSqlString((Name, Description)) - SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s')""" % (= self.Table, self.ID, CrossIndex, Name, Description) + SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s')""" % ( + self.Table, self.ID, CrossIndex, Name, Description) Table.Insert(self, SqlCommand) =20 return self.ID =20 - ## Init table + # Init table # # Create all default records of table DataModel # @@ -73,7 +76,7 @@ class TableDataModel(Table): self.Insert(CrossIndex, Name, Description) EdkLogger.verbose("Initialize table DataModel ... DONE!") =20 - ## Get CrossIndex + # Get CrossIndex # # Get a model's cross index from its name # diff --git a/BaseTools/Source/Python/Table/TableDec.py b/BaseTools/Source/P= ython/Table/TableDec.py index 04aa7aaad8b1..c155034a69c7 100644 --- a/BaseTools/Source/Python/Table/TableDec.py +++ b/BaseTools/Source/Python/Table/TableDec.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for dec datas # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,19 +14,21 @@ import CommonDataClass.DataClass as DataClass from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableDec +# TableDec # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableDec(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Dec' =20 - ## Create table + # Create table # # Create table Dec # @@ -61,7 +63,7 @@ class TableDec(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Dec # @@ -81,14 +83,15 @@ class TableDec(Table): # def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, = BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, E= nabled): self.ID =3D self.ID + 1 - (Value1, Value2, Value3, Arch) =3D ConvertToSqlString((Value1, Val= ue2, Value3, Arch)) + (Value1, Value2, Value3, Arch) =3D ConvertToSqlString( + (Value1, Value2, Value3, Arch)) SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', '%s', = '%s', %s, %s, %s, %s, %s, %s, %s)""" \ % (self.Table, self.ID, Model, Value1, Value2, Value3= , Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndC= olumn, Enabled) Table.Insert(self, SqlCommand) =20 return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # diff --git a/BaseTools/Source/Python/Table/TableDsc.py b/BaseTools/Source/P= ython/Table/TableDsc.py index deda001ca47b..b58c8ccb8a4b 100644 --- a/BaseTools/Source/Python/Table/TableDsc.py +++ b/BaseTools/Source/Python/Table/TableDsc.py @@ -1,5 +1,5 @@ from __future__ import absolute_import -## @file +# @file # This file is used to create/update/query/erase table for dsc datas # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,19 +14,21 @@ import CommonDataClass.DataClass as DataClass from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableDsc +# TableDsc # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableDsc(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Dsc' =20 - ## Create table + # Create table # # Create table Dsc # @@ -61,7 +63,7 @@ class TableDsc(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Dsc # @@ -81,14 +83,15 @@ class TableDsc(Table): # def Insert(self, Model, Value1, Value2, Value3, Arch, BelongsToItem, B= elongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled): self.ID =3D self.ID + 1 - (Value1, Value2, Value3, Arch) =3D ConvertToSqlString((Value1, Val= ue2, Value3, Arch)) + (Value1, Value2, Value3, Arch) =3D ConvertToSqlString( + (Value1, Value2, Value3, Arch)) SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', '%s', = '%s', %s, %s, %s, %s, %s, %s, %s)""" \ % (self.Table, self.ID, Model, Value1, Value2, Value3= , Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndC= olumn, Enabled) Table.Insert(self, SqlCommand) =20 return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # diff --git a/BaseTools/Source/Python/Table/TableEotReport.py b/BaseTools/So= urce/Python/Table/TableEotReport.py index 72bc11f6dbc2..ff23ef108c69 100644 --- a/BaseTools/Source/Python/Table/TableEotReport.py +++ b/BaseTools/Source/Python/Table/TableEotReport.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for ECC reports # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -10,25 +10,28 @@ # from __future__ import absolute_import import Common.EdkLogger as EdkLogger -import Common.LongFilePathOs as os, time +import Common.LongFilePathOs as os +import time from Table.Table import Table from Common.StringUtils import ConvertToSqlString2 import Eot.EotToolError as EotToolError import Eot.EotGlobalData as EotGlobalData =20 -## TableReport +# TableReport # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableEotReport(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Report' =20 - ## Create table + # Create table # # Create table report # @@ -51,16 +54,16 @@ class TableEotReport(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table report # # - def Insert(self, ModuleID =3D -1, ModuleName =3D '', ModuleGuid =3D ''= , SourceFileID =3D -1, SourceFileFullPath =3D '', \ - ItemName =3D '', ItemType =3D '', ItemMode =3D '', GuidName= =3D '', GuidMacro =3D '', GuidValue =3D '', BelongsToFunction =3D '', Enab= led =3D 0): + def Insert(self, ModuleID=3D-1, ModuleName=3D'', ModuleGuid=3D'', Sour= ceFileID=3D-1, SourceFileFullPath=3D'', + ItemName=3D'', ItemType=3D'', ItemMode=3D'', GuidName=3D'',= GuidMacro=3D'', GuidValue=3D'', BelongsToFunction=3D'', Enabled=3D0): self.ID =3D self.ID + 1 SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', %s, '%= s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s)""" \ - % (self.Table, self.ID, ModuleID, ModuleName, ModuleG= uid, SourceFileID, SourceFileFullPath, \ + % (self.Table, self.ID, ModuleID, ModuleName, ModuleG= uid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro,= GuidValue, BelongsToFunction, Enabled) Table.Insert(self, SqlCommand) =20 diff --git a/BaseTools/Source/Python/Table/TableFdf.py b/BaseTools/Source/P= ython/Table/TableFdf.py index 964ddd7a683c..08fcd0c1ef46 100644 --- a/BaseTools/Source/Python/Table/TableFdf.py +++ b/BaseTools/Source/Python/Table/TableFdf.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for fdf datas # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,19 +14,21 @@ import CommonDataClass.DataClass as DataClass from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableFdf +# TableFdf # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableFdf(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Fdf' =20 - ## Create table + # Create table # # Create table Fdf # @@ -62,7 +64,7 @@ class TableFdf(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Fdf # @@ -82,14 +84,15 @@ class TableFdf(Table): # def Insert(self, Model, Value1, Value2, Value3, Scope1, Scope2, Belong= sToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled= ): self.ID =3D self.ID + 1 - (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString((V= alue1, Value2, Value3, Scope1, Scope2)) + (Value1, Value2, Value3, Scope1, Scope2) =3D ConvertToSqlString( + (Value1, Value2, Value3, Scope1, Scope2)) SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', '%s', = '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \ % (self.Table, self.ID, Model, Value1, Value2, Value3= , Scope1, Scope2, BelongsToItem, BelongsToFile, StartLine, StartColumn, End= Line, EndColumn, Enabled) Table.Insert(self, SqlCommand) =20 return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # diff --git a/BaseTools/Source/Python/Table/TableFile.py b/BaseTools/Source/= Python/Table/TableFile.py index c54c389872bd..8fbff54a0973 100644 --- a/BaseTools/Source/Python/Table/TableFile.py +++ b/BaseTools/Source/Python/Table/TableFile.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for files # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -15,18 +15,20 @@ from Common.StringUtils import ConvertToSqlString import Common.LongFilePathOs as os from CommonDataClass.DataClass import FileClass =20 -## TableFile +# TableFile # # This class defined a table used for file # # @param object: Inherited from object class # + + class TableFile(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'File' =20 - ## Create table + # Create table # # Create table File # @@ -49,7 +51,7 @@ class TableFile(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table File # @@ -63,13 +65,14 @@ class TableFile(Table): # def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp): self.ID =3D self.ID + 1 - (Name, ExtName, Path, FullPath) =3D ConvertToSqlString((Name, ExtN= ame, Path, FullPath)) + (Name, ExtName, Path, FullPath) =3D ConvertToSqlString( + (Name, ExtName, Path, FullPath)) SqlCommand =3D """insert into %s values(%s, '%s', '%s', '%s', '%s'= , %s, '%s')""" \ - % (self.Table, self.ID, Name, E= xtName, Path, FullPath, Model, TimeStamp) + % (self.Table, self.ID, Name, ExtName, Path, FullPath, Model, = TimeStamp) Table.Insert(self, SqlCommand) =20 return self.ID - ## InsertFile + # InsertFile # # Insert one file to table # @@ -78,21 +81,24 @@ class TableFile(Table): # # @retval FileID: The ID after record is inserted # + def InsertFile(self, FileFullPath, Model): (Filepath, Name) =3D os.path.split(FileFullPath) (Root, Ext) =3D os.path.splitext(FileFullPath) TimeStamp =3D os.stat(FileFullPath)[8] - File =3D FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '= ', [], [], []) + File =3D FileClass(-1, Name, Ext, Filepath, + FileFullPath, Model, '', [], [], []) return self.Insert(File.Name, File.ExtName, File.Path, File.FullPa= th, File.Model, TimeStamp) =20 - ## Get ID of a given file + # Get ID of a given file # # @param FilePath Path of file # # @retval ID ID value of given file in the table # def GetFileId(self, File): - QueryScript =3D "select ID from %s where FullPath =3D '%s'" % (sel= f.Table, str(File)) + QueryScript =3D "select ID from %s where FullPath =3D '%s'" % ( + self.Table, str(File)) RecordList =3D self.Exec(QueryScript) if len(RecordList) =3D=3D 0: return None diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Sou= rce/Python/Table/TableFunction.py index 69d240b9a7d6..429769b426a4 100644 --- a/BaseTools/Source/Python/Table/TableFunction.py +++ b/BaseTools/Source/Python/Table/TableFunction.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for functions # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -13,18 +13,20 @@ import Common.EdkLogger as EdkLogger from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableFunction +# TableFunction # # This class defined a table used for function # # @param Table: Inherited from Table class # + + class TableFunction(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Function' =20 - ## Create table + # Create table # # Create table Function # @@ -61,7 +63,7 @@ class TableFunction(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Function # @@ -82,9 +84,10 @@ class TableFunction(Table): # def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, S= tartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFi= le, FunNameStartLine, FunNameStartColumn): self.ID =3D self.ID + 1 - (Header, Modifier, Name, ReturnStatement) =3D ConvertToSqlString((= Header, Modifier, Name, ReturnStatement)) + (Header, Modifier, Name, ReturnStatement) =3D ConvertToSqlString( + (Header, Modifier, Name, ReturnStatement)) SqlCommand =3D """insert into %s values(%s, '%s', '%s', '%s', '%s'= , %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \ - % (self.Table, self.ID, Header, Modifi= er, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, Body= StartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartCo= lumn) + % (self.Table, self.ID, Header, Modifier, Name, ReturnStatemen= t, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColu= mn, BelongsToFile, FunNameStartLine, FunNameStartColumn) Table.Insert(self, SqlCommand) =20 return self.ID diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/S= ource/Python/Table/TableIdentifier.py index 99f5023e965e..a34e1b5a76ba 100644 --- a/BaseTools/Source/Python/Table/TableIdentifier.py +++ b/BaseTools/Source/Python/Table/TableIdentifier.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for Identifiers # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -13,19 +13,21 @@ import Common.EdkLogger as EdkLogger from Common.StringUtils import ConvertToSqlString from Table.Table import Table =20 -## TableIdentifier +# TableIdentifier # # This class defined a table used for Identifier # # @param object: Inherited from object class # # + + class TableIdentifier(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Identifier' =20 - ## Create table + # Create table # # Create table Identifier # @@ -58,7 +60,7 @@ class TableIdentifier(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Identifier # @@ -77,9 +79,10 @@ class TableIdentifier(Table): # def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, Be= longsToFunction, StartLine, StartColumn, EndLine, EndColumn): self.ID =3D self.ID + 1 - (Modifier, Type, Name, Value) =3D ConvertToSqlString((Modifier, Ty= pe, Name, Value)) + (Modifier, Type, Name, Value) =3D ConvertToSqlString( + (Modifier, Type, Name, Value)) SqlCommand =3D """insert into %s values(%s, '%s', '%s', '%s', '%s'= , %s, %s, %s, %s, %s, %s, %s)""" \ - % (self.Table, self.ID, Modifie= r, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, S= tartColumn, EndLine, EndColumn) + % (self.Table, self.ID, Modifier, Type, Name, Value, Model, Be= longsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn) Table.Insert(self, SqlCommand) =20 return self.ID diff --git a/BaseTools/Source/Python/Table/TableInf.py b/BaseTools/Source/P= ython/Table/TableInf.py index 54af88c37da5..9a38cf68ba0f 100644 --- a/BaseTools/Source/Python/Table/TableInf.py +++ b/BaseTools/Source/Python/Table/TableInf.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for inf datas # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,19 +14,21 @@ import CommonDataClass.DataClass as DataClass from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TableInf +# TableInf # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableInf(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Inf' =20 - ## Create table + # Create table # # Create table Inf # @@ -65,7 +67,7 @@ class TableInf(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Inf # @@ -87,14 +89,15 @@ class TableInf(Table): # def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, = BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, E= nabled): self.ID =3D self.ID + 1 - (Value1, Value2, Value3, Value4, Value5, Arch) =3D ConvertToSqlStr= ing((Value1, Value2, Value3, Value4, Value5, Arch)) + (Value1, Value2, Value3, Value4, Value5, Arch) =3D ConvertToSqlStr= ing( + (Value1, Value2, Value3, Value4, Value5, Arch)) SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', '%s', = '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \ % (self.Table, self.ID, Model, Value1, Value2, Value3= , Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColum= n, EndLine, EndColumn, Enabled) Table.Insert(self, SqlCommand) =20 return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # diff --git a/BaseTools/Source/Python/Table/TablePcd.py b/BaseTools/Source/P= ython/Table/TablePcd.py index f1e9f578173e..2966e8f0d622 100644 --- a/BaseTools/Source/Python/Table/TablePcd.py +++ b/BaseTools/Source/Python/Table/TablePcd.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for pcds # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -13,19 +13,21 @@ import Common.EdkLogger as EdkLogger from Table.Table import Table from Common.StringUtils import ConvertToSqlString =20 -## TablePcd +# TablePcd # # This class defined a table used for pcds # # @param object: Inherited from object class # # + + class TablePcd(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Pcd' =20 - ## Create table + # Create table # # Create table Pcd # @@ -58,7 +60,7 @@ class TablePcd(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Pcd # @@ -77,9 +79,10 @@ class TablePcd(Table): # def Insert(self, CName, TokenSpaceGuidCName, Token, DatumType, Model, = BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColum= n): self.ID =3D self.ID + 1 - (CName, TokenSpaceGuidCName, DatumType) =3D ConvertToSqlString((CN= ame, TokenSpaceGuidCName, DatumType)) + (CName, TokenSpaceGuidCName, DatumType) =3D ConvertToSqlString( + (CName, TokenSpaceGuidCName, DatumType)) SqlCommand =3D """insert into %s values(%s, '%s', '%s', %s, '%s', = %s, %s, %s, %s, %s, %s, %s)""" \ - % (self.Table, self.ID, CName, = TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunct= ion, StartLine, StartColumn, EndLine, EndColumn) + % (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, Dat= umType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, En= dLine, EndColumn) Table.Insert(self, SqlCommand) =20 return self.ID diff --git a/BaseTools/Source/Python/Table/TableQuery.py b/BaseTools/Source= /Python/Table/TableQuery.py index 3e66fbfc9da8..ca4844e0f034 100644 --- a/BaseTools/Source/Python/Table/TableQuery.py +++ b/BaseTools/Source/Python/Table/TableQuery.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for Queries # # Copyright (c) 2008, Intel Corporation. All rights reserved.
        @@ -13,19 +13,21 @@ import Common.EdkLogger as EdkLogger from Common.StringUtils import ConvertToSqlString from Table.Table import Table =20 -## TableQuery +# TableQuery # # This class defined a table used for Query # # @param object: Inherited from object class # # + + class TableQuery(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Query' =20 - ## Create table + # Create table # # Create table Query # @@ -44,7 +46,7 @@ class TableQuery(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table Query # @@ -57,7 +59,7 @@ class TableQuery(Table): def Insert(self, Name, Modifier, Value, Model): self.ID =3D self.ID + 1 SqlCommand =3D """insert into %s values(%s, '%s', '%s', '%s', %s)"= "" \ - % (self.Table, self.ID, Name, M= odifier, Value, Model) + % (self.Table, self.ID, Name, Modifier, Value, Model) Table.Insert(self, SqlCommand) =20 return self.ID diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Sourc= e/Python/Table/TableReport.py index 0a77787d8f48..da32bb89094c 100644 --- a/BaseTools/Source/Python/Table/TableReport.py +++ b/BaseTools/Source/Python/Table/TableReport.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for ECC reports # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -10,26 +10,29 @@ # from __future__ import absolute_import import Common.EdkLogger as EdkLogger -import Common.LongFilePathOs as os, time +import Common.LongFilePathOs as os +import time from Table.Table import Table from Common.StringUtils import ConvertToSqlString2 import Ecc.EccToolError as EccToolError import Ecc.EccGlobalData as EccGlobalData from Common.LongFilePathSupport import OpenLongFilePath as open =20 -## TableReport +# TableReport # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableReport(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table =3D 'Report' =20 - ## Create table + # Create table # # Create table report # @@ -51,7 +54,7 @@ class TableReport(Table): )""" % self.Table Table.Create(self, SqlCommand) =20 - ## Insert table + # Insert table # # Insert a record into table report # @@ -63,7 +66,7 @@ class TableReport(Table): # @param Enabled: If this error enabled # @param Corrected: if this error corrected # - def Insert(self, ErrorID, OtherMsg=3D'', BelongsToTable=3D'', BelongsT= oItem=3D -1, Enabled=3D0, Corrected=3D -1): + def Insert(self, ErrorID, OtherMsg=3D'', BelongsToTable=3D'', BelongsT= oItem=3D-1, Enabled=3D0, Corrected=3D-1): self.ID =3D self.ID + 1 SqlCommand =3D """insert into %s values(%s, %s, '%s', '%s', %s, %s= , %s)""" \ % (self.Table, self.ID, ErrorID, ConvertToSqlString2(= OtherMsg), BelongsToTable, BelongsToItem, Enabled, Corrected) @@ -71,7 +74,7 @@ class TableReport(Table): =20 return self.ID =20 - ## Query table + # Query table # # @retval: A recordSet of all found records # @@ -80,14 +83,14 @@ class TableReport(Table): where Enabled > -1 order by ErrorID, BelongsToItem= """ % (self.Table) return self.Exec(SqlCommand) =20 - ## Update table + # Update table # def UpdateBelongsToItemByFile(self, ItemID=3D-1, File=3D""): SqlCommand =3D """update Report set BelongsToItem=3D%s where Belon= gsToTable=3D'File' and BelongsToItem=3D-2 and OtherMsg like '%%%s%%'""" % (ItemID, File) return self.Exec(SqlCommand) =20 - ## Convert to CSV + # Convert to CSV # # Get all enabled records from table report and save them to a .csv fi= le # @@ -96,7 +99,8 @@ class TableReport(Table): def ToCSV(self, Filename=3D'Report.csv'): try: File =3D open(Filename, 'w+') - File.write("""No, Error Code, Error Message, File, LineNo, Oth= er Error Message\n""") + File.write( + """No, Error Code, Error Message, File, LineNo, Other Erro= r Message\n""") RecordSet =3D self.Query() Index =3D 0 for Record in RecordSet: @@ -116,12 +120,15 @@ class TableReport(Table): """ % (BelongsToTable, BelongsToItem) NewRecord =3D self.Exec(SqlCommand) if NewRecord !=3D []: - File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, Err= orID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0]= [0], OtherMsg)) - EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1]= , NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMs= g)) + File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % ( + Index, ErrorID, EccToolError.gEccErrorMessage[Erro= rID], NewRecord[0][1], NewRecord[0][0], OtherMsg)) + EdkLogger.quiet("%s(%s): [%s]%s %s" % ( + NewRecord[0][1], NewRecord[0][0], ErrorID, EccTool= Error.gEccErrorMessage[ErrorID], OtherMsg)) =20 File.close() except IOError: - NewFilename =3D 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv",= time.localtime()) - EdkLogger.warn("ECC", "The report file %s is locked by other p= rogress, use %s instead!" % (Filename, NewFilename)) + NewFilename =3D 'Report_' + \ + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime()) + EdkLogger.warn("ECC", "The report file %s is locked by other p= rogress, use %s instead!" % ( + Filename, NewFilename)) self.ToCSV(NewFilename) - diff --git a/BaseTools/Source/Python/Table/__init__.py b/BaseTools/Source/P= ython/Table/__init__.py index e901914f30a8..caa82844e967 100644 --- a/BaseTools/Source/Python/Table/__init__.py +++ b/BaseTools/Source/Python/Table/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Table' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/S= ource/Python/TargetTool/TargetTool.py index 7f2479f0f0ac..61276661b647 100644 --- a/BaseTools/Source/Python/TargetTool/TargetTool.py +++ b/BaseTools/Source/Python/TargetTool/TargetTool.py @@ -1,4 +1,4 @@ -## @file +# @file # Target Tool Parser # # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
        @@ -21,23 +21,25 @@ from Common.TargetTxtClassObject import gDefaultTargetT= xtFile =20 # To Do 1.set clean, 2. add item, if the line is disabled. =20 + class TargetTool(): def __init__(self, opt, args): self.WorkSpace =3D os.path.normpath(os.getenv('WORKSPACE')) - self.Opt =3D opt - self.Arg =3D args[0] - self.FileName =3D os.path.normpath(os.path.join(self.WorkSpace, '= Conf', gDefaultTargetTxtFile)) + self.Opt =3D opt + self.Arg =3D args[0] + self.FileName =3D os.path.normpath(os.path.join( + self.WorkSpace, 'Conf', gDefaultTargetTxtFile)) if os.path.isfile(self.FileName) =3D=3D False: print("%s does not exist." % self.FileName) sys.exit(1) self.TargetTxtDictionary =3D { - TAB_TAT_DEFINES_ACTIVE_PLATFORM : N= one, - TAB_TAT_DEFINES_TOOL_CHAIN_CONF : N= one, - TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : N= one, - TAB_TAT_DEFINES_TARGET : N= one, - TAB_TAT_DEFINES_TOOL_CHAIN_TAG : N= one, - TAB_TAT_DEFINES_TARGET_ARCH : N= one, - TAB_TAT_DEFINES_BUILD_RULE_CONF : N= one, + TAB_TAT_DEFINES_ACTIVE_PLATFORM: None, + TAB_TAT_DEFINES_TOOL_CHAIN_CONF: None, + TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER: None, + TAB_TAT_DEFINES_TARGET: None, + TAB_TAT_DEFINES_TOOL_CHAIN_TAG: None, + TAB_TAT_DEFINES_TARGET_ARCH: None, + TAB_TAT_DEFINES_BUILD_RULE_CONF: None, } self.LoadTargetTxtFile(self.FileName) =20 @@ -45,7 +47,8 @@ class TargetTool(): if os.path.exists(filename) and os.path.isfile(filename): return self.ConvertTextFileToDict(filename, '#', '=3D') else: - raise ParseError('LoadTargetTxtFile() : No Target.txt file exi= sts.') + raise ParseError( + 'LoadTargetTxtFile() : No Target.txt file exists.') return 1 =20 # @@ -63,11 +66,12 @@ class TargetTool(): Key =3D LineList[0].strip() if Key.startswith(CommentCharacter) =3D=3D False and K= ey in self.TargetTxtDictionary: if Key =3D=3D TAB_TAT_DEFINES_ACTIVE_PLATFORM or K= ey =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_CONF \ - or Key =3D=3D TAB_TAT_DEFINES_MAX_CONCURRENT_THR= EAD_NUMBER \ - or Key =3D=3D TAB_TAT_DEFINES_ACTIVE_MODULE: - self.TargetTxtDictionary[Key] =3D LineList[1].= replace('\\', '/').strip() + or Key =3D=3D TAB_TAT_DEFINES_MAX_CONCURRE= NT_THREAD_NUMBER \ + or Key =3D=3D TAB_TAT_DEFINES_ACTIVE_MODUL= E: + self.TargetTxtDictionary[Key] =3D LineList[1].= replace( + '\\', '/').strip() elif Key =3D=3D TAB_TAT_DEFINES_TARGET or Key =3D= =3D TAB_TAT_DEFINES_TARGET_ARCH \ - or Key =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_TAG or = Key =3D=3D TAB_TAT_DEFINES_BUILD_RULE_CONF: + or Key =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_T= AG or Key =3D=3D TAB_TAT_DEFINES_BUILD_RULE_CONF: self.TargetTxtDictionary[Key] =3D LineList[1].= split() f.close() return 0 @@ -76,10 +80,11 @@ class TargetTool(): traceback.print_exception(last_type, last_value, last_tb) =20 def Print(self): - errMsg =3D '' + errMsg =3D '' for Key in self.TargetTxtDictionary: if isinstance(self.TargetTxtDictionary[Key], type([])): - print("%-30s =3D %s" % (Key, ''.join(elem + ' ' for elem i= n self.TargetTxtDictionary[Key]))) + print("%-30s =3D %s" % (Key, ''.join(elem + + ' ' for elem in self.TargetTxtDictionary[Key]))) elif self.TargetTxtDictionary[Key] is None: errMsg +=3D " Missing %s configuration information, pleas= e use TargetTool to set value!" % Key + os.linesep else: @@ -91,7 +96,8 @@ class TargetTool(): def RWFile(self, CommentCharacter, KeySplitCharacter, Num): try: fr =3D open(self.FileName, 'r') - fw =3D open(os.path.normpath(os.path.join(self.WorkSpace, 'Con= f\\targetnew.txt')), 'w') + fw =3D open(os.path.normpath(os.path.join( + self.WorkSpace, 'Conf\\targetnew.txt')), 'w') =20 existKeys =3D [] for Line in fr: @@ -105,7 +111,8 @@ class TargetTool(): if Key not in existKeys: existKeys.append(Key) else: - print("Warning: Found duplicate key item i= n original configuration files!") + print( + "Warning: Found duplicate key item in = original configuration files!") =20 if Num =3D=3D 0: Line =3D "%-30s =3D \n" % Key @@ -116,7 +123,8 @@ class TargetTool(): fw.write(Line) for key in self.TargetTxtDictionary: if key not in existKeys: - print("Warning: %s does not exist in original configur= ation file" % key) + print( + "Warning: %s does not exist in original configurat= ion file" % key) Line =3D GetConfigureKeyValue(self, key) if Line is None: Line =3D "%-30s =3D " % key @@ -125,12 +133,14 @@ class TargetTool(): fr.close() fw.close() os.remove(self.FileName) - os.rename(os.path.normpath(os.path.join(self.WorkSpace, 'Conf\= \targetnew.txt')), self.FileName) + os.rename(os.path.normpath(os.path.join( + self.WorkSpace, 'Conf\\targetnew.txt')), self.FileName) =20 except: last_type, last_value, last_tb =3D sys.exc_info() traceback.print_exception(last_type, last_value, last_tb) =20 + def GetConfigureKeyValue(self, Key): Line =3D None if Key =3D=3D TAB_TAT_DEFINES_ACTIVE_PLATFORM and self.Opt.DSCFILE is = not None: @@ -141,7 +151,8 @@ def GetConfigureKeyValue(self, Key): EdkLogger.error("TargetTool", BuildToolError.FILE_NOT_FOUND, "DSC file %s does not exist!" % self.Opt.DSCFI= LE, RaiseError=3DFalse) elif Key =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFI= NITION_FILE is not None: - tooldefFullPath =3D os.path.join(self.WorkSpace, self.Opt.TOOL_DEF= INITION_FILE) + tooldefFullPath =3D os.path.join( + self.WorkSpace, self.Opt.TOOL_DEFINITION_FILE) if os.path.exists(tooldefFullPath): Line =3D "%-30s =3D %s\n" % (Key, self.Opt.TOOL_DEFINITION_FIL= E) else: @@ -155,13 +166,16 @@ def GetConfigureKeyValue(self, Key): elif Key =3D=3D TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.= Opt.NUM is not None: Line =3D "%-30s =3D %s\n" % (Key, str(self.Opt.NUM)) elif Key =3D=3D TAB_TAT_DEFINES_TARGET and self.Opt.TARGET is not None: - Line =3D "%-30s =3D %s\n" % (Key, ''.join(elem + ' ' for elem in s= elf.Opt.TARGET)) + Line =3D "%-30s =3D %s\n" % (Key, ''.join(elem + + ' ' for elem in self.Opt.TARGET)) elif Key =3D=3D TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH i= s not None: - Line =3D "%-30s =3D %s\n" % (Key, ''.join(elem + ' ' for elem in s= elf.Opt.TARGET_ARCH)) + Line =3D "%-30s =3D %s\n" % (Key, ''.join(elem + + ' ' for elem in self.Opt.TARGET_ARCH)) elif Key =3D=3D TAB_TAT_DEFINES_TOOL_CHAIN_TAG and self.Opt.TOOL_CHAIN= _TAG is not None: Line =3D "%-30s =3D %s\n" % (Key, self.Opt.TOOL_CHAIN_TAG) elif Key =3D=3D TAB_TAT_DEFINES_BUILD_RULE_CONF and self.Opt.BUILD_RUL= E_FILE is not None: - buildruleFullPath =3D os.path.join(self.WorkSpace, self.Opt.BUILD_= RULE_FILE) + buildruleFullPath =3D os.path.join( + self.WorkSpace, self.Opt.BUILD_RULE_FILE) if os.path.exists(buildruleFullPath): Line =3D "%-30s =3D %s\n" % (Key, self.Opt.BUILD_RULE_FILE) else: @@ -169,6 +183,7 @@ def GetConfigureKeyValue(self, Key): "Build rule file %s does not exist!" % self.Op= t.BUILD_RULE_FILE, RaiseError=3DFalse) return Line =20 + VersionNumber =3D ("0.01" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + VersionNumber __copyright__ =3D "Copyright (c) 2007 - 2018, Intel Corporation All right= s reserved." @@ -179,42 +194,51 @@ __usage__ =3D "%prog [options] {args} \ \n Set replace the default configuration with expected value specified = by option." =20 gParamCheck =3D [] + + def SingleCheckCallback(option, opt_str, value, parser): if option not in gParamCheck: setattr(parser.values, option.dest, value) gParamCheck.append(option) else: - parser.error("Option %s only allows one instance in command line!"= % option) + parser.error( + "Option %s only allows one instance in command line!" % option) + =20 def RangeCheckCallback(option, opt_str, value, parser): if option not in gParamCheck: gParamCheck.append(option) if value < 1 or value > 8: - parser.error("The count of multi-thread is not in valid range = of 1 ~ 8.") + parser.error( + "The count of multi-thread is not in valid range of 1 ~ 8.= ") else: setattr(parser.values, option.dest, value) else: - parser.error("Option %s only allows one instance in command line!"= % option) + parser.error( + "Option %s only allows one instance in command line!" % option) + =20 def MyOptionParser(): - parser =3D OptionParser(version=3D__version__, prog=3D"TargetTool.exe"= , usage=3D__usage__, description=3D__copyright__) + parser =3D OptionParser(version=3D__version__, prog=3D"TargetTool.exe", + usage=3D__usage__, description=3D__copyright__) parser.add_option("-a", "--arch", action=3D"append", dest=3D"TARGET_AR= CH", - help=3D"ARCHS is one of list: IA32, X64, ARM, AARCH64 or EBC, whic= h replaces target.txt's TARGET_ARCH definition. To specify more archs, plea= se repeat this option. 0 will clear this setting in target.txt and can't co= mbine with other value.") + help=3D"ARCHS is one of list: IA32, X64, ARM, AARCH6= 4 or EBC, which replaces target.txt's TARGET_ARCH definition. To specify mo= re archs, please repeat this option. 0 will clear this setting in target.tx= t and can't combine with other value.") parser.add_option("-p", "--platform", action=3D"callback", type=3D"str= ing", dest=3D"DSCFILE", callback=3DSingleCheckCallback, - help=3D"Specify a DSC file, which replace target.txt's ACTIVE_PLAT= FORM definition. 0 will clear this setting in target.txt and can't combine = with other value.") + help=3D"Specify a DSC file, which replace target.txt= 's ACTIVE_PLATFORM definition. 0 will clear this setting in target.txt and = can't combine with other value.") parser.add_option("-c", "--tooldef", action=3D"callback", type=3D"stri= ng", dest=3D"TOOL_DEFINITION_FILE", callback=3DSingleCheckCallback, - help=3D"Specify the WORKSPACE relative path of tool_def.txt file, = which replace target.txt's TOOL_CHAIN_CONF definition. 0 will clear this se= tting in target.txt and can't combine with other value.") + help=3D"Specify the WORKSPACE relative path of tool_= def.txt file, which replace target.txt's TOOL_CHAIN_CONF definition. 0 will= clear this setting in target.txt and can't combine with other value.") parser.add_option("-t", "--target", action=3D"append", type=3D"choice"= , choices=3D['DEBUG', 'RELEASE', '0'], dest=3D"TARGET", - help=3D"TARGET is one of list: DEBUG, RELEASE, which replaces targ= et.txt's TARGET definition. To specify more TARGET, please repeat this opti= on. 0 will clear this setting in target.txt and can't combine with other va= lue.") + help=3D"TARGET is one of list: DEBUG, RELEASE, which= replaces target.txt's TARGET definition. To specify more TARGET, please re= peat this option. 0 will clear this setting in target.txt and can't combine= with other value.") parser.add_option("-n", "--tagname", action=3D"callback", type=3D"stri= ng", dest=3D"TOOL_CHAIN_TAG", callback=3DSingleCheckCallback, - help=3D"Specify the Tool Chain Tagname, which replaces target.txt'= s TOOL_CHAIN_TAG definition. 0 will clear this setting in target.txt and ca= n't combine with other value.") + help=3D"Specify the Tool Chain Tagname, which replac= es target.txt's TOOL_CHAIN_TAG definition. 0 will clear this setting in tar= get.txt and can't combine with other value.") parser.add_option("-r", "--buildrule", action=3D"callback", type=3D"st= ring", dest=3D"BUILD_RULE_FILE", callback=3DSingleCheckCallback, - help=3D"Specify the build rule configure file, which replaces targ= et.txt's BUILD_RULE_CONF definition. If not specified, the default value Co= nf/build_rule.txt will be set.") + help=3D"Specify the build rule configure file, which= replaces target.txt's BUILD_RULE_CONF definition. If not specified, the de= fault value Conf/build_rule.txt will be set.") parser.add_option("-m", "--multithreadnum", action=3D"callback", type= =3D"int", dest=3D"NUM", callback=3DRangeCheckCallback, - help=3D"Specify the multi-thread number which replace target.txt's= MAX_CONCURRENT_THREAD_NUMBER. If the value is less than 2, MULTIPLE_THREAD= will be disabled. If the value is larger than 1, MULTIPLE_THREAD will be e= nabled.") - (opt, args)=3Dparser.parse_args() + help=3D"Specify the multi-thread number which replac= e target.txt's MAX_CONCURRENT_THREAD_NUMBER. If the value is less than 2, M= ULTIPLE_THREAD will be disabled. If the value is larger than 1, MULTIPLE_TH= READ will be enabled.") + (opt, args) =3D parser.parse_args() return (opt, args) =20 + if __name__ =3D=3D '__main__': EdkLogger.Initialize() EdkLogger.SetLevel(EdkLogger.QUIET) @@ -232,12 +256,14 @@ if __name__ =3D=3D '__main__': if opt.TARGET is not None and len(opt.TARGET) > 1: for elem in opt.TARGET: if elem =3D=3D '0': - print("0 will clear the TARGET setting in target.txt and c= an't combine with other value.") + print( + "0 will clear the TARGET setting in target.txt and can= 't combine with other value.") sys.exit(1) if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1: for elem in opt.TARGET_ARCH: if elem =3D=3D '0': - print("0 will clear the TARGET_ARCH setting in target.txt = and can't combine with other value.") + print( + "0 will clear the TARGET_ARCH setting in target.txt an= d can't combine with other value.") sys.exit(1) =20 try: @@ -252,4 +278,3 @@ if __name__ =3D=3D '__main__': except Exception as e: last_type, last_value, last_tb =3D sys.exc_info() traceback.print_exception(last_type, last_value, last_tb) - diff --git a/BaseTools/Source/Python/TargetTool/__init__.py b/BaseTools/Sou= rce/Python/TargetTool/__init__.py index ae712b44aa9c..48b55bd4f367 100644 --- a/BaseTools/Source/Python/TargetTool/__init__.py +++ b/BaseTools/Source/Python/TargetTool/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'TargetTool' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index c479f7d2b2e7..cffca972d219 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -1,4 +1,4 @@ -## @file +# @file # Trim files preprocessed by compiler # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -27,43 +27,51 @@ __version_number__ =3D ("0.10" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + __version_number__ __copyright__ =3D "Copyright (c) 2007-2018, Intel Corporation. All rights = reserved." =20 -## Regular expression for matching Line Control directive like "#line xxx" +# Regular expression for matching Line Control directive like "#line xxx" gLineControlDirective =3D re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*= )"') -## Regular expression for matching "typedef struct" -gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re= .MULTILINE) -## Regular expression for matching "#pragma pack" +# Regular expression for matching "typedef struct" +gTypedefPattern =3D re.compile( + "^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re.MULTILINE) +# Regular expression for matching "#pragma pack" gPragmaPattern =3D re.compile("^\s*#pragma\s+pack", re.MULTILINE) -## Regular expression for matching "typedef" +# Regular expression for matching "typedef" gTypedef_SinglePattern =3D re.compile("^\s*typedef", re.MULTILINE) -## Regular expression for matching "typedef struct, typedef union, struct,= union" -gTypedef_MulPattern =3D re.compile("^\s*(typedef)?\s+(struct|union)(\s+\w+= )?\s*[{]*$", re.MULTILINE) +# Regular expression for matching "typedef struct, typedef union, struct, = union" +gTypedef_MulPattern =3D re.compile( + "^\s*(typedef)?\s+(struct|union)(\s+\w+)?\s*[{]*$", re.MULTILINE) =20 # # The following number pattern match will only match if following criteria= is met: # There is leading non-(alphanumeric or _) character, and no following alp= hanumeric or _ # as the pattern is greedily match, so it is ok for the gDecNumberPattern = or gHexNumberPattern to grab the maximum match # -## Regular expression for matching HEX number -gHexNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+= )(U(?=3D$|[^a-zA-Z0-9_]))?") -## Regular expression for matching decimal number with 'U' postfix -gDecNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-= zA-Z0-9_])") -## Regular expression for matching constant with 'ULL' 'LL' postfix -gLongNumberPattern =3D re.compile("(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|= [0-9]+)U?LL(?=3D$|[^a-zA-Z0-9_])") +# Regular expression for matching HEX number +gHexNumberPattern =3D re.compile( + "(?<=3D[^a-zA-Z0-9_])(0[xX])([0-9a-fA-F]+)(U(?=3D$|[^a-zA-Z0-9_]))?") +# Regular expression for matching decimal number with 'U' postfix +gDecNumberPattern =3D re.compile( + "(?<=3D[^a-zA-Z0-9_])([0-9]+)U(?=3D$|[^a-zA-Z0-9_])") +# Regular expression for matching constant with 'ULL' 'LL' postfix +gLongNumberPattern =3D re.compile( + "(?<=3D[^a-zA-Z0-9_])(0[xX][0-9a-fA-F]+|[0-9]+)U?LL(?=3D$|[^a-zA-Z0-9_= ])") =20 -## Regular expression for matching "Include ()" in asl file -gAslIncludePattern =3D re.compile("^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\= )", re.MULTILINE) -## Regular expression for matching C style #include "XXX.asl" in asl file -gAslCIncludePattern =3D re.compile(r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\= s*([>"])', re.MULTILINE) -## Patterns used to convert EDK conventions to EDK2 ECP conventions +# Regular expression for matching "Include ()" in asl file +gAslIncludePattern =3D re.compile( + "^(\s*)[iI]nclude\s*\(\"?([^\"\(\)]+)\"\)", re.MULTILINE) +# Regular expression for matching C style #include "XXX.asl" in asl file +gAslCIncludePattern =3D re.compile( + r'^(\s*)#include\s*[<"]\s*([-\\/\w.]+)\s*([>"])', re.MULTILINE) +# Patterns used to convert EDK conventions to EDK2 ECP conventions =20 -## Regular expression for finding header file inclusions -gIncludePattern =3D re.compile(r"^[ \t]*[%]?[ \t]*include(?:[ \t]*(?:\\(?:= \r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?= )", re.MULTILINE | re.UNICODE | re.IGNORECASE) +# Regular expression for finding header file inclusions +gIncludePattern =3D re.compile( + r"^[ \t]*[%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?= [\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICO= DE | re.IGNORECASE) =20 =20 -## file cache to avoid circular include in ASL file +# file cache to avoid circular include in ASL file gIncludedAslFile =3D [] =20 -## Trim preprocessed source code +# Trim preprocessed source code # # Remove extra content made by preprocessor. The preprocessor must enable = the # line number generation option when preprocessing. @@ -72,6 +80,8 @@ gIncludedAslFile =3D [] # @param Target File to store the trimmed content # @param Convert If True, convert standard HEX format to MASM format # + + def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): CreateDirectory(os.path.dirname(Target)) try: @@ -80,7 +90,8 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, Trim= Long): except IOError: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DSource) except: - EdkLogger.error("Trim", AUTOGEN_ERROR, "TrimPreprocessedFile: Erro= r while processing file", File=3DSource) + EdkLogger.error("Trim", AUTOGEN_ERROR, + "TrimPreprocessedFile: Error while processing file= ", File=3DSource) =20 PreprocessedFile =3D "" InjectedFile =3D "" @@ -183,7 +194,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, Tr= imLong): except: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DTarget) =20 -## Trim preprocessed VFR file +# Trim preprocessed VFR file # # Remove extra content made by preprocessor. The preprocessor doesn't need= to # enable line number generation option when preprocessing. @@ -191,6 +202,8 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, Tr= imLong): # @param Source File to be trimmed # @param Target File to store the trimmed content # + + def TrimPreprocessedVfr(Source, Target): CreateDirectory(os.path.dirname(Target)) =20 @@ -248,7 +261,7 @@ def TrimPreprocessedVfr(Source, Target): except: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DTarget) =20 -## Read the content ASL file, including ASL included, recursively +# Read the content ASL file, including ASL included, recursively # # @param Source File to be read # @param Indent Spaces before the Include() statement @@ -257,7 +270,9 @@ def TrimPreprocessedVfr(Source, Target): # first for the included file; otherwise, only t= he path specified # in the IncludePathList will be searched. # -def DoInclude(Source, Indent=3D'', IncludePathList=3D[], LocalSearchPath= =3DNone, IncludeFileList =3D None, filetype=3DNone): + + +def DoInclude(Source, Indent=3D'', IncludePathList=3D[], LocalSearchPath= =3DNone, IncludeFileList=3DNone, filetype=3DNone): NewFileContent =3D [] if IncludeFileList is None: IncludeFileList =3D [] @@ -287,12 +302,11 @@ def DoInclude(Source, Indent=3D'', IncludePathList=3D= [], LocalSearchPath=3DNone, Inclu EdkLogger.warn("Trim", FILE_OPEN_FAILURE, ExtraData=3DSource) return [] =20 - # avoid A "include" B and B "include" A IncludeFile =3D os.path.abspath(os.path.normpath(IncludeFile)) if IncludeFile in gIncludedAslFile: EdkLogger.warn("Trim", "Circular include", - ExtraData=3D "%s -> %s" % (" -> ".join(gIncludedAsl= File), IncludeFile)) + ExtraData=3D"%s -> %s" % (" -> ".join(gIncludedAslF= ile), IncludeFile)) return [] gIncludedAslFile.append(IncludeFile) IncludeFileList.append(IncludeFile.strip()) @@ -312,7 +326,8 @@ def DoInclude(Source, Indent=3D'', IncludePathList=3D[]= , LocalSearchPath=3DNone, Inclu LocalSearchPath =3D os.path.dirname(IncludeFile) CurrentIndent =3D Indent + Result[0][0] IncludedFile =3D Result[0][1] - NewFileContent.extend(DoInclude(IncludedFile, CurrentIndent, I= ncludePathList, LocalSearchPath,IncludeFileList,filetype)) + NewFileContent.extend(DoInclude( + IncludedFile, CurrentIndent, IncludePathList, LocalSearchP= ath, IncludeFileList, filetype)) NewFileContent.append("\n") elif filetype =3D=3D "ASM": Result =3D gIncludePattern.findall(Line) @@ -324,7 +339,8 @@ def DoInclude(Source, Indent=3D'', IncludePathList=3D[]= , LocalSearchPath=3DNone, Inclu =20 IncludedFile =3D IncludedFile.strip() IncludedFile =3D os.path.normpath(IncludedFile) - NewFileContent.extend(DoInclude(IncludedFile, '', IncludePathL= ist, LocalSearchPath,IncludeFileList,filetype)) + NewFileContent.extend(DoInclude( + IncludedFile, '', IncludePathList, LocalSearchPath, Includ= eFileList, filetype)) NewFileContent.append("\n") =20 gIncludedAslFile.pop() @@ -332,7 +348,7 @@ def DoInclude(Source, Indent=3D'', IncludePathList=3D[]= , LocalSearchPath=3DNone, Inclu return NewFileContent =20 =20 -## Trim ASL file +# Trim ASL file # # Replace ASL include statement with the content the included file # @@ -340,7 +356,7 @@ def DoInclude(Source, Indent=3D'', IncludePathList=3D[]= , LocalSearchPath=3DNone, Inclu # @param Target File to store the trimmed content # @param IncludePathFile The file to log the external include path # -def TrimAslFile(Source, Target, IncludePathFile,AslDeps =3D False): +def TrimAslFile(Source, Target, IncludePathFile, AslDeps=3DFalse): CreateDirectory(os.path.dirname(Target)) =20 SourceDir =3D os.path.dirname(Source) @@ -363,16 +379,20 @@ def TrimAslFile(Source, Target, IncludePathFile,AslDe= ps =3D False): FileLines =3D File.readlines() for Line in FileLines: LineNum +=3D 1 - if Line.startswith("/I") or Line.startswith ("-I"): + if Line.startswith("/I") or Line.startswith("-I"): IncludePathList.append(Line[2:].strip()) else: - EdkLogger.warn("Trim", "Invalid include line in includ= e list file.", IncludePathFile, LineNum) + EdkLogger.warn( + "Trim", "Invalid include line in include list file= .", IncludePathFile, LineNum) except: - EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DInclude= PathFile) + EdkLogger.error("Trim", FILE_OPEN_FAILURE, + ExtraData=3DIncludePathFile) AslIncludes =3D [] - Lines =3D DoInclude(Source, '', IncludePathList,IncludeFileList=3DAslI= ncludes,filetype=3D'ASL') - AslIncludes =3D [item for item in AslIncludes if item !=3DSource] - SaveFileOnChange(os.path.join(os.path.dirname(Target),os.path.basename= (Source))+".trim.deps", " \\\n".join([Source+":"] +AslIncludes),False) + Lines =3D DoInclude(Source, '', IncludePathList, + IncludeFileList=3DAslIncludes, filetype=3D'ASL') + AslIncludes =3D [item for item in AslIncludes if item !=3D Source] + SaveFileOnChange(os.path.join(os.path.dirname(Target), os.path.basenam= e( + Source))+".trim.deps", " \\\n".join([Source+":"] + AslIncludes), F= alse) =20 # # Undef MIN and MAX to avoid collision in ASL source code @@ -386,7 +406,7 @@ def TrimAslFile(Source, Target, IncludePathFile,AslDeps= =3D False): except: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DTarget) =20 -## Trim ASM file +# Trim ASM file # # Output ASM include statement with the content the included file # @@ -394,6 +414,8 @@ def TrimAslFile(Source, Target, IncludePathFile,AslDeps= =3D False): # @param Target File to store the trimmed content # @param IncludePathFile The file to log the external include path # + + def TrimAsmFile(Source, Target, IncludePathFile): CreateDirectory(os.path.dirname(Target)) =20 @@ -416,17 +438,21 @@ def TrimAsmFile(Source, Target, IncludePathFile): FileLines =3D File.readlines() for Line in FileLines: LineNum +=3D 1 - if Line.startswith("/I") or Line.startswith ("-I"): + if Line.startswith("/I") or Line.startswith("-I"): IncludePathList.append(Line[2:].strip()) else: - EdkLogger.warn("Trim", "Invalid include line in includ= e list file.", IncludePathFile, LineNum) + EdkLogger.warn( + "Trim", "Invalid include line in include list file= .", IncludePathFile, LineNum) except: - EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DInclude= PathFile) + EdkLogger.error("Trim", FILE_OPEN_FAILURE, + ExtraData=3DIncludePathFile) AsmIncludes =3D [] - Lines =3D DoInclude(Source, '', IncludePathList,IncludeFileList=3DAsmI= ncludes,filetype=3D'ASM') + Lines =3D DoInclude(Source, '', IncludePathList, + IncludeFileList=3DAsmIncludes, filetype=3D'ASM') AsmIncludes =3D [item for item in AsmIncludes if item !=3D Source] if AsmIncludes: - SaveFileOnChange(os.path.join(os.path.dirname(Target),os.path.base= name(Source))+".trim.deps", " \\\n".join([Source+":"] +AsmIncludes),False) + SaveFileOnChange(os.path.join(os.path.dirname(Target), os.path.bas= ename( + Source))+".trim.deps", " \\\n".join([Source+":"] + AsmIncludes= ), False) # save all lines trimmed try: with open(Target, 'w') as File: @@ -434,6 +460,7 @@ def TrimAsmFile(Source, Target, IncludePathFile): except: EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DTarget) =20 + def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile): VfrNameList =3D [] if os.path.isdir(DebugDir): @@ -441,9 +468,9 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile): for FileName in Files: Name, Ext =3D os.path.splitext(FileName) if Ext =3D=3D '.c' and Name !=3D 'AutoGen': - VfrNameList.append (Name + 'Bin') + VfrNameList.append(Name + 'Bin') =20 - VfrNameList.append (ModuleName + 'Strings') + VfrNameList.append(ModuleName + 'Strings') =20 EfiFileName =3D os.path.join(DebugDir, ModuleName + '.efi') MapFileName =3D os.path.join(DebugDir, ModuleName + '.map') @@ -455,7 +482,8 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile): try: fInputfile =3D open(OutputFile, "wb+") except: - EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %= s" %OutputFile, None) + EdkLogger.error("Trim", FILE_OPEN_FAILURE, + "File open failed for %s" % OutputFile, None) =20 # Use a instance of BytesIO to cache data fStringIO =3D BytesIO() @@ -469,8 +497,8 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile): # UniGuid =3D b'\xe0\xc5\x13\x89\xf63\x86M\x9b\xf1C\xef\x89\xfc\= x06f' fStringIO.write(UniGuid) - UniValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (UniValue) + UniValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(UniValue) else: # # VFR binary offset in image. @@ -479,23 +507,24 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFil= e): # VfrGuid =3D b'\xb4|\xbc\xd0Gj_I\xaa\x11q\x07F\xda\x06\xa2' fStringIO.write(VfrGuid) - type (Item[1]) - VfrValue =3D pack ('Q', int (Item[1], 16)) - fStringIO.write (VfrValue) + type(Item[1]) + VfrValue =3D pack('Q', int(Item[1], 16)) + fStringIO.write(VfrValue) =20 # # write data into file. # - try : - fInputfile.write (fStringIO.getvalue()) + try: + fInputfile.write(fStringIO.getvalue()) except: - EdkLogger.error("Trim", FILE_WRITE_FAILURE, "Write data to file %s= failed, please check whether the file been locked or using by other applic= ations." %OutputFile, None) + EdkLogger.error("Trim", FILE_WRITE_FAILURE, + "Write data to file %s failed, please check whethe= r the file been locked or using by other applications." % OutputFile, None) =20 - fStringIO.close () - fInputfile.close () + fStringIO.close() + fInputfile.close() =20 =20 -## Parse command line options +# Parse command line options # # Using standard Python module optparse to parse command line option of th= is tool. # @@ -509,13 +538,13 @@ def Options(): make_option("-r", "--vfr-file", dest=3D"FileType", const=3D"Vfr", = action=3D"store_const", help=3D"The input file is preprocessed VFR file"= ), make_option("--Vfr-Uni-Offset", dest=3D"FileType", const=3D"VfrOff= setBin", action=3D"store_const", - help=3D"The input file is EFI image"), + help=3D"The input file is EFI image"), make_option("--asl-deps", dest=3D"AslDeps", const=3D"True", action= =3D"store_const", - help=3D"Generate Asl dependent files."), + help=3D"Generate Asl dependent files."), make_option("-a", "--asl-file", dest=3D"FileType", const=3D"Asl", = action=3D"store_const", help=3D"The input file is ASL file"), - make_option( "--asm-file", dest=3D"FileType", const=3D"Asm", actio= n=3D"store_const", - help=3D"The input file is asm file"), + make_option("--asm-file", dest=3D"FileType", const=3D"Asm", action= =3D"store_const", + help=3D"The input file is asm file"), make_option("-c", "--convert-hex", dest=3D"ConvertHex", action=3D"= store_true", help=3D"Convert standard hex format (0xabcd) to = MASM format (abcdh)"), =20 @@ -525,22 +554,25 @@ def Options(): help=3D"The input file is include path list to s= earch for ASL include file"), make_option("-o", "--output", dest=3D"OutputFile", help=3D"File to store the trimmed content"), - make_option("--ModuleName", dest=3D"ModuleName", help=3D"The modul= e's BASE_NAME"), + make_option("--ModuleName", dest=3D"ModuleName", + help=3D"The module's BASE_NAME"), make_option("--DebugDir", dest=3D"DebugDir", - help=3D"Debug Output directory to store the outp= ut files"), + help=3D"Debug Output directory to store the output fil= es"), make_option("-v", "--verbose", dest=3D"LogLevel", action=3D"store_= const", const=3DEdkLogger.VERBOSE, help=3D"Run verbosely"), make_option("-d", "--debug", dest=3D"LogLevel", type=3D"int", help=3D"Run with debug information"), make_option("-q", "--quiet", dest=3D"LogLevel", action=3D"store_co= nst", const=3DEdkLogger.QUIET, help=3D"Run quietly"), - make_option("-?", action=3D"help", help=3D"show this help message = and exit"), + make_option("-?", action=3D"help", + help=3D"show this help message and exit"), ] =20 # use clearer usage to override default usage message UsageString =3D "%prog [-s|-r|-a|--Vfr-Uni-Offset] [-c] [-v|-d |-q] [-i ] [-o ] [--ModuleName ] [--DebugDir ] []" =20 - Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, option_list=3DOptionList, usage=3DUsageString) + Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, + option_list=3DOptionList, usage=3DUsageString) Parser.set_defaults(FileType=3D"Vfr") Parser.set_defaults(ConvertHex=3DFalse) Parser.set_defaults(LogLevel=3DEdkLogger.INFO) @@ -552,16 +584,18 @@ def Options(): if len(Args) =3D=3D 0: return Options, '' elif len(Args) > 1: - EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, ExtraData=3DPars= er.get_usage()) + EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, + ExtraData=3DParser.get_usage()) if len(Args) =3D=3D 0: EdkLogger.error("Trim", OPTION_MISSING, ExtraData=3DParser.get_usa= ge()) if len(Args) > 1: - EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, ExtraData=3DParser.g= et_usage()) + EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, + ExtraData=3DParser.get_usage()) =20 InputFile =3D Args[0] return Options, InputFile =20 -## Entrance method +# Entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -570,6 +604,8 @@ def Options(): # @retval 0 Tool was successful # @retval 1 Tool failed # + + def Main(): try: EdkLogger.Initialize() @@ -584,44 +620,54 @@ def Main(): try: if CommandOptions.FileType =3D=3D "Vfr": if CommandOptions.OutputFile is None: - CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' + CommandOptions.OutputFile =3D os.path.splitext(InputFile)[ + 0] + '.iii' TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType =3D=3D "Asl": if CommandOptions.OutputFile is None: - CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' - TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptio= ns.IncludePathFile,CommandOptions.AslDeps) + CommandOptions.OutputFile =3D os.path.splitext(InputFile)[ + 0] + '.iii' + TrimAslFile(InputFile, CommandOptions.OutputFile, + CommandOptions.IncludePathFile, CommandOptions.Asl= Deps) elif CommandOptions.FileType =3D=3D "VfrOffsetBin": - GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.De= bugDir, CommandOptions.OutputFile) + GenerateVfrBinSec(CommandOptions.ModuleName, + CommandOptions.DebugDir, CommandOptions.Outp= utFile) elif CommandOptions.FileType =3D=3D "Asm": - TrimAsmFile(InputFile, CommandOptions.OutputFile, CommandOptio= ns.IncludePathFile) - else : + TrimAsmFile(InputFile, CommandOptions.OutputFile, + CommandOptions.IncludePathFile) + else: if CommandOptions.OutputFile is None: - CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' - TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, Com= mandOptions.ConvertHex, CommandOptions.TrimLong) + CommandOptions.OutputFile =3D os.path.splitext(InputFile)[ + 0] + '.iii' + TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, + CommandOptions.ConvertHex, CommandOptions= .TrimLong) except FatalError as X: import platform import traceback if CommandOptions is not None and CommandOptions.LogLevel <=3D Edk= Logger.DEBUG_9: - EdkLogger.quiet("(Python %s on %s) " % (platform.python_versio= n(), sys.platform) + traceback.format_exc()) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.forma= t_exc()) return 1 except: import traceback import platform EdkLogger.error( - "\nTrim", - CODE_ERROR, - "Unknown fatal error when trimming [%s]" % InputFile, - ExtraData=3D"\n(Please send email to %s for help, atta= ching following call stack trace!)\n" % MSG_EDKII_MAIL_ADDR, - RaiseError=3DFalse - ) - EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(),= sys.platform) + traceback.format_exc()) + "\nTrim", + CODE_ERROR, + "Unknown fatal error when trimming [%s]" % InputFile, + ExtraData=3D"\n(Please send email to %s for help, attaching fo= llowing call stack trace!)\n" % MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.format_ex= c()) return 1 =20 return 0 =20 + if __name__ =3D=3D '__main__': r =3D Main() - ## 0-127 is a safe return range, and 1 is a standard default error - if r < 0 or r > 127: r =3D 1 + # 0-127 is a safe return range, and 1 is a standard default error + if r < 0 or r > 127: + r =3D 1 sys.exit(r) - diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source= /Python/UPT/BuildVersion.py index 1b144dc1b666..de0225985950 100644 --- a/BaseTools/Source/Python/UPT/BuildVersion.py +++ b/BaseTools/Source/Python/UPT/BuildVersion.py @@ -1,4 +1,4 @@ -## @file +# @file # # This file is for build version number auto generation # diff --git a/BaseTools/Source/Python/UPT/Core/DependencyRules.py b/BaseTool= s/Source/Python/UPT/Core/DependencyRules.py index 0c801c72d614..2b6b088b4809 100644 --- a/BaseTools/Source/Python/UPT/Core/DependencyRules.py +++ b/BaseTools/Source/Python/UPT/Core/DependencyRules.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is for installed package information database operations # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -26,11 +26,11 @@ from Library import GlobalData from Logger.ToolError import FatalError from Logger.ToolError import EDK1_INF_ERROR from Logger.ToolError import UNKNOWN_ERROR -(DEPEX_CHECK_SUCCESS, DEPEX_CHECK_MODULE_NOT_FOUND, \ -DEPEX_CHECK_PACKAGE_NOT_FOUND, DEPEX_CHECK_DP_NOT_FOUND) =3D (0, 1, 2, 3) +(DEPEX_CHECK_SUCCESS, DEPEX_CHECK_MODULE_NOT_FOUND, + DEPEX_CHECK_PACKAGE_NOT_FOUND, DEPEX_CHECK_DP_NOT_FOUND) =3D (0, 1, 2, 3) =20 =20 -## DependencyRules +# DependencyRules # # This class represents the dependency rule check mechanism # @@ -42,10 +42,12 @@ class DependencyRules(object): self.WsPkgList =3D GetWorkspacePackage() self.WsModuleList =3D GetWorkspaceModule() =20 - self.PkgsToBeDepend =3D [(PkgInfo[1], PkgInfo[2]) for PkgInfo in s= elf.WsPkgList] + self.PkgsToBeDepend =3D [(PkgInfo[1], PkgInfo[2]) + for PkgInfo in self.WsPkgList] =20 # Add package info from the DIST to be installed. - self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstal= ledPkgList)) + self.PkgsToBeDepend.extend( + self.GenToBeInstalledPkgList(ToBeInstalledPkgList)) =20 def GenToBeInstalledPkgList(self, ToBeInstalledPkgList): if not ToBeInstalledPkgList: @@ -57,7 +59,7 @@ class DependencyRules(object): =20 return RtnList =20 - ## Check whether a module exists by checking the Guid+Version+Name+Pat= h combination + # Check whether a module exists by checking the Guid+Version+Name+Path= combination # # @param Guid: Guid of a module # @param Version: Version of a module @@ -68,14 +70,15 @@ class DependencyRules(object): def CheckModuleExists(self, Guid, Version, Name, Path): Logger.Verbose(ST.MSG_CHECK_MODULE_EXIST) ModuleList =3D self.IpiDb.GetModInPackage(Guid, Version, Name, Pat= h) - ModuleList.extend(self.IpiDb.GetStandaloneModule(Guid, Version, Na= me, Path)) + ModuleList.extend(self.IpiDb.GetStandaloneModule( + Guid, Version, Name, Path)) Logger.Verbose(ST.MSG_CHECK_MODULE_EXIST_FINISH) if len(ModuleList) > 0: return True else: return False =20 - ## Check whether a module depex satisfied. + # Check whether a module depex satisfied. # # @param ModuleObj: A module object # @param DpObj: A distribution object @@ -103,7 +106,7 @@ class DependencyRules(object): for GuidVerPair in DpObj.PackageSurfaceArea.keys(): if Dep.GetGuid() =3D=3D GuidVerPair[0]: if Dep.GetVersion() is None or \ - len(Dep.GetVersion()) =3D=3D 0: + len(Dep.GetVersion()) =3D=3D 0: Result =3D True break if Dep.GetVersion() =3D=3D GuidVerPair[1]: @@ -114,14 +117,14 @@ class DependencyRules(object): break =20 if not Result: - Logger.Error("CheckModuleDepex", UNKNOWN_ERROR, \ - ST.ERR_DEPENDENCY_NOT_MATCH % (ModuleObj.GetName(= ), \ - Dep.GetPackageFile= Path(), \ - Dep.GetGuid(), \ + Logger.Error("CheckModuleDepex", UNKNOWN_ERROR, + ST.ERR_DEPENDENCY_NOT_MATCH % (ModuleObj.GetName(= ), + Dep.GetPackageFile= Path(), + Dep.GetGuid(), Dep.GetVersion())) return Result =20 - ## Check whether a package exists in a package list specified by PkgsT= oBeDepend. + # Check whether a package exists in a package list specified by PkgsTo= BeDepend. # # @param Guid: Guid of a package # @param Version: Version of a package @@ -148,7 +151,7 @@ class DependencyRules(object): Logger.Verbose(ST.MSG_CHECK_PACKAGE_FINISH) return Found =20 - ## Check whether a package depex satisfied. + # Check whether a package depex satisfied. # # @param PkgObj: A package object # @param DpObj: A distribution object @@ -165,7 +168,7 @@ class DependencyRules(object): return False return True =20 - ## Check whether a DP exists. + # Check whether a DP exists. # # @param Guid: Guid of a Distribution # @param Version: Version of a Distribution @@ -182,7 +185,7 @@ class DependencyRules(object): Logger.Verbose(ST.MSG_CHECK_DP_FINISH) return Found =20 - ## Check whether a DP depex satisfied by current workspace for Install + # Check whether a DP depex satisfied by current workspace for Install # # @param DpObj: A distribution object # @return: True if distribution depex satisfied @@ -208,24 +211,26 @@ class DependencyRules(object): =20 return True, DpObj =20 - - ## Check whether a DP depex satisfied by current workspace + # Check whether a DP depex satisfied by current workspace # (excluding the original distribution's packages to be replaced) for= Replace # # @param DpObj: A distribution object # @param OrigDpGuid: The original distribution's Guid # @param OrigDpVersion: The original distribution's Version # + def ReplaceCheckNewDpDepex(self, DpObj, OrigDpGuid, OrigDpVersion): - self.PkgsToBeDepend =3D [(PkgInfo[1], PkgInfo[2]) for PkgInfo in s= elf.WsPkgList] - OrigDpPackageList =3D self.IpiDb.GetPackageListFromDp(OrigDpGuid, = OrigDpVersion) + self.PkgsToBeDepend =3D [(PkgInfo[1], PkgInfo[2]) + for PkgInfo in self.WsPkgList] + OrigDpPackageList =3D self.IpiDb.GetPackageListFromDp( + OrigDpGuid, OrigDpVersion) for OrigPkgInfo in OrigDpPackageList: Guid, Version =3D OrigPkgInfo[0], OrigPkgInfo[1] if (Guid, Version) in self.PkgsToBeDepend: self.PkgsToBeDepend.remove((Guid, Version)) return self.CheckDpDepexSatisfied(DpObj) =20 - ## Check whether a DP depex satisfied by current workspace. + # Check whether a DP depex satisfied by current workspace. # # @param DpObj: A distribution object # @@ -246,7 +251,7 @@ class DependencyRules(object): =20 return True =20 - ## Check whether a DP could be removed from current workspace. + # Check whether a DP could be removed from current workspace. # # @param DpGuid: File's guid # @param DpVersion: File's version @@ -293,7 +298,7 @@ class DependencyRules(object): # for (PkgGuid, PkgVersion, InstallPath) in DpPackageList: Logger.Warn("UPT", - ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgV= ersion, InstallPath)) + ST.WARN_INSTALLED_PACKAGE_NOT_FOUND % (PkgGuid, Pk= gVersion, InstallPath)) =20 # # check modules to see if has dependency on package of current DP @@ -304,8 +309,7 @@ class DependencyRules(object): DependModuleList.append(Module) return (Removable, DependModuleList) =20 - - ## Check whether a DP could be replaced by a distribution containing N= ewDpPkgList + # Check whether a DP could be replaced by a distribution containing Ne= wDpPkgList # from current workspace. # # @param OrigDpGuid: original Dp's Guid @@ -314,6 +318,7 @@ class DependencyRules(object): # @retval Replaceable: True if distribution could be replaced, False E= lse # @retval DependModuleList: the list of modules that make distribution= can not be replaced # + def CheckDpDepexForReplace(self, OrigDpGuid, OrigDpVersion, NewDpPkgLi= st): Replaceable =3D True DependModuleList =3D [] @@ -333,7 +338,8 @@ class DependencyRules(object): # # get packages in current Dp and find the install path # List of item (PkgGuid, PkgVersion, InstallPath) - DpPackageList =3D self.IpiDb.GetPackageListFromDp(OrigDpGuid, Orig= DpVersion) + DpPackageList =3D self.IpiDb.GetPackageListFromDp( + OrigDpGuid, OrigDpVersion) DpPackagePathList =3D [] WorkSP =3D GlobalData.gWORKSPACE for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList: @@ -358,7 +364,7 @@ class DependencyRules(object): # for (PkgGuid, PkgVersion, InstallPath) in DpPackageList: Logger.Warn("UPT", - ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgV= ersion, InstallPath)) + ST.WARN_INSTALLED_PACKAGE_NOT_FOUND % (PkgGuid, Pk= gVersion, InstallPath)) =20 # # check modules to see if it can be satisfied by package not belon= g to removed DP @@ -370,7 +376,7 @@ class DependencyRules(object): return (Replaceable, DependModuleList) =20 =20 -## check whether module depends on packages in DpPackagePathList, return T= rue +# check whether module depends on packages in DpPackagePathList, return Tr= ue # if found, False else # # @param Path: a module path @@ -382,7 +388,8 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): try: for Item in GetPackagePath(Path): if Item in DpPackagePathList: - DecPath =3D os.path.normpath(os.path.join(GlobalData.gWORK= SPACE, Item)) + DecPath =3D os.path.normpath( + os.path.join(GlobalData.gWORKSPACE, Item)) Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath)) return False else: @@ -390,7 +397,7 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", - ST.WRN_EDK1_INF_FOUND%Path) + ST.WRN_EDK1_INF_FOUND % Path) return True else: return True @@ -399,6 +406,8 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList): # # Get Dependency package path from an Inf file path # + + def GetPackagePath(InfPath): PackagePath =3D [] if os.path.exists(InfPath): @@ -419,7 +428,7 @@ def GetPackagePath(InfPath): =20 return PackagePath =20 -## check whether module depends on packages in DpPackagePathList and can n= ot be satisfied by OtherPkgList +# check whether module depends on packages in DpPackagePathList and can no= t be satisfied by OtherPkgList # # @param Path: a module path # @param DpPackagePathList: a list of Package Paths @@ -428,11 +437,14 @@ def GetPackagePath(InfPath): # True: either module doesn't depend on DpPackagePathList or mo= dule depends on DpPackagePathList # but can be satisfied by OtherPkgList # + + def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList): try: for Item in GetPackagePath(Path): if Item in DpPackagePathList: - DecPath =3D os.path.normpath(os.path.join(GlobalData.gWORK= SPACE, Item)) + DecPath =3D os.path.normpath( + os.path.join(GlobalData.gWORKSPACE, Item)) Name, Guid, Version =3D GetPkgInfoFromDec(DecPath) if (Guid, Version) not in OtherPkgList: Logger.Info(ST.MSG_MODULE_DEPEND_ON % (Path, DecPath)) @@ -442,7 +454,7 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, Oth= erPkgList): except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", - ST.WRN_EDK1_INF_FOUND%Path) + ST.WRN_EDK1_INF_FOUND % Path) return True else: return True diff --git a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py b= /BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py index 5ee79b6317bc..5fa211c9088a 100644 --- a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py +++ b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define a class object to describe a distribution pa= ckage # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -28,12 +28,14 @@ from Object.POM.CommonObject import CommonHeaderObject from Object.POM.CommonObject import MiscFileObject from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## DistributionPackageHeaderClass +# DistributionPackageHeaderClass # # @param IdentificationObject: Identification Object # @param CommonHeaderObject: Common Header Object # -class DistributionPackageHeaderObject(IdentificationObject, \ + + +class DistributionPackageHeaderObject(IdentificationObject, CommonHeaderObject): def __init__(self): IdentificationObject.__init__(self) @@ -78,10 +80,12 @@ class DistributionPackageHeaderObject(IdentificationObj= ect, \ def GetXmlSpecification(self): return self.XmlSpecification =20 -## DistributionPackageClass +# DistributionPackageClass # # @param object: DistributionPackageClass # + + class DistributionPackageClass(object): def __init__(self): self.Header =3D DistributionPackageHeaderObject() @@ -98,7 +102,7 @@ class DistributionPackageClass(object): self.UserExtensions =3D [] self.FileList =3D [] =20 - ## Get all included packages and modules for a distribution package + # Get all included packages and modules for a distribution package # # @param WorkspaceDir: WorkspaceDir # @param PackageList: A list of all packages @@ -115,7 +119,8 @@ class DistributionPackageClass(object): for PackageFile in PackageList: PackageFileFullPath =3D mws.join(Root, PackageFile) WorkspaceDir =3D mws.getWs(Root, PackageFile) - DecObj =3D DecPomAlignment(PackageFileFullPath, WorkspaceD= ir, CheckMulDec=3DTrue) + DecObj =3D DecPomAlignment( + PackageFileFullPath, WorkspaceDir, CheckMulDec=3DTrue) PackageObj =3D DecObj # # Parser inf file one bye one @@ -127,10 +132,10 @@ class DistributionPackageClass(object): if ModuleList and WsRelPath in ModuleList: Logger.Error("UPT", OPTION_VALUE_INVALID, - ST.ERR_NOT_STANDALONE_MODULE_ERROR%\ + ST.ERR_NOT_STANDALONE_MODULE_ERROR % (WsRelPath, PackageFile)) - Filename =3D os.path.normpath\ - (os.path.join(PackageObj.GetRelaPath(), File)) + Filename =3D os.path.normpath( + os.path.join(PackageObj.GetRelaPath(), File)) os.path.splitext(Filename) # # Call INF parser to generate Inf Object. @@ -138,27 +143,27 @@ class DistributionPackageClass(object): # Inf class in InfPomAlignment. # try: - ModuleObj =3D InfPomAlignment(Filename, WorkspaceD= ir, PackageObj.GetPackagePath()) + ModuleObj =3D InfPomAlignment( + Filename, WorkspaceDir, PackageObj.GetPackageP= ath()) =20 # # Add module to package # ModuleDict =3D PackageObj.GetModuleDict() - ModuleDict[(ModuleObj.GetGuid(), \ - ModuleObj.GetVersion(), \ - ModuleObj.GetName(), \ + ModuleDict[(ModuleObj.GetGuid(), + ModuleObj.GetVersion(), + ModuleObj.GetName(), ModuleObj.GetCombinePath())] =3D Modul= eObj PackageObj.SetModuleDict(ModuleDict) except FatalError as ErrCode: if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Warn("UPT", - ST.WRN_EDK1_INF_FOUND%Filename) + ST.WRN_EDK1_INF_FOUND % Filename) else: raise =20 - self.PackageSurfaceArea\ - [(PackageObj.GetGuid(), PackageObj.GetVersion(), \ - PackageObj.GetCombinePath())] =3D PackageObj + self.PackageSurfaceArea[(PackageObj.GetGuid(), PackageObj.= GetVersion(), + PackageObj.GetCombinePath())] =3D= PackageObj =20 # # Get Modules @@ -169,7 +174,8 @@ class DistributionPackageClass(object): WorkspaceDir =3D mws.getWs(Root, ModuleFile) =20 try: - ModuleObj =3D InfPomAlignment(ModuleFileFullPath, Work= spaceDir) + ModuleObj =3D InfPomAlignment( + ModuleFileFullPath, WorkspaceDir) ModuleKey =3D (ModuleObj.GetGuid(), ModuleObj.GetVersion(), ModuleObj.GetName(), @@ -179,7 +185,7 @@ class DistributionPackageClass(object): if ErrCode.message =3D=3D EDK1_INF_ERROR: Logger.Error("UPT", EDK1_INF_ERROR, - ST.WRN_EDK1_INF_FOUND%ModuleFileFullP= ath, + ST.WRN_EDK1_INF_FOUND % ModuleFileFul= lPath, ExtraData=3DST.ERR_NOT_SUPPORTED_SA_M= ODULE) else: raise @@ -187,7 +193,7 @@ class DistributionPackageClass(object): # Recover WorkspaceDir WorkspaceDir =3D Root =20 - ## Get all files included for a distribution package, except tool/misc= of + # Get all files included for a distribution package, except tool/misc = of # distribution level # # @retval DistFileList A list of filepath for NonMetaDataFile, relati= ve to workspace @@ -204,15 +210,19 @@ class DistributionPackageClass(object): MetaDataFileList.append(Path) IncludePathList =3D Package.GetIncludePathList() for IncludePath in IncludePathList: - SearchPath =3D os.path.normpath(os.path.join(os.path.dirna= me(FullPath), IncludePath)) - AddPath =3D os.path.normpath(os.path.join(PackagePath, Inc= ludePath)) - self.FileList +=3D GetNonMetaDataFiles(SearchPath, ['CVS',= '.svn'], False, AddPath) + SearchPath =3D os.path.normpath(os.path.join( + os.path.dirname(FullPath), IncludePath)) + AddPath =3D os.path.normpath( + os.path.join(PackagePath, IncludePath)) + self.FileList +=3D GetNonMetaDataFiles( + SearchPath, ['CVS', '.svn'], False, AddPath) # # Add the miscellaneous files on DEC file # for MiscFileObj in Package.GetMiscFileList(): for FileObj in MiscFileObj.GetFileList(): - MiscFileFullPath =3D os.path.normpath(os.path.join(Pac= kagePath, FileObj.GetURI())) + MiscFileFullPath =3D os.path.normpath( + os.path.join(PackagePath, FileObj.GetURI())) if MiscFileFullPath not in self.FileList: self.FileList.append(MiscFileFullPath) =20 @@ -222,20 +232,23 @@ class DistributionPackageClass(object): Module =3D ModuleDict[Guid, Version, Name, Path] ModulePath =3D Module.GetModulePath() FullPath =3D Module.GetFullPath() - PkgRelPath =3D os.path.normpath(os.path.join(PackagePath, = ModulePath)) + PkgRelPath =3D os.path.normpath( + os.path.join(PackagePath, ModulePath)) MetaDataFileList.append(Path) SkipList =3D ['CVS', '.svn'] NonMetaDataFileList =3D [] if Module.UniFileClassObject: for UniFile in Module.UniFileClassObject.IncFileList: OriPath =3D os.path.normpath(os.path.dirname(FullP= ath)) - UniFilePath =3D os.path.normpath(os.path.join(PkgR= elPath, UniFile.Path[len(OriPath) + 1:])) + UniFilePath =3D os.path.normpath(os.path.join( + PkgRelPath, UniFile.Path[len(OriPath) + 1:])) if UniFilePath not in SkipModulesUniList: SkipModulesUniList.append(UniFilePath) for IncludeFile in Module.UniFileClassObject.IncludePa= thList: if IncludeFile not in SkipModulesUniList: SkipModulesUniList.append(IncludeFile) - NonMetaDataFileList =3D GetNonMetaDataFiles(os.path.dirnam= e(FullPath), SkipList, False, PkgRelPath) + NonMetaDataFileList =3D GetNonMetaDataFiles( + os.path.dirname(FullPath), SkipList, False, PkgRelPath) for NonMetaDataFile in NonMetaDataFileList: if NonMetaDataFile not in self.FileList: self.FileList.append(NonMetaDataFile) @@ -249,10 +262,12 @@ class DistributionPackageClass(object): if Module.UniFileClassObject: for UniFile in Module.UniFileClassObject.IncFileList: OriPath =3D os.path.normpath(os.path.dirname(FullPath)) - UniFilePath =3D os.path.normpath(os.path.join(ModulePa= th, UniFile.Path[len(OriPath) + 1:])) + UniFilePath =3D os.path.normpath(os.path.join( + ModulePath, UniFile.Path[len(OriPath) + 1:])) if UniFilePath not in SkipModulesUniList: SkipModulesUniList.append(UniFilePath) - NonMetaDataFileList =3D GetNonMetaDataFiles(os.path.dirname(Fu= llPath), SkipList, False, ModulePath) + NonMetaDataFileList =3D GetNonMetaDataFiles( + os.path.dirname(FullPath), SkipList, False, ModulePath) for NonMetaDataFile in NonMetaDataFileList: if NonMetaDataFile not in self.FileList: self.FileList.append(NonMetaDataFile) @@ -261,7 +276,4 @@ class DistributionPackageClass(object): if SkipModuleUni in self.FileList: self.FileList.remove(SkipModuleUni) =20 - return self.FileList, MetaDataFileList - - - + return self.FileList, MetaDataFileList diff --git a/BaseTools/Source/Python/UPT/Core/FileHook.py b/BaseTools/Sourc= e/Python/UPT/Core/FileHook.py index 20712065f742..0de02b6a19be 100644 --- a/BaseTools/Source/Python/UPT/Core/FileHook.py +++ b/BaseTools/Source/Python/UPT/Core/FileHook.py @@ -1,4 +1,4 @@ -## @file +# @file # This file hooks file and directory creation and removal # # Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
        @@ -18,19 +18,21 @@ from time import sleep from Library import GlobalData =20 __built_in_remove__ =3D os.remove -__built_in_mkdir__ =3D os.mkdir -__built_in_rmdir__ =3D os.rmdir -__built_in_chmod__ =3D os.chmod -__built_in_open__ =3D open +__built_in_mkdir__ =3D os.mkdir +__built_in_rmdir__ =3D os.rmdir +__built_in_chmod__ =3D os.chmod +__built_in_open__ =3D open =20 -_RMFILE =3D 0 -_MKFILE =3D 1 -_RMDIR =3D 2 -_MKDIR =3D 3 -_CHMOD =3D 4 +_RMFILE =3D 0 +_MKFILE =3D 1 +_RMDIR =3D 2 +_MKDIR =3D 3 +_CHMOD =3D 4 =20 gBACKUPFILE =3D 'file.backup' -gEXCEPTION_LIST =3D ['Conf'+os.sep+'DistributionPackageDatabase.db', '.tmp= ', gBACKUPFILE] +gEXCEPTION_LIST =3D ['Conf'+os.sep + + 'DistributionPackageDatabase.db', '.tmp', gBACKUPFILE] + =20 class _PathInfo: def __init__(self, action, path, mode=3D-1): @@ -38,6 +40,7 @@ class _PathInfo: self.path =3D path self.mode =3D mode =20 + class RecoverMgr: def __init__(self, workspace): self.rlist =3D [] @@ -101,12 +104,13 @@ class RecoverMgr: item =3D self.rlist[index] exist =3D os.path.exists(item.path) if item.action =3D=3D _MKFILE and exist: - #if not os.access(item.path, os.W_OK): + # if not os.access(item.path, os.W_OK): # os.chmod(item.path, S_IWUSR) __built_in_remove__(item.path) elif item.action =3D=3D _RMFILE and not exist: if not self.zip: - self.zip =3D zipfile.ZipFile(self.zipfile, 'r', zipfil= e.ZIP_DEFLATED) + self.zip =3D zipfile.ZipFile( + self.zipfile, 'r', zipfile.ZIP_DEFLATED) arcname =3D os.path.normpath(item.path) arcname =3D arcname[len(self.workspace)+1:].encode('utf_8') if os.sep !=3D "/" and os.sep in arcname: @@ -145,7 +149,8 @@ class RecoverMgr: # Check if path needs to be hooked def _tryhook(self, path): path =3D os.path.normpath(path) - works =3D self.workspace if str(self.workspace).endswith(os.sep) e= lse (self.workspace + os.sep) + works =3D self.workspace if str(self.workspace).endswith( + os.sep) else (self.workspace + os.sep) if not path.startswith(works): return '' for exceptdir in gEXCEPTION_LIST: @@ -154,40 +159,47 @@ class RecoverMgr: return '' return path[len(self.workspace)+1:] =20 + def _hookrm(path): if GlobalData.gRECOVERMGR: GlobalData.gRECOVERMGR.bkrmfile(path) else: __built_in_remove__(path) =20 + def _hookmkdir(path, mode=3D0o777): if GlobalData.gRECOVERMGR: GlobalData.gRECOVERMGR.bkmkdir(path, mode) else: __built_in_mkdir__(path, mode) =20 + def _hookrmdir(path): if GlobalData.gRECOVERMGR: GlobalData.gRECOVERMGR.bkrmdir(path) else: __built_in_rmdir__(path) =20 + def _hookmkfile(path, mode=3D'r', bufsize=3D-1): if GlobalData.gRECOVERMGR: return GlobalData.gRECOVERMGR.bkmkfile(path, mode, bufsize) return __built_in_open__(path, mode, bufsize) =20 + def _hookchmod(path, mode): if GlobalData.gRECOVERMGR: GlobalData.gRECOVERMGR.bkchmod(path, mode) else: __built_in_chmod__(path, mode) =20 + def SetRecoverMgr(mgr): GlobalData.gRECOVERMGR =3D mgr =20 -os.remove =3D _hookrm -os.mkdir =3D _hookmkdir -os.rmdir =3D _hookrmdir -os.chmod =3D _hookchmod -__FileHookOpen__ =3D _hookmkfile + +os.remove =3D _hookrm +os.mkdir =3D _hookmkdir +os.rmdir =3D _hookrmdir +os.chmod =3D _hookchmod +__FileHookOpen__ =3D _hookmkfile diff --git a/BaseTools/Source/Python/UPT/Core/IpiDb.py b/BaseTools/Source/P= ython/UPT/Core/IpiDb.py index 69895e11cd04..feb81e49aad6 100644 --- a/BaseTools/Source/Python/UPT/Core/IpiDb.py +++ b/BaseTools/Source/Python/UPT/Core/IpiDb.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is for installed package information database operations # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,7 +23,7 @@ from Logger.ToolError import UPT_ALREADY_RUNNING_ERROR from Logger.ToolError import UPT_DB_UPDATE_ERROR import platform as pf =20 -## IpiDb +# IpiDb # # This class represents the installed package information database # Add/Remove/Get installed distribution package information here. @@ -33,12 +33,15 @@ import platform as pf # @param DbPath: A string for the path of the database # # + + class IpiDatabase(object): def __init__(self, DbPath, Workspace): Dir =3D os.path.dirname(DbPath) if not os.path.isdir(Dir): os.mkdir(Dir) - self.Conn =3D sqlite3.connect(u''.join(DbPath), isolation_level=3D= 'DEFERRED') + self.Conn =3D sqlite3.connect( + u''.join(DbPath), isolation_level=3D'DEFERRED') self.Conn.execute("PRAGMA page_size=3D4096") self.Conn.execute("PRAGMA synchronous=3DOFF") self.Cur =3D self.Conn.cursor() @@ -51,10 +54,10 @@ class IpiDatabase(object): self.DummyTable =3D 'Dummy' self.Workspace =3D os.path.normpath(Workspace) =20 - ## Initialize build database + # Initialize build database # # - def InitDatabase(self, SkipLock =3D False): + def InitDatabase(self, SkipLock=3DFalse): Logger.Verbose(ST.MSG_INIT_IPI_START) if not SkipLock: try: @@ -158,7 +161,7 @@ class IpiDatabase(object): def Commit(self): self.Conn.commit() =20 - ## Add a distribution install information from DpObj + # Add a distribution install information from DpObj # # @param DpObj: # @param NewDpPkgFileName: New DpPkg File Name @@ -171,7 +174,7 @@ class IpiDatabase(object): PkgGuid =3D PkgKey[0] PkgVersion =3D PkgKey[1] PkgInstallPath =3D PkgKey[2] - self._AddPackage(PkgGuid, PkgVersion, DpObj.Header.GetGuid= (), \ + self._AddPackage(PkgGuid, PkgVersion, DpObj.Header.GetGuid= (), DpObj.Header.GetVersion(), PkgInstallPath) PkgObj =3D DpObj.PackageSurfaceArea[PkgKey] for ModKey in PkgObj.GetModuleDict().keys(): @@ -180,18 +183,19 @@ class IpiDatabase(object): ModName =3D ModKey[2] ModInstallPath =3D ModKey[3] ModInstallPath =3D \ - os.path.normpath(os.path.join(PkgInstallPath, ModInsta= llPath)) - self._AddModuleInPackage(ModGuid, ModVersion, ModName,= PkgGuid, \ + os.path.normpath(os.path.join( + PkgInstallPath, ModInstallPath)) + self._AddModuleInPackage(ModGuid, ModVersion, ModName,= PkgGuid, PkgVersion, ModInstallPath) ModObj =3D PkgObj.GetModuleDict()[ModKey] for Dep in ModObj.GetPackageDependencyList(): DepexGuid =3D Dep.GetGuid() DepexVersion =3D Dep.GetVersion() - self._AddModuleDepex(ModGuid, ModVersion, ModName,= ModInstallPath, \ + self._AddModuleDepex(ModGuid, ModVersion, ModName,= ModInstallPath, DepexGuid, DepexVersion) for (FilePath, Md5Sum) in PkgObj.FileList: - self._AddDpFilePathList(DpObj.Header.GetGuid(), \ - DpObj.Header.GetVersion(), Fil= ePath, \ + self._AddDpFilePathList(DpObj.Header.GetGuid(), + DpObj.Header.GetVersion(), Fil= ePath, Md5Sum) =20 for ModKey in DpObj.ModuleSurfaceArea.keys(): @@ -199,46 +203,46 @@ class IpiDatabase(object): ModVersion =3D ModKey[1] ModName =3D ModKey[2] ModInstallPath =3D ModKey[3] - self._AddStandaloneModule(ModGuid, ModVersion, ModName, \ - DpObj.Header.GetGuid(), \ - DpObj.Header.GetVersion(), \ + self._AddStandaloneModule(ModGuid, ModVersion, ModName, + DpObj.Header.GetGuid(), + DpObj.Header.GetVersion(), ModInstallPath) ModObj =3D DpObj.ModuleSurfaceArea[ModKey] for Dep in ModObj.GetPackageDependencyList(): DepexGuid =3D Dep.GetGuid() DepexVersion =3D Dep.GetVersion() - self._AddModuleDepex(ModGuid, ModVersion, ModName, Mod= InstallPath, \ + self._AddModuleDepex(ModGuid, ModVersion, ModName, Mod= InstallPath, DepexGuid, DepexVersion) for (Path, Md5Sum) in ModObj.FileList: - self._AddDpFilePathList(DpObj.Header.GetGuid(), \ - DpObj.Header.GetVersion(), \ + self._AddDpFilePathList(DpObj.Header.GetGuid(), + DpObj.Header.GetVersion(), Path, Md5Sum) =20 # # add tool/misc files # for (Path, Md5Sum) in DpObj.FileList: - self._AddDpFilePathList(DpObj.Header.GetGuid(), \ + self._AddDpFilePathList(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(), Path, M= d5Sum) =20 - self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(),= \ + self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(), NewDpPkgFileName, DpPkgFileName, RePackage) =20 except sqlite3.IntegrityError as DetailMsg: Logger.Error("UPT", UPT_DB_UPDATE_ERROR, ST.ERR_UPT_DB_UPDATE_ERROR, - ExtraData =3D DetailMsg + ExtraData=3DDetailMsg ) =20 - ## Add a distribution install information + # Add a distribution install information # # @param Guid Guid of the distribution package # @param Version Version of the distribution package # @param NewDpFileName the saved filename of distribution package file # @param DistributionFileName the filename of distribution package file # - def _AddDp(self, Guid, Version, NewDpFileName, DistributionFileName, \ + def _AddDp(self, Guid, Version, NewDpFileName, DistributionFileName, RePackage): =20 if Version is None or len(Version.strip()) =3D=3D 0: @@ -253,19 +257,19 @@ class IpiDatabase(object): PkgFileName =3D NewDpFileName CurrentTime =3D time.time() SqlCommand =3D \ - """insert into %s values('%s', '%s', %s, '%s', '%s', '%s')""" % \ - (self.DpTable, Guid, Version, CurrentTime, PkgFileName, \ - DistributionFileName, str(RePackage).upper()) + """insert into %s values('%s', '%s', %s, '%s', '%s', '%s')""" = % \ + (self.DpTable, Guid, Version, CurrentTime, PkgFileName, + DistributionFileName, str(RePackage).upper()) self.Cur.execute(SqlCommand) =20 - - ## Add a file list from DP + # Add a file list from DP # # @param DpGuid: A DpGuid # @param DpVersion: A DpVersion # @param Path: A Path # @param Path: A Md5Sum # + def _AddDpFilePathList(self, DpGuid, DpVersion, Path, Md5Sum): Path =3D os.path.normpath(Path) if pf.system() =3D=3D 'Windows': @@ -275,11 +279,11 @@ class IpiDatabase(object): if Path.startswith(self.Workspace + os.sep): Path =3D Path[len(self.Workspace)+1:] SqlCommand =3D """insert into %s values('%s', '%s', '%s', '%s')"""= % \ - (self.DpFileListTable, Path, DpGuid, DpVersion, Md5Sum) + (self.DpFileListTable, Path, DpGuid, DpVersion, Md5Sum) =20 self.Cur.execute(SqlCommand) =20 - ## Add a package install information + # Add a package install information # # @param Guid: A package guid # @param Version: A package version @@ -303,11 +307,11 @@ class IpiDatabase(object): # CurrentTime =3D time.time() SqlCommand =3D \ - """insert into %s values('%s', '%s', %s, '%s', '%s', '%s')""" % \ - (self.PkgTable, Guid, Version, CurrentTime, DpGuid, DpVersion, Pat= h) + """insert into %s values('%s', '%s', %s, '%s', '%s', '%s')""" = % \ + (self.PkgTable, Guid, Version, CurrentTime, DpGuid, DpVersion,= Path) self.Cur.execute(SqlCommand) =20 - ## Add a module that from a package install information + # Add a module that from a package install information # # @param Guid: Module Guid # @param Version: Module version @@ -316,7 +320,7 @@ class IpiDatabase(object): # @param PkgVersion: Package version # @param Path: Package relative path that module installs # - def _AddModuleInPackage(self, Guid, Version, Name, PkgGuid=3DNone, \ + def _AddModuleInPackage(self, Guid, Version, Name, PkgGuid=3DNone, PkgVersion=3DNone, Path=3D''): =20 if Version is None or len(Version.strip()) =3D=3D 0: @@ -338,12 +342,12 @@ class IpiDatabase(object): # CurrentTime =3D time.time() SqlCommand =3D \ - """insert into %s values('%s', '%s', '%s', %s, '%s', '%s', '%s')""= " % \ - (self.ModInPkgTable, Guid, Version, Name, CurrentTime, PkgGuid, Pk= gVersion, \ - Path) + """insert into %s values('%s', '%s', '%s', %s, '%s', '%s', '%s= ')""" % \ + (self.ModInPkgTable, Guid, Version, Name, CurrentTime, PkgGuid= , PkgVersion, + Path) self.Cur.execute(SqlCommand) =20 - ## Add a module that is standalone install information + # Add a module that is standalone install information # # @param Guid: a module Guid # @param Version: a module Version @@ -352,7 +356,7 @@ class IpiDatabase(object): # @param DpVersion: a DpVersion # @param Path: path # - def _AddStandaloneModule(self, Guid, Version, Name, DpGuid=3DNone, \ + def _AddStandaloneModule(self, Guid, Version, Name, DpGuid=3DNone, DpVersion=3DNone, Path=3D''): =20 if Version is None or len(Version.strip()) =3D=3D 0: @@ -369,12 +373,12 @@ class IpiDatabase(object): # CurrentTime =3D time.time() SqlCommand =3D \ - """insert into %s values('%s', '%s', '%s', %s, '%s', '%s', '%s')""= " % \ - (self.StandaloneModTable, Guid, Version, Name, CurrentTime, DpGuid= , \ - DpVersion, Path) + """insert into %s values('%s', '%s', '%s', %s, '%s', '%s', '%s= ')""" % \ + (self.StandaloneModTable, Guid, Version, Name, CurrentTime, Dp= Guid, + DpVersion, Path) self.Cur.execute(SqlCommand) =20 - ## Add a module depex + # Add a module depex # # @param Guid: a module Guid # @param Version: a module Version @@ -382,7 +386,7 @@ class IpiDatabase(object): # @param DepexGuid: a module DepexGuid # @param DepexVersion: a module DepexVersion # - def _AddModuleDepex(self, Guid, Version, Name, Path, DepexGuid=3DNone,= \ + def _AddModuleDepex(self, Guid, Version, Name, Path, DepexGuid=3DNone, DepexVersion=3DNone): =20 if DepexGuid is None or len(DepexGuid.strip()) =3D=3D 0: @@ -400,10 +404,10 @@ class IpiDatabase(object): # Add module depex information to DB. # SqlCommand =3D """insert into %s values('%s', '%s', '%s', '%s', '%= s', '%s')"""\ - % (self.ModDepexTable, Guid, Version, Name, Path, DepexGuid, Depe= xVersion) + % (self.ModDepexTable, Guid, Version, Name, Path, DepexGuid, D= epexVersion) self.Cur.execute(SqlCommand) =20 - ## Remove a distribution install information, if no version specified, + # Remove a distribution install information, if no version specified, # remove all DPs with this Guid. # # @param DpGuid: guid of dpex @@ -416,7 +420,7 @@ class IpiDatabase(object): # delete from ModDepex the standalone module's dependency # SqlCommand =3D \ - """delete from ModDepexInfo where ModDepexInfo.ModuleGuid in + """delete from ModDepexInfo where ModDepexInfo.ModuleGuid in (select ModuleGuid from StandaloneModInfo as B where B.DpGuid =3D = '%s' and B.DpVersion =3D '%s') and ModDepexInfo.ModuleVersion in @@ -428,7 +432,8 @@ class IpiDatabase(object): and ModDepexInfo.InstallPath in (select InstallPath from StandaloneModInfo as B where B.DpGuid =3D '%s' and B.DpVersion =3D '%s') """ % \ - (DpGuid, DpVersion, DpGuid, DpVersion, DpGuid, DpVersion, DpGuid, = DpVersion) + (DpGuid, DpVersion, DpGuid, DpVersion, + DpGuid, DpVersion, DpGuid, DpVersion) =20 self.Cur.execute(SqlCommand) # @@ -437,7 +442,7 @@ class IpiDatabase(object): for Pkg in PkgList: =20 SqlCommand =3D \ - """delete from ModDepexInfo where ModDepexInfo.ModuleGuid in + """delete from ModDepexInfo where ModDepexInfo.ModuleGuid = in (select ModuleGuid from ModInPkgInfo where ModInPkgInfo.PackageGuid =3D'%s' and ModInPkgInfo.PackageVersion =3D '%s') @@ -460,44 +465,44 @@ class IpiDatabase(object): # delete the standalone module # SqlCommand =3D \ - """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'""" %= \ - (self.StandaloneModTable, DpGuid, DpVersion) + """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'"= "" % \ + (self.StandaloneModTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) # # delete the from pkg module # for Pkg in PkgList: SqlCommand =3D \ - """delete from %s where %s.PackageGuid =3D'%s' + """delete from %s where %s.PackageGuid =3D'%s' and %s.PackageVersion =3D '%s'""" % \ - (self.ModInPkgTable, self.ModInPkgTable, Pkg[0], \ - self.ModInPkgTable, Pkg[1]) + (self.ModInPkgTable, self.ModInPkgTable, Pkg[0], + self.ModInPkgTable, Pkg[1]) self.Cur.execute(SqlCommand) # # delete packages # SqlCommand =3D \ - """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'""" %= \ - (self.PkgTable, DpGuid, DpVersion) + """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'"= "" % \ + (self.PkgTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) # # delete file list from DP # SqlCommand =3D \ - """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'""" %= \ - (self.DpFileListTable, DpGuid, DpVersion) + """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'"= "" % \ + (self.DpFileListTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) # # delete DP # SqlCommand =3D \ - """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'""" %= \ - (self.DpTable, DpGuid, DpVersion) + """delete from %s where DpGuid =3D'%s' and DpVersion =3D '%s'"= "" % \ + (self.DpTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) =20 - #self.Conn.commit() + # self.Conn.commit() =20 - ## Get a list of distribution install information. + # Get a list of distribution install information. # # @param Guid: distribution package guid # @param Version: distribution package version @@ -509,15 +514,15 @@ class IpiDatabase(object): Logger.Verbose(ST.MSG_GET_DP_INSTALL_LIST) (DpGuid, DpVersion) =3D (Guid, Version) SqlCommand =3D """select * from %s where DpGuid =3D'%s'""" % \ - (self.DpTable, DpGuid) + (self.DpTable, DpGuid) self.Cur.execute(SqlCommand) =20 else: Logger.Verbose(ST.MSG_GET_DP_INSTALL_INFO_START) (DpGuid, DpVersion) =3D (Guid, Version) SqlCommand =3D \ - """select * from %s where DpGuid =3D'%s' and DpVersion =3D '%s= '""" % \ - (self.DpTable, DpGuid, DpVersion) + """select * from %s where DpGuid =3D'%s' and DpVersion =3D= '%s'""" % \ + (self.DpTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) =20 DpList =3D [] @@ -531,13 +536,14 @@ class IpiDatabase(object): Logger.Verbose(ST.MSG_GET_DP_INSTALL_INFO_FINISH) return DpList =20 - ## Get a list of distribution install dirs + # Get a list of distribution install dirs # # @param Guid: distribution package guid # @param Version: distribution package version # def GetDpInstallDirList(self, Guid, Version): - SqlCommand =3D """select InstallPath from PkgInfo where DpGuid =3D= '%s' and DpVersion =3D '%s'""" % (Guid, Version) + SqlCommand =3D """select InstallPath from PkgInfo where DpGuid =3D= '%s' and DpVersion =3D '%s'""" % ( + Guid, Version) self.Cur.execute(SqlCommand) DirList =3D [] for Result in self.Cur: @@ -553,18 +559,18 @@ class IpiDatabase(object): =20 return DirList =20 - - ## Get a list of distribution install file path information. + # Get a list of distribution install file path information. # # @param Guid: distribution package guid # @param Version: distribution package version # + def GetDpFileList(self, Guid, Version): =20 (DpGuid, DpVersion) =3D (Guid, Version) SqlCommand =3D \ - """select * from %s where DpGuid =3D'%s' and DpVersion =3D '%s'"""= % \ - (self.DpFileListTable, DpGuid, DpVersion) + """select * from %s where DpGuid =3D'%s' and DpVersion =3D '%s= '""" % \ + (self.DpFileListTable, DpGuid, DpVersion) self.Cur.execute(SqlCommand) =20 PathList =3D [] @@ -575,7 +581,7 @@ class IpiDatabase(object): =20 return PathList =20 - ## Get files' repackage attribute if present that are installed into c= urrent workspace + # Get files' repackage attribute if present that are installed into cu= rrent workspace # # @retval FileDict: a Dict of file, key is file path, value is (DpGui= d, DpVersion, NewDpFileName, RePackage) # @@ -603,13 +609,13 @@ class IpiDatabase(object): =20 return FileDict =20 - ## Get (Guid, Version) from distribution file name information. + # Get (Guid, Version) from distribution file name information. # # @param DistributionFile: Distribution File # def GetDpByName(self, DistributionFile): SqlCommand =3D """select * from %s where NewPkgFileName =3D '%s'""= " % \ - (self.DpTable, DistributionFile) + (self.DpTable, DistributionFile) self.Cur.execute(SqlCommand) =20 for Result in self.Cur: @@ -621,7 +627,7 @@ class IpiDatabase(object): else: return (None, None, None) =20 - ## Get a list of package information. + # Get a list of package information. # # @param Guid: package guid # @param Version: package version @@ -632,22 +638,22 @@ class IpiDatabase(object): =20 (PackageGuid, PackageVersion) =3D (Guid, Version) SqlCommand =3D """select * from %s where PackageGuid =3D'%s' - and PackageVersion =3D '%s'""" % (self.PkgTable, PackageGuid, \ + and PackageVersion =3D '%s'""" % (self.PkgTable, PackageGuid, PackageVersion) self.Cur.execute(SqlCommand) =20 elif Version is None or len(Version.strip()) =3D=3D 0: =20 SqlCommand =3D """select * from %s where PackageGuid =3D'%s'""= " % \ - (self.PkgTable, Guid) + (self.PkgTable, Guid) self.Cur.execute(SqlCommand) else: (PackageGuid, PackageVersion) =3D (Guid, Version) SqlCommand =3D """select * from %s where PackageGuid =3D'%s' a= nd PackageVersion =3D '%s' and DpGuid =3D '%s' and DpVersion =3D '%s'""" = % \ - (self.PkgTable, PackageGuid, PackageVersion, \ - DpGuid, DpVersion) + (self.PkgTable, PackageGuid, PackageVersion, + DpGuid, DpVersion) self.Cur.execute(SqlCommand) =20 PkgList =3D [] @@ -656,31 +662,32 @@ class IpiDatabase(object): PkgVersion =3D PkgInfo[1] InstallTime =3D PkgInfo[2] InstallPath =3D PkgInfo[5] - PkgList.append((PkgGuid, PkgVersion, InstallTime, DpGuid, \ + PkgList.append((PkgGuid, PkgVersion, InstallTime, DpGuid, DpVersion, InstallPath)) =20 return PkgList =20 - - ## Get a list of module in package information. + # Get a list of module in package information. # # @param Guid: A module guid # @param Version: A module version # + def GetModInPackage(self, Guid, Version, Name, Path, PkgGuid=3D'', Pkg= Version=3D''): - (ModuleGuid, ModuleVersion, ModuleName, InstallPath) =3D (Guid, Ve= rsion, Name, Path) + (ModuleGuid, ModuleVersion, ModuleName, + InstallPath) =3D (Guid, Version, Name, Path) if PkgVersion =3D=3D '' or PkgGuid =3D=3D '': SqlCommand =3D """select * from %s where ModuleGuid =3D'%s' and ModuleVersion =3D '%s' and InstallPath =3D '%s' - and ModuleName =3D '%s'""" % (self.ModInPkgTable, ModuleGuid, \ - ModuleVersion, InstallPath, ModuleN= ame) + and ModuleName =3D '%s'""" % (self.ModInPkgTable, ModuleGuid, + ModuleVersion, InstallPath, Module= Name) self.Cur.execute(SqlCommand) else: SqlCommand =3D """select * from %s where ModuleGuid =3D'%s' and ModuleVersion =3D '%s' and InstallPath =3D '%s' and ModuleName =3D '%s' and PackageGuid =3D'%s' and PackageVersion =3D '%s' - """ % (self.ModInPkgTable, ModuleGuid, \ + """ % (self.ModInPkgTable, ModuleGuid, ModuleVersion, InstallPath, ModuleName,= PkgGuid, PkgVersion) self.Cur.execute(SqlCommand) =20 @@ -690,29 +697,30 @@ class IpiDatabase(object): ModVersion =3D ModInfo[1] InstallTime =3D ModInfo[2] InstallPath =3D ModInfo[5] - ModList.append((ModGuid, ModVersion, InstallTime, PkgGuid, \ + ModList.append((ModGuid, ModVersion, InstallTime, PkgGuid, PkgVersion, InstallPath)) =20 return ModList =20 - ## Get a list of module standalone. + # Get a list of module standalone. # # @param Guid: A module guid # @param Version: A module version # def GetStandaloneModule(self, Guid, Version, Name, Path, DpGuid=3D'', = DpVersion=3D''): - (ModuleGuid, ModuleVersion, ModuleName, InstallPath) =3D (Guid, Ve= rsion, Name, Path) + (ModuleGuid, ModuleVersion, ModuleName, + InstallPath) =3D (Guid, Version, Name, Path) if DpGuid =3D=3D '': SqlCommand =3D """select * from %s where ModuleGuid =3D'%s' and ModuleVersion =3D '%s' and InstallPath =3D '%s' - and ModuleName =3D '%s'""" % (self.StandaloneModTable, ModuleG= uid, \ - ModuleVersion, InstallPath, ModuleN= ame) + and ModuleName =3D '%s'""" % (self.StandaloneModTable, ModuleG= uid, + ModuleVersion, InstallPath, Module= Name) self.Cur.execute(SqlCommand) =20 else: SqlCommand =3D """select * from %s where ModuleGuid =3D'%s' and ModuleVersion =3D '%s' and InstallPath =3D '%s' and ModuleName= =3D '%s' and DpGuid =3D'%s' and DpVersion =3D '%s' - """ % (self.StandaloneModTable, ModuleGuid, \ + """ % (self.StandaloneModTable, ModuleGuid, ModuleVersion, ModuleName, InstallPath,= DpGuid, DpVersion) self.Cur.execute(SqlCommand) =20 @@ -722,12 +730,12 @@ class IpiDatabase(object): ModVersion =3D ModInfo[1] InstallTime =3D ModInfo[2] InstallPath =3D ModInfo[5] - ModList.append((ModGuid, ModVersion, InstallTime, DpGuid, \ + ModList.append((ModGuid, ModVersion, InstallTime, DpGuid, DpVersion, InstallPath)) =20 return ModList =20 - ## Get a list of module information that comes from DP. + # Get a list of module information that comes from DP. # # @param DpGuid: A Distribution Guid # @param DpVersion: A Distribution version @@ -746,7 +754,7 @@ class IpiDatabase(object): =20 return PathList =20 - ## Get a list of package information. + # Get a list of package information. # # @param DpGuid: A Distribution Guid # @param DpVersion: A Distribution version @@ -766,7 +774,7 @@ class IpiDatabase(object): =20 return PkgList =20 - ## Get a list of modules that depends on package information from a DP. + # Get a list of modules that depends on package information from a DP. # # @param DpGuid: A Distribution Guid # @param DpVersion: A Distribution version @@ -790,8 +798,8 @@ class IpiDatabase(object): t1.ModuleVersion =3D t2.ModuleVersion and t2.DepexGuid =3D'%s' and (t2.DepexVersion =3D '%s' or t2.DepexVersion =3D 'N/A') and t1.PackageGuid !=3D '%s' and t1.PackageVersion !=3D '%s' - """ % (self.ModInPkgTable, \ - self.ModDepexTable, Pkg[0], Pkg[1], Pkg[0],= \ + """ % (self.ModInPkgTable, + self.ModDepexTable, Pkg[0], Pkg[1], Pkg[0], Pkg[1]) self.Cur.execute(SqlCommand) for ModInfo in self.Cur: @@ -802,17 +810,17 @@ class IpiDatabase(object): =20 # # get all modules from standalone modules that depends on curr= ent - #Pkg (Guid match, Version match or NA) but not in current dp + # Pkg (Guid match, Version match or NA) but not in current dp # SqlCommand =3D \ - """select t1.ModuleGuid, t1.ModuleVersion, t1.InstallPath + """select t1.ModuleGuid, t1.ModuleVersion, t1.InstallPath from %s as t1, %s as t2 where t1.ModuleGuid =3D t2.ModuleGuid = and t1.ModuleVersion =3D t2.ModuleVersion and t2.DepexGuid =3D'%s' and (t2.DepexVersion =3D '%s' or t2.DepexVersion =3D 'N/A') and t1.DpGuid !=3D '%s' and t1.DpVersion !=3D '%s' """ % \ - (self.StandaloneModTable, self.ModDepexTable, Pkg[= 0], \ - Pkg[1], DpGuid, DpVersion) + (self.StandaloneModTable, self.ModDepexTable, Pkg[0], + Pkg[1], DpGuid, DpVersion) self.Cur.execute(SqlCommand) for ModInfo in self.Cur: ModGuid =3D ModInfo[0] @@ -820,10 +828,9 @@ class IpiDatabase(object): InstallPath =3D ModInfo[2] ModList.append((ModGuid, ModVersion, InstallPath)) =20 - return ModList =20 - ## Get Dp's list of modules. + # Get Dp's list of modules. # # @param DpGuid: A Distribution Guid # @param DpVersion: A Distribution version @@ -845,13 +852,13 @@ class IpiDatabase(object): =20 return ModList =20 - - ## Get a module depex + # Get a module depex # # @param DpGuid: A module Guid # @param DpVersion: A module version # @param Path: # + def GetModuleDepex(self, Guid, Version, Path): =20 # @@ -862,7 +869,6 @@ class IpiDatabase(object): """ % (self.ModDepexTable, Guid, Version, Path) self.Cur.execute(SqlCommand) =20 - DepexList =3D [] for DepInfo in self.Cur: DepexGuid =3D DepInfo[3] @@ -871,7 +877,7 @@ class IpiDatabase(object): =20 return DepexList =20 - ## Inventory the distribution installed to current workspace + # Inventory the distribution installed to current workspace # # Inventory the distribution installed to current workspace # @@ -889,7 +895,7 @@ class IpiDatabase(object): =20 return DpInfoList =20 - ## Close entire database + # Close entire database # # Close the connection and cursor # @@ -906,7 +912,7 @@ class IpiDatabase(object): self.Cur.close() self.Conn.close() =20 - ## Convert To Sql String + # Convert To Sql String # # 1. Replace "'" with "''" in each item of StringList # @@ -916,7 +922,3 @@ class IpiDatabase(object): if self.DpTable: pass return list(map(lambda s: s.replace("'", "''"), StringList)) - - - - diff --git a/BaseTools/Source/Python/UPT/Core/PackageFile.py b/BaseTools/So= urce/Python/UPT/Core/PackageFile.py index c9157e84d6ff..79b287cdb093 100644 --- a/BaseTools/Source/Python/UPT/Core/PackageFile.py +++ b/BaseTools/Source/Python/UPT/Core/PackageFile.py @@ -1,4 +1,4 @@ -## @file +# @file # # PackageFile class represents the zip file of a distribution package. # @@ -40,29 +40,29 @@ class PackageFile: if Mode not in ["r", "w", "a"]: Mode =3D "r" try: - self._ZipFile =3D zipfile.ZipFile(FileName, Mode, \ + self._ZipFile =3D zipfile.ZipFile(FileName, Mode, zipfile.ZIP_DEFLATED) self._Files =3D {} for Filename in self._ZipFile.namelist(): self._Files[os.path.normpath(Filename)] =3D Filename except BaseException as Xstr: Logger.Error("PackagingTool", FILE_OPEN_FAILURE, - ExtraData=3D"%s (%s)" % (FileName, str(Xstr))) + ExtraData=3D"%s (%s)" % (FileName, str(Xstr))) =20 BadFile =3D self._ZipFile.testzip() if BadFile is not None: Logger.Error("PackagingTool", FILE_CHECKSUM_FAILURE, - ExtraData=3D"[%s] in %s" % (BadFile, FileName)) + ExtraData=3D"[%s] in %s" % (BadFile, FileName)) =20 def GetZipFile(self): return self._ZipFile =20 - ## Get file name + # Get file name # def __str__(self): return self._FileName =20 - ## Extract the file + # Extract the file # # @param To: the destination file # @@ -73,7 +73,7 @@ class PackageFile: Logger.Info(Msg) self.Extract(FileN, ToFile) =20 - ## Extract the file + # Extract the file # # @param File: the extracted file # @param ToFile: the destination file @@ -88,7 +88,7 @@ class PackageFile: =20 return '' =20 - ## Extract the file + # Extract the file # # @param Which: the source path # @param ToDest: the destination path @@ -97,34 +97,34 @@ class PackageFile: Which =3D os.path.normpath(Which) if Which not in self._Files: Logger.Error("PackagingTool", FILE_NOT_FOUND, - ExtraData=3D"[%s] in %s" % (Which, self._FileN= ame)) + ExtraData=3D"[%s] in %s" % (Which, self._FileName= )) try: FileContent =3D self._ZipFile.read(self._Files[Which]) except BaseException as Xstr: Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE, - ExtraData=3D"[%s] in %s (%s)" % (Which, \ - self._FileName,= \ - str(Xstr))) + ExtraData=3D"[%s] in %s (%s)" % (Which, + self._FileName, + str(Xstr))) try: CreateDirectory(os.path.dirname(ToDest)) if os.path.exists(ToDest) and not os.access(ToDest, os.W_OK): - Logger.Warn("PackagingTool", \ + Logger.Warn("PackagingTool", ST.WRN_FILE_NOT_OVERWRITTEN % ToDest) return else: ToFile =3D __FileHookOpen__(ToDest, 'wb') except BaseException as Xstr: Logger.Error("PackagingTool", FILE_OPEN_FAILURE, - ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) + ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) =20 try: ToFile.write(FileContent) ToFile.close() except BaseException as Xstr: Logger.Error("PackagingTool", FILE_WRITE_FAILURE, - ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) + ExtraData=3D"%s (%s)" % (ToDest, str(Xstr))) =20 - ## Remove the file + # Remove the file # # @param Files: the removed files # @@ -139,12 +139,12 @@ class PackageFile: SinF =3D os.path.normpath(SinF) if SinF not in self._Files: Logger.Error("PackagingTool", FILE_NOT_FOUND, - ExtraData=3D"%s is not in %s!" % \ - (SinF, self._FileName)) + ExtraData=3D"%s is not in %s!" % + (SinF, self._FileName)) self._Files.pop(SinF) self._ZipFile.close() =20 - self._ZipFile =3D zipfile.ZipFile(self._FileName, "w", \ + self._ZipFile =3D zipfile.ZipFile(self._FileName, "w", zipfile.ZIP_DEFLATED) Cwd =3D os.getcwd() os.chdir(TmpDir) @@ -152,7 +152,7 @@ class PackageFile: os.chdir(Cwd) RemoveDirectory(TmpDir, True) =20 - ## Pack the files under Top directory, the directory shown in the zipF= ile start from BaseDir, + # Pack the files under Top directory, the directory shown in the zipFi= le start from BaseDir, # BaseDir should be the parent directory of the Top directory, for exa= mple, # Pack(Workspace\Dir1, Workspace) will pack files under Dir1, and the = path in the zipfile will # start from Workspace @@ -162,13 +162,13 @@ class PackageFile: # def Pack(self, Top, BaseDir): if not os.path.isdir(Top): - Logger.Error("PackagingTool", FILE_UNKNOWN_ERROR, \ - "%s is not a directory!" %Top) + Logger.Error("PackagingTool", FILE_UNKNOWN_ERROR, + "%s is not a directory!" % Top) =20 FilesToPack =3D [] Cwd =3D os.getcwd() os.chdir(BaseDir) - RelaDir =3D Top[Top.upper().find(BaseDir.upper()).\ + RelaDir =3D Top[Top.upper().find(BaseDir.upper()). join(len(BaseDir).join(1)):] =20 for Root, Dirs, Files in os.walk(RelaDir): @@ -193,7 +193,7 @@ class PackageFile: self.PackFiles(FilesToPack) os.chdir(Cwd) =20 - ## Pack the file + # Pack the file # # @param Files: the files to pack # @@ -204,7 +204,7 @@ class PackageFile: self.PackFile(File) os.chdir(Cwd) =20 - ## Pack the file + # Pack the file # # @param File: the files to pack # @param ArcName: the Arc Name @@ -224,9 +224,9 @@ class PackageFile: self._ZipFile.write(File, ArcName) except BaseException as Xstr: Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, - ExtraData=3D"%s (%s)" % (File, str(Xstr))) + ExtraData=3D"%s (%s)" % (File, str(Xstr))) =20 - ## Write data to the packed file + # Write data to the packed file # # @param Data: data to write # @param ArcName: the Arc Name @@ -238,13 +238,10 @@ class PackageFile: self._ZipFile.writestr(ArcName, Data) except BaseException as Xstr: Logger.Error("PackagingTool", FILE_COMPRESS_FAILURE, - ExtraData=3D"%s (%s)" % (ArcName, str(Xstr))) + ExtraData=3D"%s (%s)" % (ArcName, str(Xstr))) =20 - ## Close file + # Close file # # def Close(self): self._ZipFile.close() - - - diff --git a/BaseTools/Source/Python/UPT/Core/__init__.py b/BaseTools/Sourc= e/Python/UPT/Core/__init__.py index 9af96f9c3c13..201bcf236305 100644 --- a/BaseTools/Source/Python/UPT/Core/__init__.py +++ b/BaseTools/Source/Python/UPT/Core/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenDecFile.py index 91952a5feec7..14360fe7e1e8 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py @@ -1,4 +1,4 @@ -## @file GenDecFile.py +# @file GenDecFile.py # # This file contained the logical of transfer package object to DEC files. # @@ -61,6 +61,7 @@ import Library.DataType as DT from Library.UniClassObject import FormatUniEntry from Library.StringUtils import GetUniFileName =20 + def GenPcd(Package, Content): # # generate [Pcd] section @@ -121,15 +122,17 @@ def GenPcd(Package, Content): SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [Statement] + NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] =3D [Statement] =20 for ValidUsage in ValidUsageDict: - Content +=3D GenSection(ValidUsage, ValidUsageDict[ValidUsage], Tr= ue, True) + Content +=3D GenSection(ValidUsage, + ValidUsageDict[ValidUsage], True, True) =20 return Content =20 + def GenPcdErrorMsgSection(Package, Content): if not Package.PcdErrorCommentDict: return Content @@ -139,7 +142,8 @@ def GenPcdErrorMsgSection(Package, Content): # Content +=3D END_OF_LINE + END_OF_LINE SectionComment =3D TAB_COMMENT_SPLIT + END_OF_LINE - SectionComment +=3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_ERRO= R_SECTION_COMMENT + END_OF_LINE + SectionComment +=3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + \ + TAB_PCD_ERROR_SECTION_COMMENT + END_OF_LINE SectionComment +=3D TAB_COMMENT_SPLIT + END_OF_LINE TokenSpcCNameList =3D [] =20 @@ -152,20 +156,22 @@ def GenPcdErrorMsgSection(Package, Content): =20 for TokenSpcCNameItem in TokenSpcCNameList: SectionName =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_SECTION_= START + TAB_PCD_ERROR + \ - TAB_SPLIT + TokenSpcCNameItem + TAB_SECTION_END + EN= D_OF_LINE + TAB_SPLIT + TokenSpcCNameItem + TAB_SECTION_END + END_OF_LINE Content +=3D SectionComment Content +=3D SectionName for (TokenSpcCName, ErrorNumber) in Package.PcdErrorCommentDict: if TokenSpcCNameItem =3D=3D TokenSpcCName: - PcdErrorMsg =3D GetLocalValue(Package.PcdErrorCommentDict[= (TokenSpcCName, ErrorNumber)]) + PcdErrorMsg =3D GetLocalValue( + Package.PcdErrorCommentDict[(TokenSpcCName, ErrorNumbe= r)]) SectionItem =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_= SPACE_SPLIT + \ - ErrorNumber + TAB_SPACE_SPLIT + TAB_VALUE_SP= LIT + TAB_SPACE_SPLIT + \ - PcdErrorMsg + END_OF_LINE + ErrorNumber + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT + TAB_= SPACE_SPLIT + \ + PcdErrorMsg + END_OF_LINE Content +=3D SectionItem =20 Content +=3D TAB_COMMENT_SPLIT return Content =20 + def GenGuidProtocolPpi(Package, Content): # # generate [Guids] section @@ -202,7 +208,7 @@ def GenGuidProtocolPpi(Package, Content): SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [Statement] + NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] =3D [Statement] =20 @@ -242,7 +248,7 @@ def GenGuidProtocolPpi(Package, Content): SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [Statement] + NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] =3D [Statement] =20 @@ -282,7 +288,7 @@ def GenGuidProtocolPpi(Package, Content): SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [Statement] + NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] =3D [Statement] =20 @@ -290,13 +296,15 @@ def GenGuidProtocolPpi(Package, Content): =20 return Content =20 -## Transfer Package Object to Dec files +# Transfer Package Object to Dec files # # Transfer all contents of a standard Package Object to a Dec file # # @param Package: A Package # -def PackageToDec(Package, DistHeader =3D None): + + +def PackageToDec(Package, DistHeader=3DNone): # # Init global information for the file # @@ -333,9 +341,9 @@ def PackageToDec(Package, DistHeader =3D None): # # Generate header comment section of DEC file # - Content +=3D GenHeaderCommentSection(PackageAbstract, \ - PackageDescription, \ - PackageCopyright, \ + Content +=3D GenHeaderCommentSection(PackageAbstract, + PackageDescription, + PackageCopyright, PackageLicense).replace('\r\n', '\n= ') =20 # @@ -343,9 +351,11 @@ def PackageToDec(Package, DistHeader =3D None): # for UserExtension in Package.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D TAB_BINARY_HEADER_USERID \ - and UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER_IDENTIF= IER: - PackageBinaryAbstract =3D GetLocalValue(UserExtension.GetBinar= yAbstract()) - PackageBinaryDescription =3D GetLocalValue(UserExtension.GetBi= naryDescription()) + and UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER= _IDENTIFIER: + PackageBinaryAbstract =3D GetLocalValue( + UserExtension.GetBinaryAbstract()) + PackageBinaryDescription =3D GetLocalValue( + UserExtension.GetBinaryDescription()) PackageBinaryCopyright =3D '' PackageBinaryLicense =3D '' for (Lang, Copyright) in UserExtension.GetBinaryCopyright(): @@ -353,23 +363,23 @@ def PackageToDec(Package, DistHeader =3D None): for (Lang, License) in UserExtension.GetBinaryLicense(): PackageBinaryLicense =3D License if PackageBinaryAbstract and PackageBinaryDescription and \ - PackageBinaryCopyright and PackageBinaryLicense: + PackageBinaryCopyright and PackageBinaryLicense: Content +=3D GenHeaderCommentSection(PackageBinaryAbstract, - PackageBinaryDescription, - PackageBinaryCopyright, - PackageBinaryLicense, - True) + PackageBinaryDescriptio= n, + PackageBinaryCopyright, + PackageBinaryLicense, + True) =20 # # Generate PACKAGE_UNI_FILE for the Package # - FileHeader =3D GenHeaderCommentSection(PackageAbstract, PackageDescrip= tion, PackageCopyright, PackageLicense, False, \ + FileHeader =3D GenHeaderCommentSection(PackageAbstract, PackageDescrip= tion, PackageCopyright, PackageLicense, False, TAB_COMMENT_EDK1_SPLIT) GenPackageUNIEncodeFile(Package, FileHeader) =20 # # for each section, maintain a dict, sorted arch will be its key, - #statement list will be its data + # statement list will be its data # { 'Arch1 Arch2 Arch3': [statement1, statement2], # 'Arch1' : [statement1, statement3] # } @@ -379,31 +389,36 @@ def PackageToDec(Package, DistHeader =3D None): # generate [Defines] section # LeftOffset =3D 31 - NewSectionDict =3D {TAB_ARCH_COMMON : []} + NewSectionDict =3D {TAB_ARCH_COMMON: []} SpecialItemList =3D [] =20 - Statement =3D (u'%s ' % TAB_DEC_DEFINES_DEC_SPECIFICATION).ljust(LeftO= ffset) + u'=3D %s' % '0x00010017' + Statement =3D (u'%s ' % TAB_DEC_DEFINES_DEC_SPECIFICATION).ljust( + LeftOffset) + u'=3D %s' % '0x00010017' SpecialItemList.append(Statement) =20 BaseName =3D Package.GetBaseName() if BaseName.startswith('.') or BaseName.startswith('-'): BaseName =3D '_' + BaseName - Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_NAME).ljust(LeftOffset= ) + u'=3D %s' % BaseName + Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_NAME).ljust( + LeftOffset) + u'=3D %s' % BaseName SpecialItemList.append(Statement) =20 - Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_VERSION).ljust(LeftOff= set) + u'=3D %s' % Package.GetVersion() + Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_VERSION).ljust( + LeftOffset) + u'=3D %s' % Package.GetVersion() SpecialItemList.append(Statement) =20 - Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_GUID).ljust(LeftOffset= ) + u'=3D %s' % Package.GetGuid() + Statement =3D (u'%s ' % TAB_DEC_DEFINES_PACKAGE_GUID).ljust( + LeftOffset) + u'=3D %s' % Package.GetGuid() SpecialItemList.append(Statement) =20 if Package.UNIFlag: - Statement =3D (u'%s ' % TAB_DEC_DEFINES_PKG_UNI_FILE).ljust(LeftOf= fset) + u'=3D %s' % Package.GetBaseName() + '.uni' + Statement =3D (u'%s ' % TAB_DEC_DEFINES_PKG_UNI_FILE).ljust( + LeftOffset) + u'=3D %s' % Package.GetBaseName() + '.uni' SpecialItemList.append(Statement) =20 for SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + SpecialItemList + NewSectionDict[SortedArch] + SpecialItemList Content +=3D GenSection('Defines', NewSectionDict) =20 # @@ -418,7 +433,7 @@ def PackageToDec(Package, DistHeader =3D None): SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [ConvertPath(Statement)] + NewSectionDict[SortedArch] + [ConvertPath(Statement)] else: NewSectionDict[SortedArch] =3D [ConvertPath(Statement)] =20 @@ -452,12 +467,12 @@ def PackageToDec(Package, DistHeader =3D None): # if LibraryClass.GetSupModuleList(): Statement +=3D \ - GenDecTailComment(LibraryClass.GetSupModuleList()) + GenDecTailComment(LibraryClass.GetSupModuleList()) ArchList =3D sorted(LibraryClass.GetSupArchList()) SortedArch =3D ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D \ - NewSectionDict[SortedArch] + [Statement] + NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] =3D [Statement] =20 @@ -476,7 +491,7 @@ def PackageToDec(Package, DistHeader =3D None): NewSectionDict =3D {} for UserExtension in Package.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D TAB_BINARY_HEADER_USERID and \ - UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER_IDENTIF= IER: + UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER_IDE= NTIFIER: continue =20 # Generate Private Section first @@ -513,15 +528,18 @@ def PackageToDec(Package, DistHeader =3D None): =20 SaveFileOnChange(ContainerFile, Content, False) if DistHeader.ReadOnly: - os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) + os.chmod(ContainerFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) else: - os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|sta= t.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH) + os.chmod(ContainerFile, stat.S_IRUSR | stat.S_IRGRP | + stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) return ContainerFile =20 -## GenPackageUNIEncodeFile +# GenPackageUNIEncodeFile # GenPackageUNIEncodeFile, default is a UCS-2LE encode file # -def GenPackageUNIEncodeFile(PackageObject, UniFileHeader =3D '', Encoding= =3DTAB_ENCODING_UTF16LE): + + +def GenPackageUNIEncodeFile(PackageObject, UniFileHeader=3D'', Encoding=3D= TAB_ENCODING_UTF16LE): GenUNIFlag =3D False OnlyLANGUAGE_EN_X =3D True BinaryAbstract =3D [] @@ -538,7 +556,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeade= r =3D '', Encoding=3DTAB_ENCO =20 for UserExtension in PackageObject.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D TAB_BINARY_HEADER_USERID \ - and UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER_IDENTIF= IER: + and UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER= _IDENTIFIER: for (Key, Value) in UserExtension.GetBinaryAbstract(): if Key =3D=3D TAB_LANGUAGE_EN_X: GenUNIFlag =3D True @@ -577,25 +595,30 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHea= der =3D '', Encoding=3DTAB_ENCO if not os.path.exists(os.path.dirname(PackageObject.GetFullPath())): os.makedirs(os.path.dirname(PackageObject.GetFullPath())) =20 - ContainerFile =3D GetUniFileName(os.path.dirname(PackageObject.GetFull= Path()), PackageObject.GetBaseName()) + ContainerFile =3D GetUniFileName(os.path.dirname( + PackageObject.GetFullPath()), PackageObject.GetBaseName()) =20 Content =3D UniFileHeader + '\r\n' Content +=3D '\r\n' =20 - Content +=3D FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, Pac= kageObject.GetAbstract(), ContainerFile) + '\r\n' + Content +=3D FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, + PackageObject.GetAbstract(), ContainerFile) = + '\r\n' =20 Content +=3D FormatUniEntry('#string ' + TAB_DEC_PACKAGE_DESCRIPTION, = PackageObject.GetDescription(), ContainerFile) \ - + '\r\n' + + '\r\n' =20 - Content +=3D FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, Bina= ryAbstract, ContainerFile) + '\r\n' + Content +=3D FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, + BinaryAbstract, ContainerFile) + '\r\n' =20 - Content +=3D FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, B= inaryDescription, ContainerFile) + '\r\n' + Content +=3D FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, + BinaryDescription, ContainerFile) + '\r\n' =20 PromptGenList =3D [] HelpTextGenList =3D [] for Pcd in PackageObject.GetPcdList(): # Generate Prompt for each Pcd - PcdPromptStrName =3D '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCN= ame() + '_' + Pcd.GetCName() + '_PROMPT ' + PcdPromptStrName =3D '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCN= ame() + '_' + \ + Pcd.GetCName() + '_PROMPT ' TokenValueList =3D [] for TxtObj in Pcd.GetPromptList(): Lang =3D TxtObj.GetLang() @@ -606,12 +629,14 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHea= der =3D '', Encoding=3DTAB_ENCO if (PcdPromptStrName, Lang) not in PromptGenList: TokenValueList.append((Lang, PromptStr)) PromptGenList.append((PcdPromptStrName, Lang)) - PromptString =3D FormatUniEntry(PcdPromptStrName, TokenValueList, = ContainerFile) + '\r\n' + PromptString =3D FormatUniEntry( + PcdPromptStrName, TokenValueList, ContainerFile) + '\r\n' if PromptString not in Content: Content +=3D PromptString =20 # Generate Help String for each Pcd - PcdHelpStrName =3D '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCNam= e() + '_' + Pcd.GetCName() + '_HELP ' + PcdHelpStrName =3D '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCNam= e() + '_' + \ + Pcd.GetCName() + '_HELP ' TokenValueList =3D [] for TxtObj in Pcd.GetHelpTextList(): Lang =3D TxtObj.GetLang() @@ -622,7 +647,8 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeade= r =3D '', Encoding=3DTAB_ENCO if (PcdHelpStrName, Lang) not in HelpTextGenList: TokenValueList.append((Lang, HelpStr)) HelpTextGenList.append((PcdHelpStrName, Lang)) - HelpTextString =3D FormatUniEntry(PcdHelpStrName, TokenValueList, = ContainerFile) + '\r\n' + HelpTextString =3D FormatUniEntry( + PcdHelpStrName, TokenValueList, ContainerFile) + '\r\n' if HelpTextString not in Content: Content +=3D HelpTextString =20 @@ -633,7 +659,8 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeade= r =3D '', Encoding=3DTAB_ENCO PcdErrStrName =3D '#string ' + TAB_STR_TOKENCNAME + TAB_UN= DERLINE_SPLIT + Pcd.GetTokenSpaceGuidCName() \ + TAB_UNDERLINE_SPLIT + TAB_STR_TOKENERR \ + TAB_UNDERLINE_SPLIT + ErrorNo[2:] - PcdErrString =3D FormatUniEntry(PcdErrStrName, PcdError.Ge= tErrorMessageList(), ContainerFile) + '\r\n' + PcdErrString =3D FormatUniEntry( + PcdErrStrName, PcdError.GetErrorMessageList(), Contain= erFile) + '\r\n' if PcdErrString not in Content: Content +=3D PcdErrString =20 @@ -647,18 +674,21 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHea= der =3D '', Encoding=3DTAB_ENCO =20 return ContainerFile =20 -## GenPcdErrComment +# GenPcdErrComment # # @param PcdErrObject: PcdErrorObject # # @retval CommentStr: Generated comment lines, with prefix "#" # -def GenPcdErrComment (PcdErrObject): + + +def GenPcdErrComment(PcdErrObject): CommentStr =3D '' ErrorCode =3D PcdErrObject.GetErrorNumber() ValidValueRange =3D PcdErrObject.GetValidValueRange() if ValidValueRange: - CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_VALID= RANGE + TAB_SPACE_SPLIT + CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + \ + TAB_PCD_VALIDRANGE + TAB_SPACE_SPLIT if ErrorCode: CommentStr +=3D ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT = + TAB_SPACE_SPLIT CommentStr +=3D ValidValueRange + END_OF_LINE @@ -666,18 +696,19 @@ def GenPcdErrComment (PcdErrObject): ValidValue =3D PcdErrObject.GetValidValue() if ValidValue: ValidValueList =3D \ - [Value for Value in ValidValue.split(TAB_SPACE_SPLIT) if Value] - CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_VALID= LIST + TAB_SPACE_SPLIT + [Value for Value in ValidValue.split(TAB_SPACE_SPLIT) if Value] + CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + \ + TAB_PCD_VALIDLIST + TAB_SPACE_SPLIT if ErrorCode: CommentStr +=3D ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT = + TAB_SPACE_SPLIT CommentStr +=3D TAB_COMMA_SPLIT.join(ValidValueList) + END_OF_LINE =20 Expression =3D PcdErrObject.GetExpression() if Expression: - CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_EXPRE= SSION + TAB_SPACE_SPLIT + CommentStr =3D TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + \ + TAB_PCD_EXPRESSION + TAB_SPACE_SPLIT if ErrorCode: CommentStr +=3D ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT = + TAB_SPACE_SPLIT CommentStr +=3D Expression + END_OF_LINE =20 return CommentStr - diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenInfFile.py index dd6184e0471e..fec699e2d22d 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py @@ -1,4 +1,4 @@ -## @file GenInfFile.py +# @file GenInfFile.py # # This file contained the logical of transfer package object to INF files. # @@ -38,7 +38,7 @@ from Library.UniClassObject import FormatUniEntry from Library.StringUtils import GetUniFileName =20 =20 -## Transfer Module Object to Inf files +# Transfer Module Object to Inf files # # Transfer all contents of a standard Module Object to an Inf file # @param ModuleObject: A Module Object @@ -112,9 +112,11 @@ def ModuleToInf(ModuleObject, PackageObject=3DNone, Di= stHeader=3DNone): # for UserExtension in ModuleObject.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D DT.TAB_BINARY_HEADER_USERID \ - and UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEADER_IDEN= TIFIER: - ModuleBinaryAbstract =3D GetLocalValue(UserExtension.GetBinary= Abstract()) - ModuleBinaryDescription =3D GetLocalValue(UserExtension.GetBin= aryDescription()) + and UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEA= DER_IDENTIFIER: + ModuleBinaryAbstract =3D GetLocalValue( + UserExtension.GetBinaryAbstract()) + ModuleBinaryDescription =3D GetLocalValue( + UserExtension.GetBinaryDescription()) ModuleBinaryCopyright =3D '' ModuleBinaryLicense =3D '' for (Lang, Copyright) in UserExtension.GetBinaryCopyright(): @@ -122,17 +124,17 @@ def ModuleToInf(ModuleObject, PackageObject=3DNone, D= istHeader=3DNone): for (Lang, License) in UserExtension.GetBinaryLicense(): ModuleBinaryLicense =3D License if ModuleBinaryAbstract and ModuleBinaryDescription and \ - ModuleBinaryCopyright and ModuleBinaryLicense: + ModuleBinaryCopyright and ModuleBinaryLicense: Content +=3D GenHeaderCommentSection(ModuleBinaryAbstract, - ModuleBinaryDescription, - ModuleBinaryCopyright, - ModuleBinaryLicense, - True) + ModuleBinaryDescription, + ModuleBinaryCopyright, + ModuleBinaryLicense, + True) =20 # # Generate MODULE_UNI_FILE for module # - FileHeader =3D GenHeaderCommentSection(ModuleAbstract, ModuleDescripti= on, ModuleCopyright, ModuleLicense, False, \ + FileHeader =3D GenHeaderCommentSection(ModuleAbstract, ModuleDescripti= on, ModuleCopyright, ModuleLicense, False, DT.TAB_COMMENT_EDK1_SPLIT) ModuleUniFile =3D GenModuleUNIEncodeFile(ModuleObject, FileHeader) if ModuleUniFile: @@ -172,19 +174,25 @@ def ModuleToInf(ModuleObject, PackageObject=3DNone, D= istHeader=3DNone): # # generate [Event], [BootMode], [Hob] section # - Content +=3D GenSpecialSections(ModuleObject.GetEventList(), 'Event', = __UserExtensionsContent) - Content +=3D GenSpecialSections(ModuleObject.GetBootModeList(), 'BootM= ode', __UserExtensionsContent) - Content +=3D GenSpecialSections(ModuleObject.GetHobList(), 'Hob', __Us= erExtensionsContent) + Content +=3D GenSpecialSections(ModuleObject.GetEventList(), + 'Event', __UserExtensionsContent) + Content +=3D GenSpecialSections(ModuleObject.GetBootModeList(), + 'BootMode', __UserExtensionsContent) + Content +=3D GenSpecialSections(ModuleObject.GetHobList(), + 'Hob', __UserExtensionsContent) SaveFileOnChange(ContainerFile, Content, False) if DistHeader.ReadOnly: - os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) + os.chmod(ContainerFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) else: - os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|sta= t.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH) + os.chmod(ContainerFile, stat.S_IRUSR | stat.S_IRGRP | + stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) return ContainerFile =20 -## GenModuleUNIEncodeFile +# GenModuleUNIEncodeFile # GenModuleUNIEncodeFile, default is a UCS-2LE encode file # + + def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader=3D'', Encoding=3DDT= .TAB_ENCODING_UTF16LE): GenUNIFlag =3D False OnlyLANGUAGE_EN_X =3D True @@ -202,7 +210,7 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader= =3D'', Encoding=3DDT.TAB_ENCOD =20 for UserExtension in ModuleObject.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D DT.TAB_BINARY_HEADER_USERID \ - and UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEADER_IDEN= TIFIER: + and UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEA= DER_IDENTIFIER: for (Key, Value) in UserExtension.GetBinaryAbstract(): if Key =3D=3D DT.TAB_LANGUAGE_EN_X: GenUNIFlag =3D True @@ -216,14 +224,14 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeade= r=3D'', Encoding=3DDT.TAB_ENCOD OnlyLANGUAGE_EN_X =3D False BinaryDescription.append((Key, Value)) =20 - if not GenUNIFlag: return elif OnlyLANGUAGE_EN_X: return else: ModuleObject.UNIFlag =3D True - ContainerFile =3D GetUniFileName(os.path.dirname(ModuleObject.GetFullP= ath()), ModuleObject.GetBaseName()) + ContainerFile =3D GetUniFileName(os.path.dirname( + ModuleObject.GetFullPath()), ModuleObject.GetBaseName()) =20 if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())): os.makedirs(os.path.dirname(ModuleObject.GetFullPath())) @@ -231,16 +239,18 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeade= r=3D'', Encoding=3DDT.TAB_ENCOD Content =3D UniFileHeader + '\r\n' Content +=3D '\r\n' =20 - Content +=3D FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleOb= ject.GetAbstract(), ContainerFile) + '\r\n' + Content +=3D FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, + ModuleObject.GetAbstract(), ContainerFile) += '\r\n' =20 Content +=3D FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, Modul= eObject.GetDescription(), ContainerFile) \ - + '\r\n' + + '\r\n' =20 - BinaryAbstractString =3D FormatUniEntry('#string ' + DT.TAB_INF_BINARY= _ABSTRACT, BinaryAbstract, ContainerFile) + BinaryAbstractString =3D FormatUniEntry( + '#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, Container= File) if BinaryAbstractString: Content +=3D BinaryAbstractString + '\r\n' =20 - BinaryDescriptionString =3D FormatUniEntry('#string ' + DT.TAB_INF_BIN= ARY_DESCRIPTION, BinaryDescription, \ + BinaryDescriptionString =3D FormatUniEntry('#string ' + DT.TAB_INF_BIN= ARY_DESCRIPTION, BinaryDescription, ContainerFile) if BinaryDescriptionString: Content +=3D BinaryDescriptionString + '\r\n' @@ -255,6 +265,8 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader= =3D'', Encoding=3DDT.TAB_ENCOD ModuleObject.FileList.append((ContainerFile, Md5Sum)) =20 return ContainerFile + + def GenDefines(ModuleObject): # # generate [Defines] section @@ -270,7 +282,7 @@ def GenDefines(ModuleObject): for Statement in DefinesDict: if len(Statement.split(DT.TAB_EQUAL_SPLIT)) > 1: Statement =3D (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT= , 1)[0]).ljust(LeftOffset) \ - + u'=3D %s' % Statement.split(DT.TAB_EQUAL_SP= LIT, 1)[1].lstrip() + + u'=3D %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[1= ].lstrip() SortedArch =3D DT.TAB_ARCH_COMMON if Statement.strip().startswith(DT.TAB_INF_DEFINES_CUSTOM_MAKE= FILE): pos =3D Statement.find(DT.TAB_VALUE_SPLIT) @@ -285,51 +297,56 @@ def GenDefines(ModuleObject): SpecialStatementList =3D [] =20 # TAB_INF_DEFINES_INF_VERSION - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_INF_VERSION).ljust(LeftOffs= et) + u'=3D %s' % '0x00010017' + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_INF_VERSION).ljust( + LeftOffset) + u'=3D %s' % '0x00010017' SpecialStatementList.append(Statement) =20 # BaseName BaseName =3D ModuleObject.GetBaseName() if BaseName.startswith('.') or BaseName.startswith('-'): BaseName =3D '_' + BaseName - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_BASE_NAME).ljust(LeftOffset= ) + u'=3D %s' % BaseName + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_BASE_NAME).ljust( + LeftOffset) + u'=3D %s' % BaseName SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_FILE_GUID - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_FILE_GUID).ljust(LeftOffset= ) + u'=3D %s' % ModuleObject.GetGuid() + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_FILE_GUID).ljust( + LeftOffset) + u'=3D %s' % ModuleObject.GetGuid() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_VERSION_STRING - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_VERSION_STRING).ljust(LeftO= ffset) + u'=3D %s' % ModuleObject.GetVersion() + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_VERSION_STRING).ljust( + LeftOffset) + u'=3D %s' % ModuleObject.GetVersion() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_VERSION_STRING if ModuleObject.UNIFlag: Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(= LeftOffset) + \ - u'=3D %s' % ModuleObject.GetModuleUniFile() + u'=3D %s' % ModuleObject.GetModuleUniFile() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_MODULE_TYPE if ModuleObject.GetModuleType(): - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_MODULE_TYPE).ljust(Left= Offset) + u'=3D %s' % ModuleObject.GetModuleType() + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_MODULE_TYPE).ljust( + LeftOffset) + u'=3D %s' % ModuleObject.GetModuleType() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_PCD_IS_DRIVER if ModuleObject.GetPcdIsDriver(): Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_PCD_IS_DRIVER).ljust(Le= ftOffset) + \ - u'=3D %s' % ModuleObject.GetPcdIsDriver() + u'=3D %s' % ModuleObject.GetPcdIsDriver() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION if ModuleObject.GetUefiSpecificationVersion(): Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERS= ION).ljust(LeftOffset) + \ - u'=3D %s' % ModuleObject.GetUefiSpecificationVersion() + u'=3D %s' % ModuleObject.GetUefiSpecificationVersion() SpecialStatementList.append(Statement) =20 # TAB_INF_DEFINES_PI_SPECIFICATION_VERSION if ModuleObject.GetPiSpecificationVersion(): Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSIO= N).ljust(LeftOffset) + \ - u'=3D %s' % ModuleObject.GetPiSpecificationVersion() + u'=3D %s' % ModuleObject.GetPiSpecificationVersion() SpecialStatementList.append(Statement) =20 # LibraryClass @@ -337,9 +354,11 @@ def GenDefines(ModuleObject): if LibraryClass.GetUsage() =3D=3D DT.USAGE_ITEM_PRODUCES or \ LibraryClass.GetUsage() =3D=3D DT.USAGE_ITEM_SOMETIMES_PRODUCES: Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_LIBRARY_CLASS).ljus= t(LeftOffset) + \ - u'=3D %s' % LibraryClass.GetLibraryClass() + u'=3D %s' % LibraryClass.GetLibraryClass() if LibraryClass.GetSupModuleList(): - Statement +=3D '|' + DT.TAB_SPACE_SPLIT.join(l for l in Li= braryClass.GetSupModuleList()) + Statement +=3D '|' + \ + DT.TAB_SPACE_SPLIT.join( + l for l in LibraryClass.GetSupModuleList()) SpecialStatementList.append(Statement) =20 # Spec Item @@ -359,7 +378,8 @@ def GenDefines(ModuleObject): Destructor =3D Extern.GetDestructor() HelpStringList =3D Extern.GetHelpTextList() FFE =3D Extern.GetFeatureFlag() - ExternList.append([ArchList, EntryPoint, UnloadImage, Constructor,= Destructor, FFE, HelpStringList]) + ExternList.append([ArchList, EntryPoint, UnloadImage, + Constructor, Destructor, FFE, HelpStringList]) # # Add VALID_ARCHITECTURES information # @@ -368,17 +388,22 @@ def GenDefines(ModuleObject): ValidArchStatement =3D '\n' + '# ' + '\n' ValidArchStatement +=3D '# The following information is for refere= nce only and not required by the build tools.\n' ValidArchStatement +=3D '# ' + '\n' - ValidArchStatement +=3D '# VALID_ARCHITECTURES =3D %s' % (' '.join= (ModuleObject.SupArchList)) + '\n' + ValidArchStatement +=3D '# VALID_ARCHITECTURES =3D %s' % ( + ' '.join(ModuleObject.SupArchList)) + '\n' ValidArchStatement +=3D '# ' if DT.TAB_ARCH_COMMON not in NewSectionDict: NewSectionDict[DT.TAB_ARCH_COMMON] =3D [] - NewSectionDict[DT.TAB_ARCH_COMMON] =3D NewSectionDict[DT.TAB_ARCH_COMM= ON] + SpecialStatementList - GenMetaFileMisc.AddExternToDefineSec(NewSectionDict, DT.TAB_ARCH_COMMO= N, ExternList) + NewSectionDict[DT.TAB_ARCH_COMMON] =3D NewSectionDict[DT.TAB_ARCH_COMM= ON] + \ + SpecialStatementList + GenMetaFileMisc.AddExternToDefineSec( + NewSectionDict, DT.TAB_ARCH_COMMON, ExternList) if ValidArchStatement is not None: - NewSectionDict[DT.TAB_ARCH_COMMON] =3D NewSectionDict[DT.TAB_ARCH_= COMMON] + [ValidArchStatement] + NewSectionDict[DT.TAB_ARCH_COMMON] =3D NewSectionDict[DT.TAB_ARCH_= COMMON] + \ + [ValidArchStatement] Content +=3D GenSection('Defines', NewSectionDict) return Content =20 + def GenLibraryClasses(ModuleObject): # # generate [LibraryClasses] section @@ -451,6 +476,7 @@ def GenLibraryClasses(ModuleObject): =20 return Content =20 + def GenPackages(ModuleObject): Content =3D '' # @@ -496,6 +522,7 @@ def GenPackages(ModuleObject): Content +=3D GenSection('Packages', NewSectionDict) return Content =20 + def GenSources(ModuleObject): # # generate [Sources] section @@ -508,7 +535,8 @@ def GenSources(ModuleObject): FeatureFlag =3D Source.GetFeatureFlag() SupArchList =3D sorted(Source.GetSupArchList()) SortedArch =3D ' '.join(SupArchList) - Statement =3D GenSourceStatement(ConvertPath(SourceFile), Family, = FeatureFlag) + Statement =3D GenSourceStatement( + ConvertPath(SourceFile), Family, FeatureFlag) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] =3D NewSectionDict[SortedArch] + [S= tatement] else: @@ -517,6 +545,7 @@ def GenSources(ModuleObject): =20 return Content =20 + def GenDepex(ModuleObject): # # generate [Depex] section @@ -540,7 +569,8 @@ def GenDepex(ModuleObject): else: for ModuleType in SupModList: for Arch in SupArchList: - KeyList.append(ConvertArchForInstall(Arch) + '.' + Mod= uleType) + KeyList.append(ConvertArchForInstall( + Arch) + '.' + ModuleType) for Key in KeyList: if Key in NewSectionDict: NewSectionDict[Key] =3D NewSectionDict[Key] + [Statement] @@ -549,15 +579,17 @@ def GenDepex(ModuleObject): Content +=3D GenSection('Depex', NewSectionDict, False) =20 return Content -## GenUserExtensions +# GenUserExtensions # # GenUserExtensions # + + def GenUserExtensions(ModuleObject): NewSectionDict =3D {} for UserExtension in ModuleObject.GetUserExtensionList(): if UserExtension.GetUserID() =3D=3D DT.TAB_BINARY_HEADER_USERID an= d \ - UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEADER_IDEN= TIFIER: + UserExtension.GetIdentifier() =3D=3D DT.TAB_BINARY_HEADER_= IDENTIFIER: continue if UserExtension.GetIdentifier() =3D=3D 'Depex': continue @@ -601,6 +633,8 @@ def GenUserExtensions(ModuleObject): # # @retval Statement: The generated statement for source # + + def GenSourceStatement(SourceFile, Family, FeatureFlag, TagName=3DNone, ToolCode=3DNone, HelpStr=3DNone): Statement =3D '' @@ -632,6 +666,8 @@ def GenSourceStatement(SourceFile, Family, FeatureFlag,= TagName=3DNone, # @param Value: (Target, Family, TagName, Comment) # # + + def GenBinaryStatement(Key, Value, SubTypeGuidValue=3DNone): (FileName, FileType, FFE, SortedArch) =3D Key if SortedArch: @@ -666,11 +702,13 @@ def GenBinaryStatement(Key, Value, SubTypeGuidValue= =3DNone): elif Target: Statement +=3D '|' + Target return Statement -## GenGuidSections +# GenGuidSections # # @param GuidObjList: List of GuidObject # @retVal Content: The generated section contents # + + def GenGuidSections(GuidObjList): # # generate [Guids] section @@ -729,11 +767,13 @@ def GenGuidSections(GuidObjList): =20 return Content =20 -## GenProtocolPPiSections +# GenProtocolPPiSections # # @param ObjList: List of ProtocolObject or Ppi Object # @retVal Content: The generated section contents # + + def GenProtocolPPiSections(ObjList, IsProtocol): Content =3D '' Dict =3D Sdict() @@ -791,9 +831,11 @@ def GenProtocolPPiSections(ObjList, IsProtocol): =20 return Content =20 -## GenPcdSections +# GenPcdSections # # + + def GenPcdSections(ModuleObject): Content =3D '' if not GlobalData.gIS_BINARY_INF: @@ -868,9 +910,11 @@ def GenPcdSections(ModuleObject): =20 return Content =20 -## GenPcdSections +# GenPcdSections # # + + def GenAsBuiltPacthPcdSections(ModuleObject): PatchPcdDict =3D {} for BinaryFile in ModuleObject.GetBinaryFileList(): @@ -894,10 +938,11 @@ def GenAsBuiltPacthPcdSections(ModuleObject): if TokenSpaceName =3D=3D '' or PcdCName =3D=3D '': Logger.Error("Upt", ToolError.RESOURCE_NOT_AVAILABLE, - ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSp= aceGuidValue, Token), + ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % ( + TokenSpaceGuidValue, Token), File=3DModuleObject.GetFullPath()) Statement =3D HelpString + TokenSpaceName + '.' + PcdCName + '= | ' + PcdValue + ' | ' + \ - PcdOffset + DT.TAB_SPACE_SPLIT + PcdOffset + DT.TAB_SPACE_SPLIT # # Use binary file's Arch to be Pcd's Arch # @@ -919,9 +964,11 @@ def GenAsBuiltPacthPcdSections(ModuleObject): else: PatchPcdDict[Arch] =3D [Statement] return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict) -## GenPcdSections +# GenPcdSections # # + + def GenAsBuiltPcdExSections(ModuleObject): PcdExDict =3D {} for BinaryFile in ModuleObject.GetBinaryFileList(): @@ -942,10 +989,12 @@ def GenAsBuiltPcdExSections(ModuleObject): if TokenSpaceName =3D=3D '' or PcdCName =3D=3D '': Logger.Error("Upt", ToolError.RESOURCE_NOT_AVAILABLE, - ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSp= aceGuidValue, Token), + ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % ( + TokenSpaceGuidValue, Token), File=3DModuleObject.GetFullPath()) =20 - Statement =3D HelpString + TokenSpaceName + DT.TAB_SPLIT + Pcd= CName + DT.TAB_SPACE_SPLIT + Statement =3D HelpString + TokenSpaceName + \ + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT =20 # # Use binary file's Arch to be Pcd's Arch @@ -969,9 +1018,11 @@ def GenAsBuiltPcdExSections(ModuleObject): PcdExDict[Arch] =3D [Statement] return GenSection('PcdEx', PcdExDict) =20 -## GenSpecialSections +# GenSpecialSections # generate special sections for Event/BootMode/Hob # + + def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=3D''= ): # # generate section @@ -1017,13 +1068,15 @@ def GenSpecialSections(ObjectList, SectionName, Use= rExtensionsContent=3D''): SupArch =3D sorted(Obj.GetSupArchList()) SortedArch =3D ' '.join(SupArch) if SortedArch in NewSectionDict: - NewSectionDict[SortedArch] =3D NewSectionDict[SortedArch] + [N= ewStateMent] + NewSectionDict[SortedArch] =3D NewSectionDict[SortedArch] + \ + [NewStateMent] else: NewSectionDict[SortedArch] =3D [NewStateMent] SectionContent =3D GenSection(SectionName, NewSectionDict) SectionContent =3D SectionContent.strip() if SectionContent: - Content =3D '# ' + ('\n' + '# ').join(GetSplitValueList(SectionCon= tent, '\n')) + Content =3D '# ' + \ + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n')) Content =3D Content.lstrip() # # add a return to differentiate it between other possible sections @@ -1031,9 +1084,11 @@ def GenSpecialSections(ObjectList, SectionName, User= ExtensionsContent=3D''): if Content: Content +=3D '\n' return Content -## GenBuildOptions +# GenBuildOptions # # + + def GenBuildOptions(ModuleObject): Content =3D '' if not ModuleObject.BinaryModule: @@ -1047,7 +1102,8 @@ def GenBuildOptions(ModuleObject): continue for Arch in BuildOptionDict: if Arch in NewSectionDict: - NewSectionDict[Arch] =3D NewSectionDict[Arch] + [Build= OptionDict[Arch]] + NewSectionDict[Arch] =3D NewSectionDict[Arch] + \ + [BuildOptionDict[Arch]] else: NewSectionDict[Arch] =3D [BuildOptionDict[Arch]] Content =3D GenSection('BuildOptions', NewSectionDict) @@ -1076,9 +1132,11 @@ def GenBuildOptions(ModuleObject): Content =3D GenSection('BuildOptions', BuildOptionDict) =20 return Content -## GenBinaries +# GenBinaries # # + + def GenBinaries(ModuleObject): NewSectionDict =3D {} BinariesDict =3D [] @@ -1110,7 +1168,8 @@ def GenBinaries(ModuleObject): BinariesDict[Key] =3D [] else: if FileType =3D=3D 'SUBTYPE_GUID' and FileNameObj.GetGuidV= alue(): - Statement =3D GenBinaryStatement(Key, None, FileNameOb= j.GetGuidValue()) + Statement =3D GenBinaryStatement( + Key, None, FileNameObj.GetGuidValue()) else: Statement =3D GenBinaryStatement(Key, None) if SortedArch in NewSectionDict: diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenMetaFileMisc.py b/B= aseTools/Source/Python/UPT/GenMetaFile/GenMetaFileMisc.py index c7146977dc84..7dcea267bf4c 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenMetaFileMisc.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenMetaFileMisc.py @@ -1,4 +1,4 @@ -## @file GenMetaFileMisc.py +# @file GenMetaFileMisc.py # # This file contained the miscellaneous routines for GenMetaFile usage. # @@ -21,57 +21,69 @@ from Parser.DecParser import Dec # @param Arch: string of source file family field # @param ExternList: string of source file FeatureFlag field # + + def AddExternToDefineSec(SectionDict, Arch, ExternList): LeftOffset =3D 31 for ArchList, EntryPoint, UnloadImage, Constructor, Destructor, FFE, H= elpStringList in ExternList: if Arch or ArchList: if EntryPoint: - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_ENTRY_POINT).lj= ust(LeftOffset) + u'=3D %s' % EntryPoint + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_ENTRY_POINT).lj= ust( + LeftOffset) + u'=3D %s' % EntryPoint if FFE: Statement +=3D ' | %s' % FFE if len(HelpStringList) > 0: - Statement =3D HelpStringList[0].GetString() + '\n' + S= tatement + Statement =3D HelpStringList[0].GetString( + ) + '\n' + Statement if len(HelpStringList) > 1: Statement =3D Statement + HelpStringList[1].GetString() SectionDict[Arch] =3D SectionDict[Arch] + [Statement] =20 if UnloadImage: - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_UNLOAD_IMAGE).l= just(LeftOffset) + u'=3D %s' % UnloadImage + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_UNLOAD_IMAGE).l= just( + LeftOffset) + u'=3D %s' % UnloadImage if FFE: Statement +=3D ' | %s' % FFE =20 if len(HelpStringList) > 0: - Statement =3D HelpStringList[0].GetString() + '\n' + S= tatement + Statement =3D HelpStringList[0].GetString( + ) + '\n' + Statement if len(HelpStringList) > 1: Statement =3D Statement + HelpStringList[1].GetString() SectionDict[Arch] =3D SectionDict[Arch] + [Statement] =20 if Constructor: - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_CONSTRUCTOR).lj= ust(LeftOffset) + u'=3D %s' % Constructor + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_CONSTRUCTOR).lj= ust( + LeftOffset) + u'=3D %s' % Constructor if FFE: Statement +=3D ' | %s' % FFE =20 if len(HelpStringList) > 0: - Statement =3D HelpStringList[0].GetString() + '\n' + S= tatement + Statement =3D HelpStringList[0].GetString( + ) + '\n' + Statement if len(HelpStringList) > 1: Statement =3D Statement + HelpStringList[1].GetString() SectionDict[Arch] =3D SectionDict[Arch] + [Statement] =20 if Destructor: - Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_DESTRUCTOR).lju= st(LeftOffset) + u'=3D %s' % Destructor + Statement =3D (u'%s ' % DT.TAB_INF_DEFINES_DESTRUCTOR).lju= st( + LeftOffset) + u'=3D %s' % Destructor if FFE: Statement +=3D ' | %s' % FFE =20 if len(HelpStringList) > 0: - Statement =3D HelpStringList[0].GetString() + '\n' + S= tatement + Statement =3D HelpStringList[0].GetString( + ) + '\n' + Statement if len(HelpStringList) > 1: Statement =3D Statement + HelpStringList[1].GetString() SectionDict[Arch] =3D SectionDict[Arch] + [Statement] =20 -## ObtainPcdName +# ObtainPcdName # # Using TokenSpaceGuidValue and Token to obtain PcdName from DEC file # + + def ObtainPcdName(Packages, TokenSpaceGuidValue, Token): TokenSpaceGuidName =3D '' PcdCName =3D '' @@ -149,11 +161,13 @@ def ObtainPcdName(Packages, TokenSpaceGuidValue, Toke= n): =20 return TokenSpaceGuidName, PcdCName =20 -## _TransferDict +# _TransferDict # transfer dict that using (Statement, SortedArch) as key, # (GenericComment, UsageComment) as value into a dict that using SortedAr= ch as # key and NewStatement as value # + + def TransferDict(OrigDict, Type=3DNone): NewDict =3D {} LeftOffset =3D 0 @@ -175,7 +189,8 @@ def TransferDict(OrigDict, Type=3DNone): NewStateMent =3D Comment + Statement else: if LeftOffset: - NewStateMent =3D Statement.ljust(LeftOffset) + ' ' + Comme= nt.rstrip('\n') + NewStateMent =3D Statement.ljust( + LeftOffset) + ' ' + Comment.rstrip('\n') else: NewStateMent =3D Statement + ' ' + Comment.rstrip('\n') =20 @@ -185,4 +200,3 @@ def TransferDict(OrigDict, Type=3DNone): NewDict[SortedArch] =3D [NewStateMent] =20 return NewDict - diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenXmlFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenXmlFile.py index 50d79973b948..94fc35b1101f 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenXmlFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenXmlFile.py @@ -1,4 +1,4 @@ -## @file GenXmlFile.py +# @file GenXmlFile.py # # This file contained the logical of generate XML files. # diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/__init__.py b/BaseTool= s/Source/Python/UPT/GenMetaFile/__init__.py index 508c6d060045..1b771c1edf87 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/__init__.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py b/BaseTools/Source/P= ython/UPT/InstallPkg.py index e4c7565441ba..576b0ab38358 100644 --- a/BaseTools/Source/Python/UPT/InstallPkg.py +++ b/BaseTools/Source/Python/UPT/InstallPkg.py @@ -1,4 +1,4 @@ -## @file +# @file # Install distribution package. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -51,15 +51,17 @@ from Core.PackageFile import CreateDirectory from Core.DependencyRules import DependencyRules from Library import GlobalData =20 -## InstallNewPackage +# InstallNewPackage # # @param WorkspaceDir: Workspace Directory # @param Path: Package Path # @param CustomPath: whether need to customize path at first # -def InstallNewPackage(WorkspaceDir, Path, CustomPath =3D False): + + +def InstallNewPackage(WorkspaceDir, Path, CustomPath=3DFalse): if os.path.isabs(Path): - Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%Path) + Logger.Info(ST.MSG_RELATIVE_PATH_ONLY % Path) elif CustomPath: Logger.Info(ST.MSG_NEW_PKG_PATH) else: @@ -67,7 +69,7 @@ def InstallNewPackage(WorkspaceDir, Path, CustomPath =3D = False): Path =3D os.path.normpath(Path) FullPath =3D os.path.normpath(os.path.join(WorkspaceDir, Path)) if os.path.exists(FullPath): - Logger.Info(ST.ERR_DIR_ALREADY_EXIST%FullPath) + Logger.Info(ST.ERR_DIR_ALREADY_EXIST % FullPath) else: return Path =20 @@ -78,22 +80,24 @@ def InstallNewPackage(WorkspaceDir, Path, CustomPath = =3D False): Input =3D Input.replace('\r', '').replace('\n', '') return InstallNewPackage(WorkspaceDir, Input, False) =20 -## InstallNewModule +# InstallNewModule # # @param WorkspaceDir: Workspace Directory # @param Path: Standalone Module Path # @param PathList: The already installed standalone module Path list # -def InstallNewModule(WorkspaceDir, Path, PathList =3D None): + + +def InstallNewModule(WorkspaceDir, Path, PathList=3DNone): if PathList is None: PathList =3D [] Path =3D ConvertPath(Path) Path =3D os.path.normpath(Path) FullPath =3D os.path.normpath(os.path.join(WorkspaceDir, Path)) if os.path.exists(FullPath) and FullPath not in PathList: - Logger.Info(ST.ERR_DIR_ALREADY_EXIST%Path) + Logger.Info(ST.ERR_DIR_ALREADY_EXIST % Path) elif Path =3D=3D FullPath: - Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%FullPath) + Logger.Info(ST.MSG_RELATIVE_PATH_ONLY % FullPath) else: return Path =20 @@ -105,7 +109,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList =3D N= one): return InstallNewModule(WorkspaceDir, Input, PathList) =20 =20 -## InstallNewFile +# InstallNewFile # # @param WorkspaceDir: Workspace Direction # @param File: File @@ -113,7 +117,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList =3D N= one): def InstallNewFile(WorkspaceDir, File): FullPath =3D os.path.normpath(os.path.join(WorkspaceDir, File)) if os.path.exists(FullPath): - Logger.Info(ST.ERR_FILE_ALREADY_EXIST %File) + Logger.Info(ST.ERR_FILE_ALREADY_EXIST % File) Input =3D stdin.readline() Input =3D Input.replace('\r', '').replace('\n', '') if Input =3D=3D '': @@ -123,10 +127,12 @@ def InstallNewFile(WorkspaceDir, File): else: return File =20 -## UnZipDp +# UnZipDp # # UnZipDp # + + def UnZipDp(WorkspaceDir, DpPkgFileName, Index=3D1): ContentZipFile =3D None Logger.Quiet(ST.MSG_UZIP_PARSE_XML) @@ -134,11 +140,14 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=3D1): =20 DpDescFileName, ContentFileName =3D GetDPFile(DistFile.GetZipFile()) =20 - TempDir =3D os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" = % str(Index))) + TempDir =3D os.path.normpath(os.path.join( + WorkspaceDir, "Conf/.tmp%s" % str(Index))) GlobalData.gUNPACK_DIR.append(TempDir) - DistPkgFile =3D DistFile.UnpackFile(DpDescFileName, os.path.normpath(o= s.path.join(TempDir, DpDescFileName))) + DistPkgFile =3D DistFile.UnpackFile( + DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileN= ame))) if not DistPkgFile: - Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpD= escFileName) + Logger.Error("InstallPkg", FILE_NOT_FOUND, + ST.ERR_FILE_BROKEN % DpDescFileName) =20 # # Generate distpkg @@ -153,10 +162,11 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=3D1): # # unzip contents.zip file # - ContentFile =3D DistFile.UnpackFile(ContentFileName, os.path.normpath(= os.path.join(TempDir, ContentFileName))) + ContentFile =3D DistFile.UnpackFile( + ContentFileName, os.path.normpath(os.path.join(TempDir, ContentFil= eName))) if not ContentFile: Logger.Error("InstallPkg", FILE_NOT_FOUND, - ST.ERR_FILE_BROKEN % ContentFileName) + ST.ERR_FILE_BROKEN % ContentFileName) =20 # # Get file size @@ -174,14 +184,16 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=3D1): if DistPkg.Header.Signature !=3D Md5Signature.hexdigest(): ContentZipFile.Close() Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE, - ExtraData=3DContentFile) + ExtraData=3DContentFile) =20 return DistPkg, ContentZipFile, DpPkgFileName, DistFile =20 -## GetPackageList +# GetPackageList # # GetPackageList # + + def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, Mo= duleList, PackageList): NewDict =3D Sdict() for Guid, Version, Path in DistPkg.PackageSurfaceArea: @@ -192,9 +204,11 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options= , ContentZipFile, ModuleLi # Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version)) if Options.UseGuidedPkgPath: GuidedPkgPath =3D "%s_%s_%s" % (Package.GetName(), Guid, Versi= on) - NewPackagePath =3D InstallNewPackage(WorkspaceDir, GuidedPkgPa= th, Options.CustomPath) + NewPackagePath =3D InstallNewPackage( + WorkspaceDir, GuidedPkgPath, Options.CustomPath) else: - NewPackagePath =3D InstallNewPackage(WorkspaceDir, PackagePath= , Options.CustomPath) + NewPackagePath =3D InstallNewPackage( + WorkspaceDir, PackagePath, Options.CustomPath) InstallPackageContent(PackagePath, NewPackagePath, Package, Conten= tZipFile, Dep, WorkspaceDir, ModuleList, DistPkg.Header.ReadOnly) PackageList.append(Package) @@ -216,10 +230,12 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Option= s, ContentZipFile, ModuleLi =20 return NewDict =20 -## GetModuleList +# GetModuleList # # GetModuleList # + + def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList): # # ModulePathList will keep track of the standalone module path that @@ -240,16 +256,18 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, Content= ZipFile, ModuleList): Module =3D DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path] Logger.Info(ST.MSG_INSTALL_MODULE % Module.GetName()) if Dep.CheckModuleExists(Guid, Version, Name, Path): - Logger.Quiet(ST.WRN_MODULE_EXISTED %Path) + Logger.Quiet(ST.WRN_MODULE_EXISTED % Path) # # here check for the multiple inf share the same module path cases: # they should be installed into the same directory # ModuleFullPath =3D \ - os.path.normpath(os.path.join(WorkspaceDir, ModulePath)) + os.path.normpath(os.path.join(WorkspaceDir, ModulePath)) if ModuleFullPath not in ModulePathList: - NewModulePath =3D InstallNewModule(WorkspaceDir, ModulePath, M= odulePathList) - NewModuleFullPath =3D os.path.normpath(os.path.join(WorkspaceD= ir, NewModulePath)) + NewModulePath =3D InstallNewModule( + WorkspaceDir, ModulePath, ModulePathList) + NewModuleFullPath =3D os.path.normpath( + os.path.join(WorkspaceDir, NewModulePath)) ModulePathList.append(NewModuleFullPath) else: NewModulePath =3D ModulePath @@ -259,7 +277,8 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZi= pFile, ModuleList): # # Update module # - Module.SetModulePath(Module.GetModulePath().replace(Path, NewModul= ePath, 1)) + Module.SetModulePath( + Module.GetModulePath().replace(Path, NewModulePath, 1)) =20 NewDict[Guid, Version, Name, Module.GetModulePath()] =3D Module =20 @@ -289,6 +308,8 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZi= pFile, ModuleList): ## # Get all protocol/ppi/guid CNames and pcd name from all dependent DEC file # + + def GetDepProtocolPpiGuidPcdNames(DePackageObjList): # # [[Dec1Protocol1, Dec1Protocol2...], [Dec2Protocols...],...] @@ -340,12 +361,13 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList): =20 DependentPcdNames.append(PcdNames) =20 - return DependentProtocolCNames, DependentPpiCNames, DependentGuidCName= s, DependentPcdNames =20 ## # Check if protocol CName is redefined # + + def CheckProtoclCNameRedefined(Module, DependentProtocolCNames): for ProtocolInModule in Module.GetProtocolList(): IsCNameDefined =3D False @@ -353,15 +375,16 @@ def CheckProtoclCNameRedefined(Module, DependentProto= colCNames): if ProtocolInModule.GetCName() in PackageProtocolCNames: if IsCNameDefined: Logger.Error("\nUPT", FORMAT_INVALID, - File =3D Module.GetFullPath(), - ExtraData =3D \ - ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC %= ProtocolInModule.GetCName()) + File=3DModule.GetFullPath(), + ExtraData=3DST.ERR_INF_PARSER_ITEM_DUPLIC= ATE_IN_DEC % ProtocolInModule.GetCName()) else: IsCNameDefined =3D True =20 ## # Check if Ppi CName is redefined # + + def CheckPpiCNameRedefined(Module, DependentPpiCNames): for PpiInModule in Module.GetPpiList(): IsCNameDefined =3D False @@ -369,14 +392,16 @@ def CheckPpiCNameRedefined(Module, DependentPpiCNames= ): if PpiInModule.GetCName() in PackagePpiCNames: if IsCNameDefined: Logger.Error("\nUPT", FORMAT_INVALID, - File =3D Module.GetFullPath(), - ExtraData =3D ST.ERR_INF_PARSER_ITEM_DUPL= ICATE_IN_DEC % PpiInModule.GetCName()) + File=3DModule.GetFullPath(), + ExtraData=3DST.ERR_INF_PARSER_ITEM_DUPLIC= ATE_IN_DEC % PpiInModule.GetCName()) else: IsCNameDefined =3D True =20 ## # Check if Guid CName is redefined # + + def CheckGuidCNameRedefined(Module, DependentGuidCNames): for GuidInModule in Module.GetGuidList(): IsCNameDefined =3D False @@ -384,15 +409,16 @@ def CheckGuidCNameRedefined(Module, DependentGuidCNam= es): if GuidInModule.GetCName() in PackageGuidCNames: if IsCNameDefined: Logger.Error("\nUPT", FORMAT_INVALID, - File =3D Module.GetFullPath(), - ExtraData =3D \ - ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC %= GuidInModule.GetCName()) + File=3DModule.GetFullPath(), + ExtraData=3DST.ERR_INF_PARSER_ITEM_DUPLIC= ATE_IN_DEC % GuidInModule.GetCName()) else: IsCNameDefined =3D True =20 ## # Check if PcdName is redefined # + + def CheckPcdNameRedefined(Module, DependentPcdNames): PcdObjs =3D [] if not Module.GetBinaryFileList(): @@ -403,20 +429,23 @@ def CheckPcdNameRedefined(Module, DependentPcdNames): PcdObjs +=3D AsBuild.GetPatchPcdList() + AsBuild.GetPcdExList() =20 for PcdObj in PcdObjs: - PcdName =3D '.'.join([PcdObj.GetTokenSpaceGuidCName(), PcdObj.GetC= Name()]) + PcdName =3D '.'.join( + [PcdObj.GetTokenSpaceGuidCName(), PcdObj.GetCName()]) IsPcdNameDefined =3D False for PcdNames in DependentPcdNames: if PcdName in PcdNames: if IsPcdNameDefined: Logger.Error("\nUPT", FORMAT_INVALID, - File =3D Module.GetFullPath(), - ExtraData =3D ST.ERR_INF_PARSER_ITEM_DUPL= ICATE_IN_DEC % PcdName) + File=3DModule.GetFullPath(), + ExtraData=3DST.ERR_INF_PARSER_ITEM_DUPLIC= ATE_IN_DEC % PcdName) else: IsPcdNameDefined =3D True =20 ## # Check if any Protocol/Ppi/Guid and Pcd name is redefined in its dependen= t DEC files # + + def CheckCNameInModuleRedefined(Module, DistPkg): DePackageObjList =3D [] # @@ -431,18 +460,20 @@ def CheckCNameInModuleRedefined(Module, DistPkg): DePackageObjList.append(DistPkg.PackageSurfaceArea[Key= ]) =20 DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, Depe= ndentPcdNames =3D \ - GetDepProtocolPpiGuidPcdNames(DePackageObjList) + GetDepProtocolPpiGuidPcdNames(DePackageObjList) =20 CheckProtoclCNameRedefined(Module, DependentProtocolCNames) CheckPpiCNameRedefined(Module, DependentPpiCNames) CheckGuidCNameRedefined(Module, DependentGuidCNames) CheckPcdNameRedefined(Module, DependentPcdNames) =20 -## GenToolMisc +# GenToolMisc # # GenToolMisc # # + + def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile): ToolObject =3D DistPkg.Tools MiscObject =3D DistPkg.MiscellaneousFiles @@ -473,20 +504,21 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile= ): File =3D ConvertPath(FileObject.GetURI()) ToFile =3D os.path.normpath(os.path.join(RootDir, File)) if os.path.exists(ToFile): - Logger.Info( ST.WRN_FILE_EXISTED % ToFile ) + Logger.Info(ST.WRN_FILE_EXISTED % ToFile) # # ask for user input the new file name # - Logger.Info( ST.MSG_NEW_FILE_NAME) + Logger.Info(ST.MSG_NEW_FILE_NAME) Input =3D stdin.readline() Input =3D Input.replace('\r', '').replace('\n', '') OrigPath =3D os.path.split(ToFile)[0] ToFile =3D os.path.normpath(os.path.join(OrigPath, Input)) FromFile =3D os.path.join(FileObject.GetURI()) - Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, DistPkg.H= eader.ReadOnly, FileObject.GetExecutable()) + Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, + DistPkg.Header.ReadOnly, FileObject.GetExecut= able()) DistPkg.FileList.append((ToFile, Md5Sum)) =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -494,12 +526,15 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile= ): # # @param Options: command Options # -def Main(Options =3D None): + + +def Main(Options=3DNone): try: DataBase =3D GlobalData.gDB WorkspaceDir =3D GlobalData.gWORKSPACE if not Options.PackageFile: - Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=3DST.ERR_= SPECIFY_PACKAGE) + Logger.Error("InstallPkg", OPTION_MISSING, + ExtraData=3DST.ERR_SPECIFY_PACKAGE) =20 # Get all Dist Info DistInfoList =3D [] @@ -509,7 +544,8 @@ def Main(Options =3D None): # # unzip dist.pkg file # - DistInfoList.append(UnZipDp(WorkspaceDir, ToBeInstalledDist, I= ndex)) + DistInfoList.append( + UnZipDp(WorkspaceDir, ToBeInstalledDist, Index)) DistPkgList.append(DistInfoList[-1][0]) Index +=3D 1 =20 @@ -534,24 +570,26 @@ def Main(Options =3D None): except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) =20 except KeyboardInterrupt: ReturnCode =3D ABORT_ERROR if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) =20 except: ReturnCode =3D CODE_ERROR Logger.Error( - "\nInstallPkg", - CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.PackageFile, - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) + "\nInstallPkg", + CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.PackageFile, + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), - platform) + format_exc()) + platform) + format_exc()) finally: Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED) for ToBeInstalledDist in DistInfoList: @@ -578,6 +616,8 @@ def Main(Options =3D None): # @param WorkspaceDir: The workspace directory # @retval NewDpPkgFileName: The exact backup file name # + + def BackupDist(DpPkgFileName, Guid, Version, WorkspaceDir): DistFileName =3D os.path.split(DpPkgFileName)[1] DestDir =3D os.path.normpath(os.path.join(WorkspaceDir, GlobalData.gUP= T_DIR)) @@ -591,7 +631,7 @@ def BackupDist(DpPkgFileName, Guid, Version, WorkspaceD= ir): # # ask for user input the new file name # - Logger.Info( ST.MSG_NEW_FILE_NAME_FOR_DIST) + Logger.Info(ST.MSG_NEW_FILE_NAME_FOR_DIST) Input =3D stdin.readline() Input =3D Input.replace('\r', '').replace('\n', '') DestFile =3D os.path.normpath(os.path.join(DestDir, Input)) @@ -599,19 +639,21 @@ def BackupDist(DpPkgFileName, Guid, Version, Workspac= eDir): NewDpPkgFileName =3D DestFile[DestFile.find(DestDir) + len(DestDir) + = 1:] return NewDpPkgFileName =20 -## CheckInstallDpx method +# CheckInstallDpx method # # check whether distribution could be installed # # @param Dep: the DependencyRules instance that used to check dependency # @param DistPkg: the distribution object # + + def CheckInstallDpx(Dep, DistPkg, DistPkgFileName): # # Check distribution package installed or not # if Dep.CheckDpExists(DistPkg.Header.GetGuid(), - DistPkg.Header.GetVersion()): + DistPkg.Header.GetVersion()): Logger.Error("InstallPkg", UPT_ALREADY_INSTALLED_ERROR, ST.WRN_DIST_PKG_INSTALLED % os.path.basename(DistPkgF= ileName)) @@ -621,10 +663,10 @@ def CheckInstallDpx(Dep, DistPkg, DistPkgFileName): # if not Dep.CheckInstallDpDepexSatisfied(DistPkg): Logger.Error("InstallPkg", UNKNOWN_ERROR, - ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY, - ExtraData=3DDistPkg.Header.Name) + ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY, + ExtraData=3DDistPkg.Header.Name) =20 -## InstallModuleContent method +# InstallModuleContent method # # If this is standalone module, then Package should be none, # ModulePath should be '' @@ -637,19 +679,22 @@ def CheckInstallDpx(Dep, DistPkg, DistPkgFileName): # @param ModuleList: ModuleList # @param Package: Package # + + def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZip= File, - WorkspaceDir, ModuleList, Package =3D None, ReadOnly =3D False): + WorkspaceDir, ModuleList, Package=3DNone, ReadOnl= y=3DFalse): =20 if NewPath.startswith("\\") or NewPath.startswith("/"): NewPath =3D NewPath[1:] =20 if not IsValidInstallPath(NewPath): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewP= ath) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % NewPath) =20 NewModuleFullPath =3D os.path.normpath(os.path.join(WorkspaceDir, NewP= ath, - ConvertPath(ModulePath))) + ConvertPath(ModulePa= th))) Module.SetFullPath(os.path.normpath(os.path.join(NewModuleFullPath, - ConvertPath(Module.GetName()) + '.inf'))) + ConvertPath(Module.Ge= tName()) + '.inf'))) Module.FileList =3D [] =20 for MiscFile in Module.GetMiscFileList(): @@ -661,12 +706,15 @@ def InstallModuleContent(FromPath, NewPath, ModulePat= h, Module, ContentZipFile, File =3D File[1:] =20 if not IsValidInstallPath(File): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVAL= IDE%File) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % File) =20 FromFile =3D os.path.join(FromPath, ModulePath, File) Executable =3D Item.GetExecutable() - ToFile =3D os.path.normpath(os.path.join(NewModuleFullPath, Co= nvertPath(File))) - Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, ReadO= nly, Executable) + ToFile =3D os.path.normpath(os.path.join( + NewModuleFullPath, ConvertPath(File))) + Md5Sum =3D InstallFile(ContentZipFile, FromFile, + ToFile, ReadOnly, Executable) if Package and ((ToFile, Md5Sum) not in Package.FileList): Package.FileList.append((ToFile, Md5Sum)) elif Package: @@ -679,10 +727,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePat= h, Module, ContentZipFile, File =3D File[1:] =20 if not IsValidInstallPath(File): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%= File) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % File) =20 FromFile =3D os.path.join(FromPath, ModulePath, File) - ToFile =3D os.path.normpath(os.path.join(NewModuleFullPath, Conver= tPath(File))) + ToFile =3D os.path.normpath(os.path.join( + NewModuleFullPath, ConvertPath(File))) Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly) if Package and ((ToFile, Md5Sum) not in Package.FileList): Package.FileList.append((ToFile, Md5Sum)) @@ -698,10 +748,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePat= h, Module, ContentZipFile, File =3D File[1:] =20 if not IsValidInstallPath(File): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVAL= IDE%File) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % File) =20 FromFile =3D os.path.join(FromPath, ModulePath, File) - ToFile =3D os.path.normpath(os.path.join(NewModuleFullPath, Co= nvertPath(File))) + ToFile =3D os.path.normpath(os.path.join( + NewModuleFullPath, ConvertPath(File))) Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, ReadO= nly) if Package and ((ToFile, Md5Sum) not in Package.FileList): Package.FileList.append((ToFile, Md5Sum)) @@ -713,10 +765,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePat= h, Module, ContentZipFile, InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, Work= spaceDir, NewPath, Module, Package, ReadOnly, ModuleList) =20 -## InstallModuleContentZipFile +# InstallModuleContentZipFile # # InstallModuleContentZipFile # + + def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, Work= spaceDir, NewPath, Module, Package, ReadOnly, ModuleList): # @@ -731,11 +785,12 @@ def InstallModuleContentZipFile(ContentZipFile, FromP= ath, ModulePath, WorkspaceD FileName =3D FileName[1:] =20 if not IsValidInstallPath(FileName): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_I= NVALIDE%FileName) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % FileName) =20 FromFile =3D FileName ToFile =3D os.path.normpath(os.path.join(WorkspaceDir, - ConvertPath(FileName.replace(FromPath, NewPath, 1)= ))) + ConvertPath(FileNam= e.replace(FromPath, NewPath, 1)))) CheckList =3D copy.copy(Module.FileList) if Package: CheckList +=3D Package.FileList @@ -743,7 +798,8 @@ def InstallModuleContentZipFile(ContentZipFile, FromPat= h, ModulePath, WorkspaceD if Item[0] =3D=3D ToFile: break else: - Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFil= e, ReadOnly) + Md5Sum =3D InstallFile( + ContentZipFile, FromFile, ToFile, ReadOnly) if Package and ((ToFile, Md5Sum) not in Package.FileLi= st): Package.FileList.append((ToFile, Md5Sum)) elif Package: @@ -753,13 +809,15 @@ def InstallModuleContentZipFile(ContentZipFile, FromP= ath, ModulePath, WorkspaceD =20 ModuleList.append((Module, Package)) =20 -## FileUnderPath +# FileUnderPath # Check whether FileName started with directory specified by CheckPath # # @param FileName: the FileName need to be checked # @param CheckPath: the path need to be checked against # @return: True or False # + + def FileUnderPath(FileName, CheckPath): FileName =3D FileName.replace('\\', '/') FileName =3D os.path.normpath(FileName) @@ -774,35 +832,40 @@ def FileUnderPath(FileName, CheckPath): =20 return False =20 -## InstallFile +# InstallFile # Extract File from Zipfile, set file attribute, and return the Md5Sum # # @return: True or False # + + def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=3DF= alse): if os.path.exists(os.path.normpath(ToFile)): pass else: if not ContentZipFile or not ContentZipFile.UnpackFile(FromFile, T= oFile): - Logger.Error("UPT", FILE_NOT_FOUND, ST.ERR_INSTALL_FILE_FROM_E= MPTY_CONTENT % FromFile) + Logger.Error("UPT", FILE_NOT_FOUND, + ST.ERR_INSTALL_FILE_FROM_EMPTY_CONTENT % FromFile) =20 if ReadOnly: if not Executable: chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) else: - chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |= stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) + chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | + stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) elif Executable: chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | sta= t.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOT= H) else: - chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | sta= t.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) + chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | + stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) =20 Md5Signature =3D md5(__FileHookOpen__(str(ToFile), 'rb').read()) Md5Sum =3D Md5Signature.hexdigest() =20 return Md5Sum =20 -## InstallPackageContent method +# InstallPackageContent method # # @param FromPath: FromPath # @param ToPath: ToPath @@ -812,8 +875,10 @@ def InstallFile(ContentZipFile, FromFile, ToFile, Read= Only, Executable=3DFalse): # @param WorkspaceDir: WorkspaceDir # @param ModuleList: ModuleList # + + def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep, - WorkspaceDir, ModuleList, ReadOnly =3D False): + WorkspaceDir, ModuleList, ReadOnly=3DFalse): if Dep: pass Package.FileList =3D [] @@ -822,13 +887,14 @@ def InstallPackageContent(FromPath, ToPath, Package, = ContentZipFile, Dep, ToPath =3D ToPath[1:] =20 if not IsValidInstallPath(ToPath): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPa= th) + Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE % To= Path) =20 if FromPath.startswith("\\") or FromPath.startswith("/"): FromPath =3D FromPath[1:] =20 if not IsValidInstallPath(FromPath): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%From= Path) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % FromPath) =20 PackageFullPath =3D os.path.normpath(os.path.join(WorkspaceDir, ToPath= )) for MiscFile in Package.GetMiscFileList(): @@ -838,12 +904,14 @@ def InstallPackageContent(FromPath, ToPath, Package, = ContentZipFile, Dep, FileName =3D FileName[1:] =20 if not IsValidInstallPath(FileName): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVAL= IDE%FileName) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % FileName) =20 FromFile =3D os.path.join(FromPath, FileName) Executable =3D Item.GetExecutable() - ToFile =3D (os.path.join(PackageFullPath, ConvertPath(FileNam= e))) - Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, ReadO= nly, Executable) + ToFile =3D (os.path.join(PackageFullPath, ConvertPath(FileName= ))) + Md5Sum =3D InstallFile(ContentZipFile, FromFile, + ToFile, ReadOnly, Executable) if (ToFile, Md5Sum) not in Package.FileList: Package.FileList.append((ToFile, Md5Sum)) PackageIncludeArchList =3D [] @@ -853,23 +921,27 @@ def InstallPackageContent(FromPath, ToPath, Package, = ContentZipFile, Dep, FileName =3D FileName[1:] =20 if not IsValidInstallPath(FileName): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%= FileName) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % FileName) =20 FromFile =3D os.path.join(FromPath, FileName) - ToFile =3D os.path.normpath(os.path.join(PackageFullPath, ConvertP= ath(FileName))) + ToFile =3D os.path.normpath(os.path.join( + PackageFullPath, ConvertPath(FileName))) RetFile =3D ContentZipFile.UnpackFile(FromFile, ToFile) if RetFile =3D=3D '': # # a non-exist path in Zipfile will return '', which means an i= nclude directory in our case # save the information for later DEC creation usage and also c= reate the directory # - PackageIncludeArchList.append([Item.GetFilePath(), Item.GetSup= ArchList()]) + PackageIncludeArchList.append( + [Item.GetFilePath(), Item.GetSupArchList()]) CreateDirectory(ToFile) continue if ReadOnly: - chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH) + chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) else: - chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IW= USR|stat.S_IWGRP|stat.S_IWOTH) + chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | + stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) Md5Signature =3D md5(__FileHookOpen__(str(ToFile), 'rb').read()) Md5Sum =3D Md5Signature.hexdigest() if (ToFile, Md5Sum) not in Package.FileList: @@ -882,10 +954,12 @@ def InstallPackageContent(FromPath, ToPath, Package, = ContentZipFile, Dep, FileName =3D FileName[1:] =20 if not IsValidInstallPath(FileName): - Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%= FileName) + Logger.Error("UPT", FORMAT_INVALID, + ST.ERR_FILE_NAME_INVALIDE % FileName) =20 FromFile =3D os.path.join(FromPath, FileName) - ToFile =3D os.path.normpath(os.path.join(PackageFullPath, ConvertP= ath(FileName))) + ToFile =3D os.path.normpath(os.path.join( + PackageFullPath, ConvertPath(FileName))) Md5Sum =3D InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly) if (ToFile, Md5Sum) not in Package.FileList: Package.FileList.append((ToFile, Md5Sum)) @@ -894,9 +968,9 @@ def InstallPackageContent(FromPath, ToPath, Package, Co= ntentZipFile, Dep, # Update package # Package.SetPackagePath(Package.GetPackagePath().replace(FromPath, - ToPath, 1)) + ToPath, 1)) Package.SetFullPath(os.path.normpath(os.path.join(PackageFullPath, - ConvertPath(Package.GetName()) + '.dec'))) + ConvertPath(Package.= GetName()) + '.dec'))) =20 # # Install files in module @@ -906,12 +980,14 @@ def InstallPackageContent(FromPath, ToPath, Package, = ContentZipFile, Dep, for ModuleGuid, ModuleVersion, ModuleName, ModulePath in ModuleDict: Module =3D ModuleDict[ModuleGuid, ModuleVersion, ModuleName, Modul= ePath] InstallModuleContent(FromPath, ToPath, ModulePath, Module, - ContentZipFile, WorkspaceDir, ModuleList, Package, ReadOnly) + ContentZipFile, WorkspaceDir, ModuleList, Pac= kage, ReadOnly) =20 -## GetDPFile method +# GetDPFile method # # @param ZipFile: A ZipFile # + + def GetDPFile(ZipFile): ContentFile =3D '' DescFile =3D '' @@ -928,16 +1004,18 @@ def GetDPFile(ZipFile): continue =20 Logger.Error("PackagingTool", FILE_TYPE_MISMATCH, - ExtraData=3DST.ERR_DIST_FILE_TOOMANY) + ExtraData=3DST.ERR_DIST_FILE_TOOMANY) if not DescFile or not ContentFile: Logger.Error("PackagingTool", FILE_UNKNOWN_ERROR, - ExtraData=3DST.ERR_DIST_FILE_TOOFEW) + ExtraData=3DST.ERR_DIST_FILE_TOOFEW) return DescFile, ContentFile =20 -## InstallDp method +# InstallDp method # # Install the distribution to current workspace # + + def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, Worksp= aceDir, DataBase): # # PackageList, ModuleList record the information for the meta-data @@ -948,7 +1026,8 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, = Options, Dep, WorkspaceDir DistPkg.PackageSurfaceArea =3D GetPackageList(DistPkg, Dep, WorkspaceD= ir, Options, ContentZipFile, ModuleList= , PackageList) =20 - DistPkg.ModuleSurfaceArea =3D GetModuleList(DistPkg, Dep, WorkspaceDir= , ContentZipFile, ModuleList) + DistPkg.ModuleSurfaceArea =3D GetModuleList( + DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList) =20 GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile) =20 @@ -956,12 +1035,12 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile= , Options, Dep, WorkspaceDir # copy "Distribution File" to directory $(WORKSPACE)/conf/upt # DistFileName =3D os.path.split(DpPkgFileName)[1] - NewDpPkgFileName =3D BackupDist(DpPkgFileName, DistPkg.Header.GetGuid(= ), DistPkg.Header.GetVersion(), WorkspaceDir) + NewDpPkgFileName =3D BackupDist(DpPkgFileName, DistPkg.Header.GetGuid( + ), DistPkg.Header.GetVersion(), WorkspaceDir) =20 # # update database # Logger.Quiet(ST.MSG_UPDATE_PACKAGE_DATABASE) DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName, - DistPkg.Header.RePackage) - + DistPkg.Header.RePackage) diff --git a/BaseTools/Source/Python/UPT/InventoryWs.py b/BaseTools/Source/= Python/UPT/InventoryWs.py index 955b2e510eb2..438af59454b5 100644 --- a/BaseTools/Source/Python/UPT/InventoryWs.py +++ b/BaseTools/Source/Python/UPT/InventoryWs.py @@ -1,4 +1,4 @@ -## @file +# @file # Inventory workspace's distribution package information. # # Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
        @@ -23,12 +23,14 @@ import Logger.Log as Logger =20 from Library import GlobalData =20 -## InventoryDistInstalled +# InventoryDistInstalled # # This method retrieves the installed distribution information from the in= ternal UPT database # # @param DataBase: the UPT database # + + def InventoryDistInstalled(DataBase): DistInstalled =3D DataBase.InventoryDistInstalled() =20 @@ -47,7 +49,8 @@ def InventoryDistInstalled(DataBase): for (DpGuid, DpVersion, DpOriginalName, DpAliasFileName) in DistInstal= led: MaxGuidlen =3D max(MaxGuidlen, len(DpGuid)) MaxVerlen =3D max(MaxVerlen, len(DpVersion)) - MaxDpAliasFileNameLen =3D max(MaxDpAliasFileNameLen, len(DpAliasFi= leName)) + MaxDpAliasFileNameLen =3D max( + MaxDpAliasFileNameLen, len(DpAliasFileName)) MaxDpOrigFileNamelen =3D max(MaxDpOrigFileNamelen, len(DpOriginalN= ame)) =20 OutMsgFmt =3D "%-*s\t%-*s\t%-*s\t%-s" @@ -62,15 +65,15 @@ def InventoryDistInstalled(DataBase): =20 for (DpGuid, DpVersion, DpFileName, DpAliasFileName) in DistInstalled: OutMsg =3D OutMsgFmt % (MaxDpAliasFileNameLen, - DpAliasFileName, - MaxGuidlen, - DpGuid, - MaxVerlen, - DpVersion, - DpFileName) + DpAliasFileName, + MaxGuidlen, + DpGuid, + MaxVerlen, + DpVersion, + DpFileName) Logger.Info(OutMsg) =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -78,7 +81,9 @@ def InventoryDistInstalled(DataBase): # # @param Options: command Options # -def Main(Options =3D None): + + +def Main(Options=3DNone): if Options: pass =20 @@ -89,21 +94,23 @@ def Main(Options =3D None): except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) except KeyboardInterrupt: ReturnCode =3D ABORT_ERROR if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) except: ReturnCode =3D CODE_ERROR Logger.Error("\nInventoryWs", - CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_INVENTORYWS_ERR, - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) + CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_INVENTORYWS_ERR, + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAI= L_ADDR, + RaiseError=3DFalse + ) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), - platform) + format_exc()) + platform) + format_exc()) =20 if ReturnCode =3D=3D 0: Logger.Quiet(ST.MSG_FINISH) diff --git a/BaseTools/Source/Python/UPT/Library/CommentGenerating.py b/Bas= eTools/Source/Python/UPT/Library/CommentGenerating.py index bded508f565a..2666a8c4e9aa 100644 --- a/BaseTools/Source/Python/UPT/Library/CommentGenerating.py +++ b/BaseTools/Source/Python/UPT/Library/CommentGenerating.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define comment generating interface # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -30,33 +30,38 @@ from Library.DataType import TAB_STAR from Library.DataType import TAB_PCD_PROMPT from Library.UniClassObject import ConvertSpecialUnicodes from Library.Misc import GetLocalValue -## GenTailCommentLines +# GenTailCommentLines # # @param TailCommentLines: the tail comment lines that need to be generat= ed # @param LeadingSpaceNum: the number of leading space needed for non-fir= st # line tail comment # -def GenTailCommentLines (TailCommentLines, LeadingSpaceNum =3D 0): + + +def GenTailCommentLines(TailCommentLines, LeadingSpaceNum=3D0): TailCommentLines =3D TailCommentLines.rstrip(END_OF_LINE) CommentStr =3D TAB_SPACE_SPLIT*2 + TAB_SPECIAL_COMMENT + TAB_SPACE_SPL= IT + \ - (END_OF_LINE + LeadingSpaceNum * TAB_SPACE_SPLIT + TAB_SPACE_SPLIT*2 += TAB_SPECIAL_COMMENT + \ - TAB_SPACE_SPLIT).join(GetSplitValueList(TailCommentLines, END_OF_LINE= )) + (END_OF_LINE + LeadingSpaceNum * TAB_SPACE_SPLIT + TAB_SPACE_SPLIT= *2 + TAB_SPECIAL_COMMENT + + TAB_SPACE_SPLIT).join(GetSplitValueList(TailCommentLines, END_OF_= LINE)) =20 return CommentStr =20 -## GenGenericComment +# GenGenericComment # # @param CommentLines: Generic comment Text, maybe Multiple Lines # -def GenGenericComment (CommentLines): + + +def GenGenericComment(CommentLines): if not CommentLines: return '' CommentLines =3D CommentLines.rstrip(END_OF_LINE) - CommentStr =3D TAB_SPECIAL_COMMENT + TAB_SPACE_SPLIT + (END_OF_LINE + = TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT).join\ - (GetSplitValueList(CommentLines, END_OF_LINE)) + END_OF_LINE + CommentStr =3D TAB_SPECIAL_COMMENT + TAB_SPACE_SPLIT + \ + (END_OF_LINE + TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT).join( + GetSplitValueList(CommentLines, END_OF_LINE)) + END_OF_LINE return CommentStr =20 -## GenGenericCommentF +# GenGenericCommentF # # similar to GenGenericComment but will remove at end of comment on= ce, # and for line with only , '#\n' will be generated instead of '# \n' @@ -64,7 +69,9 @@ def GenGenericComment (CommentLines): # @param CommentLines: Generic comment Text, maybe Multiple Lines # @return CommentStr: Generated comment line # -def GenGenericCommentF (CommentLines, NumOfPound=3D1, IsPrompt=3DFalse, Is= InfLibraryClass=3DFalse): + + +def GenGenericCommentF(CommentLines, NumOfPound=3D1, IsPrompt=3DFalse, IsI= nfLibraryClass=3DFalse): if not CommentLines: return '' # @@ -76,7 +83,7 @@ def GenGenericCommentF (CommentLines, NumOfPound=3D1, IsP= rompt=3DFalse, IsInfLibrary CommentStr =3D '' if IsPrompt: CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT += TAB_PCD_PROMPT + TAB_SPACE_SPLIT + \ - CommentLines.replace(END_OF_LINE, '') + END_OF_LINE + CommentLines.replace(END_OF_LINE, '') + END_OF_LINE else: CommentLineList =3D GetSplitValueList(CommentLines, END_OF_LINE) FindLibraryClass =3D False @@ -93,16 +100,19 @@ def GenGenericCommentF (CommentLines, NumOfPound=3D1, = IsPrompt=3DFalse, IsInfLibrary CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + END_OF_LI= NE else: if FindLibraryClass and Line.find(u'@libraryclass ') > -1: - CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + TAB_S= PACE_SPLIT + Line + END_OF_LINE + CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + \ + TAB_SPACE_SPLIT + Line + END_OF_LINE elif FindLibraryClass: - CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + TAB_S= PACE_SPLIT * 16 + Line + END_OF_LINE + CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + \ + TAB_SPACE_SPLIT * 16 + Line + END_OF_LINE else: - CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + TAB_S= PACE_SPLIT + Line + END_OF_LINE + CommentStr +=3D TAB_COMMENT_SPLIT * NumOfPound + \ + TAB_SPACE_SPLIT + Line + END_OF_LINE =20 return CommentStr =20 =20 -## GenHeaderCommentSection +# GenHeaderCommentSection # # Generate Header comment sections # @@ -111,7 +121,7 @@ def GenGenericCommentF (CommentLines, NumOfPound=3D1, I= sPrompt=3DFalse, IsInfLibrary # @param Copyright possible multiple copyright lines # @param License possible multiple license lines # -def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsB= inaryHeader=3DFalse, \ +def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsB= inaryHeader=3DFalse, CommChar=3DTAB_COMMENT_SPLIT): Content =3D '' =20 @@ -124,21 +134,21 @@ def GenHeaderCommentSection(Abstract, Description, Co= pyright, License, IsBinaryH Content +=3D CommChar * 2 + TAB_SPACE_SPLIT + TAB_BINARY_HEADER_CO= MMENT + '\r\n' elif CommChar =3D=3D TAB_COMMENT_EDK1_SPLIT: Content +=3D CommChar + TAB_SPACE_SPLIT + TAB_COMMENT_EDK1_START += TAB_STAR + TAB_SPACE_SPLIT +\ - TAB_HEADER_COMMENT + '\r\n' + TAB_HEADER_COMMENT + '\r\n' else: Content +=3D CommChar * 2 + TAB_SPACE_SPLIT + TAB_HEADER_COMMENT += '\r\n' if Abstract: Abstract =3D Abstract.rstrip('\r\n') - Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList\ - = (Abstract, '\n')) + Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList + = (Abstract, '\n')) Content +=3D '\r\n' + CommChar + '\r\n' else: Content +=3D CommChar + '\r\n' =20 if Description: Description =3D Description.rstrip('\r\n') - Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList\ - (Description, '\n')) + Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList + = (Description, '\n')) Content +=3D '\r\n' + CommChar + '\r\n' =20 # @@ -146,14 +156,14 @@ def GenHeaderCommentSection(Abstract, Description, Co= pyright, License, IsBinaryH # if Copyright: Copyright =3D Copyright.rstrip('\r\n') - Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join\ - (GetSplitValueList(Copyright, '\n')) + Content +=3D CommChar + TAB_SPACE_SPLIT + \ + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList(C= opyright, '\n')) Content +=3D '\r\n' + CommChar + '\r\n' =20 if License: License =3D License.rstrip('\r\n') - Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList\ - (License, '\n')) + Content +=3D CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB= _SPACE_SPLIT).join(GetSplitValueList + = (License, '\n')) Content +=3D '\r\n' + CommChar + '\r\n' =20 if CommChar =3D=3D TAB_COMMENT_EDK1_SPLIT: @@ -164,26 +174,28 @@ def GenHeaderCommentSection(Abstract, Description, Co= pyright, License, IsBinaryH return Content =20 =20 -## GenInfPcdTailComment +# GenInfPcdTailComment # Generate Pcd tail comment for Inf, this would be one line comment # # @param Usage: Usage type # @param TailCommentText: Comment text for tail comment # -def GenInfPcdTailComment (Usage, TailCommentText): +def GenInfPcdTailComment(Usage, TailCommentText): if (Usage =3D=3D ITEM_UNDEFINED) and (not TailCommentText): return '' =20 CommentLine =3D TAB_SPACE_SPLIT.join([Usage, TailCommentText]) return GenTailCommentLines(CommentLine) =20 -## GenInfProtocolPPITailComment +# GenInfProtocolPPITailComment # Generate Protocol/PPI tail comment for Inf # # @param Usage: Usage type # @param TailCommentText: Comment text for tail comment # -def GenInfProtocolPPITailComment (Usage, Notify, TailCommentText): + + +def GenInfProtocolPPITailComment(Usage, Notify, TailCommentText): if (not Notify) and (Usage =3D=3D ITEM_UNDEFINED) and (not TailComment= Text): return '' =20 @@ -195,16 +207,18 @@ def GenInfProtocolPPITailComment (Usage, Notify, Tail= CommentText): CommentLine +=3D TAB_SPACE_SPLIT.join([Usage, TailCommentText]) return GenTailCommentLines(CommentLine) =20 -## GenInfGuidTailComment +# GenInfGuidTailComment # Generate Guid tail comment for Inf # # @param Usage: Usage type # @param TailCommentText: Comment text for tail comment # -def GenInfGuidTailComment (Usage, GuidTypeList, VariableName, TailCommentT= ext): + + +def GenInfGuidTailComment(Usage, GuidTypeList, VariableName, TailCommentTe= xt): GuidType =3D GuidTypeList[0] if (Usage =3D=3D ITEM_UNDEFINED) and (GuidType =3D=3D ITEM_UNDEFINED) = and \ - (not TailCommentText): + (not TailCommentText): return '' =20 FirstLine =3D Usage + " ## " + GuidType @@ -214,16 +228,18 @@ def GenInfGuidTailComment (Usage, GuidTypeList, Varia= bleName, TailCommentText): CommentLine =3D TAB_SPACE_SPLIT.join([FirstLine, TailCommentText]) return GenTailCommentLines(CommentLine) =20 -## GenDecGuidTailComment +# GenDecGuidTailComment # # @param SupModuleList: Supported module type list # -def GenDecTailComment (SupModuleList): + + +def GenDecTailComment(SupModuleList): CommentLine =3D TAB_SPACE_SPLIT.join(SupModuleList) return GenTailCommentLines(CommentLine) =20 =20 -## _GetHelpStr +# _GetHelpStr # get HelpString from a list of HelpTextObject, the priority refer to # related HLD # diff --git a/BaseTools/Source/Python/UPT/Library/CommentParsing.py b/BaseTo= ols/Source/Python/UPT/Library/CommentParsing.py index 7ba9830d34ac..511b2861a8d7 100644 --- a/BaseTools/Source/Python/UPT/Library/CommentParsing.py +++ b/BaseTools/Source/Python/UPT/Library/CommentParsing.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define comment parsing interface # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -44,7 +44,7 @@ from Logger.ToolError import FORMAT_INVALID from Logger.ToolError import FORMAT_NOT_SUPPORTED from Logger import StringTable as ST =20 -## ParseHeaderCommentSection +# ParseHeaderCommentSection # # Parse Header comment section lines, extract Abstract, Description, Copyr= ight # , License lines @@ -52,7 +52,9 @@ from Logger import StringTable as ST # @param CommentList: List of (Comment, LineNumber) # @param FileName: FileName of the comment # -def ParseHeaderCommentSection(CommentList, FileName =3D None, IsBinaryHead= er =3D False): + + +def ParseHeaderCommentSection(CommentList, FileName=3DNone, IsBinaryHeader= =3DFalse): Abstract =3D '' Description =3D '' Copyright =3D '' @@ -79,7 +81,8 @@ def ParseHeaderCommentSection(CommentList, FileName =3D N= one, IsBinaryHeader =3D Fal LineNo =3D Item[1] =20 if not Line.startswith(TAB_COMMENT_SPLIT) and Line: - Logger.Error("\nUPT", FORMAT_INVALID, ST.ERR_INVALID_COMMENT_F= ORMAT, FileName, Item[1]) + Logger.Error("\nUPT", FORMAT_INVALID, + ST.ERR_INVALID_COMMENT_FORMAT, FileName, Item[1]) Comment =3D CleanString2(Line)[1] Comment =3D Comment.strip() # @@ -87,7 +90,7 @@ def ParseHeaderCommentSection(CommentList, FileName =3D N= one, IsBinaryHeader =3D Fal # indication of different block; or in the position that Abstract = should be, also keep it # as it indicates that no abstract # - if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICEN= SE, \ + if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICEN= SE, HEADER_COMMENT_DESCR= IPTION, HEADER_COMMENT_ABSTRACT]: continue =20 @@ -105,7 +108,8 @@ def ParseHeaderCommentSection(CommentList, FileName =3D= None, IsBinaryHeader =3D Fal HeaderCommentStage =3D HEADER_COMMENT_DESCRIPTION elif _IsCopyrightLine(Comment): Result, ErrMsg =3D _ValidateCopyright(Comment) - ValidateCopyright(Result, ST.WRN_INVALID_COPYRIGHT, Fi= leName, LineNo, ErrMsg) + ValidateCopyright( + Result, ST.WRN_INVALID_COPYRIGHT, FileName, LineNo= , ErrMsg) Copyright +=3D Comment + EndOfLine HeaderCommentStage =3D HEADER_COMMENT_COPYRIGHT else: @@ -117,7 +121,8 @@ def ParseHeaderCommentSection(CommentList, FileName =3D= None, IsBinaryHeader =3D Fal # if _IsCopyrightLine(Comment): Result, ErrMsg =3D _ValidateCopyright(Comment) - ValidateCopyright(Result, ST.WRN_INVALID_COPYRIGHT, Fi= leName, LineNo, ErrMsg) + ValidateCopyright( + Result, ST.WRN_INVALID_COPYRIGHT, FileName, LineNo= , ErrMsg) Copyright +=3D Comment + EndOfLine HeaderCommentStage =3D HEADER_COMMENT_COPYRIGHT else: @@ -125,7 +130,8 @@ def ParseHeaderCommentSection(CommentList, FileName =3D= None, IsBinaryHeader =3D Fal elif HeaderCommentStage =3D=3D HEADER_COMMENT_COPYRIGHT: if _IsCopyrightLine(Comment): Result, ErrMsg =3D _ValidateCopyright(Comment) - ValidateCopyright(Result, ST.WRN_INVALID_COPYRIGHT, Fi= leName, LineNo, ErrMsg) + ValidateCopyright( + Result, ST.WRN_INVALID_COPYRIGHT, FileName, LineNo= , ErrMsg) Copyright +=3D Comment + EndOfLine else: # @@ -144,14 +150,16 @@ def ParseHeaderCommentSection(CommentList, FileName = =3D None, IsBinaryHeader =3D Fal =20 return Abstract.strip(), Description.strip(), Copyright.strip(), Licen= se.strip() =20 -## _IsCopyrightLine +# _IsCopyrightLine # check whether current line is copyright line, the criteria is whether th= ere is case insensitive keyword "Copyright" # followed by zero or more white space characters followed by a "(" charac= ter # # @param LineContent: the line need to be checked # @return: True if current line is copyright line, False else # -def _IsCopyrightLine (LineContent): + + +def _IsCopyrightLine(LineContent): LineContent =3D LineContent.upper() Result =3D False =20 @@ -161,13 +169,15 @@ def _IsCopyrightLine (LineContent): =20 return Result =20 -## ParseGenericComment +# ParseGenericComment # # @param GenericComment: Generic comment list, element of # (CommentLine, LineNum) # @param ContainerFile: Input value for filename of Dec file # -def ParseGenericComment (GenericComment, ContainerFile=3DNone, SkipTag=3DN= one): + + +def ParseGenericComment(GenericComment, ContainerFile=3DNone, SkipTag=3DNo= ne): if ContainerFile: pass HelpTxt =3D None @@ -188,13 +198,15 @@ def ParseGenericComment (GenericComment, ContainerFil= e=3DNone, SkipTag=3DNone): =20 return HelpTxt =20 -## ParsePcdErrorCode +# ParsePcdErrorCode # # @param Value: original ErrorCode value # @param ContainerFile: Input value for filename of Dec file # @param LineNum: Line Num # -def ParsePcdErrorCode (Value =3D None, ContainerFile =3D None, LineNum =3D= None): + + +def ParsePcdErrorCode(Value=3DNone, ContainerFile=3DNone, LineNum=3DNone): try: if Value.strip().startswith((TAB_HEX_START, TAB_CAPHEX_START)): Base =3D 16 @@ -203,28 +215,30 @@ def ParsePcdErrorCode (Value =3D None, ContainerFile = =3D None, LineNum =3D None): ErrorCode =3D int(Value, Base) if ErrorCode > PCD_ERR_CODE_MAX_SIZE or ErrorCode < 0: Logger.Error('Parser', - FORMAT_NOT_SUPPORTED, - "The format %s of ErrorCode is not valid, should b= e UNIT32 type or long type" % Value, - File =3D ContainerFile, - Line =3D LineNum) + FORMAT_NOT_SUPPORTED, + "The format %s of ErrorCode is not valid, should = be UNIT32 type or long type" % Value, + File=3DContainerFile, + Line=3DLineNum) ErrorCode =3D '0x%x' % ErrorCode return ErrorCode except ValueError as XStr: if XStr: pass Logger.Error('Parser', - FORMAT_NOT_SUPPORTED, - "The format %s of ErrorCode is not valid, should be UN= IT32 type or long type" % Value, - File =3D ContainerFile, - Line =3D LineNum) + FORMAT_NOT_SUPPORTED, + "The format %s of ErrorCode is not valid, should be U= NIT32 type or long type" % Value, + File=3DContainerFile, + Line=3DLineNum) =20 -## ParseDecPcdGenericComment +# ParseDecPcdGenericComment # # @param GenericComment: Generic comment list, element of (CommentLine, # LineNum) # @param ContainerFile: Input value for filename of Dec file # -def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGu= idCName, CName, MacroReplaceDict): + + +def ParseDecPcdGenericComment(GenericComment, ContainerFile, TokenSpaceGui= dCName, CName, MacroReplaceDict): HelpStr =3D '' PromptStr =3D '' PcdErr =3D None @@ -239,19 +253,20 @@ def ParseDecPcdGenericComment (GenericComment, Contai= nerFile, TokenSpaceGuidCNam # To replace Macro # MACRO_PATTERN =3D '[\t\s]*\$\([A-Z][_A-Z0-9]*\)' - MatchedStrs =3D re.findall(MACRO_PATTERN, Comment) + MatchedStrs =3D re.findall(MACRO_PATTERN, Comment) for MatchedStr in MatchedStrs: if MatchedStr: Macro =3D MatchedStr.strip().lstrip('$(').rstrip(')').stri= p() if Macro in MacroReplaceDict: - Comment =3D Comment.replace(MatchedStr, MacroReplaceDi= ct[Macro]) + Comment =3D Comment.replace( + MatchedStr, MacroReplaceDict[Macro]) if Comment.startswith(TAB_PCD_VALIDRANGE): if ValidValueNum > 0 or ExpressionNum > 0: Logger.Error('Parser', FORMAT_NOT_SUPPORTED, ST.WRN_MULTI_PCD_RANGES, - File =3D ContainerFile, - Line =3D LineNum) + File=3DContainerFile, + Line=3DLineNum) else: PcdErr =3D PcdErrorObject() PcdErr.SetTokenSpaceGuidCName(TokenSpaceGuidCName) @@ -264,30 +279,32 @@ def ParseDecPcdGenericComment (GenericComment, Contai= nerFile, TokenSpaceGuidCNam if Valid: ValueList =3D ValidRange.split(TAB_VALUE_SPLIT) if len(ValueList) > 1: - PcdErr.SetValidValueRange((TAB_VALUE_SPLIT.join(ValueL= ist[1:])).strip()) - PcdErr.SetErrorNumber(ParsePcdErrorCode(ValueList[0], = ContainerFile, LineNum)) + PcdErr.SetValidValueRange( + (TAB_VALUE_SPLIT.join(ValueList[1:])).strip()) + PcdErr.SetErrorNumber(ParsePcdErrorCode( + ValueList[0], ContainerFile, LineNum)) else: PcdErr.SetValidValueRange(ValidRange) PcdErrList.append(PcdErr) else: Logger.Error("Parser", - FORMAT_NOT_SUPPORTED, - Cause, - ContainerFile, - LineNum) + FORMAT_NOT_SUPPORTED, + Cause, + ContainerFile, + LineNum) elif Comment.startswith(TAB_PCD_VALIDLIST): if ValidRangeNum > 0 or ExpressionNum > 0: Logger.Error('Parser', FORMAT_NOT_SUPPORTED, ST.WRN_MULTI_PCD_RANGES, - File =3D ContainerFile, - Line =3D LineNum) + File=3DContainerFile, + Line=3DLineNum) elif ValidValueNum > 0: Logger.Error('Parser', FORMAT_NOT_SUPPORTED, ST.WRN_MULTI_PCD_VALIDVALUE, - File =3D ContainerFile, - Line =3D LineNum) + File=3DContainerFile, + Line=3DLineNum) else: PcdErr =3D PcdErrorObject() PcdErr.SetTokenSpaceGuidCName(TokenSpaceGuidCName) @@ -295,30 +312,34 @@ def ParseDecPcdGenericComment (GenericComment, Contai= nerFile, TokenSpaceGuidCNam PcdErr.SetFileLine(Comment) PcdErr.SetLineNum(LineNum) ValidValueNum +=3D 1 - ValidValueExpr =3D Comment.replace(TAB_PCD_VALIDLIST, "", = 1).strip() + ValidValueExpr =3D Comment.replace( + TAB_PCD_VALIDLIST, "", 1).strip() Valid, Cause =3D _CheckListExpression(ValidValueExpr) if Valid: - ValidValue =3D Comment.replace(TAB_PCD_VALIDLIST, "", 1).r= eplace(TAB_COMMA_SPLIT, TAB_SPACE_SPLIT) + ValidValue =3D Comment.replace(TAB_PCD_VALIDLIST, "", 1).r= eplace( + TAB_COMMA_SPLIT, TAB_SPACE_SPLIT) ValueList =3D ValidValue.split(TAB_VALUE_SPLIT) if len(ValueList) > 1: - PcdErr.SetValidValue((TAB_VALUE_SPLIT.join(ValueList[1= :])).strip()) - PcdErr.SetErrorNumber(ParsePcdErrorCode(ValueList[0], = ContainerFile, LineNum)) + PcdErr.SetValidValue( + (TAB_VALUE_SPLIT.join(ValueList[1:])).strip()) + PcdErr.SetErrorNumber(ParsePcdErrorCode( + ValueList[0], ContainerFile, LineNum)) else: PcdErr.SetValidValue(ValidValue) PcdErrList.append(PcdErr) else: Logger.Error("Parser", - FORMAT_NOT_SUPPORTED, - Cause, - ContainerFile, - LineNum) + FORMAT_NOT_SUPPORTED, + Cause, + ContainerFile, + LineNum) elif Comment.startswith(TAB_PCD_EXPRESSION): if ValidRangeNum > 0 or ValidValueNum > 0: Logger.Error('Parser', FORMAT_NOT_SUPPORTED, ST.WRN_MULTI_PCD_RANGES, - File =3D ContainerFile, - Line =3D LineNum) + File=3DContainerFile, + Line=3DLineNum) else: PcdErr =3D PcdErrorObject() PcdErr.SetTokenSpaceGuidCName(TokenSpaceGuidCName) @@ -331,24 +352,26 @@ def ParseDecPcdGenericComment (GenericComment, Contai= nerFile, TokenSpaceGuidCNam if Valid: ValueList =3D Expression.split(TAB_VALUE_SPLIT) if len(ValueList) > 1: - PcdErr.SetExpression((TAB_VALUE_SPLIT.join(ValueList[1= :])).strip()) - PcdErr.SetErrorNumber(ParsePcdErrorCode(ValueList[0], = ContainerFile, LineNum)) + PcdErr.SetExpression( + (TAB_VALUE_SPLIT.join(ValueList[1:])).strip()) + PcdErr.SetErrorNumber(ParsePcdErrorCode( + ValueList[0], ContainerFile, LineNum)) else: PcdErr.SetExpression(Expression) PcdErrList.append(PcdErr) else: Logger.Error("Parser", - FORMAT_NOT_SUPPORTED, - Cause, - ContainerFile, - LineNum) + FORMAT_NOT_SUPPORTED, + Cause, + ContainerFile, + LineNum) elif Comment.startswith(TAB_PCD_PROMPT): if PromptStr: Logger.Error('Parser', FORMAT_NOT_SUPPORTED, ST.WRN_MULTI_PCD_PROMPT, - File =3D ContainerFile, - Line =3D LineNum) + File=3DContainerFile, + Line=3DLineNum) PromptStr =3D Comment.replace(TAB_PCD_PROMPT, "", 1).strip() else: if Comment: @@ -363,14 +386,16 @@ def ParseDecPcdGenericComment (GenericComment, Contai= nerFile, TokenSpaceGuidCNam =20 return HelpStr, PcdErrList, PromptStr =20 -## ParseDecPcdTailComment +# ParseDecPcdTailComment # # @param TailCommentList: Tail comment list of Pcd, item of format (Com= ment, LineNum) # @param ContainerFile: Input value for filename of Dec file # @retVal SupModuleList: The supported module type list detected # @retVal HelpStr: The generic help text string detected # -def ParseDecPcdTailComment (TailCommentList, ContainerFile): + + +def ParseDecPcdTailComment(TailCommentList, ContainerFile): assert(len(TailCommentList) =3D=3D 1) TailComment =3D TailCommentList[0][0] LineNum =3D TailCommentList[0][1] @@ -399,7 +424,7 @@ def ParseDecPcdTailComment (TailCommentList, ContainerF= ile): elif Mod not in SUP_MODULE_LIST: Logger.Error("UPT", FORMAT_INVALID, - ST.WRN_INVALID_MODULE_TYPE%Mod, + ST.WRN_INVALID_MODULE_TYPE % Mod, ContainerFile, LineNum) else: @@ -407,10 +432,12 @@ def ParseDecPcdTailComment (TailCommentList, Containe= rFile): =20 return SupModuleList, HelpStr =20 -## _CheckListExpression +# _CheckListExpression # # @param Expression: Pcd value list expression # + + def _CheckListExpression(Expression): ListExpr =3D '' if TAB_VALUE_SPLIT in Expression: @@ -420,10 +447,12 @@ def _CheckListExpression(Expression): =20 return IsValidListExpr(ListExpr) =20 -## _CheckExpression +# _CheckExpression # # @param Expression: Pcd value expression # + + def _CheckExpression(Expression): Expr =3D '' if TAB_VALUE_SPLIT in Expression: @@ -432,10 +461,12 @@ def _CheckExpression(Expression): Expr =3D Expression return IsValidLogicalExpr(Expr, True) =20 -## _CheckRangeExpression +# _CheckRangeExpression # # @param Expression: Pcd range expression # + + def _CheckRangeExpression(Expression): RangeExpr =3D '' if TAB_VALUE_SPLIT in Expression: @@ -445,21 +476,25 @@ def _CheckRangeExpression(Expression): =20 return IsValidRangeExpr(RangeExpr) =20 -## ValidateCopyright +# ValidateCopyright # # # + + def ValidateCopyright(Result, ErrType, FileName, LineNo, ErrMsg): if not Result: Logger.Warn("\nUPT", ErrType, FileName, LineNo, ErrMsg) =20 -## _ValidateCopyright +# _ValidateCopyright # # @param Line: Line that contains copyright information, # stripped # # @retval Result: True if line is conformed to Spec format, False else # @retval ErrMsg: the detailed error description # + + def _ValidateCopyright(Line): if Line: pass @@ -468,14 +503,16 @@ def _ValidateCopyright(Line): =20 return Result, ErrMsg =20 -def GenerateTokenList (Comment): + +def GenerateTokenList(Comment): # # Tokenize Comment using '#' and ' ' as token separators # ReplacedComment =3D None while Comment !=3D ReplacedComment: ReplacedComment =3D Comment - Comment =3D Comment.replace('##', '#').replace(' ', ' ').replace(= ' ', '#').strip('# ') + Comment =3D Comment.replace('##', '#').replace( + ' ', ' ').replace(' ', '#').strip('# ') return Comment.split('#') =20 =20 @@ -485,7 +522,7 @@ def GenerateTokenList (Comment): # RemoveTokens - A list of tokens to remove from help text # ParseVariable - True for parsing [Guids]. Otherwise False # -def ParseComment (Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVar= iable): +def ParseComment(Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVari= able): # # Initialize return values # @@ -503,7 +540,7 @@ def ParseComment (Comment, UsageTokens, TypeTokens, Rem= oveTokens, ParseVariable) # List =3D Comment.split(':', 1) if len(List) > 1: - SubList =3D GenerateTokenList (List[0].strip()) + SubList =3D GenerateTokenList(List[0].strip()) if len(SubList) in [1, 2] and SubList[-1] =3D=3D 'Variable': if List[1].strip().find('L"') =3D=3D 0: Comment =3D List[0].strip() + ':' + List[1].strip() @@ -524,7 +561,7 @@ def ParseComment (Comment, UsageTokens, TypeTokens, Rem= oveTokens, ParseVariable) String =3D Comment[Start:] End =3D String[2:].find('"') if End >=3D 0: - SubList =3D GenerateTokenList (Comment[:Start]) + SubList =3D GenerateTokenList(Comment[:Start]) if len(SubList) < 2: Comment =3D Comment[:Start] + String[End + 3:] String =3D String[:End + 3] @@ -540,7 +577,7 @@ def ParseComment (Comment, UsageTokens, TypeTokens, Rem= oveTokens, ParseVariable) # # Tokenize Comment using '#' and ' ' as token separators # - List =3D GenerateTokenList (Comment) + List =3D GenerateTokenList(Comment) =20 # # Search first two tokens for Usage and Type and remove any matching t= okens diff --git a/BaseTools/Source/Python/UPT/Library/DataType.py b/BaseTools/So= urce/Python/UPT/Library/DataType.py index 2033149aa6dc..a5e0bb154e33 100644 --- a/BaseTools/Source/Python/UPT/Library/DataType.py +++ b/BaseTools/Source/Python/UPT/Library/DataType.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class for data type structure # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -42,18 +42,18 @@ USAGE_LIST =3D ["CONSUMES", "SOMETIMES_PRODUCES"] =20 TAB_LANGUAGE_EN_US =3D 'en-US' -TAB_LANGUAGE_ENG =3D 'eng' -TAB_LANGUAGE_EN =3D 'en' -TAB_LANGUAGE_EN_X =3D 'en-x-tianocore' +TAB_LANGUAGE_ENG =3D 'eng' +TAB_LANGUAGE_EN =3D 'en' +TAB_LANGUAGE_EN_X =3D 'en-x-tianocore' =20 -USAGE_ITEM_PRODUCES =3D 'PRODUCES' +USAGE_ITEM_PRODUCES =3D 'PRODUCES' USAGE_ITEM_SOMETIMES_PRODUCES =3D 'SOMETIMES_PRODUCES' -USAGE_ITEM_CONSUMES =3D 'CONSUMES' +USAGE_ITEM_CONSUMES =3D 'CONSUMES' USAGE_ITEM_SOMETIMES_CONSUMES =3D 'SOMETIMES_CONSUMES' -USAGE_ITEM_TO_START =3D 'TO_START' -USAGE_ITEM_BY_START =3D 'BY_START' -USAGE_ITEM_NOTIFY =3D 'NOTIFY' -USAGE_ITEM_UNDEFINED =3D 'UNDEFINED' +USAGE_ITEM_TO_START =3D 'TO_START' +USAGE_ITEM_BY_START =3D 'BY_START' +USAGE_ITEM_NOTIFY =3D 'NOTIFY' +USAGE_ITEM_UNDEFINED =3D 'UNDEFINED' =20 USAGE_CONSUMES_LIST =3D [USAGE_ITEM_CONSUMES, 'CONSUMED', @@ -90,103 +90,103 @@ TAB_STR_TOKENERR =3D 'ERR' # Dictionary of usage tokens and their synonyms # ALL_USAGE_TOKENS =3D { - "PRODUCES" : "PRODUCES", - "PRODUCED" : "PRODUCES", - "ALWAYS_PRODUCES" : "PRODUCES", - "ALWAYS_PRODUCED" : "PRODUCES", - "SOMETIMES_PRODUCES" : "SOMETIMES_PRODUCES", - "SOMETIMES_PRODUCED" : "SOMETIMES_PRODUCES", - "CONSUMES" : "CONSUMES", - "CONSUMED" : "CONSUMES", - "ALWAYS_CONSUMES" : "CONSUMES", - "ALWAYS_CONSUMED" : "CONSUMES", - "SOMETIMES_CONSUMES" : "SOMETIMES_CONSUMES", - "SOMETIMES_CONSUMED" : "SOMETIMES_CONSUMES", - "SOMETIME_CONSUMES" : "SOMETIMES_CONSUMES", - "UNDEFINED" : "UNDEFINED" - } + "PRODUCES": "PRODUCES", + "PRODUCED": "PRODUCES", + "ALWAYS_PRODUCES": "PRODUCES", + "ALWAYS_PRODUCED": "PRODUCES", + "SOMETIMES_PRODUCES": "SOMETIMES_PRODUCES", + "SOMETIMES_PRODUCED": "SOMETIMES_PRODUCES", + "CONSUMES": "CONSUMES", + "CONSUMED": "CONSUMES", + "ALWAYS_CONSUMES": "CONSUMES", + "ALWAYS_CONSUMED": "CONSUMES", + "SOMETIMES_CONSUMES": "SOMETIMES_CONSUMES", + "SOMETIMES_CONSUMED": "SOMETIMES_CONSUMES", + "SOMETIME_CONSUMES": "SOMETIMES_CONSUMES", + "UNDEFINED": "UNDEFINED" +} =20 PROTOCOL_USAGE_TOKENS =3D { - "TO_START" : "TO_START", - "BY_START" : "BY_START" - } + "TO_START": "TO_START", + "BY_START": "BY_START" +} =20 -PROTOCOL_USAGE_TOKENS.update (ALL_USAGE_TOKENS) +PROTOCOL_USAGE_TOKENS.update(ALL_USAGE_TOKENS) =20 # # Dictionary of GUID type tokens # GUID_TYPE_TOKENS =3D { - "Event" : "Event", - "File" : "File", - "FV" : "FV", - "GUID" : "GUID", - "Guid" : "GUID", - "HII" : "HII", - "HOB" : "HOB", - "Hob" : "HOB", - "Hob:" : "HOB", - "SystemTable" : "SystemTable", - "TokenSpaceGuid" : "TokenSpaceGuid", - "UNDEFINED" : "UNDEFINED" - } + "Event": "Event", + "File": "File", + "FV": "FV", + "GUID": "GUID", + "Guid": "GUID", + "HII": "HII", + "HOB": "HOB", + "Hob": "HOB", + "Hob:": "HOB", + "SystemTable": "SystemTable", + "TokenSpaceGuid": "TokenSpaceGuid", + "UNDEFINED": "UNDEFINED" +} =20 # # Dictionary of Protocol Notify tokens and their synonyms # PROTOCOL_NOTIFY_TOKENS =3D { - "NOTIFY" : "NOTIFY", - "PROTOCOL_NOTIFY" : "NOTIFY", - "UNDEFINED" : "UNDEFINED" - } + "NOTIFY": "NOTIFY", + "PROTOCOL_NOTIFY": "NOTIFY", + "UNDEFINED": "UNDEFINED" +} =20 # # Dictionary of PPI Notify tokens and their synonyms # PPI_NOTIFY_TOKENS =3D { - "NOTIFY" : "NOTIFY", - "PPI_NOTIFY" : "NOTIFY", - "UNDEFINED" : "UNDEFINED" - } + "NOTIFY": "NOTIFY", + "PPI_NOTIFY": "NOTIFY", + "UNDEFINED": "UNDEFINED" +} =20 EVENT_TOKENS =3D { - "EVENT_TYPE_PERIODIC_TIMER" : "EVENT_TYPE_PERIODIC_TIMER", - "EVENT_TYPE_RELATIVE_TIMER" : "EVENT_TYPE_RELATIVE_TIMER", - "UNDEFINED" : "UNDEFINED" - } + "EVENT_TYPE_PERIODIC_TIMER": "EVENT_TYPE_PERIODIC_TIMER", + "EVENT_TYPE_RELATIVE_TIMER": "EVENT_TYPE_RELATIVE_TIMER", + "UNDEFINED": "UNDEFINED" +} =20 BOOTMODE_TOKENS =3D { - "FULL" : "FULL", - "MINIMAL" : "MINIMAL", - "NO_CHANGE" : "NO_CHANGE", - "DIAGNOSTICS" : "DIAGNOSTICS", - "DEFAULT" : "DEFAULT", - "S2_RESUME" : "S2_RESUME", - "S3_RESUME" : "S3_RESUME", - "S4_RESUME" : "S4_RESUME", - "S5_RESUME" : "S5_RESUME", - "FLASH_UPDATE" : "FLASH_UPDATE", - "RECOVERY_FULL" : "RECOVERY_FULL", - "RECOVERY_MINIMAL" : "RECOVERY_MINIMAL", - "RECOVERY_NO_CHANGE" : "RECOVERY_NO_CHANGE", - "RECOVERY_DIAGNOSTICS" : "RECOVERY_DIAGNOSTICS", - "RECOVERY_DEFAULT" : "RECOVERY_DEFAULT", - "RECOVERY_S2_RESUME" : "RECOVERY_S2_RESUME", - "RECOVERY_S3_RESUME" : "RECOVERY_S3_RESUME", - "RECOVERY_S4_RESUME" : "RECOVERY_S4_RESUME", - "RECOVERY_S5_RESUME" : "RECOVERY_S5_RESUME", - "RECOVERY_FLASH_UPDATE" : "RECOVERY_FLASH_UPDATE", - "UNDEFINED" : "UNDEFINED" - } + "FULL": "FULL", + "MINIMAL": "MINIMAL", + "NO_CHANGE": "NO_CHANGE", + "DIAGNOSTICS": "DIAGNOSTICS", + "DEFAULT": "DEFAULT", + "S2_RESUME": "S2_RESUME", + "S3_RESUME": "S3_RESUME", + "S4_RESUME": "S4_RESUME", + "S5_RESUME": "S5_RESUME", + "FLASH_UPDATE": "FLASH_UPDATE", + "RECOVERY_FULL": "RECOVERY_FULL", + "RECOVERY_MINIMAL": "RECOVERY_MINIMAL", + "RECOVERY_NO_CHANGE": "RECOVERY_NO_CHANGE", + "RECOVERY_DIAGNOSTICS": "RECOVERY_DIAGNOSTICS", + "RECOVERY_DEFAULT": "RECOVERY_DEFAULT", + "RECOVERY_S2_RESUME": "RECOVERY_S2_RESUME", + "RECOVERY_S3_RESUME": "RECOVERY_S3_RESUME", + "RECOVERY_S4_RESUME": "RECOVERY_S4_RESUME", + "RECOVERY_S5_RESUME": "RECOVERY_S5_RESUME", + "RECOVERY_FLASH_UPDATE": "RECOVERY_FLASH_UPDATE", + "UNDEFINED": "UNDEFINED" +} =20 HOB_TOKENS =3D { - "PHIT" : "PHIT", - "MEMORY_ALLOCATION" : "MEMORY_ALLOCATION", - "LOAD_PEIM" : "LOAD_PEIM", - "RESOURCE_DESCRIPTOR" : "RESOURCE_DESCRIPTOR", - "FIRMWARE_VOLUME" : "FIRMWARE_VOLUME", - "UNDEFINED" : "UNDEFINED" - } + "PHIT": "PHIT", + "MEMORY_ALLOCATION": "MEMORY_ALLOCATION", + "LOAD_PEIM": "LOAD_PEIM", + "RESOURCE_DESCRIPTOR": "RESOURCE_DESCRIPTOR", + "FIRMWARE_VOLUME": "FIRMWARE_VOLUME", + "UNDEFINED": "UNDEFINED" +} =20 ## # Usage List Items for Protocol @@ -260,12 +260,13 @@ GUID_TYPE_LIST =3D ["Event", "File", "FV", "GUID", "H= II", "HOB", # PCD Usage Type List of Package # PCD_USAGE_TYPE_LIST_OF_PACKAGE =3D ["FeatureFlag", "PatchableInModule", - "FixedAtBuild", "Dynamic", "DynamicEx"] + "FixedAtBuild", "Dynamic", "DynamicEx"] =20 ## # PCD Usage Type List of Module # -PCD_USAGE_TYPE_LIST_OF_MODULE =3D ["FEATUREPCD", "PATCHPCD", "FIXEDPCD", "= PCD", "PCDEX"] +PCD_USAGE_TYPE_LIST_OF_MODULE =3D ["FEATUREPCD", + "PATCHPCD", "FIXEDPCD", "PCD", "PCDEX"] ## # PCD Usage Type List of UPT # @@ -282,14 +283,14 @@ BINARY_FILE_TYPE_LIST =3D ["PE32", "PIC", "TE", "DXE_= DEPEX", "VER", "UI", "COMPAT1 "DISPOSABLE" ] BINARY_FILE_TYPE_LIST_IN_UDP =3D \ - ["GUID", "FREEFORM", - "UEFI_IMAGE", "PE32", "PIC", - "PEI_DEPEX", - "DXE_DEPEX", - "SMM_DEPEX", - "FV", "TE", - "BIN", "VER", "UI" - ] + ["GUID", "FREEFORM", + "UEFI_IMAGE", "PE32", "PIC", + "PEI_DEPEX", + "DXE_DEPEX", + "SMM_DEPEX", + "FV", "TE", + "BIN", "VER", "UI" + ] =20 SUBTYPE_GUID_BINARY_FILE_TYPE =3D "FREEFORM" ## @@ -300,28 +301,28 @@ SUBTYPE_GUID_BINARY_FILE_TYPE =3D "FREEFORM" # are required. The COMPONENT_TYPE definition is case sensitive. # COMPONENT_TYPE_LIST =3D [ - "APPLICATION", - "ACPITABLE", - "APRIORI", - "BINARY", - "BS_DRIVER", - "CONFIG", - "FILE", - "FVIMAGEFILE", - "LIBRARY", - "LOGO", - "LEGACY16", - "MICROCODE", - "PE32_PEIM", - "PEI_CORE", - "RAWFILE", - "RT_DRIVER", - "SAL_RT_DRIVER", - "SECURITY_CORE", - "COMBINED_PEIM_DRIVER", - "PIC_PEIM", - "RELOCATABLE_PEIM" - ] + "APPLICATION", + "ACPITABLE", + "APRIORI", + "BINARY", + "BS_DRIVER", + "CONFIG", + "FILE", + "FVIMAGEFILE", + "LIBRARY", + "LOGO", + "LEGACY16", + "MICROCODE", + "PE32_PEIM", + "PEI_CORE", + "RAWFILE", + "RT_DRIVER", + "SAL_RT_DRIVER", + "SECURITY_CORE", + "COMBINED_PEIM_DRIVER", + "PIC_PEIM", + "RELOCATABLE_PEIM" +] =20 ## # Common Definitions @@ -343,7 +344,7 @@ TAB_COLON_SPLIT =3D ':' TAB_SECTION_START =3D '[' TAB_SECTION_END =3D ']' TAB_OPTION_START =3D '<' -TAB_OPTION_END =3D '>' +TAB_OPTION_END =3D '>' TAB_SLASH =3D '\\' TAB_BACK_SLASH =3D '/' TAB_SPECIAL_COMMENT =3D '##' @@ -370,7 +371,7 @@ TAB_ARCH_ARM =3D 'ARM' TAB_ARCH_EBC =3D 'EBC' =20 ARCH_LIST =3D \ -[TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC] + [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC] =20 SUP_MODULE_BASE =3D 'BASE' SUP_MODULE_SEC =3D 'SEC' @@ -387,12 +388,12 @@ SUP_MODULE_USER_DEFINED =3D 'USER_DEFINED' SUP_MODULE_SMM_CORE =3D 'SMM_CORE' =20 SUP_MODULE_LIST =3D \ -[SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, \ -SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, \ - SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVE= R, \ - SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \ - SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, \ - SUP_MODULE_SMM_CORE] + [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, + SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, + SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, + SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, + SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, + SUP_MODULE_SMM_CORE] SUP_MODULE_LIST_STRING =3D TAB_VALUE_SPLIT.join(l for l in SUP_MODULE_LIST) =20 EDK_COMPONENT_TYPE_LIBRARY =3D 'LIBRARY' @@ -405,7 +406,7 @@ EDK_COMPONENT_TYPE_BS_DRIVER =3D 'BS_DRIVER' EDK_COMPONENT_TYPE_RT_DRIVER =3D 'RT_DRIVER' EDK_COMPONENT_TYPE_SAL_RT_DRIVER =3D 'SAL_RT_DRIVER' EDK_COMPONENT_TYPE_APPLICATION =3D 'APPLICATION' -EDK_NAME =3D 'EDK' +EDK_NAME =3D 'EDK' EDKII_NAME =3D 'EDKII' =20 BINARY_FILE_TYPE_FW =3D 'FW' @@ -432,9 +433,9 @@ BINARY_FILE_TYPE_UI_LIST =3D [BINARY_FILE_TYPE_UNI_UI, BINARY_FILE_TYPE_UI ] BINARY_FILE_TYPE_VER_LIST =3D [BINARY_FILE_TYPE_UNI_VER, - BINARY_FILE_TYPE_SEC_VER, - BINARY_FILE_TYPE_VER - ] + BINARY_FILE_TYPE_SEC_VER, + BINARY_FILE_TYPE_VER + ] =20 DEPEX_SECTION_LIST =3D ['', '', @@ -527,117 +528,117 @@ TAB_PCDS_DYNAMIC_HII =3D 'DynamicHii' =20 TAB_PTR_TYPE_PCD =3D 'VOID*' =20 -PCD_DYNAMIC_TYPE_LIST =3D [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, \ +PCD_DYNAMIC_TYPE_LIST =3D [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII] -PCD_DYNAMIC_EX_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEF= AULT, \ +PCD_DYNAMIC_EX_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEF= AULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_H= II] =20 -## Dynamic-ex PCD types +# Dynamic-ex PCD types # -gDYNAMIC_EX_PCD =3D [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, \ - TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] +gDYNAMIC_EX_PCD =3D [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, + TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] =20 TAB_PCDS_FIXED_AT_BUILD_NULL =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD TAB_PCDS_FIXED_AT_BUILD_COMMON =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_COMMON + TAB_SPLIT + TAB_ARCH_COMMON TAB_PCDS_FIXED_AT_BUILD_IA32 =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_IA32 + TAB_SPLIT + TAB_ARCH_IA32 TAB_PCDS_FIXED_AT_BUILD_X64 =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_X64 + TAB_SPLIT + TAB_ARCH_X64 TAB_PCDS_FIXED_AT_BUILD_IPF =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_IPF + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_FIXED_AT_BUILD_ARM =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_ARM + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_FIXED_AT_BUILD_EBC =3D TAB_PCDS + TAB_PCDS_FIXED_AT_BUILD + \ -TAB_SPLIT + TAB_ARCH_EBC + TAB_SPLIT + TAB_ARCH_EBC =20 TAB_PCDS_PATCHABLE_IN_MODULE_NULL =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MOD= ULE TAB_PCDS_PATCHABLE_IN_MODULE_COMMON =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_M= ODULE \ -+ TAB_SPLIT + TAB_ARCH_COMMON + + TAB_SPLIT + TAB_ARCH_COMMON TAB_PCDS_PATCHABLE_IN_MODULE_IA32 =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MOD= ULE + \ -TAB_SPLIT + TAB_ARCH_IA32 + TAB_SPLIT + TAB_ARCH_IA32 TAB_PCDS_PATCHABLE_IN_MODULE_X64 =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + \ -TAB_SPLIT + TAB_ARCH_X64 + TAB_SPLIT + TAB_ARCH_X64 TAB_PCDS_PATCHABLE_IN_MODULE_IPF =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + \ -TAB_SPLIT + TAB_ARCH_IPF + TAB_SPLIT + TAB_ARCH_IPF TAB_PCDS_PATCHABLE_IN_MODULE_ARM =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + \ -TAB_SPLIT + TAB_ARCH_ARM + TAB_SPLIT + TAB_ARCH_ARM TAB_PCDS_PATCHABLE_IN_MODULE_EBC =3D TAB_PCDS + TAB_PCDS_PATCHABLE_IN_MODU= LE + \ -TAB_SPLIT + TAB_ARCH_EBC + TAB_SPLIT + TAB_ARCH_EBC =20 TAB_PCDS_FEATURE_FLAG_NULL =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG TAB_PCDS_FEATURE_FLAG_COMMON =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SP= LIT \ -+ TAB_ARCH_COMMON + + TAB_ARCH_COMMON TAB_PCDS_FEATURE_FLAG_IA32 =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLI= T + \ -TAB_ARCH_IA32 + TAB_ARCH_IA32 TAB_PCDS_FEATURE_FLAG_X64 =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + \ -TAB_ARCH_X64 + TAB_ARCH_X64 TAB_PCDS_FEATURE_FLAG_IPF =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + \ -TAB_ARCH_IPF + TAB_ARCH_IPF TAB_PCDS_FEATURE_FLAG_ARM =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + \ -TAB_ARCH_ARM + TAB_ARCH_ARM TAB_PCDS_FEATURE_FLAG_EBC =3D TAB_PCDS + TAB_PCDS_FEATURE_FLAG + TAB_SPLIT= + \ -TAB_ARCH_EBC + TAB_ARCH_EBC =20 TAB_PCDS_DYNAMIC_EX_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_DEFAULT TAB_PCDS_DYNAMIC_EX_HII_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_HII TAB_PCDS_DYNAMIC_EX_VPD_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX_VPD TAB_PCDS_DYNAMIC_EX_COMMON =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT = + \ -TAB_ARCH_COMMON + TAB_ARCH_COMMON TAB_PCDS_DYNAMIC_EX_IA32 =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ -TAB_ARCH_IA32 + TAB_ARCH_IA32 TAB_PCDS_DYNAMIC_EX_X64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ -TAB_ARCH_X64 + TAB_ARCH_X64 TAB_PCDS_DYNAMIC_EX_IPF =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ -TAB_ARCH_IPF + TAB_ARCH_IPF TAB_PCDS_DYNAMIC_EX_ARM =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ -TAB_ARCH_ARM + TAB_ARCH_ARM TAB_PCDS_DYNAMIC_EX_EBC =3D TAB_PCDS + TAB_PCDS_DYNAMIC_EX + TAB_SPLIT + \ -TAB_ARCH_EBC + TAB_ARCH_EBC =20 TAB_PCDS_DYNAMIC_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC TAB_PCDS_DYNAMIC_DEFAULT_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_DEFAULT TAB_PCDS_DYNAMIC_HII_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_HII TAB_PCDS_DYNAMIC_VPD_NULL =3D TAB_PCDS + TAB_PCDS_DYNAMIC_VPD TAB_PCDS_DYNAMIC_COMMON =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + \ -TAB_ARCH_COMMON + TAB_ARCH_COMMON TAB_PCDS_DYNAMIC_IA32 =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_AR= CH_IA32 TAB_PCDS_DYNAMIC_X64 =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_X64 TAB_PCDS_DYNAMIC_IPF =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_IPF TAB_PCDS_DYNAMIC_ARM =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_ARM TAB_PCDS_DYNAMIC_EBC =3D TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARC= H_EBC =20 -TAB_PCD_DYNAMIC_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_DEFAULT_NULL, \ - TAB_PCDS_DYNAMIC_VPD_NULL, \ +TAB_PCD_DYNAMIC_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_DEFAULT_NULL, + TAB_PCDS_DYNAMIC_VPD_NULL, TAB_PCDS_DYNAMIC_HII_NULL] -TAB_PCD_DYNAMIC_EX_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, \ - TAB_PCDS_DYNAMIC_EX_VPD_NULL, \ +TAB_PCD_DYNAMIC_EX_TYPE_LIST =3D [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, + TAB_PCDS_DYNAMIC_EX_VPD_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL] =20 TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE =3D \ -'PcdLoadFixAddressPeiCodePageNumber' + 'PcdLoadFixAddressPeiCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE =3D 'UINT32' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE =3D \ -'PcdLoadFixAddressBootTimeCodePageNumber' + 'PcdLoadFixAddressBootTimeCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE =3D 'UINT32' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE =3D \ -'PcdLoadFixAddressRuntimeCodePageNumber' + 'PcdLoadFixAddressRuntimeCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE =3D 'UINT3= 2' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE =3D \ -'PcdLoadFixAddressSmmCodePageNumber' + 'PcdLoadFixAddressSmmCodePageNumber' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE =3D 'UINT32' TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST =3D \ -[TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, \ -TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE, \ -TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE, \ -TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE] -PCD_SECTION_LIST =3D [TAB_PCDS_FIXED_AT_BUILD_NULL.upper(), \ - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(), \ - TAB_PCDS_FEATURE_FLAG_NULL.upper(), \ - TAB_PCDS_DYNAMIC_EX_NULL.upper(), \ + [TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE, + TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE] +PCD_SECTION_LIST =3D [TAB_PCDS_FIXED_AT_BUILD_NULL.upper(), + TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(), + TAB_PCDS_FEATURE_FLAG_NULL.upper(), + TAB_PCDS_DYNAMIC_EX_NULL.upper(), TAB_PCDS_DYNAMIC_NULL.upper()] -INF_PCD_SECTION_LIST =3D ["FixedPcd".upper(), "FeaturePcd".upper(), \ +INF_PCD_SECTION_LIST =3D ["FixedPcd".upper(), "FeaturePcd".upper(), "PatchPcd".upper(), "Pcd".upper(), "PcdEx".upper()] =20 TAB_DEPEX =3D 'Depex' @@ -692,7 +693,7 @@ TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION =3D 'EFI_SPEC= IFICATION_VERSION' TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION =3D 'UEFI_SPECIFICATION_VERSION' TAB_INF_DEFINES_PI_SPECIFICATION_VERSION =3D 'PI_SPECIFICATION_VERSION' TAB_INF_DEFINES_EDK_RELEASE_VERSION =3D 'EDK_RELEASE_VERSION' -TAB_INF_DEFINES_MODULE_UNI_FILE =3D 'MODULE_UNI_FILE' +TAB_INF_DEFINES_MODULE_UNI_FILE =3D 'MODULE_UNI_FILE' TAB_INF_DEFINES_BINARY_MODULE =3D 'BINARY_MODULE' TAB_INF_DEFINES_LIBRARY_CLASS =3D 'LIBRARY_CLASS' TAB_INF_DEFINES_COMPONENT_TYPE =3D 'COMPONENT_TYPE' @@ -702,7 +703,7 @@ TAB_INF_DEFINES_BUILD_TYPE =3D 'BUILD_TYPE' TAB_INF_DEFINES_FFS_EXT =3D 'FFS_EXT' TAB_INF_DEFINES_FV_EXT =3D 'FV_EXT' TAB_INF_DEFINES_SOURCE_FV =3D 'SOURCE_FV' -TAB_INF_DEFINES_PACKAGE =3D 'PACKAGE' +TAB_INF_DEFINES_PACKAGE =3D 'PACKAGE' TAB_INF_DEFINES_VERSION_NUMBER =3D 'VERSION_NUMBER' TAB_INF_DEFINES_VERSION =3D 'VERSION' TAB_INF_DEFINES_VERSION_STRING =3D 'VERSION_STRING' @@ -712,11 +713,11 @@ TAB_INF_DEFINES_ENTRY_POINT =3D 'ENTRY_POINT' TAB_INF_DEFINES_UNLOAD_IMAGE =3D 'UNLOAD_IMAGE' TAB_INF_DEFINES_CONSTRUCTOR =3D 'CONSTRUCTOR' TAB_INF_DEFINES_DESTRUCTOR =3D 'DESTRUCTOR' -TAB_INF_DEFINES_PCI_VENDOR_ID =3D 'PCI_VENDOR_ID' -TAB_INF_DEFINES_PCI_DEVICE_ID =3D 'PCI_DEVICE_ID' +TAB_INF_DEFINES_PCI_VENDOR_ID =3D 'PCI_VENDOR_ID' +TAB_INF_DEFINES_PCI_DEVICE_ID =3D 'PCI_DEVICE_ID' TAB_INF_DEFINES_PCI_CLASS_CODE =3D 'PCI_CLASS_CODE' -TAB_INF_DEFINES_PCI_REVISION =3D 'PCI_REVISION' -TAB_INF_DEFINES_PCI_COMPRESS =3D 'PCI_COMPRESS' +TAB_INF_DEFINES_PCI_REVISION =3D 'PCI_REVISION' +TAB_INF_DEFINES_PCI_COMPRESS =3D 'PCI_COMPRESS' TAB_INF_DEFINES_DEFINE =3D 'DEFINE' TAB_INF_DEFINES_SPEC =3D 'SPEC' TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION =3D 'UEFI_HII_RESOURCE_SECTION' @@ -744,7 +745,7 @@ TAB_DEC_DEFINES_DEC_SPECIFICATION =3D 'DEC_SPECIFICATIO= N' TAB_DEC_DEFINES_PACKAGE_NAME =3D 'PACKAGE_NAME' TAB_DEC_DEFINES_PACKAGE_GUID =3D 'PACKAGE_GUID' TAB_DEC_DEFINES_PACKAGE_VERSION =3D 'PACKAGE_VERSION' -TAB_DEC_DEFINES_PKG_UNI_FILE =3D 'PACKAGE_UNI_FILE' +TAB_DEC_DEFINES_PKG_UNI_FILE =3D 'PACKAGE_UNI_FILE' TAB_DEC_PACKAGE_ABSTRACT =3D 'STR_PACKAGE_ABSTRACT' TAB_DEC_PACKAGE_DESCRIPTION =3D 'STR_PACKAGE_DESCRIPTION' TAB_DEC_PACKAGE_LICENSE =3D 'STR_PACKAGE_LICENSE' @@ -829,12 +830,12 @@ DATABASE_PATH =3D ":memory:" # # used by ECC # -MODIFIER_LIST =3D ['IN', 'OUT', 'OPTIONAL', 'UNALIGNED', 'EFI_RUNTIMESERVI= CE', \ +MODIFIER_LIST =3D ['IN', 'OUT', 'OPTIONAL', 'UNALIGNED', 'EFI_RUNTIMESERVI= CE', 'EFI_BOOTSERVICE', 'EFIAPI'] # # Dependency Expression # -DEPEX_SUPPORTED_OPCODE =3D ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT",= \ +DEPEX_SUPPORTED_OPCODE =3D ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "END", "SOR", "TRUE", "FALSE", '(', ')'] =20 TAB_STATIC_LIBRARY =3D "STATIC-LIBRARY-FILE" @@ -851,13 +852,13 @@ TAB_DEFAULT_BINARY_FILE =3D "_BINARY_FILE_" # inf files # HEADER_COMMENT_NOT_STARTED =3D -1 -HEADER_COMMENT_STARTED =3D 0 -HEADER_COMMENT_FILE =3D 1 -HEADER_COMMENT_ABSTRACT =3D 2 +HEADER_COMMENT_STARTED =3D 0 +HEADER_COMMENT_FILE =3D 1 +HEADER_COMMENT_ABSTRACT =3D 2 HEADER_COMMENT_DESCRIPTION =3D 3 -HEADER_COMMENT_COPYRIGHT =3D 4 -HEADER_COMMENT_LICENSE =3D 5 -HEADER_COMMENT_END =3D 6 +HEADER_COMMENT_COPYRIGHT =3D 4 +HEADER_COMMENT_LICENSE =3D 5 +HEADER_COMMENT_END =3D 6 =20 # # Static values for data models diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py b/Ba= seTools/Source/Python/UPT/Library/ExpressionValidate.py index 7718ca12e5cf..da2d2da73d73 100644 --- a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py +++ b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to check PCD logical expression # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -16,13 +16,15 @@ from __future__ import print_function import re from Logger import StringTable as ST =20 -## IsValidBareCString +# IsValidBareCString # # Check if String is comprised by whitespace(0x20), !(0x21), 0x23 - 0x7E # or '\n', '\t', '\f', '\r', '\b', '\0', '\\' # # @param String: string to be checked # + + def IsValidBareCString(String): EscapeList =3D ['n', 't', 'f', 'r', 'b', '0', '\\', '"'] PreChar =3D '' @@ -38,7 +40,7 @@ def IsValidBareCString(String): else: IntChar =3D ord(Char) if IntChar !=3D 0x20 and IntChar !=3D 0x09 and IntChar !=3D 0x= 21 \ - and (IntChar < 0x23 or IntChar > 0x7e): + and (IntChar < 0x23 or IntChar > 0x7e): return False PreChar =3D Char =20 @@ -47,6 +49,7 @@ def IsValidBareCString(String): return False return True =20 + def _ValidateToken(Token): Token =3D Token.strip() Index =3D Token.find("\"") @@ -54,31 +57,36 @@ def _ValidateToken(Token): return IsValidBareCString(Token[Index+1:-1]) return True =20 -## _ExprError +# _ExprError # # @param Exception: Exception # + + class _ExprError(Exception): - def __init__(self, Error =3D ''): + def __init__(self, Error=3D''): Exception.__init__(self) self.Error =3D Error =20 -## _ExprBase +# _ExprBase # + + class _ExprBase: HEX_PATTERN =3D '[\t\s]*0[xX][a-fA-F0-9]+' INT_PATTERN =3D '[\t\s]*[0-9]+' MACRO_PATTERN =3D '[\t\s]*\$\(([A-Z][_A-Z0-9]*)\)' PCD_PATTERN =3D \ - '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*' + '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_= ]*' QUOTED_PATTERN =3D '[\t\s]*L?"[^"]*"' BOOL_PATTERN =3D '[\t\s]*(true|True|TRUE|false|False|FALSE)' + def __init__(self, Token): self.Token =3D Token self.Index =3D 0 self.Len =3D len(Token) =20 - ## SkipWhitespace + # SkipWhitespace # def SkipWhitespace(self): for Char in self.Token[self.Index:]: @@ -86,7 +94,7 @@ class _ExprBase: break self.Index +=3D 1 =20 - ## IsCurrentOp + # IsCurrentOp # # @param OpList: option list # @@ -95,11 +103,11 @@ class _ExprBase: LetterOp =3D ["EQ", "NE", "GE", "LE", "GT", "LT", "NOT", "and", "A= ND", "or", "OR", "XOR"] OpMap =3D { - '|' : '|', - '&' : '&', - '!' : '=3D', - '>' : '=3D', - '<' : '=3D' + '|': '|', + '&': '&', + '!': '=3D', + '>': '=3D', + '<': '=3D' } =20 for Operator in OpList: @@ -107,10 +115,10 @@ class _ExprBase: continue =20 self.Index +=3D len(Operator) - Char =3D self.Token[self.Index : self.Index + 1] + Char =3D self.Token[self.Index: self.Index + 1] =20 if (Operator in LetterOp and (Char =3D=3D '_' or Char.isalnum(= ))) \ - or (Operator in OpMap and OpMap[Operator] =3D=3D Char): + or (Operator in OpMap and OpMap[Operator] =3D=3D Char): self.Index -=3D len(Operator) break =20 @@ -118,10 +126,12 @@ class _ExprBase: =20 return False =20 -## _LogicalExpressionParser +# _LogicalExpressionParser # # @param _ExprBase: _ExprBase object # + + class _LogicalExpressionParser(_ExprBase): # # STRINGITEM can only be logical field according to spec @@ -147,21 +157,21 @@ class _LogicalExpressionParser(_ExprBase): for Match in MatchList: if Match and Match.start() =3D=3D 0: if not _ValidateToken( - self.Token[self.Index:self.Index+Match.end()] - ): + self.Token[self.Index:self.Index+Match.end()] + ): return False =20 self.Index +=3D Match.end() if self.Token[self.Index - 1] =3D=3D '"': return True if self.Token[self.Index:self.Index+1] =3D=3D '_' or \ - self.Token[self.Index:self.Index+1].isalnum(): + self.Token[self.Index:self.Index+1].isalnum(): self.Index -=3D Match.end() return False =20 Token =3D self.Token[self.Index - Match.end():self.Index] if Token.strip() in ["EQ", "NE", "GE", "LE", "GT", "LT", - "NOT", "and", "AND", "or", "OR", "XOR"]: + "NOT", "and", "AND", "or", "OR", "XOR= "]: self.Index -=3D Match.end() return False =20 @@ -192,7 +202,6 @@ class _LogicalExpressionParser(_ExprBase): =20 return self._CheckToken([Match1, Match2, Match3, Match4]) =20 - def IsAtomicItem(self): # # Macro @@ -208,18 +217,18 @@ class _LogicalExpressionParser(_ExprBase): # Quoted string # Match3 =3D re.compile(self.QUOTED_PATTERN).\ - match(self.Token[self.Index:].replace('\\\\', '//').\ + match(self.Token[self.Index:].replace('\\\\', '//'). replace('\\\"', '\\\'')) =20 return self._CheckToken([Match1, Match2, Match3]) =20 - ## A || B + # A || B # def LogicalExpression(self): Ret =3D self.SpecNot() while self.IsCurrentOp(['||', 'OR', 'or', '&&', 'AND', 'and', 'XOR= ', 'xor', '^']): if self.Token[self.Index-1] =3D=3D '|' and self.Parens <=3D 0: - raise _ExprError(ST.ERR_EXPR_OR % self.Token) + raise _ExprError(ST.ERR_EXPR_OR % self.Token) if Ret not in [self.ARITH, self.LOGICAL, self.REALLOGICAL, sel= f.STRINGITEM]: raise _ExprError(ST.ERR_EXPR_LOGICAL % self.Token) Ret =3D self.SpecNot() @@ -253,7 +262,7 @@ class _LogicalExpressionParser(_ExprBase): Ret =3D self.Factor() while self.IsCurrentOp(["+", "-", "&", "|", "^", "XOR", "xor"]): if self.Token[self.Index-1] =3D=3D '|' and self.Parens <=3D 0: - raise _ExprError(ST.ERR_EXPR_OR) + raise _ExprError(ST.ERR_EXPR_OR) if Ret =3D=3D self.STRINGITEM or Ret =3D=3D self.REALLOGICAL: raise _ExprError(ST.ERR_EXPR_LOGICAL % self.Token) Ret =3D self.Factor() @@ -262,14 +271,14 @@ class _LogicalExpressionParser(_ExprBase): Ret =3D self.ARITH return Ret =20 - ## Factor + # Factor # def Factor(self): if self.IsCurrentOp(["("]): self.Parens +=3D 1 Ret =3D self.LogicalExpression() if not self.IsCurrentOp([")"]): - raise _ExprError(ST.ERR_EXPR_RIGHT_PAREN % \ + raise _ExprError(ST.ERR_EXPR_RIGHT_PAREN % (self.Token, self.Token[self.Index:])) self.Parens -=3D 1 return Ret @@ -281,10 +290,10 @@ class _LogicalExpressionParser(_ExprBase): elif self.IsAtomicNumVal(): return self.ARITH else: - raise _ExprError(ST.ERR_EXPR_FACTOR % \ + raise _ExprError(ST.ERR_EXPR_FACTOR % (self.Token[self.Index:], self.Token)) =20 - ## IsValidLogicalExpression + # IsValidLogicalExpression # def IsValidLogicalExpression(self): if self.Len =3D=3D 0: @@ -296,16 +305,19 @@ class _LogicalExpressionParser(_ExprBase): return False, XExcept.Error self.SkipWhitespace() if self.Index !=3D self.Len: - return False, (ST.ERR_EXPR_BOOLEAN % \ + return False, (ST.ERR_EXPR_BOOLEAN % (self.Token[self.Index:], self.Token)) return True, '' =20 -## _ValidRangeExpressionParser +# _ValidRangeExpressionParser # + + class _ValidRangeExpressionParser(_ExprBase): INT_RANGE_PATTERN =3D '[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+' HEX_RANGE_PATTERN =3D \ '[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+' + def __init__(self, Token): _ExprBase.__init__(self, Token) self.Parens =3D 0 @@ -314,7 +326,7 @@ class _ValidRangeExpressionParser(_ExprBase): self.IsParenHappen =3D False self.IsLogicalOpHappen =3D False =20 - ## IsValidRangeExpression + # IsValidRangeExpression # def IsValidRangeExpression(self): if self.Len =3D=3D 0: @@ -330,7 +342,7 @@ class _ValidRangeExpressionParser(_ExprBase): return False, (ST.ERR_EXPR_RANGE % self.Token) return True, '' =20 - ## RangeExpression + # RangeExpression # def RangeExpression(self): Ret =3D self.Unary() @@ -346,7 +358,7 @@ class _ValidRangeExpressionParser(_ExprBase): =20 return Ret =20 - ## Unary + # Unary # def Unary(self): if self.IsCurrentOp(["NOT"]): @@ -354,7 +366,7 @@ class _ValidRangeExpressionParser(_ExprBase): =20 return self.ValidRange() =20 - ## ValidRange + # ValidRange # def ValidRange(self): Ret =3D -1 @@ -363,7 +375,8 @@ class _ValidRangeExpressionParser(_ExprBase): self.IsParenHappen =3D True self.Parens +=3D 1 if self.Parens > 1: - raise _ExprError(ST.ERR_EXPR_RANGE_DOUBLE_PAREN_NESTED % s= elf.Token) + raise _ExprError( + ST.ERR_EXPR_RANGE_DOUBLE_PAREN_NESTED % self.Token) Ret =3D self.RangeExpression() if not self.IsCurrentOp([")"]): raise _ExprError(ST.ERR_EXPR_RIGHT_PAREN % self.Token) @@ -385,14 +398,15 @@ class _ValidRangeExpressionParser(_ExprBase): self.Index +=3D IntMatch.end() Ret =3D self.INT else: - raise _ExprError(ST.ERR_EXPR_RANGE_FACTOR % (self.Token[se= lf.Index:], self.Token)) + raise _ExprError(ST.ERR_EXPR_RANGE_FACTOR % + (self.Token[self.Index:], self.Token)) else: IntRangeMatch =3D re.compile( self.INT_RANGE_PATTERN).match(self.Token[self.Index:] - ) + ) HexRangeMatch =3D re.compile( self.HEX_RANGE_PATTERN).match(self.Token[self.Index:] - ) + ) if HexRangeMatch and HexRangeMatch.start() =3D=3D 0: self.Index +=3D HexRangeMatch.end() Ret =3D self.HEX @@ -404,10 +418,13 @@ class _ValidRangeExpressionParser(_ExprBase): =20 return Ret =20 -## _ValidListExpressionParser +# _ValidListExpressionParser # + + class _ValidListExpressionParser(_ExprBase): VALID_LIST_PATTERN =3D '(0[xX][0-9a-fA-F]+|[0-9]+)([\t\s]*,[\t\s]*(0[x= X][0-9a-fA-F]+|[0-9]+))*' + def __init__(self, Token): _ExprBase.__init__(self, Token) self.NUM =3D 1 @@ -430,7 +447,8 @@ class _ValidListExpressionParser(_ExprBase): def ListExpression(self): Ret =3D -1 self.SkipWhitespace() - ListMatch =3D re.compile(self.VALID_LIST_PATTERN).match(self.Token= [self.Index:]) + ListMatch =3D re.compile(self.VALID_LIST_PATTERN).match( + self.Token[self.Index:]) if ListMatch and ListMatch.start() =3D=3D 0: self.Index +=3D ListMatch.end() Ret =3D self.NUM @@ -439,13 +457,15 @@ class _ValidListExpressionParser(_ExprBase): =20 return Ret =20 -## _StringTestParser +# _StringTestParser # + + class _StringTestParser(_ExprBase): def __init__(self, Token): _ExprBase.__init__(self, Token) =20 - ## IsValidStringTest + # IsValidStringTest # def IsValidStringTest(self): if self.Len =3D=3D 0: @@ -456,11 +476,11 @@ class _StringTestParser(_ExprBase): return False, XExcept.Error return True, '' =20 - ## StringItem + # StringItem # def StringItem(self): Match1 =3D re.compile(self.QUOTED_PATTERN)\ - .match(self.Token[self.Index:].replace('\\\\', '//')\ + .match(self.Token[self.Index:].replace('\\\\', '//') .replace('\\\"', '\\\'')) Match2 =3D re.compile(self.MACRO_PATTERN).match(self.Token[self.In= dex:]) Match3 =3D re.compile(self.PCD_PATTERN).match(self.Token[self.Inde= x:]) @@ -468,30 +488,30 @@ class _StringTestParser(_ExprBase): for Match in MatchList: if Match and Match.start() =3D=3D 0: if not _ValidateToken( - self.Token[self.Index:self.Index+Match.end()] - ): - raise _ExprError(ST.ERR_EXPR_STRING_ITEM % \ + self.Token[self.Index:self.Index+Match.end()] + ): + raise _ExprError(ST.ERR_EXPR_STRING_ITEM % (self.Token, self.Token[self.Index:])) self.Index +=3D Match.end() Token =3D self.Token[self.Index - Match.end():self.Index] if Token.strip() in ["EQ", "NE"]: - raise _ExprError(ST.ERR_EXPR_STRING_ITEM % \ - (self.Token, self.Token[self.Index:])) + raise _ExprError(ST.ERR_EXPR_STRING_ITEM % + (self.Token, self.Token[self.Index:])) return else: - raise _ExprError(ST.ERR_EXPR_STRING_ITEM % \ + raise _ExprError(ST.ERR_EXPR_STRING_ITEM % (self.Token, self.Token[self.Index:])) =20 - ## StringTest + # StringTest # def StringTest(self): self.StringItem() if not self.IsCurrentOp(["=3D=3D", "EQ", "!=3D", "NE"]): - raise _ExprError(ST.ERR_EXPR_EQUALITY % \ + raise _ExprError(ST.ERR_EXPR_EQUALITY % (self.Token[self.Index:], self.Token)) self.StringItem() if self.Index !=3D self.Len: - raise _ExprError(ST.ERR_EXPR_BOOLEAN % \ + raise _ExprError(ST.ERR_EXPR_BOOLEAN % (self.Token[self.Index:], self.Token)) =20 ## @@ -499,6 +519,8 @@ class _StringTestParser(_ExprBase): # # @param Token: string test token # + + def IsValidStringTest(Token, Flag=3DFalse): # # Not do the check right now, keep the implementation for future enhan= cement. @@ -526,6 +548,8 @@ def IsValidLogicalExpr(Token, Flag=3DFalse): # # @param Token: range expression token # + + def IsValidRangeExpr(Token): return _ValidRangeExpressionParser(Token).IsValidRangeExpression() =20 @@ -534,6 +558,8 @@ def IsValidRangeExpr(Token): # # @param Token: value list expression token # + + def IsValidListExpr(Token): return _ValidListExpressionParser(Token).IsValidListExpression() =20 @@ -542,6 +568,8 @@ def IsValidListExpr(Token): # # @param Token: feature flag expression # + + def IsValidFeatureFlagExp(Token, Flag=3DFalse): # # Not do the check right now, keep the implementation for future enhan= cement. @@ -559,9 +587,8 @@ def IsValidFeatureFlagExp(Token, Flag=3DFalse): return False, Cause return True, "" =20 + if __name__ =3D=3D '__main__': -# print IsValidRangeExpr('LT 9') - print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1B= ridgeAddressLE0').IsValidLogicalExpression()) - - - + # print IsValidRangeExpr('LT 9') + print(_LogicalExpressionParser( + 'gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLo= gicalExpression()) diff --git a/BaseTools/Source/Python/UPT/Library/GlobalData.py b/BaseTools/= Source/Python/UPT/Library/GlobalData.py index 8e88fb1e3fde..ae76425f20d9 100644 --- a/BaseTools/Source/Python/UPT/Library/GlobalData.py +++ b/BaseTools/Source/Python/UPT/Library/GlobalData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common static strings and global data used b= y UPT # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source= /Python/UPT/Library/Misc.py index 77ba3584e000..f6880e02b450 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -1,4 +1,4 @@ -## @file +# @file # Common routines used by all tools # # Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
        @@ -46,11 +46,13 @@ from Object.POM.CommonObject import TextObject from Core.FileHook import __FileHookOpen__ from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C +# Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C # structure style # # @param Guid: The GUID string # + + def GuidStringToGuidStructureString(Guid): GuidList =3D Guid.split('-') Result =3D '{' @@ -62,18 +64,20 @@ def GuidStringToGuidStructureString(Guid): Result +=3D '}}' return Result =20 -## Check whether GUID string is of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx= xxxx +# Check whether GUID string is of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx= xxx # # @param GuidValue: The GUID value # + + def CheckGuidRegFormat(GuidValue): - ## Regular expression used to find out register format of GUID + # Regular expression used to find out register format of GUID # RegFormatGuidPattern =3D re.compile("^\s*([0-9a-fA-F]){8}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){12}\s*$") + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){12}\s*$") =20 if RegFormatGuidPattern.match(GuidValue): return True @@ -81,38 +85,40 @@ def CheckGuidRegFormat(GuidValue): return False =20 =20 -## Convert GUID string in C structure style to +# Convert GUID string in C structure style to # xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # # @param GuidValue: The GUID value in C structure format # def GuidStructureStringToGuidString(GuidValue): GuidValueString =3D GuidValue.lower().replace("{", "").replace("}", ""= ).\ - replace(" ", "").replace(";", "") + replace(" ", "").replace(";", "") GuidValueList =3D GuidValueString.split(",") if len(GuidValueList) !=3D 11: return '' try: return "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % ( - int(GuidValueList[0], 16), - int(GuidValueList[1], 16), - int(GuidValueList[2], 16), - int(GuidValueList[3], 16), - int(GuidValueList[4], 16), - int(GuidValueList[5], 16), - int(GuidValueList[6], 16), - int(GuidValueList[7], 16), - int(GuidValueList[8], 16), - int(GuidValueList[9], 16), - int(GuidValueList[10], 16) - ) + int(GuidValueList[0], 16), + int(GuidValueList[1], 16), + int(GuidValueList[2], 16), + int(GuidValueList[3], 16), + int(GuidValueList[4], 16), + int(GuidValueList[5], 16), + int(GuidValueList[6], 16), + int(GuidValueList[7], 16), + int(GuidValueList[8], 16), + int(GuidValueList[9], 16), + int(GuidValueList[10], 16) + ) except BaseException: return '' =20 -## Create directories +# Create directories # # @param Directory: The directory name # + + def CreateDirectory(Directory): if Directory is None or Directory.strip() =3D=3D "": return True @@ -123,13 +129,15 @@ def CreateDirectory(Directory): return False return True =20 -## Remove directories, including files and sub-directories in it +# Remove directories, including files and sub-directories in it # # @param Directory: The directory name # + + def RemoveDirectory(Directory, Recursively=3DFalse): if Directory is None or Directory.strip() =3D=3D "" or not \ - os.path.exists(Directory): + os.path.exists(Directory): return if Recursively: CurrentDirectory =3D getcwd() @@ -142,7 +150,7 @@ def RemoveDirectory(Directory, Recursively=3DFalse): chdir(CurrentDirectory) rmdir(Directory) =20 -## Store content in file +# Store content in file # # This method is used to save file only when its content is changed. This = is # quite useful for "make" system to decide what will be re-built and what @@ -153,6 +161,8 @@ def RemoveDirectory(Directory, Recursively=3DFalse): # @param IsBinaryFile: The flag indicating if the file is binary f= ile # or not # + + def SaveFileOnChange(File, Content, IsBinaryFile=3DTrue): if os.path.exists(File): if IsBinaryFile: @@ -186,11 +196,13 @@ def SaveFileOnChange(File, Content, IsBinaryFile=3DTr= ue): =20 return True =20 -## Get all files of a directory +# Get all files of a directory # # @param Root: Root dir # @param SkipList : The files need be skipped # + + def GetFiles(Root, SkipList=3DNone, FullPath=3DTrue): OriPath =3D os.path.normpath(Root) FileList =3D [] @@ -215,7 +227,7 @@ def GetFiles(Root, SkipList=3DNone, FullPath=3DTrue): =20 return FileList =20 -## Get all non-metadata files of a directory +# Get all non-metadata files of a directory # # @param Root: Root Dir # @param SkipList : List of path need be skipped @@ -223,6 +235,8 @@ def GetFiles(Root, SkipList=3DNone, FullPath=3DTrue): # @param PrefixPath: the path that need to be added to the files found # @return: the list of files found # + + def GetNonMetaDataFiles(Root, SkipList, FullPath, PrefixPath): FileList =3D GetFiles(Root, SkipList, FullPath) NewFileList =3D [] @@ -232,15 +246,18 @@ def GetNonMetaDataFiles(Root, SkipList, FullPath, Pre= fixPath): # skip '.dec', '.inf', '.dsc', '.fdf' files # if ExtName.lower() not in ['.dec', '.inf', '.dsc', '.fdf']: - NewFileList.append(os.path.normpath(os.path.join(PrefixPath, F= ile))) + NewFileList.append(os.path.normpath( + os.path.join(PrefixPath, File))) =20 return NewFileList =20 -## Check if given file exists or not +# Check if given file exists or not # # @param File: File name or path to be checked # @param Dir: The directory the file is relative to # + + def ValidFile(File, Ext=3DNone): File =3D File.replace('\\', '/') if Ext is not None: @@ -251,12 +268,14 @@ def ValidFile(File, Ext=3DNone): return False return True =20 -## RealPath +# RealPath # # @param File: File name or path to be checked # @param Dir: The directory the file is relative to # @param OverrideDir: The override directory # + + def RealPath(File, Dir=3D'', OverrideDir=3D''): NewFile =3D os.path.normpath(os.path.join(Dir, File)) NewFile =3D GlobalData.gALL_FILES[NewFile] @@ -265,22 +284,24 @@ def RealPath(File, Dir=3D'', OverrideDir=3D''): NewFile =3D GlobalData.gALL_FILES[NewFile] return NewFile =20 -## RealPath2 +# RealPath2 # # @param File: File name or path to be checked # @param Dir: The directory the file is relative to # @param OverrideDir: The override directory # + + def RealPath2(File, Dir=3D'', OverrideDir=3D''): if OverrideDir: - NewFile =3D GlobalData.gALL_FILES[os.path.normpath(os.path.join\ - (OverrideDir, File= ))] + NewFile =3D GlobalData.gALL_FILES[os.path.normpath(os.path.join + (OverrideDir, Fil= e))] if NewFile: if OverrideDir[-1] =3D=3D os.path.sep: return NewFile[len(OverrideDir):], NewFile[0:len(OverrideD= ir)] else: return NewFile[len(OverrideDir) + 1:], \ - NewFile[0:len(OverrideDir)] + NewFile[0:len(OverrideDir)] =20 NewFile =3D GlobalData.gALL_FILES[os.path.normpath(os.path.join(Dir, F= ile))] if NewFile: @@ -294,10 +315,12 @@ def RealPath2(File, Dir=3D'', OverrideDir=3D''): =20 return None, None =20 -## CommonPath +# CommonPath # # @param PathList: PathList # + + def CommonPath(PathList): Path1 =3D min(PathList).split(os.path.sep) Path2 =3D max(PathList).split(os.path.sep) @@ -306,11 +329,13 @@ def CommonPath(PathList): return os.path.sep.join(Path1[:Index]) return os.path.sep.join(Path1) =20 -## PathClass +# PathClass # + + class PathClass(object): def __init__(self, File=3D'', Root=3D'', AlterRoot=3D'', Type=3D'', Is= Binary=3DFalse, - Arch=3D'COMMON', ToolChainFamily=3D'', Target=3D'', TagNa= me=3D'', \ + Arch=3D'COMMON', ToolChainFamily=3D'', Target=3D'', TagNa= me=3D'', ToolCode=3D''): self.Arch =3D Arch self.File =3D str(File) @@ -366,14 +391,14 @@ class PathClass(object): =20 self._Key =3D None =20 - ## Convert the object of this class to a string + # Convert the object of this class to a string # # Convert member Path of the class to a string # def __str__(self): return self.Path =20 - ## Override __eq__ function + # Override __eq__ function # # Check whether PathClass are the same # @@ -383,27 +408,28 @@ class PathClass(object): else: return self.Path =3D=3D str(Other) =20 - ## Override __hash__ function + # Override __hash__ function # # Use Path as key in hash table # def __hash__(self): return hash(self.Path) =20 - ## _GetFileKey + # _GetFileKey # def _GetFileKey(self): if self._Key is None: self._Key =3D self.Path.upper() return self._Key - ## Validate + # Validate # + def Validate(self, Type=3D'', CaseSensitive=3DTrue): if GlobalData.gCASE_INSENSITIVE: CaseSensitive =3D False if Type and Type.lower() !=3D self.Type: return ToolError.FILE_TYPE_MISMATCH, '%s (expect %s but got %s= )' % \ - (self.File, Type, self.Type) + (self.File, Type, self.Type) =20 RealFile, RealRoot =3D RealPath2(self.File, self.Root, self.AlterR= oot) if not RealRoot and not RealFile: @@ -417,12 +443,12 @@ class PathClass(object): ErrorCode =3D 0 ErrorInfo =3D '' if RealRoot !=3D self.Root or RealFile !=3D self.File: - if CaseSensitive and (RealFile !=3D self.File or \ - (RealRoot !=3D self.Root and RealRoot != =3D \ + if CaseSensitive and (RealFile !=3D self.File or + (RealRoot !=3D self.Root and RealRoot != =3D self.AlterRoot)): ErrorCode =3D ToolError.FILE_CASE_MISMATCH ErrorInfo =3D self.File + '\n\t' + RealFile + \ - " [in file system]" + " [in file system]" =20 self.SubDir, self.Name =3D os.path.split(RealFile) self.BaseName, self.Ext =3D os.path.splitext(self.Name) @@ -437,10 +463,12 @@ class PathClass(object): =20 Key =3D property(_GetFileKey) =20 -## Get current workspace +# Get current workspace # # get WORKSPACE from environment variable if present,if not use current w= orking directory as WORKSPACE # + + def GetWorkspace(): # # check WORKSPACE @@ -463,7 +491,7 @@ def GetWorkspace(): =20 return WorkspaceDir, mws.PACKAGES_PATH =20 -## Get relative path +# Get relative path # # use full path and workspace to get relative path # the destination of this function is mainly to resolve the root path iss= ue(like c: or c:\) @@ -471,22 +499,28 @@ def GetWorkspace(): # @param Fullpath: a string of fullpath # @param Workspace: a string of workspace # + + def GetRelativePath(Fullpath, Workspace): =20 RelativePath =3D '' if Workspace.endswith(os.sep): - RelativePath =3D Fullpath[Fullpath.upper().find(Workspace.upper())= +len(Workspace):] + RelativePath =3D Fullpath[Fullpath.upper().find( + Workspace.upper())+len(Workspace):] else: - RelativePath =3D Fullpath[Fullpath.upper().find(Workspace.upper())= +len(Workspace)+1:] + RelativePath =3D Fullpath[Fullpath.upper().find( + Workspace.upper())+len(Workspace)+1:] =20 return RelativePath =20 -## Check whether all module types are in list +# Check whether all module types are in list # # check whether all module types (SUP_MODULE_LIST) are in list # # @param ModuleList: a list of ModuleType # + + def IsAllModuleList(ModuleList): NewModuleList =3D [Module.upper() for Module in ModuleList] for Module in SUP_MODULE_LIST: @@ -495,12 +529,14 @@ def IsAllModuleList(ModuleList): else: return True =20 -## Dictionary that use comment(GenericComment, TailComment) as value, +# Dictionary that use comment(GenericComment, TailComment) as value, # if a new comment which key already in the dic is inserted, then the # comment will be merged. # Key is (Statement, SupArch), when TailComment is added, it will ident # according to Statement # + + class MergeCommentDict(dict): ## []=3D operator # @@ -509,18 +545,18 @@ class MergeCommentDict(dict): if Key in self: OrigVal1, OrigVal2 =3D dict.__getitem__(self, Key) Statement =3D Key[0] - dict.__setitem__(self, Key, (OrigVal1 + GenericComment, OrigVa= l2 \ + dict.__setitem__(self, Key, (OrigVal1 + GenericComment, OrigVa= l2 + len(Statement) * ' ' + TailComm= ent)) else: dict.__setitem__(self, Key, (GenericComment, TailComment)) =20 - ## =3D[] operator + # =3D[] operator # def __getitem__(self, Key): return dict.__getitem__(self, Key) =20 =20 -## GenDummyHelpTextObj +# GenDummyHelpTextObj # # @retval HelpTxt: Generated dummy help text object # @@ -530,7 +566,7 @@ def GenDummyHelpTextObj(): HelpTxt.SetString(' ') return HelpTxt =20 -## ConvertVersionToDecimal, the minor version should be within 0 - 99 +# ConvertVersionToDecimal, the minor version should be within 0 - 99 # ::=3D "0x" # ::=3D (a-fA-F0-9){4} # ::=3D (a-fA-F0-9){4} @@ -539,6 +575,8 @@ def GenDummyHelpTextObj(): # @param StringIn: The string contains version defined in INF file. # It can be Decimal or Hex # + + def ConvertVersionToDecimal(StringIn): if IsValidHexVersion(StringIn): Value =3D int(StringIn, 16) @@ -559,12 +597,14 @@ def ConvertVersionToDecimal(StringIn): # return StringIn =20 -## GetHelpStringByRemoveHashKey +# GetHelpStringByRemoveHashKey # # Remove hash key at the header of string and return the remain. # # @param String: The string need to be processed. # + + def GetHelpStringByRemoveHashKey(String): ReturnString =3D '' PattenRemoveHashKey =3D re.compile(r"^[#+\s]+", re.DOTALL) @@ -585,7 +625,7 @@ def GetHelpStringByRemoveHashKey(String): =20 return ReturnString =20 -## ConvPathFromAbsToRel +# ConvPathFromAbsToRel # # Get relative file path from absolute path. # @@ -593,6 +633,8 @@ def GetHelpStringByRemoveHashKey(String): # @param Root: The string contain the parent path of Path in. # # + + def ConvPathFromAbsToRel(Path, Root): Path =3D os.path.normpath(Path) Root =3D os.path.normpath(Root) @@ -608,13 +650,15 @@ def ConvPathFromAbsToRel(Path, Root): else: return Path =20 -## ConvertPath +# ConvertPath # # Convert special characters to '_', '\' to '/' # return converted path: Test!1.inf -> Test_1.inf # # @param Path: Path to be converted # + + def ConvertPath(Path): RetPath =3D '' for Char in Path.strip(): @@ -626,7 +670,7 @@ def ConvertPath(Path): RetPath =3D RetPath + '_' return RetPath =20 -## ConvertSpec +# ConvertSpec # # during install, convert the Spec string extract from UPD into INF allowa= ble definition, # the difference is period is allowed in the former (not the first letter)= but not in the latter. @@ -634,6 +678,8 @@ def ConvertPath(Path): # # @param SpecStr: SpecStr to be converted # + + def ConvertSpec(SpecStr): RetStr =3D '' for Char in SpecStr: @@ -645,7 +691,7 @@ def ConvertSpec(SpecStr): return RetStr =20 =20 -## IsEqualList +# IsEqualList # # Judge two lists are identical(contain same item). # The rule is elements in List A are in List B and elements in List B are = in List A. @@ -669,7 +715,7 @@ def IsEqualList(ListA, ListB): =20 return True =20 -## ConvertArchList +# ConvertArchList # # Convert item in ArchList if the start character is lower case. # In UDP spec, Arch is only allowed as: [A-Z]([a-zA-Z0-9])* @@ -678,6 +724,8 @@ def IsEqualList(ListA, ListB): # # @return NewList The ArchList been converted. # + + def ConvertArchList(ArchList): NewArchList =3D [] if not ArchList: @@ -693,7 +741,7 @@ def ConvertArchList(ArchList): =20 return NewArchList =20 -## ProcessLineExtender +# ProcessLineExtender # # Process the LineExtender of Line in LineList. # If one line ends with a line extender, then it will be combined together= with next line. @@ -702,6 +750,8 @@ def ConvertArchList(ArchList): # # @return NewList The ArchList been processed. # + + def ProcessLineExtender(LineList): NewList =3D [] Count =3D 0 @@ -716,7 +766,7 @@ def ProcessLineExtender(LineList): =20 return NewList =20 -## ProcessEdkComment +# ProcessEdkComment # # Process EDK style comment in LineList: c style /* */ comment or cpp styl= e // comment # @@ -726,6 +776,8 @@ def ProcessLineExtender(LineList): # @return LineList The LineList been processed. # @return FirstPos Where Edk comment is first found, -1 if not found # + + def ProcessEdkComment(LineList): FindEdkBlockComment =3D False Count =3D 0 @@ -769,7 +821,7 @@ def ProcessEdkComment(LineList): =20 return LineList, FirstPos =20 -## GetLibInstanceInfo +# GetLibInstanceInfo # # Get the information from Library Instance INF file. # @@ -777,6 +829,8 @@ def ProcessEdkComment(LineList): # @param WorkSpace. The WorkSpace directory used to combined with INF file= path. # # @return GUID, Version + + def GetLibInstanceInfo(String, WorkSpace, LineNo): =20 FileGuidString =3D "" @@ -795,7 +849,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): # # Validate file name exist. # - FullFileName =3D os.path.normpath(os.path.realpath(os.path.join(WorkSp= ace, String))) + FullFileName =3D os.path.normpath( + os.path.realpath(os.path.join(WorkSpace, String))) if not (ValidFile(FullFileName)): Logger.Error("InfParser", ToolError.FORMAT_INVALID, @@ -812,7 +867,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (S= tring), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % ( + String), File=3DGlobalData.gINF_MODULE_NAME, Line=3DLineNo, ExtraData=3DOriginalString) @@ -855,7 +911,7 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): =20 return FileGuidString, VerString =20 -## GetLocalValue +# GetLocalValue # # Generate the local value for INF and DEC file. If Lang attribute not pre= sent, then use this value. # If present, and there is no element without the Lang attribute, and one = of the elements has the rfc1766 code is @@ -867,6 +923,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo): # @param UseFirstValue: True to use the first value, False to use the last= value # # @return LocalValue + + def GetLocalValue(ValueList, UseFirstValue=3DFalse): Value1 =3D '' Value2 =3D '' @@ -919,7 +977,7 @@ def GetLocalValue(ValueList, UseFirstValue=3DFalse): return '' =20 =20 -## GetCharIndexOutStr +# GetCharIndexOutStr # # Get comment character index outside a string # @@ -941,19 +999,21 @@ def GetCharIndexOutStr(CommentCharacter, Line): for Index in range(0, len(Line)): if Line[Index] =3D=3D '"': InString =3D not InString - elif Line[Index] =3D=3D CommentCharacter and InString : + elif Line[Index] =3D=3D CommentCharacter and InString: pass - elif Line[Index] =3D=3D CommentCharacter and (Index +1) < len(Line= ) and Line[Index+1] =3D=3D CommentCharacter \ - and not InString : + elif Line[Index] =3D=3D CommentCharacter and (Index + 1) < len(Lin= e) and Line[Index+1] =3D=3D CommentCharacter \ + and not InString: return Index return -1 =20 -## ValidateUNIFilePath +# ValidateUNIFilePath # # Check the UNI file path # # @param FilePath: The UNI file path # + + def ValidateUNIFilePath(Path): Suffix =3D Path[Path.rfind(TAB_SPLIT):] =20 @@ -962,18 +1022,18 @@ def ValidateUNIFilePath(Path): # if Suffix not in TAB_UNI_FILE_SUFFIXS: Logger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - Message=3DST.ERR_UNI_FILE_SUFFIX_WRONG, - ExtraData=3DPath) + ToolError.FORMAT_INVALID, + Message=3DST.ERR_UNI_FILE_SUFFIX_WRONG, + ExtraData=3DPath) =20 # # Check if '..' in the file name(without suffix) # if (TAB_SPLIT + TAB_SPLIT) in Path: Logger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - Message=3DST.ERR_UNI_FILE_NAME_INVALID, - ExtraData=3DPath) + ToolError.FORMAT_INVALID, + Message=3DST.ERR_UNI_FILE_NAME_INVALID, + ExtraData=3DPath) =20 # # Check if the file name is valid according to the DEC and INF specifi= cation @@ -983,7 +1043,6 @@ def ValidateUNIFilePath(Path): InvalidCh =3D re.sub(Pattern, '', FileName) if InvalidCh: Logger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - Message=3DST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME= _INVALID, - ExtraData=3DPath) - + ToolError.FORMAT_INVALID, + Message=3DST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_IN= VALID, + ExtraData=3DPath) diff --git a/BaseTools/Source/Python/UPT/Library/ParserValidate.py b/BaseTo= ols/Source/Python/UPT/Library/ParserValidate.py index 62f406141cc6..202466adf5de 100644 --- a/BaseTools/Source/Python/UPT/Library/ParserValidate.py +++ b/BaseTools/Source/Python/UPT/Library/ParserValidate.py @@ -1,4 +1,4 @@ -## @file ParserValidate.py +# @file ParserValidate.py # Functions for parser validation # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,26 +23,30 @@ from Library.ExpressionValidate import IsValidBareCStri= ng from Library.ExpressionValidate import IsValidFeatureFlagExp from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## __HexDigit() method +# __HexDigit() method # # Whether char input is a Hex data bit # # @param TempChar: The char to test # + + def __HexDigit(TempChar): if (TempChar >=3D 'a' and TempChar <=3D 'f') or \ - (TempChar >=3D 'A' and TempChar <=3D 'F') \ + (TempChar >=3D 'A' and TempChar <=3D 'F') \ or (TempChar >=3D '0' and TempChar <=3D '9'): return True else: return False =20 -## IsValidHex() method +# IsValidHex() method # # Whether char input is a Hex data. # # @param TempChar: The char to test # + + def IsValidHex(HexStr): if not HexStr.upper().startswith("0X"): return False @@ -52,7 +56,7 @@ def IsValidHex(HexStr): else: return False =20 -## Judge the input string is valid bool type or not. +# Judge the input string is valid bool type or not. # # ::=3D {"TRUE"} {"true"} {"True"} {"0x1"} {"0x01= "} # ::=3D {"FALSE"} {"false"} {"False"} {"0x0"} {"0= x00"} @@ -60,6 +64,8 @@ def IsValidHex(HexStr): # # @param BoolString: A string contained the value need to be judged. # + + def IsValidBoolType(BoolString): # # Valid True @@ -74,10 +80,10 @@ def IsValidBoolType(BoolString): # Valid False # elif BoolString =3D=3D 'FALSE' or \ - BoolString =3D=3D 'False' or \ - BoolString =3D=3D 'false' or \ - BoolString =3D=3D '0x0' or \ - BoolString =3D=3D '0x00': + BoolString =3D=3D 'False' or \ + BoolString =3D=3D 'false' or \ + BoolString =3D=3D '0x0' or \ + BoolString =3D=3D '0x00': return True # # Invalid bool type @@ -85,29 +91,35 @@ def IsValidBoolType(BoolString): else: return False =20 -## Is Valid Module Type List or not +# Is Valid Module Type List or not # # @param ModuleTypeList: A list contain ModuleType strings need to be # judged. # + + def IsValidInfMoudleTypeList(ModuleTypeList): for ModuleType in ModuleTypeList: return IsValidInfMoudleType(ModuleType) =20 -## Is Valid Module Type or not +# Is Valid Module Type or not # # @param ModuleType: A string contain ModuleType need to be judged. # + + def IsValidInfMoudleType(ModuleType): if ModuleType in MODULE_LIST: return True else: return False =20 -## Is Valid Component Type or not +# Is Valid Component Type or not # # @param ComponentType: A string contain ComponentType need to be ju= dged. # + + def IsValidInfComponentType(ComponentType): if ComponentType.upper() in COMPONENT_TYPE_LIST: return True @@ -115,7 +127,7 @@ def IsValidInfComponentType(ComponentType): return False =20 =20 -## Is valid Tool Family or not +# Is valid Tool Family or not # # @param ToolFamily: A string contain Tool Family need to be judged. # Family :=3D [A-Z]([a-zA-Z0-9])* @@ -126,12 +138,14 @@ def IsValidToolFamily(ToolFamily): return False return True =20 -## Is valid Tool TagName or not +# Is valid Tool TagName or not # # The TagName sample is MYTOOLS and VS2005. # # @param TagName: A string contain Tool TagName need to be judged. # + + def IsValidToolTagName(TagName): if TagName.strip() =3D=3D '': return True @@ -141,7 +155,7 @@ def IsValidToolTagName(TagName): return False return True =20 -## Is valid arch or not +# Is valid arch or not # # @param Arch The arch string need to be validated # ::=3D (a-zA-Z)(A-Za-z0-9){0,} @@ -149,6 +163,8 @@ def IsValidToolTagName(TagName): # {"common"} # @param Arch: Input arch # + + def IsValidArch(Arch): if Arch =3D=3D 'common': return True @@ -157,13 +173,15 @@ def IsValidArch(Arch): return False return True =20 -## Is valid family or not +# Is valid family or not # # ::=3D {"MSFT"} {"GCC"} {"INTEL"} {} {"*"} # ::=3D [A-Z][A-Za-z0-9]{0,} # # @param family: The family string need to be validated # + + def IsValidFamily(Family): Family =3D Family.strip() if Family =3D=3D '*': @@ -177,10 +195,12 @@ def IsValidFamily(Family): return False return True =20 -## Is valid build option name or not +# Is valid build option name or not # # @param BuildOptionName: The BuildOptionName string need to be validated # + + def IsValidBuildOptionName(BuildOptionName): if not BuildOptionName: return False @@ -207,24 +227,28 @@ def IsValidBuildOptionName(BuildOptionName): =20 return True =20 -## IsValidToken +# IsValidToken # # Check if pattern string matches total token # # @param ReString: regular string # @param Token: Token to be matched # + + def IsValidToken(ReString, Token): Match =3D re.compile(ReString).match(Token) return Match and Match.start() =3D=3D 0 and Match.end() =3D=3D len(Tok= en) =20 -## IsValidPath +# IsValidPath # # Check if path exist # # @param Path: Absolute path or relative path to be checked # @param Root: Root path # + + def IsValidPath(Path, Root): Path =3D Path.strip() OrigPath =3D Path.replace('\\', '/') @@ -269,7 +293,7 @@ def IsValidPath(Path, Root): =20 return True =20 -## IsValidInstallPath +# IsValidInstallPath # # Check if an install path valid or not. # @@ -277,6 +301,8 @@ def IsValidPath(Path, Root): # # @param Path: path to be checked # + + def IsValidInstallPath(Path): if platform.platform().find("Windows") >=3D 0: if os.path.isabs(Path): @@ -295,7 +321,7 @@ def IsValidInstallPath(Path): return True =20 =20 -## IsValidCFormatGuid +# IsValidCFormatGuid # # Check if GUID format has the from of {8,4,4,{2,2,2,2,2,2,2,2}} # @@ -356,19 +382,21 @@ def IsValidCFormatGuid(Guid): =20 return SepValue =3D=3D '}}' and Value =3D=3D '' =20 -## IsValidPcdType +# IsValidPcdType # # Check whether the PCD type is valid # # @param PcdTypeString: The PcdType string need to be checked. # + + def IsValidPcdType(PcdTypeString): if PcdTypeString.upper() in PCD_USAGE_TYPE_LIST_OF_MODULE: return True else: return False =20 -## IsValidWord +# IsValidWord # # Check whether the word is valid. # ::=3D (a-zA-Z0-9_)(a-zA-Z0-9_-){0,} Alphanumeric characters wi= th @@ -378,6 +406,8 @@ def IsValidPcdType(PcdTypeString): # # @param Word: The word string need to be checked. # + + def IsValidWord(Word): if not Word: return False @@ -404,7 +434,7 @@ def IsValidWord(Word): return True =20 =20 -## IsValidSimpleWord +# IsValidSimpleWord # # Check whether the SimpleWord is valid. # ::=3D (a-zA-Z0-9)(a-zA-Z0-9_-){0,} @@ -424,13 +454,15 @@ def IsValidSimpleWord(Word): =20 return True =20 -## IsValidDecVersion +# IsValidDecVersion # # Check whether the decimal version is valid. # ::=3D (0-9){1,} ["." (0-9){1,}] # # @param Word: The word string need to be checked. # + + def IsValidDecVersion(Word): if Word.find('.') > -1: ReIsValidDecVersion =3D re.compile(r"[0-9]+\.?[0-9]+$") @@ -440,7 +472,7 @@ def IsValidDecVersion(Word): return False return True =20 -## IsValidHexVersion +# IsValidHexVersion # # Check whether the hex version is valid. # ::=3D "0x" @@ -449,6 +481,8 @@ def IsValidDecVersion(Word): # # @param Word: The word string need to be checked. # + + def IsValidHexVersion(Word): ReIsValidHexVersion =3D re.compile(r"[0][xX][0-9A-Fa-f]{8}$", re.DOTAL= L) if ReIsValidHexVersion.match(Word) is None: @@ -456,13 +490,15 @@ def IsValidHexVersion(Word): =20 return True =20 -## IsValidBuildNumber +# IsValidBuildNumber # # Check whether the BUILD_NUMBER is valid. # ["BUILD_NUMBER" "=3D" {1,4} ] # # @param Word: The BUILD_NUMBER string need to be checked. # + + def IsValidBuildNumber(Word): ReIsValieBuildNumber =3D re.compile(r"[0-9]{1,4}$", re.DOTALL) if ReIsValieBuildNumber.match(Word) is None: @@ -470,12 +506,14 @@ def IsValidBuildNumber(Word): =20 return True =20 -## IsValidDepex +# IsValidDepex # # Check whether the Depex is valid. # # @param Word: The Depex string need to be checked. # + + def IsValidDepex(Word): Index =3D Word.upper().find("PUSH") if Index > -1: @@ -487,7 +525,7 @@ def IsValidDepex(Word): =20 return True =20 -## IsValidNormalizedString +# IsValidNormalizedString # # Check # ::=3D [{} {}]{1,} @@ -495,6 +533,8 @@ def IsValidDepex(Word): # # @param String: string to be checked # + + def IsValidNormalizedString(String): if String =3D=3D '': return True @@ -513,12 +553,14 @@ def IsValidNormalizedString(String): =20 return True =20 -## IsValidIdString +# IsValidIdString # # Check whether the IdString is valid. # # @param IdString: The IdString need to be checked. # + + def IsValidIdString(String): if IsValidSimpleWord(String.strip()): return True @@ -533,7 +575,7 @@ def IsValidIdString(String): =20 return False =20 -## IsValidVersionString +# IsValidVersionString # # Check whether the VersionString is valid. # ::=3D [ []{0,} []{0,} ]= {0,} @@ -544,6 +586,8 @@ def IsValidIdString(String): # # @param VersionString: The VersionString need to be checked. # + + def IsValidVersionString(VersionString): VersionString =3D VersionString.strip() for Char in VersionString: @@ -552,12 +596,14 @@ def IsValidVersionString(VersionString): =20 return True =20 -## IsValidPcdValue +# IsValidPcdValue # # Check whether the PcdValue is valid. # # @param VersionString: The PcdValue need to be checked. # + + def IsValidPcdValue(PcdValue): for Char in PcdValue: if Char =3D=3D '\n' or Char =3D=3D '\t' or Char =3D=3D '\f': @@ -615,7 +661,7 @@ def IsValidPcdValue(PcdValue): return True =20 ReIsValidByteHex =3D re.compile(r"^\s*0x[0-9a-fA-F]{1,2}\s*$", re.DOTA= LL) - if PcdValue.strip().startswith('{') and PcdValue.strip().endswith('}')= : + if PcdValue.strip().startswith('{') and PcdValue.strip().endswith('}'): StringValue =3D PcdValue.strip().lstrip('{').rstrip('}') ValueList =3D StringValue.split(',') AllValidFlag =3D True @@ -640,12 +686,14 @@ def IsValidPcdValue(PcdValue): =20 return False =20 -## IsValidCVariableName +# IsValidCVariableName # # Check whether the PcdValue is valid. # # @param VersionString: The PcdValue need to be checked. # + + def IsValidCVariableName(CName): ReIsValidCName =3D re.compile(r"^[A-Za-z_][0-9A-Za-z_]*$", re.DOTALL) if ReIsValidCName.match(CName) is None: @@ -653,7 +701,7 @@ def IsValidCVariableName(CName): =20 return True =20 -## IsValidIdentifier +# IsValidIdentifier # # ::=3D {0,} # ::=3D (a-zA-Z0-9_) @@ -661,6 +709,8 @@ def IsValidCVariableName(CName): # # @param Ident: identifier to be checked # + + def IsValidIdentifier(Ident): ReIdent =3D re.compile(r"^[A-Za-z_][0-9A-Za-z_]*$", re.DOTALL) if ReIdent.match(Ident) is None: @@ -668,12 +718,14 @@ def IsValidIdentifier(Ident): =20 return True =20 -## IsValidDecVersionVal +# IsValidDecVersionVal # # {(0-9){1,} "." (0-99)} # # @param Ver: version to be checked # + + def IsValidDecVersionVal(Ver): ReVersion =3D re.compile(r"[0-9]+(\.[0-9]{1,2})$") =20 @@ -683,7 +735,7 @@ def IsValidDecVersionVal(Ver): return True =20 =20 -## IsValidLibName +# IsValidLibName # # (A-Z)(a-zA-Z0-9){0,} and could not be "NULL" # @@ -701,6 +753,8 @@ def IsValidLibName(LibName): # ::=3D (a-zA-Z)(a-zA-Z0-9_.){0,} # Words that contain period "." must be encapsulated in double quotation m= arks. # + + def IsValidUserId(UserId): UserId =3D UserId.strip() Quoted =3D False @@ -719,6 +773,8 @@ def IsValidUserId(UserId): # # Check if a UTF16-LE file has a BOM header # + + def CheckUTF16FileHeader(File): FileIn =3D open(File, 'rb').read(2) if FileIn !=3D b'\xff\xfe': diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Sou= rce/Python/UPT/Library/Parsing.py index 6fb133745e36..2ac5ae82e0cd 100644 --- a/BaseTools/Source/Python/UPT/Library/Parsing.py +++ b/BaseTools/Source/Python/UPT/Library/Parsing.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common parsing related functions used in par= sing # INF/DEC/DSC process # @@ -41,7 +41,7 @@ from . import GlobalData =20 gPKG_INFO_DICT =3D {} =20 -## GetBuildOption +# GetBuildOption # # Parse a string with format "[:]=3DFlag" # Return (Family, ToolFlag, Flag) @@ -49,22 +49,24 @@ gPKG_INFO_DICT =3D {} # @param String: String with BuildOption statement # @param File: The file which defines build option, used in error report # -def GetBuildOption(String, File, LineNo=3D -1): + + +def GetBuildOption(String, File, LineNo=3D-1): (Family, ToolChain, Flag) =3D ('', '', '') if String.find(DataType.TAB_EQUAL_SPLIT) < 0: - RaiseParserError(String, 'BuildOptions', File, \ + RaiseParserError(String, 'BuildOptions', File, '[:]=3DFlag', LineNo) else: List =3D GetSplitValueList(String, DataType.TAB_EQUAL_SPLIT, MaxSp= lit=3D1) if List[0].find(':') > -1: - Family =3D List[0][ : List[0].find(':')].strip() - ToolChain =3D List[0][List[0].find(':') + 1 : ].strip() + Family =3D List[0][: List[0].find(':')].strip() + ToolChain =3D List[0][List[0].find(':') + 1:].strip() else: ToolChain =3D List[0].strip() Flag =3D List[1].strip() return (Family, ToolChain, Flag) =20 -## Get Library Class +# Get Library Class # # Get Library of Dsc as | # @@ -72,23 +74,25 @@ def GetBuildOption(String, File, LineNo=3D -1): # @param ContainerFile: The file which describes the library class, used = for # error report # -def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo=3D -1): + + +def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo=3D-1): List =3D GetSplitValueList(Item[0]) SupMod =3D DataType.SUP_MODULE_LIST_STRING if len(List) !=3D 2: - RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, \ + RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, '|') else: - CheckFileType(List[1], '.Inf', ContainerFile, \ + CheckFileType(List[1], '.Inf', ContainerFile, 'library class instance', Item[0], LineNo) - CheckFileExist(WorkspaceDir, List[1], ContainerFile, \ + CheckFileExist(WorkspaceDir, List[1], ContainerFile, 'LibraryClasses', Item[0], LineNo) if Item[1] !=3D '': SupMod =3D Item[1] =20 return (List[0], List[1], SupMod) =20 -## Get Library Class +# Get Library Class # # Get Library of Dsc as [|] # [|.] @@ -97,29 +101,30 @@ def GetLibraryClass(Item, ContainerFile, WorkspaceDir,= LineNo=3D -1): # @param ContainerFile: The file which describes the library class, used = for # error report # -def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo=3D -1): + + +def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo=3D-1): ItemList =3D GetSplitValueList((Item[0] + DataType.TAB_VALUE_SPLIT * 2= )) SupMod =3D DataType.SUP_MODULE_LIST_STRING =20 if len(ItemList) > 5: - RaiseParserError\ - (Item[0], 'LibraryClasses', ContainerFile, \ - '[|]\ + RaiseParserError(Item[0], 'LibraryClasses', ContainerFile, + '[|]\ [|.]') else: - CheckFileType(ItemList[1], '.Inf', ContainerFile, 'LibraryClasses'= , \ + CheckFileType(ItemList[1], '.Inf', ContainerFile, 'LibraryClasses', Item[0], LineNo) - CheckFileExist(WorkspaceDir, ItemList[1], ContainerFile, \ + CheckFileExist(WorkspaceDir, ItemList[1], ContainerFile, 'LibraryClasses', Item[0], LineNo) if ItemList[2] !=3D '': - CheckPcdTokenInfo(ItemList[2], 'LibraryClasses', \ + CheckPcdTokenInfo(ItemList[2], 'LibraryClasses', ContainerFile, LineNo) if Item[1] !=3D '': SupMod =3D Item[1] =20 return (ItemList[0], ItemList[1], ItemList[2], SupMod) =20 -## CheckPcdTokenInfo +# CheckPcdTokenInfo # # Check if PcdTokenInfo is following . # @@ -127,7 +132,9 @@ def GetLibraryClassOfInf(Item, ContainerFile, Workspace= Dir, LineNo=3D -1): # @param Section: Used for error report # @param File: Used for error report # -def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo=3D -1): + + +def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo=3D-1): Format =3D '.' if TokenInfoString !=3D '' and TokenInfoString is not None: TokenInfoList =3D GetSplitValueList(TokenInfoString, DataType.TAB_= SPLIT) @@ -136,7 +143,7 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, L= ineNo=3D -1): =20 RaiseParserError(TokenInfoString, Section, File, Format, LineNo) =20 -## Get Pcd +# Get Pcd # # Get Pcd of Dsc as .| # [||] @@ -147,12 +154,14 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File,= LineNo=3D -1): # report =20 # -def GetPcd(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value, MaximumDatumSize, Token =3D '', '', '', '= ', '' List =3D GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT * 2) =20 if len(List) < 4 or len(List) > 6: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, \ + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|\ [||]', LineNo) else: @@ -165,7 +174,7 @@ def GetPcd(Item, Type, ContainerFile, LineNo=3D -1): =20 return (TokenName, TokenGuid, Value, MaximumDatumSize, Token, Type) =20 -## Get FeatureFlagPcd +# Get FeatureFlagPcd # # Get FeatureFlagPcd of Dsc as .|TRUE/= FALSE # @@ -174,12 +183,14 @@ def GetPcd(Item, Type, ContainerFile, LineNo=3D -1): # @param ContainerFile: The file which describes the pcd, used for error # report # -def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value =3D '', '', '' List =3D GetSplitValueList(Item) if len(List) !=3D 2: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, \ - '.|TRUE/FALSE= ', \ + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, + '.|TRUE/FALSE= ', LineNo) else: Value =3D List[1] @@ -188,7 +199,7 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo= =3D -1): =20 return (TokenName, TokenGuid, Value, Type) =20 -## Get DynamicDefaultPcd +# Get DynamicDefaultPcd # # Get DynamicDefaultPcd of Dsc as . # |[|[|]] @@ -198,11 +209,13 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, Line= No=3D -1): # @param ContainerFile: The file which describes the pcd, used for error # report # -def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, Value, DatumTyp, MaxDatumSize =3D '', '', '', ''= , '' List =3D GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT * 2) if len(List) < 4 or len(List) > 8: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, \ + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|\ [|[|]]', LineNo) else: @@ -214,7 +227,7 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, Lin= eNo=3D -1): =20 return (TokenName, TokenGuid, Value, DatumTyp, MaxDatumSize, Type) =20 -## Get DynamicHiiPcd +# Get DynamicHiiPcd # # Get DynamicHiiPcd of Dsc as .|| # |[|[|= ]] @@ -224,24 +237,26 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, L= ineNo=3D -1): # @param ContainerFile: The file which describes the pcd, used for error # report # -def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, List1, List2, List3, List4, List5 =3D \ - '', '', '', '', '', '', '' + '', '', '', '', '', '', '' List =3D GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT * 2) if len(List) < 6 or len(List) > 8: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, \ + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.||\ |[|\ [|]]', LineNo) else: List1, List2, List3, List4, List5 =3D \ - List[1], List[2], List[3], List[4], List[5] + List[1], List[2], List[3], List[4], List[5] if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo): (TokenGuid, TokenName) =3D GetSplitValueList(List[0], DataType.TAB= _SPLIT) =20 return (TokenName, TokenGuid, List1, List2, List3, List4, List5, Type) =20 -## Get DynamicVpdPcd +# Get DynamicVpdPcd # # Get DynamicVpdPcd of Dsc as .| # [|] @@ -251,11 +266,13 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineN= o=3D -1): # @param ContainerFile: The file which describes the pcd, used for error # report # -def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo=3D-1): TokenGuid, TokenName, List1, List2 =3D '', '', '', '' List =3D GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT) if len(List) < 3 or len(List) > 4: - RaiseParserError(Item, 'Pcds' + Type, ContainerFile, \ + RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '.|\ [|]', LineNo) else: @@ -265,7 +282,7 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo= =3D -1): =20 return (TokenName, TokenGuid, List1, List2, Type) =20 -## GetComponent +# GetComponent # # Parse block of the components defined in dsc file # Set KeyValues as [ ['component name', [lib1, lib2, lib3], @@ -274,10 +291,12 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineN= o=3D -1): # @param Lines: The content to be parsed # @param KeyValues: To store data after parsing # + + def GetComponent(Lines, KeyValues): - (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, \ - FindPcdsDynamicEx) =3D (False, False, False, False, False, False, Fal= se, \ + (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, + FindPcdsDynamicEx) =3D (False, False, False, False, False, False, Fal= se, False) ListItem =3D None LibraryClassItem =3D [] @@ -290,7 +309,7 @@ def GetComponent(Lines, KeyValues): # Ignore !include statement # if Line.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1 or \ - Line.upper().find(DataType.TAB_DEFINE + ' ') > -1: + Line.upper().find(DataType.TAB_DEFINE + ' ') > -1: continue =20 if FindBlock =3D=3D False: @@ -300,7 +319,7 @@ def GetComponent(Lines, KeyValues): # if Line.endswith('{'): FindBlock =3D True - ListItem =3D CleanString(Line.rsplit('{', 1)[0], \ + ListItem =3D CleanString(Line.rsplit('{', 1)[0], DataType.TAB_COMMENT_SPLIT) =20 # @@ -308,57 +327,57 @@ def GetComponent(Lines, KeyValues): # if FindBlock: if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (True, False, False, False, False, False, False) + (True, False, False, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, True, False, False, False, False, False) + (False, True, False, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, True, False, False, False, False) + (False, False, True, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, True, False, False, False) + (False, False, False, True, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, True, False, False) + (False, False, False, False, True, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, False, True, False) + (False, False, False, False, False, True, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, False, False, True) + (False, False, False, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # - KeyValues.append([ListItem, LibraryClassItem, \ + KeyValues.append([ListItem, LibraryClassItem, BuildOption, Pcd]) - (FindBlock, FindLibraryClass, FindBuildOption, \ - FindPcdsFeatureFlag, FindPcdsPatchableInModule, \ + (FindBlock, FindLibraryClass, FindBuildOption, + FindPcdsFeatureFlag, FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx)= =3D \ - (False, False, False, False, False, False, False, False) + (False, False, False, False, False, False, False, Fals= e) LibraryClassItem, BuildOption, Pcd =3D [], [], [] continue =20 @@ -382,25 +401,27 @@ def GetComponent(Lines, KeyValues): =20 return True =20 -## GetExec +# GetExec # # Parse a string with format "InfFilename [EXEC =3D ExecFilename]" # Return (InfFilename, ExecFilename) # # @param String: String with EXEC statement # + + def GetExec(String): InfFilename =3D '' ExecFilename =3D '' if String.find('EXEC') > -1: - InfFilename =3D String[ : String.find('EXEC')].strip() - ExecFilename =3D String[String.find('EXEC') + len('EXEC') : ].stri= p() + InfFilename =3D String[: String.find('EXEC')].strip() + ExecFilename =3D String[String.find('EXEC') + len('EXEC'):].strip() else: InfFilename =3D String.strip() =20 return (InfFilename, ExecFilename) =20 -## GetComponents +# GetComponents # # Parse block of the components defined in dsc file # Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3= ], @@ -413,13 +434,15 @@ def GetExec(String): # # @retval True Get component successfully # + + def GetComponents(Lines, KeyValues, CommentCharacter): if Lines.find(DataType.TAB_SECTION_END) > -1: Lines =3D Lines.split(DataType.TAB_SECTION_END, 1)[1] - (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, \ + (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, False, False, False, False) + (False, False, False, False, False, False, False, False) ListItem =3D None LibraryClassItem =3D [] BuildOption =3D [] @@ -438,64 +461,65 @@ def GetComponents(Lines, KeyValues, CommentCharacter): # if Line.endswith('{'): FindBlock =3D True - ListItem =3D CleanString(Line.rsplit('{', 1)[0], CommentCh= aracter) + ListItem =3D CleanString(Line.rsplit('{', 1)[ + 0], CommentCharacter) =20 # # Parse a block content # if FindBlock: if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (True, False, False, False, False, False, False) + (True, False, False, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, True, False, False, False, False, False) + (False, True, False, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, True, False, False, False, False) + (False, False, True, False, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, True, False, False, False) + (False, False, False, True, False, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, True, False, False) + (False, False, False, False, True, False, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, False, True, False) + (False, False, False, False, False, True, False) continue if Line.find('') !=3D -1: - (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ - FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ + (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, + FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) =3D \ - (False, False, False, False, False, False, True) + (False, False, False, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # - KeyValues.append([ListItem, LibraryClassItem, BuildOption,= \ + KeyValues.append([ListItem, LibraryClassItem, BuildOption, Pcd]) - (FindBlock, FindLibraryClass, FindBuildOption, \ - FindPcdsFeatureFlag, FindPcdsPatchableInModule, \ + (FindBlock, FindLibraryClass, FindBuildOption, + FindPcdsFeatureFlag, FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx)= =3D \ - (False, False, False, False, False, False, False, False) + (False, False, False, False, False, False, False, Fals= e) LibraryClassItem, BuildOption, Pcd =3D [], [], [] continue =20 @@ -519,7 +543,7 @@ def GetComponents(Lines, KeyValues, CommentCharacter): =20 return True =20 -## Get Source +# Get Source # # Get Source of Inf as [|[|[| # [|]]]] @@ -529,22 +553,24 @@ def GetComponents(Lines, KeyValues, CommentCharacter): # @param ContainerFile: The file which describes the library class, used # for error report # -def GetSource(Item, ContainerFile, FileRelativePath, LineNo=3D -1): + + +def GetSource(Item, ContainerFile, FileRelativePath, LineNo=3D-1): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT * 4 List =3D GetSplitValueList(ItemNew) if len(List) < 5 or len(List) > 9: - RaiseParserError(Item, 'Sources', ContainerFile, \ + RaiseParserError(Item, 'Sources', ContainerFile, '[|[|[|\ [|]]]]', LineNo) List[0] =3D NormPath(List[0]) - CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Sources', \ + CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Sources', Item, LineNo) if List[4] !=3D '': CheckPcdTokenInfo(List[4], 'Sources', ContainerFile, LineNo) =20 return (List[0], List[1], List[2], List[3], List[4]) =20 -## Get Binary +# Get Binary # # Get Binary of Inf as [|[|[| # [|]]]] @@ -554,11 +580,13 @@ def GetSource(Item, ContainerFile, FileRelativePath, = LineNo=3D -1): # @param ContainerFile: The file which describes the library class, # used for error report # -def GetBinary(Item, ContainerFile, LineNo=3D -1): + + +def GetBinary(Item, ContainerFile, LineNo=3D-1): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) if len(List) < 3 or len(List) > 5: - RaiseParserError(Item, 'Binaries', ContainerFile, \ + RaiseParserError(Item, 'Binaries', ContainerFile, "|[|\ [|.]]", LineNo) =20 @@ -569,7 +597,7 @@ def GetBinary(Item, ContainerFile, LineNo=3D -1): elif len(List) =3D=3D 3: return (List[0], List[1], List[2], '') =20 -## Get Guids/Protocols/Ppis +# Get Guids/Protocols/Ppis # # Get Guids/Protocols/Ppis of Inf as [|] # @@ -578,12 +606,14 @@ def GetBinary(Item, ContainerFile, LineNo=3D -1): # @param ContainerFile: The file which describes the library class, # used for error report # + + def GetGuidsProtocolsPpisOfInf(Item): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) return (List[0], List[1]) =20 -## Get Guids/Protocols/Ppis +# Get Guids/Protocols/Ppis # # Get Guids/Protocols/Ppis of Dec as =3D # @@ -592,29 +622,31 @@ def GetGuidsProtocolsPpisOfInf(Item): # @param ContainerFile: The file which describes the library class, # used for error report # -def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo=3D -1): + + +def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo=3D-1): List =3D GetSplitValueList(Item, DataType.TAB_EQUAL_SPLIT) if len(List) !=3D 2: - RaiseParserError(Item, Type, ContainerFile, '=3D= ', \ + RaiseParserError(Item, Type, ContainerFile, '=3D= ', LineNo) # - #convert C-Format Guid to Register Format + # convert C-Format Guid to Register Format # if List[1][0] =3D=3D '{' and List[1][-1] =3D=3D '}': RegisterFormatGuid =3D GuidStructureStringToGuidString(List[1]) if RegisterFormatGuid =3D=3D '': - RaiseParserError(Item, Type, ContainerFile, \ + RaiseParserError(Item, Type, ContainerFile, 'CFormat or RegisterFormat', LineNo) else: if CheckGuidRegFormat(List[1]): RegisterFormatGuid =3D List[1] else: - RaiseParserError(Item, Type, ContainerFile, \ + RaiseParserError(Item, Type, ContainerFile, 'CFormat or RegisterFormat', LineNo) =20 return (List[0], RegisterFormatGuid) =20 -## GetPackage +# GetPackage # # Get Package of Inf as [|] # @@ -623,18 +655,20 @@ def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerF= ile, LineNo=3D -1): # @param ContainerFile: The file which describes the library class, # used for error report # -def GetPackage(Item, ContainerFile, FileRelativePath, LineNo=3D -1): + + +def GetPackage(Item, ContainerFile, FileRelativePath, LineNo=3D-1): ItemNew =3D Item + DataType.TAB_VALUE_SPLIT List =3D GetSplitValueList(ItemNew) CheckFileType(List[0], '.Dec', ContainerFile, 'package', List[0], Line= No) - CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Packages', \ + CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Packages', List[0], LineNo) if List[1] !=3D '': CheckPcdTokenInfo(List[1], 'Packages', ContainerFile, LineNo) =20 return (List[0], List[1]) =20 -## Get Pcd Values of Inf +# Get Pcd Values of Inf # # Get Pcd of Inf as .[|] # @@ -642,6 +676,8 @@ def GetPackage(Item, ContainerFile, FileRelativePath, L= ineNo=3D -1): # @param Type: The type of Pcd # @param File: The file which describes the pcd, used for error report # + + def GetPcdOfInf(Item, Type, File, LineNo): Format =3D '.[|]' TokenGuid, TokenName, Value, InfType =3D '', '', '', '' @@ -671,7 +707,7 @@ def GetPcdOfInf(Item, Type, File, LineNo): return (TokenGuid, TokenName, Value, InfType) =20 =20 -## Get Pcd Values of Dec +# Get Pcd Values of Dec # # Get Pcd of Dec as .||| # @param Item: Pcd item @@ -679,7 +715,7 @@ def GetPcdOfInf(Item, Type, File, LineNo): # @param File: Dec file # @param LineNo: Line number # -def GetPcdOfDec(Item, Type, File, LineNo=3D -1): +def GetPcdOfDec(Item, Type, File, LineNo=3D-1): Format =3D '.|||' TokenGuid, TokenName, Value, DatumType, Token =3D '', '', '', '', '' List =3D GetSplitValueList(Item) @@ -698,7 +734,7 @@ def GetPcdOfDec(Item, Type, File, LineNo=3D -1): =20 return (TokenGuid, TokenName, Value, DatumType, Token, Type) =20 -## Parse DEFINE statement +# Parse DEFINE statement # # Get DEFINE macros # @@ -711,21 +747,23 @@ def GetPcdOfDec(Item, Type, File, LineNo=3D -1): # @param SectionModel: DEFINE section model # @param Arch: DEFINE arch # -def ParseDefine(LineValue, StartLine, Table, FileID, SectionName, \ + + +def ParseDefine(LineValue, StartLine, Table, FileID, SectionName, SectionModel, Arch): - Logger.Debug(Logger.DEBUG_2, ST.MSG_DEFINE_STATEMENT_FOUND % (LineValu= e, \ + Logger.Debug(Logger.DEBUG_2, ST.MSG_DEFINE_STATEMENT_FOUND % (LineValu= e, SectionN= ame)) Define =3D \ - GetSplitValueList(CleanString\ - (LineValue[LineValue.upper().\ - find(DataType.TAB_DEFINE.upper() + ' ') += \ - len(DataType.TAB_DEFINE + ' ') : ]), \ - DataType.TAB_EQUAL_SPLIT, 1) - Table.Insert(DataType.MODEL_META_DATA_DEFINE, Define[0], Define[1], ''= , \ - '', '', Arch, SectionModel, FileID, StartLine, -1, \ + GetSplitValueList(CleanString + (LineValue[LineValue.upper(). + find(DataType.TAB_DEFINE.upper() + ' = ') + + len(DataType.TAB_DEFINE + ' '):]), + DataType.TAB_EQUAL_SPLIT, 1) + Table.Insert(DataType.MODEL_META_DATA_DEFINE, Define[0], Define[1], '', + '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0) =20 -## InsertSectionItems +# InsertSectionItems # # Insert item data of a section to a dict # @@ -736,7 +774,9 @@ def ParseDefine(LineValue, StartLine, Table, FileID, Se= ctionName, \ # @param ThirdList: Third list # @param RecordSet: Record set # -def InsertSectionItems(Model, SectionItemList, ArchList, \ + + +def InsertSectionItems(Model, SectionItemList, ArchList, ThirdList, RecordSet): # # Insert each item data of a section @@ -750,7 +790,7 @@ def InsertSectionItems(Model, SectionItemList, ArchList= , \ Records =3D RecordSet[Model] for SectionItem in SectionItemList: LineValue, StartLine, Comment =3D SectionItem[0], \ - SectionItem[1], SectionItem[2] + SectionItem[1], SectionItem[2] =20 Logger.Debug(4, ST.MSG_PARSING % LineValue) # @@ -767,24 +807,28 @@ def InsertSectionItems(Model, SectionItemList, ArchLi= st, \ if RecordSet !=3D {}: RecordSet[Model] =3D Records =20 -## GenMetaDatSectionItem +# GenMetaDatSectionItem # # @param Key: A key # @param Value: A value # @param List: A list # + + def GenMetaDatSectionItem(Key, Value, List): if Key not in List: List[Key] =3D [Value] else: List[Key].append(Value) =20 -## GetPkgInfoFromDec +# GetPkgInfoFromDec # # get package name, guid, version info from dec files # # @param Path: File path # + + def GetPkgInfoFromDec(Path): PkgName =3D None PkgGuid =3D None @@ -815,7 +859,7 @@ def GetPkgInfoFromDec(Path): return None, None, None =20 =20 -## GetWorkspacePackage +# GetWorkspacePackage # # Get a list of workspace package information. # @@ -837,8 +881,8 @@ def GetWorkspacePackage(): continue Ext =3D os.path.splitext(FileSp)[1] if Ext.lower() in ['.dec']: - DecFileList.append\ - (os.path.normpath(os.path.join(Root, FileSp))) + DecFileList.append(os.path.normpath( + os.path.join(Root, FileSp))) # # abstract package guid, version info from DecFile List # @@ -850,10 +894,12 @@ def GetWorkspacePackage(): =20 return PkgList =20 -## GetWorkspaceModule +# GetWorkspaceModule # # Get a list of workspace modules. # + + def GetWorkspaceModule(): InfFileList =3D [] WorkspaceDir =3D GlobalData.gWORKSPACE @@ -872,18 +918,20 @@ def GetWorkspaceModule(): continue Ext =3D os.path.splitext(FileSp)[1] if Ext.lower() in ['.inf']: - InfFileList.append\ - (os.path.normpath(os.path.join(Root, FileSp))) + InfFileList.append(os.path.normpath( + os.path.join(Root, FileSp))) =20 return InfFileList =20 -## MacroParser used to parse macro definition +# MacroParser used to parse macro definition # # @param Line: The content contain linestring and line number # @param FileName: The meta-file file name # @param SectionType: Section for the Line belong to # @param FileLocalMacros: A list contain Macro defined in [Defines] sectio= n. # + + def MacroParser(Line, FileName, SectionType, FileLocalMacros): MacroDefPattern =3D re.compile("^(DEFINE)[ \t]+") LineContent =3D Line[0] @@ -895,17 +943,17 @@ def MacroParser(Line, FileName, SectionType, FileLoca= lMacros): # return None, None =20 - TokenList =3D GetSplitValueList(LineContent[Match.end(1):], \ + TokenList =3D GetSplitValueList(LineContent[Match.end(1):], DataType.TAB_EQUAL_SPLIT, 1) # # Syntax check # if not TokenList[0]: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_MACRONAME_NOGIVEN, - ExtraData=3DLineContent, File=3DFileName, Line=3DL= ineNo) + ExtraData=3DLineContent, File=3DFileName, Line=3DLine= No) if len(TokenList) < 2: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_MACROVALUE_NOGIVEN, - ExtraData=3DLineContent, File=3DFileName, Line=3DL= ineNo) + ExtraData=3DLineContent, File=3DFileName, Line=3DLine= No) =20 Name, Value =3D TokenList =20 @@ -945,7 +993,7 @@ def MacroParser(Line, FileName, SectionType, FileLocalM= acros): =20 return Name, Value =20 -## GenSection +# GenSection # # generate section contents # @@ -956,21 +1004,26 @@ def MacroParser(Line, FileName, SectionType, FileLoc= alMacros): # separated by space, # value is statement # + + def GenSection(SectionName, SectionDict, SplitArch=3DTrue, NeedBlankLine= =3DFalse): Content =3D '' for SectionAttrs in SectionDict: StatementList =3D SectionDict[SectionAttrs] if SectionAttrs and SectionName !=3D 'Defines' and SectionAttrs.st= rip().upper() !=3D DataType.TAB_ARCH_COMMON: if SplitArch: - ArchList =3D GetSplitValueList(SectionAttrs, DataType.TAB_= SPACE_SPLIT) + ArchList =3D GetSplitValueList( + SectionAttrs, DataType.TAB_SPACE_SPLIT) else: if SectionName !=3D 'UserExtensions': - ArchList =3D GetSplitValueList(SectionAttrs, DataType.= TAB_COMMENT_SPLIT) + ArchList =3D GetSplitValueList( + SectionAttrs, DataType.TAB_COMMENT_SPLIT) else: ArchList =3D [SectionAttrs] for Index in range(0, len(ArchList)): ArchList[Index] =3D ConvertArchForInstall(ArchList[Index]) - Section =3D '[' + SectionName + '.' + (', ' + SectionName + '.= ').join(ArchList) + ']' + Section =3D '[' + SectionName + '.' + \ + (', ' + SectionName + '.').join(ArchList) + ']' else: Section =3D '[' + SectionName + ']' Content +=3D '\n' + Section + '\n' @@ -998,16 +1051,18 @@ def GenSection(SectionName, SectionDict, SplitArch= =3DTrue, NeedBlankLine=3DFalse): return '' return Content =20 -## ConvertArchForInstall +# ConvertArchForInstall # if Arch.upper() is in "IA32", "X64", "IPF", and "EBC", it must be upper = case. "common" must be lower case. # Anything else, the case must be preserved # # @param Arch: the arch string that need to be converted, it should be str= ipped before pass in # @return: the arch string that get converted # + + def ConvertArchForInstall(Arch): if Arch.upper() in [DataType.TAB_ARCH_IA32, DataType.TAB_ARCH_X64, - DataType.TAB_ARCH_IPF, DataType.TAB_ARC= H_EBC]: + DataType.TAB_ARCH_IPF, DataType.TAB_ARCH_EBC]: Arch =3D Arch.upper() elif Arch.upper() =3D=3D DataType.TAB_ARCH_COMMON: Arch =3D Arch.lower() diff --git a/BaseTools/Source/Python/UPT/Library/StringUtils.py b/BaseTools= /Source/Python/UPT/Library/StringUtils.py index fbc5177caf5a..df9d10b0bb83 100644 --- a/BaseTools/Source/Python/UPT/Library/StringUtils.py +++ b/BaseTools/Source/Python/UPT/Library/StringUtils.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common string related functions used in pars= ing # process # @@ -25,7 +25,7 @@ from Logger import StringTable as ST # gMACRO_PATTERN =3D re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE) =20 -## GetSplitValueList +# GetSplitValueList # # Get a value list from a string with multiple values split with SplitTag # The default SplitTag is DataType.TAB_VALUE_SPLIT @@ -36,10 +36,12 @@ gMACRO_PATTERN =3D re.compile("\$\(([_A-Z][_A-Z0-9]*)\)= ", re.UNICODE) # @param MaxSplit: The max number of split values, default is -1 # # -def GetSplitValueList(String, SplitTag=3DDataType.TAB_VALUE_SPLIT, MaxSpli= t=3D -1): + + +def GetSplitValueList(String, SplitTag=3DDataType.TAB_VALUE_SPLIT, MaxSpli= t=3D-1): return list(map(lambda l: l.strip(), String.split(SplitTag, MaxSplit))) =20 -## MergeArches +# MergeArches # # Find a key's all arches in dict, add the new arch to the list # If not exist any arch, set the arch directly @@ -48,13 +50,15 @@ def GetSplitValueList(String, SplitTag=3DDataType.TAB_V= ALUE_SPLIT, MaxSplit=3D -1): # @param Key: The input value for Key # @param Arch: The Arch to be added or merged # + + def MergeArches(Dict, Key, Arch): if Key in Dict.keys(): Dict[Key].append(Arch) else: Dict[Key] =3D Arch.split() =20 -## GenDefines +# GenDefines # # Parse a string with format "DEFINE =3D " # Generate a map Defines[VarName] =3D PATH @@ -64,10 +68,12 @@ def MergeArches(Dict, Key, Arch): # @param Arch: Supported Arch # @param Defines: DEFINE statement to be parsed # + + def GenDefines(String, Arch, Defines): if String.find(DataType.TAB_DEFINE + ' ') > -1: List =3D String.replace(DataType.TAB_DEFINE + ' ', '').\ - split(DataType.TAB_EQUAL_SPLIT) + split(DataType.TAB_EQUAL_SPLIT) if len(List) =3D=3D 2: Defines[(CleanString(List[0]), Arch)] =3D CleanString(List[1]) return 0 @@ -75,7 +81,7 @@ def GenDefines(String, Arch, Defines): return -1 return 1 =20 -## GetLibraryClassesWithModuleType +# GetLibraryClassesWithModuleType # # Get Library Class definition when no module type defined # @@ -84,6 +90,8 @@ def GenDefines(String, Arch, Defines): # @param KeyValues: To store data after parsing # @param CommentCharacter: Comment char, used to ignore comment content # + + def GetLibraryClassesWithModuleType(Lines, Key, KeyValues, CommentCharacte= r): NewKey =3D SplitModuleType(Key) Lines =3D Lines.split(DataType.TAB_SECTION_END, 1)[1] @@ -95,7 +103,7 @@ def GetLibraryClassesWithModuleType(Lines, Key, KeyValue= s, CommentCharacter): =20 return True =20 -## GetDynamics +# GetDynamics # # Get Dynamic Pcds # @@ -104,6 +112,8 @@ def GetLibraryClassesWithModuleType(Lines, Key, KeyValu= es, CommentCharacter): # @param KeyValues: To store data after parsing # @param CommentCharacter: Comment char, used to ignore comment content # + + def GetDynamics(Lines, Key, KeyValues, CommentCharacter): # # Get SkuId Name List @@ -115,11 +125,12 @@ def GetDynamics(Lines, Key, KeyValues, CommentCharact= er): for Line in LineList: Line =3D CleanString(Line, CommentCharacter) if Line !=3D '' and Line[0] !=3D CommentCharacter: - KeyValues.append([CleanString(Line, CommentCharacter), SkuIdNa= meList[1]]) + KeyValues.append( + [CleanString(Line, CommentCharacter), SkuIdNameList[1]]) =20 return True =20 -## SplitModuleType +# SplitModuleType # # Split ModuleType out of section defien to get key # [LibraryClass.Arch.ModuleType|ModuleType|ModuleType] -> [ @@ -127,6 +138,8 @@ def GetDynamics(Lines, Key, KeyValues, CommentCharacter= ): # # @param Key: String to be parsed # + + def SplitModuleType(Key): KeyList =3D Key.split(DataType.TAB_SPLIT) # @@ -146,7 +159,7 @@ def SplitModuleType(Key): =20 return ReturnValue =20 -## Replace macro in string +# Replace macro in string # # This method replace macros used in given string. The macros are given in= a # dictionary. @@ -157,6 +170,8 @@ def SplitModuleType(Key): # @param Line: The content contain line string and line number # @param FileName: The meta-file file name # + + def ReplaceMacro(String, MacroDefinitions=3DNone, SelfReplacement=3DFalse,= Line=3DNone, FileName=3DNone, Flag=3DFalse): LastString =3D String if MacroDefinitions is None: @@ -191,20 +206,22 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, Sel= fReplacement=3DFalse, Line=3DNone if Macro not in MacroDefinitions: if SelfReplacement: String =3D String.replace("$(%s)" % Macro, '') - Logger.Debug(5, "Delete undefined MACROs in file %s li= ne %d: %s!" % (FileName, Line[1], Line[0])) + Logger.Debug(5, "Delete undefined MACROs in file %s li= ne %d: %s!" % ( + FileName, Line[1], Line[0])) continue if not HaveQuotedMacroFlag: - String =3D String.replace("$(%s)" % Macro, MacroDefinition= s[Macro]) + String =3D String.replace( + "$(%s)" % Macro, MacroDefinitions[Macro]) else: Count =3D 0 for QuotedStringItem in QuotedStringList: Count +=3D 1 if Count % 2 !=3D 0: QuotedStringList[Count - 1] =3D QuotedStringList[C= ount - 1].replace("$(%s)" % Macro, - Ma= croDefinitions[Macro]) + = MacroDefinitions[Macro]) elif Count =3D=3D len(QuotedStringList) and Count % 2 = =3D=3D 0: QuotedStringList[Count - 1] =3D QuotedStringList[C= ount - 1].replace("$(%s)" % Macro, - Ma= croDefinitions[Macro]) + = MacroDefinitions[Macro]) =20 RetString =3D '' if HaveQuotedMacroFlag: @@ -227,7 +244,7 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, SelfR= eplacement=3DFalse, Line=3DNone =20 return String =20 -## NormPath +# NormPath # # Create a normal path # And replace DEFINE in the path @@ -235,6 +252,8 @@ def ReplaceMacro(String, MacroDefinitions=3DNone, SelfR= eplacement=3DFalse, Line=3DNone # @param Path: The input value for Path to be converted # @param Defines: A set for DEFINE statement # + + def NormPath(Path, Defines=3DNone): IsRelativePath =3D False if Defines is None: @@ -256,7 +275,7 @@ def NormPath(Path, Defines=3DNone): Path =3D os.path.join('.', Path) return Path =20 -## CleanString +# CleanString # # Remove comments in a string # Remove spaces @@ -265,6 +284,8 @@ def NormPath(Path, Defines=3DNone): # @param CommentCharacter: Comment char, used to ignore comment content, # default is DataType.TAB_COMMENT_SPLIT # + + def CleanString(Line, CommentCharacter=3DDataType.TAB_COMMENT_SPLIT, Allow= CppStyleComment=3DFalse): # # remove whitespace @@ -292,7 +313,7 @@ def CleanString(Line, CommentCharacter=3DDataType.TAB_C= OMMENT_SPLIT, AllowCppStyle =20 return Line =20 -## CleanString2 +# CleanString2 # # Split comments in a string # Remove spaces @@ -301,6 +322,8 @@ def CleanString(Line, CommentCharacter=3DDataType.TAB_C= OMMENT_SPLIT, AllowCppStyle # @param CommentCharacter: Comment char, used to ignore comment content, # default is DataType.TAB_COMMENT_SPLIT # + + def CleanString2(Line, CommentCharacter=3DDataType.TAB_COMMENT_SPLIT, Allo= wCppStyleComment=3DFalse): # # remove whitespace @@ -337,7 +360,7 @@ def CleanString2(Line, CommentCharacter=3DDataType.TAB_= COMMENT_SPLIT, AllowCppStyl =20 return Line, Comment =20 -## GetMultipleValuesOfKeyFromLines +# GetMultipleValuesOfKeyFromLines # # Parse multiple strings to clean comment and spaces # The result is saved to KeyValues @@ -347,6 +370,8 @@ def CleanString2(Line, CommentCharacter=3DDataType.TAB_= COMMENT_SPLIT, AllowCppStyl # @param KeyValues: To store data after parsing # @param CommentCharacter: Comment char, used to ignore comment content # + + def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValues, CommentCharacte= r): if Key: pass @@ -360,7 +385,7 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValu= es, CommentCharacter): KeyValues +=3D [Line] return True =20 -## GetDefineValue +# GetDefineValue # # Parse a DEFINE statement to get defined value # DEFINE Key Value @@ -369,13 +394,15 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyVa= lues, CommentCharacter): # @param Key: The key of DEFINE statement # @param CommentCharacter: Comment char, used to ignore comment content # + + def GetDefineValue(String, Key, CommentCharacter): if CommentCharacter: pass String =3D CleanString(String) - return String[String.find(Key + ' ') + len(Key + ' ') : ] + return String[String.find(Key + ' ') + len(Key + ' '):] =20 -## GetSingleValueOfKeyFromLines +# GetSingleValueOfKeyFromLines # # Parse multiple strings as below to get value of each definition line # Key1 =3D Value1 @@ -393,7 +420,9 @@ def GetDefineValue(String, Key, CommentCharacter): # values. Key1 =3D Value1|Value2, '|' is the = value # split char # -def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeyS= plitCharacter, \ + + +def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeyS= plitCharacter, ValueSplitFlag, ValueSplitCharacter): Lines =3D Lines.split('\n') Keys =3D [] @@ -408,12 +437,14 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, C= ommentCharacter, KeySplitCh if Line.find(DataType.TAB_INF_DEFINES_DEFINE + ' ') > -1: if '' in DefineValues: DefineValues.remove('') - DefineValues.append(GetDefineValue(Line, DataType.TAB_INF_DEFI= NES_DEFINE, CommentCharacter)) + DefineValues.append(GetDefineValue( + Line, DataType.TAB_INF_DEFINES_DEFINE, CommentCharacter)) continue if Line.find(DataType.TAB_INF_DEFINES_SPEC + ' ') > -1: if '' in SpecValues: SpecValues.remove('') - SpecValues.append(GetDefineValue(Line, DataType.TAB_INF_DEFINE= S_SPEC, CommentCharacter)) + SpecValues.append(GetDefineValue( + Line, DataType.TAB_INF_DEFINES_SPEC, CommentCharacter)) continue =20 # @@ -428,9 +459,11 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Co= mmentCharacter, KeySplitCh # LineList[1] =3D CleanString(LineList[1], CommentCharacter) if ValueSplitFlag: - Value =3D list(map(lambda x: x.strip(), LineList[1].sp= lit(ValueSplitCharacter))) + Value =3D list( + map(lambda x: x.strip(), LineList[1].split(ValueSp= litCharacter))) else: - Value =3D CleanString(LineList[1], CommentCharacter).s= plitlines() + Value =3D CleanString( + LineList[1], CommentCharacter).splitlines() =20 if Key[0] in Dictionary: if Key[0] not in Keys: @@ -450,7 +483,7 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Com= mentCharacter, KeySplitCh =20 return True =20 -## The content to be parsed +# The content to be parsed # # Do pre-check for a file before it is parsed # Check $() @@ -460,6 +493,8 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, Com= mentCharacter, KeySplitCh # @param FileContent: File content to be parsed # @param SupSectionTag: Used for error report # + + def PreCheck(FileName, FileContent, SupSectionTag): if SupSectionTag: pass @@ -482,7 +517,8 @@ def PreCheck(FileName, FileContent, SupSectionTag): # if Line.find('$') > -1: if Line.find('$(') < 0 or Line.find(')') < 0: - Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, File= =3DFileName, RaiseError=3DLogger.IS_RAISE_ERROR) + Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DLogger.IS_RAISE= _ERROR) # # Check [] # @@ -491,18 +527,20 @@ def PreCheck(FileName, FileContent, SupSectionTag): # Only get one '[' or one ']' # if not (Line.find('[') > -1 and Line.find(']') > -1): - Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, File= =3DFileName, RaiseError=3DLogger.IS_RAISE_ERROR) + Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DLogger.IS_RAISE= _ERROR) # # Regenerate FileContent # NewFileContent =3D NewFileContent + Line + '\r\n' =20 if IsFailed: - Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, File=3DFileN= ame, RaiseError=3DLogger.IS_RAISE_ERROR) + Logger.Error("Parser", FORMAT_INVALID, Line=3DLineNo, + File=3DFileName, RaiseError=3DLogger.IS_RAISE_ERROR) =20 return NewFileContent =20 -## CheckFileType +# CheckFileType # # Check if the Filename is including ExtName # Return True if it exists @@ -516,20 +554,23 @@ def PreCheck(FileName, FileContent, SupSectionTag): # @param Line: The line in container file which defines the = file # to be checked # -def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, = Line, LineNo=3D -1): + + +def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, = Line, LineNo=3D-1): if CheckFilename !=3D '' and CheckFilename is not None: (Root, Ext) =3D os.path.splitext(CheckFilename) if Ext.upper() !=3D ExtName.upper() and Root: ContainerFile =3D open(ContainerFilename, 'r').read() if LineNo =3D=3D -1: LineNo =3D GetLineNo(ContainerFile, Line) - ErrorMsg =3D ST.ERR_SECTIONNAME_INVALID % (SectionName, CheckF= ilename, ExtName) - Logger.Error("Parser", PARSER_ERROR, ErrorMsg, Line=3DLineNo, \ + ErrorMsg =3D ST.ERR_SECTIONNAME_INVALID % ( + SectionName, CheckFilename, ExtName) + Logger.Error("Parser", PARSER_ERROR, ErrorMsg, Line=3DLineNo, File=3DContainerFilename, RaiseError=3DLogger.IS_= RAISE_ERROR) =20 return True =20 -## CheckFileExist +# CheckFileExist # # Check if the file exists # Return True if it exists @@ -543,7 +584,9 @@ def CheckFileType(CheckFilename, ExtName, ContainerFile= name, SectionName, Line, # @param Line: The line in container file which defines the # file to be checked # -def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, Section= Name, Line, LineNo=3D -1): + + +def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, Section= Name, Line, LineNo=3D-1): CheckFile =3D '' if CheckFilename !=3D '' and CheckFilename is not None: CheckFile =3D WorkspaceFile(WorkspaceDir, CheckFilename) @@ -553,16 +596,18 @@ def CheckFileExist(WorkspaceDir, CheckFilename, Conta= inerFilename, SectionName, LineNo =3D GetLineNo(ContainerFile, Line) ErrorMsg =3D ST.ERR_CHECKFILE_NOTFOUND % (CheckFile, SectionNa= me) Logger.Error("Parser", PARSER_ERROR, ErrorMsg, - File=3DContainerFilename, Line=3DLineNo, Raise= Error=3DLogger.IS_RAISE_ERROR) + File=3DContainerFilename, Line=3DLineNo, RaiseErr= or=3DLogger.IS_RAISE_ERROR) return CheckFile =20 -## GetLineNo +# GetLineNo # # Find the index of a line in a file # # @param FileContent: Search scope # @param Line: Search key # + + def GetLineNo(FileContent, Line, IsIgnoreComment=3DTrue): LineList =3D FileContent.splitlines() for Index in range(len(LineList)): @@ -577,7 +622,7 @@ def GetLineNo(FileContent, Line, IsIgnoreComment=3DTrue= ): =20 return -1 =20 -## RaiseParserError +# RaiseParserError # # Raise a parser error # @@ -586,31 +631,37 @@ def GetLineNo(FileContent, Line, IsIgnoreComment=3DTr= ue): # @param File: File which has the string # @param Format: Correct format # -def RaiseParserError(Line, Section, File, Format=3D'', LineNo=3D -1): + + +def RaiseParserError(Line, Section, File, Format=3D'', LineNo=3D-1): if LineNo =3D=3D -1: LineNo =3D GetLineNo(open(os.path.normpath(File), 'r').read(), Lin= e) ErrorMsg =3D ST.ERR_INVALID_NOTFOUND % (Line, Section) if Format !=3D '': Format =3D "Correct format is " + Format - Logger.Error("Parser", PARSER_ERROR, ErrorMsg, File=3DFile, Line=3DLin= eNo, \ + Logger.Error("Parser", PARSER_ERROR, ErrorMsg, File=3DFile, Line=3DLin= eNo, ExtraData=3DFormat, RaiseError=3DLogger.IS_RAISE_ERROR) =20 -## WorkspaceFile +# WorkspaceFile # # Return a full path with workspace dir # # @param WorkspaceDir: Workspace dir # @param Filename: Relative file name # + + def WorkspaceFile(WorkspaceDir, Filename): return os.path.join(NormPath(WorkspaceDir), NormPath(Filename)) =20 -## Split string +# Split string # # Remove '"' which startswith and endswith string # # @param String: The string need to be split # + + def SplitString(String): if String.startswith('\"'): String =3D String[1:] @@ -618,31 +669,37 @@ def SplitString(String): String =3D String[:-1] return String =20 -## Convert To Sql String +# Convert To Sql String # # Replace "'" with "''" in each item of StringList # # @param StringList: A list for strings to be converted # + + def ConvertToSqlString(StringList): return list(map(lambda s: s.replace("'", "''"), StringList)) =20 -## Convert To Sql String +# Convert To Sql String # # Replace "'" with "''" in the String # # @param String: A String to be converted # + + def ConvertToSqlString2(String): return String.replace("'", "''") =20 -## GetStringOfList +# GetStringOfList # # Get String of a List # # @param Lines: string list # @param Split: split character # + + def GetStringOfList(List, Split=3D' '): if not isinstance(List, type([])): return List @@ -651,27 +708,32 @@ def GetStringOfList(List, Split=3D' '): Str =3D Str + Item + Split return Str.strip() =20 -## Get HelpTextList +# Get HelpTextList # # Get HelpTextList from HelpTextClassList # # @param HelpTextClassList: Help Text Class List # + + def GetHelpTextList(HelpTextClassList): List =3D [] if HelpTextClassList: for HelpText in HelpTextClassList: if HelpText.String.endswith('\n'): - HelpText.String =3D HelpText.String[0: len(HelpText.String= ) - len('\n')] + HelpText.String =3D HelpText.String[0: len( + HelpText.String) - len('\n')] List.extend(HelpText.String.split('\n')) return List =20 -## Get String Array Length +# Get String Array Length # # Get String Array Length # # @param String: the source string # + + def StringArrayLength(String): if String.startswith('L"'): return (len(String) - 3 + 1) * 2 @@ -680,7 +742,7 @@ def StringArrayLength(String): else: return len(String.split()) + 1 =20 -## RemoveDupOption +# RemoveDupOption # # Remove Dup Option # @@ -688,6 +750,8 @@ def StringArrayLength(String): # @param Which: Which flag # @param Against: Against flag # + + def RemoveDupOption(OptionString, Which=3D"/I", Against=3DNone): OptionList =3D OptionString.split() ValueList =3D [] @@ -707,7 +771,7 @@ def RemoveDupOption(OptionString, Which=3D"/I", Against= =3DNone): ValueList.append(Val) return " ".join(OptionList) =20 -## Check if the string is HexDgit +# Check if the string is HexDgit # # Return true if all characters in the string are digits and there is at # least one character @@ -715,6 +779,8 @@ def RemoveDupOption(OptionString, Which=3D"/I", Against= =3DNone): # , false otherwise. # @param string: input string # + + def IsHexDigit(Str): try: int(Str, 10) @@ -728,7 +794,7 @@ def IsHexDigit(Str): return False return False =20 -## Check if the string is HexDgit and its integer value within limit of UI= NT32 +# Check if the string is HexDgit and its integer value within limit of UIN= T32 # # Return true if all characters in the string are digits and there is at # least one character @@ -736,6 +802,8 @@ def IsHexDigit(Str): # , false otherwise. # @param string: input string # + + def IsHexDigitUINT32(Str): try: Value =3D int(Str, 10) @@ -751,7 +819,7 @@ def IsHexDigitUINT32(Str): return False return False =20 -## CleanSpecialChar +# CleanSpecialChar # # The ASCII text files of type INF, DEC, INI are edited by developers, # and may contain characters that cannot be directly translated to strings= that @@ -759,20 +827,25 @@ def IsHexDigitUINT32(Str): # (0x00-0x08, TAB [0x09], 0x0B, 0x0C, 0x0E-0x1F, 0x80-0xFF) # must be converted to a space character[0x20] as part of the parsing proc= ess. # + + def ConvertSpecialChar(Lines): RetLines =3D [] for line in Lines: - ReMatchSpecialChar =3D re.compile(r"[\x00-\x08]|\x09|\x0b|\x0c|[\x= 0e-\x1f]|[\x7f-\xff]") + ReMatchSpecialChar =3D re.compile( + r"[\x00-\x08]|\x09|\x0b|\x0c|[\x0e-\x1f]|[\x7f-\xff]") RetLines.append(ReMatchSpecialChar.sub(' ', line)) =20 return RetLines =20 -## __GetTokenList +# __GetTokenList # # Assume Str is a valid feature flag expression. # Return a list which contains tokens: alpha numeric token and other token # Whitespace are not stripped # + + def __GetTokenList(Str): InQuote =3D False Token =3D '' @@ -819,13 +892,15 @@ def __GetTokenList(Str): List.append(TokenOP) return List =20 -## ConvertNEToNOTEQ +# ConvertNEToNOTEQ # # Convert NE operator to NOT EQ # For example: 1 NE 2 -> 1 NOT EQ 2 # # @param Expr: Feature flag expression to be converted # + + def ConvertNEToNOTEQ(Expr): List =3D __GetTokenList(Expr) for Index in range(len(List)): @@ -833,13 +908,15 @@ def ConvertNEToNOTEQ(Expr): List[Index] =3D 'NOT EQ' return ''.join(List) =20 -## ConvertNOTEQToNE +# ConvertNOTEQToNE # # Convert NOT EQ operator to NE # For example: 1 NOT NE 2 -> 1 NE 2 # # @param Expr: Feature flag expression to be converted # + + def ConvertNOTEQToNE(Expr): List =3D __GetTokenList(Expr) HasNOT =3D False @@ -860,7 +937,7 @@ def ConvertNOTEQToNE(Expr): =20 return ''.join(RetList) =20 -## SplitPcdEntry +# SplitPcdEntry # # Split an PCD entry string to Token.CName and PCD value and FFE. # NOTE: PCD Value and FFE can contain "|" in its expression. And in INF sp= ecification, have below rule. @@ -871,6 +948,8 @@ def ConvertNOTEQToNE(Expr): # # @return List [PcdTokenCName, Value, FFE] # + + def SplitPcdEntry(String): if not String: return ['', '', ''], False @@ -923,11 +1002,13 @@ def SplitPcdEntry(String): =20 return ['', '', ''], False =20 -## Check if two arches matched? +# Check if two arches matched? # # @param Arch1 # @param Arch2 # + + def IsMatchArch(Arch1, Arch2): if 'COMMON' in Arch1 or 'COMMON' in Arch2: return True @@ -953,6 +1034,8 @@ def IsMatchArch(Arch1, Arch2): # Search all files in FilePath to find the FileName with the largest index # Return the FileName with index +1 under the FilePath # + + def GetUniFileName(FilePath, FileName): Files =3D [] try: diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTo= ols/Source/Python/UPT/Library/UniClassObject.py index 8c44dc225277..c06799ed66d1 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # Collect all defined strings in multiple uni files. # # Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
        @@ -13,7 +13,9 @@ from __future__ import print_function ## # Import Modules # -import os, codecs, re +import os +import codecs +import re import shlex from Logger import ToolError from Logger import Log as EdkLogger @@ -42,40 +44,40 @@ NULL =3D u'\u0000' TAB =3D u'\t' BACK_SPLASH =3D u'\\' =20 -gLANG_CONV_TABLE =3D {'eng':'en', 'fra':'fr', \ - 'aar':'aa', 'abk':'ab', 'ave':'ae', 'afr':'af', 'aka':'ak= ', 'amh':'am', \ - 'arg':'an', 'ara':'ar', 'asm':'as', 'ava':'av', 'aym':'ay= ', 'aze':'az', \ - 'bak':'ba', 'bel':'be', 'bul':'bg', 'bih':'bh', 'bis':'bi= ', 'bam':'bm', \ - 'ben':'bn', 'bod':'bo', 'bre':'br', 'bos':'bs', 'cat':'ca= ', 'che':'ce', \ - 'cha':'ch', 'cos':'co', 'cre':'cr', 'ces':'cs', 'chu':'cu= ', 'chv':'cv', \ - 'cym':'cy', 'dan':'da', 'deu':'de', 'div':'dv', 'dzo':'dz= ', 'ewe':'ee', \ - 'ell':'el', 'epo':'eo', 'spa':'es', 'est':'et', 'eus':'eu= ', 'fas':'fa', \ - 'ful':'ff', 'fin':'fi', 'fij':'fj', 'fao':'fo', 'fry':'fy= ', 'gle':'ga', \ - 'gla':'gd', 'glg':'gl', 'grn':'gn', 'guj':'gu', 'glv':'gv= ', 'hau':'ha', \ - 'heb':'he', 'hin':'hi', 'hmo':'ho', 'hrv':'hr', 'hat':'ht= ', 'hun':'hu', \ - 'hye':'hy', 'her':'hz', 'ina':'ia', 'ind':'id', 'ile':'ie= ', 'ibo':'ig', \ - 'iii':'ii', 'ipk':'ik', 'ido':'io', 'isl':'is', 'ita':'it= ', 'iku':'iu', \ - 'jpn':'ja', 'jav':'jv', 'kat':'ka', 'kon':'kg', 'kik':'ki= ', 'kua':'kj', \ - 'kaz':'kk', 'kal':'kl', 'khm':'km', 'kan':'kn', 'kor':'ko= ', 'kau':'kr', \ - 'kas':'ks', 'kur':'ku', 'kom':'kv', 'cor':'kw', 'kir':'ky= ', 'lat':'la', \ - 'ltz':'lb', 'lug':'lg', 'lim':'li', 'lin':'ln', 'lao':'lo= ', 'lit':'lt', \ - 'lub':'lu', 'lav':'lv', 'mlg':'mg', 'mah':'mh', 'mri':'mi= ', 'mkd':'mk', \ - 'mal':'ml', 'mon':'mn', 'mar':'mr', 'msa':'ms', 'mlt':'mt= ', 'mya':'my', \ - 'nau':'na', 'nob':'nb', 'nde':'nd', 'nep':'ne', 'ndo':'ng= ', 'nld':'nl', \ - 'nno':'nn', 'nor':'no', 'nbl':'nr', 'nav':'nv', 'nya':'ny= ', 'oci':'oc', \ - 'oji':'oj', 'orm':'om', 'ori':'or', 'oss':'os', 'pan':'pa= ', 'pli':'pi', \ - 'pol':'pl', 'pus':'ps', 'por':'pt', 'que':'qu', 'roh':'rm= ', 'run':'rn', \ - 'ron':'ro', 'rus':'ru', 'kin':'rw', 'san':'sa', 'srd':'sc= ', 'snd':'sd', \ - 'sme':'se', 'sag':'sg', 'sin':'si', 'slk':'sk', 'slv':'sl= ', 'smo':'sm', \ - 'sna':'sn', 'som':'so', 'sqi':'sq', 'srp':'sr', 'ssw':'ss= ', 'sot':'st', \ - 'sun':'su', 'swe':'sv', 'swa':'sw', 'tam':'ta', 'tel':'te= ', 'tgk':'tg', \ - 'tha':'th', 'tir':'ti', 'tuk':'tk', 'tgl':'tl', 'tsn':'tn= ', 'ton':'to', \ - 'tur':'tr', 'tso':'ts', 'tat':'tt', 'twi':'tw', 'tah':'ty= ', 'uig':'ug', \ - 'ukr':'uk', 'urd':'ur', 'uzb':'uz', 'ven':'ve', 'vie':'vi= ', 'vol':'vo', \ - 'wln':'wa', 'wol':'wo', 'xho':'xh', 'yid':'yi', 'yor':'yo= ', 'zha':'za', \ - 'zho':'zh', 'zul':'zu'} +gLANG_CONV_TABLE =3D {'eng': 'en', 'fra': 'fr', + 'aar': 'aa', 'abk': 'ab', 'ave': 'ae', 'afr': 'af', 'a= ka': 'ak', 'amh': 'am', + 'arg': 'an', 'ara': 'ar', 'asm': 'as', 'ava': 'av', 'a= ym': 'ay', 'aze': 'az', + 'bak': 'ba', 'bel': 'be', 'bul': 'bg', 'bih': 'bh', 'b= is': 'bi', 'bam': 'bm', + 'ben': 'bn', 'bod': 'bo', 'bre': 'br', 'bos': 'bs', 'c= at': 'ca', 'che': 'ce', + 'cha': 'ch', 'cos': 'co', 'cre': 'cr', 'ces': 'cs', 'c= hu': 'cu', 'chv': 'cv', + 'cym': 'cy', 'dan': 'da', 'deu': 'de', 'div': 'dv', 'd= zo': 'dz', 'ewe': 'ee', + 'ell': 'el', 'epo': 'eo', 'spa': 'es', 'est': 'et', 'e= us': 'eu', 'fas': 'fa', + 'ful': 'ff', 'fin': 'fi', 'fij': 'fj', 'fao': 'fo', 'f= ry': 'fy', 'gle': 'ga', + 'gla': 'gd', 'glg': 'gl', 'grn': 'gn', 'guj': 'gu', 'g= lv': 'gv', 'hau': 'ha', + 'heb': 'he', 'hin': 'hi', 'hmo': 'ho', 'hrv': 'hr', 'h= at': 'ht', 'hun': 'hu', + 'hye': 'hy', 'her': 'hz', 'ina': 'ia', 'ind': 'id', 'i= le': 'ie', 'ibo': 'ig', + 'iii': 'ii', 'ipk': 'ik', 'ido': 'io', 'isl': 'is', 'i= ta': 'it', 'iku': 'iu', + 'jpn': 'ja', 'jav': 'jv', 'kat': 'ka', 'kon': 'kg', 'k= ik': 'ki', 'kua': 'kj', + 'kaz': 'kk', 'kal': 'kl', 'khm': 'km', 'kan': 'kn', 'k= or': 'ko', 'kau': 'kr', + 'kas': 'ks', 'kur': 'ku', 'kom': 'kv', 'cor': 'kw', 'k= ir': 'ky', 'lat': 'la', + 'ltz': 'lb', 'lug': 'lg', 'lim': 'li', 'lin': 'ln', 'l= ao': 'lo', 'lit': 'lt', + 'lub': 'lu', 'lav': 'lv', 'mlg': 'mg', 'mah': 'mh', 'm= ri': 'mi', 'mkd': 'mk', + 'mal': 'ml', 'mon': 'mn', 'mar': 'mr', 'msa': 'ms', 'm= lt': 'mt', 'mya': 'my', + 'nau': 'na', 'nob': 'nb', 'nde': 'nd', 'nep': 'ne', 'n= do': 'ng', 'nld': 'nl', + 'nno': 'nn', 'nor': 'no', 'nbl': 'nr', 'nav': 'nv', 'n= ya': 'ny', 'oci': 'oc', + 'oji': 'oj', 'orm': 'om', 'ori': 'or', 'oss': 'os', 'p= an': 'pa', 'pli': 'pi', + 'pol': 'pl', 'pus': 'ps', 'por': 'pt', 'que': 'qu', 'r= oh': 'rm', 'run': 'rn', + 'ron': 'ro', 'rus': 'ru', 'kin': 'rw', 'san': 'sa', 's= rd': 'sc', 'snd': 'sd', + 'sme': 'se', 'sag': 'sg', 'sin': 'si', 'slk': 'sk', 's= lv': 'sl', 'smo': 'sm', + 'sna': 'sn', 'som': 'so', 'sqi': 'sq', 'srp': 'sr', 's= sw': 'ss', 'sot': 'st', + 'sun': 'su', 'swe': 'sv', 'swa': 'sw', 'tam': 'ta', 't= el': 'te', 'tgk': 'tg', + 'tha': 'th', 'tir': 'ti', 'tuk': 'tk', 'tgl': 'tl', 't= sn': 'tn', 'ton': 'to', + 'tur': 'tr', 'tso': 'ts', 'tat': 'tt', 'twi': 'tw', 't= ah': 'ty', 'uig': 'ug', + 'ukr': 'uk', 'urd': 'ur', 'uzb': 'uz', 'ven': 've', 'v= ie': 'vi', 'vol': 'vo', + 'wln': 'wa', 'wol': 'wo', 'xho': 'xh', 'yid': 'yi', 'y= or': 'yo', 'zha': 'za', + 'zho': 'zh', 'zul': 'zu'} =20 -## Convert a python unicode string to a normal string +# Convert a python unicode string to a normal string # # Convert a python unicode string to a normal string # UniToStr(u'I am a string') is 'I am a string' @@ -84,10 +86,12 @@ gLANG_CONV_TABLE =3D {'eng':'en', 'fra':'fr', \ # # @retval: The formatted normal string # + + def UniToStr(Uni): return repr(Uni)[2:-1] =20 -## Convert a unicode string to a Hex list +# Convert a unicode string to a Hex list # # Convert a unicode string to a Hex list # UniToHexList('ABC') is ['0x41', '0x00', '0x42', '0x00', '0x43', '0x00'] @@ -96,6 +100,8 @@ def UniToStr(Uni): # # @retval List: The formatted hex list # + + def UniToHexList(Uni): List =3D [] for Item in Uni: @@ -104,7 +110,7 @@ def UniToHexList(Uni): List.append('0x' + Temp[0:2]) return List =20 -## Convert special unicode characters +# Convert special unicode characters # # Convert special characters to (c), (r) and (tm). # @@ -112,6 +118,8 @@ def UniToHexList(Uni): # # @retval NewUni: The converted unicode string # + + def ConvertSpecialUnicodes(Uni): OldUni =3D NewUni =3D Uni NewUni =3D NewUni.replace(u'\u00A9', '(c)') @@ -121,7 +129,7 @@ def ConvertSpecialUnicodes(Uni): NewUni =3D OldUni return NewUni =20 -## GetLanguageCode1766 +# GetLanguageCode1766 # # Check the language code read from .UNI file and convert RFC 4646 codes t= o RFC 1766 codes # RFC 1766 language codes supported in compatibility mode @@ -131,6 +139,8 @@ def ConvertSpecialUnicodes(Uni): # # @retval LangName: Valid language code in RFC 1766 format or None # + + def GetLanguageCode1766(LangName, File=3DNone): return LangName =20 @@ -145,9 +155,9 @@ def GetLanguageCode1766(LangName, File=3DNone): return LangName else: EdkLogger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - "Invalid RFC 1766 language code : %s" % LangN= ame, - File) + ToolError.FORMAT_INVALID, + "Invalid RFC 1766 language code : %s" % LangNa= me, + File) elif length =3D=3D 5: if LangName[0:2].isalpha() and LangName[2] =3D=3D '-': for Key in gLANG_CONV_TABLE.keys(): @@ -164,11 +174,11 @@ def GetLanguageCode1766(LangName, File=3DNone): return Key =20 EdkLogger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - "Invalid RFC 4646 language code : %s" % LangN= ame, - File) + ToolError.FORMAT_INVALID, + "Invalid RFC 4646 language code : %s" % LangName, + File) =20 -## GetLanguageCode +# GetLanguageCode # # Check the language code read from .UNI file and convert RFC 1766 codes t= o RFC 4646 codes if appropriate # RFC 1766 language codes supported in compatibility mode @@ -178,6 +188,8 @@ def GetLanguageCode1766(LangName, File=3DNone): # # @retval LangName: Valid lanugage code in RFC 4646 format or None # + + def GetLanguageCode(LangName, IsCompatibleMode, File): length =3D len(LangName) if IsCompatibleMode: @@ -188,9 +200,9 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): return LangName else: EdkLogger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - "Invalid RFC 1766 language code : %s" % LangN= ame, - File) + ToolError.FORMAT_INVALID, + "Invalid RFC 1766 language code : %s" % LangNa= me, + File) if (LangName[0] =3D=3D 'X' or LangName[0] =3D=3D 'x') and LangName[1] = =3D=3D '-': return LangName if length =3D=3D 2: @@ -209,11 +221,11 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): return LangName =20 EdkLogger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - "Invalid RFC 4646 language code : %s" % LangN= ame, - File) + ToolError.FORMAT_INVALID, + "Invalid RFC 4646 language code : %s" % LangName, + File) =20 -## FormatUniEntry +# FormatUniEntry # # Formatted the entry in Uni file. # @@ -222,6 +234,8 @@ def GetLanguageCode(LangName, IsCompatibleMode, File): # @param ContainerFile ContainerFile. # # @return formatted entry + + def FormatUniEntry(StrTokenName, TokenValueList, ContainerFile): SubContent =3D '' PreFormatLength =3D 40 @@ -243,21 +257,24 @@ def FormatUniEntry(StrTokenName, TokenValueList, Cont= ainerFile): for SubValue in ValueList: if SubValue.strip(): SubValueContent +=3D \ - ' ' * (PreFormatLength + len('#language en-US ')) + '\"%s\= \n\"' % SubValue.strip() + '\r\n' + ' ' * (PreFormatLength + len('#language en-US ')) + \ + '\"%s\\n\"' % SubValue.strip() + '\r\n' SubValueContent =3D SubValueContent[(PreFormatLength + len('#langu= age en-US ')):SubValueContent.rfind('\\n')] \ - + '\"' + '\r\n' + + '\"' + '\r\n' SubContent +=3D ' '*PreFormatLength + '#language %-5s ' % Lang + S= ubValueContent if SubContent: - SubContent =3D StrTokenName + ' '*(PreFormatLength - len(StrTokenN= ame)) + SubContent[PreFormatLength:] + SubContent =3D StrTokenName + ' ' * \ + (PreFormatLength - len(StrTokenName)) + \ + SubContent[PreFormatLength:] return SubContent =20 =20 -## StringDefClassObject +# StringDefClassObject # # A structure for language definition # class StringDefClassObject(object): - def __init__(self, Name =3D None, Value =3D None, Referenced =3D False= , Token =3D None, UseOtherLangDef =3D ''): + def __init__(self, Name=3DNone, Value=3DNone, Referenced=3DFalse, Toke= n=3DNone, UseOtherLangDef=3D''): self.StringName =3D '' self.StringNameByteList =3D [] self.StringValue =3D '' @@ -279,12 +296,12 @@ class StringDefClassObject(object): =20 def __str__(self): return repr(self.StringName) + ' ' + \ - repr(self.Token) + ' ' + \ - repr(self.Referenced) + ' ' + \ - repr(self.StringValue) + ' ' + \ - repr(self.UseOtherLangDef) + repr(self.Token) + ' ' + \ + repr(self.Referenced) + ' ' + \ + repr(self.StringValue) + ' ' + \ + repr(self.UseOtherLangDef) =20 - def UpdateValue(self, Value =3D None): + def UpdateValue(self, Value=3DNone): if Value is not None: if self.StringValue: self.StringValue =3D self.StringValue + '\r\n' + Value @@ -293,21 +310,26 @@ class StringDefClassObject(object): self.StringValueByteList =3D UniToHexList(self.StringValue) self.Length =3D len(self.StringValueByteList) =20 -## UniFileClassObject +# UniFileClassObject # # A structure for .uni file definition # + + class UniFileClassObject(object): - def __init__(self, FileList =3D None, IsCompatibleMode =3D False, Incl= udePathList =3D None): + def __init__(self, FileList=3DNone, IsCompatibleMode=3DFalse, IncludeP= athList=3DNone): self.FileList =3D FileList self.File =3D None self.IncFileList =3D FileList self.UniFileHeader =3D '' self.Token =3D 2 - self.LanguageDef =3D [] #[ [u'LanguageIdentifier= ', u'PrintableName'], ... ] - self.OrderedStringList =3D {} #{ u'LanguageIdentifier'= : [StringDefClassObject] } - self.OrderedStringDict =3D {} #{ u'LanguageIdentifier'= : {StringName:(IndexInList)} } - self.OrderedStringListByToken =3D {} #{ u'LanguageIdentifier'= : {Token: StringDefClassObject} } + self.LanguageDef =3D [] # [ [u'LanguageIdentifier', u'PrintableNa= me'], ... ] + # { u'LanguageIdentifier' : [StringDefClassObject] } + self.OrderedStringList =3D {} + # { u'LanguageIdentifier' : {StringName:(IndexInList)} } + self.OrderedStringDict =3D {} + # { u'LanguageIdentifier' : {Token: StringDefClassObject} } + self.OrderedStringListByToken =3D {} self.IsCompatibleMode =3D IsCompatibleMode if not IncludePathList: self.IncludePathList =3D [] @@ -323,11 +345,14 @@ class UniFileClassObject(object): Lang =3D shlex.split(Line.split(u"//")[0]) if len(Lang) !=3D 3: try: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_8').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_8').readlines() except UnicodeError as Xstr: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_16').readlines() except UnicodeError as Xstr: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16_le').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_16_le').readlines() except: EdkLogger.Error("Unicode File Parser", ToolError.FILE_OPEN_FAILURE, @@ -335,12 +360,13 @@ class UniFileClassObject(object): ExtraData=3DFile) LineNo =3D GetLineNo(FileIn, Line, False) EdkLogger.Error("Unicode File Parser", - ToolError.PARSER_ERROR, - "Wrong language definition", - ExtraData=3D"""%s\n\t*Correct format is like = '#langdef en-US "English"'""" % Line, - File =3D File, Line =3D LineNo) + ToolError.PARSER_ERROR, + "Wrong language definition", + ExtraData=3D"""%s\n\t*Correct format is like '= #langdef en-US "English"'""" % Line, + File=3DFile, Line=3DLineNo) else: - LangName =3D GetLanguageCode(Lang[1], self.IsCompatibleMode, s= elf.File) + LangName =3D GetLanguageCode( + Lang[1], self.IsCompatibleMode, self.File) LangPrintName =3D Lang[2] =20 IsLangInDef =3D False @@ -355,8 +381,10 @@ class UniFileClassObject(object): # # Add language string # - self.AddStringToList(u'$LANGUAGE_NAME', LangName, LangName, 0, Tru= e, Index=3D0) - self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', LangName, LangPr= intName, 1, True, Index=3D1) + self.AddStringToList(u'$LANGUAGE_NAME', LangName, + LangName, 0, True, Index=3D0) + self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', + LangName, LangPrintName, 1, True, Index=3D1) =20 if not IsLangInDef: # @@ -365,18 +393,19 @@ class UniFileClassObject(object): # FirstLangName =3D self.LanguageDef[0][0] if LangName !=3D FirstLangName: - for Index in range (2, len (self.OrderedStringList[FirstLa= ngName])): + for Index in range(2, len(self.OrderedStringList[FirstLang= Name])): Item =3D self.OrderedStringList[FirstLangName][Index] if Item.UseOtherLangDef !=3D '': OtherLang =3D Item.UseOtherLangDef else: OtherLang =3D FirstLangName - self.OrderedStringList[LangName].append (StringDefClas= sObject(Item.StringName, - = '', - = Item.Referenced, - = Item.Token, - = OtherLang)) - self.OrderedStringDict[LangName][Item.StringName] =3D = len(self.OrderedStringList[LangName]) - 1 + self.OrderedStringList[LangName].append(StringDefClass= Object(Item.StringName, + = '', + = Item.Referenced, + = Item.Token, + = OtherLang)) + self.OrderedStringDict[LangName][Item.StringName] =3D = len( + self.OrderedStringList[LangName]) - 1 return True =20 # @@ -392,27 +421,30 @@ class UniFileClassObject(object): MatchString =3D re.match('[A-Z0-9_]+', Name, re.UNICODE) if MatchString is None or MatchString.end(0) !=3D len(Name): EdkLogger.Error("Unicode File Parser", - ToolError.FORMAT_INVALID, - 'The string token name %s in UNI file %s must= be upper case character.' %(Name, self.File)) + ToolError.FORMAT_INVALID, + 'The string token name %s in UNI file %s m= ust be upper case character.' % (Name, self.File)) LanguageList =3D Item.split(u'#language ') for IndexI in range(len(LanguageList)): if IndexI =3D=3D 0: continue else: Language =3D LanguageList[IndexI].split()[0] - #.replace(u'\r\n', u'') + # .replace(u'\r\n', u'') Value =3D \ - LanguageList[IndexI][LanguageList[IndexI].find(u'\"') + le= n(u'\"') : LanguageList[IndexI].rfind(u'\"')] - Language =3D GetLanguageCode(Language, self.IsCompatibleMo= de, self.File) + LanguageList[IndexI][LanguageList[IndexI].find( + u'\"') + len(u'\"'): LanguageList[IndexI].rfind(u'= \"')] + Language =3D GetLanguageCode( + Language, self.IsCompatibleMode, self.File) self.AddStringToList(Name, Language, Value) =20 # # Get include file list and load them # - def GetIncludeFile(self, Item, Dir =3D None): + def GetIncludeFile(self, Item, Dir=3DNone): if Dir: pass - FileName =3D Item[Item.find(u'!include ') + len(u'!include ') :Ite= m.find(u' ', len(u'!include '))][1:-1] + FileName =3D Item[Item.find( + u'!include ') + len(u'!include '):Item.find(u' ', len(u'!inclu= de '))][1:-1] self.LoadUniFile(FileName) =20 # @@ -421,8 +453,8 @@ class UniFileClassObject(object): def PreProcess(self, File, IsIncludeFile=3DFalse): if not os.path.exists(File.Path) or not os.path.isfile(File.Path): EdkLogger.Error("Unicode File Parser", - ToolError.FILE_NOT_FOUND, - ExtraData=3DFile.Path) + ToolError.FILE_NOT_FOUND, + ExtraData=3DFile.Path) =20 # # Check file header of the Uni file @@ -432,14 +464,17 @@ class UniFileClassObject(object): # ExtraData=3D'The file %s is either invalid U= TF-16LE or it is missing the BOM.' % File.Path) =20 try: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _8').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_8').readlines() except UnicodeError as Xstr: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _16').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_16').readlines() except UnicodeError: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _16_le').readlines() + FileIn =3D codecs.open(File.Path, mode=3D'rb', + encoding=3D'utf_16_le').readlines() except: - EdkLogger.Error("Unicode File Parser", ToolError.FILE_OPEN_FAI= LURE, ExtraData=3DFile.Path) - + EdkLogger.Error("Unicode File Parser", + ToolError.FILE_OPEN_FAILURE, ExtraData=3DFile.= Path) =20 # # get the file header @@ -456,7 +491,7 @@ class UniFileClassObject(object): if Line =3D=3D u'': continue if Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and (Line.find(D= T.TAB_HEADER_COMMENT) > -1) \ - and not HeaderEnd and not HeaderStart: + and not HeaderEnd and not HeaderStart: HeaderStart =3D True if not Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderSt= art and not HeaderEnd: HeaderEnd =3D True @@ -494,7 +529,8 @@ class UniFileClassObject(object): # there should be only one line feed character between them # if MultiLineFeedExits: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) continue =20 MultiLineFeedExits =3D False @@ -509,8 +545,8 @@ class UniFileClassObject(object): FileIn[LineCount-1] =3D Line FileIn[LineCount] =3D '\r\n' LineCount -=3D 1 - for Index in range (LineCount + 1, len (FileIn) - 1): - if (Index =3D=3D len(FileIn) -1): + for Index in range(LineCount + 1, len(FileIn) - 1): + if (Index =3D=3D len(FileIn) - 1): FileIn[Index] =3D '\r\n' else: FileIn[Index] =3D FileIn[Index + 1] @@ -521,9 +557,11 @@ class UniFileClassObject(object): if Line[CommIndex+1] =3D=3D u'/': Line =3D Line[:CommIndex].strip() else: - EdkLogger.Error("Unicode File Parser", ToolError.F= ORMAT_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error( + "Unicode File Parser", ToolError.FORMAT_INVALI= D, ExtraData=3DFile.Path) else: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) =20 Line =3D Line.replace(UNICODE_WIDE_CHAR, WIDE_CHAR) Line =3D Line.replace(UNICODE_NARROW_CHAR, NARROW_CHAR) @@ -545,7 +583,7 @@ class UniFileClassObject(object): if not Line.endswith('"'): EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3D'''The line %s misses '"' = at the end of it in file %s''' - % (LineCount, File.Path)) + % (LineCount, File.Path)) =20 # # Between Name entry and Language entry can not contain line f= eed @@ -624,31 +662,34 @@ class UniFileClassObject(object): # =20 if not IsIncludeFile and not Lines: - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, \ - Message=3DST.ERR_UNIPARSE_NO_SECTION_EXIST, \ - ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, + Message=3DST.ERR_UNIPARSE_NO_SECTION_EXIST, + ExtraData=3DFile.Path) =20 NewLines =3D [] StrName =3D u'' ExistStrNameList =3D [] for Line in Lines: if StrName and not StrName.split()[1].startswith(DT.TAB_STR_TO= KENCNAME + DT.TAB_UNDERLINE_SPLIT): - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, \ - Message=3DST.ERR_UNIPARSE_STRNAME_FORMAT_E= RROR % StrName.split()[1], \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, + Message=3DST.ERR_UNIPARSE_STRNAME_FORMAT_E= RROR % StrName.split()[ + 1], ExtraData=3DFile.Path) =20 if StrName and len(StrName.split()[1].split(DT.TAB_UNDERLINE_S= PLIT)) =3D=3D 4: - StringTokenList =3D StrName.split()[1].split(DT.TAB_UNDERL= INE_SPLIT) - if (StringTokenList[3].upper() in [DT.TAB_STR_TOKENPROMPT,= DT.TAB_STR_TOKENHELP] and \ - StringTokenList[3] not in [DT.TAB_STR_TOKENPROMPT, DT.= TAB_STR_TOKENHELP]) or \ - (StringTokenList[2].upper() =3D=3D DT.TAB_STR_TOKENERR= and StringTokenList[2] !=3D DT.TAB_STR_TOKENERR): - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, \ - Message=3DST.ERR_UNIPARSE_STRTOKEN_FORMAT_= ERROR % StrName.split()[1], \ - ExtraData=3DFile.Path) + StringTokenList =3D StrName.split()[1].split( + DT.TAB_UNDERLINE_SPLIT) + if (StringTokenList[3].upper() in [DT.TAB_STR_TOKENPROMPT,= DT.TAB_STR_TOKENHELP] and + StringTokenList[3] not in [DT.TAB_STR_TOKENPROMPT,= DT.TAB_STR_TOKENHELP]) or \ + (StringTokenList[2].upper() =3D=3D DT.TAB_STR_TOKE= NERR and StringTokenList[2] !=3D DT.TAB_STR_TOKENERR): + EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, + Message=3DST.ERR_UNIPARSE_STRTOKEN_FOR= MAT_ERROR % StrName.split()[ + 1], + ExtraData=3DFile.Path) =20 if Line.count(u'#language') > 1: - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, \ - Message=3DST.ERR_UNIPARSE_SEP_LANGENTRY_LI= NE % Line, \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, + Message=3DST.ERR_UNIPARSE_SEP_LANGENTRY_LI= NE % Line, ExtraData=3DFile.Path) =20 if Line.startswith(u'//'): @@ -661,74 +702,88 @@ class UniFileClassObject(object): NewLines.append(Line[:Line.find(u'"')].strip()) NewLines.append(Line[Line.find(u'"'):]) else: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) elif Line.startswith(u'#string'): if len(Line.split()) =3D=3D 2: StrName =3D Line if StrName: if StrName.split()[1] not in ExistStrNameList: ExistStrNameList.append(StrName.split()[1].str= ip()) - elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, \ - DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, \ - DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, \ + elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, + DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, + DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, DT.TAB_DEC_BINARY_ABST= RACT, DT.TAB_DEC_BINARY_DESCRIPTION]: - EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, \ - Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[1], \ + EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, + Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[ + 1], ExtraData=3DFile.Path) continue elif len(Line.split()) =3D=3D 4 and Line.find(u'#language'= ) > 0: if Line[Line.find(u'#language')-1] !=3D ' ' or \ Line[Line.find(u'#language')+len(u'#language')] != =3D u' ': - EdkLogger.Error("Unicode File Parser", ToolError.F= ORMAT_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error( + "Unicode File Parser", ToolError.FORMAT_INVALI= D, ExtraData=3DFile.Path) =20 if Line.find(u'"') > 0: - EdkLogger.Error("Unicode File Parser", ToolError.F= ORMAT_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error( + "Unicode File Parser", ToolError.FORMAT_INVALI= D, ExtraData=3DFile.Path) =20 StrName =3D Line.split()[0] + u' ' + Line.split()[1] if StrName: if StrName.split()[1] not in ExistStrNameList: ExistStrNameList.append(StrName.split()[1].str= ip()) - elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, \ - DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, \ - DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, \ + elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, + DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, + DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, DT.TAB_DEC_BINARY_ABST= RACT, DT.TAB_DEC_BINARY_DESCRIPTION]: - EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, \ - Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[1], \ + EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, + Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[ + 1], ExtraData=3DFile.Path) if IsIncludeFile: if StrName not in NewLines: - NewLines.append((Line[:Line.find(u'#language')= ]).strip()) + NewLines.append( + (Line[:Line.find(u'#language')]).strip()) else: - NewLines.append((Line[:Line.find(u'#language')]).s= trip()) + NewLines.append( + (Line[:Line.find(u'#language')]).strip()) NewLines.append((Line[Line.find(u'#language'):]).strip= ()) elif len(Line.split()) > 4 and Line.find(u'#language') > 0= and Line.find(u'"') > 0: if Line[Line.find(u'#language')-1] !=3D u' ' or \ Line[Line.find(u'#language')+len(u'#language')] != =3D u' ': - EdkLogger.Error("Unicode File Parser", ToolError.F= ORMAT_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error( + "Unicode File Parser", ToolError.FORMAT_INVALI= D, ExtraData=3DFile.Path) =20 if Line[Line.find(u'"')-1] !=3D u' ': - EdkLogger.Error("Unicode File Parser", ToolError.F= ORMAT_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error( + "Unicode File Parser", ToolError.FORMAT_INVALI= D, ExtraData=3DFile.Path) =20 StrName =3D Line.split()[0] + u' ' + Line.split()[1] if StrName: if StrName.split()[1] not in ExistStrNameList: ExistStrNameList.append(StrName.split()[1].str= ip()) - elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, \ - DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, \ - DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, \ + elif StrName.split()[1] in [DT.TAB_INF_ABSTRACT, D= T.TAB_INF_DESCRIPTION, + DT.TAB_INF_BINARY_ABST= RACT, DT.TAB_INF_BINARY_DESCRIPTION, + DT.TAB_DEC_PACKAGE_ABS= TRACT, DT.TAB_DEC_PACKAGE_DESCRIPTION, DT.TAB_DEC_BINARY_ABST= RACT, DT.TAB_DEC_BINARY_DESCRIPTION]: - EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, \ - Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[1], \ + EdkLogger.Error("Unicode File Parser", ToolErr= or.FORMAT_INVALID, + Message=3DST.ERR_UNIPARSE_MULT= I_ENTRY_EXIST % StrName.split()[ + 1], ExtraData=3DFile.Path) if IsIncludeFile: if StrName not in NewLines: - NewLines.append((Line[:Line.find(u'#language')= ]).strip()) + NewLines.append( + (Line[:Line.find(u'#language')]).strip()) else: - NewLines.append((Line[:Line.find(u'#language')]).s= trip()) - NewLines.append((Line[Line.find(u'#language'):Line.fin= d(u'"')]).strip()) + NewLines.append( + (Line[:Line.find(u'#language')]).strip()) + NewLines.append( + (Line[Line.find(u'#language'):Line.find(u'"')]).st= rip()) NewLines.append((Line[Line.find(u'"'):]).strip()) else: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) elif Line.startswith(u'#language'): if len(Line.split()) =3D=3D 2: if IsIncludeFile: @@ -746,23 +801,27 @@ class UniFileClassObject(object): NewLines.append((Line[:Line.find(u'"')]).strip()) NewLines.append((Line[Line.find(u'"'):]).strip()) else: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) elif Line.startswith(u'"'): - if u'#string' in Line or u'#language' in Line: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, ExtraData=3DFile.Path) + if u'#string' in Line or u'#language' in Line: + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3D= File.Path) NewLines.append(Line) else: print(Line) - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", + ToolError.FORMAT_INVALID, ExtraData=3DFile= .Path) =20 if StrName and not StrName.split()[1].startswith(u'STR_'): - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, \ - Message=3DST.ERR_UNIPARSE_STRNAME_FORMAT_E= RROR % StrName.split()[1], \ - ExtraData=3DFile.Path) + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, + Message=3DST.ERR_UNIPARSE_STRNAME_FORMAT_ERROR= % StrName.split()[ + 1], + ExtraData=3DFile.Path) =20 if StrName and not NewLines: - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, \ - Message=3DST.ERR_UNI_MISS_LANGENTRY % StrName,= \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, + Message=3DST.ERR_UNI_MISS_LANGENTRY % StrName, ExtraData=3DFile.Path) =20 # @@ -785,33 +844,34 @@ class UniFileClassObject(object): DescriptionPosition =3D ExistStrNameList.index(StrName) =20 OrderList =3D sorted([AbstractPosition, DescriptionPosition]) - BinaryOrderList =3D sorted([BinaryAbstractPosition, BinaryDescript= ionPosition]) + BinaryOrderList =3D sorted( + [BinaryAbstractPosition, BinaryDescriptionPosition]) Min =3D OrderList[0] Max =3D OrderList[1] BinaryMin =3D BinaryOrderList[0] BinaryMax =3D BinaryOrderList[1] if BinaryDescriptionPosition > -1: - if not(BinaryDescriptionPosition =3D=3D BinaryMax and BinaryAb= stractPosition =3D=3D BinaryMin and \ + if not(BinaryDescriptionPosition =3D=3D BinaryMax and BinaryAb= stractPosition =3D=3D BinaryMin and BinaryMax > Max): - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, \ - Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, + Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, ExtraData=3DFile.Path) elif BinaryAbstractPosition > -1: if not(BinaryAbstractPosition > Max): - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, \ - Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, + Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, ExtraData=3DFile.Path) =20 - if DescriptionPosition > -1: - if not(DescriptionPosition =3D=3D Max and AbstractPosition =3D= =3D Min and \ + if DescriptionPosition > -1: + if not(DescriptionPosition =3D=3D Max and AbstractPosition =3D= =3D Min and DescriptionPosition > AbstractPosition): - EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, \ - Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, \ + EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_IN= VALID, + Message=3DST.ERR_UNIPARSE_ENTRY_ORDER_WRON= G, ExtraData=3DFile.Path) =20 if not self.UniFileHeader: EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALI= D, - Message =3D ST.ERR_NO_SOURCE_HEADER, + Message=3DST.ERR_NO_SOURCE_HEADER, ExtraData=3DFile.Path) =20 return NewLines @@ -819,7 +879,7 @@ class UniFileClassObject(object): # # Load a .uni file # - def LoadUniFile(self, File =3D None): + def LoadUniFile(self, File=3DNone): if File is None: EdkLogger.Error("Unicode File Parser", ToolError.PARSER_ERROR, @@ -867,34 +927,39 @@ class UniFileClassObject(object): # "Mi segunda secuencia 2" # if Line.find(u'#string ') >=3D 0 and Line.find(u'#language ') = < 0 and \ - SecondLine.find(u'#string ') < 0 and SecondLine.find(u'#la= nguage ') >=3D 0 and \ - ThirdLine.find(u'#string ') < 0 and ThirdLine.find(u'#lang= uage ') < 0: + SecondLine.find(u'#string ') < 0 and SecondLine.find(u= '#language ') >=3D 0 and \ + ThirdLine.find(u'#string ') < 0 and ThirdLine.find(u'#= language ') < 0: if Line.find('"') > 0 or SecondLine.find('"') > 0: EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, - Message=3DST.ERR_UNIPARSE_DBLQUOTE_UNMATCH= ED, - ExtraData=3DFile.Path) + Message=3DST.ERR_UNIPARSE_DBLQUOTE_UNM= ATCHED, + ExtraData=3DFile.Path) =20 - Name =3D Line[Line.find(u'#string ') + len(u'#string ') : = ].strip(' ') - Language =3D SecondLine[SecondLine.find(u'#language ') + l= en(u'#language ') : ].strip(' ') + Name =3D Line[Line.find(u'#string ') + + len(u'#string '):].strip(' ') + Language =3D SecondLine[SecondLine.find( + u'#language ') + len(u'#language '):].strip(' ') for IndexJ in range(IndexI + 2, len(Lines)): if Lines[IndexJ].find(u'#string ') < 0 and Lines[Index= J].find(u'#language ') < 0 and \ - Lines[IndexJ].strip().startswith(u'"') and Lines[Index= J].strip().endswith(u'"'): + Lines[IndexJ].strip().startswith(u'"') and Lin= es[IndexJ].strip().endswith(u'"'): if Lines[IndexJ][-2] =3D=3D ' ': CombineToken =3D True if CombineToken: if Lines[IndexJ].strip()[1:-1].strip(): - Value =3D Value + Lines[IndexJ].strip()[1:= -1].rstrip() + ' ' + Value =3D Value + \ + Lines[IndexJ].strip()[1:-1].rstrip() += ' ' else: Value =3D Value + Lines[IndexJ].strip()[1:= -1] CombineToken =3D False else: - Value =3D Value + Lines[IndexJ].strip()[1:-1] = + '\r\n' + Value =3D Value + \ + Lines[IndexJ].strip()[1:-1] + '\r\n' else: IndexI =3D IndexJ break if Value.endswith('\r\n'): Value =3D Value[: Value.rfind('\r\n')] - Language =3D GetLanguageCode(Language, self.IsCompatibleMo= de, self.File) + Language =3D GetLanguageCode( + Language, self.IsCompatibleMode, self.File) self.AddStringToList(Name, Language, Value) continue =20 @@ -911,7 +976,7 @@ class UniFileClassObject(object): # # Add a string to list # - def AddStringToList(self, Name, Language, Value, Token =3D 0, Referenc= ed =3D False, UseOtherLangDef =3D '', Index =3D -1): + def AddStringToList(self, Name, Language, Value, Token=3D0, Referenced= =3DFalse, UseOtherLangDef=3D'', Index=3D-1): for LangNameItem in self.LanguageDef: if Language =3D=3D LangNameItem[0]: break @@ -953,7 +1018,8 @@ class UniFileClassObject(object): = Referenced, = Token, = OtherLangDef)) - self.OrderedStringDict[LangName[0]][Name] =3D len(= self.OrderedStringList[LangName[0]]) - 1 + self.OrderedStringDict[LangName[0]][Name] =3D len( + self.OrderedStringList[LangName[0]]) - 1 else: self.OrderedStringList[Language].insert(Index, StringDefCl= assObject(Name, = Value, @@ -1015,7 +1081,7 @@ class UniFileClassObject(object): # Use small token for all referred string stoken. # RefToken =3D 0 - for Index in range (0, len (self.OrderedStringList[FirstLangName])= ): + for Index in range(0, len(self.OrderedStringList[FirstLangName])): FirstLangItem =3D self.OrderedStringList[FirstLangName][Index] if FirstLangItem.Referenced =3D=3D True: for LangNameItem in self.LanguageDef: @@ -1030,7 +1096,7 @@ class UniFileClassObject(object): # Use big token for all unreferred string stoken. # UnRefToken =3D 0 - for Index in range (0, len (self.OrderedStringList[FirstLangName])= ): + for Index in range(0, len(self.OrderedStringList[FirstLangName])): FirstLangItem =3D self.OrderedStringList[FirstLangName][Index] if FirstLangItem.Referenced =3D=3D False: for LangNameItem in self.LanguageDef: @@ -1045,7 +1111,7 @@ class UniFileClassObject(object): # def ShowMe(self): print(self.LanguageDef) - #print self.OrderedStringList + # print self.OrderedStringList for Item in self.OrderedStringList: print(Item) for Member in self.OrderedStringList[Item]: @@ -1060,15 +1126,18 @@ class UniFileClassObject(object): =20 if not os.path.exists(FilaPath) or not os.path.isfile(FilaPath): EdkLogger.Error("Unicode File Parser", - ToolError.FILE_NOT_FOUND, - ExtraData=3DFilaPath) + ToolError.FILE_NOT_FOUND, + ExtraData=3DFilaPath) try: - FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 8').readlines() + FileIn =3D codecs.open(FilaPath, mode=3D'rb', + encoding=3D'utf_8').readlines() except UnicodeError as Xstr: - FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 16').readlines() + FileIn =3D codecs.open(FilaPath, mode=3D'rb', + encoding=3D'utf_16').readlines() except UnicodeError: - FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 16_le').readlines() + FileIn =3D codecs.open(FilaPath, mode=3D'rb', + encoding=3D'utf_16_le').readlines() except: - EdkLogger.Error("Unicode File Parser", ToolError.FILE_OPEN_FAI= LURE, ExtraData=3DFilaPath) + EdkLogger.Error("Unicode File Parser", + ToolError.FILE_OPEN_FAILURE, ExtraData=3DFilaP= ath) return FileIn - diff --git a/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py b/BaseT= ools/Source/Python/UPT/Library/Xml/XmlRoutines.py index 94e97fa45c12..8cbf8aa6b76a 100644 --- a/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py +++ b/BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py @@ -1,4 +1,4 @@ -## @file +# @file # This is an XML API that uses a syntax similar to XPath, but it is writte= n in # standard python so that no extra python packages are required to use it. # @@ -20,13 +20,15 @@ import codecs from Logger.ToolError import PARSER_ERROR import Logger.Log as Logger =20 -## Create a element of XML +# Create a element of XML # # @param Name # @param String # @param NodeList # @param AttributeList # + + def CreateXmlElement(Name, String, NodeList, AttributeList): Doc =3D xml.dom.minidom.Document() Element =3D Doc.createElement(Name) @@ -51,7 +53,7 @@ def CreateXmlElement(Name, String, NodeList, AttributeLis= t): =20 return Element =20 -## Get a list of XML nodes using XPath style syntax. +# Get a list of XML nodes using XPath style syntax. # # Return a list of XML DOM nodes from the root Dom specified by XPath Stri= ng. # If the input Dom or String is not valid, then an empty list is returned. @@ -59,6 +61,8 @@ def CreateXmlElement(Name, String, NodeList, AttributeLis= t): # @param Dom The root XML DOM node. # @param String A XPath style path. # + + def XmlList(Dom, String): if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": return [] @@ -74,7 +78,7 @@ def XmlList(Dom, String): ChildNodes =3D [] for Node in Nodes: if Node.nodeType =3D=3D Node.ELEMENT_NODE and Node.tagName =3D= =3D \ - TagList[Index]: + TagList[Index]: if Index < End: ChildNodes.extend(Node.childNodes) else: @@ -86,7 +90,7 @@ def XmlList(Dom, String): return Nodes =20 =20 -## Get a single XML node using XPath style syntax. +# Get a single XML node using XPath style syntax. # # Return a single XML DOM node from the root Dom specified by XPath String. # If the input Dom or String is not valid, then an empty string is returne= d. @@ -95,7 +99,7 @@ def XmlList(Dom, String): # @param String A XPath style path. # def XmlNode(Dom, String): - if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": + if String is None or String =3D=3D "" or Dom is None or Dom =3D=3D "": return None if Dom.nodeType =3D=3D Dom.DOCUMENT_NODE: Dom =3D Dom.documentElement @@ -118,7 +122,7 @@ def XmlNode(Dom, String): return None =20 =20 -## Get a single XML element using XPath style syntax. +# Get a single XML element using XPath style syntax. # # Return a single XML element from the root Dom specified by XPath String. # If the input Dom or String is not valid, then an empty string is returne= d. @@ -132,7 +136,7 @@ def XmlElement(Dom, String): except BaseException: return "" =20 -## Get a single XML element using XPath style syntax. +# Get a single XML element using XPath style syntax. # # Similar with XmlElement, but do not strip all the leading and tailing sp= ace # and newline, instead just remove the newline and spaces introduced by @@ -141,6 +145,8 @@ def XmlElement(Dom, String): # @param Dom The root XML DOM object. # @param Strin A XPath style path. # + + def XmlElement2(Dom, String): try: HelpStr =3D XmlNode(Dom, String).firstChild.data @@ -151,7 +157,7 @@ def XmlElement2(Dom, String): return "" =20 =20 -## Get a single XML element of the current node. +# Get a single XML element of the current node. # # Return a single XML element specified by the current root Dom. # If the input Dom is not valid, then an empty string is returned. @@ -165,7 +171,7 @@ def XmlElementData(Dom): return "" =20 =20 -## Get a list of XML elements using XPath style syntax. +# Get a list of XML elements using XPath style syntax. # # Return a list of XML elements from the root Dom specified by XPath Strin= g. # If the input Dom or String is not valid, then an empty list is returned. @@ -177,7 +183,7 @@ def XmlElementList(Dom, String): return list(map(XmlElementData, XmlList(Dom, String))) =20 =20 -## Get the XML attribute of the current node. +# Get the XML attribute of the current node. # # Return a single XML attribute named Attribute from the current root Dom. # If the input Dom or Attribute is not valid, then an empty string is retu= rned. @@ -192,7 +198,7 @@ def XmlAttribute(Dom, Attribute): return '' =20 =20 -## Get the XML node name of the current node. +# Get the XML node name of the current node. # # Return a single XML node name from the current root Dom. # If the input Dom is not valid, then an empty string is returned. @@ -205,13 +211,15 @@ def XmlNodeName(Dom): except BaseException: return '' =20 -## Parse an XML file. +# Parse an XML file. # # Parse the input XML file named FileName and return a XML DOM it stands f= or. # If the input File is not a valid XML file, then an empty string is retur= ned. # # @param FileName The XML file name. # + + def XmlParseFile(FileName): try: XmlFile =3D codecs.open(FileName, 'rb') @@ -220,4 +228,5 @@ def XmlParseFile(FileName): return Dom except BaseException as XExcept: XmlFile.close() - Logger.Error('\nUPT', PARSER_ERROR, XExcept, File=3DFileName, Rais= eError=3DTrue) + Logger.Error('\nUPT', PARSER_ERROR, XExcept, + File=3DFileName, RaiseError=3DTrue) diff --git a/BaseTools/Source/Python/UPT/Library/Xml/__init__.py b/BaseTool= s/Source/Python/UPT/Library/Xml/__init__.py index 172e498451b8..03dedeed636e 100644 --- a/BaseTools/Source/Python/UPT/Library/Xml/__init__.py +++ b/BaseTools/Source/Python/UPT/Library/Xml/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/Library/__init__.py b/BaseTools/So= urce/Python/UPT/Library/__init__.py index 07b5b75dd51e..bb3ceeeb7572 100644 --- a/BaseTools/Source/Python/UPT/Library/__init__.py +++ b/BaseTools/Source/Python/UPT/Library/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/Logger/Log.py b/BaseTools/Source/P= ython/UPT/Logger/Log.py index a2e32a6236ac..425bcc7c45a4 100644 --- a/BaseTools/Source/Python/UPT/Logger/Log.py +++ b/BaseTools/Source/Python/UPT/Logger/Log.py @@ -1,4 +1,4 @@ -## @file +# @file # This file implements the log mechanism for Python tools. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -10,7 +10,7 @@ Logger ''' =20 -## Import modules +# Import modules from sys import argv from sys import stdout from sys import stderr @@ -42,12 +42,12 @@ DEBUG_7 =3D 8 DEBUG_8 =3D 9 DEBUG_9 =3D 10 VERBOSE =3D 15 -INFO =3D 20 -WARN =3D 30 -QUIET =3D 40 +INFO =3D 20 +WARN =3D 30 +QUIET =3D 40 QUIET_1 =3D 41 -ERROR =3D 50 -SILENT =3D 60 +ERROR =3D 50 +SILENT =3D 60 =20 IS_RAISE_ERROR =3D True SUPRESS_ERROR =3D False @@ -59,15 +59,15 @@ _TOOL_NAME =3D os.path.basename(argv[0]) # # For validation purpose # -_LOG_LEVELS =3D [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5, DEB= UG_6, \ - DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO, ERROR, QUIET= , \ - QUIET_1, SILENT] +_LOG_LEVELS =3D [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5, DEB= UG_6, + DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO, ERROR, QUIE= T, + QUIET_1, SILENT] # # For DEBUG level (All DEBUG_0~9 are applicable) # _DEBUG_LOGGER =3D getLogger("tool_debug") -_DEBUG_FORMATTER =3D Formatter("[%(asctime)s.%(msecs)d]: %(message)s", \ - datefmt=3D"%H:%M:%S") +_DEBUG_FORMATTER =3D Formatter("[%(asctime)s.%(msecs)d]: %(message)s", + datefmt=3D"%H:%M:%S") # # For VERBOSE, INFO, WARN level # @@ -83,10 +83,10 @@ _ERROR_FORMATTER =3D Formatter("%(message)s") # String templates for ERROR/WARN/DEBUG log message # _ERROR_MESSAGE_TEMPLATE =3D \ -('\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\n\t%= (extra)s') + ('\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\= n\t%(extra)s') =20 __ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE =3D \ -'\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s' + '\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s' =20 _WARNING_MESSAGE_TEMPLATE =3D '%(tool)s...\n%(file)s(%(line)s): warning: %= (msg)s' _WARNING_MESSAGE_TEMPLATE_WITHOUT_FILE =3D '%(tool)s: : warning: %(msg)s' @@ -104,15 +104,19 @@ def Info(msg, *args, **kwargs): # # Log information which should be always put out # + + def Quiet(msg, *args, **kwargs): _ERROR_LOGGER.error(msg, *args, **kwargs) =20 -## Log debug message +# Log debug message # # @param Level DEBUG level (DEBUG0~9) # @param Message Debug information # @param ExtraData More information associated with "Message" # + + def Debug(Level, Message, ExtraData=3DNone): if _DEBUG_LOGGER.level > Level: return @@ -123,9 +127,9 @@ def Debug(Level, Message, ExtraData=3DNone): # CallerStack =3D extract_stack()[-2] TemplateDict =3D { - "file" : CallerStack[0], - "line" : CallerStack[1], - "msg" : Message, + "file": CallerStack[0], + "line": CallerStack[1], + "msg": Message, } =20 if ExtraData is not None: @@ -135,14 +139,16 @@ def Debug(Level, Message, ExtraData=3DNone): =20 _DEBUG_LOGGER.log(Level, LogText) =20 -## Log verbose message +# Log verbose message # # @param Message Verbose information # + + def Verbose(Message): return _INFO_LOGGER.log(VERBOSE, Message) =20 -## Log warning message +# Log warning message # # Warning messages are those which might be wrong but won't fail the too= l. # @@ -153,6 +159,8 @@ def Verbose(Message): # @param Line The line number in the "File" which caused the war= ning. # @param ExtraData More information associated with "Message" # + + def Warn(ToolName, Message, File=3DNone, Line=3DNone, ExtraData=3DNone): if _INFO_LOGGER.level > WARN: return @@ -168,10 +176,10 @@ def Warn(ToolName, Message, File=3DNone, Line=3DNone,= ExtraData=3DNone): Line =3D "%d" % Line =20 TemplateDict =3D { - "tool" : ToolName, - "file" : File, - "line" : Line, - "msg" : Message, + "tool": ToolName, + "file": File, + "line": Line, + "msg": Message, } =20 if File is not None: @@ -189,7 +197,7 @@ def Warn(ToolName, Message, File=3DNone, Line=3DNone, E= xtraData=3DNone): if GlobalData.gWARNING_AS_ERROR =3D=3D True: raise FatalError(WARNING_AS_ERROR) =20 -## Log ERROR message +# Log ERROR message # # Once an error messages is logged, the tool's execution will be broken by # raising an exception. If you don't want to break the execution later, you @@ -205,7 +213,9 @@ def Warn(ToolName, Message, File=3DNone, Line=3DNone, E= xtraData=3DNone): # @param RaiseError Raise an exception to break the tool's execution if # it's True. This is the default behavior. # -def Error(ToolName, ErrorCode, Message=3DNone, File=3DNone, Line=3DNone, \ + + +def Error(ToolName, ErrorCode, Message=3DNone, File=3DNone, Line=3DNone, ExtraData=3DNone, RaiseError=3DIS_RAISE_ERROR): if ToolName: pass @@ -224,16 +234,16 @@ def Error(ToolName, ErrorCode, Message=3DNone, File= =3DNone, Line=3DNone, \ ExtraData =3D "" =20 TemplateDict =3D { - "tool" : _TOOL_NAME, - "file" : File, - "line" : Line, - "errorcode" : ErrorCode, - "msg" : Message, - "extra" : ExtraData + "tool": _TOOL_NAME, + "file": File, + "line": Line, + "errorcode": ErrorCode, + "msg": Message, + "extra": ExtraData } =20 if File is not None: - LogText =3D _ERROR_MESSAGE_TEMPLATE % TemplateDict + LogText =3D _ERROR_MESSAGE_TEMPLATE % TemplateDict else: LogText =3D __ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE % TemplateDict =20 @@ -243,7 +253,7 @@ def Error(ToolName, ErrorCode, Message=3DNone, File=3DN= one, Line=3DNone, \ raise FatalError(ErrorCode) =20 =20 -## Initialize log system +# Initialize log system # def Initialize(): # @@ -272,33 +282,39 @@ def Initialize(): _ERROR_LOGGER.addHandler(_ErrorCh) =20 =20 -## Set log level +# Set log level # # @param Level One of log level in _LogLevel # def SetLevel(Level): if Level not in _LOG_LEVELS: - Info("Not supported log level (%d). Use default level instead." % \ + Info("Not supported log level (%d). Use default level instead." % Level) Level =3D INFO _DEBUG_LOGGER.setLevel(Level) _INFO_LOGGER.setLevel(Level) _ERROR_LOGGER.setLevel(Level) =20 -## Get current log level +# Get current log level # + + def GetLevel(): return _INFO_LOGGER.getEffectiveLevel() =20 -## Raise up warning as error +# Raise up warning as error # + + def SetWarningAsError(): GlobalData.gWARNING_AS_ERROR =3D True =20 -## Specify a file to store the log message as well as put on console +# Specify a file to store the log message as well as put on console # # @param LogFile The file path used to store the log message # + + def SetLogFile(LogFile): if os.path.exists(LogFile): remove(LogFile) @@ -314,6 +330,3 @@ def SetLogFile(LogFile): _Ch =3D FileHandler(LogFile) _Ch.setFormatter(_ERROR_FORMATTER) _ERROR_LOGGER.addHandler(_Ch) - - - diff --git a/BaseTools/Source/Python/UPT/Logger/StringTable.py b/BaseTools/= Source/Python/UPT/Logger/StringTable.py index 13c015844ea0..317885048dfb 100644 --- a/BaseTools/Source/Python/UPT/Logger/StringTable.py +++ b/BaseTools/Source/Python/UPT/Logger/StringTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define strings used in the UPT tool # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -16,7 +16,7 @@ import gettext # string table starts here... # =20 -## strings are classified as following types +# strings are classified as following types # MSG_...: it is a message string # ERR_...: it is a error string # WRN_...: it is a warning string @@ -26,24 +26,25 @@ import gettext _ =3D gettext.gettext =20 MSG_USAGE_STRING =3D _("\n" - "UEFI Packaging Tool (UEFIPT)\n" - "%prog [options]" - ) + "UEFI Packaging Tool (UEFIPT)\n" + "%prog [options]" + ) =20 ## # Version and Copyright # MSG_VERSION_NUMBER =3D _("1.1") -MSG_VERSION =3D _("UEFI Packaging Tool (UEFIPT) - Revision " + \ +MSG_VERSION =3D _("UEFI Packaging Tool (UEFIPT) - Revision " + MSG_VERSION_NUMBER) -MSG_COPYRIGHT =3D _("Copyright (c) 2011 - 2018 Intel Corporation All Right= s Reserved.") +MSG_COPYRIGHT =3D _( + "Copyright (c) 2011 - 2018 Intel Corporation All Rights Reserved.") MSG_VERSION_COPYRIGHT =3D _("\n %s\n %s" % (MSG_VERSION, MSG_COPYRIGHT)) MSG_USAGE =3D _("%s [options]\n%s" % ("UPT", MSG_VERSION_COPYRIGHT)) -MSG_DESCRIPTION =3D _("The UEFIPT is used to create, " + \ - "install or remove a UEFI Distribution Package. " + \ - "If WORKSPACE environment variable is present, " + \ - "then UPT will install packages to the location specif= ied by WORKSPACE, " + \ - "otherwise UPT will install packages to the current di= rectory. " + \ +MSG_DESCRIPTION =3D _("The UEFIPT is used to create, " + + "install or remove a UEFI Distribution Package. " + + "If WORKSPACE environment variable is present, " + + "then UPT will install packages to the location specif= ied by WORKSPACE, " + + "otherwise UPT will install packages to the current di= rectory. " + "Option -n will override this default installation loc= ation") =20 # @@ -56,23 +57,23 @@ ERR_INF_PARSER_HEADER_MISSGING =3D _( ERR_INF_PARSER_UNKNOWN_SECTION =3D _("An unknown section was found. " "It must be corrected before continuing= . ") ERR_INF_PARSER_NO_SECTION_ERROR =3D _("No section was found. " - "A section must be included before continuing.= ") + "A section must be included before con= tinuing.") ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID =3D \ _("Build Option format incorrect.") ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID =3D _( - "The format of binary %s item is incorrect. " - "It should contain at least %d elements.") + "The format of binary %s item is incorrect. " + "It should contain at least %d elements.") ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX =3D _( - "The format of binary %s item is invalid, " - "it should contain not more than %d elements.") + "The format of binary %s item is invalid, " + "it should contain not more than %d elements.") ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE =3D _( - "The Binary FileType is incorrect. It should in %s") + "The Binary FileType is incorrect. It should in %s") ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST =3D _( - "The Binary File: %s not exist.") + "The Binary File: %s not exist.") ERR_INF_PARSER_BINARY_ITEM_FILENAME_NOT_EXIST =3D _( - "The Binary File Name item not exist") + "The Binary File Name item not exist") ERR_INF_PARSER_BINARY_VER_TYPE =3D _( - "Only this type is allowed: \"%s\".") + "Only this type is allowed: \"%s\".") ERR_INF_PARSER_MULTI_DEFINE_SECTION =3D \ _("Multiple define sections found. " "It must be corrected before continuing.") @@ -91,8 +92,8 @@ ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID =3D \ "or has an incorrect file name of the directory containing the INF o= r DEC file: %s. " "It must be corrected before continuing") ERR_INF_PARSER_DEFINE_SHADOW_INVALID =3D \ - _("The SHADOW keyword is only valid for" - " SEC, PEI_CORE and PEIM module typ= es.") + _("The SHADOW keyword is only valid for" + " SEC, PEI_CORE and PEIM module types.") ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID =3D \ _("The format of the section header is incorrect") ERR_INF_PARSER_DEPEX_SECTION_INVALID =3D \ @@ -103,15 +104,15 @@ ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_LIBRARY_CLAS= S =3D \ _("A library class can't have a Depex section when its supported modul= e type list is not defined.") ERR_INF_PARSER_DEPEX_SECTION_INVALID_FOR_DRIVER =3D \ _("A driver can't have a Depex section when its module type is UEFI_DR= IVER.") -ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED =3D \ +ERR_INF_PARSER_DEPEX_SECTION_NOT_DETERMINED =3D \ _("Cannot determine the module's Depex type. The Depex's module types = are conflict") ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST =3D _( - "No %s found in INF file, please check it.") + "No %s found in INF file, please check it.") ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR =3D \ _("The module type of [Depex] section is invalid, not support type of = %s") ERR_INF_PARSER_DEPEX_SECTION_CONTENT_MISSING =3D \ _("Missing content in: %s") -ERR_INF_PARSER_DEPEX_SECTION_CONTENT_ERROR =3D \ +ERR_INF_PARSER_DEPEX_SECTION_CONTENT_ERROR =3D \ _("The [Depex] section contains invalid content: %s") ERR_INF_PARSER_DEPEX_SECTION_SEC_TYPE_ERROR =3D \ _("The format is incorrect. The section type keyword of the content in= the" @@ -186,7 +187,7 @@ ERR_INF_PARSER_CNAME_MISSING =3D \ _("Missing CName. Specify a valid C variable name.") ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID =3D \ _("The Define section contains an invalid keyword: \"%s\"." - "It must be corrected before continuing.") + "It must be corrected before continuing.") ERR_INF_PARSER_FILE_MISS_DEFINE =3D \ _("The following file listed in the module " "directory is not listed in the INF: %s") @@ -197,66 +198,75 @@ ERR_INF_PARSER_VER_EXIST_BOTH_NUM_STR =3D \ _("The INF file %s defines both VERSION_NUMBER and VERSION_STRING, " "using VERSION_STRING") ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF =3D _("EDKI INF is not supported") -ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII =3D _("The EDKI style comment is not = supported in EDKII modules") +ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII =3D _( + "The EDKI style comment is not supported in EDKII modules") =20 ERR_INF_PARSER_FEATUREPCD_USAGE_INVALID =3D _("The usage for FeaturePcd ca= n only" - " be type of \"CONSUMES\".") + " be type of \"CONSUMES\".") =20 ERR_INF_PARSER_DEFINE_ITEM_NO_NAME =3D _("No name specified") ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE =3D _("No value specified") =20 ERR_INF_PARSER_MODULETYPE_INVALID =3D _("Drivers and applications are not = allowed to have a MODULE_TYPE of \"BASE\". " -"Only libraries are permitted to a have a MODULE_TYPE of \"BASE\".") -ERR_INF_GET_PKG_DEPENDENCY_FAIL =3D _("Failed to get PackageDependencies i= nformation from file %s") -ERR_INF_NO_PKG_DEPENDENCY_INFO =3D _("There are no packages defined that u= se the AsBuilt PCD information.") + "Only libraries are permitted to a h= ave a MODULE_TYPE of \"BASE\".") +ERR_INF_GET_PKG_DEPENDENCY_FAIL =3D _( + "Failed to get PackageDependencies information from file %s") +ERR_INF_NO_PKG_DEPENDENCY_INFO =3D _( + "There are no packages defined that use the AsBuilt PCD information.") =20 # # Item duplicate # ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC =3D \ -_('"%s" is redefined in its dependent DEC files') + _('"%s" is redefined in its dependent DEC files') ERR_INF_PARSER_ITEM_DUPLICATE =3D _("%s define duplicated! " "It must be corrected before continuing.= ") ERR_INF_PARSER_ITEM_DUPLICATE_COMMON =3D _("%s define duplicated! Item lis= ted" -"in an architectural section must not be listed in the common architectura= l" -"section.It must be corrected before continuing.") + "in an architectural section must= not be listed in the common architectural" + "section.It must be corrected bef= ore continuing.") ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR =3D \ -_("%s define duplicated! Each UserExtensions section header must have a " - "unique set of UserId, IdString and Arch values. " - "It must be corrected before continuing.") + _("%s define duplicated! Each UserExtensions section header must have = a " + "unique set of UserId, IdString and Arch values. " + "It must be corrected before continuing.") =20 ERR_INF_PARSER_DEFINE_LIB_NAME_INVALID =3D \ -_("The name 'NULL' for LibraryClass is a reserved word." -"Please don't use it.") + _("The name 'NULL' for LibraryClass is a reserved word." + "Please don't use it.") =20 ERR_GLOBAL_MARCO_INVALID =3D \ -_("Using global MACRO in INF/DEC is not permitted: %s . " -"It must be corrected before continuing.") + _("Using global MACRO in INF/DEC is not permitted: %s . " + "It must be corrected before continuing.") =20 ERR_MARCO_DEFINITION_MISS_ERROR =3D \ -_("MACRO expand incorrectly, can not find the MACRO definition. " -"It must be corrected before continuing.") + _("MACRO expand incorrectly, can not find the MACRO definition. " + "It must be corrected before continuing.") =20 # # AsBuilt related # ERR_LIB_CONTATIN_ASBUILD_AND_COMMON =3D _("A binary INF file should not co= ntain both AsBuilt LIB_INSTANCES information " "and a common library entry.") -ERR_LIB_INSTANCE_MISS_GUID =3D _("Could not get FILE_GUID definition from = instance INF file.") +ERR_LIB_INSTANCE_MISS_GUID =3D _( + "Could not get FILE_GUID definition from instance INF file.") =20 ERR_BO_CONTATIN_ASBUILD_AND_COMMON =3D _("A binary INF file should contain= either AsBuilt information " "or a common build option entry, no= t both.") =20 -ERR_ASBUILD_PCD_SECTION_TYPE =3D _("The AsBuilt INF file contains a PCD se= ction type that is not permitted: %s.") -ERR_ASBUILD_PATCHPCD_FORMAT_INVALID =3D _("The AsBuilt PatchPcd entry must= contain 3 elements: PcdName|Value|Offset") -ERR_ASBUILD_PCDEX_FORMAT_INVALID =3D _("The AsBuilt PcdEx entry must conta= in one element: PcdName") +ERR_ASBUILD_PCD_SECTION_TYPE =3D _( + "The AsBuilt INF file contains a PCD section type that is not permitte= d: %s.") +ERR_ASBUILD_PATCHPCD_FORMAT_INVALID =3D _( + "The AsBuilt PatchPcd entry must contain 3 elements: PcdName|Value|Off= set") +ERR_ASBUILD_PCDEX_FORMAT_INVALID =3D _( + "The AsBuilt PcdEx entry must contain one element: PcdName") ERR_ASBUILD_PCD_VALUE_INVALID =3D \ _("The AsBuilt PCD value %s is incorrect or not align with its datum t= ype %s. " "It must be corrected before continuing.") -ERR_ASBUILD_PCD_TOKENSPACE_GUID_VALUE_MISS =3D _("Package file value could= not be retrieved for %s.") -ERR_ASBUILD_PCD_DECLARITION_MISS =3D _("PCD Declaration in DEC files could= not be found for: %s.") +ERR_ASBUILD_PCD_TOKENSPACE_GUID_VALUE_MISS =3D _( + "Package file value could not be retrieved for %s.") +ERR_ASBUILD_PCD_DECLARITION_MISS =3D _( + "PCD Declaration in DEC files could not be found for: %s.") ERR_ASBUILD_PCD_OFFSET_FORMAT_INVALID =3D _("PCD offset format invalid, nu= mber of (0-4294967295) or" -"Hex number of UINT32 allowed : %s.") + "Hex number of UINT32 allowed : = %s.") =20 # # XML parser related strings @@ -267,13 +277,13 @@ ERR_XML_INVALID_VARIABLENAME =3D \ _("The VariableName of the GUID in the XML tree does not conform to th= e packaging specification. " "Only a Hex Byte Array of UCS-2 format or L\"string\" is allowed): %= s %s %s") ERR_XML_INVALID_LIB_SUPMODLIST =3D _("The LIBRARY_CLASS entry %s must have= the list appended using the format as: \n" -"BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER SMM_CORE DXE_SMM_DRIVER DXE_RU= NTIME_DRIVER " -"DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION USER_DEFINED\n Current is %s.= ") + "BASE SEC PEI_CORE PEIM DXE_CORE DXE_DR= IVER SMM_CORE DXE_SMM_DRIVER DXE_RUNTIME_DRIVER " + "DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLIC= ATION USER_DEFINED\n Current is %s.") ERR_XML_INVALID_EXTERN_SUPARCHLIST =3D \ _("There is a mismatch of SupArchList %s between the EntryPoint, Unloa= dImage, Constructor, " "and Destructor elements in the ModuleSurfaceArea.ModuleProperties: = SupArchList: %s. ") ERR_XML_INVALID_EXTERN_SUPMODLIST =3D _("The SupModList attribute of the C= ONSTRUCTOR or DESTRUCTOR element: %s does not " -"match the Supported Module Types listed after LIBRARY_CLASS =3D = | %s") + "match the Supported Module Types li= sted after LIBRARY_CLASS =3D | %s") ERR_XML_INVALID_EXTERN_SUPMODLIST_NOT_LIB =3D _("The module is not a libra= ry module. " "The MODULE_TYPE : %s listed= in the ModuleSurfaceArea.Header " "must match the SupModList a= ttribute %s") @@ -285,76 +295,79 @@ ERR_XML_INVALID_BINARY_FILE_TYPE =3D _("Invalid binar= y file type %s.") MSG_DISTRIBUTION_PACKAGE_FILE_EXISTS =3D _( "The distribution package file %s already exists.\nPress Y to override= it." " To exit the application, press any other key.") -MSG_CHECK_MODULE_EXIST =3D _( +MSG_CHECK_MODULE_EXIST =3D _( "\nChecking to see if module exists in workspace started ...") -MSG_CHECK_MODULE_EXIST_FINISH =3D \ +MSG_CHECK_MODULE_EXIST_FINISH =3D \ _("Checking to see if module exists in workspace ... Done.") -MSG_CHECK_MODULE_DEPEX_START =3D _( +MSG_CHECK_MODULE_DEPEX_START =3D _( "\nChecking to see if module depex met by workspace started ...") -MSG_CHECK_MODULE_DEPEX_FINISH =3D _( +MSG_CHECK_MODULE_DEPEX_FINISH =3D _( "Checking to see if module depex met by workspace ... Done.") -MSG_CHECK_PACKAGE_START =3D _( +MSG_CHECK_PACKAGE_START =3D _( "\nChecking to see if package exists in workspace started ...") -MSG_CHECK_PACKAGE_FINISH =3D _( +MSG_CHECK_PACKAGE_FINISH =3D _( "Checking to see if package exists in workspace ... Done.") -MSG_CHECK_DP_START =3D \ +MSG_CHECK_DP_START =3D \ _("\nChecking to see if DP exists in workspace ... Done.") -MSG_CHECK_DP_FINISH =3D _("Check DP exists in workspace ... Don= e.") -MSG_MODULE_DEPEND_ON =3D _("Module %s depends on Package %s") -MSG_INIT_IPI_START =3D _("\nInitialize IPI database started ..= .") -MSG_INIT_IPI_FINISH =3D _("Initialize IPI database ... Done.") -MSG_GET_DP_INSTALL_LIST =3D _( +MSG_CHECK_DP_FINISH =3D _("Check DP exists in workspace ... Done.") +MSG_MODULE_DEPEND_ON =3D _("Module %s depends on Package %s") +MSG_INIT_IPI_START =3D _("\nInitialize IPI database started ...") +MSG_INIT_IPI_FINISH =3D _("Initialize IPI database ... Done.") +MSG_GET_DP_INSTALL_LIST =3D _( "\nGetting list of DP install information started ...") -MSG_GET_DP_INSTALL_INFO_START =3D _( +MSG_GET_DP_INSTALL_INFO_START =3D _( "\nGetting list of DP install information started ...") MSG_GET_DP_INSTALL_INFO_FINISH =3D _("Getting DP install information ... D= one.") -MSG_UZIP_PARSE_XML =3D _( +MSG_UZIP_PARSE_XML =3D _( "Unzipping and parsing distribution package XML file ... ") -MSG_INSTALL_PACKAGE =3D _("Installing package ... %s") -MSG_INSTALL_MODULE =3D _("Installing module ... %s") -MSG_NEW_FILE_NAME_FOR_DIST =3D _( +MSG_INSTALL_PACKAGE =3D _("Installing package ... %s") +MSG_INSTALL_MODULE =3D _("Installing module ... %s") +MSG_NEW_FILE_NAME_FOR_DIST =3D _( "Provide new filename for distribution file to be saved:\n") -MSG_UPDATE_PACKAGE_DATABASE =3D _("Update Distribution Package Database= ...") -MSG_PYTHON_ON =3D _("(Python %s on %s) ") -MSG_EDKII_MAIL_ADDR =3D 'devel@edk2.groups.io' -MSG_SEARCH_FOR_HELP =3D _( +MSG_UPDATE_PACKAGE_DATABASE =3D _("Update Distribution Package Database ..= .") +MSG_PYTHON_ON =3D _("(Python %s on %s) ") +MSG_EDKII_MAIL_ADDR =3D 'devel@edk2.groups.io' +MSG_SEARCH_FOR_HELP =3D _( "\n(Please send email to %s for\n" " help, attach the following call stack trace.)\n") -MSG_REMOVE_TEMP_FILE_STARTED =3D _("Removing temp files started ... ") -MSG_REMOVE_TEMP_FILE_DONE =3D _("Removing temp files ... Done.") -MSG_FINISH =3D _("Successfully Done.") -MSG_COMPRESS_DISTRIBUTION_PKG =3D _("Compressing Distribution Package Fil= e ...") -MSG_CONFIRM_REMOVE =3D _( +MSG_REMOVE_TEMP_FILE_STARTED =3D _("Removing temp files started ... ") +MSG_REMOVE_TEMP_FILE_DONE =3D _("Removing temp files ... Done.") +MSG_FINISH =3D _("Successfully Done.") +MSG_COMPRESS_DISTRIBUTION_PKG =3D _("Compressing Distribution Package File= ...") +MSG_CONFIRM_REMOVE =3D _( "Some packages or modules depend on this distribution package.\n" "Do you really want to remove it?") -MSG_CONFIRM_REMOVE2 =3D _( +MSG_CONFIRM_REMOVE2 =3D _( "This file has been modified: %s. Do you want to remove it?" "Press Y to remove or other key to keep it") -MSG_CONFIRM_REMOVE3 =3D _( +MSG_CONFIRM_REMOVE3 =3D _( "This is a newly created file: %s. Are you sure you want to remove it= ? " "Press Y to remove or any other key to keep it") -MSG_USER_DELETE_OP =3D _( +MSG_USER_DELETE_OP =3D _( "Press Y to delete all files or press any other key to quit:") -MSG_REMOVE_FILE =3D _("Removing file: %s ...") +MSG_REMOVE_FILE =3D _("Removing file: %s ...") =20 -MSG_INITIALIZE_ECC_STARTED =3D _("\nInitialize ECC database started ..= .") -MSG_INITIALIZE_ECC_DONE =3D _("Initialize ECC database ... Done.") -MSG_DEFINE_STATEMENT_FOUND =3D _("DEFINE statement '%s' found in secti= on %s") -MSG_PARSING =3D _("Parsing %s ...") +MSG_INITIALIZE_ECC_STARTED =3D _("\nInitialize ECC database started ...") +MSG_INITIALIZE_ECC_DONE =3D _("Initialize ECC database ... Done.") +MSG_DEFINE_STATEMENT_FOUND =3D _("DEFINE statement '%s' found in section %= s") +MSG_PARSING =3D _("Parsing %s ...") =20 -MSG_REPKG_CONFLICT =3D \ -_("Repackaging is not allowed on this file: %s. " - "It was installed from distribution %s(Guid %s Version %s).") +MSG_REPKG_CONFLICT =3D \ + _("Repackaging is not allowed on this file: %s. " + "It was installed from distribution %s(Guid %s Version %s).") =20 -MSG_INVALID_MODULE_INTRODUCED =3D _("Some modules are not valid after rem= oval.") -MSG_CHECK_LOG_FILE =3D _("Please check log file %s for full li= st") -MSG_NEW_FILE_NAME =3D _( +MSG_INVALID_MODULE_INTRODUCED =3D _("Some modules are not valid after remo= val.") +MSG_CHECK_LOG_FILE =3D _("Please check log file %s for full list") +MSG_NEW_FILE_NAME =3D _( "Provide new filename:\n") -MSG_RELATIVE_PATH_ONLY =3D _("Please specify a relative path, full path is= not allowed: %s") -MSG_NEW_PKG_PATH =3D _( +MSG_RELATIVE_PATH_ONLY =3D _( + "Please specify a relative path, full path is not allowed: %s") +MSG_NEW_PKG_PATH =3D _( "Select package location. To quit with no input, press [Enter].") -MSG_CHECK_DP_FOR_REPLACE =3D _("Verifying the dependency rule for replacem= ent of distributions:\n %s replaces %s") -MSG_CHECK_DP_FOR_INSTALL =3D _("Verifying the dependency rule for installa= tion of distribution:\n %s") +MSG_CHECK_DP_FOR_REPLACE =3D _( + "Verifying the dependency rule for replacement of distributions:\n %s = replaces %s") +MSG_CHECK_DP_FOR_INSTALL =3D _( + "Verifying the dependency rule for installation of distribution:\n %s") MSG_REPLACE_ALREADY_INSTALLED_DP =3D _("Distribution with the same GUID/Ve= rsion is already installed, " "replace would result in two instance= s, which is not allowed") MSG_RECOVER_START =3D _('An error was detected, recovery started ...') @@ -364,398 +377,416 @@ MSG_RECOVER_FAIL =3D _('Recovery failed.') # Error related strings. # =20 -ERR_DEPENDENCY_NOT_MATCH =3D _( +ERR_DEPENDENCY_NOT_MATCH =3D _( "Module %s's dependency on package %s (GUID %s Version %s) " "cannot be satisfied") -ERR_MODULE_NOT_INSTALLED =3D _( +ERR_MODULE_NOT_INSTALLED =3D _( "This module is not installed in the workspace: %s\n") -ERR_DIR_ALREADY_EXIST =3D _( +ERR_DIR_ALREADY_EXIST =3D _( "This directory already exists: %s.\n" "Select another location. Press [Enter] with no input to quit:") -ERR_USER_INTERRUPT =3D _("The user has paused the applicatio= n") -ERR_DIST_FILE_TOOMANY =3D _( +ERR_USER_INTERRUPT =3D _("The user has paused the application") +ERR_DIST_FILE_TOOMANY =3D _( "Only one .content and one .pkg file in ZIP file are allowed.") -ERR_DIST_FILE_TOOFEW =3D _( +ERR_DIST_FILE_TOOFEW =3D _( "Must have one .content and one .pkg file in the ZIP file.") -ERR_FILE_ALREADY_EXIST =3D _( +ERR_FILE_ALREADY_EXIST =3D _( "This file already exists: %s.\n" "Select another path to continue. To quit with no input press [Enter]:= ") -ERR_SPECIFY_PACKAGE =3D _( +ERR_SPECIFY_PACKAGE =3D _( "One distribution package must be specified") -ERR_FILE_BROKEN =3D _( +ERR_FILE_BROKEN =3D _( "This file is invalid in the distribution package: %s") ERR_PACKAGE_NOT_MATCH_DEPENDENCY =3D _( "This distribution package does not meet the dependency requirements") -ERR_UNKNOWN_FATAL_INSTALL_ERR =3D \ -_("Unknown unrecoverable error when installing: %s") -ERR_UNKNOWN_FATAL_REPLACE_ERR =3D \ -_("Unknown unrecoverable error during replacement of distributions: %s rep= laces %s") -ERR_OPTION_NOT_FOUND =3D _("Options not found") -ERR_INVALID_PACKAGE_NAME =3D _("Incorrect package name: %s. ") -ERR_INVALID_PACKAGE_PATH =3D \ -_("Incorrect package path: %s. The path must be a relative path.") -ERR_NOT_FOUND =3D _("This was not found: %s") -ERR_INVALID_MODULE_NAME =3D _("This is not a valid module name: %= s") -ERR_INVALID_METAFILE_PATH =3D _('This file must be in sub-directory= of WORKSPACE: %s.') -ERR_INVALID_MODULE_PATH =3D \ -_("Incorrect module path: %s. The path must be a relative path.") -ERR_UNKNOWN_FATAL_CREATING_ERR =3D _("Unknown error when creating: %s") -ERR_PACKAGE_NOT_INSTALLED =3D _( +ERR_UNKNOWN_FATAL_INSTALL_ERR =3D \ + _("Unknown unrecoverable error when installing: %s") +ERR_UNKNOWN_FATAL_REPLACE_ERR =3D \ + _("Unknown unrecoverable error during replacement of distributions: %s= replaces %s") +ERR_OPTION_NOT_FOUND =3D _("Options not found") +ERR_INVALID_PACKAGE_NAME =3D _("Incorrect package name: %s. ") +ERR_INVALID_PACKAGE_PATH =3D \ + _("Incorrect package path: %s. The path must be a relative path.") +ERR_NOT_FOUND =3D _("This was not found: %s") +ERR_INVALID_MODULE_NAME =3D _("This is not a valid module name: %s") +ERR_INVALID_METAFILE_PATH =3D _( + 'This file must be in sub-directory of WORKSPACE: %s.') +ERR_INVALID_MODULE_PATH =3D \ + _("Incorrect module path: %s. The path must be a relative path.") +ERR_UNKNOWN_FATAL_CREATING_ERR =3D _("Unknown error when creating: %s") +ERR_PACKAGE_NOT_INSTALLED =3D _( "This distribution package not installed: %s") -ERR_DISTRIBUTION_NOT_INSTALLED =3D _( +ERR_DISTRIBUTION_NOT_INSTALLED =3D _( "The distribution package is not installed.") -ERR_UNKNOWN_FATAL_REMOVING_ERR =3D _("Unknown error when removing packag= e") -ERR_UNKNOWN_FATAL_INVENTORYWS_ERR =3D _("Unknown error when inventorying= WORKSPACE") -ERR_NOT_CONFIGURE_WORKSPACE_ENV =3D _( +ERR_UNKNOWN_FATAL_REMOVING_ERR =3D _("Unknown error when removing package") +ERR_UNKNOWN_FATAL_INVENTORYWS_ERR =3D _( + "Unknown error when inventorying WORKSPACE") +ERR_NOT_CONFIGURE_WORKSPACE_ENV =3D _( "The WORKSPACE environment variable must be configured.") -ERR_NO_TEMPLATE_FILE =3D _("This package information data file= is not found: %s") -ERR_DEBUG_LEVEL =3D _( +ERR_NO_TEMPLATE_FILE =3D _("This package information data file is not foun= d: %s") +ERR_DEBUG_LEVEL =3D _( "Not supported debug level. Use default level instead.") -ERR_REQUIRE_T_OPTION =3D _( +ERR_REQUIRE_T_OPTION =3D _( "Option -t is required during distribution creation.") -ERR_REQUIRE_O_OPTION =3D _( +ERR_REQUIRE_O_OPTION =3D _( "Option -o is required during distribution replacement.") -ERR_REQUIRE_U_OPTION =3D _( +ERR_REQUIRE_U_OPTION =3D _( "Option -u is required during distribution replacement.") -ERR_REQUIRE_I_C_R_OPTION =3D _( +ERR_REQUIRE_I_C_R_OPTION =3D _( "Options -i, -c and -r are mutually exclusive.") -ERR_I_C_EXCLUSIVE =3D \ -_("Option -c and -i are mutually exclusive.") -ERR_I_R_EXCLUSIVE =3D \ -_("Option -i and -r are mutually exclusive.") -ERR_C_R_EXCLUSIVE =3D \ -_("Option -c and -r are mutually exclusive.") -ERR_U_ICR_EXCLUSIVE =3D \ -_("Option -u and -c/-i/-r are mutually exclusive.") +ERR_I_C_EXCLUSIVE =3D \ + _("Option -c and -i are mutually exclusive.") +ERR_I_R_EXCLUSIVE =3D \ + _("Option -i and -r are mutually exclusive.") +ERR_C_R_EXCLUSIVE =3D \ + _("Option -c and -r are mutually exclusive.") +ERR_U_ICR_EXCLUSIVE =3D \ + _("Option -u and -c/-i/-r are mutually exclusive.") =20 -ERR_L_OA_EXCLUSIVE =3D \ -_("Option -l and -c/-i/-r/-u are mutually exclusive.") +ERR_L_OA_EXCLUSIVE =3D \ + _("Option -l and -c/-i/-r/-u are mutually exclusive.") =20 -ERR_FAILED_LOAD =3D _("Failed to load %s\n\t%s") +ERR_FAILED_LOAD =3D _("Failed to load %s\n\t%s") ERR_PLACEHOLDER_DIFFERENT_REPEAT =3D _( "${%s} has different repeat time from others.") -ERR_KEY_NOTALLOWED =3D _("This keyword is not allowed: %s") -ERR_NOT_FOUND_ENVIRONMENT =3D _("Environment variable not found") -ERR_WORKSPACE_NOTEXIST =3D _("WORKSPACE doesn't exist") -ERR_SPACE_NOTALLOWED =3D _( +ERR_KEY_NOTALLOWED =3D _("This keyword is not allowed: %s") +ERR_NOT_FOUND_ENVIRONMENT =3D _("Environment variable not found") +ERR_WORKSPACE_NOTEXIST =3D _("WORKSPACE doesn't exist") +ERR_SPACE_NOTALLOWED =3D _( "Whitespace characters are not allowed in the WORKSPACE path. ") -ERR_MACRONAME_NOGIVEN =3D _("No MACRO name given") -ERR_MACROVALUE_NOGIVEN =3D _("No MACRO value given") -ERR_MACRONAME_INVALID =3D _("Incorrect MACRO name: %s") -ERR_MACROVALUE_INVALID =3D _("Incorrect MACRO value: %s") -ERR_NAME_ONLY_DEFINE =3D _( +ERR_MACRONAME_NOGIVEN =3D _("No MACRO name given") +ERR_MACROVALUE_NOGIVEN =3D _("No MACRO value given") +ERR_MACRONAME_INVALID =3D _("Incorrect MACRO name: %s") +ERR_MACROVALUE_INVALID =3D _("Incorrect MACRO value: %s") +ERR_NAME_ONLY_DEFINE =3D _( "This variable can only be defined via environment variable: %s") -ERR_EDK_GLOBAL_SAMENAME =3D _( +ERR_EDK_GLOBAL_SAMENAME =3D _( "EDK_GLOBAL defined a macro with the same name as one defined by 'DEFI= NE'") -ERR_SECTIONNAME_INVALID =3D _( +ERR_SECTIONNAME_INVALID =3D _( "An incorrect section name was found: %s. 'The correct file is '%s' .") -ERR_CHECKFILE_NOTFOUND =3D _( +ERR_CHECKFILE_NOTFOUND =3D _( "Can't find file '%s' defined in section '%s'") -ERR_INVALID_NOTFOUND =3D _( +ERR_INVALID_NOTFOUND =3D _( "Incorrect statement '%s' was found in section '%s'") -ERR_TEMPLATE_NOTFOUND =3D _("This package information data file= is not found: %s") -ERR_SECTION_NAME_INVALID =3D _('Incorrect section name: %s') -ERR_SECTION_REDEFINE =3D _( +ERR_TEMPLATE_NOTFOUND =3D _( + "This package information data file is not found: %s") +ERR_SECTION_NAME_INVALID =3D _('Incorrect section name: %s') +ERR_SECTION_REDEFINE =3D _( "This section already defined: %s.") -ERR_SECTION_NAME_NONE =3D \ +ERR_SECTION_NAME_NONE =3D \ _('The section needs to be specified first.') -ERR_KEYWORD_INVALID =3D _('Invalid keyword: %s') -ERR_VALUE_INVALID =3D _("Invalid \"%s\" value in section [%= s].") -ERR_FILELIST_LOCATION =3D _( +ERR_KEYWORD_INVALID =3D _('Invalid keyword: %s') +ERR_VALUE_INVALID =3D _("Invalid \"%s\" value in section [%s].") +ERR_FILELIST_LOCATION =3D _( 'The directory "%s" must contain this file: "%s".') -ERR_KEYWORD_REDEFINE =3D _( +ERR_KEYWORD_REDEFINE =3D _( "Keyword in this section can only be used once: %s.") -ERR_FILELIST_EXIST =3D _( +ERR_FILELIST_EXIST =3D _( 'This file does not exist: %s.') -ERR_COPYRIGHT_CONTENT =3D _( +ERR_COPYRIGHT_CONTENT =3D _( "The copyright content must contain the word \"Copyright\" (case insen= sitive).") -ERR_WRONG_FILELIST_FORMAT =3D \ -_('File list format is incorrect.' - 'The correct format is: filename|key=3Dvalue[|key=3Dvalue]') -ERR_FILELIST_ATTR =3D _( +ERR_WRONG_FILELIST_FORMAT =3D \ + _('File list format is incorrect.' + 'The correct format is: filename|key=3Dvalue[|key=3Dvalue]') +ERR_FILELIST_ATTR =3D _( "The value of attribute \"%s\" includes illegal character.") -ERR_UNKNOWN_FILELIST_ATTR =3D _( +ERR_UNKNOWN_FILELIST_ATTR =3D _( 'Unknown attribute name: %s.') -ERR_EMPTY_VALUE =3D _("Empty value is not allowed") -ERR_KEYWORD_MANDATORY =3D _('This keyword is mandatory: %s') -ERR_BOOLEAN_VALUE =3D _( +ERR_EMPTY_VALUE =3D _("Empty value is not allowed") +ERR_KEYWORD_MANDATORY =3D _('This keyword is mandatory: %s') +ERR_BOOLEAN_VALUE =3D _( 'Value of key [%s] must be true or false, current: [%s]') -ERR_GUID_VALUE =3D _( +ERR_GUID_VALUE =3D _( 'GUID must have the format of 8-4-4-4-12 with HEX value. ' 'Current value: [%s]') -ERR_VERSION_VALUE =3D _( +ERR_VERSION_VALUE =3D _( 'The value of key [%s] must be a decimal number. Found: [%s]') -ERR_VERSION_XMLSPEC =3D _( +ERR_VERSION_XMLSPEC =3D _( 'XmlSpecification value must be 1.1, current: %s.') =20 -ERR_INVALID_GUID =3D _("Incorrect GUID value string: %s") +ERR_INVALID_GUID =3D _("Incorrect GUID value string: %s") =20 -ERR_FILE_NOT_FOUND =3D \ +ERR_FILE_NOT_FOUND =3D \ _("File or directory not found in workspace") -ERR_FILE_OPEN_FAILURE =3D _("Could not open file") -ERR_FILE_WRITE_FAILURE =3D _("Could not write file.") -ERR_FILE_PARSE_FAILURE =3D _("Could not parse file") -ERR_FILE_READ_FAILURE =3D _("Could not read file") -ERR_FILE_CREATE_FAILURE =3D _("Could not create file") -ERR_FILE_CHECKSUM_FAILURE =3D _("Checksum of file is incorrect") -ERR_FILE_COMPRESS_FAILURE =3D _("File compression did not correctly= ") -ERR_FILE_DECOMPRESS_FAILURE =3D \ +ERR_FILE_OPEN_FAILURE =3D _("Could not open file") +ERR_FILE_WRITE_FAILURE =3D _("Could not write file.") +ERR_FILE_PARSE_FAILURE =3D _("Could not parse file") +ERR_FILE_READ_FAILURE =3D _("Could not read file") +ERR_FILE_CREATE_FAILURE =3D _("Could not create file") +ERR_FILE_CHECKSUM_FAILURE =3D _("Checksum of file is incorrect") +ERR_FILE_COMPRESS_FAILURE =3D _("File compression did not correctly") +ERR_FILE_DECOMPRESS_FAILURE =3D \ _("File decompression did not complete correctly") -ERR_FILE_MOVE_FAILURE =3D _("Move file did not complete success= fully") -ERR_FILE_DELETE_FAILURE =3D _("File could not be deleted") -ERR_FILE_COPY_FAILURE =3D _("File did not copy correctly") -ERR_FILE_POSITIONING_FAILURE =3D _("Could not find file seek position") -ERR_FILE_TYPE_MISMATCH =3D _("Incorrect file type") -ERR_FILE_CASE_MISMATCH =3D _("File name case mismatch") -ERR_FILE_DUPLICATED =3D _("Duplicate file found") -ERR_FILE_UNKNOWN_ERROR =3D _("Unknown error encountered on file") -ERR_FILE_NAME_INVALIDE =3D _("This file name is invalid, it must= not be an absolute path or " - "contain a period \".\" or \"..\": %= s.") -ERR_OPTION_UNKNOWN =3D _("Unknown option") -ERR_OPTION_MISSING =3D _("Missing option") -ERR_OPTION_CONFLICT =3D _("Options conflict") -ERR_OPTION_VALUE_INVALID =3D _("Invalid option value") -ERR_OPTION_DEPRECATED =3D _("Deprecated option") -ERR_OPTION_NOT_SUPPORTED =3D _("Unsupported option") -ERR_OPTION_UNKNOWN_ERROR =3D _("Unknown error when processing opti= ons") -ERR_PARAMETER_INVALID =3D _("Invalid parameter") -ERR_PARAMETER_MISSING =3D _("Missing parameter") -ERR_PARAMETER_UNKNOWN_ERROR =3D _("Unknown error in parameters") -ERR_FORMAT_INVALID =3D _("Invalid syntax/format") -ERR_FORMAT_NOT_SUPPORTED =3D _("Syntax/format not supported") -ERR_FORMAT_UNKNOWN =3D _("Unknown format") -ERR_FORMAT_UNKNOWN_ERROR =3D _("Unknown error in syntax/format ") -ERR_RESOURCE_NOT_AVAILABLE =3D _("Not available") -ERR_RESOURCE_ALLOCATE_FAILURE =3D _("A resource allocation has failed") -ERR_RESOURCE_FULL =3D _("Full") -ERR_RESOURCE_OVERFLOW =3D _("Overflow") -ERR_RESOURCE_UNDERRUN =3D _("Underrun") -ERR_RESOURCE_UNKNOWN_ERROR =3D _("Unknown error") -ERR_ATTRIBUTE_NOT_AVAILABLE =3D _("Not available") -ERR_ATTRIBUTE_RETRIEVE_FAILURE =3D _("Unable to retrieve") -ERR_ATTRIBUTE_SET_FAILURE =3D _("Unable to set") -ERR_ATTRIBUTE_UPDATE_FAILURE =3D _("Unable to update") -ERR_ATTRIBUTE_ACCESS_DENIED =3D _("Access denied") -ERR_ATTRIBUTE_UNKNOWN_ERROR =3D _("Unknown error when accessing") -ERR_COMMAND_FAILURE =3D _("Unable to execute command") -ERR_IO_NOT_READY =3D _("Not ready") -ERR_IO_BUSY =3D _("Busy") -ERR_IO_TIMEOUT =3D _("Timeout") -ERR_IO_UNKNOWN_ERROR =3D _("Unknown error in IO operation") -ERR_UNKNOWN_ERROR =3D _("Unknown error") -ERR_UPT_ALREADY_INSTALLED_ERROR =3D _("Already installed") -ERR_UPT_ENVIRON_MISSING_ERROR =3D _("Environ missing") -ERR_UPT_REPKG_ERROR =3D _("File not allowed for RePackage") -ERR_UPT_DB_UPDATE_ERROR =3D _("Update database did not complete s= uccessfully") -ERR_UPT_INI_PARSE_ERROR =3D _("INI file parse error") -ERR_COPYRIGHT_MISSING =3D \ -_("Header comment section must have copyright information") -ERR_LICENSE_MISSING =3D \ -_("Header comment section must have license information") -ERR_INVALID_BINARYHEADER_FORMAT =3D \ -_("Binary Header comment section must have abstract,description,copyright,= license information") +ERR_FILE_MOVE_FAILURE =3D _("Move file did not complete successfully") +ERR_FILE_DELETE_FAILURE =3D _("File could not be deleted") +ERR_FILE_COPY_FAILURE =3D _("File did not copy correctly") +ERR_FILE_POSITIONING_FAILURE =3D _("Could not find file seek position") +ERR_FILE_TYPE_MISMATCH =3D _("Incorrect file type") +ERR_FILE_CASE_MISMATCH =3D _("File name case mismatch") +ERR_FILE_DUPLICATED =3D _("Duplicate file found") +ERR_FILE_UNKNOWN_ERROR =3D _("Unknown error encountered on file") +ERR_FILE_NAME_INVALIDE =3D _("This file name is invalid, it must not be an= absolute path or " + "contain a period \".\" or \"..\": %s.") +ERR_OPTION_UNKNOWN =3D _("Unknown option") +ERR_OPTION_MISSING =3D _("Missing option") +ERR_OPTION_CONFLICT =3D _("Options conflict") +ERR_OPTION_VALUE_INVALID =3D _("Invalid option value") +ERR_OPTION_DEPRECATED =3D _("Deprecated option") +ERR_OPTION_NOT_SUPPORTED =3D _("Unsupported option") +ERR_OPTION_UNKNOWN_ERROR =3D _("Unknown error when processing options") +ERR_PARAMETER_INVALID =3D _("Invalid parameter") +ERR_PARAMETER_MISSING =3D _("Missing parameter") +ERR_PARAMETER_UNKNOWN_ERROR =3D _("Unknown error in parameters") +ERR_FORMAT_INVALID =3D _("Invalid syntax/format") +ERR_FORMAT_NOT_SUPPORTED =3D _("Syntax/format not supported") +ERR_FORMAT_UNKNOWN =3D _("Unknown format") +ERR_FORMAT_UNKNOWN_ERROR =3D _("Unknown error in syntax/format ") +ERR_RESOURCE_NOT_AVAILABLE =3D _("Not available") +ERR_RESOURCE_ALLOCATE_FAILURE =3D _("A resource allocation has failed") +ERR_RESOURCE_FULL =3D _("Full") +ERR_RESOURCE_OVERFLOW =3D _("Overflow") +ERR_RESOURCE_UNDERRUN =3D _("Underrun") +ERR_RESOURCE_UNKNOWN_ERROR =3D _("Unknown error") +ERR_ATTRIBUTE_NOT_AVAILABLE =3D _("Not available") +ERR_ATTRIBUTE_RETRIEVE_FAILURE =3D _("Unable to retrieve") +ERR_ATTRIBUTE_SET_FAILURE =3D _("Unable to set") +ERR_ATTRIBUTE_UPDATE_FAILURE =3D _("Unable to update") +ERR_ATTRIBUTE_ACCESS_DENIED =3D _("Access denied") +ERR_ATTRIBUTE_UNKNOWN_ERROR =3D _("Unknown error when accessing") +ERR_COMMAND_FAILURE =3D _("Unable to execute command") +ERR_IO_NOT_READY =3D _("Not ready") +ERR_IO_BUSY =3D _("Busy") +ERR_IO_TIMEOUT =3D _("Timeout") +ERR_IO_UNKNOWN_ERROR =3D _("Unknown error in IO operation") +ERR_UNKNOWN_ERROR =3D _("Unknown error") +ERR_UPT_ALREADY_INSTALLED_ERROR =3D _("Already installed") +ERR_UPT_ENVIRON_MISSING_ERROR =3D _("Environ missing") +ERR_UPT_REPKG_ERROR =3D _("File not allowed for RePackage") +ERR_UPT_DB_UPDATE_ERROR =3D _("Update database did not complete successful= ly") +ERR_UPT_INI_PARSE_ERROR =3D _("INI file parse error") +ERR_COPYRIGHT_MISSING =3D \ + _("Header comment section must have copyright information") +ERR_LICENSE_MISSING =3D \ + _("Header comment section must have license information") +ERR_INVALID_BINARYHEADER_FORMAT =3D \ + _("Binary Header comment section must have abstract,description,copyri= ght,license information") ERR_MULTIPLE_BINARYHEADER_EXIST =3D \ -_("the inf file at most support one BinaryHeader at the fileheader section= .") -ERR_INVALID_COMMENT_FORMAT =3D _("Comment must start with #") -ERR_USER_ABORT =3D _("User has stopped the application") -ERR_DIST_EXT_ERROR =3D \ -_("Distribution file extension should be '.dist'. Current given: '%s'.") -ERR_DIST_FILENAME_ONLY_FOR_REMOVE =3D \ -_("Only distribution filename without path allowed during remove. Current = given: '%s'.") -ERR_NOT_STANDALONE_MODULE_ERROR =3D \ + _("the inf file at most support one BinaryHeader at the fileheader sec= tion.") +ERR_INVALID_COMMENT_FORMAT =3D _("Comment must start with #") +ERR_USER_ABORT =3D _("User has stopped the application") +ERR_DIST_EXT_ERROR =3D \ + _("Distribution file extension should be '.dist'. Current given: '%s'.= ") +ERR_DIST_FILENAME_ONLY_FOR_REMOVE =3D \ + _("Only distribution filename without path allowed during remove. Curr= ent given: '%s'.") +ERR_NOT_STANDALONE_MODULE_ERROR =3D \ _("Module %s is not a standalone module (found in Package %s)") -ERR_UPT_ALREADY_RUNNING_ERROR =3D \ +ERR_UPT_ALREADY_RUNNING_ERROR =3D \ _("UPT is already running, only one instance is allowed") -ERR_MUL_DEC_ERROR =3D _("Multiple DEC files found within one package direc= tory tree %s: %s, %s") -ERR_INSTALL_FILE_FROM_EMPTY_CONTENT =3D _("Error file to be installed is n= ot found in content file: %s") +ERR_MUL_DEC_ERROR =3D _( + "Multiple DEC files found within one package directory tree %s: %s, %s= ") +ERR_INSTALL_FILE_FROM_EMPTY_CONTENT =3D _( + "Error file to be installed is not found in content file: %s") ERR_INSTALL_FILE_DEC_FILE_ERROR =3D _("Could not obtain the TokenSpaceGuid= CName and the PcdCName from the DEC files " -"that the package depends on for this pcd entry: TokenValue: %s Token: %s") -ERR_NOT_SUPPORTED_SA_MODULE =3D _("Stand-alone module distribution does no= t allow EDK 1 INF") -ERR_INSTALL_DIST_NOT_FOUND =3D \ -_("Distribution file to be installed is not found in current working direc= tory or workspace: %s") -ERR_REPLACE_DIST_NOT_FOUND =3D \ -_("Distribution file for replace function was not found in the current wor= king directory or workspace: %s") -ERR_DIST_FILENAME_ONLY_FOR_REPLACE_ORIG =3D \ -_("Only a distribution file name without a path is allowed for " - "the distribution to be replaced during replace. Current given: '%s'.") + "that the package depends on for this = pcd entry: TokenValue: %s Token: %s") +ERR_NOT_SUPPORTED_SA_MODULE =3D _( + "Stand-alone module distribution does not allow EDK 1 INF") +ERR_INSTALL_DIST_NOT_FOUND =3D \ + _("Distribution file to be installed is not found in current working d= irectory or workspace: %s") +ERR_REPLACE_DIST_NOT_FOUND =3D \ + _("Distribution file for replace function was not found in the current= working directory or workspace: %s") +ERR_DIST_FILENAME_ONLY_FOR_REPLACE_ORIG =3D \ + _("Only a distribution file name without a path is allowed for " + "the distribution to be replaced during replace. Current given: '%s'= .") ERR_UNIPARSE_DBLQUOTE_UNMATCHED =3D \ -_("Only Language entry can contain a couple of matched quote in one line") -ERR_UNIPARSE_NO_SECTION_EXIST =3D _("No PackageDef or ModuleDef section ex= ists in the UNI file.") -ERR_UNIPARSE_STRNAME_FORMAT_ERROR =3D _("The String Token Name %s must sta= rt with \"STR_\"") -ERR_UNIPARSE_SEP_LANGENTRY_LINE =3D _("Each should be in a sep= arate line :%s.") + _("Only Language entry can contain a couple of matched quote in one li= ne") +ERR_UNIPARSE_NO_SECTION_EXIST =3D _( + "No PackageDef or ModuleDef section exists in the UNI file.") +ERR_UNIPARSE_STRNAME_FORMAT_ERROR =3D _( + "The String Token Name %s must start with \"STR_\"") +ERR_UNIPARSE_SEP_LANGENTRY_LINE =3D _( + "Each should be in a separate line :%s.") ERR_UNIPARSE_MULTI_ENTRY_EXIST =3D \ -_("There are same entries : %s in the UNI file, every kind of entry should= be only one.") + _("There are same entries : %s in the UNI file, every kind of entry sh= ould be only one.") ERR_UNIPARSE_ENTRY_ORDER_WRONG =3D \ -_("The string entry order in UNI file should be , , \ + _("The string entry order in UNI file should be , , \ , .") -ERR_UNIPARSE_STRTOKEN_FORMAT_ERROR =3D _("The String Token Type %s must be= one of the '_PROMPT', '_HELP' and '_ERR_'.") -ERR_UNIPARSE_LINEFEED_UNDER_EXIST =3D _("Line feed should not exist under = this line: %s.") -ERR_UNIPARSE_LINEFEED_UP_EXIST =3D _("Line feed should not exist up this l= ine: %s.") +ERR_UNIPARSE_STRTOKEN_FORMAT_ERROR =3D _( + "The String Token Type %s must be one of the '_PROMPT', '_HELP' and '_= ERR_'.") +ERR_UNIPARSE_LINEFEED_UNDER_EXIST =3D _( + "Line feed should not exist under this line: %s.") +ERR_UNIPARSE_LINEFEED_UP_EXIST =3D _( + "Line feed should not exist up this line: %s.") ERR_UNI_MISS_STRING_ENTRY =3D _("String entry missed in this Entry, %s.") ERR_UNI_MISS_LANGENTRY =3D _("Language entry missed in this Entry, %s.") -ERR_BINARY_HEADER_ORDER =3D _("Binary header must follow the fil= e header.") -ERR_NO_SOURCE_HEADER =3D _("File header statement \"## @file\= " must exist at the first place.") -ERR_UNI_FILE_SUFFIX_WRONG =3D _("The UNI file must have an extension of '.= uni', '.UNI' or '.Uni'") -ERR_UNI_FILE_NAME_INVALID =3D _("The use of '..', '../' and './' in the UN= I file is prohibited.") +ERR_BINARY_HEADER_ORDER =3D _("Binary header must follow the file header.") +ERR_NO_SOURCE_HEADER =3D _( + "File header statement \"## @file\" must exist at the first place.") +ERR_UNI_FILE_SUFFIX_WRONG =3D _( + "The UNI file must have an extension of '.uni', '.UNI' or '.Uni'") +ERR_UNI_FILE_NAME_INVALID =3D _( + "The use of '..', '../' and './' in the UNI file is prohibited.") ERR_UNI_SUBGUID_VALUE_DEFINE_DEC_NOT_FOUND =3D _("There are no DEC file to= define the GUID value for \ this GUID CName: '%s'.") =20 # # Expression error message # -ERR_EXPR_RIGHT_PAREN =3D \ -_('Missing ")" in expression "%s".') -ERR_EXPR_FACTOR =3D \ -_('"%s" is expected to be HEX, integer, macro, quoted string or PcdName in= ' - 'expression "%s".') -ERR_EXPR_STRING_ITEM =3D \ -_('"%s" is expected to be HEX, integer, macro, quoted string or PcdName in= ' - 'expression [%s].') -ERR_EXPR_EQUALITY =3D \ -_('"%s" is expected to be =3D=3D, EQ, !=3D or NE in expression "%s".') -ERR_EXPR_BOOLEAN =3D \ -_('The string "%s" in expression "%s" can not be recognized as a part of t= he logical expression.') -ERR_EXPR_EMPTY =3D _('Boolean value cannot be empty.') -ERR_EXPRESS_EMPTY =3D _('Expression can not be empty.') -ERR_EXPR_LOGICAL =3D \ -_('The following is not a valid logical expression: "%s".') -ERR_EXPR_OR =3D _('The expression: "%s" must be encaps= ulated in open "(" and close ")" ' - 'parenthesis when using | or ||.') -ERR_EXPR_RANGE =3D \ -_('The following is not a valid range expression: "%s".') -ERR_EXPR_RANGE_FACTOR =3D \ -_('"%s" is expected to be HEX, integer in valid range expression "%s".') +ERR_EXPR_RIGHT_PAREN =3D \ + _('Missing ")" in expression "%s".') +ERR_EXPR_FACTOR =3D \ + _('"%s" is expected to be HEX, integer, macro, quoted string or PcdNam= e in ' + 'expression "%s".') +ERR_EXPR_STRING_ITEM =3D \ + _('"%s" is expected to be HEX, integer, macro, quoted string or PcdNam= e in ' + 'expression [%s].') +ERR_EXPR_EQUALITY =3D \ + _('"%s" is expected to be =3D=3D, EQ, !=3D or NE in expression "%s".') +ERR_EXPR_BOOLEAN =3D \ + _('The string "%s" in expression "%s" can not be recognized as a part = of the logical expression.') +ERR_EXPR_EMPTY =3D _('Boolean value cannot be empty.') +ERR_EXPRESS_EMPTY =3D _('Expression can not be empty.') +ERR_EXPR_LOGICAL =3D \ + _('The following is not a valid logical expression: "%s".') +ERR_EXPR_OR =3D _('The expression: "%s" must be encapsulated in open "(" a= nd close ")" ' + 'parenthesis when using | or ||.') +ERR_EXPR_RANGE =3D \ + _('The following is not a valid range expression: "%s".') +ERR_EXPR_RANGE_FACTOR =3D \ + _('"%s" is expected to be HEX, integer in valid range expression "%s".= ') ERR_EXPR_RANGE_DOUBLE_PAREN_NESTED =3D \ -_('Double parentheses nested is not allowed in valid range expression: "%s= ".') -ERR_EXPR_RANGE_EMPTY =3D _('Valid range can not be empty.') -ERR_EXPR_LIST_EMPTY =3D _('Valid list can not be empty.') -ERR_PAREN_NOT_USED =3D _('Parenthesis must be used on both si= des of "OR", "AND" in valid range : %s.') -ERR_EXPR_LIST =3D \ -_('The following is not a valid list expression: "%s".') + _('Double parentheses nested is not allowed in valid range expression:= "%s".') +ERR_EXPR_RANGE_EMPTY =3D _('Valid range can not be empty.') +ERR_EXPR_LIST_EMPTY =3D _('Valid list can not be empty.') +ERR_PAREN_NOT_USED =3D _( + 'Parenthesis must be used on both sides of "OR", "AND" in valid range = : %s.') +ERR_EXPR_LIST =3D \ + _('The following is not a valid list expression: "%s".') =20 =20 # DEC parser error message # -ERR_DECPARSE_STATEMENT_EMPTY =3D \ -_('Must have at least one statement in section %s.') -ERR_DECPARSE_DEFINE_DEFINED =3D \ -_('%s already defined in define section.') -ERR_DECPARSE_DEFINE_SECNAME =3D \ -_('No arch and others can be followed for define section.') -ERR_DECPARSE_DEFINE_MULTISEC =3D \ -_('The DEC file does not allow multiple define sections.') -ERR_DECPARSE_DEFINE_REQUIRED =3D \ -_("Field [%s] is required in define section.") -ERR_DECPARSE_DEFINE_FORMAT =3D \ -_("Wrong define section format, must be KEY =3D Value.") -ERR_DECPARSE_DEFINE_UNKNOWKEY =3D \ -_("Unknown key [%s] in define section.") -ERR_DECPARSE_DEFINE_SPEC =3D \ -_("Specification value must be HEX numbers or decimal numbers.") -ERR_DECPARSE_DEFINE_PKGNAME =3D \ -_("Package name must be AlphaNumeric characters.") -ERR_DECPARSE_DEFINE_PKGGUID =3D \ -_("GUID format error, must be HEX value with form 8-4-4-4-12.") -ERR_DECPARSE_DEFINE_PKGVERSION =3D \ -_("Version number must be decimal number.") -ERR_DECPARSE_DEFINE_PKGVUNI =3D \ -_("UNI file name format error or file does not exist.") -ERR_DECPARSE_INCLUDE =3D \ -_("Incorrect path: [%s].") -ERR_DECPARSE_LIBCLASS_SPLIT =3D \ -_("Library class format error, must be Libraryclass|Headerpath.") -ERR_DECPARSE_LIBCLASS_EMPTY =3D \ -_("Class name or file name must not be empty.") -ERR_DECPARSE_LIBCLASS_LIB =3D \ -_("Class name format error, must start with upper case letter followed wit= h " - "zero or more alphanumeric characters.") -ERR_DECPARSE_LIBCLASS_PATH_EXT =3D _("File name must be end with .h.") -ERR_DECPARSE_LIBCLASS_PATH_DOT =3D _("Path must not include '..'.") -ERR_DECPARSE_LIBCLASS_PATH_EXIST =3D _("File name [%s] does not exist.") -ERR_DECPARSE_PCD_CVAR_GUID =3D \ -_("TokenSpaceGuidCName must be valid C variable format.") -ERR_DECPARSE_PCD_SPLIT =3D \ -_("Incorrect PcdName. The format must be TokenSpaceGuidCName.PcdCName" - "|PcdData|PcdType|Token.") -ERR_DECPARSE_PCD_NAME =3D \ -_("Incorrect PCD name. The correct format must be " - "..") -ERR_DECPARSE_PCD_CVAR_PCDCNAME =3D \ -_("PcdCName must be valid C variable format.") -ERR_DECPARSE_PCD_TYPE =3D \ -_('Incorrect PCD data type. A PCD data type must be one of ' - '"UINT8", "UINT16", "UINT32", "UINT64", "VOID*", "BOOLEAN".') -ERR_DECPARSE_PCD_VOID =3D \ -_("Incorrect value [%s] of type [%s]. Value must be printable and in th= e " - "form of{...} for array, or ""..."" for string, or L""...""" - "for unicode string.") -ERR_DECPARSE_PCD_VALUE_EMPTY =3D \ -_("Pcd value can not be empty.") -ERR_DECPARSE_PCD_BOOL =3D \ -_("Invalid value [%s] of type [%s]; must be expression, TRUE, FALSE, 0 or = 1.") -ERR_DECPARSE_PCD_INT =3D _("Incorrect value [%s] of type [%= s]."\ -" Value must be a hexadecimal, decimal or octal in C language format.") -ERR_DECPARSE_PCD_INT_NEGTIVE =3D _("Incorrect value [%s] of type [%= s];" - " must not be signed number.") -ERR_DECPARSE_PCD_INT_EXCEED =3D _("Incorrect value [%s] of type [%= s]; " - "the number is too long for this type.= ") -ERR_DECPARSE_PCD_FEATUREFLAG =3D \ -_("PcdFeatureFlag only allow BOOLEAN type.") -ERR_DECPARSE_PCD_TOKEN =3D \ -_("An incorrect PCD token found: [%s]. " - "It must start with 0x followed by 1 - 8 hexadecimal. ") -ERR_DECPARSE_PCD_TOKEN_INT =3D _("Incorrect token number [%s]. " - "This token number exceeds the maximal value of unsigned 32.") -ERR_DECPARSE_PCD_TOKEN_UNIQUE =3D _("Token number must be unique to = the token space: %s.") -ERR_DECPARSE_CGUID =3D \ -_("No GUID name or value specified, must be =3D .") -ERR_DECPARSE_CGUID_NAME =3D \ -_("No GUID name specified, must be =3D .") -ERR_DECPARSE_CGUID_GUID =3D \ -_("No GUID value specified, must be =3D .") -ERR_DECPARSE_CGUID_GUIDFORMAT =3D \ -_("Incorrect GUID value format, must be .") -ERR_DECPARSE_CGUID_NOT_FOUND =3D _("Unable to find the GUID value of this = GUID CName : '%s'.") -ERR_DECPARSE_FILEOPEN =3D _("Unable to open: [%s].") -ERR_DECPARSE_SECTION_EMPTY =3D _("Empty sections are not allowed.= ") -ERR_DECPARSE_SECTION_UE =3D _("Incorrect UserExtensions format= . " +ERR_DECPARSE_STATEMENT_EMPTY =3D \ + _('Must have at least one statement in section %s.') +ERR_DECPARSE_DEFINE_DEFINED =3D \ + _('%s already defined in define section.') +ERR_DECPARSE_DEFINE_SECNAME =3D \ + _('No arch and others can be followed for define section.') +ERR_DECPARSE_DEFINE_MULTISEC =3D \ + _('The DEC file does not allow multiple define sections.') +ERR_DECPARSE_DEFINE_REQUIRED =3D \ + _("Field [%s] is required in define section.") +ERR_DECPARSE_DEFINE_FORMAT =3D \ + _("Wrong define section format, must be KEY =3D Value.") +ERR_DECPARSE_DEFINE_UNKNOWKEY =3D \ + _("Unknown key [%s] in define section.") +ERR_DECPARSE_DEFINE_SPEC =3D \ + _("Specification value must be HEX numbers or decimal numbers.") +ERR_DECPARSE_DEFINE_PKGNAME =3D \ + _("Package name must be AlphaNumeric characters.") +ERR_DECPARSE_DEFINE_PKGGUID =3D \ + _("GUID format error, must be HEX value with form 8-4-4-4-12.") +ERR_DECPARSE_DEFINE_PKGVERSION =3D \ + _("Version number must be decimal number.") +ERR_DECPARSE_DEFINE_PKGVUNI =3D \ + _("UNI file name format error or file does not exist.") +ERR_DECPARSE_INCLUDE =3D \ + _("Incorrect path: [%s].") +ERR_DECPARSE_LIBCLASS_SPLIT =3D \ + _("Library class format error, must be Libraryclass|Headerpath.") +ERR_DECPARSE_LIBCLASS_EMPTY =3D \ + _("Class name or file name must not be empty.") +ERR_DECPARSE_LIBCLASS_LIB =3D \ + _("Class name format error, must start with upper case letter followed= with " + "zero or more alphanumeric characters.") +ERR_DECPARSE_LIBCLASS_PATH_EXT =3D _("File name must be end with .h.") +ERR_DECPARSE_LIBCLASS_PATH_DOT =3D _("Path must not include '..'.") +ERR_DECPARSE_LIBCLASS_PATH_EXIST =3D _("File name [%s] does not exist.") +ERR_DECPARSE_PCD_CVAR_GUID =3D \ + _("TokenSpaceGuidCName must be valid C variable format.") +ERR_DECPARSE_PCD_SPLIT =3D \ + _("Incorrect PcdName. The format must be TokenSpaceGuidCName.PcdCName" + "|PcdData|PcdType|Token.") +ERR_DECPARSE_PCD_NAME =3D \ + _("Incorrect PCD name. The correct format must be " + "..") +ERR_DECPARSE_PCD_CVAR_PCDCNAME =3D \ + _("PcdCName must be valid C variable format.") +ERR_DECPARSE_PCD_TYPE =3D \ + _('Incorrect PCD data type. A PCD data type must be one of ' + '"UINT8", "UINT16", "UINT32", "UINT64", "VOID*", "BOOLEAN".') +ERR_DECPARSE_PCD_VOID =3D \ + _("Incorrect value [%s] of type [%s]. Value must be printable and i= n the " + "form of{...} for array, or ""..."" for string, or L""...""" + "for unicode string.") +ERR_DECPARSE_PCD_VALUE_EMPTY =3D \ + _("Pcd value can not be empty.") +ERR_DECPARSE_PCD_BOOL =3D \ + _("Invalid value [%s] of type [%s]; must be expression, TRUE, FALSE, 0= or 1.") +ERR_DECPARSE_PCD_INT =3D _("Incorrect value [%s] of type [%s]." + " Value must be a hexadecimal, decimal or octal i= n C language format.") +ERR_DECPARSE_PCD_INT_NEGTIVE =3D _("Incorrect value [%s] of type [%s];" + " must not be signed number.") +ERR_DECPARSE_PCD_INT_EXCEED =3D _("Incorrect value [%s] of type [%s]; " + "the number is too long for this type.") +ERR_DECPARSE_PCD_FEATUREFLAG =3D \ + _("PcdFeatureFlag only allow BOOLEAN type.") +ERR_DECPARSE_PCD_TOKEN =3D \ + _("An incorrect PCD token found: [%s]. " + "It must start with 0x followed by 1 - 8 hexadecimal. ") +ERR_DECPARSE_PCD_TOKEN_INT =3D _("Incorrect token number [%s]. " + "This token number exceeds the maximal valu= e of unsigned 32.") +ERR_DECPARSE_PCD_TOKEN_UNIQUE =3D _( + "Token number must be unique to the token space: %s.") +ERR_DECPARSE_CGUID =3D \ + _("No GUID name or value specified, must be =3D .") +ERR_DECPARSE_CGUID_NAME =3D \ + _("No GUID name specified, must be =3D .") +ERR_DECPARSE_CGUID_GUID =3D \ + _("No GUID value specified, must be =3D .") +ERR_DECPARSE_CGUID_GUIDFORMAT =3D \ + _("Incorrect GUID value format, must be .") +ERR_DECPARSE_CGUID_NOT_FOUND =3D _( + "Unable to find the GUID value of this GUID CName : '%s'.") +ERR_DECPARSE_FILEOPEN =3D _("Unable to open: [%s].") +ERR_DECPARSE_SECTION_EMPTY =3D _("Empty sections are not allowed.") +ERR_DECPARSE_SECTION_UE =3D _("Incorrect UserExtensions format. " "Must be UserExtenxions.UserId.IdString[.Arch]= +.") -ERR_DECPARSE_SECTION_UE_USERID =3D _("Invalid UserId, must be undersc= ore" - "or alphanumeric characters.") -ERR_DECPARSE_SECTION_UE_IDSTRING =3D \ +ERR_DECPARSE_SECTION_UE_USERID =3D _("Invalid UserId, must be underscore" + "or alphanumeric characters.") +ERR_DECPARSE_SECTION_UE_IDSTRING =3D \ _("Incorrect IdString, must be \" ... \".") -ERR_DECPARSE_ARCH =3D \ -_("Unknown arch, must be 'common' or start with upper case letter followed= by" - " zero or more upper case letters and numbers.= ") -ERR_DECPARSE_SECTION_COMMA =3D _("Section cannot end with comma.") -ERR_DECPARSE_SECTION_COMMON =3D \ -_("'COMMON' must not be used with specific ARCHs in the same section.") -ERR_DECPARSE_SECTION_IDENTIFY =3D \ -_("Section header must start with and end with brackets[].") -ERR_DECPARSE_SECTION_SUBEMPTY =3D \ -_("Missing a sub-section name in section: [%s]. " - "All sub-sections need to have names. ") -ERR_DECPARSE_SECTION_SUBTOOMANY =3D _("Too many DOT splits in [%s].") -ERR_DECPARSE_SECTION_UNKNOW =3D _("Section name [%s] unknown.") -ERR_DECPARSE_SECTION_FEATUREFLAG =3D \ -_("[%s] must not be in the same section as other types of PCD.") -ERR_DECPARSE_MACRO_PAIR =3D _("No macro name/value given.") -ERR_DECPARSE_MACRO_NAME =3D _("No macro name given.") -ERR_DECPARSE_MACRO_NAME_UPPER =3D \ -_("Macro name must start with upper case letter followed " -"by zero or more upper case letters or numbers. Current macro name is: [%= s].") -ERR_DECPARSE_SECTION_NAME =3D \ -_('Cannot mix different section names %s.') -ERR_DECPARSE_BACKSLASH =3D \ -_('Backslash must be the last character on a line and ' - 'preceded by a space character.') -ERR_DECPARSE_BACKSLASH_EMPTY =3D \ -_('Empty line after previous line that has backslash is not allowed.') -ERR_DECPARSE_REDEFINE =3D _( +ERR_DECPARSE_ARCH =3D \ + _("Unknown arch, must be 'common' or start with upper case letter foll= owed by" + " zero or more upper case letters and numbers.") +ERR_DECPARSE_SECTION_COMMA =3D _("Section cannot end with comma.") +ERR_DECPARSE_SECTION_COMMON =3D \ + _("'COMMON' must not be used with specific ARCHs in the same section.") +ERR_DECPARSE_SECTION_IDENTIFY =3D \ + _("Section header must start with and end with brackets[].") +ERR_DECPARSE_SECTION_SUBEMPTY =3D \ + _("Missing a sub-section name in section: [%s]. " + "All sub-sections need to have names. ") +ERR_DECPARSE_SECTION_SUBTOOMANY =3D _("Too many DOT splits in [%s].") +ERR_DECPARSE_SECTION_UNKNOW =3D _("Section name [%s] unknown.") +ERR_DECPARSE_SECTION_FEATUREFLAG =3D \ + _("[%s] must not be in the same section as other types of PCD.") +ERR_DECPARSE_MACRO_PAIR =3D _("No macro name/value given.") +ERR_DECPARSE_MACRO_NAME =3D _("No macro name given.") +ERR_DECPARSE_MACRO_NAME_UPPER =3D \ + _("Macro name must start with upper case letter followed " + "by zero or more upper case letters or numbers. Current macro name = is: [%s].") +ERR_DECPARSE_SECTION_NAME =3D \ + _('Cannot mix different section names %s.') +ERR_DECPARSE_BACKSLASH =3D \ + _('Backslash must be the last character on a line and ' + 'preceded by a space character.') +ERR_DECPARSE_BACKSLASH_EMPTY =3D \ + _('Empty line after previous line that has backslash is not allowed.') +ERR_DECPARSE_REDEFINE =3D _( "\"%s\" already defined in line %d.") -ERR_DECPARSE_MACRO_RESOLVE =3D _("Macro %s in %s cannot be resolv= ed.") -ERR_DECPARSE_UE_DUPLICATE =3D \ +ERR_DECPARSE_MACRO_RESOLVE =3D _("Macro %s in %s cannot be resolved.") +ERR_DECPARSE_UE_DUPLICATE =3D \ _("Duplicated UserExtensions header found.") ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT =3D \ _("Missing '|' between Pcd's error code and Pcd's error message.") @@ -763,36 +794,38 @@ ERR_DECPARSE_PCD_MISS_ERRORMSG =3D \ _("Missing Pcd's error message.") ERR_DECPARSE_PCD_UNMATCHED_ERRORCODE =3D \ _("There is no error message matched with this Pcd error code : %s in = both DEC and UNI file.") -ERR_DECPARSE_PCD_NODEFINED =3D _("The PCD : %s used in the Expression is u= ndefined.") +ERR_DECPARSE_PCD_NODEFINED =3D _( + "The PCD : %s used in the Expression is undefined.") # # Used to print the current line content which cause error raise. # Be attached to the end of every error message above. # -ERR_DECPARSE_LINE =3D _(" Parsing line: \"%s\".") +ERR_DECPARSE_LINE =3D _(" Parsing line: \"%s\".") =20 # # Warning related strings. # -WRN_PACKAGE_EXISTED =3D _( +WRN_PACKAGE_EXISTED =3D _( "A package with this GUID and Version already exists: " "GUID %s, Version %s.") -WRN_MODULE_EXISTED =3D _("This module already exists: %s") -WRN_FILE_EXISTED =3D _("This file already exists: %s") -WRN_FILE_NOT_OVERWRITTEN =3D \ -_("This file already exist and cannot be overwritten: %s") -WRN_DIST_PKG_INSTALLED =3D _("This distribution package %s has previously = been installed.") -WRN_DIST_NOT_FOUND =3D _( +WRN_MODULE_EXISTED =3D _("This module already exists: %s") +WRN_FILE_EXISTED =3D _("This file already exists: %s") +WRN_FILE_NOT_OVERWRITTEN =3D \ + _("This file already exist and cannot be overwritten: %s") +WRN_DIST_PKG_INSTALLED =3D _( + "This distribution package %s has previously been installed.") +WRN_DIST_NOT_FOUND =3D _( "Distribution is not found at location %s") -WRN_MULTI_PCD_RANGES =3D _( +WRN_MULTI_PCD_RANGES =3D _( "A PCD can only have one type of @ValidRange, @ValidList, and @Express= ion comment") -WRN_MULTI_PCD_VALIDVALUE =3D _( +WRN_MULTI_PCD_VALIDVALUE =3D _( "A PCD can only have one of @ValidList comment") -WRN_MULTI_PCD_PROMPT =3D _( +WRN_MULTI_PCD_PROMPT =3D _( "A PCD can only have one of @Prompt comment") -WRN_MISSING_USAGE =3D _("Missing usage") -WRN_INVALID_GUID_TYPE =3D _("This is and incorrect Guid type: %= s") -WRN_MISSING_GUID_TYPE =3D _("Missing Guid Type") -WRN_INVALID_USAGE =3D _("This is an incorrect Usage: %s") +WRN_MISSING_USAGE =3D _("Missing usage") +WRN_INVALID_GUID_TYPE =3D _("This is and incorrect Guid type: %s") +WRN_MISSING_GUID_TYPE =3D _("Missing Guid Type") +WRN_INVALID_USAGE =3D _("This is an incorrect Usage: %s") WRN_INF_PARSER_MODULE_INVALID_HOB_TYPE =3D \ _("This is an incorrect HOB type: %s") WRN_INF_PARSER_MODULE_INVALID_EVENT_TYPE =3D \ @@ -817,37 +850,37 @@ WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH =3D \ # # Help related strings. # -HLP_PRINT_DEBUG_INFO =3D _( +HLP_PRINT_DEBUG_INFO =3D _( "Print DEBUG statements, where DEBUG_LEVEL is 0-9") HLP_PRINT_INFORMATIONAL_STATEMENT =3D _("Print informational statements") -HLP_RETURN_NO_DISPLAY =3D _( +HLP_RETURN_NO_DISPLAY =3D _( "Returns only the exit code, informational and error messages are" " not displayed") -HLP_RETURN_AND_DISPLAY =3D _( +HLP_RETURN_AND_DISPLAY =3D _( "Returns the exit code and displays error messages only") HLP_SPECIFY_PACKAGE_NAME_INSTALL =3D _( "Specify the UEFI Distribution Package filename to install") -HLP_SPECIFY_PACKAGE_NAME_CREATE =3D _( +HLP_SPECIFY_PACKAGE_NAME_CREATE =3D _( "Specify the UEFI Distribution Package filename to create") -HLP_SPECIFY_PACKAGE_NAME_REMOVE =3D _( +HLP_SPECIFY_PACKAGE_NAME_REMOVE =3D _( "Specify the UEFI Distribution Package filename to remove") HLP_SPECIFY_TEMPLATE_NAME_CREATE =3D _( "Specify Package Information Data filename to create package") -HLP_SPECIFY_DEC_NAME_CREATE =3D _( +HLP_SPECIFY_DEC_NAME_CREATE =3D _( "Specify dec file names to create package") -HLP_SPECIFY_INF_NAME_CREATE =3D _( +HLP_SPECIFY_INF_NAME_CREATE =3D _( "Specify inf file names to create package") -HLP_LIST_DIST_INSTALLED =3D _( +HLP_LIST_DIST_INSTALLED =3D _( "List the UEFI Distribution Packages that have been installed") -HLP_NO_SUPPORT_GUI =3D _( +HLP_NO_SUPPORT_GUI =3D _( "Starting the tool in graphical mode is not supported in this version") -HLP_DISABLE_PROMPT =3D _( +HLP_DISABLE_PROMPT =3D _( "Disable user prompts for removing modified files. Valid only when -r = is present") -HLP_CUSTOM_PATH_PROMPT =3D _( +HLP_CUSTOM_PATH_PROMPT =3D _( "Enable user prompting for alternate installation directories") -HLP_SKIP_LOCK_CHECK =3D _( +HLP_SKIP_LOCK_CHECK =3D _( "Skip the check for multiple instances") -HLP_SPECIFY_PACKAGE_NAME_REPLACE =3D _( +HLP_SPECIFY_PACKAGE_NAME_REPLACE =3D _( "Specify the UEFI Distribution Package file name to replace the existi= ng file name") HLP_SPECIFY_PACKAGE_NAME_TO_BE_REPLACED =3D _( "Specify the UEFI Distribution Package file name to be replaced") @@ -856,5 +889,7 @@ HLP_USE_GUIDED_PATHS =3D _( HLP_TEST_INSTALL =3D _( "Specify the UEFI Distribution Package filenames to install") =20 -MSG_TEST_INSTALL_PASS =3D _("All distribution package file are satisfied f= or dependence check.") -MSG_TEST_INSTALL_FAIL =3D _("NOT all distribution package file are satisfi= ed for dependence check.") +MSG_TEST_INSTALL_PASS =3D _( + "All distribution package file are satisfied for dependence check.") +MSG_TEST_INSTALL_FAIL =3D _( + "NOT all distribution package file are satisfied for dependence check.= ") diff --git a/BaseTools/Source/Python/UPT/Logger/ToolError.py b/BaseTools/So= urce/Python/UPT/Logger/ToolError.py index 925982beb346..32a7fcfcb977 100644 --- a/BaseTools/Source/Python/UPT/Logger/ToolError.py +++ b/BaseTools/Source/Python/UPT/Logger/ToolError.py @@ -1,4 +1,4 @@ -## @file +# @file # Standardized Error Handling infrastructures. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -94,78 +94,79 @@ UPT_MUL_DEC_ERROR =3D 0xD004 UPT_DB_UPDATE_ERROR =3D 0xD005 UPT_INI_PARSE_ERROR =3D 0xE000 =20 -## Error message of each error code +# Error message of each error code # gERROR_MESSAGE =3D { - FILE_NOT_FOUND : ST.ERR_FILE_NOT_FOUND, - FILE_OPEN_FAILURE : ST.ERR_FILE_OPEN_FAILURE, - FILE_WRITE_FAILURE : ST.ERR_FILE_WRITE_FAILURE, - FILE_PARSE_FAILURE : ST.ERR_FILE_PARSE_FAILURE, - FILE_READ_FAILURE : ST.ERR_FILE_READ_FAILURE, - FILE_CREATE_FAILURE : ST.ERR_FILE_CREATE_FAILURE, - FILE_CHECKSUM_FAILURE : ST.ERR_FILE_CHECKSUM_FAILURE, - FILE_COMPRESS_FAILURE : ST.ERR_FILE_COMPRESS_FAILURE, - FILE_DECOMPRESS_FAILURE : ST.ERR_FILE_DECOMPRESS_FAILURE, - FILE_MOVE_FAILURE : ST.ERR_FILE_MOVE_FAILURE, - FILE_DELETE_FAILURE : ST.ERR_FILE_DELETE_FAILURE, - FILE_COPY_FAILURE : ST.ERR_FILE_COPY_FAILURE, + FILE_NOT_FOUND: ST.ERR_FILE_NOT_FOUND, + FILE_OPEN_FAILURE: ST.ERR_FILE_OPEN_FAILURE, + FILE_WRITE_FAILURE: ST.ERR_FILE_WRITE_FAILURE, + FILE_PARSE_FAILURE: ST.ERR_FILE_PARSE_FAILURE, + FILE_READ_FAILURE: ST.ERR_FILE_READ_FAILURE, + FILE_CREATE_FAILURE: ST.ERR_FILE_CREATE_FAILURE, + FILE_CHECKSUM_FAILURE: ST.ERR_FILE_CHECKSUM_FAILURE, + FILE_COMPRESS_FAILURE: ST.ERR_FILE_COMPRESS_FAILURE, + FILE_DECOMPRESS_FAILURE: ST.ERR_FILE_DECOMPRESS_FAILURE, + FILE_MOVE_FAILURE: ST.ERR_FILE_MOVE_FAILURE, + FILE_DELETE_FAILURE: ST.ERR_FILE_DELETE_FAILURE, + FILE_COPY_FAILURE: ST.ERR_FILE_COPY_FAILURE, FILE_POSITIONING_FAILURE: ST.ERR_FILE_POSITIONING_FAILURE, - FILE_ALREADY_EXIST : ST.ERR_FILE_ALREADY_EXIST, - FILE_TYPE_MISMATCH : ST.ERR_FILE_TYPE_MISMATCH , - FILE_CASE_MISMATCH : ST.ERR_FILE_CASE_MISMATCH, - FILE_DUPLICATED : ST.ERR_FILE_DUPLICATED, - FILE_UNKNOWN_ERROR : ST.ERR_FILE_UNKNOWN_ERROR, + FILE_ALREADY_EXIST: ST.ERR_FILE_ALREADY_EXIST, + FILE_TYPE_MISMATCH: ST.ERR_FILE_TYPE_MISMATCH, + FILE_CASE_MISMATCH: ST.ERR_FILE_CASE_MISMATCH, + FILE_DUPLICATED: ST.ERR_FILE_DUPLICATED, + FILE_UNKNOWN_ERROR: ST.ERR_FILE_UNKNOWN_ERROR, =20 - OPTION_UNKNOWN : ST.ERR_OPTION_UNKNOWN, - OPTION_MISSING : ST.ERR_OPTION_MISSING, - OPTION_CONFLICT : ST.ERR_OPTION_CONFLICT, - OPTION_VALUE_INVALID : ST.ERR_OPTION_VALUE_INVALID, - OPTION_DEPRECATED : ST.ERR_OPTION_DEPRECATED, - OPTION_NOT_SUPPORTED : ST.ERR_OPTION_NOT_SUPPORTED, - OPTION_UNKNOWN_ERROR : ST.ERR_OPTION_UNKNOWN_ERROR, + OPTION_UNKNOWN: ST.ERR_OPTION_UNKNOWN, + OPTION_MISSING: ST.ERR_OPTION_MISSING, + OPTION_CONFLICT: ST.ERR_OPTION_CONFLICT, + OPTION_VALUE_INVALID: ST.ERR_OPTION_VALUE_INVALID, + OPTION_DEPRECATED: ST.ERR_OPTION_DEPRECATED, + OPTION_NOT_SUPPORTED: ST.ERR_OPTION_NOT_SUPPORTED, + OPTION_UNKNOWN_ERROR: ST.ERR_OPTION_UNKNOWN_ERROR, =20 - PARAMETER_INVALID : ST.ERR_PARAMETER_INVALID, - PARAMETER_MISSING : ST.ERR_PARAMETER_MISSING, - PARAMETER_UNKNOWN_ERROR : ST.ERR_PARAMETER_UNKNOWN_ERROR, + PARAMETER_INVALID: ST.ERR_PARAMETER_INVALID, + PARAMETER_MISSING: ST.ERR_PARAMETER_MISSING, + PARAMETER_UNKNOWN_ERROR: ST.ERR_PARAMETER_UNKNOWN_ERROR, =20 - FORMAT_INVALID : ST.ERR_FORMAT_INVALID, - FORMAT_NOT_SUPPORTED : ST.ERR_FORMAT_NOT_SUPPORTED, - FORMAT_UNKNOWN : ST.ERR_FORMAT_UNKNOWN, - FORMAT_UNKNOWN_ERROR : ST.ERR_FORMAT_UNKNOWN_ERROR, + FORMAT_INVALID: ST.ERR_FORMAT_INVALID, + FORMAT_NOT_SUPPORTED: ST.ERR_FORMAT_NOT_SUPPORTED, + FORMAT_UNKNOWN: ST.ERR_FORMAT_UNKNOWN, + FORMAT_UNKNOWN_ERROR: ST.ERR_FORMAT_UNKNOWN_ERROR, =20 - RESOURCE_NOT_AVAILABLE : ST.ERR_RESOURCE_NOT_AVAILABLE, - RESOURCE_ALLOCATE_FAILURE : ST.ERR_RESOURCE_ALLOCATE_FAILURE, - RESOURCE_FULL : ST.ERR_RESOURCE_FULL, - RESOURCE_OVERFLOW : ST.ERR_RESOURCE_OVERFLOW, - RESOURCE_UNDERRUN : ST.ERR_RESOURCE_UNDERRUN, - RESOURCE_UNKNOWN_ERROR : ST.ERR_RESOURCE_UNKNOWN_ERROR, + RESOURCE_NOT_AVAILABLE: ST.ERR_RESOURCE_NOT_AVAILABLE, + RESOURCE_ALLOCATE_FAILURE: ST.ERR_RESOURCE_ALLOCATE_FAILURE, + RESOURCE_FULL: ST.ERR_RESOURCE_FULL, + RESOURCE_OVERFLOW: ST.ERR_RESOURCE_OVERFLOW, + RESOURCE_UNDERRUN: ST.ERR_RESOURCE_UNDERRUN, + RESOURCE_UNKNOWN_ERROR: ST.ERR_RESOURCE_UNKNOWN_ERROR, =20 - ATTRIBUTE_NOT_AVAILABLE : ST.ERR_ATTRIBUTE_NOT_AVAILABLE, - ATTRIBUTE_RETRIEVE_FAILURE : ST.ERR_ATTRIBUTE_RETRIEVE_FAILURE, - ATTRIBUTE_SET_FAILURE : ST.ERR_ATTRIBUTE_SET_FAILURE, + ATTRIBUTE_NOT_AVAILABLE: ST.ERR_ATTRIBUTE_NOT_AVAILABLE, + ATTRIBUTE_RETRIEVE_FAILURE: ST.ERR_ATTRIBUTE_RETRIEVE_FAILURE, + ATTRIBUTE_SET_FAILURE: ST.ERR_ATTRIBUTE_SET_FAILURE, ATTRIBUTE_UPDATE_FAILURE: ST.ERR_ATTRIBUTE_UPDATE_FAILURE, - ATTRIBUTE_ACCESS_DENIED : ST.ERR_ATTRIBUTE_ACCESS_DENIED, - ATTRIBUTE_UNKNOWN_ERROR : ST.ERR_ATTRIBUTE_UNKNOWN_ERROR, + ATTRIBUTE_ACCESS_DENIED: ST.ERR_ATTRIBUTE_ACCESS_DENIED, + ATTRIBUTE_UNKNOWN_ERROR: ST.ERR_ATTRIBUTE_UNKNOWN_ERROR, =20 - COMMAND_FAILURE : ST.ERR_COMMAND_FAILURE, + COMMAND_FAILURE: ST.ERR_COMMAND_FAILURE, =20 - IO_NOT_READY : ST.ERR_IO_NOT_READY, - IO_BUSY : ST.ERR_IO_BUSY, - IO_TIMEOUT : ST.ERR_IO_TIMEOUT, - IO_UNKNOWN_ERROR : ST.ERR_IO_UNKNOWN_ERROR, + IO_NOT_READY: ST.ERR_IO_NOT_READY, + IO_BUSY: ST.ERR_IO_BUSY, + IO_TIMEOUT: ST.ERR_IO_TIMEOUT, + IO_UNKNOWN_ERROR: ST.ERR_IO_UNKNOWN_ERROR, =20 - UNKNOWN_ERROR : ST.ERR_UNKNOWN_ERROR, + UNKNOWN_ERROR: ST.ERR_UNKNOWN_ERROR, =20 - UPT_ALREADY_INSTALLED_ERROR : ST.ERR_UPT_ALREADY_INSTALLED_ERROR, - UPT_ENVIRON_MISSING_ERROR : ST.ERR_UPT_ENVIRON_MISSING_ERROR, - UPT_REPKG_ERROR : ST.ERR_UPT_REPKG_ERROR, - UPT_ALREADY_RUNNING_ERROR : ST.ERR_UPT_ALREADY_RUNNING_ERROR, - UPT_MUL_DEC_ERROR : ST.ERR_MUL_DEC_ERROR, - UPT_INI_PARSE_ERROR : ST.ERR_UPT_INI_PARSE_ERROR, + UPT_ALREADY_INSTALLED_ERROR: ST.ERR_UPT_ALREADY_INSTALLED_ERROR, + UPT_ENVIRON_MISSING_ERROR: ST.ERR_UPT_ENVIRON_MISSING_ERROR, + UPT_REPKG_ERROR: ST.ERR_UPT_REPKG_ERROR, + UPT_ALREADY_RUNNING_ERROR: ST.ERR_UPT_ALREADY_RUNNING_ERROR, + UPT_MUL_DEC_ERROR: ST.ERR_MUL_DEC_ERROR, + UPT_INI_PARSE_ERROR: ST.ERR_UPT_INI_PARSE_ERROR, } =20 -## Exception indicating a fatal error +# Exception indicating a fatal error # + + class FatalError(Exception): pass - diff --git a/BaseTools/Source/Python/UPT/Logger/__init__.py b/BaseTools/Sou= rce/Python/UPT/Logger/__init__.py index e53198451794..cee19ef24060 100644 --- a/BaseTools/Source/Python/UPT/Logger/__init__.py +++ b/BaseTools/Source/Python/UPT/Logger/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Logger' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/MkPkg.py b/BaseTools/Source/Python= /UPT/MkPkg.py index c6d4731ed655..e7912b44c6a1 100644 --- a/BaseTools/Source/Python/UPT/MkPkg.py +++ b/BaseTools/Source/Python/UPT/MkPkg.py @@ -1,4 +1,4 @@ -## @file +# @file # Install distribution package. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -46,27 +46,32 @@ from Core.DistributionPackageClass import DistributionP= ackageClass from Core.PackageFile import PackageFile from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## CheckForExistingDp +# CheckForExistingDp # # Check if there is a same name DP file existing # @param Path: The path to be checked # + + def CheckForExistingDp(Path): if os.path.exists(Path): Logger.Info(ST.MSG_DISTRIBUTION_PACKAGE_FILE_EXISTS % Path) Input =3D stdin.readline() Input =3D Input.replace('\r', '').replace('\n', '') if Input.upper() !=3D "Y": - Logger.Error("\nMkPkg", ABORT_ERROR, ST.ERR_USER_ABORT, RaiseE= rror=3DTrue) + Logger.Error("\nMkPkg", ABORT_ERROR, + ST.ERR_USER_ABORT, RaiseError=3DTrue) =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know # if it's executed successfully or not. # # -def Main(Options =3D None): + + +def Main(Options=3DNone): if Options is None: Logger.Error("\nMkPkg", OPTION_UNKNOWN_ERROR, ST.ERR_OPTION_NOT_FO= UND) try: @@ -78,7 +83,8 @@ def Main(Options =3D None): # Init PackFileToCreate # if not Options.PackFileToCreate: - Logger.Error("\nMkPkg", OPTION_UNKNOWN_ERROR, ST.ERR_OPTION_NO= T_FOUND) + Logger.Error("\nMkPkg", OPTION_UNKNOWN_ERROR, + ST.ERR_OPTION_NOT_FOUND) =20 # # Handle if the distribution package file already exists @@ -88,11 +94,13 @@ def Main(Options =3D None): # # Check package file existing and valid # - CheckFileList('.DEC', Options.PackageFileList, ST.ERR_INVALID_PACK= AGE_NAME, ST.ERR_INVALID_PACKAGE_PATH) + CheckFileList('.DEC', Options.PackageFileList, + ST.ERR_INVALID_PACKAGE_NAME, ST.ERR_INVALID_PACKAGE_= PATH) # # Check module file existing and valid # - CheckFileList('.INF', Options.ModuleFileList, ST.ERR_INVALID_MODUL= E_NAME, ST.ERR_INVALID_MODULE_PATH) + CheckFileList('.INF', Options.ModuleFileList, + ST.ERR_INVALID_MODULE_NAME, ST.ERR_INVALID_MODULE_PA= TH) =20 # # Get list of files that installed with RePackage attribute availa= ble @@ -130,15 +138,17 @@ def Main(Options =3D None): # strings in your desired encoding before passing them to # write(). # - FromFile =3D os.path.normpath(FileObject.GetURI()).encode(= 'utf_8') + FromFile =3D os.path.normpath( + FileObject.GetURI()).encode('utf_8') FileFullPath =3D mws.join(WorkspaceDir, FromFile) if FileFullPath in RePkgDict: - (DpGuid, DpVersion, DpName, Repackage) =3D RePkgDict[F= ileFullPath] + (DpGuid, DpVersion, DpName, + Repackage) =3D RePkgDict[FileFullPath] if not Repackage: Logger.Error("\nMkPkg", UPT_REPKG_ERROR, ST.ERR_UPT_REPKG_ERROR, - ExtraData=3DST.MSG_REPKG_CONFLICT %\ + ExtraData=3DST.MSG_REPKG_CONFLICT % (FileFullPath, DpGuid, DpVersion, DpN= ame) ) else: @@ -155,7 +165,7 @@ def Main(Options =3D None): DistPkg.Header.Guid =3D str(uuid4()) DistPkg.Header.Version =3D '1.0' =20 - DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileLi= st, \ + DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileLi= st, Options.ModuleFileList) FileList, MetaDataFileList =3D DistPkg.GetDistributionFileList() for File in FileList + MetaDataFileList: @@ -165,14 +175,14 @@ def Main(Options =3D None): # be repackaged # if FileFullPath in RePkgDict: - (DpGuid, DpVersion, DpName, Repackage) =3D RePkgDict[FileF= ullPath] + (DpGuid, DpVersion, DpName, + Repackage) =3D RePkgDict[FileFullPath] if not Repackage: Logger.Error("\nMkPkg", UPT_REPKG_ERROR, ST.ERR_UPT_REPKG_ERROR, - ExtraData =3D \ - ST.MSG_REPKG_CONFLICT %(FileFullPath, DpN= ame, \ - DpGuid, DpVersion) + ExtraData=3DST.MSG_REPKG_CONFLICT % (File= FullPath, DpName, + DpGuid= , DpVersion) ) else: DistPkg.Header.RePackage =3D True @@ -190,7 +200,8 @@ def Main(Options =3D None): # # Add Md5Signature # - DistPkg.Header.Signature =3D md5(open(str(ContentFile), 'rb').read= ()).hexdigest() + DistPkg.Header.Signature =3D md5( + open(str(ContentFile), 'rb').read()).hexdigest() # # Add current Date # @@ -210,25 +221,25 @@ def Main(Options =3D None): except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % \ + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) except KeyboardInterrupt: ReturnCode =3D ABORT_ERROR if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % \ + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) except OSError: pass except: Logger.Error( - "\nMkPkg", - CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_CREATING_ERR % \ - Options.PackFileToCreate, - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) - Logger.Quiet(ST.MSG_PYTHON_ON % \ + "\nMkPkg", + CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_CREATING_ERR % + Options.PackFileToCreate, + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) ReturnCode =3D CODE_ERROR finally: @@ -240,7 +251,7 @@ def Main(Options =3D None): return ReturnCode =20 =20 -## CheckFileList +# CheckFileList # # @param QualifiedExt: QualifiedExt # @param FileList: FileList @@ -255,7 +266,7 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringEx= t, ErrorStringFullPath): for Item in FileList: Ext =3D os.path.splitext(Item)[1] if Ext.upper() !=3D QualifiedExt.upper(): - Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \ + Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, ErrorStringExt % Item) =20 Item =3D os.path.normpath(Item) @@ -266,9 +277,9 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringEx= t, ErrorStringFullPath): Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, ErrorStringFullPath % Item) elif not IsValidPath(Item, WorkspaceDir): - Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \ + Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, ErrorStringExt % Item) =20 if not os.path.split(Item)[0]: - Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \ + Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, ST.ERR_INVALID_METAFILE_PATH % Item) diff --git a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py b/BaseT= ools/Source/Python/UPT/Object/POM/CommonObject.py index ae8fe8306dbd..061a3864df4f 100644 --- a/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py +++ b/BaseTools/Source/Python/UPT/Object/POM/CommonObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common items of class object # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -10,10 +10,12 @@ Common Object ''' from Library.DataType import TAB_LANGUAGE_EN_US =20 -## HelpTextObject +# HelpTextObject # # @param object: Inherited from object class # + + class HelpTextObject(object): def __init__(self): self.HelpText =3D TextObject() @@ -24,10 +26,12 @@ class HelpTextObject(object): def GetHelpText(self): return self.HelpText =20 -## HelpTextListObject +# HelpTextListObject # # @param object: Inherited from object class # + + class HelpTextListObject(object): def __init__(self): self.HelpTextList =3D [] @@ -38,10 +42,12 @@ class HelpTextListObject(object): def GetHelpTextList(self): return self.HelpTextList =20 -## PromptListObject +# PromptListObject # # @param object: Inherited from object class # + + class PromptListObject(object): def __init__(self): self.PromptList =3D [] @@ -52,7 +58,7 @@ class PromptListObject(object): def GetPromptList(self): return self.PromptList =20 -## CommonPropertiesObject +# CommonPropertiesObject # # This class defined common attribution used in Module/Platform/Package fi= les # @@ -63,6 +69,8 @@ class PromptListObject(object): # @param HelpText: Input value for HelpText, default is '' # @param HelpTextList: Input value for HelpTextList, default is [] # + + class CommonPropertiesObject(HelpTextObject, HelpTextListObject): def __init__(self): self.Usage =3D [] @@ -96,12 +104,14 @@ class CommonPropertiesObject(HelpTextObject, HelpTextL= istObject): def GetGuidValue(self): return self.GuidValue =20 -## CommonHeaderObject +# CommonHeaderObject # # This class defined common header items used in Module/Platform/Package f= iles # # @param object: Inherited from object class # + + class CommonHeaderObject(object): def __init__(self): self.AbstractList =3D [] @@ -145,12 +155,14 @@ class CommonHeaderObject(object): def GetLicense(self): return self.LicenseList =20 -## BinaryHeaderObject +# BinaryHeaderObject # # This class defined Binary header items used in Module/Platform/Package f= iles # # @param object: Inherited from object class # + + class BinaryHeaderObject(object): def __init__(self): self.BinaryHeaderAbstractList =3D [] @@ -194,12 +206,14 @@ class BinaryHeaderObject(object): def GetBinaryHeaderLicense(self): return self.BinaryHeaderLicenseList =20 -## ClonedRecordObject +# ClonedRecordObject # # This class defined ClonedRecord items used in Module/Platform/Package fi= les # # @param object: Inherited from object class # + + class ClonedRecordObject(object): def __init__(self): self.IdNum =3D 0 @@ -245,12 +259,14 @@ class ClonedRecordObject(object): def GetModuleVersion(self): return self.ModuleVersion =20 -## TextObject +# TextObject # # This class defined Text item used in PKG file # # @param object: Inherited from object class # + + class TextObject(object): def __init__(self): self.Lang =3D TAB_LANGUAGE_EN_US @@ -268,12 +284,14 @@ class TextObject(object): def GetString(self): return self.String =20 -## FileNameObject +# FileNameObject # # This class defined File item used in module, for binary files # # @param CommonPropertiesObject: Inherited from CommonPropertiesObject c= lass # + + class FileNameObject(CommonPropertiesObject): def __init__(self): self.FileType =3D '' @@ -292,12 +310,14 @@ class FileNameObject(CommonPropertiesObject): def GetFilename(self): return self.Filename =20 -## FileObject +# FileObject # # This class defined File item used in PKG file # # @param object: Inherited from object class # + + class FileObject(object): def __init__(self): self.Executable =3D '' @@ -327,6 +347,8 @@ class FileObject(object): # # @param CommonHeaderObject: Inherited from CommonHeaderObject class # + + class MiscFileObject(CommonHeaderObject): def __init__(self): self.Name =3D '' @@ -348,15 +370,19 @@ class MiscFileObject(CommonHeaderObject): ## # ToolsObject # + + class ToolsObject(MiscFileObject): pass =20 -## GuidVersionObject +# GuidVersionObject # # This class defined GUID/Version items used in PKG file # # @param object: Inherited from object class # + + class GuidVersionObject(object): def __init__(self): self.Guid =3D '' @@ -374,12 +400,14 @@ class GuidVersionObject(object): def GetVersion(self): return self.Version =20 -## IdentificationObject +# IdentificationObject # # This class defined Identification items used in Module/Platform/Package = files # # @param object: Inherited from object class # + + class IdentificationObject(GuidVersionObject): def __init__(self): self.Name =3D '' @@ -440,13 +468,15 @@ class IdentificationObject(GuidVersionObject): def GetCombinePath(self): return self.CombinePath =20 -## GuidProtocolPpiCommonObject +# GuidProtocolPpiCommonObject # # This class defined Guid, Protocol and Ppi like items used in # Module/Platform/Package files # # @param CommonPropertiesObject: Inherited from CommonPropertiesObject = class # + + class GuidProtocolPpiCommonObject(CommonPropertiesObject): def __init__(self): self.Name =3D '' @@ -479,17 +509,20 @@ class GuidProtocolPpiCommonObject(CommonPropertiesObj= ect): def GetSupModuleList(self): return self.SupModuleList =20 -## GuidObject +# GuidObject # # This class defined Guid item used in Module/Platform/Package files # # @param GuidProtocolPpiCommonObject: GuidProtocolPpiCommonObject # + + class GuidObject(GuidProtocolPpiCommonObject): def __init__(self): self.VariableName =3D '' self.GuidTypeList =3D [] GuidProtocolPpiCommonObject.__init__(self) + def SetVariableName(self, VariableName): self.VariableName =3D VariableName =20 @@ -502,54 +535,64 @@ class GuidObject(GuidProtocolPpiCommonObject): def GetGuidTypeList(self): return self.GuidTypeList =20 -## ProtocolObject +# ProtocolObject # # This class defined Protocol item used in Module/Platform/Package files # # @param GuidProtocolPpiCommonObject: Inherited from # GuidProtocolPpiCommonObject # + + class ProtocolObject(GuidProtocolPpiCommonObject): def __init__(self): self.Notify =3D False GuidProtocolPpiCommonObject.__init__(self) + def SetNotify(self, Notify): self.Notify =3D Notify =20 def GetNotify(self): return self.Notify =20 -## PpiObject +# PpiObject # # This class defined Ppi item used in Module/Platform/Package files # # @param GuidProtocolPpiCommonObject: Inherited from # GuidProtocolPpiCommonObject # + + class PpiObject(GuidProtocolPpiCommonObject): def __init__(self): self.Notify =3D False GuidProtocolPpiCommonObject.__init__(self) + def SetNotify(self, Notify): self.Notify =3D Notify =20 def GetNotify(self): return self.Notify =20 -## DefineObject +# DefineObject # # This class defined item DEFINE used in Module/Platform/Package files # # @param object: Inherited from object class # + + class DefineClass(object): def __init__(self): self.Define =3D {} =20 -## UserExtensionObject +# UserExtensionObject # # @param object: Inherited from object class # + + class UserExtensionObject(object): def __init__(self): self.UserID =3D '' @@ -684,12 +727,14 @@ class UserExtensionObject(object): def GetBinariesDict(self): return self.BinariesDict =20 -## LibraryClassObject +# LibraryClassObject # # This class defined Library item used in Module/Platform/Package files # # @param CommonPropertiesObject: Inherited from CommonPropertiesObject cl= ass # + + class LibraryClassObject(CommonPropertiesObject): def __init__(self): self.LibraryClass =3D '' @@ -723,7 +768,7 @@ class LibraryClassObject(CommonPropertiesObject): return self.RecommendedInstance =20 =20 -## PcdErrorObject +# PcdErrorObject # # @param object: Inherited from object class # @@ -801,7 +846,7 @@ class PcdErrorObject(object): return self.LineNum =20 =20 -## IncludeObject +# IncludeObject # # This class defined Include item used in Module/Platform/Package files # @@ -839,7 +884,7 @@ class IncludeObject(CommonPropertiesObject): def GetComment(self): return self.Comment =20 -## PcdObject +# PcdObject # # This class defined Pcd item used in Module/Platform/Package files # @@ -855,6 +900,8 @@ class IncludeObject(CommonPropertiesObject): # @param SkuInfoList: Input value for SkuInfoList, default is {} # @param SupModuleList: Input value for SupModuleList, default is [] # + + class PcdObject(CommonPropertiesObject, HelpTextListObject, PromptListObje= ct): def __init__(self): self.PcdCName =3D '' diff --git a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py b/BaseT= ools/Source/Python/UPT/Object/POM/ModuleObject.py index 6e515a2c3fe4..6aaae4c1aff2 100644 --- a/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py +++ b/BaseTools/Source/Python/UPT/Object/POM/ModuleObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define a class object to describe a module # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -38,6 +38,8 @@ class BootModeObject(CommonPropertiesObject, HelpTextList= Object): ## # EventObject # + + class EventObject(CommonPropertiesObject, HelpTextListObject): def __init__(self): self.EventType =3D '' @@ -53,6 +55,8 @@ class EventObject(CommonPropertiesObject, HelpTextListObj= ect): ## # HobObject # + + class HobObject(CommonPropertiesObject, HelpTextListObject): def __init__(self): self.HobType =3D '' @@ -68,6 +72,8 @@ class HobObject(CommonPropertiesObject, HelpTextListObjec= t): ## # SpecObject # + + class SpecObject(object): def __init__(self): self.Spec =3D '' @@ -85,10 +91,12 @@ class SpecObject(object): def GetVersion(self): return self.Version =20 -## ModuleHeaderObject +# ModuleHeaderObject # # This class defined header items used in Module file # + + class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryH= eaderObject): def __init__(self): self.IsLibrary =3D False @@ -211,6 +219,8 @@ class ModuleHeaderObject(IdentificationObject, CommonHe= aderObject, BinaryHeaderO ## # SourceFileObject # + + class SourceFileObject(CommonPropertiesObject): def __init__(self): CommonPropertiesObject.__init__(self) @@ -224,7 +234,7 @@ class SourceFileObject(CommonPropertiesObject): self.SourceFile =3D SourceFile =20 def GetSourceFile(self): - return self.SourceFile + return self.SourceFile =20 def SetTagName(self, TagName): self.TagName =3D TagName @@ -284,22 +294,27 @@ class AsBuildLibraryClassObject(object): =20 def SetLibGuid(self, LibGuid): self.LibGuid =3D LibGuid + def GetLibGuid(self): return self.LibGuid =20 def SetLibVersion(self, LibVersion): self.LibVersion =3D LibVersion + def GetLibVersion(self): return self.LibVersion =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 ## # AsBuiltObject # + + class AsBuiltObject(object): def __init__(self): # @@ -347,6 +362,8 @@ class AsBuiltObject(object): # BinaryBuildFlag, this object will include those fields that are not # covered by the UPT Spec BinaryFile field # + + class BinaryBuildFlagObject(object): def __init__(self): self.Target =3D '' @@ -374,12 +391,15 @@ class BinaryBuildFlagObject(object): =20 def SetAsBuiltOptionFlags(self, AsBuiltOptionFlags): self.AsBuiltOptionFlags =3D AsBuiltOptionFlags + def GetAsBuiltOptionFlags(self): return self.AsBuiltOptionFlags =20 ## # ExternObject # + + class ExternObject(CommonPropertiesObject): def __init__(self): self.EntryPoint =3D '' @@ -415,12 +435,15 @@ class ExternObject(CommonPropertiesObject): =20 def SetSupModList(self, SupModList): self.SupModList =3D SupModList + def GetSupModList(self): return self.SupModList =20 ## # DepexObject # + + class DepexObject(CommonPropertiesObject): def __init__(self): self.Depex =3D '' @@ -442,6 +465,8 @@ class DepexObject(CommonPropertiesObject): ## # PackageDependencyObject # + + class PackageDependencyObject(GuidVersionObject, CommonPropertiesObject): def __init__(self): self.Package =3D '' @@ -464,6 +489,8 @@ class PackageDependencyObject(GuidVersionObject, Common= PropertiesObject): ## # BuildOptionObject # + + class BuildOptionObject(CommonPropertiesObject): def __init__(self): CommonPropertiesObject.__init__(self) @@ -478,6 +505,8 @@ class BuildOptionObject(CommonPropertiesObject): ## # ModuleObject # + + class ModuleObject(ModuleHeaderObject): def __init__(self): # diff --git a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py b/Base= Tools/Source/Python/UPT/Object/POM/PackageObject.py index fcc2a3bea94a..8fc202959a1a 100644 --- a/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py +++ b/BaseTools/Source/Python/UPT/Object/POM/PackageObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define a class object to describe a package # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -18,8 +18,10 @@ from Object.POM.CommonObject import CommonHeaderObject from Object.POM.CommonObject import BinaryHeaderObject from Library.Misc import Sdict =20 -## StandardIncludeFileObject +# StandardIncludeFileObject # + + class StandardIncludeFileObject(CommonPropertiesObject): def __init__(self): CommonPropertiesObject.__init__(self) @@ -31,14 +33,18 @@ class StandardIncludeFileObject(CommonPropertiesObject): def GetIncludeFile(self): return self.IncludeFile =20 -## PackageIncludeFileObject +# PackageIncludeFileObject # + + class PackageIncludeFileObject(StandardIncludeFileObject): pass =20 ## # PackageObject # + + class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeader= Object): def __init__(self): IdentificationObject.__init__(self) @@ -189,4 +195,3 @@ class PackageObject(IdentificationObject, CommonHeaderO= bject, BinaryHeaderObject =20 def GetModuleFileList(self): return self.ModuleFileList - diff --git a/BaseTools/Source/Python/UPT/Object/POM/__init__.py b/BaseTools= /Source/Python/UPT/Object/POM/__init__.py index b36e7f6585c1..ceb3226afc0c 100644 --- a/BaseTools/Source/Python/UPT/Object/POM/__init__.py +++ b/BaseTools/Source/Python/UPT/Object/POM/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Object' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py b/BaseT= ools/Source/Python/UPT/Object/Parser/DecObject.py index 2a7fcf1697e5..28d5153a6af8 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/DecObject.py @@ -1,6 +1,6 @@ -## @file +# @file # This file is used to define class objects for DEC file. It will consumed= by -#DecParser +# DecParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        # @@ -10,7 +10,7 @@ DecObject ''' =20 -## Import modules +# Import modules # import os.path =20 @@ -25,51 +25,55 @@ from Library.DataType import TAB_USER_EXTENSIONS from Library.DataType import TAB_PCDS from Library.DataType import TAB_ARCH_COMMON =20 -## _DecComments +# _DecComments # # Base class for all data objects which have head and tail comments # + + class _DecComments: =20 - ##constructor + # constructor # def __init__(self): self._HeadComment =3D [] self._TailComment =3D [] =20 - ## GetComments + # GetComments # def GetComments(self): return self._HeadComment, self._TailComment =20 - ## GetHeadComment + # GetHeadComment # def GetHeadComment(self): return self._HeadComment =20 - ## SetHeadComment + # SetHeadComment # # @param Comment: comment content # def SetHeadComment(self, Comment): self._HeadComment =3D Comment =20 - ## GetTailComment + # GetTailComment # def GetTailComment(self): return self._TailComment =20 - ## SetTailComment + # SetTailComment # # @param Comment: comment content # def SetTailComment(self, Comment): self._TailComment =3D Comment =20 -## _DecBaseObject +# _DecBaseObject # # Base class that hold common info # + + class _DecBaseObject(_DecComments): def __init__(self, PkgFullName): _DecComments.__init__(self) @@ -82,27 +86,27 @@ class _DecBaseObject(_DecComments): self._PackagePath, self._FileName =3D os.path.split(PkgFullName) self._SecName =3D '' =20 - ## GetSectionName + # GetSectionName # def GetSectionName(self): return self._SecName =20 - ## GetPackagePath + # GetPackagePath # def GetPackagePath(self): return self._PackagePath =20 - ## GetPackageFile + # GetPackageFile # def GetPackageFile(self): return self._FileName =20 - ## GetPackageFullName + # GetPackageFullName # def GetPackageFullName(self): return self._PkgFullName =20 - ## AddItem + # AddItem # Add sub-item to current object, sub-class should override it if need= ed # # @param Item: Sub-item to be added @@ -122,7 +126,7 @@ class _DecBaseObject(_DecComments): ArchModule.append(Ele[1]) Item.ArchAndModuleType =3D ArchModule =20 - ## _GetItemByArch + # _GetItemByArch # Helper class used by sub-class # @param Arch: arch # @@ -132,7 +136,7 @@ class _DecBaseObject(_DecComments): return [] return self.ValueDict[Arch] =20 - ## _GetAllItems + # _GetAllItems # Get all items, union all arches, items in returned list are unique # def _GetAllItems(self): @@ -143,10 +147,12 @@ class _DecBaseObject(_DecComments): Retlst.append(Item) return Retlst =20 -## _DecItemBaseObject +# _DecItemBaseObject # # Module type and arch the item belongs to # + + class _DecItemBaseObject(_DecComments): def __init__(self): _DecComments.__init__(self) @@ -155,7 +161,7 @@ class _DecItemBaseObject(_DecComments): # self.ArchAndModuleType =3D [] =20 - ## GetArchList + # GetArchList # def GetArchList(self): ArchSet =3D set() @@ -163,10 +169,12 @@ class _DecItemBaseObject(_DecComments): ArchSet.add(Arch) return list(ArchSet) =20 -## DecDefineObject +# DecDefineObject # # Class to hold define section information # + + class DecDefineObject(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) @@ -177,7 +185,7 @@ class DecDefineObject(_DecBaseObject): self._PkgVersion =3D '' self._PkgUniFile =3D '' =20 - ## GetPackageSpecification + # GetPackageSpecification # def GetPackageSpecification(self): return self._DecSpec @@ -185,7 +193,7 @@ class DecDefineObject(_DecBaseObject): def SetPackageSpecification(self, DecSpec): self._DecSpec =3D DecSpec =20 - ## GetPackageName + # GetPackageName # def GetPackageName(self): return self._PkgName @@ -193,7 +201,7 @@ class DecDefineObject(_DecBaseObject): def SetPackageName(self, PkgName): self._PkgName =3D PkgName =20 - ## GetPackageGuid + # GetPackageGuid # def GetPackageGuid(self): return self._PkgGuid @@ -201,7 +209,7 @@ class DecDefineObject(_DecBaseObject): def SetPackageGuid(self, PkgGuid): self._PkgGuid =3D PkgGuid =20 - ## GetPackageVersion + # GetPackageVersion # def GetPackageVersion(self): return self._PkgVersion @@ -209,7 +217,7 @@ class DecDefineObject(_DecBaseObject): def SetPackageVersion(self, PkgVersion): self._PkgVersion =3D PkgVersion =20 - ## GetPackageUniFile + # GetPackageUniFile # def GetPackageUniFile(self): return self._PkgUniFile @@ -217,109 +225,119 @@ class DecDefineObject(_DecBaseObject): def SetPackageUniFile(self, PkgUniFile): self._PkgUniFile =3D PkgUniFile =20 - ## GetDefines + # GetDefines # def GetDefines(self): return self._GetItemByArch(TAB_ARCH_COMMON) =20 - ## GetAllDefines + # GetAllDefines # def GetAllDefines(self): return self._GetAllItems() =20 -## DecDefineItemObject +# DecDefineItemObject # # Each item of define section # + + class DecDefineItemObject(_DecItemBaseObject): def __init__(self): _DecItemBaseObject.__init__(self) self.Key =3D '' self.Value =3D '' =20 - ## __hash__ + # __hash__ # def __hash__(self): return hash(self.Key + self.Value) =20 - ## __eq__ + # __eq__ # def __eq__(self, Other): return id(self) =3D=3D id(Other) =20 - ## __str__ + # __str__ # def __str__(self): return str(self.ArchAndModuleType) + '\n' + self.Key + \ ' =3D ' + self.Value =20 -## DecIncludeObject +# DecIncludeObject # # Class to hold include section info # + + class DecIncludeObject(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) self._SecName =3D TAB_INCLUDES.upper() =20 - ## GetIncludes + # GetIncludes # def GetIncludes(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetAllIncludes + # GetAllIncludes # def GetAllIncludes(self): return self._GetAllItems() =20 -## DecIncludeItemObject +# DecIncludeItemObject # # Item of include section # + + class DecIncludeItemObject(_DecItemBaseObject): def __init__(self, File, Root): self.File =3D File self.Root =3D Root _DecItemBaseObject.__init__(self) =20 - ## __hash__ + # __hash__ # def __hash__(self): return hash(self.File) =20 - ## __eq__ + # __eq__ # def __eq__(self, Other): return id(self) =3D=3D id(Other) =20 - ## __str__ + # __str__ # def __str__(self): return self.File =20 -## DecLibraryclassObject +# DecLibraryclassObject # # Class to hold library class section info # + + class DecLibraryclassObject(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) self._PackagePath, self._FileName =3D os.path.split(PkgFullName) self._SecName =3D TAB_LIBRARY_CLASSES.upper() =20 - ## GetLibraryclasses + # GetLibraryclasses # def GetLibraryclasses(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetAllLibraryclasses + # GetAllLibraryclasses # def GetAllLibraryclasses(self): return self._GetAllItems() =20 -## DecLibraryclassItemObject +# DecLibraryclassItemObject # Item of library class section # + + class DecLibraryclassItemObject(_DecItemBaseObject): def __init__(self, Libraryclass, File, Root): _DecItemBaseObject.__init__(self) @@ -327,30 +345,32 @@ class DecLibraryclassItemObject(_DecItemBaseObject): self.Root =3D Root self.Libraryclass =3D Libraryclass =20 - ## __hash__ + # __hash__ # def __hash__(self): return hash(self.Libraryclass + self.File) =20 - ## __eq__ + # __eq__ # def __eq__(self, Other): return id(self) =3D=3D id(Other) =20 - ## __str__ + # __str__ # def __str__(self): return self.Libraryclass + '|' + self.File =20 -## DecPcdObject +# DecPcdObject # Class to hold PCD section # + + class DecPcdObject(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) self._SecName =3D TAB_PCDS.upper() =20 - ## AddItem + # AddItem # # Diff from base class # @@ -371,7 +391,7 @@ class DecPcdObject(_DecBaseObject): ArchModule.append([Type, Arch]) Item.ArchAndModuleType =3D ArchModule =20 - ## GetPcds + # GetPcds # # @param PcdType: PcdType # @param Arch: Arch @@ -383,7 +403,7 @@ class DecPcdObject(_DecBaseObject): return [] return self.ValueDict[PcdType, Arch] =20 - ## GetPcdsByType + # GetPcdsByType # # @param PcdType: PcdType # @@ -398,12 +418,14 @@ class DecPcdObject(_DecBaseObject): Retlst.append(Item) return Retlst =20 -## DecPcdItemObject +# DecPcdItemObject # # Item of PCD section # # @param _DecItemBaseObject: _DecItemBaseObject object # + + class DecPcdItemObject(_DecItemBaseObject): def __init__(self, Guid, Name, Value, DatumType, Token, MaxDatumSize=3D''): @@ -415,17 +437,17 @@ class DecPcdItemObject(_DecItemBaseObject): self.TokenValue =3D Token self.MaxDatumSize =3D MaxDatumSize =20 - ## __hash__ + # __hash__ # def __hash__(self): return hash(self.TokenSpaceGuidCName + self.TokenCName) =20 - ## __eq__ + # __eq__ # def __eq__(self, Other): return id(self) =3D=3D id(Other) =20 - ## GetArchListOfType + # GetArchListOfType # # @param PcdType: PcdType # @@ -438,35 +460,39 @@ class DecPcdItemObject(_DecItemBaseObject): ItemSet.add(Arch) return list(ItemSet) =20 -## DecGuidObjectBase +# DecGuidObjectBase # # Base class for PPI, Protocol, and GUID. # Hold same data but has different method for clarification in sub-class # # @param _DecBaseObject: Dec Base Object # + + class DecGuidObjectBase(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) =20 - ## GetGuidStyleItems + # GetGuidStyleItems # # @param Arch: Arch # def GetGuidStyleItems(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetGuidStyleAllItems + # GetGuidStyleAllItems # def GetGuidStyleAllItems(self): return self._GetAllItems() =20 -## DecGuidItemObject +# DecGuidItemObject # # Item of GUID, PPI and Protocol section # # @param _DecItemBaseObject: Dec Item Base Object # + + class DecGuidItemObject(_DecItemBaseObject): def __init__(self, CName, GuidCValue, GuidString): _DecItemBaseObject.__init__(self) @@ -474,103 +500,111 @@ class DecGuidItemObject(_DecItemBaseObject): self.GuidCValue =3D GuidCValue self.GuidString =3D GuidString =20 - ## __hash__ + # __hash__ # def __hash__(self): return hash(self.GuidCName) =20 - ## __eq__ + # __eq__ # def __eq__(self, Other): return id(self) =3D=3D id(Other) =20 - ## __str__ + # __str__ # def __str__(self): return self.GuidCName + ' =3D ' + self.GuidCValue =20 -## DecGuidObject +# DecGuidObject # # Class for GUID section # # @param DecGuidObjectBase: Dec Guid Object Base # + + class DecGuidObject(DecGuidObjectBase): def __init__(self, PkgFullName): DecGuidObjectBase.__init__(self, PkgFullName) self._SecName =3D TAB_GUIDS.upper() =20 - ## GetGuids + # GetGuids # # @param Arch: Arch # def GetGuids(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetAllGuids + # GetAllGuids # def GetAllGuids(self): return self._GetAllItems() =20 -## DecPpiObject +# DecPpiObject # # Class for PPI section # # @param DecGuidObjectBase: Dec Guid Object Base # + + class DecPpiObject(DecGuidObjectBase): def __init__(self, PkgFullName): DecGuidObjectBase.__init__(self, PkgFullName) self._SecName =3D TAB_PPIS.upper() =20 - ## GetPpis + # GetPpis # # @param Arch: Arch # def GetPpis(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetAllPpis + # GetAllPpis # def GetAllPpis(self): return self._GetAllItems() =20 -## DecProtocolObject +# DecProtocolObject # # Class for protocol section # # @param DecGuidObjectBase: Dec Guid Object Base # + + class DecProtocolObject(DecGuidObjectBase): def __init__(self, PkgFullName): DecGuidObjectBase.__init__(self, PkgFullName) self._SecName =3D TAB_PROTOCOLS.upper() =20 - ## GetProtocols + # GetProtocols # # @param Arch: Arch # def GetProtocols(self, Arch=3DTAB_ARCH_COMMON): return self._GetItemByArch(Arch) =20 - ## GetAllProtocols + # GetAllProtocols # def GetAllProtocols(self): return self._GetAllItems() =20 -## DecUserExtensionObject +# DecUserExtensionObject # # Class for user extension section # # @param _DecBaseObject: Dec Guid Object Base # + + class DecUserExtensionObject(_DecBaseObject): def __init__(self, PkgFullName): _DecBaseObject.__init__(self, PkgFullName) self._SecName =3D TAB_USER_EXTENSIONS.upper() self.ItemList =3D [] =20 - ## GetProtocols + # GetProtocols # # @param Item: Item # @param Scope: Scope @@ -582,13 +616,13 @@ class DecUserExtensionObject(_DecBaseObject): return self.ItemList.append(Item) =20 - ## GetAllUserExtensions + # GetAllUserExtensions # def GetAllUserExtensions(self): return self.ItemList =20 =20 -## DecUserExtensionItemObject +# DecUserExtensionItemObject # Item for user extension section # # @param _DecItemBaseObject: Dec Item Base Object @@ -599,7 +633,3 @@ class DecUserExtensionItemObject(_DecItemBaseObject): self.UserString =3D '' self.UserId =3D '' self.IdString =3D '' - - - - diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py index 6b55d01ab2a2..dd6210c697a3 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Binaries] section. # It will consumed by InfParser. # @@ -39,33 +39,41 @@ class InfBianryItem(): =20 def SetFileName(self, FileName): self.FileName =3D FileName + def GetFileName(self): return self.FileName =20 def SetTarget(self, Target): self.Target =3D Target + def GetTarget(self): return self.Target =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetType(self, Type): self.Type =3D Type + def GetType(self): return self.Type + def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 + class InfBianryVerItem(InfBianryItem, CurrentLine): def __init__(self): InfBianryItem.__init__(self) @@ -74,9 +82,11 @@ class InfBianryVerItem(InfBianryItem, CurrentLine): =20 def SetVerTypeName(self, VerTypeName): self.VerTypeName =3D VerTypeName + def GetVerTypeName(self): return self.VerTypeName =20 + class InfBianryUiItem(InfBianryItem, CurrentLine): def __init__(self): InfBianryItem.__init__(self) @@ -85,9 +95,11 @@ class InfBianryUiItem(InfBianryItem, CurrentLine): =20 def SetUiTypeName(self, UiTypeName): self.UiTypeName =3D UiTypeName + def GetVerTypeName(self): return self.UiTypeName =20 + class InfBianryCommonItem(InfBianryItem, CurrentLine): def __init__(self): self.CommonType =3D '' @@ -99,21 +111,25 @@ class InfBianryCommonItem(InfBianryItem, CurrentLine): =20 def SetCommonType(self, CommonType): self.CommonType =3D CommonType + def GetCommonType(self): return self.CommonType =20 def SetTagName(self, TagName): self.TagName =3D TagName + def GetTagName(self): return self.TagName =20 def SetFamily(self, Family): self.Family =3D Family + def GetFamily(self): return self.Family =20 def SetGuidValue(self, GuidValue): self.GuidValue =3D GuidValue + def GetGuidValue(self): return self.GuidValue =20 @@ -121,6 +137,8 @@ class InfBianryCommonItem(InfBianryItem, CurrentLine): # # # + + class InfBinariesObject(InfSectionCommonDef): def __init__(self): self.Binaries =3D Sdict() @@ -130,7 +148,7 @@ class InfBinariesObject(InfSectionCommonDef): self.Macros =3D {} InfSectionCommonDef.__init__(self) =20 - ## CheckVer + # CheckVer # # def CheckVer(self, Ver, __SupArchList): @@ -150,7 +168,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(VerContent) < 2: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID = % (VerContent[0], 2), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID = % ( + VerContent[0], 2), File=3DVerCurrentLine.GetFileName(), Line=3DVerCurrentLine.GetLineNo(), ExtraData=3DVerCurrentLine.GetLineString()) @@ -158,7 +177,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(VerContent) > 4: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_= MAX % (VerContent[0], 4), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_= MAX % ( + VerContent[0], 4), File=3DVerCurrentLine.GetFileName(), Line=3DVerCurrentLine.GetLineNo(), ExtraData=3DVerCurrentLine.GetLineString()) @@ -187,7 +207,8 @@ class InfBinariesObject(InfSectionCommonDef): if not (ValidFile(FullFileName) or ValidFile(VerContent[1]= )): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EX= IST % (VerContent[1]), + ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EX= IST % ( + VerContent[1]), File=3DVerCurrentLine.GetFileName(), Line=3DVerCurrentLine.GetLineNo(), ExtraData=3DVerCurrentLine.GetLineString(= )) @@ -199,14 +220,15 @@ class InfBinariesObject(InfSectionCommonDef): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % (VerContent[1]), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % ( + VerContent[1]), File=3DVerCurrentLine.GetFileName(), Line=3DVerCurrentLine.GetLineNo(), ExtraData=3DVerCurrentLine.GetLineString(= )) return False if IsValidFileFlag: VerContent[0] =3D ConvPathFromAbsToRel(VerContent[0], - GlobalData.gINF_MODULE_DIR) + GlobalData.gINF_M= ODULE_DIR) InfBianryVerItemObj.SetFileName(VerContent[1]) if len(VerContent) >=3D 3: # @@ -224,12 +246,13 @@ class InfBinariesObject(InfSectionCommonDef): # # Validate Feature Flag Express # - FeatureFlagRtv =3D IsValidFeatureFlagExp(VerContent[3].\ + FeatureFlagRtv =3D IsValidFeatureFlagExp(VerContent[3]. strip()) if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % ( + FeatureFlagRtv[1]), File=3DVerCurrentLine.GetFileName(), Line=3DVerCurrentLine.GetLineNo(), ExtraData=3DVerCurrentLine.GetLineString(= )) @@ -275,7 +298,7 @@ class InfBinariesObject(InfSectionCommonDef): BinariesList.append((InfBianryVerItemObj, VerComment)) self.Binaries[InfBianryVerItemObj] =3D BinariesList =20 - ## ParseCommonBinary + # ParseCommonBinary # # ParseCommonBinary # @@ -295,7 +318,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(ItemContent) < 3: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVA= LID % (ItemContent[0], 3), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVA= LID % ( + ItemContent[0], 3), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) @@ -304,7 +328,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(ItemContent) < 2: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVA= LID % (ItemContent[0], 2), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVA= LID % ( + ItemContent[0], 2), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) @@ -313,7 +338,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(ItemContent) > 7: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_= MAX % (ItemContent[0], 7), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_= MAX % ( + ItemContent[0], 7), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLineString()) @@ -333,7 +359,7 @@ class InfBinariesObject(InfSectionCommonDef): if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FIL= ETYPE % \ + ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FIL= ETYPE % (DT.BINARY_FILE_TYPE_LIST.__str__()), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), @@ -345,7 +371,7 @@ class InfBinariesObject(InfSectionCommonDef): if BinaryFileType =3D=3D 'LIB' or BinaryFileType =3D=3D 'U= EFI_APP': Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FIL= ETYPE % \ + ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FIL= ETYPE % (DT.BINARY_FILE_TYPE_LIST.__str__()), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), @@ -360,11 +386,11 @@ class InfBinariesObject(InfSectionCommonDef): FileName =3D ItemContent[2] else: Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FILENAME_NO= T_EXIST, - File=3DCurrentLineOfItem.GetFileName(), - Line=3DCurrentLineOfItem.GetLineNo(), - ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) + ToolError.FORMAT_INVALID, + ST.ERR_INF_PARSER_BINARY_ITEM_FILENAM= E_NOT_EXIST, + File=3DCurrentLineOfItem.GetFileName(= ), + Line=3DCurrentLineOfItem.GetLineNo(), + ExtraData=3DCurrentLineOfItem.GetLine= String()) else: FileName =3D ItemContent[1] # @@ -375,7 +401,8 @@ class InfBinariesObject(InfSectionCommonDef): if not (ValidFile(FullFileName) or ValidFile(FileName)): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EX= IST % (FileName), + ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EX= IST % ( + FileName), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) @@ -386,14 +413,16 @@ class InfBinariesObject(InfSectionCommonDef): IsValidFileFlag =3D True else: Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_I= NVALID % (FileName), - File=3DCurrentLineOfItem.GetFileName(), - Line=3DCurrentLineOfItem.GetLineNo(), - ExtraData=3DCurrentLineOfItem.GetLineStrin= g()) + ToolError.FORMAT_INVALID, + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % ( + FileName), + File=3DCurrentLineOfItem.GetFileName(), + Line=3DCurrentLineOfItem.GetLineNo(), + ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) return False if IsValidFileFlag: - ItemContent[0] =3D ConvPathFromAbsToRel(ItemContent[0]= , GlobalData.gINF_MODULE_DIR) + ItemContent[0] =3D ConvPathFromAbsToRel( + ItemContent[0], GlobalData.gINF_MODULE_DIR) InfBianryCommonItemObj.SetFileName(FileName) if len(ItemContent) >=3D 3: # @@ -423,7 +452,8 @@ class InfBinariesObject(InfSectionCommonDef): if ItemContent[4].strip() !=3D '': Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITT= ED % (ItemContent[4]), + ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITT= ED % ( + ItemContent[4]), File=3DCurrentLineOfItem.GetFileName(= ), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLine= String()) @@ -445,11 +475,13 @@ class InfBinariesObject(InfSectionCommonDef): # # Validate Feature Flag Express # - FeatureFlagRtv =3D IsValidFeatureFlagExp(ItemContent[5= ].strip()) + FeatureFlagRtv =3D IsValidFeatureFlagExp( + ItemContent[5].strip()) if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfItem.GetFileName(= ), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLine= String()) @@ -458,7 +490,8 @@ class InfBinariesObject(InfSectionCommonDef): if ItemContent[5].strip() !=3D '': Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITT= ED % (ItemContent[5]), + ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITT= ED % ( + ItemContent[5]), File=3DCurrentLineOfItem.GetFileName(= ), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLine= String()) @@ -466,11 +499,11 @@ class InfBinariesObject(InfSectionCommonDef): if len(ItemContent) =3D=3D 7: if ItemContent[6].strip() =3D=3D '': Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MI= SSING, - File=3DCurrentLineOfItem.GetFileName(= ), - Line=3DCurrentLineOfItem.GetLineNo(), - ExtraData=3DCurrentLineOfItem.GetLine= String()) + ToolError.FORMAT_INVALID, + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSIN= G, + File=3DCurrentLineOfItem.GetFileName(), + Line=3DCurrentLineOfItem.GetLineNo(), + ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) # # Validate Feature Flag Express # @@ -478,7 +511,8 @@ class InfBinariesObject(InfSectionCommonDef): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfItem.GetFileName(), Line=3DCurrentLineOfItem.GetLineNo(), ExtraData=3DCurrentLineOfItem.GetLineStri= ng()) @@ -554,7 +588,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(UiContent) < 2: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_= INVALID % (UiContent[0], 2), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_= INVALID % ( + UiContent[0], 2), File=3DUiCurrentLine.GetFileName(), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLineStri= ng()) @@ -563,7 +598,8 @@ class InfBinariesObject(InfSectionCommonDef): if len(UiContent) > 4: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_= INVALID_MAX % (UiContent[0], 4), + ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_= INVALID_MAX % ( + UiContent[0], 4), File=3DUiCurrentLine.GetFileName(), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLineStri= ng()) @@ -576,7 +612,8 @@ class InfBinariesObject(InfSectionCommonDef): if UiContent[0] !=3D 'UI': Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_VER_TYPE= % ('UI'), + ST.ERR_INF_PARSER_BINARY_VER_TYPE= % ( + 'UI'), File=3DUiCurrentLine.GetFileName(= ), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLine= String()) @@ -590,7 +627,8 @@ class InfBinariesObject(InfSectionCommonDef): if not (ValidFile(FullFileName) or ValidFile(UiCon= tent[1])): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_BINARY_ITEM_FIL= E_NOT_EXIST % (UiContent[1]), + ST.ERR_INF_PARSER_BINARY_ITEM_FIL= E_NOT_EXIST % ( + UiContent[1]), File=3DUiCurrentLine.GetFileName(= ), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLine= String()) @@ -602,13 +640,15 @@ class InfBinariesObject(InfSectionCommonDef): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_= OR_NAME_INVALID % (UiContent[1]), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_= OR_NAME_INVALID % ( + UiContent[1]), File=3DUiCurrentLine.GetFileName(= ), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLine= String()) return False if IsValidFileFlag: - UiContent[0] =3D ConvPathFromAbsToRel(UiConten= t[0], GlobalData.gINF_MODULE_DIR) + UiContent[0] =3D ConvPathFromAbsToRel( + UiContent[0], GlobalData.gINF_MODULE_DIR) InfBianryUiItemObj.SetFileName(UiContent[1]) if len(UiContent) >=3D 3: # @@ -626,11 +666,13 @@ class InfBinariesObject(InfSectionCommonDef): # # Validate Feature Flag Express # - FeatureFlagRtv =3D IsValidFeatureFlagExp(UiContent= [3].strip()) + FeatureFlagRtv =3D IsValidFeatureFlagExp( + UiContent[3].strip()) if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EX= P_SYNTAX_INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EX= P_SYNTAX_INVLID % ( + FeatureFlagRtv[1]), File=3DUiCurrentLine.GetFileName(= ), Line=3DUiCurrentLine.GetLineNo(), ExtraData=3DUiCurrentLine.GetLine= String()) @@ -669,11 +711,13 @@ class InfBinariesObject(InfSectionCommonDef): if InfBianryUiItemObj is not None: if (InfBianryUiItemObj) in self.Binaries: BinariesList =3D self.Binaries[InfBianryUiItem= Obj] - BinariesList.append((InfBianryUiItemObj, UiCom= ment)) + BinariesList.append( + (InfBianryUiItemObj, UiComment)) self.Binaries[InfBianryUiItemObj] =3D Binaries= List else: BinariesList =3D [] - BinariesList.append((InfBianryUiItemObj, UiCom= ment)) + BinariesList.append( + (InfBianryUiItemObj, UiComment)) self.Binaries[InfBianryUiItemObj] =3D Binaries= List if Ver is not None and len(Ver) > 0: self.CheckVer(Ver, __SupArchList) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject= .py b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py index fdba5db98311..a00a93436f78 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [BuildOptions] sec= tion. # It will consumed by InfParser. # @@ -14,19 +14,22 @@ from Library import GlobalData =20 from Object.Parser.InfCommonObject import InfSectionCommonDef =20 + class InfBuildOptionItem(): def __init__(self): - self.Content =3D '' + self.Content =3D '' self.SupArchList =3D [] self.AsBuildList =3D [] =20 def SetContent(self, Content): self.Content =3D Content + def GetContent(self): return self.Content =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 @@ -35,11 +38,12 @@ class InfBuildOptionItem(): # def SetAsBuildList(self, AsBuildList): self.AsBuildList =3D AsBuildList + def GetAsBuildList(self): return self.AsBuildList =20 =20 -## INF BuildOption section +# INF BuildOption section # Macro define is not permitted for this section. # # @@ -47,7 +51,7 @@ class InfBuildOptionsObject(InfSectionCommonDef): def __init__(self): self.BuildOptions =3D [] InfSectionCommonDef.__init__(self) - ## SetBuildOptions function + # SetBuildOptions function # # For BuildOptionName, need to validate its format # For BuildOptionValue, just ignore it. @@ -61,7 +65,8 @@ class InfBuildOptionsObject(InfSectionCommonDef): # @return True Build options set/validate successfully # @return False Build options set/validate failed # - def SetBuildOptions(self, BuildOptCont, ArchList =3D None, SectionCont= ent =3D ''): + + def SetBuildOptions(self, BuildOptCont, ArchList=3DNone, SectionConten= t=3D''): =20 if not GlobalData.gIS_BINARY_INF: =20 diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py index aa23d0878890..05871d9320a9 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfCommonObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common class objects for INF file. # It will consumed by InfParser # @@ -10,7 +10,7 @@ InfCommonObject ''' =20 -## InfLineCommentObject +# InfLineCommentObject # # Comment Object for any line in the INF file # @@ -19,6 +19,8 @@ InfCommonObject # # # Line # TailComment # + + class InfLineCommentObject(): def __init__(self): self.HeaderComments =3D '' @@ -36,46 +38,48 @@ class InfLineCommentObject(): def GetTailComments(self): return self.TailComments =20 -## CurrentLine +# CurrentLine # + + class CurrentLine(): def __init__(self): self.LineNo =3D '' self.LineString =3D '' self.FileName =3D '' =20 - ## SetLineNo + # SetLineNo # # @param LineNo: LineNo # def SetLineNo(self, LineNo): self.LineNo =3D LineNo =20 - ## GetLineNo + # GetLineNo # def GetLineNo(self): return self.LineNo =20 - ## SetLineString + # SetLineString # # @param LineString: Line String content # def SetLineString(self, LineString): self.LineString =3D LineString =20 - ## GetLineString + # GetLineString # def GetLineString(self): return self.LineString =20 - ## SetFileName + # SetFileName # # @param FileName: File Name # def SetFileName(self, FileName): self.FileName =3D FileName =20 - ## GetFileName + # GetFileName # def GetFileName(self): return self.FileName @@ -83,6 +87,8 @@ class CurrentLine(): ## # Inf Section common data # + + class InfSectionCommonDef(): def __init__(self): # @@ -93,43 +99,43 @@ class InfSectionCommonDef(): # data # self.HeaderComments =3D '' - self.TailComments =3D '' + self.TailComments =3D '' # # The support arch list of this section # - self.SupArchList =3D [] + self.SupArchList =3D [] =20 # # Store all section content # Key is supported Arch # - self.AllContent =3D {} + self.AllContent =3D {} =20 - ## SetHeaderComments + # SetHeaderComments # # @param HeaderComments: HeaderComments # def SetHeaderComments(self, HeaderComments): self.HeaderComments =3D HeaderComments =20 - ## GetHeaderComments + # GetHeaderComments # def GetHeaderComments(self): return self.HeaderComments =20 - ## SetTailComments + # SetTailComments # # @param TailComments: TailComments # def SetTailComments(self, TailComments): self.TailComments =3D TailComments =20 - ## GetTailComments + # GetTailComments # def GetTailComments(self): return self.TailComments =20 - ## SetSupArchList + # SetSupArchList # # @param Arch: Arch # @@ -137,12 +143,12 @@ class InfSectionCommonDef(): if Arch not in self.SupArchList: self.SupArchList.append(Arch) =20 - ## GetSupArchList + # GetSupArchList # def GetSupArchList(self): return self.SupArchList =20 - ## SetAllContent + # SetAllContent # # @param ArchList: ArchList # @param Content: Content @@ -150,7 +156,7 @@ class InfSectionCommonDef(): def SetAllContent(self, Content): self.AllContent =3D Content =20 - ## GetAllContent + # GetAllContent # def GetAllContent(self): return self.AllContent diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObjec= t.py b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py index 738a4c2dbf41..16e804e40f98 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineCommonObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define common class objects of [Defines] section fo= r INF file. # It will consumed by InfParser # @@ -12,37 +12,48 @@ InfDefineCommonObject =20 from Object.Parser.InfCommonObject import InfLineCommentObject =20 -## InfDefineImageExeParamItem +# InfDefineImageExeParamItem # + + class InfDefineImageExeParamItem(): def __init__(self): - self.CName =3D '' + self.CName =3D '' self.FeatureFlagExp =3D '' self.Comments =3D InfLineCommentObject() =20 def SetCName(self, CName): self.CName =3D CName + def GetCName(self): return self.CName + def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 -## InfDefineEntryPointItem +# InfDefineEntryPointItem # + + class InfDefineEntryPointItem(InfDefineImageExeParamItem): def __init__(self): InfDefineImageExeParamItem.__init__(self) =20 -## InfDefineUnloadImageItem +# InfDefineUnloadImageItem # + + class InfDefineUnloadImageItem(InfDefineImageExeParamItem): def __init__(self): InfDefineImageExeParamItem.__init__(self) =20 -## InfDefineConstructorItem +# InfDefineConstructorItem # + + class InfDefineConstructorItem(InfDefineImageExeParamItem): def __init__(self): InfDefineImageExeParamItem.__init__(self) @@ -50,11 +61,14 @@ class InfDefineConstructorItem(InfDefineImageExeParamIt= em): =20 def SetSupModList(self, SupModList): self.SupModList =3D SupModList + def GetSupModList(self): return self.SupModList =20 -## InfDefineDestructorItem +# InfDefineDestructorItem # + + class InfDefineDestructorItem(InfDefineImageExeParamItem): def __init__(self): InfDefineImageExeParamItem.__init__(self) @@ -62,11 +76,14 @@ class InfDefineDestructorItem(InfDefineImageExeParamIte= m): =20 def SetSupModList(self, SupModList): self.SupModList =3D SupModList + def GetSupModList(self): return self.SupModList =20 -## InfDefineLibraryItem +# InfDefineLibraryItem # + + class InfDefineLibraryItem(): def __init__(self): self.LibraryName =3D '' @@ -75,9 +92,12 @@ class InfDefineLibraryItem(): =20 def SetLibraryName(self, Name): self.LibraryName =3D Name + def GetLibraryName(self): return self.LibraryName + def SetTypes(self, Type): self.Types =3D Type + def GetTypes(self): return self.Types diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py index a1b691ff0300..aa3d20ae2fa4 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of [Defines] section for INF f= ile. # It will consumed by InfParser # @@ -44,20 +44,22 @@ from Object.Parser.InfDefineCommonObject import InfDefi= neUnloadImageItem from Object.Parser.InfDefineCommonObject import InfDefineConstructorItem from Object.Parser.InfDefineCommonObject import InfDefineDestructorItem =20 + class InfDefSectionOptionRomInfo(): def __init__(self): - self.PciVendorId =3D None - self.PciDeviceId =3D None - self.PciClassCode =3D None - self.PciRevision =3D None - self.PciCompress =3D None - self.CurrentLine =3D ['', -1, ''] + self.PciVendorId =3D None + self.PciDeviceId =3D None + self.PciClassCode =3D None + self.PciRevision =3D None + self.PciCompress =3D None + self.CurrentLine =3D ['', -1, ''] + def SetPciVendorId(self, PciVendorId, Comments): # # Value has been set before. # if self.PciVendorId is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_PCI_VENDOR_ID), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_PCI_VENDOR_ID), LineInfo=3Dself.CurrentLine) return False # @@ -69,7 +71,7 @@ class InfDefSectionOptionRomInfo(): self.PciVendorId.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciVendorI= d), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PciVendo= rId), LineInfo=3Dself.CurrentLine) return False =20 @@ -81,7 +83,7 @@ class InfDefSectionOptionRomInfo(): # Value has been set before. # if self.PciDeviceId is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_PCI_DEVICE_ID), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_PCI_DEVICE_ID), LineInfo=3Dself.CurrentLine) return False # @@ -93,7 +95,7 @@ class InfDefSectionOptionRomInfo(): self.PciDeviceId.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciDeviceI= d), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PciDevic= eId), LineInfo=3Dself.CurrentLine) return False =20 @@ -105,7 +107,7 @@ class InfDefSectionOptionRomInfo(): # Value has been set before. # if self.PciClassCode is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_PCI_CLASS_CODE), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_PCI_CLASS_CODE), LineInfo=3Dself.CurrentLine) return False # @@ -117,7 +119,7 @@ class InfDefSectionOptionRomInfo(): self.PciClassCode.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\ + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PciClassCode), LineInfo=3Dself.CurrentLine) return False @@ -130,7 +132,7 @@ class InfDefSectionOptionRomInfo(): # Value has been set before. # if self.PciRevision is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_PCI_REVISION), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_PCI_REVISION), LineInfo=3Dself.CurrentLine) return False # @@ -142,7 +144,7 @@ class InfDefSectionOptionRomInfo(): self.PciRevision.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciRevisio= n), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PciRevis= ion), LineInfo=3Dself.CurrentLine) return False =20 @@ -154,7 +156,7 @@ class InfDefSectionOptionRomInfo(): # Value has been set before. # if self.PciCompress is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_PCI_COMPRESS), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_PCI_COMPRESS), LineInfo=3Dself.CurrentLine) return False =20 @@ -167,41 +169,44 @@ class InfDefSectionOptionRomInfo(): self.PciCompress.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciCompres= s), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PciCompr= ess), LineInfo=3Dself.CurrentLine) return False + def GetPciCompress(self): return self.PciCompress ## # INF [Define] section Object # + + class InfDefSection(InfDefSectionOptionRomInfo): def __init__(self): - self.BaseName =3D None - self.FileGuid =3D None - self.ModuleType =3D None - self.ModuleUniFileName =3D None - self.InfVersion =3D None - self.EdkReleaseVersion =3D None - self.UefiSpecificationVersion =3D None - self.PiSpecificationVersion =3D None - self.LibraryClass =3D [] - self.Package =3D None - self.VersionString =3D None - self.PcdIsDriver =3D None - self.EntryPoint =3D [] - self.UnloadImages =3D [] - self.Constructor =3D [] - self.Destructor =3D [] - self.Shadow =3D None - self.CustomMakefile =3D [] - self.Specification =3D [] - self.UefiHiiResourceSection =3D None - self.DpxSource =3D [] - self.CurrentLine =3D ['', -1, ''] + self.BaseName =3D None + self.FileGuid =3D None + self.ModuleType =3D None + self.ModuleUniFileName =3D None + self.InfVersion =3D None + self.EdkReleaseVersion =3D None + self.UefiSpecificationVersion =3D None + self.PiSpecificationVersion =3D None + self.LibraryClass =3D [] + self.Package =3D None + self.VersionString =3D None + self.PcdIsDriver =3D None + self.EntryPoint =3D [] + self.UnloadImages =3D [] + self.Constructor =3D [] + self.Destructor =3D [] + self.Shadow =3D None + self.CustomMakefile =3D [] + self.Specification =3D [] + self.UefiHiiResourceSection =3D None + self.DpxSource =3D [] + self.CurrentLine =3D ['', -1, ''] InfDefSectionOptionRomInfo.__init__(self) =20 - ## SetHeadComment + # SetHeadComment # # @param BaseName: BaseName # @@ -210,7 +215,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.BaseName is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_BASE_NAME), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_BASE_NAME), LineInfo=3Dself.CurrentLine) return False if not (BaseName =3D=3D '' or BaseName is None): @@ -220,16 +225,16 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.BaseName.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_NAME_INVALID%(BaseName= ), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (BaseNa= me), LineInfo=3Dself.CurrentLine) return False =20 - ## GetBaseName + # GetBaseName # def GetBaseName(self): return self.BaseName =20 - ## SetFileGuid + # SetFileGuid # # @param FileGuid: FileGuid # @@ -238,8 +243,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.FileGuid is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_FILE_GUID), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_FILE_GUID), LineInfo=3Dself.CurrentLine) return False # @@ -251,16 +256,16 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.FileGuid.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_GUID_INVALID%(FileGuid), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_GUID_INVALID % (FileGuid), LineInfo=3Dself.CurrentLine) return False =20 - ## GetFileGuid + # GetFileGuid # def GetFileGuid(self): return self.FileGuid =20 - ## SetModuleType + # SetModuleType # # @param ModuleType: ModuleType # @@ -269,8 +274,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.ModuleType is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_MODULE_TYPE), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_MODULE_TYPE), LineInfo=3Dself.CurrentLine) return False # @@ -286,17 +291,17 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.ModuleType.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%\ + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID % (ModuleType), LineInfo=3Dself.CurrentLine) return False =20 - ## GetModuleType + # GetModuleType # def GetModuleType(self): return self.ModuleType =20 - ## SetModuleUniFileName + # SetModuleUniFileName # # @param ModuleUniFileName: ModuleUniFileName # @@ -304,16 +309,16 @@ class InfDefSection(InfDefSectionOptionRomInfo): if Comments: pass if self.ModuleUniFileName is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_MODULE_UNI_FILE), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_MODULE_UNI_FILE), LineInfo=3Dself.CurrentLine) self.ModuleUniFileName =3D ModuleUniFileName =20 - ## GetModuleType + # GetModuleType # def GetModuleUniFileName(self): return self.ModuleUniFileName =20 - ## SetInfVersion + # SetInfVersion # # @param InfVersion: InfVersion # @@ -322,8 +327,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.InfVersion is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_INF_VERSION), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_INF_VERSION), LineInfo=3Dself.CurrentLine) return False # @@ -340,7 +345,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): ErrorCode=3DToolError.EDK1_INF_ERROR, LineInfo=3Dself.CurrentLine) else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(InfVersion= ), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (InfVersi= on), LineInfo=3Dself.CurrentLine) return False =20 @@ -349,12 +354,12 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.InfVersion.Comments =3D Comments return True =20 - ## GetInfVersion + # GetInfVersion # def GetInfVersion(self): return self.InfVersion =20 - ## SetEdkReleaseVersion + # SetEdkReleaseVersion # # @param EdkReleaseVersion: EdkReleaseVersion # @@ -363,8 +368,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.EdkReleaseVersion is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION), LineInfo=3Dself.CurrentLine) return False # @@ -377,17 +382,17 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.EdkReleaseVersion.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ - %(EdkReleaseVersion), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID + % (EdkReleaseVersion), LineInfo=3Dself.CurrentLine) return False =20 - ## GetEdkReleaseVersion + # GetEdkReleaseVersion # def GetEdkReleaseVersion(self): return self.EdkReleaseVersion =20 - ## SetUefiSpecificationVersion + # SetUefiSpecificationVersion # # @param UefiSpecificationVersion: UefiSpecificationVersion # @@ -396,8 +401,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.UefiSpecificationVersion is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION), LineInfo=3Dself.CurrentLine) return False # @@ -410,17 +415,17 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.UefiSpecificationVersion.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ - %(UefiSpecificationVersion), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID + % (UefiSpecificationVersion), LineInfo=3Dself.CurrentLine) return False =20 - ## GetUefiSpecificationVersion + # GetUefiSpecificationVersion # def GetUefiSpecificationVersion(self): return self.UefiSpecificationVersion =20 - ## SetPiSpecificationVersion + # SetPiSpecificationVersion # # @param PiSpecificationVersion: PiSpecificationVersion # @@ -429,8 +434,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.PiSpecificationVersion is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION), LineInfo=3Dself.CurrentLine) return False # @@ -443,17 +448,17 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.PiSpecificationVersion.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ - %(PiSpecificationVersion), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID + % (PiSpecificationVersion), LineInfo=3Dself.CurrentLine) return False =20 - ## GetPiSpecificationVersion + # GetPiSpecificationVersion # def GetPiSpecificationVersion(self): return self.PiSpecificationVersion =20 - ## SetLibraryClass + # SetLibraryClass # # @param LibraryClass: LibraryClass # @@ -470,13 +475,13 @@ class InfDefSection(InfDefSectionOptionRomInfo): TypeList =3D [Type for Type in TypeList if Type !=3D ''] for Item in TypeList: if Item not in DT.MODULE_LIST: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID= %(Item), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID= % (Item), LineInfo=3Dself.CurrentLine) return False InfDefineLibraryItemObj.SetTypes(TypeList) self.LibraryClass.append(InfDefineLibraryItemObj) else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Name), LineInfo=3Dself.CurrentLine) return False =20 @@ -490,20 +495,19 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.VersionString is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_VERSION_STRING), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_VERSION_STRING), LineInfo=3Dself.CurrentLine) return False if not IsValidDecVersion(VersionString): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ - %(VersionString), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID + % (VersionString), LineInfo=3Dself.CurrentLine) self.VersionString =3D InfDefMember() self.VersionString.SetValue(VersionString) self.VersionString.Comments =3D Comments return True =20 - def GetVersionString(self): return self.VersionString =20 @@ -512,8 +516,8 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.PcdIsDriver is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ - %(DT.TAB_INF_DEFINES_PCD_IS_DRIVER), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND + % (DT.TAB_INF_DEFINES_PCD_IS_DRIVER), LineInfo=3Dself.CurrentLine) return False if PcdIsDriver =3D=3D 'PEI_PCD_DRIVER' or PcdIsDriver =3D=3D 'DXE_= PCD_DRIVER': @@ -522,7 +526,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.PcdIsDriver.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PcdIsDrive= r), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (PcdIsDri= ver), LineInfo=3Dself.CurrentLine) return False =20 @@ -541,13 +545,13 @@ class InfDefSection(InfDefSectionOptionRomInfo): ValueList[0:len(TokenList)] =3D TokenList InfDefineEntryPointItemObj =3D InfDefineEntryPointItem() if not IsValidCVariableName(ValueList[0]): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\ + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[0]), LineInfo=3Dself.CurrentLine) InfDefineEntryPointItemObj.SetCName(ValueList[0]) if len(ValueList) =3D=3D 2: if ValueList[1].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\ + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[1]), LineInfo=3Dself.CurrentLine) # @@ -555,12 +559,12 @@ class InfDefSection(InfDefSectionOptionRomInfo): # FeatureFlagRtv =3D IsValidFeatureFlagExp(ValueList[1].strip()) if not FeatureFlagRtv[0]: - ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D%\ + ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D % (FeatureFlagRtv[1]), LineInfo=3Dself.CurrentLine) InfDefineEntryPointItemObj.SetFeatureFlagExp(ValueList[1]) if len(ValueList) > 2: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(EntryPoint= ), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (EntryPoi= nt), LineInfo=3Dself.CurrentLine) InfDefineEntryPointItemObj.Comments =3D Comments self.EntryPoint.append(InfDefineEntryPointItemObj) @@ -580,24 +584,24 @@ class InfDefSection(InfDefSectionOptionRomInfo): ValueList[0:len(TokenList)] =3D TokenList InfDefineUnloadImageItemObj =3D InfDefineUnloadImageItem() if not IsValidCVariableName(ValueList[0]): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[= 0]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueLis= t[0]), LineInfo=3Dself.CurrentLine) InfDefineUnloadImageItemObj.SetCName(ValueList[0]) if len(ValueList) =3D=3D 2: if ValueList[1].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueL= ist[1]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Valu= eList[1]), LineInfo=3Dself.CurrentLine) # # Validate FFE # FeatureFlagRtv =3D IsValidFeatureFlagExp(ValueList[1].strip()) if not FeatureFlagRtv[0]: - ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D%(FeatureFlagRtv[1]), + ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D % (FeatureFlagRtv[1]), LineInfo=3Dself.CurrentLine) InfDefineUnloadImageItemObj.SetFeatureFlagExp(ValueList[1]) =20 if len(ValueList) > 2: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UnloadImag= es), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (UnloadIm= ages), LineInfo=3Dself.CurrentLine) InfDefineUnloadImageItemObj.Comments =3D Comments self.UnloadImages.append(InfDefineUnloadImageItemObj) @@ -617,34 +621,34 @@ class InfDefSection(InfDefSectionOptionRomInfo): ValueList[0:len(TokenList)] =3D TokenList InfDefineConstructorItemObj =3D InfDefineConstructorItem() if not IsValidCVariableName(ValueList[0]): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[= 0]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueLis= t[0]), LineInfo=3Dself.CurrentLine) InfDefineConstructorItemObj.SetCName(ValueList[0]) if len(ValueList) >=3D 2: ModList =3D GetSplitValueList(ValueList[1], ' ') if ValueList[1].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueL= ist[1]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Valu= eList[1]), LineInfo=3Dself.CurrentLine) for ModItem in ModList: if ModItem not in DT.MODULE_LIST: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID= %(ModItem), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID= % (ModItem), LineInfo=3Dself.CurrentLine) InfDefineConstructorItemObj.SetSupModList(ModList) if len(ValueList) =3D=3D 3: if ValueList[2].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueL= ist[2]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Valu= eList[2]), LineInfo=3Dself.CurrentLine) # # Validate FFE # FeatureFlagRtv =3D IsValidFeatureFlagExp(ValueList[2].strip()) if not FeatureFlagRtv[0]: - ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D%(FeatureFlagRtv[2]), + ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D % (FeatureFlagRtv[2]), LineInfo=3Dself.CurrentLine) InfDefineConstructorItemObj.SetFeatureFlagExp(ValueList[2]) =20 if len(ValueList) > 3: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Constructo= r), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Construc= tor), LineInfo=3Dself.CurrentLine) InfDefineConstructorItemObj.Comments =3D Comments self.Constructor.append(InfDefineConstructorItemObj) @@ -664,34 +668,34 @@ class InfDefSection(InfDefSectionOptionRomInfo): ValueList[0:len(TokenList)] =3D TokenList InfDefineDestructorItemObj =3D InfDefineDestructorItem() if not IsValidCVariableName(ValueList[0]): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[= 0]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueLis= t[0]), LineInfo=3Dself.CurrentLine) InfDefineDestructorItemObj.SetCName(ValueList[0]) if len(ValueList) >=3D 2: ModList =3D GetSplitValueList(ValueList[1].strip(), ' ') if ValueList[1].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueL= ist[1]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Valu= eList[1]), LineInfo=3Dself.CurrentLine) for ModItem in ModList: if ModItem not in DT.MODULE_LIST: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID= %(ModItem), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID= % (ModItem), LineInfo=3Dself.CurrentLine) InfDefineDestructorItemObj.SetSupModList(ModList) if len(ValueList) =3D=3D 3: if ValueList[2].strip() =3D=3D '': - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueL= ist[2]), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Valu= eList[2]), LineInfo=3Dself.CurrentLine) # # Validate FFE # FeatureFlagRtv =3D IsValidFeatureFlagExp(ValueList[2].strip()) if not FeatureFlagRtv[0]: - ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D%(FeatureFlagRtv[1]), + ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLI= D % (FeatureFlagRtv[1]), LineInfo=3Dself.CurrentLine) InfDefineDestructorItemObj.SetFeatureFlagExp(ValueList[2]) =20 if len(ValueList) > 3: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Destructor= ), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Destruct= or), LineInfo=3Dself.CurrentLine) =20 InfDefineDestructorItemObj.Comments =3D Comments @@ -705,7 +709,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): # Value has been set before. # if self.Shadow is not None: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(= DT.TAB_INF_DEFINES_SHADOW), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND %= (DT.TAB_INF_DEFINES_SHADOW), LineInfo=3Dself.CurrentLine) return False if (IsValidBoolType(Shadow)): @@ -714,9 +718,10 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.Shadow.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Shadow), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Shadow), LineInfo=3Dself.CurrentLine) return False + def GetShadow(self): return self.Shadow =20 @@ -736,7 +741,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): Family =3D Family.strip() if Family !=3D '': if not IsValidFamily(Family): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Fa= mily), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (= Family), LineInfo=3Dself.CurrentLine) return False # @@ -747,11 +752,12 @@ class InfDefSection(InfDefSectionOptionRomInfo): if IsValidPath(FileName, ModulePath): IsValidFileFlag =3D True else: - ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALI= D%(FileName), + ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALI= D % (FileName), LineInfo=3Dself.CurrentLine) return False if IsValidFileFlag: - FileName =3D ConvPathFromAbsToRel(FileName, GlobalData.gIN= F_MODULE_DIR) + FileName =3D ConvPathFromAbsToRel( + FileName, GlobalData.gINF_MODULE_DIR) self.CustomMakefile.append((Family, FileName, Comments)) IsValidFileFlag =3D False return True @@ -785,11 +791,11 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.Specification.append((Name, Version, Comments)) return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Versio= n), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Vers= ion), LineInfo=3Dself.CurrentLine) return False else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Name), LineInfo=3Dself.CurrentLine) return False return True @@ -807,7 +813,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): # if self.UefiHiiResourceSection is not None: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND - %(DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION), + % (DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION), LineInfo=3Dself.CurrentLine) return False if not (UefiHiiResourceSection =3D=3D '' or UefiHiiResourceSection= is None): @@ -817,7 +823,7 @@ class InfDefSection(InfDefSectionOptionRomInfo): self.UefiHiiResourceSection.Comments =3D Comments return True else: - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UefiHi= iResourceSection), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Uefi= HiiResourceSection), LineInfo=3Dself.CurrentLine) return False else: @@ -835,12 +841,12 @@ class InfDefSection(InfDefSectionOptionRomInfo): if IsValidPath(DpxSource, ModulePath): IsValidFileFlag =3D True else: - ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(D= pxSource), + ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % = (DpxSource), LineInfo=3Dself.CurrentLine) return False if IsValidFileFlag: DpxSource =3D ConvPathFromAbsToRel(DpxSource, - GlobalData.gINF_MODULE_DIR) + GlobalData.gINF_MODULE_DIR) self.DpxSource.append((DpxSource, Comments)) IsValidFileFlag =3D False return True @@ -848,69 +854,79 @@ class InfDefSection(InfDefSectionOptionRomInfo): def GetDpxSource(self): return self.DpxSource =20 + gFUNCTION_MAPPING_FOR_DEFINE_SECTION =3D { # # Required Fields # - DT.TAB_INF_DEFINES_BASE_NAME : InfDefSection.SetBase= Name, - DT.TAB_INF_DEFINES_FILE_GUID : InfDefSection.SetFile= Guid, - DT.TAB_INF_DEFINES_MODULE_TYPE : InfDefSection.SetModu= leType, + DT.TAB_INF_DEFINES_BASE_NAME: InfDefSection.SetBaseName, + DT.TAB_INF_DEFINES_FILE_GUID: InfDefSection.SetFileGuid, + DT.TAB_INF_DEFINES_MODULE_TYPE: InfDefSection.SetModuleType, # # Required by EDKII style INF file # - DT.TAB_INF_DEFINES_INF_VERSION : InfDefSection.SetInfV= ersion, + DT.TAB_INF_DEFINES_INF_VERSION: InfDefSection.SetInfVersion, # # Optional Fields # - DT.TAB_INF_DEFINES_MODULE_UNI_FILE : InfDefSection.SetModu= leUniFileName, - DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION : InfDefSection.SetEdkR= eleaseVersion, - DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : InfDefSection.SetUefi= SpecificationVersion, - DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION : InfDefSection.SetPiSp= ecificationVersion, - DT.TAB_INF_DEFINES_LIBRARY_CLASS : InfDefSection.SetLibr= aryClass, - DT.TAB_INF_DEFINES_VERSION_STRING : InfDefSection.SetVers= ionString, - DT.TAB_INF_DEFINES_PCD_IS_DRIVER : InfDefSection.SetPcdI= sDriver, - DT.TAB_INF_DEFINES_ENTRY_POINT : InfDefSection.SetEntr= yPoint, - DT.TAB_INF_DEFINES_UNLOAD_IMAGE : InfDefSection.SetUnlo= adImages, - DT.TAB_INF_DEFINES_CONSTRUCTOR : InfDefSection.SetCons= tructor, - DT.TAB_INF_DEFINES_DESTRUCTOR : InfDefSection.SetDest= ructor, - DT.TAB_INF_DEFINES_SHADOW : InfDefSection.SetShad= ow, - DT.TAB_INF_DEFINES_PCI_VENDOR_ID : InfDefSection.SetPciV= endorId, - DT.TAB_INF_DEFINES_PCI_DEVICE_ID : InfDefSection.SetPciD= eviceId, - DT.TAB_INF_DEFINES_PCI_CLASS_CODE : InfDefSection.SetPciC= lassCode, - DT.TAB_INF_DEFINES_PCI_REVISION : InfDefSection.SetPciR= evision, - DT.TAB_INF_DEFINES_PCI_COMPRESS : InfDefSection.SetPciC= ompress, - DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE : InfDefSection.SetCust= omMakefile, - DT.TAB_INF_DEFINES_SPEC : InfDefSection.SetSpec= ification, - DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION : InfDefSection.SetUefi= HiiResourceSection, - DT.TAB_INF_DEFINES_DPX_SOURCE : InfDefSection.SetDpxS= ource + DT.TAB_INF_DEFINES_MODULE_UNI_FILE: InfDefSection.SetModuleUniFileName, + DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION: InfDefSection.SetEdkReleaseVer= sion, + DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION: InfDefSection.SetUefiSp= ecificationVersion, + DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION: InfDefSection.SetPiSpecif= icationVersion, + DT.TAB_INF_DEFINES_LIBRARY_CLASS: InfDefSection.SetLibraryClass, + DT.TAB_INF_DEFINES_VERSION_STRING: InfDefSection.SetVersionString, + DT.TAB_INF_DEFINES_PCD_IS_DRIVER: InfDefSection.SetPcdIsDriver, + DT.TAB_INF_DEFINES_ENTRY_POINT: InfDefSection.SetEntryPoint, + DT.TAB_INF_DEFINES_UNLOAD_IMAGE: InfDefSection.SetUnloadImages, + DT.TAB_INF_DEFINES_CONSTRUCTOR: InfDefSection.SetConstructor, + DT.TAB_INF_DEFINES_DESTRUCTOR: InfDefSection.SetDestructor, + DT.TAB_INF_DEFINES_SHADOW: InfDefSection.SetShadow, + DT.TAB_INF_DEFINES_PCI_VENDOR_ID: InfDefSection.SetPciVendorId, + DT.TAB_INF_DEFINES_PCI_DEVICE_ID: InfDefSection.SetPciDeviceId, + DT.TAB_INF_DEFINES_PCI_CLASS_CODE: InfDefSection.SetPciClassCode, + DT.TAB_INF_DEFINES_PCI_REVISION: InfDefSection.SetPciRevision, + DT.TAB_INF_DEFINES_PCI_COMPRESS: InfDefSection.SetPciCompress, + DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE: InfDefSection.SetCustomMakefile, + DT.TAB_INF_DEFINES_SPEC: InfDefSection.SetSpecification, + DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION: InfDefSection.SetUefiHii= ResourceSection, + DT.TAB_INF_DEFINES_DPX_SOURCE: InfDefSection.SetDpxSource } =20 -## InfDefMember +# InfDefMember # # + + class InfDefMember(): def __init__(self, Name=3D'', Value=3D''): self.Comments =3D InfLineCommentObject() - self.Name =3D Name + self.Name =3D Name self.Value =3D Value self.CurrentLine =3D CurrentLine() + def GetName(self): return self.Name + def SetName(self, Name): self.Name =3D Name + def GetValue(self): return self.Value + def SetValue(self, Value): self.Value =3D Value =20 -## InfDefObject +# InfDefObject # # + + class InfDefObject(InfSectionCommonDef): def __init__(self): self.Defines =3D Sdict() InfSectionCommonDef.__init__(self) - def SetDefines(self, DefineContent, Arch =3D None): + + def SetDefines(self, DefineContent, Arch=3DNone): # # Validate Arch # @@ -926,16 +942,19 @@ class InfDefObject(InfSectionCommonDef): Value =3D InfDefMemberObj.GetValue() if Name =3D=3D DT.TAB_INF_DEFINES_MODULE_UNI_FILE: ValidateUNIFilePath(Value) - Value =3D os.path.join(os.path.dirname(InfDefMemberObj.Cur= rentLine.FileName), Value) + Value =3D os.path.join(os.path.dirname( + InfDefMemberObj.CurrentLine.FileName), Value) if not os.path.isfile(Value) or not os.path.exists(Value): LineInfo[0] =3D InfDefMemberObj.CurrentLine.GetFileNam= e() LineInfo[1] =3D InfDefMemberObj.CurrentLine.GetLineNo() LineInfo[2] =3D InfDefMemberObj.CurrentLine.GetLineStr= ing() - ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_IN= VALID%(Name), - LineInfo=3DLineInfo) + ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_IN= VALID % (Name), + LineInfo=3DLineInfo) InfLineCommentObj =3D InfLineCommentObject() - InfLineCommentObj.SetHeaderComments(InfDefMemberObj.Comments.G= etHeaderComments()) - InfLineCommentObj.SetTailComments(InfDefMemberObj.Comments.Get= TailComments()) + InfLineCommentObj.SetHeaderComments( + InfDefMemberObj.Comments.GetHeaderComments()) + InfLineCommentObj.SetTailComments( + InfDefMemberObj.Comments.GetTailComments()) if Name =3D=3D 'COMPONENT_TYPE': ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ErrorCode=3DToolError.EDK1_INF_ERROR, @@ -961,7 +980,7 @@ class InfDefObject(InfSectionCommonDef): # Found the process function from mapping table. # if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.ke= ys(): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWOR= D_INVALID%(Name), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWOR= D_INVALID % (Name), LineInfo=3DLineInfo) else: ProcessFunc =3D gFUNCTION_MAPPING_FOR_DEFINE_SECTI= ON[Name] @@ -978,7 +997,7 @@ class InfDefObject(InfSectionCommonDef): # Found the process function from mapping table. # if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.ke= ys(): - ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWOR= D_INVALID%(Name), + ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWOR= D_INVALID % (Name), LineInfo=3DLineInfo) # # Found the process function from mapping table. @@ -999,4 +1018,3 @@ class InfDefObject(InfSectionCommonDef): =20 def GetDefines(self): return self.Defines - diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py b/= BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py index 0de663291c11..870ca3317f16 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfDepexObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Depex] section. # It will consumed by InfParser. # @@ -19,6 +19,7 @@ from Logger import StringTable as ST from Object.Parser.InfCommonObject import InfSectionCommonDef from Library.ParserValidate import IsValidArch =20 + class InfDepexContentItem(): def __init__(self): self.SectionType =3D '' @@ -26,11 +27,13 @@ class InfDepexContentItem(): =20 def SetSectionType(self, SectionType): self.SectionType =3D SectionType + def GetSectionType(self): return self.SectionType =20 def SetSectionString(self, SectionString): self.SectionString =3D SectionString + def GetSectionString(self): return self.SectionString =20 @@ -46,38 +49,46 @@ class InfDepexItem(): =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetSupArch(self, Arch): self.SupArch =3D Arch + def GetSupArch(self): return self.SupArch =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetModuleType(self, Type): self.ModuleType =3D Type + def GetModuleType(self): return self.ModuleType =20 def SetDepexConent(self, Content): self.DepexContent =3D Content + def GetDepexContent(self): return self.DepexContent =20 def SetInfDepexContentItemList(self, InfDepexContentItemList): self.InfDepexContentItemList =3D InfDepexContentItemList + def GetInfDepexContentItemList(self): return self.InfDepexContentItemList =20 -## InfDepexObject +# InfDepexObject # # # + + class InfDepexObject(InfSectionCommonDef): def __init__(self): self.Depex =3D [] @@ -112,7 +123,8 @@ class InfDepexObject(InfSectionCommonDef): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TY= PE_ERROR % (ModuleType), + ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TY= PE_ERROR % ( + ModuleType), File=3DGlobalData.gINF_MODULE_NAME, Line=3DKeyItem[2]) =20 @@ -127,7 +139,8 @@ class InfDepexObject(InfSectionCommonDef): for Line in DepexContent: LineContent =3D Line[0].strip() if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - LineContent =3D LineContent[:LineContent.find(DT.TAB_C= OMMENT_SPLIT)] + LineContent =3D LineContent[:LineContent.find( + DT.TAB_COMMENT_SPLIT)] if LineContent: DepexString =3D DepexString + LineContent + DT.END_OF_= LINE continue diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py b/B= aseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py index 3e0bc8044003..997f8da17f63 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Guids] section. # It will consumed by InfParser. # @@ -20,6 +20,7 @@ import Logger.Log as Logger from Logger import ToolError from Logger import StringTable as ST =20 + class InfGuidItemCommentContent(): def __init__(self): # @@ -45,24 +46,29 @@ class InfGuidItemCommentContent(): =20 def SetUsageItem(self, UsageItem): self.UsageItem =3D UsageItem + def GetUsageItem(self): return self.UsageItem =20 def SetGuidTypeItem(self, GuidTypeItem): self.GuidTypeItem =3D GuidTypeItem + def GetGuidTypeItem(self): return self.GuidTypeItem =20 def SetVariableNameItem(self, VariableNameItem): self.VariableNameItem =3D VariableNameItem + def GetVariableNameItem(self): return self.VariableNameItem =20 def SetHelpStringItem(self, HelpStringItem): self.HelpStringItem =3D HelpStringItem + def GetHelpStringItem(self): return self.HelpStringItem =20 + class InfGuidItem(): def __init__(self): self.Name =3D '' @@ -75,33 +81,39 @@ class InfGuidItem(): =20 def SetName(self, Name): self.Name =3D Name + def GetName(self): return self.Name =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetCommentList(self, CommentList): self.CommentList =3D CommentList + def GetCommentList(self): return self.CommentList =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 -## ParseComment +# ParseComment # # ParseComment # + + def ParseGuidComment(CommentsList, InfGuidItemObj): # # Get/Set Usage and HelpString # - if CommentsList is not None and len(CommentsList) !=3D 0 : + if CommentsList is not None and len(CommentsList) !=3D 0: CommentInsList =3D [] PreUsage =3D None PreGuidType =3D None @@ -111,14 +123,14 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): for CommentItem in CommentsList: Count =3D Count + 1 CommentItemUsage, \ - CommentItemGuidType, \ - CommentItemVarString, \ - CommentItemHelpText =3D \ - ParseComment(CommentItem, - DT.ALL_USAGE_TOKENS, - DT.GUID_TYPE_TOKENS, - [], - True) + CommentItemGuidType, \ + CommentItemVarString, \ + CommentItemHelpText =3D \ + ParseComment(CommentItem, + DT.ALL_USAGE_TOKENS, + DT.GUID_TYPE_TOKENS, + [], + True) =20 if CommentItemHelpText is None: CommentItemHelpText =3D '' @@ -158,7 +170,8 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): CommentItemIns.SetGuidTypeItem(CommentItemGuidType) CommentItemIns.SetVariableNameItem(CommentItemVarString) if CommentItemHelpText =3D=3D '' or CommentItemHelpText.en= dswith(DT.END_OF_LINE): - CommentItemHelpText =3D CommentItemHelpText.strip(DT.E= ND_OF_LINE) + CommentItemHelpText =3D CommentItemHelpText.strip( + DT.END_OF_LINE) CommentItemIns.SetHelpStringItem(CommentItemHelpText) CommentInsList.append(CommentItemIns) =20 @@ -186,7 +199,8 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): CommentItemIns.SetGuidTypeItem(CommentItemGuidType) CommentItemIns.SetVariableNameItem(CommentItemVarString) if CommentItemHelpText =3D=3D '' or CommentItemHelpText.en= dswith(DT.END_OF_LINE): - CommentItemHelpText =3D CommentItemHelpText.strip(DT.E= ND_OF_LINE) + CommentItemHelpText =3D CommentItemHelpText.strip( + DT.END_OF_LINE) CommentItemIns.SetHelpStringItem(CommentItemHelpText) CommentInsList.append(CommentItemIns) =20 @@ -212,10 +226,12 @@ def ParseGuidComment(CommentsList, InfGuidItemObj): =20 return InfGuidItemObj =20 -## InfGuidObject +# InfGuidObject # # InfGuidObject # + + class InfGuidObject(): def __init__(self): self.Guids =3D Sdict() @@ -224,7 +240,7 @@ class InfGuidObject(): # self.Macros =3D {} =20 - def SetGuid(self, GuidList, Arch =3D None): + def SetGuid(self, GuidList, Arch=3DNone): __SupportArchList =3D [] for ArchItem in Arch: # @@ -252,7 +268,7 @@ class InfGuidObject(): if not IsValidCVariableName(Item[0]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]), + ST.ERR_INF_PARSER_INVALID_CNAME % (Item[0= ]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -285,7 +301,8 @@ class InfGuidObject(): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID%(FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py index 087edca93bc3..67b7b3267731 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfHeaderObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file header. # It will consumed by InfParser. # @@ -10,7 +10,7 @@ InfHeaderObject ''' =20 -## INF file header object +# INF file header object # # A sample file header # @@ -24,15 +24,17 @@ InfHeaderObject # # License # # # + + class InfHeaderObject(): def __init__(self): - self.FileName =3D '' - self.Abstract =3D '' + self.FileName =3D '' + self.Abstract =3D '' self.Description =3D '' - self.Copyright =3D '' - self.License =3D '' + self.Copyright =3D '' + self.License =3D '' =20 - ## SetFileName + # SetFileName # # @param FileName: File Name # @@ -43,12 +45,12 @@ class InfHeaderObject(): else: return False =20 - ## GetFileName + # GetFileName # def GetFileName(self): return self.FileName =20 - ## SetAbstract + # SetAbstract # # @param Abstract: Abstract # @@ -59,12 +61,12 @@ class InfHeaderObject(): else: return False =20 - ## GetAbstract + # GetAbstract # def GetAbstract(self): return self.Abstract =20 - ## SetDescription + # SetDescription # # @param Description: Description content # @@ -75,12 +77,12 @@ class InfHeaderObject(): else: return False =20 - ## GetAbstract + # GetAbstract # def GetDescription(self): return self.Description =20 - ## SetCopyright + # SetCopyright # # @param Copyright: Copyright content # @@ -91,12 +93,12 @@ class InfHeaderObject(): else: return False =20 - ## GetCopyright + # GetCopyright # def GetCopyright(self): return self.Copyright =20 - ## SetCopyright + # SetCopyright # # @param License: License content # @@ -107,7 +109,7 @@ class InfHeaderObject(): else: return False =20 - ## GetLicense + # GetLicense # def GetLicense(self): return self.License diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObj= ect.py b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.= py index 2e56028318a1..423fb15fe43f 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfLibraryClassesObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [LibraryClasses] s= ection. # It will consumed by InfParser. # @@ -20,10 +20,12 @@ from Object.Parser.InfCommonObject import CurrentLine from Library.ExpressionValidate import IsValidFeatureFlagExp from Library.ParserValidate import IsValidLibName =20 -## GetArchModuleType +# GetArchModuleType # # Get Arch List and ModuleType List # + + def GetArchModuleType(KeyList): __SupArchList =3D [] __SupModuleList =3D [] @@ -62,26 +64,31 @@ class InfLibraryClassItem(): =20 def SetLibName(self, LibName): self.LibName =3D LibName + def GetLibName(self): return self.LibName =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 def SetSupModuleList(self, SupModuleList): self.SupModuleList =3D SupModuleList + def GetSupModuleList(self): return self.SupModuleList =20 @@ -90,18 +97,22 @@ class InfLibraryClassItem(): # def SetFileGuid(self, FileGuid): self.FileGuid =3D FileGuid + def GetFileGuid(self): return self.FileGuid =20 def SetVersion(self, Version): self.Version =3D Version + def GetVersion(self): return self.Version =20 -## INF LibraryClass Section +# INF LibraryClass Section # # # + + class InfLibraryClassObject(): def __init__(self): self.LibraryClasses =3D Sdict() @@ -110,7 +121,7 @@ class InfLibraryClassObject(): # self.Macros =3D {} =20 - ##SetLibraryClasses + # SetLibraryClasses # # # @param HelpString: It can be a common comment or contain a recom= mend @@ -139,15 +150,16 @@ class InfLibraryClassObject(): LibItemObj.SetLibName(LibItem[0]) else: Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_LIB_NAME= _INVALID, - File=3DGlobalData.gINF_MODULE_NAM= E, - Line=3DLibItemObj.CurrentLine.Get= LineNo(), - ExtraData=3DLibItemObj.CurrentLin= e.GetLineString()) + ToolError.FORMAT_INVALID, + ST.ERR_INF_PARSER_DEFINE_LIB_= NAME_INVALID, + File=3DGlobalData.gINF_MODULE= _NAME, + Line=3DLibItemObj.CurrentLine= .GetLineNo(), + ExtraData=3DLibItemObj.Curren= tLine.GetLineString()) else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_I= NVALID % (LibItem[0]), + ST.ERR_INF_PARSER_DEFINE_FROMAT_I= NVALID % ( + LibItem[0]), File=3DGlobalData.gINF_MODULE_NAM= E, Line=3DLibItemObj.CurrentLine.Get= LineNo(), ExtraData=3DLibItemObj.CurrentLin= e.GetLineString()) @@ -173,7 +185,8 @@ class InfLibraryClassObject(): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % ( + FeatureFlagRtv[1]), File=3DGlobalData.gINF_MODULE_NAME, Line=3DLibItemObj.CurrentLine.GetLine= No(), ExtraData=3DLibItemObj.CurrentLine.Ge= tLineString()) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py b/BaseToo= ls/Source/Python/UPT/Object/Parser/InfMisc.py index 469d6fbb15ab..a07219d5b5cd 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file miscellaneous. # Include BootMode/HOB/Event and others. It will consumed by InfParser. # @@ -20,6 +20,8 @@ from Library.Misc import Sdict ## # BootModeObject # + + class InfBootModeObject(): def __init__(self): self.SupportedBootModes =3D '' @@ -28,21 +30,26 @@ class InfBootModeObject(): =20 def SetSupportedBootModes(self, SupportedBootModes): self.SupportedBootModes =3D SupportedBootModes + def GetSupportedBootModes(self): return self.SupportedBootModes =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetUsage(self, Usage): self.Usage =3D Usage + def GetUsage(self): return self.Usage ## # EventObject # + + class InfEventObject(): def __init__(self): self.EventType =3D '' @@ -57,16 +64,20 @@ class InfEventObject(): =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetUsage(self, Usage): self.Usage =3D Usage + def GetUsage(self): return self.Usage ## # HobObject # + + class InfHobObject(): def __init__(self): self.HobType =3D '' @@ -82,28 +93,33 @@ class InfHobObject(): =20 def SetUsage(self, Usage): self.Usage =3D Usage + def GetUsage(self): return self.Usage =20 def SetSupArchList(self, ArchList): self.SupArchList =3D ArchList + def GetSupArchList(self): return self.SupArchList =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 ## # InfSpecialCommentObject # + + class InfSpecialCommentObject(InfSectionCommonDef): def __init__(self): self.SpecialComments =3D Sdict() InfSectionCommonDef.__init__(self) =20 - def SetSpecialComments(self, SepcialSectionList =3D None, Type =3D ''): + def SetSpecialComments(self, SepcialSectionList=3DNone, Type=3D''): if Type =3D=3D DT.TYPE_HOB_SECTION or \ Type =3D=3D DT.TYPE_EVENT_SECTION or \ Type =3D=3D DT.TYPE_BOOTMODE_SECTION: @@ -123,8 +139,7 @@ class InfSpecialCommentObject(InfSectionCommonDef): return self.SpecialComments =20 =20 - -## ErrorInInf +# ErrorInInf # # An encapsulate of Error for INF parser. # diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py= b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py index 0e8fc7d98b3f..fe75340e8f37 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPackagesObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Packages] section. # It will consumed by InfParser. # @@ -19,38 +19,43 @@ from Library.Misc import Sdict from Library.ParserValidate import IsValidPath from Library.ExpressionValidate import IsValidFeatureFlagExp =20 + class InfPackageItem(): def __init__(self, - PackageName =3D '', - FeatureFlagExp =3D '', - HelpString =3D ''): - self.PackageName =3D PackageName + PackageName=3D'', + FeatureFlagExp=3D'', + HelpString=3D''): + self.PackageName =3D PackageName self.FeatureFlagExp =3D FeatureFlagExp - self.HelpString =3D HelpString - self.SupArchList =3D [] + self.HelpString =3D HelpString + self.SupArchList =3D [] =20 def SetPackageName(self, PackageName): self.PackageName =3D PackageName + def GetPackageName(self): return self.PackageName =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetHelpString(self, HelpString): self.HelpString =3D HelpString + def GetHelpString(self): return self.HelpString =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 =20 -## INF package section +# INF package section # # # @@ -60,11 +65,11 @@ class InfPackageObject(): # # Macro defined in this section should be only used in this sectio= n. # - self.Macros =3D {} + self.Macros =3D {} =20 - def SetPackages(self, PackageData, Arch =3D None): + def SetPackages(self, PackageData, Arch=3DNone): IsValidFileFlag =3D False - SupArchList =3D [] + SupArchList =3D [] for ArchItem in Arch: # # Validate Arch @@ -94,7 +99,8 @@ class InfPackageObject(): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID%(PackageItem[0]), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % ( + PackageItem[0]), File=3DCurrentLineOfPackItem[2], Line=3DCurrentLineOfPackItem[1], ExtraData=3DCurrentLineOfPackItem[0]) @@ -119,7 +125,8 @@ class InfPackageObject(): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID%(FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfPackItem[2], Line=3DCurrentLineOfPackItem[1], ExtraData=3DCurrentLineOfPackItem[0]) @@ -176,6 +183,6 @@ class InfPackageObject(): =20 return True =20 - def GetPackages(self, Arch =3D None): + def GetPackages(self, Arch=3DNone): if Arch is None: return self.Packages diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py b/Ba= seTools/Source/Python/UPT/Object/Parser/InfPcdObject.py index fd8065fab5f4..717834a4aec0 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Pcds] section. # It will consumed by InfParser. # @@ -33,6 +33,7 @@ from Parser.DecParser import Dec =20 from Object.Parser.InfPackagesObject import InfPackageItem =20 + def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList): # # Validate Arch @@ -46,7 +47,8 @@ def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchD= ict, SupArchList): if not IsValidArch(ArchItemNew): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Ar= chItemNew), + ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % ( + ArchItemNew), File=3DGlobalData.gINF_MODULE_NAME, Line=3DLineNo, ExtraData=3DArchItemNew) @@ -56,6 +58,7 @@ def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchD= ict, SupArchList): =20 return SupArchList, SupArchDict =20 + def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj): CommentInsList =3D [] PreUsage =3D None @@ -67,10 +70,10 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemOb= j): for CommentItem in CommentList: Count =3D Count + 1 CommentItemUsage, CommentType, CommentString, CommentItemHelpText = =3D ParseComment(CommentItem, - = DT.ALL_USAGE_TOKENS, - = {}, - = [], - = False) + = DT.ALL_USAGE_TOKENS, + = {}, + = [], + = False) if CommentType and CommentString: pass =20 @@ -162,6 +165,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemOb= j): =20 return PcdItemObj =20 + class InfPcdItemCommentContent(): def __init__(self): # @@ -175,15 +179,17 @@ class InfPcdItemCommentContent(): =20 def SetUsageItem(self, UsageItem): self.UsageItem =3D UsageItem + def GetUsageItem(self): return self.UsageItem =20 def SetHelpStringItem(self, HelpStringItem): self.HelpStringItem =3D HelpStringItem + def GetHelpStringItem(self): return self.HelpStringItem =20 -## InfPcdItem +# InfPcdItem # # This class defined Pcd item used in Module files # @@ -199,6 +205,8 @@ class InfPcdItemCommentContent(): # @param SkuInfoList: Input value for SkuInfoList, default is {} # @param SupModuleList: Input value for SupModuleList, default is [] # + + class InfPcdItem(): def __init__(self): self.CName =3D '' @@ -219,71 +227,85 @@ class InfPcdItem(): =20 def SetCName(self, CName): self.CName =3D CName + def GetCName(self): return self.CName =20 def SetToken(self, Token): self.Token =3D Token + def GetToken(self): return self.Token =20 def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName): self.TokenSpaceGuidCName =3D TokenSpaceGuidCName + def GetTokenSpaceGuidCName(self): return self.TokenSpaceGuidCName =20 def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue): self.TokenSpaceGuidValue =3D TokenSpaceGuidValue + def GetTokenSpaceGuidValue(self): return self.TokenSpaceGuidValue =20 def SetDatumType(self, DatumType): self.DatumType =3D DatumType + def GetDatumType(self): return self.DatumType =20 def SetMaxDatumSize(self, MaxDatumSize): self.MaxDatumSize =3D MaxDatumSize + def GetMaxDatumSize(self): return self.MaxDatumSize =20 def SetDefaultValue(self, DefaultValue): self.DefaultValue =3D DefaultValue + def GetDefaultValue(self): return self.DefaultValue =20 def SetPcdErrorsList(self, PcdErrorsList): self.PcdErrorsList =3D PcdErrorsList + def GetPcdErrorsList(self): return self.PcdErrorsList =20 def SetItemType(self, ItemType): self.ItemType =3D ItemType + def GetItemType(self): return self.ItemType =20 def SetSupModuleList(self, SupModuleList): self.SupModuleList =3D SupModuleList + def GetSupModuleList(self): return self.SupModuleList =20 def SetHelpStringList(self, HelpStringList): self.HelpStringList =3D HelpStringList + def GetHelpStringList(self): return self.HelpStringList =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetSupportArchList(self, ArchList): self.SupArchList =3D ArchList + def GetSupportArchList(self): return self.SupArchList =20 def SetOffset(self, Offset): self.Offset =3D Offset + def GetOffset(self): return self.Offset =20 @@ -297,6 +319,8 @@ class InfPcdItem(): # # # + + class InfPcdObject(): def __init__(self, FileName): self.Pcds =3D Sdict() @@ -315,7 +339,8 @@ class InfPcdObject(): SupArchDict =3D {} PcdTypeItem =3D '' for (PcdTypeItem1, ArchItem, LineNo) in KeysList: - SupArchList, SupArchDict =3D ValidateArch(ArchItem, PcdTypeIte= m1, LineNo, SupArchDict, SupArchList) + SupArchList, SupArchDict =3D ValidateArch( + ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList) =20 # # Validate PcdType @@ -326,7 +351,8 @@ class InfPcdObject(): if not IsValidPcdType(PcdTypeItem1): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_PCD_SECTION_TYPE_ERROR = % (DT.PCD_USAGE_TYPE_LIST_OF_MODULE), + ST.ERR_INF_PARSER_PCD_SECTION_TYPE_ERROR = % ( + DT.PCD_USAGE_TYPE_LIST_OF_MODULE), File=3DGlobalData.gINF_MODULE_NAME, Line=3DLineNo, ExtraData=3DPcdTypeItem1) @@ -341,14 +367,16 @@ class InfPcdObject(): PcdItem =3D PcdItem[0] =20 if CommentList is not None and len(CommentList) !=3D 0: - PcdItemObj =3D ParsePcdComment(CommentList, PcdTypeIte= m, PcdItemObj) + PcdItemObj =3D ParsePcdComment( + CommentList, PcdTypeItem, PcdItemObj) else: CommentItemIns =3D InfPcdItemCommentContent() CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED) PcdItemObj.SetHelpStringList([CommentItemIns]) =20 if len(PcdItem) >=3D 1 and len(PcdItem) <=3D 3: - PcdItemObj =3D SetPcdName(PcdItem, CurrentLineOfPcdIte= m, PcdItemObj) + PcdItemObj =3D SetPcdName( + PcdItem, CurrentLineOfPcdItem, PcdItemObj) =20 if len(PcdItem) >=3D 2 and len(PcdItem) <=3D 3: # @@ -385,7 +413,8 @@ class InfPcdObject(): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % (FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SY= NTAX_INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfPcdItem[2], Line=3DCurrentLineOfPcdItem[1], ExtraData=3DCurrentLineOfPcdItem[0]) @@ -429,9 +458,11 @@ class InfPcdObject(): CommentItemIns =3D InfPcdItemCommentContent() CommentItemIns.SetHelpStringItem(CommentString) CommentItemIns.SetUsageItem(CommentString) - PcdItemObj.SetHelpStringList(PcdItemObj.GetHelpStringList(= ) + [CommentItemIns]) + PcdItemObj.SetHelpStringList( + PcdItemObj.GetHelpStringList() + [CommentItemIns]) if PcdItemObj.GetValidUsage(): - PcdItemObj.SetValidUsage(PcdItemObj.GetValidUsage() + = DT.TAB_VALUE_SPLIT + CommentString) + PcdItemObj.SetValidUsage( + PcdItemObj.GetValidUsage() + DT.TAB_VALUE_SPLIT + = CommentString) else: PcdItemObj.SetValidUsage(CommentString) =20 @@ -444,10 +475,10 @@ class InfPcdObject(): # Set Value/DatumType/OffSet/Token # PcdItemObj =3D SetValueDatumTypeMaxSizeToken(PcdItem, - CurrentLineOfPcdItem, - PcdItemObj, - KeysList[0][1], - PackageInfo) + CurrentLineOfPcdIte= m, + PcdItemObj, + KeysList[0][1], + PackageInfo) =20 PcdTypeItem =3D KeysList[0][0] if (PcdTypeItem, PcdItemObj) in self.Pcds: @@ -462,6 +493,7 @@ class InfPcdObject(): def GetPcds(self): return self.Pcds =20 + def ParserPcdInfoInDec(String): ValueList =3D GetSplitValueList(String, DT.TAB_VALUE_SPLIT, 3) =20 @@ -470,6 +502,7 @@ def ParserPcdInfoInDec(String): # return ValueList[2], ValueList[3] =20 + def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemOb= j, Arch, PackageInfo=3DNone): # # Package information not been generated currently, we need to parser = INF file to get information. @@ -477,7 +510,8 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineO= fPcdItem, PcdItemObj, Arc if not PackageInfo: PackageInfo =3D [] InfFileName =3D CurrentLineOfPcdItem[2] - PackageInfoList =3D GetPackageListInfo(InfFileName, GlobalData.gWO= RKSPACE, -1) + PackageInfoList =3D GetPackageListInfo( + InfFileName, GlobalData.gWORKSPACE, -1) for PackageInfoListItem in PackageInfoList: PackageInfoIns =3D InfPackageItem() PackageInfoIns.SetPackageName(PackageInfoListItem) @@ -491,7 +525,8 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineO= fPcdItem, PcdItemObj, Arc # # Open DEC file to get information # - FullFileName =3D os.path.normpath(os.path.realpath(os.path.join(Gl= obalData.gWORKSPACE, PackageName))) + FullFileName =3D os.path.normpath(os.path.realpath( + os.path.join(GlobalData.gWORKSPACE, PackageName))) =20 DecParser =3D None if FullFileName not in GlobalData.gPackageDict: @@ -506,7 +541,7 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineO= fPcdItem, PcdItemObj, Arc DecPcdsDict =3D DecParser.GetPcdSectionObject().ValueDict for Key in DecPcdsDict.keys(): if (Key[0] =3D=3D 'PCDSDYNAMICEX' and PcdItemObj.GetItemType()= =3D=3D 'PcdEx') and \ - (Key[1] =3D=3D 'COMMON' or Key[1] =3D=3D Arch): + (Key[1] =3D=3D 'COMMON' or Key[1] =3D=3D Arch): for PcdInDec in DecPcdsDict[Key]: if PcdInDec.TokenCName =3D=3D PcdItemObj.CName and \ PcdInDec.TokenSpaceGuidCName =3D=3D PcdItemObj.Toke= nSpaceGuidCName: @@ -516,7 +551,7 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineO= fPcdItem, PcdItemObj, Arc PcdItemObj.SetDefaultValue(PcdInDec.DefaultValue) =20 if (Key[0] =3D=3D 'PCDSPATCHABLEINMODULE' and PcdItemObj.GetIt= emType() =3D=3D 'PatchPcd') and \ - (Key[1] =3D=3D 'COMMON' or Key[1] =3D=3D Arch): + (Key[1] =3D=3D 'COMMON' or Key[1] =3D=3D Arch): for PcdInDec in DecPcdsDict[Key]: if PcdInDec.TokenCName =3D=3D PcdItemObj.CName and \ PcdInDec.TokenSpaceGuidCName =3D=3D PcdItemObj.Toke= nSpaceGuidCName: @@ -526,7 +561,8 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineO= fPcdItem, PcdItemObj, Arc =20 if PcdItemObj.GetDatumType() =3D=3D 'VOID*': if len(PcdItem) > 1: - PcdItemObj.SetMaxDatumSize('%s' % (len(GetSplitValueList(P= cdItem[1], DT.TAB_COMMA_SPLIT)))) + PcdItemObj.SetMaxDatumSize( + '%s' % (len(GetSplitValueList(PcdItem[1], DT.TAB_COMMA= _SPLIT)))) =20 DecGuidsDict =3D DecParser.GetGuidSectionObject().ValueDict for Key in DecGuidsDict.keys(): @@ -555,35 +591,38 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLin= eOfPcdItem, PcdItemObj, Arc PcdItemObj.SetDefaultValue(PcdItem[1]) else: Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_ASBUILD_PCD_VALUE_INVALID % ("\"" + PcdItem[1]= + "\"", "\"" + - PcdItemObj.GetDatum= Type() + "\""), - File=3DCurrentLineOfPcdItem[2], - Line=3DCurrentLineOfPcdItem[1], - ExtraData=3DCurrentLineOfPcdItem[0]) + ToolError.FORMAT_INVALID, + ST.ERR_ASBUILD_PCD_VALUE_INVALID % ("\"" + PcdIte= m[1] + "\"", "\"" + + PcdItemObj.Ge= tDatumType() + "\""), + File=3DCurrentLineOfPcdItem[2], + Line=3DCurrentLineOfPcdItem[1], + ExtraData=3DCurrentLineOfPcdItem[0]) # # validate offset # if PcdItemObj.GetItemType().upper() =3D=3D DT.TAB_INF_PATCH_PCD.up= per(): if not IsHexDigitUINT32(PcdItem[2]): Logger.Error("InfParser", - ToolError.FORMAT_INVALID, - ST.ERR_ASBUILD_PCD_OFFSET_FORMAT_INVALID % ("\"" = + PcdItem[2] + "\""), - File=3DCurrentLineOfPcdItem[2], - Line=3DCurrentLineOfPcdItem[1], - ExtraData=3DCurrentLineOfPcdItem[0]) + ToolError.FORMAT_INVALID, + ST.ERR_ASBUILD_PCD_OFFSET_FORMAT_INVALID % ( + "\"" + PcdItem[2] + "\""), + File=3DCurrentLineOfPcdItem[2], + Line=3DCurrentLineOfPcdItem[1], + ExtraData=3DCurrentLineOfPcdItem[0]) PcdItemObj.SetOffset(PcdItem[2]) =20 if PcdItemObj.GetToken() =3D=3D '' or PcdItemObj.GetDatumType() =3D=3D= '': Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_ASBUILD_PCD_DECLARITION_MISS % ("\"" + PcdItem= [0] + "\""), + ST.ERR_ASBUILD_PCD_DECLARITION_MISS % ( + "\"" + PcdItem[0] + "\""), File=3DCurrentLineOfPcdItem[2], Line=3DCurrentLineOfPcdItem[1], ExtraData=3DCurrentLineOfPcdItem[0]) =20 return PcdItemObj =20 + def ValidatePcdValueOnDatumType(Value, Type): =20 Value =3D Value.strip() @@ -618,11 +657,11 @@ def ValidatePcdValueOnDatumType(Value, Type): =20 if not ReIsValidUint8z.match(Value) and Type =3D=3D 'UINT8': return False - elif not ReIsValidUint16z.match(Value) and Type =3D=3D 'UINT16': + elif not ReIsValidUint16z.match(Value) and Type =3D=3D 'UINT16': return False - elif not ReIsValidUint32z.match(Value) and Type =3D=3D 'UINT32': + elif not ReIsValidUint32z.match(Value) and Type =3D=3D 'UINT32': return False - elif not ReIsValidUint64z.match(Value) and Type =3D=3D 'UINT64': + elif not ReIsValidUint64z.match(Value) and Type =3D=3D 'UINT64': return False else: # @@ -632,6 +671,7 @@ def ValidatePcdValueOnDatumType(Value, Type): =20 return True =20 + def SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj): # # Only PCD Name specified diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py b/Ba= seTools/Source/Python/UPT/Object/Parser/InfPpiObject.py index 1968c365732d..f73506623c20 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Ppis] section. # It will consumed by InfParser. # @@ -20,6 +20,7 @@ import Logger.Log as Logger from Logger import ToolError from Logger import StringTable as ST =20 + def ParsePpiComment(CommentsList, InfPpiItemObj): PreNotify =3D None PreUsage =3D None @@ -30,14 +31,14 @@ def ParsePpiComment(CommentsList, InfPpiItemObj): for CommentItem in CommentsList: Count =3D Count + 1 CommentItemUsage, \ - CommentItemNotify, \ - CommentItemString, \ - CommentItemHelpText =3D \ - ParseComment(CommentItem, - DT.ALL_USAGE_TOKENS, - DT.PPI_NOTIFY_TOKENS, - ['PPI'], - False) + CommentItemNotify, \ + CommentItemString, \ + CommentItemHelpText =3D \ + ParseComment(CommentItem, + DT.ALL_USAGE_TOKENS, + DT.PPI_NOTIFY_TOKENS, + ['PPI'], + False) =20 # # To avoid PyLint error @@ -134,6 +135,7 @@ def ParsePpiComment(CommentsList, InfPpiItemObj): =20 return InfPpiItemObj =20 + class InfPpiItemCommentContent(): def __init__(self): # @@ -149,50 +151,60 @@ class InfPpiItemCommentContent(): =20 def SetUsage(self, UsageItem): self.UsageItem =3D UsageItem + def GetUsage(self): return self.UsageItem =20 def SetNotify(self, Notify): if Notify !=3D DT.ITEM_UNDEFINED: self.Notify =3D 'true' + def GetNotify(self): return self.Notify =20 def SetHelpStringItem(self, HelpStringItem): self.HelpStringItem =3D HelpStringItem + def GetHelpStringItem(self): return self.HelpStringItem =20 + class InfPpiItem(): def __init__(self): - self.Name =3D '' - self.FeatureFlagExp =3D '' - self.SupArchList =3D [] - self.CommentList =3D [] + self.Name =3D '' + self.FeatureFlagExp =3D '' + self.SupArchList =3D [] + self.CommentList =3D [] =20 def SetName(self, Name): self.Name =3D Name + def GetName(self): return self.Name =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 def SetCommentList(self, CommentList): self.CommentList =3D CommentList + def GetCommentList(self): return self.CommentList =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp ## # # # + + class InfPpiObject(): def __init__(self): self.Ppis =3D Sdict() @@ -201,7 +213,7 @@ class InfPpiObject(): # self.Macros =3D {} =20 - def SetPpi(self, PpiList, Arch =3D None): + def SetPpi(self, PpiList, Arch=3DNone): __SupArchList =3D [] for ArchItem in Arch: # @@ -228,7 +240,7 @@ class InfPpiObject(): if not IsValidCVariableName(Item[0]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]), + ST.ERR_INF_PARSER_INVALID_CNAME % (Item[0= ]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -265,7 +277,8 @@ class InfPpiObject(): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID%(FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX= _INVLID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -332,6 +345,5 @@ class InfPpiObject(): =20 return True =20 - def GetPpi(self): return self.Ppis diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py= b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py index 80bfca607754..cf3798dc5317 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfProtocolObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Protocols] sectio= n. # It will consumed by InfParser. # @@ -21,6 +21,7 @@ from Object.Parser.InfMisc import ErrorInInf from Library import DataType as DT from Logger import StringTable as ST =20 + def ParseProtocolComment(CommentsList, InfProtocolItemObj): CommentInsList =3D [] PreUsage =3D None @@ -31,14 +32,14 @@ def ParseProtocolComment(CommentsList, InfProtocolItemO= bj): for CommentItem in CommentsList: Count =3D Count + 1 CommentItemUsage, \ - CommentItemNotify, \ - CommentItemString, \ - CommentItemHelpText =3D \ - ParseComment(CommentItem, - DT.PROTOCOL_USAGE_TOKENS, - DT.PROTOCOL_NOTIFY_TOKENS, - ['PROTOCOL'], - False) + CommentItemNotify, \ + CommentItemString, \ + CommentItemHelpText =3D \ + ParseComment(CommentItem, + DT.PROTOCOL_USAGE_TOKENS, + DT.PROTOCOL_NOTIFY_TOKENS, + ['PROTOCOL'], + False) =20 if CommentItemString: pass @@ -123,6 +124,7 @@ def ParseProtocolComment(CommentsList, InfProtocolItemO= bj): =20 return InfProtocolItemObj =20 + class InfProtocolItemCommentContent(): def __init__(self): # @@ -138,20 +140,24 @@ class InfProtocolItemCommentContent(): =20 def SetUsageItem(self, UsageItem): self.UsageItem =3D UsageItem + def GetUsageItem(self): return self.UsageItem =20 def SetNotify(self, Notify): if Notify !=3D DT.ITEM_UNDEFINED: self.Notify =3D 'true' + def GetNotify(self): return self.Notify =20 def SetHelpStringItem(self, HelpStringItem): self.HelpStringItem =3D HelpStringItem + def GetHelpStringItem(self): return self.HelpStringItem =20 + class InfProtocolItem(): def __init__(self): self.Name =3D '' @@ -161,21 +167,25 @@ class InfProtocolItem(): =20 def SetName(self, Name): self.Name =3D Name + def GetName(self): return self.Name =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 def SetCommentList(self, CommentList): self.CommentList =3D CommentList + def GetCommentList(self): return self.CommentList =20 @@ -183,6 +193,8 @@ class InfProtocolItem(): # # # + + class InfProtocolObject(): def __init__(self): self.Protocols =3D Sdict() @@ -191,7 +203,7 @@ class InfProtocolObject(): # self.Macros =3D {} =20 - def SetProtocol(self, ProtocolContent, Arch =3D None,): + def SetProtocol(self, ProtocolContent, Arch=3DNone,): __SupArchList =3D [] for ArchItem in Arch: # @@ -209,7 +221,8 @@ class InfProtocolObject(): if len(Item) =3D=3D 3: CommentsList =3D Item[1] CurrentLineOfItem =3D Item[2] - LineInfo =3D (CurrentLineOfItem[2], CurrentLineOfItem[1], Curr= entLineOfItem[0]) + LineInfo =3D ( + CurrentLineOfItem[2], CurrentLineOfItem[1], CurrentLineOfI= tem[0]) Item =3D Item[0] InfProtocolItemObj =3D InfProtocolItem() if len(Item) >=3D 1 and len(Item) <=3D 2: @@ -217,7 +230,7 @@ class InfProtocolObject(): # Only CName contained # if not IsValidCVariableName(Item[0]): - ErrorInInf(ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]), + ErrorInInf(ST.ERR_INF_PARSER_INVALID_CNAME % (Item[0]), LineInfo=3DLineInfo) if (Item[0] !=3D ''): InfProtocolItemObj.SetName(Item[0]) @@ -239,7 +252,7 @@ class InfProtocolObject(): # FeatureFlagRtv =3D IsValidFeatureFlagExp(Item[1].strip()) if not FeatureFlagRtv[0]: - ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_I= NVLID%(FeatureFlagRtv[1]), + ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_I= NVLID % (FeatureFlagRtv[1]), LineInfo=3DLineInfo) InfProtocolItemObj.SetFeatureFlagExp(Item[1]) =20 @@ -254,7 +267,8 @@ class InfProtocolObject(): # Get/Set Usage and HelpString for Protocol entry # if CommentsList is not None and len(CommentsList) !=3D 0: - InfProtocolItemObj =3D ParseProtocolComment(CommentsList, = InfProtocolItemObj) + InfProtocolItemObj =3D ParseProtocolComment( + CommentsList, InfProtocolItemObj) else: CommentItemIns =3D InfProtocolItemCommentContent() CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py b= /BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py index 75ea209c48ac..5827afe5f50c 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [Sources] section. # It will consumed by InfParser. # @@ -24,9 +24,11 @@ from Library.Misc import ValidFile from Library.ParserValidate import IsValidFamily from Library.ParserValidate import IsValidPath =20 -## __GenSourceInstance +# __GenSourceInstance # # + + def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): =20 IsValidFileFlag =3D False @@ -53,7 +55,8 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INV= LID%(FeatureFlagRtv[1]), + ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INV= LID % ( + FeatureFlagRtv[1]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -64,7 +67,8 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_TOOLCODE_NOT_PERMITTED%(Ite= m[2]), + ST.ERR_INF_PARSER_TOOLCODE_NOT_PERMITTED % ( + Item[2]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -74,7 +78,8 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED%(Item= [2]), + ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % ( + Item[2]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -89,7 +94,8 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_SOURCE_SECTION_FAMILY_INVAL= ID%(Item[1]), + ST.ERR_INF_PARSER_SOURCE_SECTION_FAMILY_INVAL= ID % ( + Item[1]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -97,11 +103,12 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj= ): # # Validate file name exist. # - FullFileName =3D os.path.normpath(os.path.realpath(os.path.joi= n(GlobalData.gINF_MODULE_DIR, Item[0]))) + FullFileName =3D os.path.normpath(os.path.realpath( + os.path.join(GlobalData.gINF_MODULE_DIR, Item[0]))) if not (ValidFile(FullFileName) or ValidFile(Item[0])): Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_FILELIST_EXIST%(Item[0]), + ST.ERR_FILELIST_EXIST % (Item[0]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -115,7 +122,8 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj): else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVA= LID%(Item[0]), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVA= LID % ( + Item[0]), File=3DCurrentLineOfItem[2], Line=3DCurrentLineOfItem[1], ExtraData=3DCurrentLineOfItem[0]) @@ -132,74 +140,86 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemOb= j): =20 return ItemObj =20 -## InfSourcesItemObject() +# InfSourcesItemObject() # # + + class InfSourcesItemObject(): - def __init__(self, \ - SourceFileName =3D '', \ - Family =3D '', \ - TagName =3D '', \ - ToolCode =3D '', \ - FeatureFlagExp =3D ''): + def __init__(self, + SourceFileName=3D'', + Family=3D'', + TagName=3D'', + ToolCode=3D'', + FeatureFlagExp=3D''): self.SourceFileName =3D SourceFileName - self.Family =3D Family - self.TagName =3D TagName - self.ToolCode =3D ToolCode + self.Family =3D Family + self.TagName =3D TagName + self.ToolCode =3D ToolCode self.FeatureFlagExp =3D FeatureFlagExp - self.HeaderString =3D '' - self.TailString =3D '' - self.SupArchList =3D [] + self.HeaderString =3D '' + self.TailString =3D '' + self.SupArchList =3D [] =20 def SetSourceFileName(self, SourceFilename): self.SourceFileName =3D SourceFilename + def GetSourceFileName(self): return self.SourceFileName =20 def SetFamily(self, Family): self.Family =3D Family + def GetFamily(self): return self.Family =20 def SetTagName(self, TagName): self.TagName =3D TagName + def GetTagName(self): return self.TagName =20 def SetToolCode(self, ToolCode): self.ToolCode =3D ToolCode + def GetToolCode(self): return self.ToolCode =20 def SetFeatureFlagExp(self, FeatureFlagExp): self.FeatureFlagExp =3D FeatureFlagExp + def GetFeatureFlagExp(self): return self.FeatureFlagExp =20 def SetHeaderString(self, HeaderString): self.HeaderString =3D HeaderString + def GetHeaderString(self): return self.HeaderString =20 def SetTailString(self, TailString): self.TailString =3D TailString + def GetTailString(self): return self.TailString =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList ## # # # + + class InfSourcesObject(InfSectionCommonDef): def __init__(self): self.Sources =3D Sdict() InfSectionCommonDef.__init__(self) =20 - def SetSources(self, SourceList, Arch =3D None): + def SetSources(self, SourceList, Arch=3DNone): __SupArchList =3D [] for ArchItem in Arch: # diff --git a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObje= ct.py b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py index ce017dbebb45..bab6ecca94b8 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/InfUserExtensionObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define class objects of INF file [UserExtension] se= ction. # It will consumed by InfParser. # @@ -17,33 +17,38 @@ from Library import GlobalData =20 from Library.Misc import Sdict =20 + class InfUserExtensionItem(): def __init__(self, - Content =3D '', - UserId =3D '', - IdString =3D ''): - self.Content =3D Content - self.UserId =3D UserId + Content=3D'', + UserId=3D'', + IdString=3D''): + self.Content =3D Content + self.UserId =3D UserId self.IdString =3D IdString self.SupArchList =3D [] =20 def SetContent(self, Content): self.Content =3D Content + def GetContent(self): return self.Content =20 def SetUserId(self, UserId): self.UserId =3D UserId + def GetUserId(self): return self.UserId =20 def SetIdString(self, IdString): self.IdString =3D IdString + def GetIdString(self): return self.IdString =20 def SetSupArchList(self, SupArchList): self.SupArchList =3D SupArchList + def GetSupArchList(self): return self.SupArchList =20 @@ -51,6 +56,8 @@ class InfUserExtensionItem(): # # # + + class InfUserExtensionObject(): def __init__(self): self.UserExtension =3D Sdict() @@ -111,8 +118,9 @@ class InfUserExtensionObject(): # Logger.Error('InfParser', ToolError.FORMAT_INVALID, - ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\ - (IdContentItem[0] + '.' + IdContentItem[1] + = '.' + IdContentItem[2]), + ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR % + (IdContentItem[0] + '.' + + IdContentItem[1] + '.' + IdContentItem[2]), File=3DGlobalData.gINF_MODULE_NAME, Line=3DLineNo, ExtraData=3DNone) diff --git a/BaseTools/Source/Python/UPT/Object/Parser/__init__.py b/BaseTo= ols/Source/Python/UPT/Object/Parser/__init__.py index 268ce7ca1e99..3fec9ece77c0 100644 --- a/BaseTools/Source/Python/UPT/Object/Parser/__init__.py +++ b/BaseTools/Source/Python/UPT/Object/Parser/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Object' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/Object/__init__.py b/BaseTools/Sou= rce/Python/UPT/Object/__init__.py index 53db4406dc73..45bbfca726d5 100644 --- a/BaseTools/Source/Python/UPT/Object/__init__.py +++ b/BaseTools/Source/Python/UPT/Object/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Object' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/Parser/DecParser.py b/BaseTools/So= urce/Python/UPT/Parser/DecParser.py index 8dfa12d8268b..4b0c6f540935 100644 --- a/BaseTools/Source/Python/UPT/Parser/DecParser.py +++ b/BaseTools/Source/Python/UPT/Parser/DecParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse DEC file. It will consumed by DecParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -7,7 +7,7 @@ ''' DecParser ''' -## Import modules +# Import modules # import Logger.Log as Logger from Logger.ToolError import FILE_PARSE_FAILURE @@ -60,6 +60,8 @@ from Library.CommentParsing import ParsePcdErrorCode ## # _DecBase class for parsing # + + class _DecBase: def __init__(self, RawData): self._RawData =3D RawData @@ -76,20 +78,20 @@ class _DecBase: def GetLocalMacro(self): return self._LocalMacro =20 - ## BlockStart + # BlockStart # # Called if a new section starts # def BlockStart(self): self._LocalMacro =3D {} =20 - ## _CheckReDefine + # _CheckReDefine # # @param Key: to be checked if multi-defined # @param Scope: Format: [[SectionName, Arch], ...]. # If scope is none, use global scope # - def _CheckReDefine(self, Key, Scope =3D None): + def _CheckReDefine(self, Key, Scope=3DNone): if not Scope: Scope =3D self._RawData.CurrentScope return @@ -113,7 +115,8 @@ class _DecBase: # Key in common cannot be redefined in other arches # [:-1] means stripping arch info if Other[:-1] =3D=3D SubValue[:-1]: - self._LoggerError(ST.ERR_DECPARSE_REDEFINE % (= Key, Value[1])) + self._LoggerError( + ST.ERR_DECPARSE_REDEFINE % (Key, Value[1])) return continue CommonScope =3D [] @@ -123,11 +126,12 @@ class _DecBase: # Cannot be redefined if this key already defined in COMMO= N Or defined in same arch # if SubValue in Value[0] or CommonScope in Value[0]: - self._LoggerError(ST.ERR_DECPARSE_REDEFINE % (Key, Val= ue[1])) + self._LoggerError(ST.ERR_DECPARSE_REDEFINE % + (Key, Value[1])) return self._ItemDict[Key].append([SecArch, self._RawData.LineIndex]) =20 - ## CheckRequiredFields + # CheckRequiredFields # Some sections need to check if some fields exist, define section for= example # Derived class can re-implement, top parser will call this function a= fter all parsing done # @@ -136,7 +140,7 @@ class _DecBase: pass return True =20 - ## IsItemRequired + # IsItemRequired # In DEC spec, sections must have at least one statement except user # extension. # For example: "[guids" [] "]" + @@ -149,23 +153,23 @@ class _DecBase: =20 def _LoggerError(self, ErrorString): Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=3Dself._RawData.F= ilename, - Line =3D self._RawData.LineIndex, + Line=3Dself._RawData.LineIndex, ExtraData=3DErrorString + ST.ERR_DECPARSE_LINE % self= ._RawData.CurrentLine) =20 def _ReplaceMacro(self, String): if gMACRO_PATTERN.findall(String): String =3D ReplaceMacro(String, self._LocalMacro, False, - FileName =3D self._RawData.Filename, - Line =3D ['', self._RawData.LineIndex]) + FileName=3Dself._RawData.Filename, + Line=3D['', self._RawData.LineIndex]) String =3D ReplaceMacro(String, self._RawData.Macros, False, - FileName =3D self._RawData.Filename, - Line =3D ['', self._RawData.LineIndex]) + FileName=3Dself._RawData.Filename, + Line=3D['', self._RawData.LineIndex]) MacroUsed =3D gMACRO_PATTERN.findall(String) if MacroUsed: Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=3Dself._RawData.Filename, - Line =3D self._RawData.LineIndex, - ExtraData =3D ST.ERR_DECPARSE_MACRO_RESOLVE %= (str(MacroUsed), String)) + Line=3Dself._RawData.LineIndex, + ExtraData=3DST.ERR_DECPARSE_MACRO_RESOLVE % (= str(MacroUsed), String)) return String =20 def _MacroParser(self, String): @@ -184,7 +188,7 @@ class _DecBase: else: self._LocalMacro[TokenList[0]] =3D self._ReplaceMacro(TokenLis= t[1]) =20 - ## _ParseItem + # _ParseItem # # Parse specified item, this function must be derived by subclass # @@ -196,14 +200,14 @@ class _DecBase: # return None =20 - - ## _TailCommentStrategy + # _TailCommentStrategy # # This function can be derived to parse tail comment # default is it will not consume any lines # # @param Comment: Comment of current line # + def _TailCommentStrategy(self, Comment): if Comment: pass @@ -211,7 +215,7 @@ class _DecBase: pass return False =20 - ## _StopCurrentParsing + # _StopCurrentParsing # # Called in Parse if current parsing should be stopped when encounter = some # keyword @@ -224,7 +228,7 @@ class _DecBase: pass return Line[0] =3D=3D DT.TAB_SECTION_START and Line[-1] =3D=3D DT.= TAB_SECTION_END =20 - ## _TryBackSlash + # _TryBackSlash # # Split comment and DEC content, concatenate lines if end of char is '= \' # @@ -281,7 +285,7 @@ class _DecBase: =20 return CatLine, CommentList =20 - ## Parse + # Parse # This is a template method in which other member functions which might # override by sub class are called. It is responsible for reading file # line by line, and call other member functions to parse. This function @@ -291,24 +295,24 @@ class _DecBase: HeadComments =3D [] TailComments =3D [] =20 - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # CurComments may pointer to HeadComments or TailComments - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CurComments =3D HeadComments CurObj =3D None ItemNum =3D 0 FromBuf =3D False =20 - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Used to report error information if empty section found - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Index =3D self._RawData.LineIndex LineStr =3D self._RawData.CurrentLine while not self._RawData.IsEndOfFile() or self._RawData.NextLine: if self._RawData.NextLine: - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Have processed line in buffer - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Line =3D self._RawData.NextLine HeadComments.extend(self._RawData.HeadComment) TailComments.extend(self._RawData.TailComment) @@ -316,16 +320,16 @@ class _DecBase: Comment =3D '' FromBuf =3D True else: - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # No line in buffer, read next line - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Line, Comment =3D CleanString(self._RawData.GetNextLine()) FromBuf =3D False if Line: if not FromBuf and CurObj and TailComments: - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Set tail comments to previous statement if not empty. - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CurObj.SetTailComment(CurObj.GetTailComment()+TailComm= ents) =20 if not FromBuf: @@ -335,15 +339,15 @@ class _DecBase: if Comment: Comments =3D [(Comment, self._RawData.LineIndex)] =20 - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Try if last char of line has backslash - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Line, Comments =3D self._TryBackSlash(Line, Comments) CurComments.extend(Comments) =20 - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Macro found - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D if Line.startswith('DEFINE '): self._MacroParser(Line) del HeadComments[:] @@ -352,10 +356,10 @@ class _DecBase: continue =20 if self._StopCurrentParsing(Line): - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # This line does not belong to this parse, # Save it, can be used by next parse - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D self._RawData.SetNext(Line, HeadComments, TailComments) break =20 @@ -371,9 +375,9 @@ class _DecBase: CurObj =3D None else: if id(CurComments) =3D=3D id(TailComments): - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # Check if this comment belongs to tail comment - #=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D if not self._TailCommentStrategy(Comment): CurComments =3D HeadComments =20 @@ -384,15 +388,17 @@ class _DecBase: =20 if self._IsStatementRequired() and ItemNum =3D=3D 0: Logger.Error( - TOOL_NAME, FILE_PARSE_FAILURE, - File=3Dself._RawData.Filename, - Line=3DIndex, - ExtraData=3DST.ERR_DECPARSE_STATEMENT_EMPTY % LineStr + TOOL_NAME, FILE_PARSE_FAILURE, + File=3Dself._RawData.Filename, + Line=3DIndex, + ExtraData=3DST.ERR_DECPARSE_STATEMENT_EMPTY % LineStr ) =20 -## _DecDefine +# _DecDefine # Parse define section # + + class _DecDefine(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -404,11 +410,11 @@ class _DecDefine(_DecBase): # Each field has a function to validate # self.DefineValidation =3D { - DT.TAB_DEC_DEFINES_DEC_SPECIFICATION : self._SetDecSpecifi= cation, - DT.TAB_DEC_DEFINES_PACKAGE_NAME : self._SetPackageNam= e, - DT.TAB_DEC_DEFINES_PACKAGE_GUID : self._SetPackageGui= d, - DT.TAB_DEC_DEFINES_PACKAGE_VERSION : self._SetPackageVer= sion, - DT.TAB_DEC_DEFINES_PKG_UNI_FILE : self._SetPackageUni, + DT.TAB_DEC_DEFINES_DEC_SPECIFICATION: self._SetDecSpecificat= ion, + DT.TAB_DEC_DEFINES_PACKAGE_NAME: self._SetPackageName, + DT.TAB_DEC_DEFINES_PACKAGE_GUID: self._SetPackageGuid, + DT.TAB_DEC_DEFINES_PACKAGE_VERSION: self._SetPackageVersion, + DT.TAB_DEC_DEFINES_PKG_UNI_FILE: self._SetPackageUni, } =20 def BlockStart(self): @@ -416,7 +422,7 @@ class _DecDefine(_DecBase): if self._DefSecNum > 1: self._LoggerError(ST.ERR_DECPARSE_DEFINE_MULTISEC) =20 - ## CheckRequiredFields + # CheckRequiredFields # # Check required fields: DEC_SPECIFICATION, PACKAGE_NAME # PACKAGE_GUID, PACKAGE_VERSION @@ -452,14 +458,15 @@ class _DecDefine(_DecBase): self.DefineValidation[TokenList[0]](TokenList[1]) =20 DefineItem =3D DecDefineItemObject() - DefineItem.Key =3D TokenList[0] + DefineItem.Key =3D TokenList[0] DefineItem.Value =3D TokenList[1] self.ItemObject.AddItem(DefineItem, self._RawData.CurrentScope) return DefineItem =20 def _SetDecSpecification(self, Token): if self.ItemObject.GetPackageSpecification(): - self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_= DEFINES_DEC_SPECIFICATION) + self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % + DT.TAB_DEC_DEFINES_DEC_SPECIFICATION) if not IsValidToken('0[xX][0-9a-fA-F]{8}', Token): if not IsValidDecVersionVal(Token): self._LoggerError(ST.ERR_DECPARSE_DEFINE_SPEC) @@ -467,21 +474,24 @@ class _DecDefine(_DecBase): =20 def _SetPackageName(self, Token): if self.ItemObject.GetPackageName(): - self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_= DEFINES_PACKAGE_NAME) + self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % + DT.TAB_DEC_DEFINES_PACKAGE_NAME) if not IsValidWord(Token): self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGNAME) self.ItemObject.SetPackageName(Token) =20 def _SetPackageGuid(self, Token): if self.ItemObject.GetPackageGuid(): - self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_= DEFINES_PACKAGE_GUID) + self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % + DT.TAB_DEC_DEFINES_PACKAGE_GUID) if not CheckGuidRegFormat(Token): self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID) self.ItemObject.SetPackageGuid(Token) =20 def _SetPackageVersion(self, Token): if self.ItemObject.GetPackageVersion(): - self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_= DEFINES_PACKAGE_VERSION) + self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % + DT.TAB_DEC_DEFINES_PACKAGE_VERSION) if not IsValidToken(VERSION_PATTERN, Token): self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGVERSION) else: @@ -491,13 +501,16 @@ class _DecDefine(_DecBase): =20 def _SetPackageUni(self, Token): if self.ItemObject.GetPackageUniFile(): - self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_= DEFINES_PKG_UNI_FILE) + self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % + DT.TAB_DEC_DEFINES_PKG_UNI_FILE) self.ItemObject.SetPackageUniFile(Token) =20 -## _DecInclude +# _DecInclude # # Parse include section # + + class _DecInclude(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -509,14 +522,17 @@ class _DecInclude(_DecBase): if not IsValidPath(Line, self._RawData.PackagePath): self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line) =20 - Item =3D DecIncludeItemObject(StripRoot(self._RawData.PackagePath,= Line), self._RawData.PackagePath) + Item =3D DecIncludeItemObject( + StripRoot(self._RawData.PackagePath, Line), self._RawData.Pack= agePath) self.ItemObject.AddItem(Item, self._RawData.CurrentScope) return Item =20 -## _DecLibraryclass +# _DecLibraryclass # # Parse library class section # + + class _DecLibraryclass(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -552,10 +568,12 @@ class _DecLibraryclass(_DecBase): self.ItemObject.AddItem(Item, self._RawData.CurrentScope) return Item =20 -## _DecPcd +# _DecPcd # # Parse PCD section # + + class _DecPcd(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -621,7 +639,7 @@ class _DecPcd(_DecBase): IntToken =3D int(Token, 0) if (Guid, IntToken) in self.TokenMap: if self.TokenMap[Guid, IntToken] !=3D CName: - self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token)) + self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE % (Toke= n)) else: self.TokenMap[Guid, IntToken] =3D CName =20 @@ -629,10 +647,12 @@ class _DecPcd(_DecBase): self.ItemObject.AddItem(Item, self._RawData.CurrentScope) return Item =20 -## _DecGuid +# _DecGuid # # Parse GUID, PPI, Protocol section # + + class _DecGuid(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -640,11 +660,11 @@ class _DecGuid(_DecBase): self.PpiObj =3D DecPpiObject(RawData.Filename) self.ProtocolObj =3D DecProtocolObject(RawData.Filename) self.ObjectDict =3D \ - { - DT.TAB_GUIDS.upper() : self.GuidObj, - DT.TAB_PPIS.upper() : self.PpiObj, - DT.TAB_PROTOCOLS.upper() : self.ProtocolObj - } + { + DT.TAB_GUIDS.upper(): self.GuidObj, + DT.TAB_PPIS.upper(): self.PpiObj, + DT.TAB_PROTOCOLS.upper(): self.ProtocolObj + } =20 def GetDataObject(self): if self._RawData.CurrentScope: @@ -697,10 +717,12 @@ class _DecGuid(_DecBase): ItemObject.AddItem(Item, self._RawData.CurrentScope) return Item =20 -## _DecUserExtension +# _DecUserExtension # # Parse user extension section # + + class _DecUserExtension(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -739,12 +761,14 @@ class _DecUserExtension(_DecBase): Item.UserString =3D Line return Item =20 -## Dec +# Dec # # Top dec parser # + + class Dec(_DecBase, _DecComments): - def __init__(self, DecFile, Parse =3D True): + def __init__(self, DecFile, Parse=3DTrue): try: Content =3D ConvertSpecialChar(open(DecFile, 'r').readlines()) except BaseException: @@ -777,29 +801,29 @@ class Dec(_DecBase, _DecComments): self.BinaryHeadComment =3D [] self.PcdErrorCommentDict =3D {} =20 - self._Define =3D _DecDefine(RawData) - self._Include =3D _DecInclude(RawData) - self._Guid =3D _DecGuid(RawData) - self._LibClass =3D _DecLibraryclass(RawData) - self._Pcd =3D _DecPcd(RawData) - self._UserEx =3D _DecUserExtension(RawData) + self._Define =3D _DecDefine(RawData) + self._Include =3D _DecInclude(RawData) + self._Guid =3D _DecGuid(RawData) + self._LibClass =3D _DecLibraryclass(RawData) + self._Pcd =3D _DecPcd(RawData) + self._UserEx =3D _DecUserExtension(RawData) =20 # # DEC file supported data types (one type per section) # self._SectionParser =3D { - DT.TAB_DEC_DEFINES.upper() : self._Defin= e, - DT.TAB_INCLUDES.upper() : self._Inclu= de, - DT.TAB_LIBRARY_CLASSES.upper() : self._LibCl= ass, - DT.TAB_GUIDS.upper() : self._Guid, - DT.TAB_PPIS.upper() : self._Guid, - DT.TAB_PROTOCOLS.upper() : self._Guid, - DT.TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : self._Pcd, - DT.TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : self._Pcd, - DT.TAB_PCDS_FEATURE_FLAG_NULL.upper() : self._Pcd, - DT.TAB_PCDS_DYNAMIC_NULL.upper() : self._Pcd, - DT.TAB_PCDS_DYNAMIC_EX_NULL.upper() : self._Pcd, - DT.TAB_USER_EXTENSIONS.upper() : self._UserEx + DT.TAB_DEC_DEFINES.upper(): self._Define, + DT.TAB_INCLUDES.upper(): self._Include, + DT.TAB_LIBRARY_CLASSES.upper(): self._LibClass, + DT.TAB_GUIDS.upper(): self._Guid, + DT.TAB_PPIS.upper(): self._Guid, + DT.TAB_PROTOCOLS.upper(): self._Guid, + DT.TAB_PCDS_FIXED_AT_BUILD_NULL.upper(): self._Pcd, + DT.TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(): self._Pcd, + DT.TAB_PCDS_FEATURE_FLAG_NULL.upper(): self._Pcd, + DT.TAB_PCDS_DYNAMIC_NULL.upper(): self._Pcd, + DT.TAB_PCDS_DYNAMIC_EX_NULL.upper(): self._Pcd, + DT.TAB_USER_EXTENSIONS.upper(): self._UserEx } =20 if Parse: @@ -832,29 +856,36 @@ class Dec(_DecBase, _DecComments): while not self._RawData.IsEndOfFile(): self._RawData.CurrentLine =3D self._RawData.GetNextLine() if self._RawData.CurrentLine.startswith(DT.TAB_COMMENT_SPLIT) = and \ - DT.TAB_SECTION_START in self._RawData.CurrentLine and \ - DT.TAB_SECTION_END in self._RawData.CurrentLine: - self._RawData.CurrentLine =3D self._RawData.CurrentLine.re= place(DT.TAB_COMMENT_SPLIT, '').strip() + DT.TAB_SECTION_START in self._RawData.CurrentLine and \ + DT.TAB_SECTION_END in self._RawData.CurrentLine: + self._RawData.CurrentLine =3D self._RawData.CurrentLine.re= place( + DT.TAB_COMMENT_SPLIT, '').strip() =20 if self._RawData.CurrentLine[0] =3D=3D DT.TAB_SECTION_STAR= T and \ - self._RawData.CurrentLine[-1] =3D=3D DT.TAB_SECTION_EN= D: + self._RawData.CurrentLine[-1] =3D=3D DT.TAB_SECTIO= N_END: RawSection =3D self._RawData.CurrentLine[1:-1].strip() if RawSection.upper().startswith(DT.TAB_PCD_ERROR.uppe= r()+'.'): - TokenSpaceGuidCName =3D RawSection.split(DT.TAB_PC= D_ERROR+'.')[1].strip() + TokenSpaceGuidCName =3D RawSection.split( + DT.TAB_PCD_ERROR+'.')[1].strip() continue =20 if TokenSpaceGuidCName and self._RawData.CurrentLine.startswit= h(DT.TAB_COMMENT_SPLIT): - self._RawData.CurrentLine =3D self._RawData.CurrentLine.re= place(DT.TAB_COMMENT_SPLIT, '').strip() + self._RawData.CurrentLine =3D self._RawData.CurrentLine.re= place( + DT.TAB_COMMENT_SPLIT, '').strip() if self._RawData.CurrentLine !=3D '': if DT.TAB_VALUE_SPLIT not in self._RawData.CurrentLine: - self._LoggerError(ST.ERR_DECPARSE_PCDERRORMSG_MISS= _VALUE_SPLIT) + self._LoggerError( + ST.ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT) =20 - PcdErrorNumber, PcdErrorMsg =3D GetSplitValueList(self= ._RawData.CurrentLine, DT.TAB_VALUE_SPLIT, 1) - PcdErrorNumber =3D ParsePcdErrorCode(PcdErrorNumber, s= elf._RawData.Filename, self._RawData.LineIndex) + PcdErrorNumber, PcdErrorMsg =3D GetSplitValueList( + self._RawData.CurrentLine, DT.TAB_VALUE_SPLIT, 1) + PcdErrorNumber =3D ParsePcdErrorCode( + PcdErrorNumber, self._RawData.Filename, self._RawD= ata.LineIndex) if not PcdErrorMsg.strip(): self._LoggerError(ST.ERR_DECPARSE_PCD_MISS_ERRORMS= G) =20 - self.PcdErrorCommentDict[(TokenSpaceGuidCName, PcdErro= rNumber)] =3D PcdErrorMsg.strip() + self.PcdErrorCommentDict[( + TokenSpaceGuidCName, PcdErrorNumber)] =3D PcdError= Msg.strip() else: TokenSpaceGuidCName =3D '' =20 @@ -873,7 +904,7 @@ class Dec(_DecBase, _DecComments): break =20 if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) and = Comment.find(DT.TAB_HEADER_COMMENT) > 0 \ - and not Comment[2:Comment.find(DT.TAB_HEADER_COMMENT)].str= ip(): + and not Comment[2:Comment.find(DT.TAB_HEADER_COMMENT)]= .strip(): IsFileHeader =3D True IsBinaryHeader =3D False FileHeaderLineIndex =3D self._RawData.LineIndex @@ -882,12 +913,12 @@ class Dec(_DecBase, _DecComments): # Get license information before '@file' # if not IsFileHeader and not IsBinaryHeader and Comment and Com= ment.startswith(DT.TAB_COMMENT_SPLIT) and \ - DT.TAB_BINARY_HEADER_COMMENT not in Comment: + DT.TAB_BINARY_HEADER_COMMENT not in Comment: self._HeadComment.append((Comment, self._RawData.LineIndex= )) =20 if Comment and IsFileHeader and \ - not(Comment.startswith(DT.TAB_SPECIAL_COMMENT) \ - and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0): + not(Comment.startswith(DT.TAB_SPECIAL_COMMENT) + and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0): self._HeadComment.append((Comment, self._RawData.LineIndex= )) # # Double '#' indicates end of header comments @@ -897,13 +928,14 @@ class Dec(_DecBase, _DecComments): continue =20 if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) \ - and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0: + and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0: IsBinaryHeader =3D True IsFileHeader =3D False BinaryHeaderLineIndex =3D self._RawData.LineIndex =20 if Comment and IsBinaryHeader: - self.BinaryHeadComment.append((Comment, self._RawData.Line= Index)) + self.BinaryHeadComment.append( + (Comment, self._RawData.LineIndex)) # # Double '#' indicates end of header comments # @@ -918,7 +950,7 @@ class Dec(_DecBase, _DecComments): self._LoggerError(ST.ERR_BINARY_HEADER_ORDER) =20 if FileHeaderLineIndex =3D=3D -1: -# self._LoggerError(ST.ERR_NO_SOURCE_HEADER) + # self._LoggerError(ST.ERR_NO_SOURCE_HEADER) Logger.Error(TOOL_NAME, FORMAT_INVALID, ST.ERR_NO_SOURCE_HEADER, File=3Dself._RawData.Filename) @@ -949,7 +981,8 @@ class Dec(_DecBase, _DecComments): if Token.upper() !=3D DT.TAB_USER_EXTENSIONS.upper(): self._LoggerError(ST.ERR_DECPARSE_SECTION_UE) UserExtension =3D Token.upper() - Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self.= _RawData.LineIndex) + Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, + self._RawData.LineIndex) =20 # # UserID @@ -958,7 +991,8 @@ class Dec(_DecBase, _DecComments): if not IsValidUserId(Token): self._LoggerError(ST.ERR_DECPARSE_SECTION_UE_USERID) UserId =3D Token - Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self.= _RawData.LineIndex) + Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, + self._RawData.LineIndex) # # IdString # @@ -974,7 +1008,7 @@ class Dec(_DecBase, _DecComments): self._LoggerError(ST.ERR_DECPARSE_ARCH) ArchList.add(Arch) if [UserExtension, UserId, IdString, Arch] not in \ - self._RawData.CurrentScope: + self._RawData.CurrentScope: self._RawData.CurrentScope.append( [UserExtension, UserId, IdString, Arch] ) @@ -986,7 +1020,7 @@ class Dec(_DecBase, _DecComments): if 'COMMON' in ArchList and len(ArchList) > 1: self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON) =20 - ## Section header parser + # Section header parser # # The section header is always in following format: # @@ -1014,7 +1048,8 @@ class Dec(_DecBase, _DecComments): ArchList =3D set() for Item in GetSplitValueList(RawSection, DT.TAB_COMMA_SPLIT): if Item =3D=3D '': - self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBEMPTY % self.= _RawData.CurrentLine) + self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBEMPTY % + self._RawData.CurrentLine) =20 ItemList =3D GetSplitValueList(Item, DT.TAB_SPLIT) # @@ -1033,7 +1068,8 @@ class Dec(_DecBase, _DecComments): self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBTOOMANY % Ite= m) =20 if DT.TAB_PCDS_FEATURE_FLAG_NULL.upper() in SectionNames and l= en(SectionNames) > 1: - self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % DT= .TAB_PCDS_FEATURE_FLAG_NULL) + self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % + DT.TAB_PCDS_FEATURE_FLAG_NULL) # # S1 is always Arch # @@ -1053,39 +1089,55 @@ class Dec(_DecBase, _DecComments): if 'COMMON' in ArchList and len(ArchList) > 1: self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON) if len(SectionNames) =3D=3D 0: - self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBEMPTY % self._Raw= Data.CurrentLine) + self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBEMPTY % + self._RawData.CurrentLine) if len(SectionNames) !=3D 1: for Sec in SectionNames: if not Sec.startswith(DT.TAB_PCDS.upper()): - self._LoggerError(ST.ERR_DECPARSE_SECTION_NAME % str(S= ectionNames)) + self._LoggerError( + ST.ERR_DECPARSE_SECTION_NAME % str(SectionNames)) =20 def GetDefineSectionMacro(self): return self._Define.GetLocalMacro() + def GetDefineSectionObject(self): return self._Define.GetDataObject() + def GetIncludeSectionObject(self): return self._Include.GetDataObject() + def GetGuidSectionObject(self): return self._Guid.GetGuidObject() + def GetProtocolSectionObject(self): return self._Guid.GetProtocolObject() + def GetPpiSectionObject(self): return self._Guid.GetPpiObject() + def GetLibraryClassSectionObject(self): return self._LibClass.GetDataObject() + def GetPcdSectionObject(self): return self._Pcd.GetDataObject() + def GetUserExtensionSectionObject(self): return self._UserEx.GetDataObject() + def GetPackageSpecification(self): return self._Define.GetDataObject().GetPackageSpecification() + def GetPackageName(self): return self._Define.GetDataObject().GetPackageName() + def GetPackageGuid(self): return self._Define.GetDataObject().GetPackageGuid() + def GetPackageVersion(self): return self._Define.GetDataObject().GetPackageVersion() + def GetPackageUniFile(self): return self._Define.GetDataObject().GetPackageUniFile() + def GetPrivateSections(self): return self._Private diff --git a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py b/BaseTool= s/Source/Python/UPT/Parser/DecParserMisc.py index 27990467d1c5..8b1e949a5f95 100644 --- a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py +++ b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define helper class and function for DEC parser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -9,7 +9,7 @@ DecParserMisc ''' =20 -## Import modules +# Import modules # import os import Logger.Log as Logger @@ -30,9 +30,11 @@ CVAR_PATTERN =3D '[_a-zA-Z][a-zA-Z0-9_]*' PCD_TOKEN_PATTERN =3D '(0[xX]0*[a-fA-F0-9]{1,8})|([0-9]+)' MACRO_PATTERN =3D '[A-Z][_A-Z0-9]*' =20 -## FileContent +# FileContent # Class to hold DEC file information # + + class FileContent: def __init__(self, Filename, FileContent2): self.Filename =3D Filename @@ -72,7 +74,7 @@ class FileContent: return self.LineIndex >=3D self.FileLines =20 =20 -## StripRoot +# StripRoot # # Strip root path # @@ -92,7 +94,7 @@ def StripRoot(Root, Path): return Path return OrigPath =20 -## CleanString +# CleanString # # Split comments in a string # Remove spaces @@ -101,7 +103,9 @@ def StripRoot(Root, Path): # @param CommentCharacter: Comment char, used to ignore comment content, # default is DataType.TAB_COMMENT_SPLIT # -def CleanString(Line, CommentCharacter=3DTAB_COMMENT_SPLIT, \ + + +def CleanString(Line, CommentCharacter=3DTAB_COMMENT_SPLIT, AllowCppStyleComment=3DFalse): # # remove whitespace @@ -129,7 +133,7 @@ def CleanString(Line, CommentCharacter=3DTAB_COMMENT_SP= LIT, \ return Line, Comment =20 =20 -## IsValidNumValUint8 +# IsValidNumValUint8 # # Check if Token is NumValUint8: ::=3D {} {= } {} # @@ -157,13 +161,15 @@ def IsValidNumValUint8(Token): else: return True =20 -## IsValidNList +# IsValidNList # # Check if Value has the format of ["," ]{0,} # ::=3D {} {} {} # # @param Value: Value to be checked # + + def IsValidNList(Value): Par =3D ParserHelper(Value) if Par.End(): @@ -180,12 +186,14 @@ def IsValidNList(Value): break return Par.End() =20 -## IsValidCArray +# IsValidCArray # # check Array is valid # # @param Array: The input Array # + + def IsValidCArray(Array): Par =3D ParserHelper(Array) if not Par.Expect('{'): @@ -212,13 +220,15 @@ def IsValidCArray(Array): return False return Par.End() =20 -## IsValidPcdDatum +# IsValidPcdDatum # # check PcdDatum is valid # # @param Type: The pcd Type # @param Value: The pcd Value # + + def IsValidPcdDatum(Type, Value): if not Value: return False, ST.ERR_DECPARSE_PCD_VALUE_EMPTY @@ -227,13 +237,13 @@ def IsValidPcdDatum(Type, Value): if Type not in ["UINT8", "UINT16", "UINT32", "UINT64", "VOID*", "BOOLE= AN"]: return False, ST.ERR_DECPARSE_PCD_TYPE if Type =3D=3D "VOID*": - if not ((Value.startswith('L"') or Value.startswith('"') and \ + if not ((Value.startswith('L"') or Value.startswith('"') and Value.endswith('"')) - or (IsValidCArray(Value)) or (IsValidCFormatGuid(Value)) \ + or (IsValidCArray(Value)) or (IsValidCFormatGuid(Value)) or (IsValidNList(Value)) or (CheckGuidRegFormat(Value)) - ): + ): return False, ST.ERR_DECPARSE_PCD_VOID % (Value, Type) - RealString =3D Value[Value.find('"') + 1 :-1] + RealString =3D Value[Value.find('"') + 1:-1] if RealString: if not IsValidBareCString(RealString): return False, ST.ERR_DECPARSE_PCD_VOID % (Value, Type) @@ -252,7 +262,7 @@ def IsValidPcdDatum(Type, Value): try: StrVal =3D Value if Value and not Value.startswith('0x') \ - and not Value.startswith('0X'): + and not Value.startswith('0X'): Value =3D Value.lstrip('0') if not Value: return True, "" @@ -268,8 +278,10 @@ def IsValidPcdDatum(Type, Value): =20 return True, "" =20 -## ParserHelper +# ParserHelper # + + class ParserHelper: def __init__(self, String, File=3D''): self._String =3D String @@ -277,7 +289,7 @@ class ParserHelper: self._Index =3D 0 self._File =3D File =20 - ## End + # End # # End # @@ -285,7 +297,7 @@ class ParserHelper: self.__SkipWhitespace() return self._Index >=3D self._StrLen =20 - ## __SkipWhitespace + # __SkipWhitespace # # Skip whitespace # @@ -295,7 +307,7 @@ class ParserHelper: break self._Index +=3D 1 =20 - ## Expect + # Expect # # Expect char in string # @@ -314,7 +326,7 @@ class ParserHelper: # return False =20 - ## GetToken + # GetToken # # Get token until encounter StopChar, front whitespace is consumed # @@ -338,7 +350,7 @@ class ParserHelper: LastChar =3D Char return self._String[PreIndex:self._Index] =20 - ## AssertChar + # AssertChar # # Assert char at current index of string is AssertChar, or will report # error message @@ -352,7 +364,7 @@ class ParserHelper: Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=3Dself._File, Line=3DErrorLineNum, ExtraData=3DErrorString) =20 - ## AssertEnd + # AssertEnd # # @param ErrorString: ErrorString # @param ErrorLineNum: ErrorLineNum diff --git a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py b/Base= Tools/Source/Python/UPT/Parser/InfAsBuiltProcess.py index 992b609120f8..04142396f3e6 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py +++ b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to provide method for process AsBuilt INF file. It wil= l consumed by InfParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -7,7 +7,7 @@ ''' InfAsBuiltProcess ''' -## Import modules +# Import modules # =20 import os @@ -27,7 +27,7 @@ from Parser.InfParserMisc import InfExpandMacro =20 from Library import DataType as DT =20 -## GetLibInstanceInfo +# GetLibInstanceInfo # # Get the information from Library Instance INF file. # @@ -35,6 +35,8 @@ from Library import DataType as DT # @param WorkSpace. The WorkSpace directory used to combined with INF file= path. # # @return GUID, Version + + def GetLibInstanceInfo(String, WorkSpace, LineNo, CurrentInfFileName): =20 FileGuidString =3D "" @@ -54,10 +56,10 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, Curre= ntInfFileName): # To deal with library instance specified by GUID and version # RegFormatGuidPattern =3D re.compile("\s*([0-9a-fA-F]){8}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){4}-" - "([0-9a-fA-F]){12}\s*") + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){4}-" + "([0-9a-fA-F]){12}\s*") VersionPattern =3D re.compile('[\t\s]*\d+(\.\d+)?[\t\s]*') GuidMatchedObj =3D RegFormatGuidPattern.search(String) =20 @@ -72,8 +74,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, Current= InfFileName): # # To deal with library instance specified by file name # - FileLinesList =3D GetFileLineContent(String, WorkSpace, LineNo, Origin= alString) - + FileLinesList =3D GetFileLineContent( + String, WorkSpace, LineNo, OriginalString) =20 ReFindFileGuidPattern =3D re.compile("^\s*FILE_GUID\s*=3D.*$") ReFindVerStringPattern =3D re.compile("^\s*VERSION_STRING\s*=3D.*$") @@ -91,7 +93,7 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, Current= InfFileName): =20 return FileGuidString, VerString =20 -## GetPackageListInfo +# GetPackageListInfo # # Get the package information from INF file. # @@ -99,6 +101,8 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo, Curren= tInfFileName): # @param WorkSpace. The WorkSpace directory used to combined with INF file= path. # # @return GUID, Version + + def GetPackageListInfo(FileNameString, WorkSpace, LineNo): PackageInfoList =3D [] DefineSectionMacros =3D {} @@ -169,7 +173,8 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineN= o): # # Replace with Local section Macro and [Defines] section Macro. # - Line =3D InfExpandMacro(Line, (FileNameString, Line, LineNo), = DefineSectionMacros, PackageSectionMacros, True) + Line =3D InfExpandMacro(Line, (FileNameString, Line, LineNo), + DefineSectionMacros, PackageSectionMacro= s, True) =20 Line =3D GetSplitValueList(Line, "#", 1)[0] Line =3D GetSplitValueList(Line, "|", 1)[0] @@ -177,6 +182,7 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineN= o): =20 return PackageInfoList =20 + def GetFileLineContent(FileName, WorkSpace, LineNo, OriginalString): =20 if not LineNo: @@ -185,7 +191,8 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, Ori= ginalString): # # Validate file name exist. # - FullFileName =3D os.path.normpath(os.path.realpath(os.path.join(WorkSp= ace, FileName))) + FullFileName =3D os.path.normpath( + os.path.realpath(os.path.join(WorkSpace, FileName))) if not (ValidFile(FullFileName)): return [] =20 @@ -203,7 +210,8 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, Ori= ginalString): try: FileLinesList =3D Inputfile.readlines() except BaseException: - Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_= FILE_OPEN_FAILURE, File=3DFullFileName) + Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, + ST.ERR_FILE_OPEN_FAILURE, File=3DFullFileName) finally: Inputfile.close() except BaseException: @@ -220,10 +228,12 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, O= riginalString): # Get all INF files from current workspace # # + + def GetInfsFromWorkSpace(WorkSpace): InfFiles =3D [] for top, dirs, files in os.walk(WorkSpace): - dirs =3D dirs # just for pylint + dirs =3D dirs # just for pylint for File in files: if File.upper().endswith(".INF"): InfFiles.append(os.path.join(top, File)) @@ -234,6 +244,8 @@ def GetInfsFromWorkSpace(WorkSpace): # Get GUID and version from library instance file # # + + def GetGuidVerFormLibInstance(Guid, Version, WorkSpace, CurrentInfFileName= ): for InfFile in GetInfsFromWorkSpace(WorkSpace): try: @@ -270,14 +282,13 @@ def GetGuidVerFormLibInstance(Guid, Version, WorkSpac= e, CurrentInfFileName): VerString =3D GetSplitValueList(VerString, '=3D', 1)[1] =20 if FileGuidString.strip().upper() =3D=3D Guid.upper() and \ - VerString.strip().upper() =3D=3D Version.upper(): + VerString.strip().upper() =3D=3D Version.upper(): return Guid, Version =20 except BaseException: - Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, ST.ERR_= FILE_OPEN_FAILURE, File=3DInfFile) + Logger.Error("InfParser", ToolError.FILE_READ_FAILURE, + ST.ERR_FILE_OPEN_FAILURE, File=3DInfFile) finally: InfFileObj.close() =20 return '', '' - - diff --git a/BaseTools/Source/Python/UPT/Parser/InfBinarySectionParser.py b= /BaseTools/Source/Python/UPT/Parser/InfBinarySectionParser.py index 58b53276ec0e..dec21e622d80 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfBinarySectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfBinarySectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Binaries] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,8 +23,9 @@ from Object.Parser.InfCommonObject import InfLineCommentO= bject from Object.Parser.InfCommonObject import CurrentLine from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfBinarySectionParser(InfParserSectionRoot): - ## InfBinaryParser + # InfBinaryParser # # def InfBinaryParser(self, SectionString, InfSectionObject, FileName): @@ -32,12 +33,12 @@ class InfBinarySectionParser(InfParserSectionRoot): # Macro defined in this section # SectionMacros =3D {} - ValueList =3D [] + ValueList =3D [] # # For UI (UI, SEC_UI, UNI_UI) binaries # One and only one UI section can be included # - UiBinaryList =3D [] + UiBinaryList =3D [] # # For Version (VER, SEC_VER, UNI_VER). # One and only one VER section on be included @@ -48,9 +49,9 @@ class InfBinarySectionParser(InfParserSectionRoot): # ComBinaryList =3D [] =20 - StillCommentFalg =3D False - HeaderComments =3D [] - LineComment =3D None + StillCommentFalg =3D False + HeaderComments =3D [] + LineComment =3D None =20 AllSectionContent =3D '' # @@ -58,7 +59,7 @@ class InfBinarySectionParser(InfParserSectionRoot): # for Line in SectionString: BinLineContent =3D Line[0] - BinLineNo =3D Line[1] + BinLineNo =3D Line[1] =20 if BinLineContent.strip() =3D=3D '': continue @@ -104,8 +105,10 @@ class InfBinarySectionParser(InfParserSectionRoot): # Find Tail comment. # if BinLineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - TailComments =3D BinLineContent[BinLineContent.find(DT.TAB= _COMMENT_SPLIT):] - BinLineContent =3D BinLineContent[:BinLineContent.find(DT.= TAB_COMMENT_SPLIT)] + TailComments =3D BinLineContent[BinLineContent.find( + DT.TAB_COMMENT_SPLIT):] + BinLineContent =3D BinLineContent[:BinLineContent.find( + DT.TAB_COMMENT_SPLIT)] if LineComment is None: LineComment =3D InfLineCommentObject() LineComment.SetTailComments(TailComments) @@ -114,9 +117,9 @@ class InfBinarySectionParser(InfParserSectionRoot): # Find Macro # MacroDef =3D MacroParser((BinLineContent, BinLineNo), - FileName, - DT.MODEL_EFI_BINARY_FILE, - self.FileLocalMacros) + FileName, + DT.MODEL_EFI_BINARY_FILE, + self.FileLocalMacros) if MacroDef[0] is not None: SectionMacros[MacroDef[0]] =3D MacroDef[1] LineComment =3D None @@ -157,8 +160,8 @@ class InfBinarySectionParser(InfParserSectionRoot): # Should equal to VER/SEC_VER/UNI_VER # elif ValueList[0] =3D=3D DT.BINARY_FILE_TYPE_UNI_VER or \ - ValueList[0] =3D=3D DT.BINARY_FILE_TYPE_SEC_VER or \ - ValueList[0] =3D=3D DT.BINARY_FILE_TYPE_VER: + ValueList[0] =3D=3D DT.BINARY_FILE_TYPE_SEC_VER or \ + ValueList[0] =3D=3D DT.BINARY_FILE_TYPE_VER: if len(ValueList) =3D=3D 2: TokenList =3D GetSplitValueList(ValueList[1], DT.TAB_VALUE_SPLIT, @@ -178,8 +181,8 @@ class InfBinarySectionParser(InfParserSectionRoot): 5) else: TokenList =3D GetSplitValueList(ValueList[1], - DT.TAB_VALUE_SPLIT, - 4) + DT.TAB_VALUE_SPLIT, + 4) =20 NewValueList =3D [] NewValueList.append(ValueList[0]) @@ -195,9 +198,6 @@ class InfBinarySectionParser(InfParserSectionRoot): LineComment, CurrentLineObj)) =20 - - - ValueList =3D [] LineComment =3D None TailComments =3D '' @@ -220,7 +220,7 @@ class InfBinarySectionParser(InfParserSectionRoot): ArchList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Bi= naries]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Binaries]"), File=3DFileName, Line=3DItem[3]) - diff --git a/BaseTools/Source/Python/UPT/Parser/InfBuildOptionSectionParser= .py b/BaseTools/Source/Python/UPT/Parser/InfBuildOptionSectionParser.py index e3b48e9f44f6..7b9f794a656f 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfBuildOptionSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfBuildOptionSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for BuildOption sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -25,22 +25,23 @@ from Library.ParserValidate import IsValidFamily from Library.ParserValidate import IsValidBuildOptionName from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfBuildOptionSectionParser(InfParserSectionRoot): - ## InfBuildOptionParser + # InfBuildOptionParser # # def InfBuildOptionParser(self, SectionString, InfSectionObject, FileNa= me): =20 BuildOptionList =3D [] - SectionContent =3D '' + SectionContent =3D '' =20 if not GlobalData.gIS_BINARY_INF: - ValueList =3D [] - LineNo =3D 0 + ValueList =3D [] + LineNo =3D 0 =20 for Line in SectionString: LineContent =3D Line[0] - LineNo =3D Line[1] + LineNo =3D Line[1] TailComments =3D '' ReplaceFlag =3D False =20 @@ -58,10 +59,13 @@ class InfBuildOptionSectionParser(InfParserSectionRoot): # Find Tail comment. # if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - TailComments =3D LineContent[LineContent.find(DT.TAB_C= OMMENT_SPLIT):] - LineContent =3D LineContent[:LineContent.find(DT.TAB_C= OMMENT_SPLIT)] + TailComments =3D LineContent[LineContent.find( + DT.TAB_COMMENT_SPLIT):] + LineContent =3D LineContent[:LineContent.find( + DT.TAB_COMMENT_SPLIT)] =20 - TokenList =3D GetSplitValueList(LineContent, DT.TAB_DEQUAL= _SPLIT, 1) + TokenList =3D GetSplitValueList( + LineContent, DT.TAB_DEQUAL_SPLIT, 1) if len(TokenList) =3D=3D 2: # # "Replace" type build option @@ -69,7 +73,8 @@ class InfBuildOptionSectionParser(InfParserSectionRoot): TokenList.append('True') ReplaceFlag =3D True else: - TokenList =3D GetSplitValueList(LineContent, DT.TAB_EQ= UAL_SPLIT, 1) + TokenList =3D GetSplitValueList( + LineContent, DT.TAB_EQUAL_SPLIT, 1) # # "Append" type build option # @@ -98,7 +103,8 @@ class InfBuildOptionSectionParser(InfParserSectionRoot): else: EqualString =3D ' =3D=3D ' =20 - SectionContent +=3D ValueList[0] + EqualString + ValueList= [1] + TailComments + DT.END_OF_LINE + SectionContent +=3D ValueList[0] + EqualString + \ + ValueList[1] + TailComments + DT.END_OF_LINE =20 Family =3D GetSplitValueList(ValueList[0], DT.TAB_COLON_SP= LIT, 1) if len(Family) =3D=3D 2: @@ -129,7 +135,8 @@ class InfBuildOptionSectionParser(InfParserSectionRoot): ValueList =3D [] continue else: - BuildOptionList =3D InfAsBuiltBuildOptionParser(SectionString,= FileName) + BuildOptionList =3D InfAsBuiltBuildOptionParser( + SectionString, FileName) =20 # # Current section archs @@ -146,13 +153,16 @@ class InfBuildOptionSectionParser(InfParserSectionRoo= t): if not InfSectionObject.SetBuildOptions(BuildOptionList, ArchList,= SectionContent): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Bu= ilOptions]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[BuilOptions]"), File=3DFileName, Line=3DLastItem[3]) =20 -## InfBuildOptionParser +# InfBuildOptionParser # # + + def InfAsBuiltBuildOptionParser(SectionString, FileName): BuildOptionList =3D [] # @@ -164,7 +174,7 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName= ): for Line in SectionString: Count +=3D 1 LineContent =3D Line[0] - LineNo =3D Line[1] + LineNo =3D Line[1] =20 # # The last line @@ -172,7 +182,8 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName= ): if len(SectionString) =3D=3D Count: if LineContent.strip().startswith("##") and AsBuildOptionFlag: BuildOptionList.append(BuildOptionItem) - BuildOptionList.append([GetHelpStringByRemoveHashKey(LineC= ontent)]) + BuildOptionList.append( + [GetHelpStringByRemoveHashKey(LineContent)]) elif LineContent.strip().startswith("#") and AsBuildOptionFlag: BuildOptionInfo =3D GetHelpStringByRemoveHashKey(LineConte= nt) BuildOptionItem.append(BuildOptionInfo) @@ -195,11 +206,11 @@ def InfAsBuiltBuildOptionParser(SectionString, FileNa= me): =20 if not LineContent.strip().startswith("#"): Logger.Error('InfParser', - FORMAT_INVALID, - ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON, - File=3DFileName, - Line=3DLineNo, - ExtraData=3DLineContent) + FORMAT_INVALID, + ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON, + File=3DFileName, + Line=3DLineNo, + ExtraData=3DLineContent) =20 if IsAsBuildOptionInfo(LineContent): AsBuildOptionFlag =3D True diff --git a/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py b= /BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py index a63e40e61787..49fd1a26f40e 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfDefineSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for define sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -26,14 +26,17 @@ from Object.Parser.InfMisc import ErrorInInf from Logger import StringTable as ST from Parser.InfParserMisc import InfParserSectionRoot =20 -## __GetValidateArchList +# __GetValidateArchList # # + + def GetValidateArchList(LineContent): =20 TempArch =3D '' ArchList =3D [] - ValidateAcrhPatten =3D re.compile(r"^\s*#\s*VALID_ARCHITECTURES\s*=3D\= s*.*$", re.DOTALL) + ValidateAcrhPatten =3D re.compile( + r"^\s*#\s*VALID_ARCHITECTURES\s*=3D\s*.*$", re.DOTALL) =20 if ValidateAcrhPatten.match(LineContent): TempArch =3D GetSplitValueList(LineContent, DT.TAB_EQUAL_SPLIT, 1)= [1] @@ -50,6 +53,7 @@ def GetValidateArchList(LineContent): =20 return ArchList =20 + class InfDefinSectionParser(InfParserSectionRoot): def InfDefineParser(self, SectionString, InfSectionObject, FileName, S= ectionComment): =20 @@ -58,12 +62,12 @@ class InfDefinSectionParser(InfParserSectionRoot): # # Parser Defines section content and fill self._ContentList dict. # - StillCommentFalg =3D False + StillCommentFalg =3D False HeaderComments =3D [] SectionContent =3D '' - ArchList =3D [] - _ContentList =3D [] - _ValueList =3D [] + ArchList =3D [] + _ContentList =3D [] + _ValueList =3D [] # # Add WORKSPACE to global Marco dict. # @@ -71,14 +75,14 @@ class InfDefinSectionParser(InfParserSectionRoot): =20 for Line in SectionString: LineContent =3D Line[0] - LineNo =3D Line[1] - TailComments =3D '' - LineComment =3D None + LineNo =3D Line[1] + TailComments =3D '' + LineComment =3D None =20 - LineInfo =3D ['', -1, ''] - LineInfo[0] =3D FileName - LineInfo[1] =3D LineNo - LineInfo[2] =3D LineContent + LineInfo =3D ['', -1, ''] + LineInfo[0] =3D FileName + LineInfo[1] =3D LineNo + LineInfo[2] =3D LineContent =20 if LineContent.strip() =3D=3D '': continue @@ -125,8 +129,10 @@ class InfDefinSectionParser(InfParserSectionRoot): # Find Tail comment. # if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - TailComments =3D LineContent[LineContent.find(DT.TAB_COMME= NT_SPLIT):] - LineContent =3D LineContent[:LineContent.find(DT.TAB_COMME= NT_SPLIT)] + TailComments =3D LineContent[LineContent.find( + DT.TAB_COMMENT_SPLIT):] + LineContent =3D LineContent[:LineContent.find( + DT.TAB_COMMENT_SPLIT)] if LineComment is None: LineComment =3D InfLineCommentObject() LineComment.SetTailComments(TailComments) @@ -168,8 +174,10 @@ class InfDefinSectionParser(InfParserSectionRoot): =20 InfDefMemberObj =3D InfDefMember(Name, Value) if (LineComment is not None): - InfDefMemberObj.Comments.SetHeaderComments(LineComment.Get= HeaderComments()) - InfDefMemberObj.Comments.SetTailComments(LineComment.GetTa= ilComments()) + InfDefMemberObj.Comments.SetHeaderComments( + LineComment.GetHeaderComments()) + InfDefMemberObj.Comments.SetTailComments( + LineComment.GetTailComments()) =20 InfDefMemberObj.CurrentLine.SetFileName(self.FullPath) InfDefMemberObj.CurrentLine.SetLineString(LineContent) @@ -188,4 +196,3 @@ class InfDefinSectionParser(InfParserSectionRoot): InfSectionObject.SetAllContent(SectionContent) =20 InfSectionObject.SetDefines(_ContentList, Arch=3DArchList) - diff --git a/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py b/= BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py index a2e836e482b9..bdad3c79c5bd 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Depex] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -20,8 +20,9 @@ from Library import DataType as DT from Library.Misc import GetSplitValueList from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfDepexSectionParser(InfParserSectionRoot): - ## InfDepexParser + # InfDepexParser # # For now, only separate Depex String and comments. # Have two types of section header. @@ -31,13 +32,13 @@ class InfDepexSectionParser(InfParserSectionRoot): def InfDepexParser(self, SectionString, InfSectionObject, FileName): DepexContent =3D [] DepexComment =3D [] - ValueList =3D [] + ValueList =3D [] # # Parse section content # for Line in SectionString: LineContent =3D Line[0] - LineNo =3D Line[1] + LineNo =3D Line[1] =20 # # Found comment @@ -59,7 +60,6 @@ class InfDepexSectionParser(InfParserSectionRoot): DepexComment.append((LineContent[CommentCount:], LineNo)) LineContent =3D LineContent[:CommentCount-1] =20 - CommentCount =3D -1 DepexContent.append((LineContent, LineNo)) =20 @@ -90,9 +90,10 @@ class InfDepexSectionParser(InfParserSectionRoot): else: FormatCommentLn =3D CommentItem[1] + 1 =20 - if not InfSectionObject.SetDepex(DepexContent, KeyList =3D KeyList= , CommentList =3D NewCommentList): + if not InfSectionObject.SetDepex(DepexContent, KeyList=3DKeyList, = CommentList=3DNewCommentList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[De= pex]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Depex]"), File=3DFileName, Line=3DLastItem[3]) diff --git a/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionPa= rser.py b/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParse= r.py index 9b83c0473ba6..2821007a5319 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Guids], [Ppis], [Protocols] sections= in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -25,8 +25,9 @@ from Library.ParserValidate import IsValidUserId from Library.ParserValidate import IsValidArch from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfGuidPpiProtocolSectionParser(InfParserSectionRoot): - ## InfGuidParser + # InfGuidParser # # def InfGuidParser(self, SectionString, InfSectionObject, FileName): @@ -58,10 +59,10 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): # if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: CommentsList.append(( - LineContent[LineContent.find(DT.TAB_COMMENT_SP= LIT):], - LineNo)) + LineContent[LineContent.find(DT.TAB_COMMENT_SPLIT)= :], + LineNo)) LineContent =3D \ - LineContent[:LineContent.find(DT.TAB_COMMENT_S= PLIT)] + LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT= )] =20 if LineContent !=3D '': # @@ -77,7 +78,8 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoo= t): ValueList =3D [] continue =20 - TokenList =3D GetSplitValueList(LineContent, DT.TAB_VALUE_= SPLIT, 1) + TokenList =3D GetSplitValueList( + LineContent, DT.TAB_VALUE_SPLIT, 1) ValueList[0:len(TokenList)] =3D TokenList =20 # @@ -85,11 +87,10 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): # ValueList =3D [InfExpandMacro(Value, (FileName, LineConten= t, LineNo), self.FileLocalMacros, SectionM= acros, True) - for Value in ValueList] + for Value in ValueList] =20 CurrentLineVar =3D (LineContent, LineNo, FileName) =20 - if len(ValueList) >=3D 1: GuidList.append((ValueList, CommentsList, CurrentLineVar)) CommentsList =3D [] @@ -109,11 +110,12 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): if not InfSectionObject.SetGuid(GuidList, Arch=3DArchList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[= Guid]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Guid]"), File=3DFileName, Line=3DLineIndex) =20 - ## InfPpiParser + # InfPpiParser # # def InfPpiParser(self, SectionString, InfSectionObject, FileName): @@ -145,10 +147,10 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): # if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: CommentsList.append(( - LineContent[LineContent.find(DT.TAB_COMMENT_SP= LIT):], - LineNo)) + LineContent[LineContent.find(DT.TAB_COMMENT_SPLIT)= :], + LineNo)) LineContent =3D \ - LineContent[:LineContent.find(DT.TAB_COMMENT_S= PLIT)] + LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT= )] =20 if LineContent !=3D '': # @@ -164,14 +166,15 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): CommentsList =3D [] continue =20 - TokenList =3D GetSplitValueList(LineContent, DT.TAB_VALUE_= SPLIT, 1) + TokenList =3D GetSplitValueList( + LineContent, DT.TAB_VALUE_SPLIT, 1) ValueList[0:len(TokenList)] =3D TokenList =20 # # Replace with Local section Macro and [Defines] section M= acro. # ValueList =3D [InfExpandMacro(Value, (FileName, LineConten= t, LineNo), self.FileLocalMacros, SectionMacros) - for Value in ValueList] + for Value in ValueList] =20 CurrentLineVar =3D (LineContent, LineNo, FileName) =20 @@ -194,11 +197,12 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): if not InfSectionObject.SetPpi(PpiList, Arch=3DArchList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[= Ppis]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Ppis]"), File=3DFileName, Line=3DLineIndex) =20 - ## InfUserExtensionParser + # InfUserExtensionParser # # def InfUserExtensionParser(self, SectionString, InfSectionObject, File= Name): @@ -245,7 +249,8 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): if not IsValidUserId(UserId): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_UE_SECTION_USER_ID_ERRO= R % (Item[1]), + ST.ERR_INF_PARSER_UE_SECTION_USER_ID_ERRO= R % ( + Item[1]), File=3DGlobalData.gINF_MODULE_NAME, Line=3DSectionLineNo, ExtraData=3DNone) @@ -253,7 +258,8 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): if not IsValidIdString(IdString): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_UE_SECTION_ID_STRING_ER= ROR % (IdString), + ST.ERR_INF_PARSER_UE_SECTION_ID_STRING_ER= ROR % ( + IdString), File=3DGlobalData.gINF_MODULE_NAME, Line= =3DSectionLineNo, ExtraData=3DNone) IdContentList.append((UserId, IdString, Arch)) @@ -272,7 +278,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR = % ( - IdStri= ng), + IdString), File=3DGlobalData.gINF_MODULE_NAME, Line=3DSectionLineNo, ExtraData=3DNone) @@ -281,10 +287,10 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): if not InfSectionObject.SetUserExtension(UserExtensionContent, IdContent=3DIdContentList, LineNo=3DSectionLineNo): - Logger.Error\ - ('InfParser', FORMAT_INVALID, \ - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[UserExtensio= n]"), \ - File=3DFileName, Line=3DLastItem[4]) + Logger.Error('InfParser', FORMAT_INVALID, + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[UserExtension]"), + File=3DFileName, Line=3DLastItem[4]) =20 def InfProtocolParser(self, SectionString, InfSectionObject, FileName): # @@ -315,10 +321,10 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): # if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1: CommentsList.append(( - LineContent[LineContent.find(DT.TAB_COMMENT_SP= LIT):], - LineNo)) + LineContent[LineContent.find(DT.TAB_COMMENT_SPLIT)= :], + LineNo)) LineContent =3D \ - LineContent[:LineContent.find(DT.TAB_COMMENT_S= PLIT)] + LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT= )] =20 if LineContent !=3D '': # @@ -334,14 +340,15 @@ class InfGuidPpiProtocolSectionParser(InfParserSectio= nRoot): CommentsList =3D [] continue =20 - TokenList =3D GetSplitValueList(LineContent, DT.TAB_VALUE_= SPLIT, 1) + TokenList =3D GetSplitValueList( + LineContent, DT.TAB_VALUE_SPLIT, 1) ValueList[0:len(TokenList)] =3D TokenList =20 # # Replace with Local section Macro and [Defines] section M= acro. # ValueList =3D [InfExpandMacro(Value, (FileName, LineConten= t, LineNo), self.FileLocalMacros, SectionMacros) - for Value in ValueList] + for Value in ValueList] =20 CurrentLineVar =3D (LineContent, LineNo, FileName) =20 @@ -362,7 +369,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionR= oot): ArchList.append(Item[1]) =20 if not InfSectionObject.SetProtocol(ProtocolList, Arch=3DArchList): - Logger.Error\ - ('InfParser', FORMAT_INVALID, \ - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[Protocol]"),= \ - File=3DFileName, Line=3DLineIndex) + Logger.Error('InfParser', FORMAT_INVALID, + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Protocol]"), + File=3DFileName, Line=3DLineIndex) diff --git a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py = b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py index f2070b51a42f..61fb75c717d1 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfLibrarySectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Libraries] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -25,8 +25,9 @@ from Parser.InfParserMisc import IsLibInstanceInfo from Parser.InfAsBuiltProcess import GetLibInstanceInfo from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfLibrarySectionParser(InfParserSectionRoot): - ## InfLibraryParser + # InfLibraryParser # # def InfLibraryParser(self, SectionString, InfSectionObject, FileName): @@ -88,8 +89,10 @@ class InfLibrarySectionParser(InfParserSectionRoot): # Find Tail comment. # if LibLineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - LibTailComments =3D LibLineContent[LibLineContent.find= (DT.TAB_COMMENT_SPLIT):] - LibLineContent =3D LibLineContent[:LibLineContent.find= (DT.TAB_COMMENT_SPLIT)] + LibTailComments =3D LibLineContent[LibLineContent.find( + DT.TAB_COMMENT_SPLIT):] + LibLineContent =3D LibLineContent[:LibLineContent.find( + DT.TAB_COMMENT_SPLIT)] if LibLineComment is None: LibLineComment =3D InfLineCommentObject() LibLineComment.SetTailComments(LibTailComments) @@ -107,7 +110,8 @@ class InfLibrarySectionParser(InfParserSectionRoot): LibHeaderComments =3D [] continue =20 - TokenList =3D GetSplitValueList(LibLineContent, DT.TAB_VAL= UE_SPLIT, 1) + TokenList =3D GetSplitValueList( + LibLineContent, DT.TAB_VALUE_SPLIT, 1) ValueList[0:len(TokenList)] =3D TokenList =20 # @@ -115,7 +119,7 @@ class InfLibrarySectionParser(InfParserSectionRoot): # ValueList =3D [InfExpandMacro(Value, (FileName, LibLineCon= tent, LibLineNo), self.FileLocalMacros, SectionM= acros, True) - for Value in ValueList] + for Value in ValueList] =20 LibraryList.append((ValueList, LibLineComment, (LibLineContent, LibLineNo, FileName))) @@ -137,14 +141,16 @@ class InfLibrarySectionParser(InfParserSectionRoot): if not InfSectionObject.SetLibraryClasses(LibraryList, KeyList= =3DKeyList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= ("[Library]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= ( + "[Library]"), File=3DFileName, Line=3DItem[3]) # # For Binary INF # else: - self.InfAsBuiltLibraryParser(SectionString, InfSectionObject, = FileName) + self.InfAsBuiltLibraryParser( + SectionString, InfSectionObject, FileName) =20 def InfAsBuiltLibraryParser(self, SectionString, InfSectionObject, Fil= eName): LibraryList =3D [] @@ -159,18 +165,19 @@ class InfLibrarySectionParser(InfParserSectionRoot): =20 if not LineContent.strip().startswith("#"): Logger.Error('InfParser', - FORMAT_INVALID, - ST.ERR_LIB_CONTATIN_ASBUILD_AND_COMMON, - File=3DFileName, - Line=3DLineNo, - ExtraData=3DLineContent) + FORMAT_INVALID, + ST.ERR_LIB_CONTATIN_ASBUILD_AND_COMMON, + File=3DFileName, + Line=3DLineNo, + ExtraData=3DLineContent) =20 if IsLibInstanceInfo(LineContent): LibInsFlag =3D True continue =20 if LibInsFlag: - LibGuid, LibVer =3D GetLibInstanceInfo(LineContent, Global= Data.gWORKSPACE, LineNo, FileName) + LibGuid, LibVer =3D GetLibInstanceInfo( + LineContent, GlobalData.gWORKSPACE, LineNo, FileName) # # If the VERSION_STRING is missing from the INF file, tool= should default to "0". # @@ -192,6 +199,7 @@ class InfLibrarySectionParser(InfParserSectionRoot): if not InfSectionObject.SetLibraryClasses(LibraryList, KeyList=3DK= eyList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[= Library]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Library]"), File=3DFileName, Line=3DItem[3]) diff --git a/BaseTools/Source/Python/UPT/Parser/InfPackageSectionParser.py = b/BaseTools/Source/Python/UPT/Parser/InfPackageSectionParser.py index f43241034d22..d040f50c4d74 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfPackageSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfPackageSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Packages] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -22,8 +22,9 @@ from Library.Misc import GetSplitValueList from Object.Parser.InfCommonObject import InfLineCommentObject from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfPackageSectionParser(InfParserSectionRoot): - ## InfPackageParser + # InfPackageParser # # def InfPackageParser(self, SectionString, InfSectionObject, FileName): @@ -31,17 +32,17 @@ class InfPackageSectionParser(InfParserSectionRoot): # Macro defined in this section # SectionMacros =3D {} - ValueList =3D [] - PackageList =3D [] - StillCommentFalg =3D False - HeaderComments =3D [] - LineComment =3D None + ValueList =3D [] + PackageList =3D [] + StillCommentFalg =3D False + HeaderComments =3D [] + LineComment =3D None # # Parse section content # for Line in SectionString: PkgLineContent =3D Line[0] - PkgLineNo =3D Line[1] + PkgLineNo =3D Line[1] =20 if PkgLineContent.strip() =3D=3D '': continue @@ -81,8 +82,10 @@ class InfPackageSectionParser(InfParserSectionRoot): # Find Tail comment. # if PkgLineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - TailComments =3D PkgLineContent[PkgLineContent.find(DT.TAB= _COMMENT_SPLIT):] - PkgLineContent =3D PkgLineContent[:PkgLineContent.find(DT.= TAB_COMMENT_SPLIT)] + TailComments =3D PkgLineContent[PkgLineContent.find( + DT.TAB_COMMENT_SPLIT):] + PkgLineContent =3D PkgLineContent[:PkgLineContent.find( + DT.TAB_COMMENT_SPLIT)] if LineComment is None: LineComment =3D InfLineCommentObject() LineComment.SetTailComments(TailComments) @@ -99,7 +102,8 @@ class InfPackageSectionParser(InfParserSectionRoot): HeaderComments =3D [] continue =20 - TokenList =3D GetSplitValueList(PkgLineContent, DT.TAB_VALUE_S= PLIT, 1) + TokenList =3D GetSplitValueList( + PkgLineContent, DT.TAB_VALUE_SPLIT, 1) ValueList[0:len(TokenList)] =3D TokenList =20 # @@ -107,7 +111,7 @@ class InfPackageSectionParser(InfParserSectionRoot): # ValueList =3D [InfExpandMacro(Value, (FileName, PkgLineContent= , PkgLineNo), self.FileLocalMacros, SectionMacro= s, True) - for Value in ValueList] + for Value in ValueList] =20 PackageList.append((ValueList, LineComment, (PkgLineContent, PkgLineNo, FileName))) @@ -125,10 +129,10 @@ class InfPackageSectionParser(InfParserSectionRoot): if Item[1] not in ArchList: ArchList.append(Item[1]) =20 - if not InfSectionObject.SetPackages(PackageList, Arch =3D ArchList= ): + if not InfSectionObject.SetPackages(PackageList, Arch=3DArchList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR\ - %("[Packages]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR + % ("[Packages]"), File=3DFileName, Line=3DItem[3]) diff --git a/BaseTools/Source/Python/UPT/Parser/InfParser.py b/BaseTools/So= urce/Python/UPT/Parser/InfParser.py index 2072be6e42f9..a4cbad7feb5f 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -38,9 +38,11 @@ from Parser.InfSectionParser import InfSectionParser from Parser.InfParserMisc import gINF_SECTION_DEF from Parser.InfParserMisc import IsBinaryInf =20 -## OpenInfFile +# OpenInfFile # # + + def OpenInfFile(Filename): FileLinesList =3D [] =20 @@ -63,7 +65,7 @@ def OpenInfFile(Filename): =20 return FileLinesList =20 -## InfParser +# InfParser # # This class defined the structure used in InfParser object # @@ -73,19 +75,21 @@ def OpenInfFile(Filename): # @param WorkspaceDir: Input value for current workspace directory, # default is None # + + class InfParser(InfSectionParser): =20 - def __init__(self, Filename =3D None, WorkspaceDir =3D None): + def __init__(self, Filename=3DNone, WorkspaceDir=3DNone): =20 # # Call parent class construct function # InfSectionParser.__init__() =20 - self.WorkspaceDir =3D WorkspaceDir - self.SupArchList =3D DT.ARCH_LIST - self.EventList =3D [] - self.HobList =3D [] + self.WorkspaceDir =3D WorkspaceDir + self.SupArchList =3D DT.ARCH_LIST + self.EventList =3D [] + self.HobList =3D [] self.BootModeList =3D [] =20 # @@ -94,7 +98,7 @@ class InfParser(InfSectionParser): if Filename is not None: self.ParseInfFile(Filename) =20 - ## Parse INF file + # Parse INF file # # Parse the file if it exists # @@ -113,18 +117,18 @@ class InfParser(InfSectionParser): # # Initialize common data # - LineNo =3D 0 - CurrentSection =3D DT.MODEL_UNKNOWN - SectionLines =3D [] + LineNo =3D 0 + CurrentSection =3D DT.MODEL_UNKNOWN + SectionLines =3D [] =20 # # Flags # HeaderCommentStart =3D False - HeaderCommentEnd =3D False + HeaderCommentEnd =3D False HeaderStarLineNo =3D -1 BinaryHeaderCommentStart =3D False - BinaryHeaderCommentEnd =3D False + BinaryHeaderCommentEnd =3D False BinaryHeaderStarLineNo =3D -1 =20 # @@ -136,17 +140,17 @@ class InfParser(InfSectionParser): # # Parse file content # - CommentBlock =3D [] + CommentBlock =3D [] =20 # # Variables for Event/Hob/BootMode # - self.EventList =3D [] - self.HobList =3D [] + self.EventList =3D [] + self.HobList =3D [] self.BootModeList =3D [] SectionType =3D '' =20 - FileLinesList =3D OpenInfFile (Filename) + FileLinesList =3D OpenInfFile(Filename) =20 # # One INF file can only has one [Defines] section. @@ -178,8 +182,8 @@ class InfParser(InfSectionParser): InfSectionCommonDefObj =3D None =20 for Line in FileLinesList: - LineNo =3D LineNo + 1 - Line =3D Line.strip() + LineNo =3D LineNo + 1 + Line =3D Line.strip() if (LineNo < len(FileLinesList) - 1): NextLine =3D FileLinesList[LineNo].strip() =20 @@ -209,28 +213,30 @@ class InfParser(InfSectionParser): # Collect Header content. # if (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection = =3D=3D DT.MODEL_META_DATA_FILE_HEADER) and\ - HeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_= COMMENT) and not\ - HeaderCommentEnd and NextLine !=3D '': + HeaderCommentStart and not Line.startswith(DT.TAB_SPEC= IAL_COMMENT) and not\ + HeaderCommentEnd and NextLine !=3D '': SectionLines.append((Line, LineNo)) continue # # Header content end # if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip(= ).startswith("#")) and HeaderCommentStart \ - and not HeaderCommentEnd: + and not HeaderCommentEnd: HeaderCommentEnd =3D True BinaryHeaderCommentStart =3D False - BinaryHeaderCommentEnd =3D False + BinaryHeaderCommentEnd =3D False HeaderCommentStart =3D False if Line.find(DT.TAB_BINARY_HEADER_COMMENT) > -1: - self.InfHeaderParser(SectionLines, self.InfHeader, sel= f.FileName) + self.InfHeaderParser( + SectionLines, self.InfHeader, self.FileName) SectionLines =3D [] else: SectionLines.append((Line, LineNo)) # # Call Header comment parser. # - self.InfHeaderParser(SectionLines, self.InfHeader, sel= f.FileName) + self.InfHeaderParser( + SectionLines, self.InfHeader, self.FileName) SectionLines =3D [] continue =20 @@ -239,7 +245,7 @@ class InfParser(InfSectionParser): # if Line.startswith(DT.TAB_SPECIAL_COMMENT) and \ (Line.find(DT.TAB_BINARY_HEADER_COMMENT) > -1) and \ - not BinaryHeaderCommentStart: + not BinaryHeaderCommentStart: SectionLines =3D [] CurrentSection =3D DT.MODEL_META_DATA_FILE_HEADER # @@ -255,7 +261,7 @@ class InfParser(InfSectionParser): # check whether there are more than one binary header exist # if Line.startswith(DT.TAB_SPECIAL_COMMENT) and BinaryHeaderCom= mentStart and \ - not BinaryHeaderCommentEnd and (Line.find(DT.TAB_BINARY_HE= ADER_COMMENT) > -1): + not BinaryHeaderCommentEnd and (Line.find(DT.TAB_BINAR= Y_HEADER_COMMENT) > -1): Logger.Error('Parser', FORMAT_INVALID, ST.ERR_MULTIPLE_BINARYHEADER_EXIST, @@ -265,23 +271,24 @@ class InfParser(InfSectionParser): # Collect Binary Header content. # if (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection = =3D=3D DT.MODEL_META_DATA_FILE_HEADER) and\ - BinaryHeaderCommentStart and not Line.startswith(DT.TAB_SP= ECIAL_COMMENT) and not\ - BinaryHeaderCommentEnd and NextLine !=3D '': + BinaryHeaderCommentStart and not Line.startswith(DT.TA= B_SPECIAL_COMMENT) and not\ + BinaryHeaderCommentEnd and NextLine !=3D '': SectionLines.append((Line, LineNo)) continue # # Binary Header content end # if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip(= ).startswith(DT.TAB_COMMENT_SPLIT)) and \ - BinaryHeaderCommentStart and not BinaryHeaderCommentEnd: + BinaryHeaderCommentStart and not BinaryHeaderCommentEn= d: SectionLines.append((Line, LineNo)) BinaryHeaderCommentStart =3D False # # Call Binary Header comment parser. # - self.InfHeaderParser(SectionLines, self.InfBinaryHeader, s= elf.FileName, True) + self.InfHeaderParser( + SectionLines, self.InfBinaryHeader, self.FileName, Tru= e) SectionLines =3D [] - BinaryHeaderCommentEnd =3D True + BinaryHeaderCommentEnd =3D True continue # # Find a new section tab @@ -300,7 +307,7 @@ class InfParser(InfSectionParser): # # Encountered a section. start with '[' and end with ']' # - if (Line.startswith(DT.TAB_SECTION_START) and \ + if (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg: =20 HeaderCommentEnd =3D True @@ -323,14 +330,15 @@ class InfParser(InfSectionParser): # Keep last time section header content for section pa= rser # usage. # - self.LastSectionHeaderContent =3D deepcopy(self.Sectio= nHeaderContent) + self.LastSectionHeaderContent =3D deepcopy( + self.SectionHeaderContent) =20 # # TailComments in section define. # TailComments =3D '' CommentIndex =3D Line.find(DT.TAB_COMMENT_SPLIT) - if CommentIndex > -1: + if CommentIndex > -1: TailComments =3D Line[CommentIndex:] Line =3D Line[:CommentIndex] =20 @@ -345,8 +353,8 @@ class InfParser(InfSectionParser): # if CurrentSection =3D=3D DT.MODEL_META_DATA_DEFINE: DefineSectionParsedFlag =3D self._CallSectionParse= rs(CurrentSection, - DefineS= ectionParsedFlag, SectionLines, - InfSect= ionCommonDefObj, LineNo) + = DefineSectionParsedFlag, SectionLines, + = InfSectionCommonDefObj, LineNo) # # Compare the new section name with current # @@ -354,7 +362,8 @@ class InfParser(InfSectionParser): =20 self._CheckSectionHeaders(Line, LineNo) =20 - SectionType =3D _ConvertSecNameToType(self.SectionHead= erContent[0][0]) + SectionType =3D _ConvertSecNameToType( + self.SectionHeaderContent[0][0]) =20 if not FirstSectionStartFlag: CurrentSection =3D SectionType @@ -366,7 +375,8 @@ class InfParser(InfSectionParser): continue =20 if LastSectionFalg: - SectionLines, CurrentSection =3D self._ProcessLastSection(= SectionLines, Line, LineNo, CurrentSection) + SectionLines, CurrentSection =3D self._ProcessLastSection( + SectionLines, Line, LineNo, CurrentSection) =20 # # End of section content collect. @@ -374,7 +384,7 @@ class InfParser(InfSectionParser): # if NewSectionStartFlag or LastSectionFalg: if CurrentSection !=3D DT.MODEL_META_DATA_DEFINE or \ - (LastSectionFalg and CurrentSection =3D=3D DT.MODEL_ME= TA_DATA_DEFINE): + (LastSectionFalg and CurrentSection =3D=3D DT.MODE= L_META_DATA_DEFINE): DefineSectionParsedFlag =3D self._CallSectionParsers(C= urrentSection, Def= ineSectionParsedFlag, SectionLines, Inf= SectionCommonDefObj, LineNo) @@ -387,14 +397,14 @@ class InfParser(InfSectionParser): =20 if HeaderStarLineNo =3D=3D -1: Logger.Error("InfParser", - FORMAT_INVALID, - ST.ERR_NO_SOURCE_HEADER, - File=3Dself.FullPath) - if BinaryHeaderStarLineNo > -1 and HeaderStarLineNo > -1 and Head= erStarLineNo > BinaryHeaderStarLineNo: + FORMAT_INVALID, + ST.ERR_NO_SOURCE_HEADER, + File=3Dself.FullPath) + if BinaryHeaderStarLineNo > -1 and HeaderStarLineNo > -1 and Heade= rStarLineNo > BinaryHeaderStarLineNo: Logger.Error("InfParser", - FORMAT_INVALID, - ST.ERR_BINARY_HEADER_ORDER, - File=3Dself.FullPath) + FORMAT_INVALID, + ST.ERR_BINARY_HEADER_ORDER, + File=3Dself.FullPath) # # EDKII INF should not have EDKI style comment # @@ -411,7 +421,7 @@ class InfParser(InfSectionParser): # self._ExtractEventHobBootMod(FileLinesList) =20 - ## _CheckSectionHeaders + # _CheckSectionHeaders # # def _CheckSectionHeaders(self, Line, LineNo): @@ -429,10 +439,10 @@ class InfParser(InfSectionParser): # check. # if SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_FIXED_= PCD.upper() or \ - SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_PATCH= _PCD.upper() or \ - SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_PCD_E= X.upper() or \ - SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_PCD.u= pper() or \ - SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_FEATU= RE_PCD.upper(): + SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_P= ATCH_PCD.upper() or \ + SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_P= CD_EX.upper() or \ + SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_P= CD.upper() or \ + SectionItem[0].strip().upper() =3D=3D DT.TAB_INF_F= EATURE_PCD.upper(): ArchList =3D GetSplitValueList(SectionItem[1].strip(),= ' ') else: ArchList =3D [SectionItem[1].strip()] @@ -441,10 +451,11 @@ class InfParser(InfSectionParser): if (not IsValidArch(Arch)) and \ (SectionItem[0].strip().upper() !=3D DT.TAB_DEPEX.= upper()) and \ (SectionItem[0].strip().upper() !=3D DT.TAB_USER_E= XTENSIONS.upper()) and \ - (SectionItem[0].strip().upper() !=3D DT.TAB_COMMON= _DEFINES.upper()): + (SectionItem[0].strip().upper() !=3D DT.TAB_CO= MMON_DEFINES.upper()): Logger.Error("InfParser", FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_INVAL= ID%(SectionItem[1]), + ST.ERR_INF_PARSER_DEFINE_FROMAT_INVAL= ID % ( + SectionItem[1]), File=3Dself.FullPath, Line=3DLineNo, ExtraData=3DLine) # @@ -454,15 +465,16 @@ class InfParser(InfSectionParser): if (self.SectionHeaderContent[0][0].upper() in ChkModSecti= onList): if SectionItem[2].strip().upper(): MoudleTypeList =3D GetSplitValueList( - SectionItem[2].strip().upper()) + SectionItem[2].strip().upper()) if (not IsValidInfMoudleTypeList(MoudleTypeList)): Logger.Error("InfParser", FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_I= NVALID%(SectionItem[2]), + ST.ERR_INF_PARSER_DEFINE_FROMAT_I= NVALID % ( + SectionItem[2]), File=3Dself.FullPath, Line=3DLine= No, ExtraData=3DLine) =20 - ## _CallSectionParsers + # _CallSectionParsers # # def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag, @@ -479,7 +491,7 @@ class InfParser(InfSectionParser): PARSER_ERROR, ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION, File=3Dself.FullPath, - RaiseError =3D Logger.IS_RAISE_ERROR) + RaiseError=3DLogger.IS_RAISE_ERROR) =20 elif CurrentSection =3D=3D DT.MODEL_META_DATA_BUILD_OPTION: self.InfBuildOptionParser(SectionLines, @@ -499,10 +511,10 @@ class InfParser(InfSectionParser): # [Pcd] Sections, put it together # elif CurrentSection =3D=3D DT.MODEL_PCD_FIXED_AT_BUILD or \ - CurrentSection =3D=3D DT.MODEL_PCD_PATCHABLE_IN_MODULE or \ - CurrentSection =3D=3D DT.MODEL_PCD_FEATURE_FLAG or \ - CurrentSection =3D=3D DT.MODEL_PCD_DYNAMIC_EX or \ - CurrentSection =3D=3D DT.MODEL_PCD_DYNAMIC: + CurrentSection =3D=3D DT.MODEL_PCD_PATCHABLE_IN_MODULE or \ + CurrentSection =3D=3D DT.MODEL_PCD_FEATURE_FLAG or \ + CurrentSection =3D=3D DT.MODEL_PCD_DYNAMIC_EX or \ + CurrentSection =3D=3D DT.MODEL_PCD_DYNAMIC: self.InfPcdParser(SectionLines, self.InfPcdSection, self.FullPath) @@ -550,13 +562,13 @@ class InfParser(InfSectionParser): PARSER_ERROR, ST.ERR_INF_PARSER_UNKNOWN_SECTION, File=3Dself.FullPath, Line=3DLineNo, - RaiseError =3D Logger.IS_RAISE_ERROR) + RaiseError=3DLogger.IS_RAISE_ERROR) else: Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NO_SECTION_ERROR, File=3Dself.FullPath, Line=3DLineNo, - RaiseError =3D Logger.IS_RAISE_ERROR) + RaiseError=3DLogger.IS_RAISE_ERROR) =20 return DefineSectionParsedFlag =20 @@ -564,9 +576,9 @@ class InfParser(InfSectionParser): SpecialSectionStart =3D False CheckLocation =3D False GFindSpecialCommentRe =3D \ - re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL) + re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL) GFindNewSectionRe2 =3D \ - re.compile(r"""#?(\s*)\[(.*?)\](.*)""", re.DOTALL) + re.compile(r"""#?(\s*)\[(.*?)\](.*)""", re.DOTALL) LineNum =3D 0 Element =3D [] for Line in FileLinesList: @@ -605,8 +617,8 @@ class InfParser(InfSectionParser): else: if not Line.startswith(DT.TAB_COMMENT_SPLIT): Logger.Warn("Parser", - ST.WARN_SPECIAL_SECTION_LOCATION_= WRONG, - File=3Dself.FullPath, Line=3DLine= Num) + ST.WARN_SPECIAL_SECTION_LOCATION_W= RONG, + File=3Dself.FullPath, Line=3DLineN= um) SpecialSectionStart =3D False CheckLocation =3D False Element =3D [] @@ -618,8 +630,8 @@ class InfParser(InfSectionParser): CheckLocation =3D False elif Line: Logger.Warn("Parser", - ST.WARN_SPECIAL_SECTION_LOCATION_= WRONG, - File=3Dself.FullPath, Line=3DLine= Num) + ST.WARN_SPECIAL_SECTION_LOCATION_W= RONG, + File=3Dself.FullPath, Line=3DLineN= um) CheckLocation =3D False =20 if len(self.BootModeList) >=3D 1: @@ -639,9 +651,10 @@ class InfParser(InfSectionParser): self.InfSpecialCommentSection, self.FileName, DT.TYPE_HOB_SECTION) - ## _ProcessLastSection + # _ProcessLastSection # # + def _ProcessLastSection(self, SectionLines, Line, LineNo, CurrentSecti= on): # # The last line is a section header. will discard it. @@ -658,7 +671,7 @@ class InfParser(InfSectionParser): File=3Dself.FullPath, Line=3DLineNo, ExtraData=3DLine, - RaiseError =3D Logger.IS_RAISE_ERROR + RaiseError=3DLogger.IS_RAISE_ERROR ) else: CurrentSection =3D gINF_SECTION_DEF[TemSectionName] @@ -666,9 +679,11 @@ class InfParser(InfSectionParser): =20 return SectionLines, CurrentSection =20 -## _ConvertSecNameToType +# _ConvertSecNameToType # # + + def _ConvertSecNameToType(SectionName): SectionType =3D '' if SectionName.upper() not in gINF_SECTION_DEF.keys(): @@ -677,4 +692,3 @@ def _ConvertSecNameToType(SectionName): SectionType =3D gINF_SECTION_DEF[SectionName.upper()] =20 return SectionType - diff --git a/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py b/BaseTool= s/Source/Python/UPT/Parser/InfParserMisc.py index d01ae9aa0246..58dcf9cb062b 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py +++ b/BaseTools/Source/Python/UPT/Parser/InfParserMisc.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the miscellaneous functions for INF parser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -32,31 +32,31 @@ from Logger.StringTable import ERR_MARCO_DEFINITION_MIS= S_ERROR # Sections can exist in INF file # gINF_SECTION_DEF =3D { - DT.TAB_UNKNOWN.upper() : DT.MODEL_UNKNOWN, - DT.TAB_HEADER.upper() : DT.MODEL_META_DATA_FILE_HEADER, - DT.TAB_INF_DEFINES.upper() : DT.MODEL_META_DATA_DEFINE, - DT.TAB_BUILD_OPTIONS.upper() : DT.MODEL_META_DATA_BUILD_OPTION, - DT.TAB_LIBRARY_CLASSES.upper() : DT.MODEL_EFI_LIBRARY_CLASS, - DT.TAB_PACKAGES.upper() : DT.MODEL_META_DATA_PACKAGE, - DT.TAB_INF_FIXED_PCD.upper() : DT.MODEL_PCD_FIXED_AT_BUILD, - DT.TAB_INF_PATCH_PCD.upper() : DT.MODEL_PCD_PATCHABLE_IN_MODULE, - DT.TAB_INF_FEATURE_PCD.upper() : DT.MODEL_PCD_FEATURE_FLAG, - DT.TAB_INF_PCD_EX.upper() : DT.MODEL_PCD_DYNAMIC_EX, - DT.TAB_INF_PCD.upper() : DT.MODEL_PCD_DYNAMIC, - DT.TAB_SOURCES.upper() : DT.MODEL_EFI_SOURCE_FILE, - DT.TAB_GUIDS.upper() : DT.MODEL_EFI_GUID, - DT.TAB_PROTOCOLS.upper() : DT.MODEL_EFI_PROTOCOL, - DT.TAB_PPIS.upper() : DT.MODEL_EFI_PPI, - DT.TAB_DEPEX.upper() : DT.MODEL_EFI_DEPEX, - DT.TAB_BINARIES.upper() : DT.MODEL_EFI_BINARY_FILE, - DT.TAB_USER_EXTENSIONS.upper() : DT.MODEL_META_DATA_USER_EXTENSION - # - # EDK1 section - # TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE - # - } + DT.TAB_UNKNOWN.upper(): DT.MODEL_UNKNOWN, + DT.TAB_HEADER.upper(): DT.MODEL_META_DATA_FILE_HEADER, + DT.TAB_INF_DEFINES.upper(): DT.MODEL_META_DATA_DEFINE, + DT.TAB_BUILD_OPTIONS.upper(): DT.MODEL_META_DATA_BUILD_OPTION, + DT.TAB_LIBRARY_CLASSES.upper(): DT.MODEL_EFI_LIBRARY_CLASS, + DT.TAB_PACKAGES.upper(): DT.MODEL_META_DATA_PACKAGE, + DT.TAB_INF_FIXED_PCD.upper(): DT.MODEL_PCD_FIXED_AT_BUILD, + DT.TAB_INF_PATCH_PCD.upper(): DT.MODEL_PCD_PATCHABLE_IN_MODULE, + DT.TAB_INF_FEATURE_PCD.upper(): DT.MODEL_PCD_FEATURE_FLAG, + DT.TAB_INF_PCD_EX.upper(): DT.MODEL_PCD_DYNAMIC_EX, + DT.TAB_INF_PCD.upper(): DT.MODEL_PCD_DYNAMIC, + DT.TAB_SOURCES.upper(): DT.MODEL_EFI_SOURCE_FILE, + DT.TAB_GUIDS.upper(): DT.MODEL_EFI_GUID, + DT.TAB_PROTOCOLS.upper(): DT.MODEL_EFI_PROTOCOL, + DT.TAB_PPIS.upper(): DT.MODEL_EFI_PPI, + DT.TAB_DEPEX.upper(): DT.MODEL_EFI_DEPEX, + DT.TAB_BINARIES.upper(): DT.MODEL_EFI_BINARY_FILE, + DT.TAB_USER_EXTENSIONS.upper(): DT.MODEL_META_DATA_USER_EXTENSION + # + # EDK1 section + # TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE + # +} =20 -## InfExpandMacro +# InfExpandMacro # # Expand MACRO definition with MACROs defined in [Defines] section and spe= cific section. # The MACROs defined in specific section has high priority and will be exp= anded firstly. @@ -66,6 +66,8 @@ gINF_SECTION_DEF =3D { # @param SectionMacros MACROs defined in INF specific section # @param Flag If the flag set to True, need to skip macros in a q= uoted string # + + def InfExpandMacro(Content, LineInfo, GlobalMacros=3DNone, SectionMacros= =3DNone, Flag=3DFalse): if GlobalMacros is None: GlobalMacros =3D {} @@ -85,21 +87,21 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=3DNo= ne, SectionMacros=3DNone, Fla # # First, replace MARCOs with value defined in specific section # - Content =3D ReplaceMacro (Content, - SectionMacros, - False, - (LineContent, LineNo), - FileName, - Flag) + Content =3D ReplaceMacro(Content, + SectionMacros, + False, + (LineContent, LineNo), + FileName, + Flag) # # Then replace MARCOs with value defined in [Defines] section # - Content =3D ReplaceMacro (Content, - GlobalMacros, - False, - (LineContent, LineNo), - FileName, - Flag) + Content =3D ReplaceMacro(Content, + GlobalMacros, + False, + (LineContent, LineNo), + FileName, + Flag) =20 MacroUsed =3D gMACRO_PATTERN.findall(Content) # @@ -109,18 +111,18 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=3D= None, SectionMacros=3DNone, Fla return Content else: for Macro in MacroUsed: - gQuotedMacro =3D re.compile(".*\".*\$\(%s\).*\".*"%(Macro)) + gQuotedMacro =3D re.compile(".*\".*\$\(%s\).*\".*" % (Macro)) if not gQuotedMacro.match(Content): # # Still have MACROs can't be expanded. # - ErrorInInf (ERR_MARCO_DEFINITION_MISS_ERROR, - LineInfo=3DNewLineInfo) + ErrorInInf(ERR_MARCO_DEFINITION_MISS_ERROR, + LineInfo=3DNewLineInfo) =20 return Content =20 =20 -## IsBinaryInf +# IsBinaryInf # # Judge whether the INF file is Binary INF or Common INF # @@ -146,7 +148,7 @@ def IsBinaryInf(FileLineList): return False =20 =20 -## IsLibInstanceInfo +# IsLibInstanceInfo # # Judge whether the string contain the information of ## @LIB_INSTANCES. # @@ -162,7 +164,7 @@ def IsLibInstanceInfo(String): return False =20 =20 -## IsAsBuildOptionInfo +# IsAsBuildOptionInfo # # Judge whether the string contain the information of ## @ASBUILD. # @@ -197,20 +199,20 @@ class InfParserSectionRoot(object): =20 self.FullPath =3D '' =20 - self.InfDefSection =3D None - self.InfBuildOptionSection =3D None - self.InfLibraryClassSection =3D None - self.InfPackageSection =3D None - self.InfPcdSection =3D None - self.InfSourcesSection =3D None - self.InfUserExtensionSection =3D None - self.InfProtocolSection =3D None - self.InfPpiSection =3D None - self.InfGuidSection =3D None - self.InfDepexSection =3D None - self.InfPeiDepexSection =3D None - self.InfDxeDepexSection =3D None - self.InfSmmDepexSection =3D None - self.InfBinariesSection =3D None - self.InfHeader =3D None - self.InfSpecialCommentSection =3D None + self.InfDefSection =3D None + self.InfBuildOptionSection =3D None + self.InfLibraryClassSection =3D None + self.InfPackageSection =3D None + self.InfPcdSection =3D None + self.InfSourcesSection =3D None + self.InfUserExtensionSection =3D None + self.InfProtocolSection =3D None + self.InfPpiSection =3D None + self.InfGuidSection =3D None + self.InfDepexSection =3D None + self.InfPeiDepexSection =3D None + self.InfDxeDepexSection =3D None + self.InfSmmDepexSection =3D None + self.InfBinariesSection =3D None + self.InfHeader =3D None + self.InfSpecialCommentSection =3D None diff --git a/BaseTools/Source/Python/UPT/Parser/InfPcdSectionParser.py b/Ba= seTools/Source/Python/UPT/Parser/InfPcdSectionParser.py index 6954742bf20f..1ea4770a3d99 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfPcdSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfPcdSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Pcds] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,8 +23,9 @@ from Library import GlobalData from Library.StringUtils import SplitPcdEntry from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfPcdSectionParser(InfParserSectionRoot): - ## Section PCD related parser + # Section PCD related parser # # For 5 types of PCD list below, all use this function. # 'FixedPcd', 'FeaturePcd', 'PatchPcd', 'Pcd', 'PcdEx' @@ -35,7 +36,7 @@ class InfPcdSectionParser(InfParserSectionRoot): # def InfPcdParser(self, SectionString, InfSectionObject, FileName): KeysList =3D [] - PcdList =3D [] + PcdList =3D [] CommentsList =3D [] ValueList =3D [] # @@ -47,10 +48,10 @@ class InfPcdSectionParser(InfParserSectionRoot): KeysList.append((Item[0], Item[1], Item[3])) LineIndex =3D Item[3] =20 - if (Item[0].upper() =3D=3D DT.TAB_INF_FIXED_PCD.upper() or \ - Item[0].upper() =3D=3D DT.TAB_INF_FEATURE_PCD.upper() or \ - Item[0].upper() =3D=3D DT.TAB_INF_PCD.upper()) and GlobalD= ata.gIS_BINARY_INF: - Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_ASBUILD_P= CD_SECTION_TYPE%("\"" + Item[0] + "\""), + if (Item[0].upper() =3D=3D DT.TAB_INF_FIXED_PCD.upper() or + Item[0].upper() =3D=3D DT.TAB_INF_FEATURE_PCD.upper() or + Item[0].upper() =3D=3D DT.TAB_INF_PCD.upper()) and Glo= balData.gIS_BINARY_INF: + Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_ASBUILD_P= CD_SECTION_TYPE % ("\"" + Item[0] + "\""), File=3DFileName, Line=3DLineIndex) =20 # @@ -63,7 +64,7 @@ class InfPcdSectionParser(InfParserSectionRoot): SectionMacros =3D {} for Line in SectionString: PcdLineContent =3D Line[0] - PcdLineNo =3D Line[1] + PcdLineNo =3D Line[1] if PcdLineContent.strip() =3D=3D '': CommentsList =3D [] continue @@ -77,9 +78,11 @@ class InfPcdSectionParser(InfParserSectionRoot): # if PcdLineContent.find(DT.TAB_COMMENT_SPLIT) > -1: CommentsList.append(( - PcdLineContent[PcdLineContent.find(DT.TAB_= COMMENT_SPLIT):], - PcdLineNo)) - PcdLineContent =3D PcdLineContent[:PcdLineContent.= find(DT.TAB_COMMENT_SPLIT)] + PcdLineContent[PcdLineContent.find( + DT.TAB_COMMENT_SPLIT):], + PcdLineNo)) + PcdLineContent =3D PcdLineContent[:PcdLineContent.= find( + DT.TAB_COMMENT_SPLIT)] =20 if PcdLineContent !=3D '': # @@ -109,10 +112,11 @@ class InfPcdSectionParser(InfParserSectionRoot): # ValueList =3D [InfExpandMacro(Value, (FileName, PcdLin= eContent, PcdLineNo), self.FileLocalMacros, Sect= ionMacros, True) - for Value in ValueList] + for Value in ValueList] =20 if len(ValueList) >=3D 1: - PcdList.append((ValueList, CommentsList, (PcdLineConte= nt, PcdLineNo, FileName))) + PcdList.append( + (ValueList, CommentsList, (PcdLineContent, PcdLine= No, FileName))) ValueList =3D [] CommentsList =3D [] continue @@ -122,7 +126,7 @@ class InfPcdSectionParser(InfParserSectionRoot): else: for Line in SectionString: LineContent =3D Line[0].strip() - LineNo =3D Line[1] + LineNo =3D Line[1] =20 if LineContent =3D=3D '': CommentsList =3D [] @@ -135,7 +139,7 @@ class InfPcdSectionParser(InfParserSectionRoot): # Have comments at tail. # CommentIndex =3D LineContent.find(DT.TAB_COMMENT_SPLIT) - if CommentIndex > -1: + if CommentIndex > -1: CommentsList.append(LineContent[CommentIndex+1:]) LineContent =3D LineContent[:CommentIndex] =20 @@ -163,16 +167,17 @@ class InfPcdSectionParser(InfParserSectionRoot): ExtraData=3DLineContent) ValueList[0:len(TokenList)] =3D TokenList if len(ValueList) >=3D 1: - PcdList.append((ValueList, CommentsList, (LineContent,= LineNo, FileName))) + PcdList.append( + (ValueList, CommentsList, (LineContent, LineNo, Fi= leName))) ValueList =3D [] CommentsList =3D [] continue =20 - if not InfSectionObject.SetPcds(PcdList, KeysList =3D KeysList, - PackageInfo =3D self.InfPackageSec= tion.GetPackages()): + if not InfSectionObject.SetPcds(PcdList, KeysList=3DKeysList, + PackageInfo=3Dself.InfPackageSecti= on.GetPackages()): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[PC= D]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[PCD]"), File=3DFileName, Line=3DLineIndex) - diff --git a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py b/BaseT= ools/Source/Python/UPT/Parser/InfSectionParser.py index 474d37379d2b..5f5a02dc1370 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -53,10 +53,12 @@ from Parser.InfBinarySectionParser import InfBinarySect= ionParser from Parser.InfPcdSectionParser import InfPcdSectionParser from Parser.InfDepexSectionParser import InfDepexSectionParser =20 -## GetSpecialStr2 +# GetSpecialStr2 # # GetSpecialStr2 # + + def GetSpecialStr2(ItemList, FileName, LineNo, SectionString): Str2 =3D '' # @@ -68,13 +70,14 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionS= tring): # section can has more than 2 items in section header string, # others should report error. # - if not (ItemList[0].upper() =3D=3D DT.TAB_LIBRARY_CLASSES.upper() = or \ - ItemList[0].upper() =3D=3D DT.TAB_DEPEX.upper() or \ + if not (ItemList[0].upper() =3D=3D DT.TAB_LIBRARY_CLASSES.upper() = or + ItemList[0].upper() =3D=3D DT.TAB_DEPEX.upper() or ItemList[0].upper() =3D=3D DT.TAB_USER_EXTENSIONS.upper()): if ItemList[2] !=3D '': Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_= INVALID % (SectionString), + ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_= INVALID % ( + SectionString), File=3DFileName, Line=3DLineNo, ExtraData=3DSectionString) @@ -87,7 +90,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionStr= ing): # if not ItemList[0].upper() =3D=3D DT.TAB_USER_EXTENSIONS.upper() o= r ItemList[0].upper() =3D=3D DT.TAB_DEPEX.upper(): if ItemList[3] !=3D '': - Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_S= OURCE_SECTION_SECTIONNAME_INVALID \ + Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_S= OURCE_SECTION_SECTIONNAME_INVALID % (SectionString), File=3DFileName, Line=3DLi= neNo, ExtraData=3DSectionString) =20 if not ItemList[0].upper() =3D=3D DT.TAB_USER_EXTENSIONS.upper(): @@ -96,14 +99,16 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionS= tring): Str2 =3D ItemList[2] =20 elif len(ItemList) > 4: - Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SE= CTION_SECTIONNAME_INVALID \ + Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SE= CTION_SECTIONNAME_INVALID % (SectionString), File=3DFileName, Line=3DLineNo, Ex= traData=3DSectionString) =20 return Str2 =20 -## ProcessUseExtHeader +# ProcessUseExtHeader # # + + def ProcessUseExtHeader(ItemList): NewItemList =3D [] AppendContent =3D '' @@ -138,10 +143,12 @@ def ProcessUseExtHeader(ItemList): =20 return True, NewItemList =20 -## GetArch +# GetArch # # GetArch # + + def GetArch(ItemList, ArchList, FileName, LineNo, SectionString): # # S1 is always Arch @@ -165,10 +172,12 @@ def GetArch(ItemList, ArchList, FileName, LineNo, Sec= tionString): =20 return Arch, ArchList =20 -## InfSectionParser +# InfSectionParser # # Inherit from object # + + class InfSectionParser(InfDefinSectionParser, InfBuildOptionSectionParser, InfSourceSectionParser, @@ -183,7 +192,7 @@ class InfSectionParser(InfDefinSectionParser, # MetaFiles =3D {} =20 - ## Factory method + # Factory method # # One file, one parser object. This factory method makes sure that the= re's # only one object constructed for one meta file. @@ -248,16 +257,18 @@ class InfSectionParser(InfDefinSectionParser, # # File Header content parser # - def InfHeaderParser(self, Content, InfHeaderObject2, FileName, IsBinar= yHeader =3D False): + def InfHeaderParser(self, Content, InfHeaderObject2, FileName, IsBinar= yHeader=3DFalse): if IsBinaryHeader: - (Abstract, Description, Copyright, License) =3D ParseHeaderCom= mentSection(Content, FileName, True) + (Abstract, Description, Copyright, License) =3D ParseHeaderCom= mentSection( + Content, FileName, True) if not Abstract or not Description or not Copyright or not Lic= ense: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INVALID_BINARYHEADER_FORMAT, File=3DFileName) else: - (Abstract, Description, Copyright, License) =3D ParseHeaderCom= mentSection(Content, FileName) + (Abstract, Description, Copyright, + License) =3D ParseHeaderCommentSection(Content, FileName) # # Not process file name now, for later usage. # @@ -272,10 +283,7 @@ class InfSectionParser(InfDefinSectionParser, InfHeaderObject2.SetCopyright(Copyright) InfHeaderObject2.SetLicense(License) =20 - - - - ## Section header parser + # Section header parser # # The section header is always in following format: # @@ -283,23 +291,25 @@ class InfSectionParser(InfDefinSectionParser, # # @param String A string contained the content need to be parsed. # + def SectionHeaderParser(self, SectionString, FileName, LineNo): _Scope =3D [] _SectionName =3D '' ArchList =3D set() _ValueList =3D [] _PcdNameList =3D [DT.TAB_INF_FIXED_PCD.upper(), - DT.TAB_INF_FEATURE_PCD.upper(), - DT.TAB_INF_PATCH_PCD.upper(), - DT.TAB_INF_PCD.upper(), - DT.TAB_INF_PCD_EX.upper() - ] + DT.TAB_INF_FEATURE_PCD.upper(), + DT.TAB_INF_PATCH_PCD.upper(), + DT.TAB_INF_PCD.upper(), + DT.TAB_INF_PCD_EX.upper() + ] SectionString =3D SectionString.strip() for Item in GetSplitValueList(SectionString[1:-1], DT.TAB_COMMA_SP= LIT): if Item =3D=3D '': Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= (""), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= ( + ""), File=3DFileName, Line=3DLineNo, ExtraData=3DSectionString) @@ -317,10 +327,11 @@ class InfSectionParser(InfDefinSectionParser, Line=3DLineNo, ExtraData=3DSectionString) elif _PcdNameList[1] in [_SectionName.upper(), ItemList[0].upp= er()] and \ - (_SectionName.upper()!=3D ItemList[0].upper()): + (_SectionName.upper() !=3D ItemList[0].upper()): Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= (""), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR %= ( + ""), File=3DFileName, Line=3DLineNo, ExtraData=3DSectionString) @@ -340,7 +351,8 @@ class InfSectionParser(InfDefinSectionParser, # # Get Arch # - Str1, ArchList =3D GetArch(ItemList, ArchList, FileName, LineN= o, SectionString) + Str1, ArchList =3D GetArch( + ItemList, ArchList, FileName, LineNo, SectionString) =20 # # For [Defines] section, do special check. @@ -349,7 +361,8 @@ class InfSectionParser(InfDefinSectionParser, if len(ItemList) !=3D 1: Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID %= (SectionString), + ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID %= ( + SectionString), File=3DFileName, Line=3DLineNo, ExtraData= =3DSectionString) =20 # @@ -362,7 +375,8 @@ class InfSectionParser(InfDefinSectionParser, if not RetValue[0]: Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID %= (SectionString), + ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID %= ( + SectionString), File=3DFileName, Line=3DLineNo, ExtraData= =3DSectionString) else: ItemList =3D RetValue[1] @@ -377,12 +391,14 @@ class InfSectionParser(InfDefinSectionParser, # if ItemList[0].upper() =3D=3D DT.TAB_LIBRARY_CLASSES.upper() a= nd len(ItemList) =3D=3D 3: if ItemList[2] !=3D '': - ModuleTypeList =3D GetSplitValueList(ItemList[2], DT.T= AB_VALUE_SPLIT) + ModuleTypeList =3D GetSplitValueList( + ItemList[2], DT.TAB_VALUE_SPLIT) for Item in ModuleTypeList: if Item.strip() not in DT.MODULE_LIST: Logger.Error('Parser', FORMAT_INVALID, - ST.ERR_INF_PARSER_DEFINE_MODULETY= PE_INVALID % (Item), + ST.ERR_INF_PARSER_DEFINE_MODULETY= PE_INVALID % ( + Item), File=3DFileName, Line=3DLineNo, ExtraData=3DSectionString) @@ -412,18 +428,20 @@ class InfSectionParser(InfDefinSectionParser, _ValueList.append([_SectionName, Str1, Str2, LineNo]) else: if len(ItemList) =3D=3D 4: - _ValueList.append([_SectionName, Str1, Str2, ItemL= ist[3], LineNo]) + _ValueList.append( + [_SectionName, Str1, Str2, ItemList[3], LineNo= ]) =20 self.SectionHeaderContent =3D deepcopy(_ValueList) =20 - ## GenSpecialSectionList + # GenSpecialSectionList # # @param SpecialSectionList: a list of list, of which item's format # (Comment, LineNum) # @param ContainerFile: Input value for filename of Inf file # - def InfSpecialCommentParser (self, SpecialSectionList, InfSectionObjec= t, ContainerFile, SectionType): - ReFindSpecialCommentRe =3D re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)"= "", re.DOTALL) + def InfSpecialCommentParser(self, SpecialSectionList, InfSectionObject= , ContainerFile, SectionType): + ReFindSpecialCommentRe =3D re.compile( + r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL) ReFindHobArchRe =3D re.compile(r"""[Hh][Oo][Bb]\.([^,]*)""", re.DO= TALL) if self.FileName: pass @@ -450,7 +468,8 @@ class InfSectionParser(InfDefinSectionParser, ArchList.append(Arch) CommentSoFar =3D '' for Index in range(1, len(List)): - Result =3D ParseComment(List[Index], DT.ALL_USAGE_TOKENS, = TokenDict, [], False) + Result =3D ParseComment( + List[Index], DT.ALL_USAGE_TOKENS, TokenDict, [], False) Usage =3D Result[0] Type =3D Result[1] HelpText =3D Result[3] @@ -488,6 +507,7 @@ class InfSectionParser(InfDefinSectionParser, SectionType): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % (Se= ctionType), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + SectionType), ContainerFile ) diff --git a/BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py b= /BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py index 916df7ee1a34..6d82913b58c8 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfSourceSectionParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contained the parser for [Sources] sections in INF file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -22,21 +22,22 @@ from Library.Misc import GetSplitValueList from Object.Parser.InfCommonObject import InfLineCommentObject from Parser.InfParserMisc import InfParserSectionRoot =20 + class InfSourceSectionParser(InfParserSectionRoot): - ## InfSourceParser + # InfSourceParser # # def InfSourceParser(self, SectionString, InfSectionObject, FileName): SectionMacros =3D {} - ValueList =3D [] - SourceList =3D [] - StillCommentFalg =3D False - HeaderComments =3D [] - LineComment =3D None - SectionContent =3D '' + ValueList =3D [] + SourceList =3D [] + StillCommentFalg =3D False + HeaderComments =3D [] + LineComment =3D None + SectionContent =3D '' for Line in SectionString: SrcLineContent =3D Line[0] - SrcLineNo =3D Line[1] + SrcLineNo =3D Line[1] =20 if SrcLineContent.strip() =3D=3D '': continue @@ -78,8 +79,10 @@ class InfSourceSectionParser(InfParserSectionRoot): # Find Tail comment. # if SrcLineContent.find(DT.TAB_COMMENT_SPLIT) > -1: - TailComments =3D SrcLineContent[SrcLineContent.find(DT.TAB= _COMMENT_SPLIT):] - SrcLineContent =3D SrcLineContent[:SrcLineContent.find(DT.= TAB_COMMENT_SPLIT)] + TailComments =3D SrcLineContent[SrcLineContent.find( + DT.TAB_COMMENT_SPLIT):] + SrcLineContent =3D SrcLineContent[:SrcLineContent.find( + DT.TAB_COMMENT_SPLIT)] if LineComment is None: LineComment =3D InfLineCommentObject() LineComment.SetTailComments(TailComments) @@ -101,11 +104,12 @@ class InfSourceSectionParser(InfParserSectionRoot): # Replace with Local section Macro and [Defines] section Macro. # SrcLineContent =3D InfExpandMacro(SrcLineContent, - (FileName, SrcLineContent, SrcLin= eNo), - self.FileLocalMacros, - SectionMacros) + (FileName, SrcLineContent, Src= LineNo), + self.FileLocalMacros, + SectionMacros) =20 - TokenList =3D GetSplitValueList(SrcLineContent, DT.TAB_VALUE_S= PLIT, 4) + TokenList =3D GetSplitValueList( + SrcLineContent, DT.TAB_VALUE_SPLIT, 4) ValueList[0:len(TokenList)] =3D TokenList =20 # @@ -131,9 +135,10 @@ class InfSourceSectionParser(InfParserSectionRoot): InfSectionObject.SetSupArchList(Item[1]) =20 InfSectionObject.SetAllContent(SectionContent) - if not InfSectionObject.SetSources(SourceList, Arch =3D ArchList): + if not InfSectionObject.SetSources(SourceList, Arch=3DArchList): Logger.Error('InfParser', FORMAT_INVALID, - ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[= Sources]"), + ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ( + "[Sources]"), File=3DFileName, Line=3DItem[3]) diff --git a/BaseTools/Source/Python/UPT/Parser/__init__.py b/BaseTools/Sou= rce/Python/UPT/Parser/__init__.py index 785b56df6e2a..539a99527964 100644 --- a/BaseTools/Source/Python/UPT/Parser/__init__.py +++ b/BaseTools/Source/Python/UPT/Parser/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Parser' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/Ba= seTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py index da92fe5d3eb2..393d2e86a833 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py @@ -1,4 +1,4 @@ -## @file DecPomAlignment.py +# @file DecPomAlignment.py # This file contained the adapter for convert INF parser object to POM Obj= ect # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -86,12 +86,12 @@ from Object.POM.CommonObject import MiscFileObject from Object.POM.CommonObject import FileObject =20 =20 -## DecPomAlignment +# DecPomAlignment # # Inherited from PackageObject # class DecPomAlignment(PackageObject): - def __init__(self, Filename, WorkspaceDir =3D None, CheckMulDec =3D Fa= lse): + def __init__(self, Filename, WorkspaceDir=3DNone, CheckMulDec=3DFalse): PackageObject.__init__(self) self.UserExtensions =3D '' self.WorkspaceDir =3D WorkspaceDir @@ -111,7 +111,7 @@ class DecPomAlignment(PackageObject): # self.DecToPackage() =20 - ## Load Dec file + # Load Dec file # # Load the file if it exists # @@ -131,7 +131,7 @@ class DecPomAlignment(PackageObject): =20 self.DecParser =3D Dec(Filename) =20 - ## Transfer to Package Object + # Transfer to Package Object # # Transfer all contents of a Dec file to a standard Package Object # @@ -187,7 +187,7 @@ class DecPomAlignment(PackageObject): # self.GenUserExtensions() =20 - ## Generate user extension + # Generate user extension # # def GenUserExtensions(self): @@ -221,12 +221,14 @@ class DecPomAlignment(PackageObject): # Add Private sections to UserExtension if self.DecParser.GetPrivateSections(): PrivateUserExtension =3D UserExtensionObject() - PrivateUserExtension.SetStatement(self.DecParser.GetPrivateSec= tions()) + PrivateUserExtension.SetStatement( + self.DecParser.GetPrivateSections()) PrivateUserExtension.SetIdentifier(DT.TAB_PRIVATE) PrivateUserExtension.SetUserID(DT.TAB_INTEL) - self.SetUserExtensionList(self.GetUserExtensionList() + [Priva= teUserExtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [PrivateUserExtension]) =20 - ## Generate miscellaneous files on DEC file + # Generate miscellaneous files on DEC file # # def GenMiscFiles(self, Content): @@ -241,16 +243,18 @@ class DecPomAlignment(PackageObject): if IsValidPath(FileName, self.GetRelaPath()): FileObj =3D FileObject() FileObj.SetURI(FileName) - MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[Fil= eObj]) + MiscFileObj.SetFileList( + MiscFileObj.GetFileList()+[FileObj]) else: Logger.Error("InfParser", FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID%(Line), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % ( + Line), File=3Dself.GetFileName(), ExtraData=3DLine) self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj]) =20 - ## Generate Package Header + # Generate Package Header # # Gen Package Header of Dec as =3D # @@ -268,9 +272,9 @@ class DecPomAlignment(PackageObject): # # put items into Dict except for PackageName, Guid, Version, D= EC_SPECIFICATION # - SkipItemList =3D [TAB_DEC_DEFINES_PACKAGE_NAME, \ - TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_PACKAGE_VERS= ION, \ - TAB_DEC_DEFINES_DEC_SPECIFICATION, TAB_DEC_DEFINES_PKG_UNI= _FILE] + SkipItemList =3D [TAB_DEC_DEFINES_PACKAGE_NAME, + TAB_DEC_DEFINES_PACKAGE_GUID, TAB_DEC_DEFINES_= PACKAGE_VERSION, + TAB_DEC_DEFINES_DEC_SPECIFICATION, TAB_DEC_DEF= INES_PKG_UNI_FILE] if Item.Key in SkipItemList: continue DefinesDict['%s =3D %s' % (Item.Key, Item.Value)] =3D TAB_ARCH= _COMMON @@ -284,7 +288,8 @@ class DecPomAlignment(PackageObject): if DefObj.GetPackageUniFile(): ValidateUNIFilePath(DefObj.GetPackageUniFile()) self.UniFileClassObject =3D \ - UniFileClassObject([PathClass(os.path.join(DefObj.GetPackagePa= th(), DefObj.GetPackageUniFile()))]) + UniFileClassObject( + [PathClass(os.path.join(DefObj.GetPackagePath(), DefOb= j.GetPackageUniFile()))]) else: self.UniFileClassObject =3D None =20 @@ -322,9 +327,9 @@ class DecPomAlignment(PackageObject): if self.DecParser.BinaryHeadComment: Abstract, Description, Copyright, License =3D \ ParseHeaderCommentSection(self.DecParser.BinaryHeadComment, - ContainerFile, True) + ContainerFile, True) =20 - if not Abstract or not Description or not Copyright or not Li= cense: + if not Abstract or not Description or not Copyright or not Lic= ense: Logger.Error('MkPkg', FORMAT_INVALID, ST.ERR_INVALID_BINARYHEADER_FORMAT, @@ -338,7 +343,7 @@ class DecPomAlignment(PackageObject): BinaryAbstractList =3D [] BinaryDescriptionList =3D [] =20 - #Get Binary header from UNI file + # Get Binary header from UNI file # Initialize the UniStrDict dictionary, top keys are language codes UniStrDict =3D {} if self.UniFileClassObject: @@ -348,19 +353,20 @@ class DecPomAlignment(PackageObject): Lang =3D GetLanguageCode1766(Lang) if StringDefClassObject.StringName =3D=3D TAB_DEC_BINA= RY_ABSTRACT: if (Lang, ConvertSpecialUnicodes(StringDefClassObj= ect.StringValue)) \ - not in self.GetBinaryHeaderAbstract(): - BinaryAbstractList.append((Lang, ConvertSpecia= lUnicodes(StringDefClassObject.StringValue))) + not in self.GetBinaryHeaderAbstract(): + BinaryAbstractList.append( + (Lang, ConvertSpecialUnicodes(StringDefCla= ssObject.StringValue))) if StringDefClassObject.StringName =3D=3D TAB_DEC_BINA= RY_DESCRIPTION: if (Lang, ConvertSpecialUnicodes(StringDefClassObj= ect.StringValue)) \ - not in self.GetBinaryHeaderDescription(): + not in self.GetBinaryHeaderDescription(): BinaryDescriptionList.append((Lang, ConvertSpecialUn= icodes(StringDefClassObject.StringValue))) - #Combine Binary header from DEC file and UNI file + # Combine Binary header from DEC file and UNI file BinaryAbstractList =3D self.GetBinaryHeaderAbstract() + BinaryAbst= ractList BinaryDescriptionList =3D self.GetBinaryHeaderDescription() + Bina= ryDescriptionList BinaryCopyrightList =3D self.GetBinaryHeaderCopyright() BinaryLicenseList =3D self.GetBinaryHeaderLicense() - #Generate the UserExtensionObject for TianoCore."BinaryHeader" + # Generate the UserExtensionObject for TianoCore."BinaryHeader" if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightL= ist or BinaryLicenseList: BinaryUserExtension =3D UserExtensionObject() BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList) @@ -369,15 +375,16 @@ class DecPomAlignment(PackageObject): BinaryUserExtension.SetBinaryLicense(BinaryLicenseList) BinaryUserExtension.SetIdentifier(TAB_BINARY_HEADER_IDENTIFIER) BinaryUserExtension.SetUserID(TAB_BINARY_HEADER_USERID) - self.SetUserExtensionList(self.GetUserExtensionList() + [Binar= yUserExtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [BinaryUserExtension]) =20 - - ## GenIncludes + # GenIncludes # # Gen Includes of Dec # # @param ContainerFile: The Dec file full path # + def GenIncludes(self, ContainerFile): if ContainerFile: pass @@ -393,7 +400,8 @@ class DecPomAlignment(PackageObject): if Item.GetArchList() =3D=3D [TAB_ARCH_COMMON] or Includes= Dict[IncludePath] =3D=3D [TAB_ARCH_COMMON]: IncludesDict[IncludePath] =3D [TAB_ARCH_COMMON] else: - IncludesDict[IncludePath] =3D IncludesDict[IncludePath= ] + Item.GetArchList() + IncludesDict[IncludePath] =3D IncludesDict[IncludePath= ] + \ + Item.GetArchList() else: IncludesDict[IncludePath] =3D Item.GetArchList() =20 @@ -421,7 +429,7 @@ class DecPomAlignment(PackageObject): # to remove the extra path separator '\' # as this list is used to search the supported Arch info # - for IndexN in range (0, len(IncludePathList)): + for IndexN in range(0, len(IncludePathList)): IncludePathList[IndexN] =3D os.path.normpath(IncludePathList[I= ndexN]) IncludePathList.sort() IncludePathList.reverse() @@ -434,16 +442,19 @@ class DecPomAlignment(PackageObject): =20 IncludeFileList =3D [] for Path in NonOverLapList: - FileList =3D GetFiles(os.path.join(PackagePath, Path), ['CVS',= '.svn'], False) - IncludeFileList +=3D [os.path.normpath(os.path.join(Path, File= )) for File in FileList] + FileList =3D GetFiles(os.path.join(PackagePath, Path), [ + 'CVS', '.svn'], False) + IncludeFileList +=3D [os.path.normpath(os.path.join(Path, File= )) + for File in FileList] for Includefile in IncludeFileList: ExtName =3D os.path.splitext(Includefile)[1] if ExtName.upper() =3D=3D '.DEC' and self.CheckMulDec: Logger.Error('MkPkg', UPT_MUL_DEC_ERROR, - ST.ERR_MUL_DEC_ERROR%(os.path.dirname(Contain= erFile), - os.path.basename(Contai= nerFile), - Includefile)) + ST.ERR_MUL_DEC_ERROR % (os.path.dirname(Conta= inerFile), + os.path.basename( + ContainerFile), + Includefile)) =20 FileCombinePath =3D os.path.dirname(Includefile) Include =3D IncludeObject() @@ -471,9 +482,10 @@ class DecPomAlignment(PackageObject): Include.SetFilePath(IncludePath) Include.SetSupArchList(Item.GetArchList()) PackagePathList.append(Include) - self.SetPackageIncludeFileList(PackagePathList + PackageIncludeFil= eList) + self.SetPackageIncludeFileList( + PackagePathList + PackageIncludeFileList) =20 - ## GenPpis + # GenPpis # # Gen Ppis of Dec # =3D @@ -489,6 +501,7 @@ class DecPomAlignment(PackageObject): Factory =3D None if Type =3D=3D TAB_GUIDS: Obj =3D self.DecParser.GetGuidSectionObject() + def CreateGuidObject(): Object =3D GuidObject() Object.SetGuidTypeList([]) @@ -522,7 +535,7 @@ class DecPomAlignment(PackageObject): for Item in Obj.GetGuidStyleAllItems(): Name =3D Item.GuidCName Value =3D Item.GuidString - HelpTxt =3D ParseGenericComment(Item.GetHeadComment() + \ + HelpTxt =3D ParseGenericComment(Item.GetHeadComment() + Item.GetTailComment()) =20 ListObject =3D Factory() @@ -537,7 +550,7 @@ class DecPomAlignment(PackageObject): DeclarationsList.append(ListObject) =20 # - #GuidTypeList is abstracted from help + # GuidTypeList is abstracted from help # if Type =3D=3D TAB_GUIDS: self.SetGuidList(self.GetGuidList() + DeclarationsList) @@ -546,7 +559,7 @@ class DecPomAlignment(PackageObject): elif Type =3D=3D TAB_PPIS: self.SetPpiList(self.GetPpiList() + DeclarationsList) =20 - ## GenLibraryClasses + # GenLibraryClasses # # Gen LibraryClasses of Dec # =3D @@ -565,7 +578,7 @@ class DecPomAlignment(PackageObject): LibraryClass.SetLibraryClass(Item.Libraryclass) LibraryClass.SetSupArchList(Item.GetArchList()) LibraryClass.SetIncludeHeader(Item.File) - HelpTxt =3D ParseGenericComment(Item.GetHeadComment() + \ + HelpTxt =3D ParseGenericComment(Item.GetHeadComment() + Item.GetTailComment(), None, '@l= ibraryclass') if HelpTxt: if self.UniFileClassObject: @@ -573,10 +586,10 @@ class DecPomAlignment(PackageObject): LibraryClass.SetHelpTextList([HelpTxt]) LibraryClassDeclarations.append(LibraryClass) =20 - self.SetLibraryClassList(self.GetLibraryClassList() + \ + self.SetLibraryClassList(self.GetLibraryClassList() + LibraryClassDeclarations) =20 - ## GenPcds + # GenPcds # # Gen Pcds of Dec # .||| @@ -617,15 +630,15 @@ class DecPomAlignment(PackageObject): StrList =3D StringDefClassObject.StringName.split('_') # StringName format is STR___PROMPT if len(StrList) =3D=3D 4 and StrList[0] =3D=3D TAB_STR= _TOKENCNAME and StrList[3] =3D=3D TAB_STR_TOKENPROMPT: - PromptStrList.append((GetLanguageCode1766(Lang), S= tringDefClassObject.StringName, \ + PromptStrList.append((GetLanguageCode1766(Lang), S= tringDefClassObject.StringName, StringDefClassObject.StringV= alue)) # StringName format is STR___HELP if len(StrList) =3D=3D 4 and StrList[0] =3D=3D TAB_STR= _TOKENCNAME and StrList[3] =3D=3D TAB_STR_TOKENHELP: - HelpStrList.append((GetLanguageCode1766(Lang), Str= ingDefClassObject.StringName, \ + HelpStrList.append((GetLanguageCode1766(Lang), Str= ingDefClassObject.StringName, StringDefClassObject.StringVal= ue)) # StringName format is STR__ERR_## if len(StrList) =3D=3D 4 and StrList[0] =3D=3D TAB_STR= _TOKENCNAME and StrList[2] =3D=3D TAB_STR_TOKENERR: - PcdErrStrList.append((GetLanguageCode1766(Lang), S= tringDefClassObject.StringName, \ + PcdErrStrList.append((GetLanguageCode1766(Lang), S= tringDefClassObject.StringName, StringDefClassObject.StringV= alue)) # # For each PCD type @@ -638,13 +651,13 @@ class DecPomAlignment(PackageObject): # for Item in PcdObj.GetPcdsByType(PcdType.upper()): PcdDeclaration =3D GenPcdDeclaration( - ContainerFile, - (Item.TokenSpaceGuidCName, Item.TokenCName, - Item.DefaultValue, Item.DatumType, Item.TokenValue, - Type, Item.GetHeadComment(), Item.GetTailComment()= , ''), - Language, - self.DecParser.GetDefineSectionMacro() - ) + ContainerFile, + (Item.TokenSpaceGuidCName, Item.TokenCName, + Item.DefaultValue, Item.DatumType, Item.TokenValue, + Type, Item.GetHeadComment(), Item.GetTailComment(), '= '), + Language, + self.DecParser.GetDefineSectionMacro() + ) PcdDeclaration.SetSupArchList(Item.GetArchListOfType(PcdTy= pe)) =20 # @@ -652,38 +665,41 @@ class DecPomAlignment(PackageObject): # for PcdErr in PcdDeclaration.GetPcdErrorsList(): if (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.Ge= tErrorNumber()) \ - in self.DecParser.PcdErrorCommentDict: - Key =3D (PcdDeclaration.GetTokenSpaceGuidCName(), = PcdErr.GetErrorNumber()) - PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageL= ist() + \ - [(Language, self.Dec= Parser.PcdErrorCommentDict[Key])]) + in self.DecParser.PcdErrorCommentDict: + Key =3D (PcdDeclaration.GetTokenSpaceGuidCName(), + PcdErr.GetErrorNumber()) + PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageL= ist() + + [(Language, self.DecPar= ser.PcdErrorCommentDict[Key])]) =20 for Index in range(0, len(PromptStrList)): StrNameList =3D PromptStrList[Index][1].split('_') if StrNameList[1].lower() =3D=3D Item.TokenSpaceGuidCN= ame.lower() and \ - StrNameList[2].lower() =3D=3D Item.TokenCName.lower(): + StrNameList[2].lower() =3D=3D Item.TokenCName.= lower(): TxtObj =3D TextObject() TxtObj.SetLang(PromptStrList[Index][0]) TxtObj.SetString(PromptStrList[Index][2]) for Prompt in PcdDeclaration.GetPromptList(): if Prompt.GetLang() =3D=3D TxtObj.GetLang() an= d \ - Prompt.GetString() =3D=3D TxtObj.GetString= (): + Prompt.GetString() =3D=3D TxtObj.GetSt= ring(): break else: - PcdDeclaration.SetPromptList(PcdDeclaration.Ge= tPromptList() + [TxtObj]) + PcdDeclaration.SetPromptList( + PcdDeclaration.GetPromptList() + [TxtObj]) =20 for Index in range(0, len(HelpStrList)): StrNameList =3D HelpStrList[Index][1].split('_') if StrNameList[1].lower() =3D=3D Item.TokenSpaceGuidCN= ame.lower() and \ - StrNameList[2].lower() =3D=3D Item.TokenCName.lower(): + StrNameList[2].lower() =3D=3D Item.TokenCName.= lower(): TxtObj =3D TextObject() TxtObj.SetLang(HelpStrList[Index][0]) TxtObj.SetString(HelpStrList[Index][2]) for HelpStrObj in PcdDeclaration.GetHelpTextList(): if HelpStrObj.GetLang() =3D=3D TxtObj.GetLang(= ) and \ - HelpStrObj.GetString() =3D=3D TxtObj.GetSt= ring(): + HelpStrObj.GetString() =3D=3D TxtObj.G= etString(): break else: - PcdDeclaration.SetHelpTextList(PcdDeclaration.= GetHelpTextList() + [TxtObj]) + PcdDeclaration.SetHelpTextList( + PcdDeclaration.GetHelpTextList() + [TxtObj= ]) =20 # # Get PCD error message from UNI file @@ -691,12 +707,12 @@ class DecPomAlignment(PackageObject): for Index in range(0, len(PcdErrStrList)): StrNameList =3D PcdErrStrList[Index][1].split('_') if StrNameList[1].lower() =3D=3D Item.TokenSpaceGuidCN= ame.lower() and \ - StrNameList[2].lower() =3D=3D TAB_STR_TOKENERR.low= er(): + StrNameList[2].lower() =3D=3D TAB_STR_TOKENERR= .lower(): for PcdErr in PcdDeclaration.GetPcdErrorsList(): if PcdErr.GetErrorNumber().lower() =3D=3D (TAB= _HEX_START + StrNameList[3]).lower() and \ - (PcdErrStrList[Index][0], PcdErrStrList[In= dex][2]) not in PcdErr.GetErrorMessageList(): - PcdErr.SetErrorMessageList(PcdErr.GetError= MessageList() + \ - [(PcdErrStrLis= t[Index][0], PcdErrStrList[Index][2])]) + (PcdErrStrList[Index][0], PcdErrStrLis= t[Index][2]) not in PcdErr.GetErrorMessageList(): + PcdErr.SetErrorMessageList(PcdErr.GetError= MessageList() + + [(PcdErrStrList= [Index][0], PcdErrStrList[Index][2])]) =20 # # Check to prevent missing error message if a Pcd has the = error code. @@ -790,9 +806,10 @@ class DecPomAlignment(PackageObject): for MatchedItem in MatchedList: if MatchedItem not in self.PcdDefaultValueDict: Logger.Error("Dec File Parser", FORMAT_INVALID, Messag= e=3DST.ERR_DECPARSE_PCD_NODEFINED % MatchedItem, - File=3Dself.FullPath) + File=3Dself.FullPath) =20 - ReplaceValue =3D ReplaceValue.replace(MatchedItem, self.Pc= dDefaultValueDict[MatchedItem]) + ReplaceValue =3D ReplaceValue.replace( + MatchedItem, self.PcdDefaultValueDict[MatchedItem]) =20 return ReplaceValue =20 @@ -802,11 +819,12 @@ class DecPomAlignment(PackageObject): def CheckPcdValue(self): for Pcd in self.GetPcdList(): self.PcdDefaultValueDict[TAB_SPLIT.join((Pcd.GetTokenSpaceGuid= CName(), Pcd.GetCName())).strip()] =3D \ - Pcd.GetDefaultValue() + Pcd.GetDefaultValue() =20 for Pcd in self.GetPcdList(): ValidationExpressions =3D [] - PcdGuidName =3D TAB_SPLIT.join((Pcd.GetTokenSpaceGuidCName(), = Pcd.GetCName())) + PcdGuidName =3D TAB_SPLIT.join( + (Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName())) Valids =3D Pcd.GetPcdErrorsList() for Valid in Valids: Expression =3D Valid.GetExpression() @@ -819,28 +837,35 @@ class DecPomAlignment(PackageObject): if QuotedMatchedObj: MatchedStr =3D QuotedMatchedObj.group().strip() if MatchedStr.startswith('L'): - Expression =3D Expression.replace(MatchedStr, = MatchedStr[1:].strip()) + Expression =3D Expression.replace( + MatchedStr, MatchedStr[1:].strip()) =20 Expression =3D self.ReplaceForEval(Expression, IsExpr= =3DTrue) Expression =3D Expression.replace(PcdGuidName, 'x') - Message =3D self.GetEnErrorMessage(Valid.GetErrorMessa= geList()) + Message =3D self.GetEnErrorMessage( + Valid.GetErrorMessageList()) ValidationExpressions.append((Expression, Message)) =20 ValidList =3D Valid.GetValidValue() if ValidList: - ValidValue =3D 'x in %s' % [eval(v) for v in ValidList= .split(' ') if v] - Message =3D self.GetEnErrorMessage(Valid.GetErrorMessa= geList()) + ValidValue =3D 'x in %s' % [ + eval(v) for v in ValidList.split(' ') if v] + Message =3D self.GetEnErrorMessage( + Valid.GetErrorMessageList()) ValidationExpressions.append((ValidValue, Message)) =20 ValidValueRange =3D Valid.GetValidValueRange() if ValidValueRange: - ValidValueRange =3D self.ReplaceForEval(ValidValueRang= e, IsRange=3DTrue) + ValidValueRange =3D self.ReplaceForEval( + ValidValueRange, IsRange=3DTrue) if ValidValueRange.find('-') >=3D 0: - ValidValueRange =3D ValidValueRange.replace('-', '= <=3D x <=3D') + ValidValueRange =3D ValidValueRange.replace( + '-', '<=3D x <=3D') elif not ValidValueRange.startswith('x ') and not Vali= dValueRange.startswith('not ') \ - and not ValidValueRange.startswith('not(') and not= ValidValueRange.startswith('('): + and not ValidValueRange.startswith('not(') and= not ValidValueRange.startswith('('): ValidValueRange =3D 'x %s' % ValidValueRange - Message =3D self.GetEnErrorMessage(Valid.GetErrorMessa= geList()) + Message =3D self.GetEnErrorMessage( + Valid.GetErrorMessageList()) ValidationExpressions.append((ValidValueRange, Message= )) =20 DefaultValue =3D self.PcdDefaultValueDict[PcdGuidName.strip()] @@ -852,31 +877,32 @@ class DecPomAlignment(PackageObject): if QuotedMatchedObj: MatchedStr =3D QuotedMatchedObj.group().strip() if MatchedStr.startswith('L'): - DefaultValue =3D DefaultValue.replace(MatchedStr, Matc= hedStr[1:].strip()) + DefaultValue =3D DefaultValue.replace( + MatchedStr, MatchedStr[1:].strip()) =20 try: DefaultValue =3D eval(DefaultValue.replace('TRUE', 'True')= .replace('true', 'True') - .replace('FALSE', 'False').replace= ('false', 'False')) + .replace('FALSE', 'False').replace('fa= lse', 'False')) except BaseException: pass =20 for (Expression, Msg) in ValidationExpressions: try: - if not eval(Expression, {'x':DefaultValue}): - Logger.Error("Dec File Parser", FORMAT_INVALID, Ex= traData=3D'%s, value =3D %s' %\ + if not eval(Expression, {'x': DefaultValue}): + Logger.Error("Dec File Parser", FORMAT_INVALID, Ex= traData=3D'%s, value =3D %s' % (PcdGuidName, DefaultValue), Message= =3DMsg, File=3Dself.FullPath) except TypeError: - Logger.Error("Dec File Parser", FORMAT_INVALID, ExtraD= ata=3DPcdGuidName, \ - Message=3DMsg, File=3Dself.FullPath) + Logger.Error("Dec File Parser", FORMAT_INVALID, ExtraD= ata=3DPcdGuidName, + Message=3DMsg, File=3Dself.FullPath) =20 - ## GenModuleFileList + # GenModuleFileList # def GenModuleFileList(self, ContainerFile): ModuleFileList =3D [] ContainerFileName =3D os.path.basename(ContainerFile) ContainerFilePath =3D os.path.dirname(ContainerFile) for Item in GetFiles(ContainerFilePath, - ['CVS', '.svn'] + self.GetIncludePathList(), False= ): + ['CVS', '.svn'] + self.GetIncludePathList(), = False): ExtName =3D os.path.splitext(Item)[1] if ExtName.lower() =3D=3D '.inf': ModuleFileList.append(Item) @@ -885,13 +911,13 @@ class DecPomAlignment(PackageObject): continue Logger.Error('MkPkg', UPT_MUL_DEC_ERROR, - ST.ERR_MUL_DEC_ERROR%(ContainerFilePath, - ContainerFileName, - Item)) + ST.ERR_MUL_DEC_ERROR % (ContainerFilePath, + ContainerFileName, + Item)) =20 self.SetModuleFileList(ModuleFileList) =20 - ## Show detailed information of Package + # Show detailed information of Package # # Print all members and their values of Package class # @@ -901,12 +927,12 @@ class DecPomAlignment(PackageObject): print('\nVersion =3D', self.GetVersion()) print('\nGuid =3D', self.GetGuid()) =20 - print('\nStandardIncludes =3D %d ' \ - % len(self.GetStandardIncludeFileList()), end=3D' ') + print('\nStandardIncludes =3D %d ' + % len(self.GetStandardIncludeFileList()), end=3D' ') for Item in self.GetStandardIncludeFileList(): print(Item.GetFilePath(), ' ', Item.GetSupArchList()) - print('\nPackageIncludes =3D %d \n' \ - % len(self.GetPackageIncludeFileList()), end=3D' ') + print('\nPackageIncludes =3D %d \n' + % len(self.GetPackageIncludeFileList()), end=3D' ') for Item in self.GetPackageIncludeFileList(): print(Item.GetFilePath(), ' ', Item.GetSupArchList()) =20 @@ -921,16 +947,16 @@ class DecPomAlignment(PackageObject): print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()) print('\nLibraryClasses =3D', self.GetLibraryClassList()) for Item in self.GetLibraryClassList(): - print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \ - Item.GetSupArchList()) + print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), + Item.GetSupArchList()) print('\nPcds =3D', self.GetPcdList()) for Item in self.GetPcdList(): - print('CName=3D', Item.GetCName(), 'TokenSpaceGuidCName=3D', \ - Item.GetTokenSpaceGuidCName(), \ - 'DefaultValue=3D', Item.GetDefaultValue(), \ - 'ValidUsage=3D', Item.GetValidUsage(), \ - 'SupArchList', Item.GetSupArchList(), \ - 'Token=3D', Item.GetToken(), 'DatumType=3D', Item.GetDatum= Type()) + print('CName=3D', Item.GetCName(), 'TokenSpaceGuidCName=3D', + Item.GetTokenSpaceGuidCName(), + 'DefaultValue=3D', Item.GetDefaultValue(), + 'ValidUsage=3D', Item.GetValidUsage(), + 'SupArchList', Item.GetSupArchList(), + 'Token=3D', Item.GetToken(), 'DatumType=3D', Item.GetDat= umType()) =20 for Item in self.GetMiscFileList(): print(Item.GetName()) @@ -938,7 +964,7 @@ class DecPomAlignment(PackageObject): print(FileObjectItem.GetURI()) print('****************\n') =20 -## GenPcdDeclaration +# GenPcdDeclaration # # @param ContainerFile: File name of the DEC file # @param PcdInfo: Pcd information, of format (TokenGuidCName, @@ -946,6 +972,8 @@ class DecPomAlignment(PackageObject): # GenericComment, TailComment, Arch) # @param Language: The language of HelpText, Prompt # + + def GenPcdDeclaration(ContainerFile, PcdInfo, Language, MacroReplaceDict): HelpStr =3D '' PromptStr =3D '' @@ -979,7 +1007,7 @@ def GenPcdDeclaration(ContainerFile, PcdInfo, Language= , MacroReplaceDict): =20 if TailComment: SupModuleList, TailHelpStr =3D ParseDecPcdTailComment(TailComment, - ContainerFile) + ContainerFile) if SupModuleList: Pcd.SetSupModuleList(SupModuleList) =20 diff --git a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py b/Ba= seTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py index 9c406e5f49e3..e57c1749f2a1 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py @@ -1,4 +1,4 @@ -## @file InfPomAlignment.py +# @file InfPomAlignment.py # This file contained the adapter for convert INF parser object to POM Obj= ect # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -47,12 +47,14 @@ from Parser import InfParser from PomAdapter.DecPomAlignment import DecPomAlignment from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -## InfPomAlignment +# InfPomAlignment # # Inherit from ModuleObject # + + class InfPomAlignment(ModuleObject): - ## Construct of InfPomAlignment + # Construct of InfPomAlignment # Skip means that UPT don't care the syntax of INF, this may be the not # distributed INF files during creation or the INF files checked for # dependency rule during remove. @@ -110,7 +112,7 @@ class InfPomAlignment(ModuleObject): self._GenGuidProtocolPpis(DT.TAB_PPIS) self._GenDepexes() =20 - ## Convert [Defines] section content to InfDefObject + # Convert [Defines] section content to InfDefObject # # Convert [Defines] section content to InfDefObject # @@ -152,7 +154,8 @@ class InfPomAlignment(ModuleObject): ModulePath =3D os.path.split(CombinePath)[0] ModuleRelativePath =3D ModulePath if self.GetPackagePath() !=3D '': - ModuleRelativePath =3D GetRelativePath(ModulePath, self.GetPac= kagePath()) + ModuleRelativePath =3D GetRelativePath( + ModulePath, self.GetPackagePath()) self.SetModulePath(ModuleRelativePath) # # For Define Seciton Items. @@ -173,7 +176,8 @@ class InfPomAlignment(ModuleObject): SpecList =3D DefineObj.GetSpecification() NewSpecList =3D [] for SpecItem in SpecList: - NewSpecList.append((SpecItem[0], ConvertVersionToDecimal(SpecI= tem[1]))) + NewSpecList.append( + (SpecItem[0], ConvertVersionToDecimal(SpecItem[1]))) self.SetSpecList(NewSpecList) =20 # @@ -205,7 +209,8 @@ class InfPomAlignment(ModuleObject): else: self.SetBaseName(DefineObj.GetBaseName().GetValue()) if DefineObj.GetModuleUniFileName(): - self.UniFileClassObject =3D UniFileClassObject([PathClass(Defi= neObj.GetModuleUniFileName())]) + self.UniFileClassObject =3D UniFileClassObject( + [PathClass(DefineObj.GetModuleUniFileName())]) else: self.UniFileClassObject =3D None if DefineObj.GetInfVersion() is None: @@ -248,7 +253,8 @@ class InfPomAlignment(ModuleObject): if DefineObj.GetShadow(): ModuleTypeValue =3D DefineObj.GetModuleType().GetValue() if not (ModuleTypeValue =3D=3D 'SEC' or ModuleTypeValue =3D=3D= 'PEI_CORE' or ModuleTypeValue =3D=3D 'PEIM'): - Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSE= R_DEFINE_SHADOW_INVALID, File=3Dself.FullPath) + Logger.Error("InfParser", FORMAT_INVALID, + ST.ERR_INF_PARSER_DEFINE_SHADOW_INVALID, File= =3Dself.FullPath) =20 if DefineObj.GetPcdIsDriver() is not None: self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue()) @@ -284,7 +290,8 @@ class InfPomAlignment(ModuleObject): UserExtension.SetDefinesDict(DefinesDictNew) UserExtension.SetIdentifier('DefineModifiers') UserExtension.SetUserID('EDK2') - self.SetUserExtensionList(self.GetUserExtensionList() + [UserE= xtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [UserExtension]) # # Get all meta-file header information # the record is list of items formatted: @@ -311,15 +318,18 @@ class InfPomAlignment(ModuleObject): # InfBinaryHeaderObj =3D self.Parser.InfBinaryHeader if InfBinaryHeaderObj.GetAbstract(): - self.SetBinaryHeaderAbstract((Lang, InfBinaryHeaderObj.GetAbst= ract())) + self.SetBinaryHeaderAbstract( + (Lang, InfBinaryHeaderObj.GetAbstract())) if InfBinaryHeaderObj.GetDescription(): - self.SetBinaryHeaderDescription((Lang, InfBinaryHeaderObj.GetD= escription())) + self.SetBinaryHeaderDescription( + (Lang, InfBinaryHeaderObj.GetDescription())) if InfBinaryHeaderObj.GetCopyright(): - self.SetBinaryHeaderCopyright(('', InfBinaryHeaderObj.GetCopyr= ight())) + self.SetBinaryHeaderCopyright( + ('', InfBinaryHeaderObj.GetCopyright())) if InfBinaryHeaderObj.GetLicense(): self.SetBinaryHeaderLicense(('', InfBinaryHeaderObj.GetLicense= ())) =20 - ## GenModuleHeaderLibClass + # GenModuleHeaderLibClass # # def _GenModuleHeaderLibClass(self, DefineObj, ArchList): @@ -334,9 +344,10 @@ class InfPomAlignment(ModuleObject): Lib.SetSupArchList(ArchList) self.SetLibraryClassList(self.GetLibraryClassList() + [Lib]) self.SetIsLibrary(True) - self.SetIsLibraryModList(self.GetIsLibraryModList() + SupModul= eList) + self.SetIsLibraryModList( + self.GetIsLibraryModList() + SupModuleList) =20 - ## GenModuleHeaderExterns + # GenModuleHeaderExterns # # def _GenModuleHeaderExterns(self, DefineObj): @@ -382,7 +393,7 @@ class InfPomAlignment(ModuleObject): Image.SetDestructor(DestructorItem.GetCName()) self.SetExternList(self.GetExternList() + [Image]) =20 - ## GenModuleHeaderExterns + # GenModuleHeaderExterns # BootMode/HOB/Event # def _GenSpecialComments(self): @@ -421,7 +432,8 @@ class InfPomAlignment(ModuleObject): BootModeList =3D [] for Item in SpecialCommentsList[Key]: BootMode =3D BootModeObject() - BootMode.SetSupportedBootModes(Item.GetSupportedBootMo= des()) + BootMode.SetSupportedBootModes( + Item.GetSupportedBootModes()) BootMode.SetUsage(Item.GetUsage()) if Item.GetHelpString(): HelpTextObj =3D CommonObject.TextObject() @@ -432,7 +444,7 @@ class InfPomAlignment(ModuleObject): BootModeList.append(BootMode) self.SetBootModeList(BootModeList) =20 - ## GenBuildOptions + # GenBuildOptions # # Gen BuildOptions of Inf # [:]=3DFlag @@ -460,14 +472,15 @@ class InfPomAlignment(ModuleObject): UserExtension.SetBuildOptionDict(BuildOptionDict) UserExtension.SetIdentifier('BuildOptionModifiers') UserExtension.SetUserID('EDK2') - self.SetUserExtensionList(self.GetUserExtensionList() + [UserE= xtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [UserExtension]) else: # # Not process this information, will be processed in GenBinari= es() # pass =20 - ## GenLibraryClasses + # GenLibraryClasses # # Get LibraryClass of Inf # | @@ -487,7 +500,8 @@ class InfPomAlignment(ModuleObject): LibraryClass.SetLibraryClass(Item.GetLibName()) LibraryClass.SetRecommendedInstance(None) LibraryClass.SetFeatureFlag(Item.GetFeatureFlagExp()) - LibraryClass.SetSupArchList(ConvertArchList(Item.GetSu= pArchList())) + LibraryClass.SetSupArchList( + ConvertArchList(Item.GetSupArchList())) LibraryClass.SetSupModuleList(Item.GetSupModuleList()) HelpStringObj =3D Item.GetHelpString() if HelpStringObj is not None: @@ -498,9 +512,10 @@ class InfPomAlignment(ModuleObject): HelpTextHeaderObj.SetLang(DT.TAB_LANGUAGE_EN_X) HelpTextHeaderObj.SetString(CommentString) LibraryClass.SetHelpTextList([HelpTextHeaderObj]) - self.SetLibraryClassList(self.GetLibraryClassList() + = [LibraryClass]) + self.SetLibraryClassList( + self.GetLibraryClassList() + [LibraryClass]) =20 - ## GenPackages + # GenPackages # # Gen Packages of Inf # @@ -521,11 +536,15 @@ class InfPomAlignment(ModuleObject): # Need package information for dependency check usage # PackageDependency =3D PackageDependencyObject() - PackageDependency.SetPackageFilePath(NormPath(PackageItemObj.G= etPackageName())) - PackageDependency.SetSupArchList(ConvertArchList(PackageItemOb= j.GetSupArchList())) - PackageDependency.SetFeatureFlag(PackageItemObj.GetFeatureFlag= Exp()) + PackageDependency.SetPackageFilePath( + NormPath(PackageItemObj.GetPackageName())) + PackageDependency.SetSupArchList( + ConvertArchList(PackageItemObj.GetSupArchList())) + PackageDependency.SetFeatureFlag( + PackageItemObj.GetFeatureFlagExp()) =20 - PkgInfo =3D GetPkgInfoFromDec(mws.join(self.WorkSpace, NormPat= h(PackageItemObj.GetPackageName()))) + PkgInfo =3D GetPkgInfoFromDec( + mws.join(self.WorkSpace, NormPath(PackageItemObj.GetPackag= eName()))) if PkgInfo[1] and PkgInfo[2]: PackageDependency.SetGuid(PkgInfo[1]) PackageDependency.SetVersion(PkgInfo[2]) @@ -539,7 +558,7 @@ class InfPomAlignment(ModuleObject): PackageDependencyList.append(PackageDependency) self.SetPackageDependencyList(PackageDependencyList) =20 - ## GenPcds + # GenPcds # # Gen Pcds of Inf # .[| [|]] @@ -565,22 +584,25 @@ class InfPomAlignment(ModuleObject): for CommentItem in CommentList: Pcd =3D CommonObject.PcdObject() Pcd.SetCName(PcdItemObj.GetCName()) - Pcd.SetTokenSpaceGuidCName(PcdItemObj.GetToken= SpaceGuidCName()) + Pcd.SetTokenSpaceGuidCName( + PcdItemObj.GetTokenSpaceGuidCName()) Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue= ()) Pcd.SetItemType(PcdType) Pcd.SetValidUsage(CommentItem.GetUsageItem()) Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagEx= p()) - Pcd.SetSupArchList(ConvertArchList(PcdItemObj.= GetSupportArchList())) + Pcd.SetSupArchList(ConvertArchList( + PcdItemObj.GetSupportArchList())) HelpTextObj =3D CommonObject.TextObject() if self.UniFileClassObject: HelpTextObj.SetLang(DT.TAB_LANGUAGE_EN_X) - HelpTextObj.SetString(CommentItem.GetHelpStrin= gItem()) + HelpTextObj.SetString( + CommentItem.GetHelpStringItem()) Pcd.SetHelpTextList([HelpTextObj]) PcdList =3D self.GetPcdList() PcdList.append(Pcd) self.SetPcdList(PcdList) =20 - ## GenSources + # GenSources # # Gen Sources of Inf # [|[|[|[|]]]] @@ -615,11 +637,11 @@ class InfPomAlignment(ModuleObject): =20 self.SetSourceFileList(self.GetSourceFileList() + SourceList) =20 - - ## GenUserExtensions + # GenUserExtensions # # Gen UserExtensions of Inf # + def _GenUserExtensions(self): # # UserExtensions @@ -645,19 +667,21 @@ class InfPomAlignment(ModuleObject): self._GenMiscFiles(UserExtensionDataObj.GetContent()) UserExtension.SetIdentifier(Identifier) UserExtension.SetStatement(UserExtensionDataObj.GetContent= ()) - UserExtension.SetSupArchList(ConvertArchList(UserExtension= DataObj.GetSupArchList())) - self.SetUserExtensionList(self.GetUserExtensionList() + [U= serExtension]) + UserExtension.SetSupArchList(ConvertArchList( + UserExtensionDataObj.GetSupArchList())) + self.SetUserExtensionList( + self.GetUserExtensionList() + [UserExtension]) =20 # # Gen UserExtensions of TianoCore."BinaryHeader" # =20 - #Get Binary header from INF file + # Get Binary header from INF file BinaryAbstractList =3D self.BinaryHeaderAbstractList BinaryDescriptionList =3D self.BinaryHeaderDescriptionList BinaryCopyrightList =3D self.BinaryHeaderCopyrightList BinaryLicenseList =3D self.BinaryHeaderLicenseList - #Get Binary header from UNI file + # Get Binary header from UNI file # Initialize UniStrDict, the top keys are language codes UniStrDict =3D {} if self.UniFileClassObject: @@ -666,9 +690,11 @@ class InfPomAlignment(ModuleObject): for StringDefClassObject in UniStrDict[Lang]: Lang =3D GetLanguageCode1766(Lang) if StringDefClassObject.StringName =3D=3D DT.TAB_INF_B= INARY_ABSTRACT: - BinaryAbstractList.append((Lang, ConvertSpecialUni= codes(StringDefClassObject.StringValue))) + BinaryAbstractList.append( + (Lang, ConvertSpecialUnicodes(StringDefClassOb= ject.StringValue))) if StringDefClassObject.StringName =3D=3D DT.TAB_INF_B= INARY_DESCRIPTION: - BinaryDescriptionList.append((Lang, ConvertSpecial= Unicodes(StringDefClassObject.StringValue))) + BinaryDescriptionList.append( + (Lang, ConvertSpecialUnicodes(StringDefClassOb= ject.StringValue))) if BinaryAbstractList or BinaryDescriptionList or BinaryCopyrightL= ist or BinaryLicenseList: BinaryUserExtension =3D CommonObject.UserExtensionObject() BinaryUserExtension.SetBinaryAbstract(BinaryAbstractList) @@ -677,7 +703,8 @@ class InfPomAlignment(ModuleObject): BinaryUserExtension.SetBinaryLicense(BinaryLicenseList) BinaryUserExtension.SetIdentifier(DT.TAB_BINARY_HEADER_IDENTIF= IER) BinaryUserExtension.SetUserID(DT.TAB_BINARY_HEADER_USERID) - self.SetUserExtensionList(self.GetUserExtensionList() + [Binar= yUserExtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [BinaryUserExtension]) =20 def _GenDepexesList(self, SmmDepexList, DxeDepexList, PeiDepexList): if SmmDepexList: @@ -687,7 +714,7 @@ class InfPomAlignment(ModuleObject): if PeiDepexList: self.SetPeiDepex(PeiDepexList) =20 - ## GenDepexes + # GenDepexes # # Gen Depex of Inf # @@ -737,7 +764,8 @@ class InfPomAlignment(ModuleObject): ModuleType =3D self.ModuleType if ModuleType not in DT.VALID_DEPEX_MODULE_TYPE_LIST: Logger.Error("\nMkPkg", PARSER_ERROR, - ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TY= PE_ERROR % (ModuleType), + ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TY= PE_ERROR % ( + ModuleType), self.GetFullPath(), RaiseError=3DTrue) if ModuleType !=3D self.ModuleType: Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_PARSE= R_DEPEX_SECTION_NOT_DETERMINED, @@ -757,7 +785,8 @@ class InfPomAlignment(ModuleObject): HelpIns =3D CommonObject.TextObject() if self.UniFileClassObject: HelpIns.SetLang(DT.TAB_LANGUAGE_EN_X) - HelpIns.SetString(GetHelpStringByRemoveHashKey(Depex.H= elpString)) + HelpIns.SetString( + GetHelpStringByRemoveHashKey(Depex.HelpString)) DepexIns.SetHelpText(HelpIns) =20 if ModuleType in SMM_LIST: @@ -773,11 +802,11 @@ class InfPomAlignment(ModuleObject): Logger.Error("\nMkPkg", PARSER_ERROR, ST.ERR_INF_P= ARSER_DEPEX_SECTION_INVALID_FOR_DRIVER, self.GetFullPath(), RaiseError=3DTrue) =20 - #End of for ModuleType in ModuleTypeList + # End of for ModuleType in ModuleTypeList self._GenDepexesList(SmmDepexList, DxeDepexList, PeiDepexList) - #End of for Depex in DepexData + # End of for Depex in DepexData =20 - ## GenBinaries + # GenBinaries # # Gen Binary of Inf, must be called after Pcd/Library is generated # ||[|.] @@ -829,7 +858,8 @@ class InfPomAlignment(ModuleObject): # # PatchPcd and PcdEx # - AsBuildIns =3D self._GenAsBuiltPcds(self.Parser.InfPcdSection.GetP= cds(), AsBuildIns) + AsBuildIns =3D self._GenAsBuiltPcds( + self.Parser.InfPcdSection.GetPcds(), AsBuildIns) =20 # # Parse the DEC file that contains the GUID value of the GUID CNam= e which is used by @@ -843,13 +873,15 @@ class InfPomAlignment(ModuleObject): TempPath =3D ModulePath ModulePath =3D os.path.dirname(ModulePath) PackageName =3D TempPath - DecFilePath =3D os.path.normpath(os.path.join(WorkSpace, Packa= geName)) + DecFilePath =3D os.path.normpath( + os.path.join(WorkSpace, PackageName)) if DecFilePath: for File in os.listdir(DecFilePath): if File.upper().endswith('.DEC'): - DecFileFullPath =3D os.path.normpath(os.path.join(= DecFilePath, File)) - DecObjList.append(DecPomAlignment(DecFileFullPath,= self.WorkSpace)) - + DecFileFullPath =3D os.path.normpath( + os.path.join(DecFilePath, File)) + DecObjList.append(DecPomAlignment( + DecFileFullPath, self.WorkSpace)) =20 BinariesDict, AsBuildIns, BinaryFileObjectList =3D GenBinaryData(B= inaryData, BinaryObj, Bin= ariesDict, @@ -882,9 +914,10 @@ class InfPomAlignment(ModuleObject): UserExtension.SetBinariesDict(BinariesDict2) UserExtension.SetIdentifier('BinaryFileModifiers') UserExtension.SetUserID('EDK2') - self.SetUserExtensionList(self.GetUserExtensionList() + [UserE= xtension]) + self.SetUserExtensionList( + self.GetUserExtensionList() + [UserExtension]) =20 - ## GenAsBuiltPcds + # GenAsBuiltPcds # # def _GenAsBuiltPcds(self, PcdList, AsBuildIns): @@ -902,16 +935,18 @@ class InfPomAlignment(ModuleObject): if PcdItemObj.GetTokenSpaceGuidValue() =3D=3D '' and self.= BinaryModule: Logger.Error("\nMkPkg", PARSER_ERROR, - ST.ERR_ASBUILD_PCD_TOKENSPACE_GUID_VALUE_= MISS % \ + ST.ERR_ASBUILD_PCD_TOKENSPACE_GUID_VALUE_= MISS % (PcdItemObj.GetTokenSpaceGuidCName()), self.GetFullPath(), RaiseError=3DTrue) else: - Pcd.SetTokenSpaceGuidValue(PcdItemObj.GetTokenSpaceGui= dValue()) + Pcd.SetTokenSpaceGuidValue( + PcdItemObj.GetTokenSpaceGuidValue()) if (PcdItemObj.GetToken() =3D=3D '' or PcdItemObj.GetDatum= Type() =3D=3D '') and self.BinaryModule: Logger.Error("\nMkPkg", PARSER_ERROR, - ST.ERR_ASBUILD_PCD_DECLARITION_MISS % \ - (PcdItemObj.GetTokenSpaceGuidCName() + '.= ' + PcdItemObj.GetCName()), + ST.ERR_ASBUILD_PCD_DECLARITION_MISS % + (PcdItemObj.GetTokenSpaceGuidCName() + + '.' + PcdItemObj.GetCName()), self.GetFullPath(), RaiseError=3DTrue) Pcd.SetToken(PcdItemObj.GetToken()) Pcd.SetDatumType(PcdItemObj.GetDatumType()) @@ -920,7 +955,8 @@ class InfPomAlignment(ModuleObject): Pcd.SetOffset(PcdItemObj.GetOffset()) Pcd.SetItemType(PcdItem[0]) Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp()) - Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportAr= chList())) + Pcd.SetSupArchList(ConvertArchList( + PcdItemObj.GetSupportArchList())) Pcd.SetValidUsage(PcdItemObj.GetValidUsage()) for CommentItem in PcdItemObj.GetHelpStringList(): HelpTextObj =3D CommonObject.TextObject() @@ -939,7 +975,8 @@ class InfPomAlignment(ModuleObject): Pcd.SetDefaultValue(PcdItemObj.GetDefaultValue()) Pcd.SetItemType(PcdItem[0]) Pcd.SetFeatureFlag(PcdItemObj.GetFeatureFlagExp()) - Pcd.SetSupArchList(ConvertArchList(PcdItemObj.GetSupportAr= chList())) + Pcd.SetSupArchList(ConvertArchList( + PcdItemObj.GetSupportArchList())) Pcd.SetValidUsage(PcdItemObj.GetValidUsage()) for CommentItem in PcdItemObj.GetHelpStringList(): HelpTextObj =3D CommonObject.TextObject() @@ -953,7 +990,7 @@ class InfPomAlignment(ModuleObject): =20 return AsBuildIns =20 - ## GenGuidProtocolPpis + # GenGuidProtocolPpis # # Gen Guids/Protocol/Ppis of INF # =3D @@ -980,12 +1017,15 @@ class InfPomAlignment(ModuleObject): if CommentList: for GuidComentItem in CommentList: ListObject =3D CommonObject.GuidObject() - ListObject.SetGuidTypeList([GuidComentItem.GetGuid= TypeItem()]) - ListObject.SetVariableName(GuidComentItem.GetVaria= bleNameItem()) + ListObject.SetGuidTypeList( + [GuidComentItem.GetGuidTypeItem()]) + ListObject.SetVariableName( + GuidComentItem.GetVariableNameItem()) ListObject.SetUsage(GuidComentItem.GetUsageItem()) ListObject.SetName(Item.GetName()) ListObject.SetCName(Item.GetName()) - ListObject.SetSupArchList(ConvertArchList(Item.Get= SupArchList())) + ListObject.SetSupArchList( + ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) HelpString =3D GuidComentItem.GetHelpStringItem() if HelpString.strip(): @@ -1003,7 +1043,8 @@ class InfPomAlignment(ModuleObject): for CommentItem in CommentList: ListObject =3D CommonObject.ProtocolObject() ListObject.SetCName(Item.GetName()) - ListObject.SetSupArchList(ConvertArchList(Item.GetSupA= rchList())) + ListObject.SetSupArchList( + ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) ListObject.SetNotify(CommentItem.GetNotify()) ListObject.SetUsage(CommentItem.GetUsageItem()) @@ -1022,7 +1063,8 @@ class InfPomAlignment(ModuleObject): for CommentItem in CommentList: ListObject =3D CommonObject.PpiObject() ListObject.SetCName(Item.GetName()) - ListObject.SetSupArchList(ConvertArchList(Item.GetSupA= rchList())) + ListObject.SetSupArchList( + ConvertArchList(Item.GetSupArchList())) ListObject.SetFeatureFlag(Item.GetFeatureFlagExp()) ListObject.SetNotify(CommentItem.GetNotify()) ListObject.SetUsage(CommentItem.GetUsage()) @@ -1042,7 +1084,7 @@ class InfPomAlignment(ModuleObject): elif Type =3D=3D DT.TAB_PPIS: self.SetPpiList(self.GetPpiList() + GuidProtocolPpiList) =20 - ## GenMiscFiles + # GenMiscFiles # # Gen MiscellaneousFiles of Inf # @@ -1060,12 +1102,13 @@ class InfPomAlignment(ModuleObject): if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR): FileObj =3D CommonObject.FileObject() FileObj.SetURI(FileName) - MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[Fil= eObj]) + MiscFileObj.SetFileList( + MiscFileObj.GetFileList()+[FileObj]) else: Logger.Error("InfParser", FORMAT_INVALID, - ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID%(Line), + ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_= INVALID % ( + Line), File=3DGlobalData.gINF_MODULE_NAME, ExtraData=3DLine) self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj]) - diff --git a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py = b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py index 08a6b257dbef..b93ddee7ccb7 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py @@ -1,4 +1,4 @@ -## @file InfPomAlignmentMisc.py +# @file InfPomAlignmentMisc.py # This file contained the routines for InfPomAlignment # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,7 +23,7 @@ from Library.Misc import CheckGuidRegFormat from Logger import StringTable as ST =20 =20 -## GenModuleHeaderUserExt +# GenModuleHeaderUserExt # # def GenModuleHeaderUserExt(DefineObj, ArchString): @@ -120,7 +120,8 @@ def GenModuleHeaderUserExt(DefineObj, ArchString): # if len(CustomMakefileItem) =3D=3D 3: if CustomMakefileItem[0] !=3D '': - Value =3D CustomMakefileItem[0] + ' | ' + CustomMakefi= leItem[1] + Value =3D CustomMakefileItem[0] + \ + ' | ' + CustomMakefileItem[1] else: Value =3D CustomMakefileItem[1] =20 @@ -146,7 +147,7 @@ def GenModuleHeaderUserExt(DefineObj, ArchString): return DefinesDictNew =20 =20 -## Generate the define statement that will be put into userextension +# Generate the define statement that will be put into userextension # Not support comments. # # @param HeaderComment: the original header comment (# not removed) @@ -162,10 +163,12 @@ def _GenInfDefineStateMent(HeaderComment, Name, Value= , TailComment): =20 return Statement =20 -## GenBinaryData +# GenBinaryData # # -def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryF= ileObjectList, \ + + +def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryF= ileObjectList, SupArchList, BinaryModule, DecObjList=3DNone): if BinaryModule: pass @@ -206,16 +209,16 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict= , AsBuildIns, BinaryFileObj if not CheckGuidRegFormat(ItemObj.GetGuidValue()): if not DecObjList: if DT.TAB_HORIZON_LINE_SPLIT in ItemObj.GetGuidValue()= or \ - DT.TAB_COMMA_SPLIT in ItemObj.GetGuidValue(): + DT.TAB_COMMA_SPLIT in ItemObj.GetGuidValue(): Logger.Error("\nMkPkg", - FORMAT_INVALID, - ST.ERR_DECPARSE_DEFINE_PKGGUID, - ExtraData=3DItemObj.GetGuidValue(), - RaiseError=3DTrue) + FORMAT_INVALID, + ST.ERR_DECPARSE_DEFINE_PKGGUID, + ExtraData=3DItemObj.GetGuidValue(), + RaiseError=3DTrue) else: Logger.Error("\nMkPkg", FORMAT_INVALID, - ST.ERR_UNI_SUBGUID_VALUE_DEFINE_DEC_N= OT_FOUND % \ + ST.ERR_UNI_SUBGUID_VALUE_DEFINE_DEC_N= OT_FOUND % (ItemObj.GetGuidValue()), RaiseError=3DTrue) else: @@ -227,10 +230,10 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict= , AsBuildIns, BinaryFileObj =20 if not FileNameObj.GetGuidValue(): Logger.Error("\nMkPkg", - FORMAT_INVALID, - ST.ERR_DECPARSE_CGUID_NOT_FOUND %= \ - (ItemObj.GetGuidValue()), - RaiseError=3DTrue) + FORMAT_INVALID, + ST.ERR_DECPARSE_CGUID_NOT_FOUND % + (ItemObj.GetGuidValue()), + RaiseError=3DTrue) else: FileNameObj.SetGuidValue(ItemObj.GetGuidValue().strip()) =20 diff --git a/BaseTools/Source/Python/UPT/PomAdapter/__init__.py b/BaseTools= /Source/Python/UPT/PomAdapter/__init__.py index a7c7e9dbf70c..1143abb3afd8 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/__init__.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Parser' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/UPT/ReplacePkg.py b/BaseTools/Source/P= ython/UPT/ReplacePkg.py index 03b91dab8455..02b5c7141054 100644 --- a/BaseTools/Source/Python/UPT/ReplacePkg.py +++ b/BaseTools/Source/Python/UPT/ReplacePkg.py @@ -1,4 +1,4 @@ -## @file +# @file # Replace distribution package. # # Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
        @@ -30,7 +30,7 @@ from InstallPkg import InstallDp from RmPkg import GetInstalledDpInfo from RmPkg import RemoveDist =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -38,15 +38,18 @@ from RmPkg import RemoveDist # # @param Options: command Options # -def Main(Options =3D None): + + +def Main(Options=3DNone): ContentZipFile, DistFile =3D None, None try: DataBase =3D GlobalData.gDB WorkspaceDir =3D GlobalData.gWORKSPACE Dep =3D DependencyRules(DataBase) - DistPkg, ContentZipFile, DpPkgFileName, DistFile =3D UnZipDp(Works= paceDir, Options.PackFileToReplace) + DistPkg, ContentZipFile, DpPkgFileName, DistFile =3D UnZipDp( + WorkspaceDir, Options.PackFileToReplace) =20 - StoredDistFile, OrigDpGuid, OrigDpVersion =3D GetInstalledDpInfo(O= ptions.PackFileToBeReplaced, \ + StoredDistFile, OrigDpGuid, OrigDpVersion =3D GetInstalledDpInfo(O= ptions.PackFileToBeReplaced, Dep= , DataBase, WorkspaceDir) =20 # @@ -57,35 +60,38 @@ def Main(Options =3D None): # # Remove the old distribution # - RemoveDist(OrigDpGuid, OrigDpVersion, StoredDistFile, DataBase, Wo= rkspaceDir, Options.Yes) + RemoveDist(OrigDpGuid, OrigDpVersion, StoredDistFile, + DataBase, WorkspaceDir, Options.Yes) =20 # # Install the new distribution # - InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, Wo= rkspaceDir, DataBase) + InstallDp(DistPkg, DpPkgFileName, ContentZipFile, + Options, Dep, WorkspaceDir, DataBase) ReturnCode =3D 0 =20 except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), - platform) + format_exc()) + platform) + format_exc()) except KeyboardInterrupt: ReturnCode =3D ABORT_ERROR if Logger.GetLevel() <=3D Logger.DEBUG_9: Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), - platform) + format_exc()) + platform) + format_exc()) except: ReturnCode =3D CODE_ERROR Logger.Error( - "\nReplacePkg", - CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_REPLACE_ERR % (Options.PackFileTo= Replace, Options.PackFileToBeReplaced), - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) + "\nReplacePkg", + CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_REPLACE_ERR % ( + Options.PackFileToReplace, Options.PackFileToBeReplaced), + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), - platform) + format_exc()) + platform) + format_exc()) =20 finally: Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED) @@ -103,13 +109,15 @@ def Main(Options =3D None): =20 return ReturnCode =20 + def CheckReplaceDpx(Dep, DistPkg, OrigDpGuid, OrigDpVersion): NewDpPkgList =3D [] for PkgInfo in DistPkg.PackageSurfaceArea: Guid, Version =3D PkgInfo[0], PkgInfo[1] NewDpPkgList.append((Guid, Version)) =20 - NewDpInfo =3D "%s %s" % (DistPkg.Header.GetGuid(), DistPkg.Header.GetV= ersion()) + NewDpInfo =3D "%s %s" % (DistPkg.Header.GetGuid(), + DistPkg.Header.GetVersion()) OrigDpInfo =3D "%s %s" % (OrigDpGuid, OrigDpVersion) =20 # @@ -118,25 +126,25 @@ def CheckReplaceDpx(Dep, DistPkg, OrigDpGuid, OrigDpV= ersion): if (NewDpInfo !=3D OrigDpInfo): if Dep.CheckDpExists(DistPkg.Header.GetGuid(), DistPkg.Header.GetV= ersion()): Logger.Error("\nReplacePkg", UPT_ALREADY_INSTALLED_ERROR, - ST.WRN_DIST_PKG_INSTALLED, - ExtraData=3DST.MSG_REPLACE_ALREADY_INSTALLED_DP) + ST.WRN_DIST_PKG_INSTALLED, + ExtraData=3DST.MSG_REPLACE_ALREADY_INSTALLED_DP) =20 # # check whether the original distribution could be replaced by new dis= tribution # - Logger.Verbose(ST.MSG_CHECK_DP_FOR_REPLACE%(NewDpInfo, OrigDpInfo)) - DepInfoResult =3D Dep.CheckDpDepexForReplace(OrigDpGuid, OrigDpVersion= , NewDpPkgList) + Logger.Verbose(ST.MSG_CHECK_DP_FOR_REPLACE % (NewDpInfo, OrigDpInfo)) + DepInfoResult =3D Dep.CheckDpDepexForReplace( + OrigDpGuid, OrigDpVersion, NewDpPkgList) Replaceable =3D DepInfoResult[0] if not Replaceable: Logger.Error("\nReplacePkg", UNKNOWN_ERROR, - ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY) + ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY) =20 # # check whether new distribution could be installed by dependency rule # - Logger.Verbose(ST.MSG_CHECK_DP_FOR_INSTALL%str(NewDpInfo)) + Logger.Verbose(ST.MSG_CHECK_DP_FOR_INSTALL % str(NewDpInfo)) if not Dep.ReplaceCheckNewDpDepex(DistPkg, OrigDpGuid, OrigDpVersion): Logger.Error("\nReplacePkg", UNKNOWN_ERROR, - ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY, - ExtraData=3DDistPkg.Header.Name) - + ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY, + ExtraData=3DDistPkg.Header.Name) diff --git a/BaseTools/Source/Python/UPT/RmPkg.py b/BaseTools/Source/Python= /UPT/RmPkg.py index cf37e2bdcabf..2ca9a020b186 100644 --- a/BaseTools/Source/Python/UPT/RmPkg.py +++ b/BaseTools/Source/Python/UPT/RmPkg.py @@ -1,4 +1,4 @@ -## @file +# @file # Install distribution package. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -32,7 +32,7 @@ from Logger.ToolError import CODE_ERROR from Logger.ToolError import FatalError =20 =20 -## CheckDpDepex +# CheckDpDepex # # Check if the Depex is satisfied # @param Dep: Dep @@ -57,13 +57,14 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir): # also generate a log file for reference # Logger.Info(ST.MSG_INVALID_MODULE_INTRODUCED) - LogFilePath =3D os.path.normpath(os.path.join(WorkspaceDir, Gl= obalData.gINVALID_MODULE_FILE)) + LogFilePath =3D os.path.normpath(os.path.join( + WorkspaceDir, GlobalData.gINVALID_MODULE_FILE)) Logger.Info(ST.MSG_CHECK_LOG_FILE % LogFilePath) try: LogFile =3D open(LogFilePath, 'w') try: for ModulePath in DependModuleList: - LogFile.write("%s\n"%ModulePath) + LogFile.write("%s\n" % ModulePath) Logger.Info(ModulePath) except IOError: Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE, @@ -74,13 +75,15 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir): finally: LogFile.close() =20 -## Remove Path +# Remove Path # # removing readonly file on windows will get "Access is denied" # error, so before removing, change the mode to be writeable # # @param Path: The Path to be removed # + + def RemovePath(Path): Logger.Info(ST.MSG_REMOVE_FILE % Path) if not os.access(Path, os.W_OK): @@ -90,16 +93,18 @@ def RemovePath(Path): os.removedirs(os.path.split(Path)[0]) except OSError: pass -## GetCurrentFileList +# GetCurrentFileList # # @param DataBase: DataBase of UPT # @param Guid: Guid of Dp # @param Version: Version of Dp # @param WorkspaceDir: Workspace Dir # + + def GetCurrentFileList(DataBase, Guid, Version, WorkspaceDir): NewFileList =3D [] - for Dir in DataBase.GetDpInstallDirList(Guid, Version): + for Dir in DataBase.GetDpInstallDirList(Guid, Version): RootDir =3D os.path.normpath(os.path.join(WorkspaceDir, Dir)) for Root, Dirs, Files in os.walk(RootDir): Logger.Debug(0, Dirs) @@ -110,7 +115,7 @@ def GetCurrentFileList(DataBase, Guid, Version, Workspa= ceDir): return NewFileList =20 =20 -## Tool entrance method +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -118,7 +123,7 @@ def GetCurrentFileList(DataBase, Guid, Version, Workspa= ceDir): # # @param Options: command option # -def Main(Options =3D None): +def Main(Options=3DNone): =20 try: DataBase =3D GlobalData.gDB @@ -135,7 +140,8 @@ def Main(Options =3D None): # # Get the Dp information # - StoredDistFile, Guid, Version =3D GetInstalledDpInfo(Options.Distr= ibutionFile, Dep, DataBase, WorkspaceDir) + StoredDistFile, Guid, Version =3D GetInstalledDpInfo( + Options.DistributionFile, Dep, DataBase, WorkspaceDir) =20 # # Check Dp depex @@ -145,7 +151,8 @@ def Main(Options =3D None): # # remove distribution # - RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, = Options.Yes) + RemoveDist(Guid, Version, StoredDistFile, + DataBase, WorkspaceDir, Options.Yes) =20 Logger.Quiet(ST.MSG_FINISH) =20 @@ -154,27 +161,27 @@ def Main(Options =3D None): except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += \ + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) except KeyboardInterrupt: ReturnCode =3D ABORT_ERROR if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += \ + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) except: Logger.Error( - "\nRmPkg", - CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_REMOVING_ERR, - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \ + "\nRmPkg", + CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_REMOVING_ERR, + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) ReturnCode =3D CODE_ERROR return ReturnCode =20 -## GetInstalledDpInfo method +# GetInstalledDpInfo method # # Get the installed distribution information # @@ -186,10 +193,14 @@ def Main(Options =3D None): # @retval Guid: the Guid of the distribution # @retval Version: the Version of distribution # + + def GetInstalledDpInfo(DistributionFile, Dep, DataBase, WorkspaceDir): - (Guid, Version, NewDpFileName) =3D DataBase.GetDpByName(os.path.split(= DistributionFile)[1]) + (Guid, Version, NewDpFileName) =3D DataBase.GetDpByName( + os.path.split(DistributionFile)[1]) if not Guid: - Logger.Error("RmPkg", UNKNOWN_ERROR, ST.ERR_PACKAGE_NOT_INSTALLED = % DistributionFile) + Logger.Error("RmPkg", UNKNOWN_ERROR, + ST.ERR_PACKAGE_NOT_INSTALLED % DistributionFile) =20 # # Check Dp existing @@ -200,14 +211,15 @@ def GetInstalledDpInfo(DistributionFile, Dep, DataBas= e, WorkspaceDir): # Check for Distribution files existence in /conf/upt, if not exist, # Warn user and go on. # - StoredDistFile =3D os.path.normpath(os.path.join(WorkspaceDir, GlobalD= ata.gUPT_DIR, NewDpFileName)) + StoredDistFile =3D os.path.normpath(os.path.join( + WorkspaceDir, GlobalData.gUPT_DIR, NewDpFileName)) if not os.path.isfile(StoredDistFile): - Logger.Warn("RmPkg", ST.WRN_DIST_NOT_FOUND%StoredDistFile) + Logger.Warn("RmPkg", ST.WRN_DIST_NOT_FOUND % StoredDistFile) StoredDistFile =3D None =20 return StoredDistFile, Guid, Version =20 -## RemoveDist method +# RemoveDist method # # remove a distribution # @@ -218,6 +230,8 @@ def GetInstalledDpInfo(DistributionFile, Dep, DataBase,= WorkspaceDir): # @param WorkspaceDir: work space directory # @param ForceRemove: whether user want to remove file even it is modified # + + def RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, Forc= eRemove): # # Get Current File List diff --git a/BaseTools/Source/Python/UPT/TestInstall.py b/BaseTools/Source/= Python/UPT/TestInstall.py index 1adc19260d89..9d1a5880f9e6 100644 --- a/BaseTools/Source/Python/UPT/TestInstall.py +++ b/BaseTools/Source/Python/UPT/TestInstall.py @@ -31,6 +31,8 @@ from sys import platform # # @param Options: command Options # + + def Main(Options=3DNone): ContentZipFile, DistFile =3D None, None ReturnCode =3D 0 @@ -39,11 +41,13 @@ def Main(Options=3DNone): DataBase =3D GlobalData.gDB WorkspaceDir =3D GlobalData.gWORKSPACE if not Options.DistFiles: - Logger.Error("TestInstallPkg", TE.OPTION_MISSING, ExtraData=3D= ST.ERR_SPECIFY_PACKAGE) + Logger.Error("TestInstallPkg", TE.OPTION_MISSING, + ExtraData=3DST.ERR_SPECIFY_PACKAGE) =20 DistPkgList =3D [] for DistFile in Options.DistFiles: - DistPkg, ContentZipFile, __, DistFile =3D UnZipDp(WorkspaceDir= , DistFile) + DistPkg, ContentZipFile, __, DistFile =3D UnZipDp( + WorkspaceDir, DistFile) DistPkgList.append(DistPkg) =20 # @@ -65,18 +69,20 @@ def Main(Options=3DNone): except TE.FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) =20 except Exception as x: ReturnCode =3D TE.CODE_ERROR Logger.Error( - "\nTestInstallPkg", - TE.CODE_ERROR, - ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles, - ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL= _ADDR, - RaiseError=3DFalse - ) - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + for= mat_exc()) + "\nTestInstallPkg", + TE.CODE_ERROR, + ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.DistFiles, + ExtraData=3DST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) =20 finally: Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED) @@ -91,4 +97,3 @@ def Main(Options=3DNone): if ReturnCode =3D=3D 0: Logger.Quiet(ST.MSG_FINISH) return ReturnCode - diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/U= PT/UPT.py index 480f389d7d03..75b1a3bac21f 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -1,4 +1,4 @@ -## @file +# @file # # This file is the main entry for UPT # @@ -13,6 +13,35 @@ UPT =20 ## import modules # +from BuildVersion import gBUILD_VERSION +from Core.IpiDb import IpiDatabase +from Library import GlobalData +from Library.Misc import GetWorkspace +import TestInstall +import ReplacePkg +import InventoryWs +import RmPkg +import InstallPkg +import MkPkg +from Common.MultipleWorkspace import MultipleWorkspace as mws +from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR +from Logger.ToolError import FatalError +from Logger.ToolError import OPTION_CONFLICT +from Logger.ToolError import FILE_TYPE_MISMATCH +from Logger.ToolError import OPTION_MISSING +from Logger.ToolError import FILE_NOT_FOUND +from Logger.StringTable import MSG_USAGE +from Logger.StringTable import MSG_DESCRIPTION +from Logger.StringTable import MSG_VERSION +import Logger.Log as Logger +from Logger import StringTable as ST +from platform import python_version +from traceback import format_exc +from optparse import OptionParser +import platform as pf +from sys import platform +import os.path +from Core import FileHook import locale import sys from imp import reload @@ -20,57 +49,29 @@ encoding =3D locale.getdefaultlocale()[1] if encoding: reload(sys) sys.setdefaultencoding(encoding) -from Core import FileHook -import os.path -from sys import platform -import platform as pf -from optparse import OptionParser -from traceback import format_exc -from platform import python_version =20 -from Logger import StringTable as ST -import Logger.Log as Logger -from Logger.StringTable import MSG_VERSION -from Logger.StringTable import MSG_DESCRIPTION -from Logger.StringTable import MSG_USAGE -from Logger.ToolError import FILE_NOT_FOUND -from Logger.ToolError import OPTION_MISSING -from Logger.ToolError import FILE_TYPE_MISMATCH -from Logger.ToolError import OPTION_CONFLICT -from Logger.ToolError import FatalError -from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR -from Common.MultipleWorkspace import MultipleWorkspace as mws =20 -import MkPkg -import InstallPkg -import RmPkg -import InventoryWs -import ReplacePkg -import TestInstall -from Library.Misc import GetWorkspace -from Library import GlobalData -from Core.IpiDb import IpiDatabase -from BuildVersion import gBUILD_VERSION - -## CheckConflictOption +# CheckConflictOption # # CheckConflictOption # + def CheckConflictOption(Opt): if (Opt.PackFileToCreate or Opt.PackFileToInstall or Opt.PackFileToRem= ove or Opt.PackFileToReplace) \ - and Opt.InventoryWs: + and Opt.InventoryWs: Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_L_OA_EXCLU= SIVE) elif Opt.PackFileToReplace and (Opt.PackFileToCreate or Opt.PackFileTo= Install or Opt.PackFileToRemove): Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_U_ICR_EXCL= USIVE) elif (Opt.PackFileToCreate and Opt.PackFileToInstall and Opt.PackFileT= oRemove): - Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_REQUIRE_I_= C_R_OPTION) + Logger.Error("UPT", OPTION_CONFLICT, + ExtraData=3DST.ERR_REQUIRE_I_C_R_OPTION) elif Opt.PackFileToCreate and Opt.PackFileToInstall: Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_I_C_EXCLUS= IVE) elif Opt.PackFileToInstall and Opt.PackFileToRemove: Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_I_R_EXCLUS= IVE) - elif Opt.PackFileToCreate and Opt.PackFileToRemove: + elif Opt.PackFileToCreate and Opt.PackFileToRemove: Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_C_R_EXCLUS= IVE) - elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInst= all \ + elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInst= all or Opt.PackFileToRemove or Opt.PackFileToR= eplace): Logger.Error("UPT", OPTION_CONFLICT, ExtraData=3DST.ERR_C_R_EXCLUS= IVE) =20 @@ -78,8 +79,10 @@ def CheckConflictOption(Opt): Logger.Warn("UPT", ST.WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH) Opt.UseGuidedPkgPath =3D False =20 -## SetLogLevel +# SetLogLevel # + + def SetLogLevel(Opt): if Opt.opt_verbose: Logger.SetLevel(Logger.VERBOSE) @@ -96,24 +99,29 @@ def SetLogLevel(Opt): else: Logger.SetLevel(Logger.INFO) =20 -## Main +# Main # # Main # + + def Main(): Logger.Initialize() =20 Parser =3D OptionParser(version=3D(MSG_VERSION + ' Build ' + gBUILD_VE= RSION), description=3DMSG_DESCRIPTION, prog=3D"UPT.exe", usage=3DMSG_USAGE) =20 - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", des= t=3D"debug_level", help=3DST.HLP_PRINT_DEBUG_INFO) + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + dest=3D"debug_level", help=3DST.HLP_PRINT_DEBUG_INFO) =20 Parser.add_option("-v", "--verbose", action=3D"store_true", dest=3D"op= t_verbose", help=3DST.HLP_PRINT_INFORMATIONAL_STATEMENT) =20 - Parser.add_option("-s", "--silent", action=3D"store_true", dest=3D"opt= _slient", help=3DST.HLP_RETURN_NO_DISPLAY) + Parser.add_option("-s", "--silent", action=3D"store_true", + dest=3D"opt_slient", help=3DST.HLP_RETURN_NO_DISPLAY) =20 - Parser.add_option("-q", "--quiet", action=3D"store_true", dest=3D"opt_= quiet", help=3DST.HLP_RETURN_AND_DISPLAY) + Parser.add_option("-q", "--quiet", action=3D"store_true", + dest=3D"opt_quiet", help=3DST.HLP_RETURN_AND_DISPLAY) =20 Parser.add_option("-i", "--install", action=3D"append", type=3D"string= ", dest=3D"Install_Distribution_Package_File", help=3DST.HLP_SPECIFY_PACKAGE_NAME_INSTALL) @@ -136,11 +144,14 @@ def Main(): Parser.add_option("-l", "--list", action=3D"store_true", dest=3D"List_= Dist_Installed", help=3DST.HLP_LIST_DIST_INSTALLED) =20 - Parser.add_option("-f", "--force", action=3D"store_true", dest=3D"Yes"= , help=3DST.HLP_DISABLE_PROMPT) + Parser.add_option("-f", "--force", action=3D"store_true", + dest=3D"Yes", help=3DST.HLP_DISABLE_PROMPT) =20 - Parser.add_option("-n", "--custom-path", action=3D"store_true", dest= =3D"CustomPath", help=3DST.HLP_CUSTOM_PATH_PROMPT) + Parser.add_option("-n", "--custom-path", action=3D"store_true", + dest=3D"CustomPath", help=3DST.HLP_CUSTOM_PATH_PROMP= T) =20 - Parser.add_option("-x", "--free-lock", action=3D"store_true", dest=3D"= SkipLock", help=3DST.HLP_SKIP_LOCK_CHECK) + Parser.add_option("-x", "--free-lock", action=3D"store_true", + dest=3D"SkipLock", help=3DST.HLP_SKIP_LOCK_CHECK) =20 Parser.add_option("-u", "--replace", action=3D"store", type=3D"string"= , dest=3D"Replace_Distribution_Package_File", help=3DST.HLP_SPECIFY_PACKAGE_NAME_REPLACE) @@ -148,7 +159,8 @@ def Main(): Parser.add_option("-o", "--original", action=3D"store", type=3D"string= ", dest=3D"Original_Distribution_Package_File", help=3DST.HLP_SPECIFY_PACKAGE_NAME_TO_BE_REPLACED) =20 - Parser.add_option("--use-guided-paths", action=3D"store_true", dest=3D= "Use_Guided_Paths", help=3DST.HLP_USE_GUIDED_PATHS) + Parser.add_option("--use-guided-paths", action=3D"store_true", + dest=3D"Use_Guided_Paths", help=3DST.HLP_USE_GUIDED_= PATHS) =20 Parser.add_option("-j", "--test-install", action=3D"append", type=3D"s= tring", dest=3D"Test_Install_Distribution_Package_Files", he= lp=3DST.HLP_TEST_INSTALL) @@ -176,7 +188,8 @@ def Main(): GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH =3D GetWorkspace() except FatalError as XExcept: if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += format_exc()) + Logger.Quiet(ST.MSG_PYTHON_ON % + (python_version(), platform) + format_exc()) return XExcept.args[0] =20 # Support WORKSPACE is a long path @@ -197,7 +210,7 @@ def Main(): Mgr =3D FileHook.RecoverMgr(WorkspaceDir) FileHook.SetRecoverMgr(Mgr) =20 - GlobalData.gDB =3D IpiDatabase(os.path.normpath(os.path.join(Workspace= Dir, \ + GlobalData.gDB =3D IpiDatabase(os.path.normpath(os.path.join(Workspace= Dir, "Conf/Distr= ibutionPackageDatabase.db")), WorkspaceDir) GlobalData.gDB.InitDatabase(Opt.SkipLock) =20 @@ -213,24 +226,30 @@ def Main(): if Opt.PackageInformationDataFile: if not os.path.exists(Opt.PackageInformationDataFile): if not os.path.exists(os.path.join(WorkspaceDir, Opt.P= ackageInformationDataFile)): - Logger.Error("\nUPT", FILE_NOT_FOUND, ST.ERR_NO_TE= MPLATE_FILE % Opt.PackageInformationDataFile) + Logger.Error( + "\nUPT", FILE_NOT_FOUND, ST.ERR_NO_TEMPLATE_FI= LE % Opt.PackageInformationDataFile) else: - Opt.PackageInformationDataFile =3D os.path.join(Wo= rkspaceDir, Opt.PackageInformationDataFile) + Opt.PackageInformationDataFile =3D os.path.join( + WorkspaceDir, Opt.PackageInformationDataFile) else: - Logger.Error("UPT", OPTION_MISSING, ExtraData=3DST.ERR_REQ= UIRE_T_OPTION) + Logger.Error("UPT", OPTION_MISSING, + ExtraData=3DST.ERR_REQUIRE_T_OPTION) if not Opt.PackFileToCreate.endswith('.dist'): - Logger.Error("CreatePkg", FILE_TYPE_MISMATCH, ExtraData=3D= ST.ERR_DIST_EXT_ERROR % Opt.PackFileToCreate) + Logger.Error("CreatePkg", FILE_TYPE_MISMATCH, + ExtraData=3DST.ERR_DIST_EXT_ERROR % Opt.PackF= ileToCreate) RunModule =3D MkPkg.Main =20 elif Opt.PackFileToInstall: AbsPath =3D [] for Item in Opt.PackFileToInstall: if not Item.endswith('.dist'): - Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, ExtraDa= ta=3DST.ERR_DIST_EXT_ERROR % Item) + Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, + ExtraData=3DST.ERR_DIST_EXT_ERROR % Item) =20 AbsPath.append(GetFullPathDist(Item, WorkspaceDir)) if not AbsPath: - Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_INST= ALL_DIST_NOT_FOUND % Item) + Logger.Error("InstallPkg", FILE_NOT_FOUND, + ST.ERR_INSTALL_DIST_NOT_FOUND % Item) =20 Opt.PackFileToInstall =3D AbsPath setattr(Opt, 'PackageFile', Opt.PackFileToInstall) @@ -238,7 +257,8 @@ def Main(): =20 elif Opt.PackFileToRemove: if not Opt.PackFileToRemove.endswith('.dist'): - Logger.Error("RemovePkg", FILE_TYPE_MISMATCH, ExtraData=3D= ST.ERR_DIST_EXT_ERROR % Opt.PackFileToRemove) + Logger.Error("RemovePkg", FILE_TYPE_MISMATCH, + ExtraData=3DST.ERR_DIST_EXT_ERROR % Opt.PackF= ileToRemove) head, tail =3D os.path.split(Opt.PackFileToRemove) if head or not tail: Logger.Error("RemovePkg", @@ -251,13 +271,16 @@ def Main(): RunModule =3D InventoryWs.Main =20 elif Opt.PackFileToBeReplaced and not Opt.PackFileToReplace: - Logger.Error("ReplacePkg", OPTION_MISSING, ExtraData=3DST.ERR_= REQUIRE_U_OPTION) + Logger.Error("ReplacePkg", OPTION_MISSING, + ExtraData=3DST.ERR_REQUIRE_U_OPTION) =20 elif Opt.PackFileToReplace: if not Opt.PackFileToReplace.endswith('.dist'): - Logger.Error("ReplacePkg", FILE_TYPE_MISMATCH, ExtraData= =3DST.ERR_DIST_EXT_ERROR % Opt.PackFileToReplace) + Logger.Error("ReplacePkg", FILE_TYPE_MISMATCH, + ExtraData=3DST.ERR_DIST_EXT_ERROR % Opt.PackF= ileToReplace) if not Opt.PackFileToBeReplaced: - Logger.Error("ReplacePkg", OPTION_MISSING, ExtraData=3DST.= ERR_REQUIRE_O_OPTION) + Logger.Error("ReplacePkg", OPTION_MISSING, + ExtraData=3DST.ERR_REQUIRE_O_OPTION) if not Opt.PackFileToBeReplaced.endswith('.dist'): Logger.Error("ReplacePkg", FILE_TYPE_MISMATCH, @@ -271,7 +294,8 @@ def Main(): =20 AbsPath =3D GetFullPathDist(Opt.PackFileToReplace, WorkspaceDi= r) if not AbsPath: - Logger.Error("ReplacePkg", FILE_NOT_FOUND, ST.ERR_REPLACE_= DIST_NOT_FOUND % Opt.PackFileToReplace) + Logger.Error("ReplacePkg", FILE_NOT_FOUND, + ST.ERR_REPLACE_DIST_NOT_FOUND % Opt.PackFileT= oReplace) =20 Opt.PackFileToReplace =3D AbsPath RunModule =3D ReplacePkg.Main @@ -279,7 +303,8 @@ def Main(): elif Opt.Test_Install_Distribution_Package_Files: for Dist in Opt.Test_Install_Distribution_Package_Files: if not Dist.endswith('.dist'): - Logger.Error("TestInstall", FILE_TYPE_MISMATCH, ExtraD= ata=3DST.ERR_DIST_EXT_ERROR % Dist) + Logger.Error("TestInstall", FILE_TYPE_MISMATCH, + ExtraData=3DST.ERR_DIST_EXT_ERROR % Dist) =20 setattr(Opt, 'DistFiles', Opt.Test_Install_Distribution_Packag= e_Files) RunModule =3D TestInstall.Main @@ -292,7 +317,7 @@ def Main(): except FatalError as XExcept: ReturnCode =3D XExcept.args[0] if Logger.GetLevel() <=3D Logger.DEBUG_9: - Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) += \ + Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc()) finally: try: @@ -313,7 +338,7 @@ def Main(): =20 return ReturnCode =20 -## GetFullPathDist +# GetFullPathDist # # This function will check DistFile existence, if not absolute path, then= try current working directory, # then $(WORKSPACE),and return the AbsPath. If file doesn't find, then re= turn None @@ -322,6 +347,8 @@ def Main(): # @param WorkspaceDir: Workspace Directory # @return AbsPath: The Absolute path of the distribution file if exi= sted, None else # + + def GetFullPathDist(DistFile, WorkspaceDir): if os.path.isabs(DistFile): if not (os.path.exists(DistFile) and os.path.isfile(DistFile)): @@ -337,6 +364,7 @@ def GetFullPathDist(DistFile, WorkspaceDir): =20 return AbsPath =20 + if __name__ =3D=3D '__main__': RETVAL =3D Main() # diff --git a/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest= .py b/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py index dc67dc615a44..249219fbdcd7 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contain unit test for CommentParsing # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -34,6 +34,8 @@ from Library.Misc import CreateDirectory # # Test _GetHelpStr # + + class _GetHelpStrTest(unittest.TestCase): def setUp(self): pass @@ -507,6 +509,8 @@ Guid1|FFE1 # # Test GenProtocolPPiSections # + + class GenProtocolPPiSectionsTest(unittest.TestCase): def setUp(self): pass @@ -536,18 +540,18 @@ class GenProtocolPPiSectionsTest(unittest.TestCase): return Object =20 # Usage Notify Help INF Comment - #1 UNDEFINED true Present ## UNDEFINED ## NOTIFY # Help - #2 UNDEFINED true Not Present ## UNDEFINED ## NOTIFY - #3 UNDEFINED false Present ## UNDEFINED # Help - #4 UNDEFINED false Not Present ## UNDEFINED - #5 UNDEFINED Not Present Present # Help - #6 UNDEFINED Not Present Not Present - #7 Other true Present ## Other ## NOTIFY # Help - #8 Other true Not Present ## Other ## NOTIFY - #9 Other false Present ## Other # Help - #A Other false Not Present ## Other - #B Other Not Present Present ## Other # Help - #C Other Not Present Not Present ## Other + # 1 UNDEFINED true Present ## UNDEFINED ## NOTIFY # Help + # 2 UNDEFINED true Not Present ## UNDEFINED ## NOTIFY + # 3 UNDEFINED false Present ## UNDEFINED # Help + # 4 UNDEFINED false Not Present ## UNDEFINED + # 5 UNDEFINED Not Present Present # Help + # 6 UNDEFINED Not Present Not Present + # 7 Other true Present ## Other ## NOTIFY # Help + # 8 Other true Not Present ## Other ## NOTIFY + # 9 Other false Present ## Other # Help + # A Other false Not Present ## Other + # B Other Not Present Present ## Other # Help + # C Other Not Present Not Present ## Other =20 def testNormalCase1(self): ObjectList =3D [] @@ -560,10 +564,9 @@ class GenProtocolPPiSectionsTest(unittest.TestCase): HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help''' @@ -572,10 +575,9 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help''' IsProtocol =3D False ObjectList =3D [] Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Ppis] Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help''' @@ -592,10 +594,9 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## UNDEFINED ## NOTIFY''' @@ -612,10 +613,9 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY''' HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## UNDEFINED # Help''' @@ -632,10 +632,9 @@ Guid1|FFE1 ## UNDEFINED # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## UNDEFINED''' @@ -652,10 +651,9 @@ Guid1|FFE1 ## UNDEFINED''' HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 # Help''' @@ -672,10 +670,9 @@ Guid1|FFE1 # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1''' @@ -692,10 +689,9 @@ Guid1|FFE1''' HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES ## NOTIFY # Help''' @@ -712,10 +708,9 @@ Guid1|FFE1 ## PRODUCES ## NOTIFY # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES ## NOTIFY''' @@ -732,10 +727,9 @@ Guid1|FFE1 ## PRODUCES ## NOTIFY''' HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES # Help''' @@ -752,10 +746,9 @@ Guid1|FFE1 ## PRODUCES # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES''' @@ -772,10 +765,9 @@ Guid1|FFE1 ## PRODUCES''' HelpStr =3D 'Help' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES # Help''' @@ -792,10 +784,9 @@ Guid1|FFE1 ## PRODUCES # Help''' HelpStr =3D '' IsProtocol =3D True Object =3D self.ObjectFactory(CName, FFE, Usage, Notify, - HelpStr, IsProtocol) + HelpStr, IsProtocol) ObjectList.append(Object) =20 - Result =3D GenProtocolPPiSections(ObjectList, IsProtocol) Expected =3D '''[Protocols] Guid1|FFE1 ## PRODUCES''' @@ -804,6 +795,8 @@ Guid1|FFE1 ## PRODUCES''' # # Test GenPcdSections # + + class GenPcdSectionsTest(unittest.TestCase): def setUp(self): pass @@ -832,12 +825,11 @@ class GenPcdSectionsTest(unittest.TestCase): =20 return Object =20 - # Usage Help INF Comment - #1 UNDEFINED Present # Help - #2 UNDEFINED Not Present - #3 Other Present ## Other # Help - #4 Other Not Present ## Other + # 1 UNDEFINED Present # Help + # 2 UNDEFINED Not Present + # 3 Other Present ## Other # Help + # 4 Other Not Present ## Other =20 def testNormalCase1(self): ObjectList =3D [] @@ -1244,7 +1236,6 @@ class GenHobSectionsTest(unittest.TestCase): Usage =3D 'UNDEFINED' Str =3D '\nNew Stack HoB' =20 - Object =3D self.ObjectFactory(SupArchList, Type, Usage, Str) ObjectList.append(Object) =20 @@ -1266,7 +1257,6 @@ class GenHobSectionsTest(unittest.TestCase): Usage =3D 'UNDEFINED' Str =3D '\nNew Stack HoB\n\nTail Comment' =20 - Object =3D self.ObjectFactory(SupArchList, Type, Usage, Str) ObjectList.append(Object) =20 @@ -1290,7 +1280,6 @@ class GenHobSectionsTest(unittest.TestCase): Usage =3D 'UNDEFINED' Str =3D '\n\n' =20 - Object =3D self.ObjectFactory(SupArchList, Type, Usage, Str) ObjectList.append(Object) =20 @@ -1372,6 +1361,8 @@ class GenHobSectionsTest(unittest.TestCase): # # Test GenGenericCommentF # + + class GenGenericCommentFTest(unittest.TestCase): def setUp(self): pass @@ -1409,6 +1400,7 @@ class GenGenericCommentFTest(unittest.TestCase): Expected =3D '# coment line 1\n# coment line 2\n' self.assertEqual(Result, Expected) =20 + if __name__ =3D=3D '__main__': Logger.Initialize() unittest.main() diff --git a/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py= b/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py index 4a3f6db5e3b2..1f31c96e518b 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contain unit test for CommentParsing # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -9,9 +9,9 @@ import unittest =20 import Logger.Log as Logger from Library.CommentParsing import ParseHeaderCommentSection, \ - ParseGenericComment, \ - ParseDecPcdGenericComment, \ - ParseDecPcdTailComment + ParseGenericComment, \ + ParseDecPcdGenericComment, \ + ParseDecPcdTailComment from Library.CommentParsing import _IsCopyrightLine from Library.StringUtils import GetSplitValueList from Library.DataType import TAB_SPACE_SPLIT @@ -20,6 +20,8 @@ from Library.DataType import TAB_LANGUAGE_EN_US # # Test ParseHeaderCommentSection # + + class ParseHeaderCommentSectionTest(unittest.TestCase): def setUp(self): pass @@ -32,7 +34,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase1(self): TestCommentLines1 =3D \ - '''# License1 + '''# License1 # License2 # ## @file @@ -74,7 +76,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase2(self): TestCommentLines2 =3D \ - ''' # License1 + ''' # License1 # License2 # ## @file @@ -110,14 +112,14 @@ class ParseHeaderCommentSectionTest(unittest.TestCase= ): ExpectedLicense =3D 'License1\nLicense2' self.assertEqual(License, ExpectedLicense) =20 - # # Normal case2: have license/copyright/license above @file, # but no abstract/description # + def testNormalCase3(self): TestCommentLines3 =3D \ - ''' # License1 + ''' # License1 # License2 # ## @file @@ -160,7 +162,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase4(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstract # @@ -202,7 +204,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase5(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstract # @@ -248,7 +250,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase6(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstract # @@ -296,7 +298,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase7(self): TestCommentLines =3D \ - ''' + ''' ## @file # # Description @@ -343,7 +345,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testNormalCase8(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstact # @@ -383,7 +385,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testErrorCase1(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstract # @@ -410,7 +412,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # def testErrorCase2(self): TestCommentLines =3D \ - ''' + ''' ## @file # Abstract # @@ -437,6 +439,8 @@ class ParseHeaderCommentSectionTest(unittest.TestCase): # # Test ParseGenericComment # + + class ParseGenericCommentTest(unittest.TestCase): def setUp(self): pass @@ -449,7 +453,7 @@ class ParseGenericCommentTest(unittest.TestCase): # def testNormalCase1(self): TestCommentLines =3D \ - '''# hello world''' + '''# hello world''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -458,7 +462,8 @@ class ParseGenericCommentTest(unittest.TestCase): LineNum +=3D 1 TestCommentLinesList.append((Comment, LineNum)) =20 - HelptxtObj =3D ParseGenericComment(TestCommentLinesList, 'testNorm= alCase1') + HelptxtObj =3D ParseGenericComment( + TestCommentLinesList, 'testNormalCase1') self.failIf(not HelptxtObj) self.assertEqual(HelptxtObj.GetString(), 'hello world') self.assertEqual(HelptxtObj.GetLang(), TAB_LANGUAGE_EN_US) @@ -468,7 +473,7 @@ class ParseGenericCommentTest(unittest.TestCase): # def testNormalCase2(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") @@ -478,7 +483,8 @@ class ParseGenericCommentTest(unittest.TestCase): LineNum +=3D 1 TestCommentLinesList.append((Comment, LineNum)) =20 - HelptxtObj =3D ParseGenericComment(TestCommentLinesList, 'testNorm= alCase2') + HelptxtObj =3D ParseGenericComment( + TestCommentLinesList, 'testNormalCase2') self.failIf(not HelptxtObj) self.assertEqual(HelptxtObj.GetString(), 'hello world\n' + 'second line') @@ -489,7 +495,7 @@ class ParseGenericCommentTest(unittest.TestCase): # def testNormalCase3(self): TestCommentLines =3D \ - '''## hello world + '''## hello world This is not comment line''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") @@ -499,7 +505,8 @@ class ParseGenericCommentTest(unittest.TestCase): LineNum +=3D 1 TestCommentLinesList.append((Comment, LineNum)) =20 - HelptxtObj =3D ParseGenericComment(TestCommentLinesList, 'testNorm= alCase3') + HelptxtObj =3D ParseGenericComment( + TestCommentLinesList, 'testNormalCase3') self.failIf(not HelptxtObj) self.assertEqual(HelptxtObj.GetString(), 'hello world\n\n') @@ -508,6 +515,8 @@ class ParseGenericCommentTest(unittest.TestCase): # # Test ParseDecPcdGenericComment # + + class ParseDecPcdGenericCommentTest(unittest.TestCase): def setUp(self): pass @@ -520,7 +529,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # def testNormalCase1(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") @@ -537,13 +546,13 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase= ): self.assertEqual(HelpTxt, 'hello world\n' + 'second line') =20 - # # Normal case2: comments with valid list # + def testNormalCase2(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line # @ValidList 1, 2, 3 # other line''' @@ -562,8 +571,8 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): self.assertEqual(HelpTxt, 'hello world\n' + 'second line\n' + 'other line') ExpectedList =3D GetSplitValueList('1 2 3', TAB_SPACE_SPLIT) - ActualList =3D [item for item in \ - GetSplitValueList(PcdErr.GetValidValue(), TAB_SPACE_SPLIT) if = item] + ActualList =3D [item for item in + GetSplitValueList(PcdErr.GetValidValue(), TAB_SPACE_= SPLIT) if item] self.assertEqual(ExpectedList, ActualList) self.failIf(PcdErr.GetExpression()) self.failIf(PcdErr.GetValidValueRange()) @@ -573,7 +582,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # def testNormalCase3(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line # @ValidRange LT 1 AND GT 2 # other line''' @@ -600,7 +609,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # def testNormalCase4(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line # @Expression LT 1 AND GT 2 # other line''' @@ -627,7 +636,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # def testNormalCase5(self): TestCommentLines =3D \ - '''# @Expression LT 1 AND GT 2''' + '''# @Expression LT 1 AND GT 2''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -649,7 +658,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # def testNormalCase6(self): TestCommentLines =3D \ - '''#''' + '''#''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -663,15 +672,14 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase= ): self.assertEqual(HelpTxt, '\n') self.failIf(PcdErr) =20 - - # # Error case1: comments with both expression and valid list, use later # ignore the former and with a warning message # + def testErrorCase1(self): TestCommentLines =3D \ - '''## hello world + '''## hello world # second line # @ValidList 1, 2, 3 # @Expression LT 1 AND GT 2 @@ -692,6 +700,8 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase): # # Test ParseDecPcdTailComment # + + class ParseDecPcdTailCommentTest(unittest.TestCase): def setUp(self): pass @@ -704,7 +714,7 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): # def testNormalCase1(self): TestCommentLines =3D \ - '''## #hello world''' + '''## #hello world''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -725,7 +735,7 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): # def testNormalCase2(self): TestCommentLines =3D \ - '''## BASE #hello world''' + '''## BASE #hello world''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -748,7 +758,7 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): # def testNormalCase3(self): TestCommentLines =3D \ - '''## BASE UEFI_APPLICATION #hello world''' + '''## BASE UEFI_APPLICATION #hello world''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -771,7 +781,7 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): # def testNormalCase4(self): TestCommentLines =3D \ - '''## BASE UEFI_APPLICATION''' + '''## BASE UEFI_APPLICATION''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -792,7 +802,7 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): # def testNormalCase5(self): TestCommentLines =3D \ - ''' # 1 =3D 128MB, 2 =3D 256MB, 3 =3D MAX''' + ''' # 1 =3D 128MB, 2 =3D 256MB, 3 =3D MAX''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -808,14 +818,14 @@ class ParseDecPcdTailCommentTest(unittest.TestCase): '1 =3D 128MB, 2 =3D 256MB, 3 =3D MAX') self.failIf(SupModeList) =20 - # # Error case2: comments with supModList contains valid and invalid # module type # + def testErrorCase2(self): TestCommentLines =3D \ - '''## BASE INVALID_MODULE_TYPE #hello world''' + '''## BASE INVALID_MODULE_TYPE #hello world''' =20 CommentList =3D GetSplitValueList(TestCommentLines, "\n") LineNum =3D 0 @@ -912,6 +922,7 @@ class _IsCopyrightLineTest(unittest.TestCase): Result =3D _IsCopyrightLine(Line) self.failIf(Result) =20 + if __name__ =3D=3D '__main__': Logger.Initialize() unittest.main() diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py b/BaseTo= ols/Source/Python/UPT/UnitTest/DecParserTest.py index b9f7dfe52a6d..01adb668d4bc 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contain unit test for DecParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -20,6 +20,8 @@ from Library.ParserValidate import IsValidCFormatGuid # # Test tool function # + + def TestToolFuncs(): assert IsValidCArray('{0x1, 0x23}') =20 @@ -46,8 +48,11 @@ def TestToolFuncs(): assert not IsValidPcdDatum('UNKNOWNTYPE', '0xabc')[0] assert not IsValidPcdDatum('UINT8', 'not number')[0] =20 - assert( IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66= , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }}')) - assert( not IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, = 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }} 0xaa')) + assert(IsValidCFormatGuid( + '{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0= xaf, 0x48, 0xce }}')) + assert(not IsValidCFormatGuid( + '{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0= xaf, 0x48, 0xce }} 0xaa')) + =20 def TestTemplate(TestString, TestFunc): Path =3D os.path.join(os.getcwd(), 'test.dec') @@ -75,6 +80,8 @@ def TestTemplate(TestString, TestFunc): # This function test right syntax DEC file # @retval: parser object # + + def TestOK(Path, TestString): try: Parser =3D Dec(Path) @@ -84,6 +91,8 @@ def TestOK(Path, TestString): =20 # This function test wrong syntax DEC file # if parser checked wrong syntax, exception thrown and it's expected result + + def TestError(Path, TestString): try: Dec(Path) @@ -92,6 +101,7 @@ def TestError(Path, TestString): return True raise 'Bug!!! Wrong syntax in DEC file, but passed by DEC parser!!\n' = + TestString =20 + def TestDecDefine(): TestString =3D ''' [Defines] @@ -119,6 +129,7 @@ def TestDecDefine(): ''' assert TestTemplate(TestString, TestError) =20 + def TestDecInclude(): TestString =3D ''' [Defines] @@ -163,6 +174,7 @@ def TestDecInclude(): =20 os.removedirs('Include/Ia32') =20 + def TestDecGuidPpiProtocol(): TestString =3D ''' [Defines] @@ -205,6 +217,7 @@ def TestDecGuidPpiProtocol(): assert Items[0].GuidCName =3D=3D 'gEfiPeiMasterBootModePpiGuid' assert Items[0].GuidCValue =3D=3D '{ 0x7408d748, 0xfc8c, 0x4ee6, {0x92= , 0x88, 0xc4, 0xbe, 0xc0, 0x92, 0xa4, 0x10 } }' =20 + def TestDecPcd(): TestString =3D ''' [Defines] @@ -246,6 +259,7 @@ def TestDecPcd(): assert len(Items) =3D=3D 4 assert len(Obj.GetPcdsByType('PcdsPatchableInModule')) =3D=3D 2 =20 + def TestDecUserExtension(): TestString =3D ''' [Defines] @@ -264,6 +278,7 @@ def TestDecUserExtension(): assert len(Items[0].ArchAndModuleType) =3D=3D 1 assert ['MyID', '"TestString"', 'IA32'] in Items[0].ArchAndModuleType =20 + if __name__ =3D=3D '__main__': import Logger.Logger Logger.Logger.Initialize() @@ -275,5 +290,3 @@ if __name__ =3D=3D '__main__': unittest.FunctionTestCase(TestDecUserExtension).runTest() =20 print('All tests passed...') - - diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py b/Ba= seTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py index bac127f8e2ac..22d4db05e2e0 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contain unit test for DecParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -24,6 +24,8 @@ from Object.Parser.DecObject import _DecComments # # Test CleanString # + + class CleanStringTestCase(unittest.TestCase): def testCleanString(self): Line, Comment =3D CleanString('') @@ -43,13 +45,16 @@ class CleanStringTestCase(unittest.TestCase): self.assertEqual(Comment, '# and comment') =20 def testCleanStringCpp(self): - Line, Comment =3D CleanString('line // and comment', AllowCppStyle= Comment =3D True) + Line, Comment =3D CleanString( + 'line // and comment', AllowCppStyleComment=3DTrue) self.assertEqual(Line, 'line') self.assertEqual(Comment, '# and comment') =20 # # Test _DecBase._MacroParser function # + + class MacroParserTestCase(unittest.TestCase): def setUp(self): self.dec =3D _DecBase(FileContent('dummy', [])) @@ -61,7 +66,8 @@ class MacroParserTestCase(unittest.TestCase): =20 def testErrorMacro1(self): # Raise fatal error, macro name must be upper case letter - self.assertRaises(FatalError, self.dec._MacroParser, 'DEFINE not_u= pper_case =3D test2') + self.assertRaises(FatalError, self.dec._MacroParser, + 'DEFINE not_upper_case =3D test2') =20 def testErrorMacro2(self): # No macro name given @@ -70,6 +76,8 @@ class MacroParserTestCase(unittest.TestCase): # # Test _DecBase._TryBackSlash function # + + class TryBackSlashTestCase(unittest.TestCase): def setUp(self): Content =3D [ @@ -92,34 +100,43 @@ class TryBackSlashTestCase(unittest.TestCase): # # Right case, assert return values # - ConcatLine, CommentList =3D self.dec._TryBackSlash(self.dec._RawDa= ta.GetNextLine(), []) + ConcatLine, CommentList =3D self.dec._TryBackSlash( + self.dec._RawData.GetNextLine(), []) self.assertEqual(ConcatLine, 'test no backslash') self.assertEqual(CommentList, []) =20 - ConcatLine, CommentList =3D self.dec._TryBackSlash(self.dec._RawDa= ta.GetNextLine(), []) + ConcatLine, CommentList =3D self.dec._TryBackSlash( + self.dec._RawData.GetNextLine(), []) self.assertEqual(CommentList, []) - self.assertEqual(ConcatLine, 'test with backslash continue second = line') + self.assertEqual( + ConcatLine, 'test with backslash continue second line') =20 # # Error cases, assert raise exception # - self.assertRaises(FatalError, self.dec._TryBackSlash, self.dec._Ra= wData.GetNextLine(), []) - self.assertRaises(FatalError, self.dec._TryBackSlash, self.dec._Ra= wData.GetNextLine(), []) + self.assertRaises(FatalError, self.dec._TryBackSlash, + self.dec._RawData.GetNextLine(), []) + self.assertRaises(FatalError, self.dec._TryBackSlash, + self.dec._RawData.GetNextLine(), []) =20 # # Test _DecBase.Parse function # + + class DataItem(_DecComments): def __init__(self): _DecComments.__init__(self) self.String =3D '' =20 + class Data(_DecComments): def __init__(self): _DecComments.__init__(self) # List of DataItem self.ItemList =3D [] =20 + class TestInner(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -137,6 +154,7 @@ class TestInner(_DecBase): def _TailCommentStrategy(self, Comment): return Comment.find('@comment') !=3D -1 =20 + class TestTop(_DecBase): def __init__(self, RawData): _DecBase.__init__(self, RawData) @@ -153,13 +171,14 @@ class TestTop(_DecBase): self.ItemObject.append(TestParser.ItemObject) return TestParser.ItemObject =20 + class ParseTestCase(unittest.TestCase): def setUp(self): pass =20 def testParse(self): Content =3D \ - '''# Top comment + '''# Top comment [TOP] # sub1 head comment (test item has both head and tail comment) # sub1 tail comment @@ -187,7 +206,8 @@ class ParseTestCase(unittest.TestCase): self.assertEqual(len(data.ItemList), 3) =20 dataitem =3D data.ItemList[0] - self.assertEqual(dataitem.String, '(test item has both head and ta= il comment)') + self.assertEqual( + dataitem.String, '(test item has both head and tail comment)') # Comment content self.assertEqual(dataitem._HeadComment[0][0], '# sub1 head comment= ') self.assertEqual(dataitem._TailComment[0][0], '# sub1 tail comment= ') @@ -196,10 +216,12 @@ class ParseTestCase(unittest.TestCase): self.assertEqual(dataitem._TailComment[0][1], 4) =20 dataitem =3D data.ItemList[1] - self.assertEqual(dataitem.String, '(test item has head and special= tail comment)') + self.assertEqual( + dataitem.String, '(test item has head and special tail comment= )') # Comment content self.assertEqual(dataitem._HeadComment[0][0], '# sub2 head comment= ') - self.assertEqual(dataitem._TailComment[0][0], '# @comment test Tai= lCommentStrategy branch') + self.assertEqual( + dataitem._TailComment[0][0], '# @comment test TailCommentStrat= egy branch') # Comment line number self.assertEqual(dataitem._HeadComment[0][1], 5) self.assertEqual(dataitem._TailComment[0][1], 7) @@ -225,6 +247,8 @@ class ParseTestCase(unittest.TestCase): # # Test _DecDefine._ParseItem # + + class DecDefineTestCase(unittest.TestCase): def GetObj(self, Content): Obj =3D _DecDefine(FileContent('dummy', Content.splitlines())) @@ -251,6 +275,8 @@ class DecDefineTestCase(unittest.TestCase): # # Test _DecLibraryclass._ParseItem # + + class DecLibraryTestCase(unittest.TestCase): def GetObj(self, Content): Obj =3D _DecLibraryclass(FileContent('dummy', Content.splitlines()= )) @@ -266,7 +292,8 @@ class DecLibraryTestCase(unittest.TestCase): self.assertRaises(FatalError, obj._ParseItem) =20 def testLibclassNaming(self): - obj =3D self.GetObj('lowercase_efiRuntimeLib|Include/Library/UefiR= untimeLib.h') + obj =3D self.GetObj( + 'lowercase_efiRuntimeLib|Include/Library/UefiRuntimeLib.h') self.assertRaises(FatalError, obj._ParseItem) =20 def testLibclassExt(self): @@ -280,6 +307,8 @@ class DecLibraryTestCase(unittest.TestCase): # # Test _DecPcd._ParseItem # + + class DecPcdTestCase(unittest.TestCase): def GetObj(self, Content): Obj =3D _DecPcd(FileContent('dummy', Content.splitlines())) @@ -288,7 +317,8 @@ class DecPcdTestCase(unittest.TestCase): return Obj =20 def testOK(self): - item =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDis= able|FALSE|BOOLEAN|0x0000000d')._ParseItem() + item =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEA= N|0x0000000d')._ParseItem() self.assertEqual(item.TokenSpaceGuidCName, 'gEfiMdePkgTokenSpaceGu= id') self.assertEqual(item.TokenCName, 'PcdComponentNameDisable') self.assertEqual(item.DefaultValue, 'FALSE') @@ -296,31 +326,39 @@ class DecPcdTestCase(unittest.TestCase): self.assertEqual(item.TokenValue, '0x0000000d') =20 def testNoCvar(self): - obj =3D self.GetObj('123ai.PcdComponentNameDisable|FALSE|BOOLEAN|0= x0000000d') + obj =3D self.GetObj( + '123ai.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d') self.assertRaises(FatalError, obj._ParseItem) =20 def testSplit(self): - obj =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisa= ble FALSE|BOOLEAN|0x0000000d') + obj =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable FALSE|BOOLEA= N|0x0000000d') self.assertRaises(FatalError, obj._ParseItem) =20 - obj =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisa= ble|FALSE|BOOLEAN|0x0000000d | abc') + obj =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEA= N|0x0000000d | abc') self.assertRaises(FatalError, obj._ParseItem) =20 def testUnknownType(self): - obj =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisa= ble|FALSE|unknown|0x0000000d') + obj =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|unknow= n|0x0000000d') self.assertRaises(FatalError, obj._ParseItem) =20 def testVoid(self): - obj =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisa= ble|abc|VOID*|0x0000000d') + obj =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|abc|VOID*|0x= 0000000d') self.assertRaises(FatalError, obj._ParseItem) =20 def testUINT(self): - obj =3D self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisa= ble|0xabc|UINT8|0x0000000d') + obj =3D self.GetObj( + 'gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|0xabc|UINT8|= 0x0000000d') self.assertRaises(FatalError, obj._ParseItem) =20 # # Test _DecInclude._ParseItem # + + class DecIncludeTestCase(unittest.TestCase): # # Test code to be added @@ -330,6 +368,8 @@ class DecIncludeTestCase(unittest.TestCase): # # Test _DecGuid._ParseItem # + + class DecGuidTestCase(unittest.TestCase): def GetObj(self, Content): Obj =3D _DecGuid(FileContent('dummy', Content.splitlines())) @@ -341,12 +381,15 @@ class DecGuidTestCase(unittest.TestCase): item =3D self.GetObj('gEfiIpSecProtocolGuid=3D{ 0xdfb386f7, 0xe100= , 0x43ad,' ' {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x= 12 }}')._ParseItem() self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid') - self.assertEqual(item.GuidCValue, '{ 0xdfb386f7, 0xe100, 0x43ad, {= 0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}') + self.assertEqual( + item.GuidCValue, '{ 0xdfb386f7, 0xe100, 0x43ad, {0x9c, 0x9a, 0= xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}') =20 def testGuidString(self): - item =3D self.GetObj('gEfiIpSecProtocolGuid=3D1E73767F-8F52-4603-A= EB4-F29B510B6766')._ParseItem() + item =3D self.GetObj( + 'gEfiIpSecProtocolGuid=3D1E73767F-8F52-4603-AEB4-F29B510B6766'= )._ParseItem() self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid') - self.assertEqual(item.GuidCValue, '1E73767F-8F52-4603-AEB4-F29B510= B6766') + self.assertEqual( + item.GuidCValue, '1E73767F-8F52-4603-AEB4-F29B510B6766') =20 def testNoValue1(self): obj =3D self.GetObj('gEfiIpSecProtocolGuid') @@ -363,10 +406,13 @@ class DecGuidTestCase(unittest.TestCase): # # Test Dec.__init__ # + + class DecDecInitTestCase(unittest.TestCase): def testNoDecFile(self): self.assertRaises(FatalError, Dec, 'No_Such_File') =20 + class TmpFile: def __init__(self, File): self.File =3D File @@ -388,11 +434,13 @@ class TmpFile: # # Test Dec._UserExtentionSectionParser # + + class DecUESectionTestCase(unittest.TestCase): def setUp(self): self.File =3D TmpFile('test.dec') self.File.Write( -'''[userextensions.intel."myid"] + '''[userextensions.intel."myid"] [userextensions.intel."myid".IA32] [userextensions.intel."myid".IA32,] [userextensions.intel."myid] @@ -409,7 +457,8 @@ class DecUESectionTestCase(unittest.TestCase): dec._RawData.CurrentLine =3D CleanString(dec._RawData.GetNextLine(= ))[0] dec._UserExtentionSectionParser() self.assertEqual(len(dec._RawData.CurrentScope), 1) - self.assertEqual(dec._RawData.CurrentScope[0][0], 'userextensions'= .upper()) + self.assertEqual( + dec._RawData.CurrentScope[0][0], 'userextensions'.upper()) self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel') self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"') self.assertEqual(dec._RawData.CurrentScope[0][3], 'COMMON') @@ -418,7 +467,8 @@ class DecUESectionTestCase(unittest.TestCase): dec._RawData.CurrentLine =3D CleanString(dec._RawData.GetNextLine(= ))[0] dec._UserExtentionSectionParser() self.assertEqual(len(dec._RawData.CurrentScope), 1) - self.assertEqual(dec._RawData.CurrentScope[0][0], 'userextensions'= .upper()) + self.assertEqual( + dec._RawData.CurrentScope[0][0], 'userextensions'.upper()) self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel') self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"') self.assertEqual(dec._RawData.CurrentScope[0][3], 'IA32') @@ -434,11 +484,13 @@ class DecUESectionTestCase(unittest.TestCase): # # Test Dec._SectionHeaderParser # + + class DecSectionTestCase(unittest.TestCase): def setUp(self): self.File =3D TmpFile('test.dec') self.File.Write( -'''[no section start or end + '''[no section start or end [,] # empty sub-section [unknow_section_name] [Includes.IA32.other] # no third one @@ -446,7 +498,7 @@ class DecSectionTestCase(unittest.TestCase): [Includes.IA32, Includes.IA32] [Includes, Includes.IA32] # common cannot be with other arch [Includes.IA32, PcdsFeatureFlag] # different section name -''' ) +''') =20 def tearDown(self): self.File.Remove() @@ -457,7 +509,7 @@ class DecSectionTestCase(unittest.TestCase): dec._RawData.CurrentLine =3D CleanString(dec._RawData.GetNextLine(= ))[0] self.assertRaises(FatalError, dec._SectionHeaderParser) =20 - #[,] # empty sub-section + # [,] # empty sub-section dec._RawData.CurrentLine =3D CleanString(dec._RawData.GetNextLine(= ))[0] self.assertRaises(FatalError, dec._SectionHeaderParser) =20 @@ -491,11 +543,13 @@ class DecSectionTestCase(unittest.TestCase): # # Test Dec._ParseDecComment # + + class DecDecCommentTestCase(unittest.TestCase): def testDecHeadComment(self): File =3D TmpFile('test.dec') File.Write( - '''# abc + '''# abc ##''') dec =3D Dec('test.dec', False) dec.ParseDecComment() @@ -509,7 +563,7 @@ class DecDecCommentTestCase(unittest.TestCase): def testNoDoubleComment(self): File =3D TmpFile('test.dec') File.Write( - '''# abc + '''# abc # [section_start]''') dec =3D Dec('test.dec', False) @@ -521,8 +575,8 @@ class DecDecCommentTestCase(unittest.TestCase): self.assertEqual(dec._HeadComment[1][1], 2) File.Remove() =20 + if __name__ =3D=3D '__main__': import Logger.Logger Logger.Logger.Initialize() unittest.main() - diff --git a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py b= /BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py index 12e3045f3753..4b707b960fc1 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py @@ -1,4 +1,4 @@ -## @file +# @file # This file contain unit test for Test [Binary] section part of InfParser # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -23,14 +23,14 @@ import Library.GlobalData as Global # Only has 1 element, binary item Type # SectionStringsCommonItem1 =3D \ -""" + """ GUID """ # # Have 2 elements, binary item Type and FileName # SectionStringsCommonItem2 =3D \ -""" + """ GUID | Test/Test.guid """ =20 @@ -38,7 +38,7 @@ GUID | Test/Test.guid # Have 3 elements, Type | FileName | Target | Family | TagName | FeatureFl= agExp # SectionStringsCommonItem3 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG """ =20 @@ -47,7 +47,7 @@ GUID | Test/Test.guid | DEBUG # Target with MACRO defined in [Define] section # SectionStringsCommonItem4 =3D \ -""" + """ GUID | Test/Test.guid | $(TARGET) """ =20 @@ -56,7 +56,7 @@ GUID | Test/Test.guid | $(TARGET) # FileName with MACRO defined in [Binary] section # SectionStringsCommonItem5 =3D \ -""" + """ DEFINE BINARY_FILE_PATH =3D Test GUID | $(BINARY_FILE_PATH)/Test.guid | $(TARGET) """ @@ -65,7 +65,7 @@ GUID | $(BINARY_FILE_PATH)/Test.guid | $(TARGET) # Have 4 elements, Type | FileName | Target | Family # SectionStringsCommonItem6 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG | * """ =20 @@ -73,7 +73,7 @@ GUID | Test/Test.guid | DEBUG | * # Have 4 elements, Type | FileName | Target | Family # SectionStringsCommonItem7 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG | MSFT """ =20 @@ -81,7 +81,7 @@ GUID | Test/Test.guid | DEBUG | MSFT # Have 5 elements, Type | FileName | Target | Family | TagName # SectionStringsCommonItem8 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG | MSFT | TEST """ =20 @@ -89,7 +89,7 @@ GUID | Test/Test.guid | DEBUG | MSFT | TEST # Have 6 elements, Type | FileName | Target | Family | TagName | FFE # SectionStringsCommonItem9 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG | MSFT | TEST | TRUE """ =20 @@ -98,28 +98,27 @@ GUID | Test/Test.guid | DEBUG | MSFT | TEST | TRUE # Test wrong format # SectionStringsCommonItem10 =3D \ -""" + """ GUID | Test/Test.guid | DEBUG | MSFT | TEST | TRUE | OVERFLOW """ =20 #-------------end of common binary item test input------------------------= ----# =20 =20 - #-------------start of VER type binary item test input--------------------= ----# =20 # # Has 1 element, error format # SectionStringsVerItem1 =3D \ -""" + """ VER """ # # Have 5 elements, error format(Maximum elements amount is 4) # SectionStringsVerItem2 =3D \ -""" + """ VER | Test/Test.ver | * | TRUE | OverFlow """ =20 @@ -127,7 +126,7 @@ VER | Test/Test.ver | * | TRUE | OverFlow # Have 2 elements, Type | FileName # SectionStringsVerItem3 =3D \ -""" + """ VER | Test/Test.ver """ =20 @@ -135,7 +134,7 @@ VER | Test/Test.ver # Have 3 elements, Type | FileName | Target # SectionStringsVerItem4 =3D \ -""" + """ VER | Test/Test.ver | DEBUG """ =20 @@ -143,7 +142,7 @@ VER | Test/Test.ver | DEBUG # Have 4 elements, Type | FileName | Target | FeatureFlagExp # SectionStringsVerItem5 =3D \ -""" + """ VER | Test/Test.ver | DEBUG | TRUE """ =20 @@ -151,7 +150,7 @@ VER | Test/Test.ver | DEBUG | TRUE # Exist 2 VER items, both opened. # SectionStringsVerItem6 =3D \ -""" + """ VER | Test/Test.ver | * | TRUE VER | Test/Test2.ver | * | TRUE """ @@ -161,7 +160,7 @@ VER | Test/Test2.ver | * | TRUE # Exist 2 VER items, only 1 opened. # SectionStringsVerItem7 =3D \ -""" + """ VER | Test/Test.ver | * | TRUE VER | Test/Test2.ver | * | FALSE """ @@ -175,19 +174,19 @@ VER | Test/Test2.ver | * | FALSE # Test only one UI section can exist # SectionStringsUiItem1 =3D \ -""" + """ UI | Test/Test.ui | * | TRUE UI | Test/Test2.ui | * | TRUE """ =20 SectionStringsUiItem2 =3D \ -""" + """ UI | Test/Test.ui | * | TRUE SEC_UI | Test/Test2.ui | * | TRUE """ =20 SectionStringsUiItem3 =3D \ -""" + """ UI | Test/Test.ui | * | TRUE UI | Test/Test2.ui | * | FALSE """ @@ -196,14 +195,14 @@ UI | Test/Test2.ui | * | FALSE # Has 1 element, error format # SectionStringsUiItem4 =3D \ -""" + """ UI """ # # Have 5 elements, error format(Maximum elements amount is 4) # SectionStringsUiItem5 =3D \ -""" + """ UI | Test/Test.ui | * | TRUE | OverFlow """ =20 @@ -211,7 +210,7 @@ UI | Test/Test.ui | * | TRUE | OverFlow # Have 2 elements, Type | FileName # SectionStringsUiItem6 =3D \ -""" + """ UI | Test/Test.ui """ =20 @@ -219,7 +218,7 @@ UI | Test/Test.ui # Have 3 elements, Type | FileName | Target # SectionStringsUiItem7 =3D \ -""" + """ UI | Test/Test.ui | DEBUG """ =20 @@ -227,7 +226,7 @@ UI | Test/Test.ui | DEBUG # Have 4 elements, Type | FileName | Target | FeatureFlagExp # SectionStringsUiItem8 =3D \ -""" + """ UI | Test/Test.ui | DEBUG | TRUE """ #---------------end of UI type binary item test input---------------------= ----# @@ -238,6 +237,8 @@ gFileName =3D "BinarySectionTest.inf" ## # Construct SectionString for call section parser usage. # + + def StringToSectionString(String): Lines =3D String.split('\n') LineNo =3D 0 @@ -250,6 +251,7 @@ def StringToSectionString(String): =20 return SectionString =20 + def PrepareTest(String): SectionString =3D StringToSectionString(String) ItemList =3D [] @@ -263,7 +265,7 @@ def PrepareTest(String): # FileName =3D os.path.normpath(os.path.realpath(ValueList[1].st= rip())) try: - TempFile =3D open (FileName, "w") + TempFile =3D open(FileName, "w") TempFile.close() except: print("File Create Error") @@ -277,6 +279,7 @@ def PrepareTest(String): =20 return ItemList =20 + if __name__ =3D=3D '__main__': Logger.Initialize() =20 @@ -290,26 +293,26 @@ if __name__ =3D=3D '__main__': # For All Ui test # UiStringList =3D [ - SectionStringsUiItem1, - SectionStringsUiItem2, - SectionStringsUiItem3, - SectionStringsUiItem4, - SectionStringsUiItem5, - SectionStringsUiItem6, - SectionStringsUiItem7, - SectionStringsUiItem8 - ] + SectionStringsUiItem1, + SectionStringsUiItem2, + SectionStringsUiItem3, + SectionStringsUiItem4, + SectionStringsUiItem5, + SectionStringsUiItem6, + SectionStringsUiItem7, + SectionStringsUiItem8 + ] =20 for Item in UiStringList: Ui =3D PrepareTest(Item) if Item =3D=3D SectionStringsUiItem4 or Item =3D=3D SectionStrings= UiItem5: try: - InfBinariesInstance.SetBinary(Ui =3D Ui, ArchList =3D Arch= List) + InfBinariesInstance.SetBinary(Ui=3DUi, ArchList=3DArchList) except Logger.FatalError: pass else: try: - InfBinariesInstance.SetBinary(Ui =3D Ui, ArchList =3D Arch= List) + InfBinariesInstance.SetBinary(Ui=3DUi, ArchList=3DArchList) except: AllPassedFlag =3D False =20 @@ -317,27 +320,27 @@ if __name__ =3D=3D '__main__': # For All Ver Test # VerStringList =3D [ - SectionStringsVerItem1, - SectionStringsVerItem2, - SectionStringsVerItem3, - SectionStringsVerItem4, - SectionStringsVerItem5, - SectionStringsVerItem6, - SectionStringsVerItem7 - ] + SectionStringsVerItem1, + SectionStringsVerItem2, + SectionStringsVerItem3, + SectionStringsVerItem4, + SectionStringsVerItem5, + SectionStringsVerItem6, + SectionStringsVerItem7 + ] for Item in VerStringList: Ver =3D PrepareTest(Item) if Item =3D=3D SectionStringsVerItem1 or \ Item =3D=3D SectionStringsVerItem2: =20 try: - InfBinariesInstance.SetBinary(Ver =3D Ver, ArchList =3D Ar= chList) + InfBinariesInstance.SetBinary(Ver=3DVer, ArchList=3DArchLi= st) except: pass =20 else: try: - InfBinariesInstance.SetBinary(Ver =3D Ver, ArchList =3D Ar= chList) + InfBinariesInstance.SetBinary(Ver=3DVer, ArchList=3DArchLi= st) except: AllPassedFlag =3D False =20 @@ -345,17 +348,17 @@ if __name__ =3D=3D '__main__': # For All Common Test # CommonStringList =3D [ - SectionStringsCommonItem1, - SectionStringsCommonItem2, - SectionStringsCommonItem3, - SectionStringsCommonItem4, - SectionStringsCommonItem5, - SectionStringsCommonItem6, - SectionStringsCommonItem7, - SectionStringsCommonItem8, - SectionStringsCommonItem9, - SectionStringsCommonItem10 - ] + SectionStringsCommonItem1, + SectionStringsCommonItem2, + SectionStringsCommonItem3, + SectionStringsCommonItem4, + SectionStringsCommonItem5, + SectionStringsCommonItem6, + SectionStringsCommonItem7, + SectionStringsCommonItem8, + SectionStringsCommonItem9, + SectionStringsCommonItem10 + ] =20 for Item in CommonStringList: CommonBin =3D PrepareTest(Item) @@ -363,19 +366,19 @@ if __name__ =3D=3D '__main__': Item =3D=3D SectionStringsCommonItem1: =20 try: - InfBinariesInstance.SetBinary(CommonBinary =3D CommonBin, = ArchList =3D ArchList) + InfBinariesInstance.SetBinary( + CommonBinary=3DCommonBin, ArchList=3DArchList) except: pass =20 else: try: - InfBinariesInstance.SetBinary(Ver =3D Ver, ArchList =3D Ar= chList) + InfBinariesInstance.SetBinary(Ver=3DVer, ArchList=3DArchLi= st) except: print("Test Failed!") AllPassedFlag =3D False =20 - if AllPassedFlag : + if AllPassedFlag: print('All tests passed...') else: print('Some unit test failed!') - diff --git a/BaseTools/Source/Python/UPT/Xml/CommonXml.py b/BaseTools/Sourc= e/Python/UPT/Xml/CommonXml.py index cfadacf4aaaf..d7dc8435d1a2 100644 --- a/BaseTools/Source/Python/UPT/Xml/CommonXml.py +++ b/BaseTools/Source/Python/UPT/Xml/CommonXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a PCD file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -41,6 +41,8 @@ import Library.DataType as DataType ## # ClonedFromXml # + + class ClonedFromXml(object): def __init__(self): self.GUID =3D '' @@ -85,9 +87,11 @@ class CommonDefinesXml(object): pass self.Usage =3D XmlAttribute(Item, 'Usage') self.SupArchList =3D \ - [Arch for Arch in GetSplitValueList(XmlAttribute(Item, 'SupArchLis= t'), DataType.TAB_SPACE_SPLIT) if Arch] + [Arch for Arch in GetSplitValueList(XmlAttribute( + Item, 'SupArchList'), DataType.TAB_SPACE_SPLIT) if Arch] self.SupModList =3D \ - [Mod for Mod in GetSplitValueList(XmlAttribute(Item, 'SupModList')= , DataType.TAB_SPACE_SPLIT) if Mod] + [Mod for Mod in GetSplitValueList(XmlAttribute( + Item, 'SupModList'), DataType.TAB_SPACE_SPLIT) if Mod] self.FeatureFlag =3D ConvertNOTEQToNE(XmlAttribute(Item, 'FeatureF= lag')) =20 def ToXml(self): @@ -95,11 +99,13 @@ class CommonDefinesXml(object): =20 def __str__(self): return "Usage =3D %s SupArchList =3D %s SupModList =3D %s FeatureF= lag =3D %s" \ - % (self.Usage, self.SupArchList, self.SupModList, self.Fea= tureFlag) + % (self.Usage, self.SupArchList, self.SupModList, self.Feature= Flag) =20 ## # PromptXml # + + class PromptXml(object): def __init__(self): self.Prompt =3D '' @@ -115,12 +121,15 @@ class PromptXml(object): if self.Prompt: pass return CreateXmlElement('%s' % Key, Prompt.GetString(), [], [['Lan= g', Prompt.GetLang()]]) + def __str__(self): return "Prompt =3D %s Lang =3D %s" % (self.Prompt, self.Lang) =20 ## # HelpTextXml # + + class HelpTextXml(object): def __init__(self): self.HelpText =3D '' @@ -136,12 +145,15 @@ class HelpTextXml(object): if self.HelpText: pass return CreateXmlElement('%s' % Key, HelpText.GetString(), [], [['L= ang', HelpText.GetLang()]]) + def __str__(self): return "HelpText =3D %s Lang =3D %s" % (self.HelpText, self.Lang) =20 ## # HeaderXml # + + class HeaderXml(object): def __init__(self): self.Name =3D '' @@ -159,26 +171,32 @@ class HeaderXml(object): if IsStandAlongModule: XmlTreeLevel =3D ['DistributionPackage', 'ModuleSurfaceAre= a'] else: - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceAr= ea', 'ModuleSurfaceArea'] - CheckDict =3D {'Header':''} + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'ModuleSurfaceArea'] + CheckDict =3D {'Header': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) self.Name =3D XmlElement(Item, '%s/Name' % Key) - self.BaseName =3D XmlAttribute(XmlNode(Item, '%s/Name' % Key), 'Ba= seName') + self.BaseName =3D XmlAttribute( + XmlNode(Item, '%s/Name' % Key), 'BaseName') self.GUID =3D XmlElement(Item, '%s/GUID' % Key) self.Version =3D XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Ver= sion') =20 for SubItem in XmlList(Item, '%s/Abstract' % Key): HeaderAbstractLang =3D XmlAttribute(SubItem, 'Lang') - self.AbstractList.append((HeaderAbstractLang, XmlElement(SubIt= em, '%s/Abstract' % Key))) + self.AbstractList.append( + (HeaderAbstractLang, XmlElement(SubItem, '%s/Abstract' % K= ey))) for SubItem in XmlList(Item, '%s/Description' % Key): HeaderDescriptionLang =3D XmlAttribute(SubItem, 'Lang') - self.DescriptionList.append((HeaderDescriptionLang, XmlElement= (SubItem, '%s/Description' % Key))) + self.DescriptionList.append( + (HeaderDescriptionLang, XmlElement(SubItem, '%s/Descriptio= n' % Key))) for SubItem in XmlList(Item, '%s/Copyright' % Key): HeaderCopyrightLang =3D XmlAttribute(SubItem, 'Lang') - self.CopyrightList.append((HeaderCopyrightLang, XmlElement(Sub= Item, '%s/Copyright' % Key))) + self.CopyrightList.append( + (HeaderCopyrightLang, XmlElement(SubItem, '%s/Copyright' %= Key))) for SubItem in XmlList(Item, '%s/License' % Key): HeaderLicenseLang =3D XmlAttribute(SubItem, 'Lang') - self.LicenseList.append((HeaderLicenseLang, XmlElement(SubItem= , '%s/License' % Key))) + self.LicenseList.append( + (HeaderLicenseLang, XmlElement(SubItem, '%s/License' % Key= ))) ModuleHeader =3D ModuleObject() ModuleHeader.SetName(self.Name) ModuleHeader.SetBaseName(self.BaseName) @@ -193,8 +211,10 @@ class HeaderXml(object): def ToXml(self, Header, Key): if self.GUID: pass - Element1 =3D CreateXmlElement('Name', Header.GetName(), [], [['Bas= eName', Header.GetBaseName()]]) - Element2 =3D CreateXmlElement('GUID', Header.GetGuid(), [], [['Ver= sion', Header.GetVersion()]]) + Element1 =3D CreateXmlElement('Name', Header.GetName(), [], [ + ['BaseName', Header.GetBaseName()]]) + Element2 =3D CreateXmlElement('GUID', Header.GetGuid(), [], [ + ['Version', Header.GetVersion()]]) NodeList =3D [Element1, Element2, ] @@ -226,10 +246,12 @@ class HeaderXml(object): NodeList.append(CreateXmlElement('License', Value, [], [])) for (Lang, Value) in Header.GetAbstract() + UNIInfAbstractList: if Value: - NodeList.append(CreateXmlElement('Abstract', Value, [], [[= 'Lang', Lang]])) + NodeList.append(CreateXmlElement( + 'Abstract', Value, [], [['Lang', Lang]])) for (Lang, Value) in Header.GetDescription() + UNIInfDescriptionLi= st: if Value: - NodeList.append(CreateXmlElement('Description', Value, [],= [['Lang', Lang]])) + NodeList.append(CreateXmlElement( + 'Description', Value, [], [['Lang', Lang]])) =20 AttributeList =3D [] Root =3D CreateXmlElement('%s' % Key, '', NodeList, AttributeList) @@ -238,11 +260,13 @@ class HeaderXml(object): def __str__(self): return "Name =3D %s BaseName =3D %s GUID =3D %s Version =3D %s Cop= yright =3D %s \ License =3D %s Abstract =3D %s Description =3D %s" % \ - (self.Name, self.BaseName, self.GUID, self.Version, self.Copyright= List, \ - self.LicenseList, self.AbstractList, self.DescriptionList) + (self.Name, self.BaseName, self.GUID, self.Version, self.Copyr= ightList, + self.LicenseList, self.AbstractList, self.DescriptionList) ## # DistributionPackageHeaderXml # + + class DistributionPackageHeaderXml(object): def __init__(self): self.Header =3D HeaderXml() @@ -289,19 +313,21 @@ class DistributionPackageHeaderXml(object): def ToXml(self, DistributionPackageHeader, Key): if self.Header: pass - Element1 =3D CreateXmlElement('Name', \ - DistributionPackageHeader.GetName(), [= ], \ - [['BaseName', \ - DistributionPackageHeader.GetBaseName(= )]]) - Element2 =3D CreateXmlElement('GUID', \ - DistributionPackageHeader.GetGuid(), [= ], \ - [['Version', \ - DistributionPackageHeader.GetVersion()= ]]) + Element1 =3D CreateXmlElement('Name', + DistributionPackageHeader.GetName(), [= ], + [['BaseName', + DistributionPackageHeader.GetBaseNam= e()]]) + Element2 =3D CreateXmlElement('GUID', + DistributionPackageHeader.GetGuid(), [= ], + [['Version', + DistributionPackageHeader.GetVersion= ()]]) AttributeList =3D [] if DistributionPackageHeader.ReadOnly !=3D '': - AttributeList.append(['ReadOnly', str(DistributionPackageHeade= r.ReadOnly).lower()]) + AttributeList.append( + ['ReadOnly', str(DistributionPackageHeader.ReadOnly).lower= ()]) if DistributionPackageHeader.RePackage !=3D '': - AttributeList.append(['RePackage', str(DistributionPackageHead= er.RePackage).lower()]) + AttributeList.append( + ['RePackage', str(DistributionPackageHeader.RePackage).low= er()]) if DistributionPackageHeader.GetAbstract(): DPAbstract =3D DistributionPackageHeader.GetAbstract()[0][1] else: @@ -327,7 +353,7 @@ class DistributionPackageHeaderXml(object): ['Abstract', DPAbstract], ['Description', DPDescription], ['Signature', DistributionPackageHeader.Signature], - ['XmlSpecification', \ + ['XmlSpecification', DistributionPackageHeader.XmlSpecification], ] Root =3D CreateXmlElement('%s' % Key, '', NodeList, AttributeList) @@ -336,11 +362,13 @@ class DistributionPackageHeaderXml(object): def __str__(self): return "ReadOnly =3D %s RePackage =3D %s Vendor =3D %s Date =3D %s= \ Signature =3D %s XmlSpecification =3D %s %s" % \ - (self.ReadOnly, self.RePackage, self.Vendor, self.Date, \ - self.Signature, self.XmlSpecification, self.Header) + (self.ReadOnly, self.RePackage, self.Vendor, self.Date, + self.Signature, self.XmlSpecification, self.Header) ## # PackageHeaderXml # + + class PackageHeaderXml(object): def __init__(self): self.Header =3D HeaderXml() @@ -366,9 +394,9 @@ class PackageHeaderXml(object): def ToXml(self, PackageObject2, Key): if self.PackagePath: pass - Element1 =3D CreateXmlElement('Name', PackageObject2.GetName(), []= , \ - [['BaseName', PackageObject2.GetBaseName()]]) - Element2 =3D CreateXmlElement('GUID', PackageObject2.GetGuid(), []= , \ + Element1 =3D CreateXmlElement('Name', PackageObject2.GetName(), [], + [['BaseName', PackageObject2.GetBaseNa= me()]]) + Element2 =3D CreateXmlElement('GUID', PackageObject2.GetGuid(), [], [['Version', PackageObject2.GetVersion= ()]]) NodeList =3D [Element1, Element2 @@ -395,17 +423,20 @@ class PackageHeaderXml(object): # Get Abstract and Description from DEC File Header for (Lang, Value) in PackageObject2.GetCopyright(): if Value: - NodeList.append(CreateXmlElement(DataType.TAB_HEADER_COPYR= IGHT, Value, [], [])) + NodeList.append(CreateXmlElement( + DataType.TAB_HEADER_COPYRIGHT, Value, [], [])) for (Lang, Value) in PackageObject2.GetLicense(): if Value: - NodeList.append(CreateXmlElement(DataType.TAB_HEADER_LICEN= SE, Value, [], [])) + NodeList.append(CreateXmlElement( + DataType.TAB_HEADER_LICENSE, Value, [], [])) for (Lang, Value) in PackageObject2.GetAbstract() + UNIPackageAbrs= tractList: if Value: - NodeList.append(CreateXmlElement(DataType.TAB_HEADER_ABSTR= ACT, Value, [], [['Lang', Lang]])) + NodeList.append(CreateXmlElement( + DataType.TAB_HEADER_ABSTRACT, Value, [], [['Lang', Lan= g]])) for (Lang, Value) in PackageObject2.GetDescription() + UNIPackageD= escriptionList: if Value: - NodeList.append(CreateXmlElement(DataType.TAB_HEADER_DESCR= IPTION, Value, [], [['Lang', Lang]])) - + NodeList.append(CreateXmlElement( + DataType.TAB_HEADER_DESCRIPTION, Value, [], [['Lang', = Lang]])) =20 NodeList.append(['PackagePath', PackageObject2.GetPackagePath()]) AttributeList =3D [] @@ -419,6 +450,8 @@ class PackageHeaderXml(object): ## # MiscellaneousFileXml # + + class MiscellaneousFileXml(object): def __init__(self): self.Header =3D HeaderXml() @@ -426,6 +459,7 @@ class MiscellaneousFileXml(object): ## # This API is used for Package or Module's MiscellaneousFile section # + def FromXml(self, Item, Key): if not Item: return None @@ -434,7 +468,8 @@ class MiscellaneousFileXml(object): self.Header.FromXml(NewItem, 'Header') for SubItem in XmlList(Item, '%s/Filename' % Key): Filename =3D XmlElement(SubItem, '%s/Filename' % Key) - Executable =3D XmlAttribute(XmlNode(SubItem, '%s/Filename' % K= ey), 'Executable') + Executable =3D XmlAttribute( + XmlNode(SubItem, '%s/Filename' % Key), 'Executable') if Executable.upper() =3D=3D "TRUE": Executable =3D True elif Executable.upper() =3D=3D "FALSE": @@ -458,6 +493,7 @@ class MiscellaneousFileXml(object): ## # This API is used for DistP's tool section # + def FromXml2(self, Item, Key): if Item is None: return None @@ -466,7 +502,8 @@ class MiscellaneousFileXml(object): for SubItem in XmlList(Item, '%s/Filename' % Key): Filename =3D XmlElement(SubItem, '%s/Filename' % Key) Executable =3D \ - XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'Executabl= e') + XmlAttribute(XmlNode(SubItem, '%s/Filename' % + Key), 'Executable') OsType =3D XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key),= 'OS') if Executable.upper() =3D=3D "TRUE": Executable =3D True @@ -518,17 +555,17 @@ class MiscellaneousFileXml(object): ['License', DPLicense], ['Abstract', DPAbstract], ['Description', DPDescription], - ] + ] for File in MiscFile.GetFileList(): - NodeList.append\ - (CreateXmlElement\ - ('Filename', File.GetURI(), [], \ - [['Executable', str(File.GetExecutable()).lower()]])) + NodeList.append(CreateXmlElement + ('Filename', File.GetURI(), [], + [['Executable', str(File.GetExecutable())= .lower()]])) Root =3D CreateXmlElement('%s' % Key, '', NodeList, []) return Root ## # This API is used for DistP's tool section # + def ToXml2(self, MiscFile, Key): if self.Header: pass @@ -554,15 +591,14 @@ class MiscellaneousFileXml(object): ['License', DPLicense], ['Abstract', DPAbstract], ['Description', DPDescription], - ] + ] HeaderNode =3D CreateXmlElement('Header', '', NodeList, []) NodeList =3D [HeaderNode] for File in MiscFile.GetFileList(): - NodeList.append\ - (CreateXmlElement\ - ('Filename', File.GetURI(), [], \ - [['Executable', str(File.GetExecutable()).lower()], \ - ['OS', File.GetOS()]])) + NodeList.append(CreateXmlElement + ('Filename', File.GetURI(), [], + [['Executable', str(File.GetExecutable())= .lower()], + ['OS', File.GetOS()]])) Root =3D CreateXmlElement('%s' % Key, '', NodeList, []) return Root =20 @@ -574,6 +610,8 @@ class MiscellaneousFileXml(object): ## # UserExtensionsXml # + + class UserExtensionsXml(object): def __init__(self): self.UserId =3D '' @@ -605,22 +643,23 @@ class UserExtensionsXml(object): self.UserId =3D XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId') self.Identifier =3D XmlAttribute(XmlNode(Item, '%s' % Key), 'Ident= ifier') if self.UserId =3D=3D DataType.TAB_BINARY_HEADER_USERID \ - and self.Identifier =3D=3D DataType.TAB_BINARY_HEADER_IDENTIFIER: + and self.Identifier =3D=3D DataType.TAB_BINARY_HEADER_IDEN= TIFIER: for SubItem in XmlList(Item, '%s/BinaryAbstract' % Key): BinaryAbstractLang =3D XmlAttribute(SubItem, 'Lang') - self.BinaryAbstractList.append((BinaryAbstractLang, XmlEle= ment(SubItem, '%s/BinaryAbstract' % Key))) + self.BinaryAbstractList.append( + (BinaryAbstractLang, XmlElement(SubItem, '%s/BinaryAbs= tract' % Key))) for SubItem in XmlList(Item, '%s/BinaryDescription' % Key): BinaryDescriptionLang =3D XmlAttribute(SubItem, 'Lang') self.BinaryDescriptionList.append((BinaryDescriptionLang, - XmlElement(SubItem,= '%s/BinaryDescription' % Key))) + XmlElement(SubItem, '%s= /BinaryDescription' % Key))) for SubItem in XmlList(Item, '%s/BinaryCopyright' % Key): BinaryCopyrightLang =3D XmlAttribute(SubItem, 'Lang') self.BinaryCopyrightList.append((BinaryCopyrightLang, - XmlElement(SubItem, '= %s/BinaryCopyright' % Key))) + XmlElement(SubItem, '%s/B= inaryCopyright' % Key))) for SubItem in XmlList(Item, '%s/BinaryLicense' % Key): BinaryLicenseLang =3D XmlAttribute(SubItem, 'Lang') self.BinaryLicenseList.append((BinaryLicenseLang, - XmlElement(SubItem, '%s= /BinaryLicense' % Key))) + XmlElement(SubItem, '%s/Bin= aryLicense' % Key))) =20 DefineItem =3D XmlNode(Item, '%s/Define' % Key) for SubItem in XmlList(DefineItem, 'Define/Statement'): @@ -629,12 +668,14 @@ class UserExtensionsXml(object): BuildOptionItem =3D XmlNode(Item, '%s/BuildOption' % Key) for SubItem in XmlList(BuildOptionItem, 'BuildOption/Statement'): Statement =3D XmlElement(SubItem, '%s/Statement' % Key) - Arch =3D XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key), = 'SupArchList') + Arch =3D XmlAttribute( + XmlNode(SubItem, '%s/Statement' % Key), 'SupArchList') self.BuildOptionDict[Arch] =3D Statement IncludesItem =3D XmlNode(Item, '%s/Includes' % Key) for SubItem in XmlList(IncludesItem, 'Includes/Statement'): Statement =3D XmlElement(SubItem, '%s/Statement' % Key) - Arch =3D XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key), = 'SupArchList') + Arch =3D XmlAttribute( + XmlNode(SubItem, '%s/Statement' % Key), 'SupArchList') self.IncludesDict[Statement] =3D Arch SourcesItem =3D XmlNode(Item, '%s/Sources' % Key) Tmp =3D UserExtensionSourceXml() @@ -646,7 +687,8 @@ class UserExtensionsXml(object): self.BinariesDict =3D BinariesDict self.Statement =3D XmlElement(Item, 'UserExtensions') SupArch =3D XmlAttribute(XmlNode(Item, '%s' % Key), 'SupArchList') - self.SupArchList =3D [Arch for Arch in GetSplitValueList(SupArch, = DataType.TAB_SPACE_SPLIT) if Arch] + self.SupArchList =3D [Arch for Arch in GetSplitValueList( + SupArch, DataType.TAB_SPACE_SPLIT) if Arch] UserExtension =3D UserExtensionObject() UserExtension.SetUserID(self.UserId) UserExtension.SetIdentifier(self.Identifier) @@ -668,35 +710,39 @@ class UserExtensionsXml(object): pass AttributeList =3D [['UserId', str(UserExtension.GetUserID())], ['Identifier', str(UserExtension.GetIdentifier())= ], - ['SupArchList', \ + ['SupArchList', GetStringOfList(UserExtension.GetSupArchList())], - ] - Root =3D CreateXmlElement('%s' % Key, UserExtension.GetStatement()= , [], \ - AttributeList) + ] + Root =3D CreateXmlElement('%s' % Key, UserExtension.GetStatement()= , [], + AttributeList) if UserExtension.GetIdentifier() =3D=3D DataType.TAB_BINARY_HEADER= _IDENTIFIER and \ - UserExtension.GetUserID() =3D=3D DataType.TAB_BINARY_HEADER_USERID: + UserExtension.GetUserID() =3D=3D DataType.TAB_BINARY_HEADE= R_USERID: for (Lang, Value) in UserExtension.GetBinaryAbstract(): if Value: - ChildElement =3D CreateXmlElement('BinaryAbstract', Va= lue, [], [['Lang', Lang]]) + ChildElement =3D CreateXmlElement( + 'BinaryAbstract', Value, [], [['Lang', Lang]]) Root.appendChild(ChildElement) for (Lang, Value) in UserExtension.GetBinaryDescription(): if Value: - ChildElement =3D CreateXmlElement('BinaryDescription',= Value, [], [['Lang', Lang]]) + ChildElement =3D CreateXmlElement( + 'BinaryDescription', Value, [], [['Lang', Lang]]) Root.appendChild(ChildElement) for (Lang, Value) in UserExtension.GetBinaryCopyright(): if Value: - ChildElement =3D CreateXmlElement('BinaryCopyright', V= alue, [], []) + ChildElement =3D CreateXmlElement( + 'BinaryCopyright', Value, [], []) Root.appendChild(ChildElement) for (Lang, Value) in UserExtension.GetBinaryLicense(): if Value: - ChildElement =3D CreateXmlElement('BinaryLicense', Val= ue, [], []) + ChildElement =3D CreateXmlElement( + 'BinaryLicense', Value, [], []) Root.appendChild(ChildElement) =20 NodeList =3D [] DefineDict =3D UserExtension.GetDefinesDict() if DefineDict: for Item in DefineDict.keys(): - NodeList.append(CreateXmlElement\ + NodeList.append(CreateXmlElement ('Statement', Item, [], [])) DefineElement =3D CreateXmlElement('Define', '', NodeList, []) Root.appendChild(DefineElement) @@ -704,18 +750,18 @@ class UserExtensionsXml(object): BuildOptionDict =3D UserExtension.GetBuildOptionDict() if BuildOptionDict: for Item in BuildOptionDict.keys(): - NodeList.append(CreateXmlElement\ - ('Statement', BuildOptionDict[Item], [], \ + NodeList.append(CreateXmlElement + ('Statement', BuildOptionDict[Item], [], [['SupArchList', Item]])) BuildOptionElement =3D \ - CreateXmlElement('BuildOption', '', NodeList, []) + CreateXmlElement('BuildOption', '', NodeList, []) Root.appendChild(BuildOptionElement) NodeList =3D [] IncludesDict =3D UserExtension.GetIncludesDict() if IncludesDict: for Item in IncludesDict.keys(): - NodeList.append(CreateXmlElement\ - ('Statement', Item, [], \ + NodeList.append(CreateXmlElement + ('Statement', Item, [], [['SupArchList', IncludesDict[Item]]])) IncludesElement =3D CreateXmlElement('Includes', '', NodeList,= []) Root.appendChild(IncludesElement) @@ -740,6 +786,8 @@ class UserExtensionsXml(object): ## # UserExtensionSourceXml # + + class UserExtensionSourceXml(object): def __init__(self): self.UserExtensionSource =3D '' @@ -758,13 +806,13 @@ class UserExtensionSourceXml(object): SupArchStr =3D XmlElement(SubItem, 'SourceFile/SupArchList') DictKey =3D (FileName, Family, FeatureFlag, SupArchStr) ValueList =3D [] - for ValueNodeItem in XmlList(SubItem, \ + for ValueNodeItem in XmlList(SubItem, 'SourceFile/SourceFileOtherAttr'): - TagName =3D XmlElement(ValueNodeItem, \ + TagName =3D XmlElement(ValueNodeItem, 'SourceFileOtherAttr/TagName') - ToolCode =3D XmlElement(ValueNodeItem, \ + ToolCode =3D XmlElement(ValueNodeItem, 'SourceFileOtherAttr/ToolCode') - Comment =3D XmlElement(ValueNodeItem, \ + Comment =3D XmlElement(ValueNodeItem, 'SourceFileOtherAttr/Comment') if (TagName =3D=3D ' ') and (ToolCode =3D=3D ' ') and (Com= ment =3D=3D ' '): TagName =3D '' @@ -795,10 +843,10 @@ class UserExtensionSourceXml(object): ValueNodeList.append(["TagName", TagName]) ValueNodeList.append(["ToolCode", ToolCode]) ValueNodeList.append(["Comment", Comment]) - ValueNodeXml =3D CreateXmlElement('SourceFileOtherAttr', '= ', \ + ValueNodeXml =3D CreateXmlElement('SourceFileOtherAttr', '= ', ValueNodeList, []) SourceFileNodeList.append(ValueNodeXml) - SourceFileNodeXml =3D CreateXmlElement('SourceFile', '', \ + SourceFileNodeXml =3D CreateXmlElement('SourceFile', '', SourceFileNodeList, []) SourcesNodeList.append(SourceFileNodeXml) Root =3D CreateXmlElement('%s' % Key, '', SourcesNodeList, []) @@ -807,6 +855,8 @@ class UserExtensionSourceXml(object): ## # UserExtensionBinaryXml # + + class UserExtensionBinaryXml(object): def __init__(self): self.UserExtensionBinary =3D '' @@ -824,15 +874,15 @@ class UserExtensionBinaryXml(object): SupArch =3D XmlElement(SubItem, 'Binary/SupArchList') DictKey =3D (FileName, FileType, ConvertNOTEQToNE(FFE), SupArc= h) ValueList =3D [] - for ValueNodeItem in XmlList(SubItem, \ + for ValueNodeItem in XmlList(SubItem, 'Binary/BinaryFileOtherAttr'): - Target =3D XmlElement(ValueNodeItem, \ + Target =3D XmlElement(ValueNodeItem, 'BinaryFileOtherAttr/Target') - Family =3D XmlElement(ValueNodeItem, \ + Family =3D XmlElement(ValueNodeItem, 'BinaryFileOtherAttr/Family') - TagName =3D XmlElement(ValueNodeItem, \ + TagName =3D XmlElement(ValueNodeItem, 'BinaryFileOtherAttr/TagName') - Comment =3D XmlElement(ValueNodeItem, \ + Comment =3D XmlElement(ValueNodeItem, 'BinaryFileOtherAttr/Comment') if (Target =3D=3D ' ') and (Family =3D=3D ' ') and \ (TagName =3D=3D ' ') and (Comment =3D=3D ' '): @@ -868,7 +918,7 @@ class UserExtensionBinaryXml(object): ValueNodeList.append(["Family", Family]) ValueNodeList.append(["TagName", TagName]) ValueNodeList.append(["Comment", Comment]) - ValueNodeXml =3D CreateXmlElement('BinaryFileOtherAttr', '= ', \ + ValueNodeXml =3D CreateXmlElement('BinaryFileOtherAttr', '= ', ValueNodeList, []) FileNodeList.append(ValueNodeXml) FileNodeXml =3D CreateXmlElement('Binary', '', FileNodeList, [= ]) @@ -879,6 +929,8 @@ class UserExtensionBinaryXml(object): ## # LibraryClassXml # + + class LibraryClassXml(object): def __init__(self): self.Keyword =3D '' @@ -905,7 +957,8 @@ class LibraryClassXml(object): LibraryClass.SetUsage(self.CommonDefines.Usage) LibraryClass.SetSupArchList(self.CommonDefines.SupArchList) LibraryClass.SetSupModuleList(self.CommonDefines.SupModList) - LibraryClass.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.Fe= atureFlag)) + LibraryClass.SetFeatureFlag( + ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)) LibraryClass.SetHelpTextList(GetHelpTextList(self.HelpText)) return LibraryClass =20 @@ -913,10 +966,11 @@ class LibraryClassXml(object): if self.HeaderFile: pass AttributeList =3D \ - [['Keyword', LibraryClass.GetLibraryClass()], - ['SupArchList', GetStringOfList(LibraryClass.GetSupArchList())], - ['SupModList', GetStringOfList(LibraryClass.GetSupModuleList())] - ] + [['Keyword', LibraryClass.GetLibraryClass()], + ['SupArchList', GetStringOfList(LibraryClass.GetSupArchList()= )], + ['SupModList', GetStringOfList( + LibraryClass.GetSupModuleList())] + ] NodeList =3D [['HeaderFile', LibraryClass.GetIncludeHeader()]] for Item in LibraryClass.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -929,11 +983,12 @@ class LibraryClassXml(object): pass FeatureFlag =3D ConvertNEToNOTEQ(LibraryClass.GetFeatureFlag()) AttributeList =3D \ - [['Usage', LibraryClass.GetUsage()], \ - ['SupArchList', GetStringOfList(LibraryClass.GetSupArchList())], \ - ['SupModList', GetStringOfList(LibraryClass.GetSupModuleList())],= \ - ['FeatureFlag', FeatureFlag] - ] + [['Usage', LibraryClass.GetUsage()], + ['SupArchList', GetStringOfList(LibraryClass.GetSupArchList()= )], + ['SupModList', GetStringOfList( + LibraryClass.GetSupModuleList())], + ['FeatureFlag', FeatureFlag] + ] NodeList =3D [['Keyword', LibraryClass.GetLibraryClass()], ] for Item in LibraryClass.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -943,8 +998,8 @@ class LibraryClassXml(object): =20 def __str__(self): Str =3D "Keyword =3D %s HeaderFile =3D %s RecommendedInstanceGuid = =3D %s RecommendedInstanceVersion =3D %s %s" % \ - (self.Keyword, self.HeaderFile, self.RecommendedInstanceGuid= , self.RecommendedInstanceVersion, \ - self.CommonDefines) + (self.Keyword, self.HeaderFile, self.RecommendedInstanceGuid= , self.RecommendedInstanceVersion, + self.CommonDefines) for Item in self.HelpText: Str =3D Str + "\n\t" + str(Item) return Str @@ -952,6 +1007,8 @@ class LibraryClassXml(object): ## # FilenameXml # + + class FilenameXml(object): def __init__(self): self.FileType =3D '' @@ -982,16 +1039,18 @@ class FilenameXml(object): def ToXml(self, Filename, Key): if self.Filename: pass - AttributeList =3D [['SupArchList', \ + AttributeList =3D [['SupArchList', GetStringOfList(Filename.GetSupArchList())], ['FileType', Filename.GetFileType()], - ['FeatureFlag', ConvertNEToNOTEQ(Filename.GetFeat= ureFlag())], + ['FeatureFlag', ConvertNEToNOTEQ( + Filename.GetFeatureFlag())], ['GUID', Filename.GetGuidValue()] - ] - Root =3D CreateXmlElement('%s' % Key, Filename.GetFilename(), [], = AttributeList) + ] + Root =3D CreateXmlElement( + '%s' % Key, Filename.GetFilename(), [], AttributeList) =20 return Root =20 def __str__(self): return "FileType =3D %s Filename =3D %s %s" \ - % (self.FileType, self.Filename, self.CommonDefines) + % (self.FileType, self.Filename, self.CommonDefines) diff --git a/BaseTools/Source/Python/UPT/Xml/GuidProtocolPpiXml.py b/BaseTo= ols/Source/Python/UPT/Xml/GuidProtocolPpiXml.py index d6645fc23cf0..dbfc6876c1c7 100644 --- a/BaseTools/Source/Python/UPT/Xml/GuidProtocolPpiXml.py +++ b/BaseTools/Source/Python/UPT/Xml/GuidProtocolPpiXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a xml file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -28,8 +28,10 @@ from Xml.CommonXml import HelpTextXml from Xml.XmlParserMisc import GetHelpTextList =20 ## -#GUID/Protocol/Ppi Common +# GUID/Protocol/Ppi Common # + + class GuidProtocolPpiXml(object): def __init__(self, Mode): self.UiName =3D '' @@ -78,18 +80,22 @@ class GuidProtocolPpiXml(object): if self.GuidValue: pass AttributeList =3D \ - [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], \ - ['UiName', GuidProtocolPpi.GetName()], \ - ['GuidType', GetStringOfList(GuidProtocolPpi.GetGuidTypeList())],= \ - ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], \ - ['SupArchList', GetStringOfList(GuidProtocolPpi.GetSupArchList())= ], \ - ['SupModList', GetStringOfList(GuidProtocolPpi.GetSupModuleList()= )], \ - ['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureFlag()= )] - ] + [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], + ['UiName', GuidProtocolPpi.GetName()], + ['GuidType', GetStringOfList( + GuidProtocolPpi.GetGuidTypeList())], + ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], + ['SupArchList', GetStringOfList( + GuidProtocolPpi.GetSupArchList())], + ['SupModList', GetStringOfList( + GuidProtocolPpi.GetSupModuleList())], + ['FeatureFlag', ConvertNEToNOTEQ( + GuidProtocolPpi.GetFeatureFlag())] + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], ['GuidValue', GuidProtocolPpi.GetGuid()], ['VariableName', GuidProtocolPpi.VariableName] - ] + ] for Item in GuidProtocolPpi.GetHelpTextList(): Tmp =3D HelpTextXml() NodeList.append(Tmp.ToXml(Item)) @@ -99,15 +105,17 @@ class GuidProtocolPpiXml(object): =20 def __str__(self): Str =3D \ - "UiName =3D %s Notify =3D %s GuidTypes =3D %s CName =3D %s GuidVal= ue =3D %s %s" \ - % (self.UiName, self.Notify, self.GuidTypes, self.CName, \ - self.GuidValue, self.CommonDefines) + "UiName =3D %s Notify =3D %s GuidTypes =3D %s CName =3D %s Gui= dValue =3D %s %s" \ + % (self.UiName, self.Notify, self.GuidTypes, self.CName, + self.GuidValue, self.CommonDefines) for Item in self.HelpText: Str =3D Str + "\n\t" + str(Item) return Str ## -#GUID Xml +# GUID Xml # + + class GuidXml(GuidProtocolPpiXml): def __init__(self, Mode): GuidProtocolPpiXml.__init__(self, Mode) @@ -127,7 +135,8 @@ class GuidXml(GuidProtocolPpiXml): if self.GuidType: GuidProtocolPpi.SetGuidTypeList([self.GuidType]) GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList) - GuidProtocolPpi.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDef= ines.FeatureFlag)) + GuidProtocolPpi.SetFeatureFlag( + ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)) GuidProtocolPpi.SetCName(self.CName) GuidProtocolPpi.SetVariableName(self.VariableName) return GuidProtocolPpi @@ -135,27 +144,29 @@ class GuidXml(GuidProtocolPpiXml): def ToXml(self, GuidProtocolPpi, Key): if self.Mode =3D=3D 'Package': AttributeList =3D \ - [['GuidType', \ - GetStringOfList(GuidProtocolPpi.GetGuidTypeList())], \ - ['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], \ - ['SupModList', \ - GetStringOfList(GuidProtocolPpi.GetSupModuleList())], - ] + [['GuidType', + GetStringOfList(GuidProtocolPpi.GetGuidTypeList())], + ['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ['SupModList', + GetStringOfList(GuidProtocolPpi.GetSupModuleList())], + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], ['GuidValue', GuidProtocolPpi.GetGuid()], - ] + ] else: AttributeList =3D \ - [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], \ - ['GuidType', GetStringOfList(GuidProtocolPpi.GetGuidTypeList(= ))],\ - ['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], \ - ['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeature= Flag())] - ] + [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], + ['GuidType', GetStringOfList( + GuidProtocolPpi.GetGuidTypeList())], + ['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ['FeatureFlag', ConvertNEToNOTEQ( + GuidProtocolPpi.GetFeatureFlag())] + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], ['VariableName', GuidProtocolPpi.GetVariableName()] - ] + ] =20 for Item in GuidProtocolPpi.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -164,8 +175,10 @@ class GuidXml(GuidProtocolPpiXml): =20 return Root ## -#Protocol Xml +# Protocol Xml # + + class ProtocolXml(GuidProtocolPpiXml): def __init__(self, Mode): GuidProtocolPpiXml.__init__(self, Mode) @@ -188,7 +201,8 @@ class ProtocolXml(GuidProtocolPpiXml): else: GuidProtocolPpi.SetNotify('') GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList) - GuidProtocolPpi.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDef= ines.FeatureFlag)) + GuidProtocolPpi.SetFeatureFlag( + ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)) GuidProtocolPpi.SetCName(self.CName) =20 return GuidProtocolPpi @@ -196,25 +210,26 @@ class ProtocolXml(GuidProtocolPpiXml): def ToXml(self, GuidProtocolPpi, Key): if self.Mode =3D=3D 'Package': AttributeList =3D \ - [['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], \ - ['SupModList', \ - GetStringOfList(GuidProtocolPpi.GetSupModuleList())], \ - ['FeatureFlag', GuidProtocolPpi.GetFeatureFlag()] - ] + [['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ['SupModList', + GetStringOfList(GuidProtocolPpi.GetSupModuleList())], + ['FeatureFlag', GuidProtocolPpi.GetFeatureFlag()] + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], ['GuidValue', GuidProtocolPpi.GetGuid()], - ] + ] else: AttributeList =3D \ - [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], \ - ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], \ - ['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], \ - ['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureF= lag())] - ] + [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], + ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], + ['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ['FeatureFlag', ConvertNEToNOTEQ( + GuidProtocolPpi.GetFeatureFlag())] + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], - ] + ] =20 for Item in GuidProtocolPpi.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -223,8 +238,10 @@ class ProtocolXml(GuidProtocolPpiXml): =20 return Root ## -#Ppi Xml +# Ppi Xml # + + class PpiXml(GuidProtocolPpiXml): def __init__(self, Mode): GuidProtocolPpiXml.__init__(self, Mode) @@ -246,7 +263,8 @@ class PpiXml(GuidProtocolPpiXml): else: GuidProtocolPpi.SetNotify('') GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList) - GuidProtocolPpi.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDef= ines.FeatureFlag)) + GuidProtocolPpi.SetFeatureFlag( + ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)) GuidProtocolPpi.SetCName(self.CName) =20 return GuidProtocolPpi @@ -254,22 +272,23 @@ class PpiXml(GuidProtocolPpiXml): def ToXml(self, GuidProtocolPpi, Key): if self.Mode =3D=3D 'Package': AttributeList =3D \ - [['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], - ] + [['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], ['GuidValue', GuidProtocolPpi.GetGuid()], - ] + ] else: AttributeList =3D \ - [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], \ - ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], \ - ['SupArchList', \ - GetStringOfList(GuidProtocolPpi.GetSupArchList())], \ - ['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureF= lag())] - ] + [['Usage', GetStringOfList(GuidProtocolPpi.GetUsage())], + ['Notify', str(GuidProtocolPpi.GetNotify()).lower()], + ['SupArchList', + GetStringOfList(GuidProtocolPpi.GetSupArchList())], + ['FeatureFlag', ConvertNEToNOTEQ( + GuidProtocolPpi.GetFeatureFlag())] + ] NodeList =3D [['CName', GuidProtocolPpi.GetCName()], - ] + ] =20 for Item in GuidProtocolPpi.GetHelpTextList(): Tmp =3D HelpTextXml() diff --git a/BaseTools/Source/Python/UPT/Xml/IniToXml.py b/BaseTools/Source= /Python/UPT/Xml/IniToXml.py index 3dc4001313de..ce5366d755a2 100644 --- a/BaseTools/Source/Python/UPT/Xml/IniToXml.py +++ b/BaseTools/Source/Python/UPT/Xml/IniToXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is for converting package information data file to xml file. # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -28,38 +28,46 @@ from Library.StringUtils import ConvertSpecialChar from Library.ParserValidate import IsValidPath from Library import GlobalData =20 -## log error: +# log error: # # @param error: error # @param File: File # @param Line: Line # + + def IniParseError(Error, File, Line): Logger.Error("UPT", UPT_INI_PARSE_ERROR, File=3DFile, Line=3DLine, ExtraData=3DError) =20 -## __ValidatePath +# __ValidatePath # # @param Path: Path to be checked # + + def __ValidatePath(Path, Root): Path =3D Path.strip() if os.path.isabs(Path) or not IsValidPath(Path, Root): return False, ST.ERR_FILELIST_LOCATION % (Root, Path) return True, '' =20 -## ValidateMiscFile +# ValidateMiscFile # # @param Filename: File to be checked # + + def ValidateMiscFile(Filename): Root =3D GlobalData.gWORKSPACE return __ValidatePath(Filename, Root) =20 -## ValidateToolsFile +# ValidateToolsFile # # @param Filename: File to be checked # + + def ValidateToolsFile(Filename): Valid, Cause =3D False, '' if not Valid and 'EDK_TOOLS_PATH' in os.environ: @@ -68,13 +76,15 @@ def ValidateToolsFile(Filename): Valid, Cause =3D __ValidatePath(Filename, GlobalData.gWORKSPACE) return Valid, Cause =20 -## ParseFileList +# ParseFileList # # @param Line: Line # @param Map: Map # @param CurrentKey: CurrentKey # @param PathFunc: Path validate function # + + def ParseFileList(Line, Map, CurrentKey, PathFunc): FileList =3D ["", {}] TokenList =3D Line.split(TAB_VALUE_SPLIT) @@ -107,11 +117,13 @@ def ParseFileList(Line, Map, CurrentKey, PathFunc): Map[CurrentKey].append(FileList) return True, '' =20 -## Create header XML file +# Create header XML file # # @param DistMap: DistMap # @param Root: Root # + + def CreateHeaderXml(DistMap, Root): Element1 =3D CreateXmlElement('Name', DistMap['Name'], [], [['BaseName', DistMap['BaseName']]]) @@ -133,12 +145,14 @@ def CreateHeaderXml(DistMap, Root): Root.appendChild(CreateXmlElement('DistributionHeader', '', NodeList, AttributeList)) =20 -## Create tools XML file +# Create tools XML file # # @param Map: Map # @param Root: Root # @param Tag: Tag # + + def CreateToolsXml(Map, Root, Tag): # # Check if all elements in this section are empty @@ -154,7 +168,7 @@ def CreateToolsXml(Map, Root, Tag): ['License', Map['License']], ['Abstract', Map['Abstract']], ['Description', Map['Description']], - ] + ] HeaderNode =3D CreateXmlElement('Header', '', NodeList, []) NodeList =3D [HeaderNode] =20 @@ -165,12 +179,14 @@ def CreateToolsXml(Map, Root, Tag): NodeList.append(CreateXmlElement('Filename', File[0], [], AttrList= )) Root.appendChild(CreateXmlElement(Tag, '', NodeList, [])) =20 -## ValidateValues +# ValidateValues # # @param Key: Key # @param Value: Value # @param SectionName: SectionName # + + def ValidateValues(Key, Value, SectionName): if SectionName =3D=3D 'DistributionHeader': Valid, Cause =3D ValidateRegValues(Key, Value) @@ -185,24 +201,26 @@ def ValidateValues(Key, Value, SectionName): return Valid, ST.ERR_VALUE_INVALID % (Key, SectionName) return True, '' =20 -## ValidateRegValues +# ValidateRegValues # # @param Key: Key # @param Value: Value # + + def ValidateRegValues(Key, Value): ValidateMap =3D { - 'ReadOnly' : + 'ReadOnly': ('true|false', ST.ERR_BOOLEAN_VALUE % (Key, Value)), - 'RePackage' : + 'RePackage': ('true|false', ST.ERR_BOOLEAN_VALUE % (Key, Value)), - 'GUID' : + 'GUID': ('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}' - '-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}', - ST.ERR_GUID_VALUE % Value), - 'Version' : ('[0-9]+(\.[0-9]+)?', ST.ERR_VERSION_VALUE % \ - (Key, Value)), - 'XmlSpecification' : ('1\.1', ST.ERR_VERSION_XMLSPEC % Value) + '-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}', + ST.ERR_GUID_VALUE % Value), + 'Version': ('[0-9]+(\.[0-9]+)?', ST.ERR_VERSION_VALUE % + (Key, Value)), + 'XmlSpecification': ('1\.1', ST.ERR_VERSION_XMLSPEC % Value) } if Key not in ValidateMap: return True, '' @@ -212,10 +230,12 @@ def ValidateRegValues(Key, Value): return True, '' return False, Elem[1] =20 -## __ValidateDistHeaderName +# __ValidateDistHeaderName # # @param Name: Name # + + def __ValidateDistHeaderName(Name): if len(Name) < 1: return False @@ -225,10 +245,12 @@ def __ValidateDistHeaderName(Name): return False return True =20 -## __ValidateDistHeaderBaseName +# __ValidateDistHeaderBaseName # # @param BaseName: BaseName # + + def __ValidateDistHeaderBaseName(BaseName): if not BaseName: return False @@ -241,78 +263,88 @@ def __ValidateDistHeaderBaseName(BaseName): return False return True =20 -## __ValidateDistHeaderAbstract +# __ValidateDistHeaderAbstract # # @param Abstract: Abstract # + + def __ValidateDistHeaderAbstract(Abstract): return '\t' not in Abstract and len(Abstract.splitlines()) =3D=3D 1 =20 -## __ValidateOtherHeaderAbstract +# __ValidateOtherHeaderAbstract # # @param Abstract: Abstract # + + def __ValidateOtherHeaderAbstract(Abstract): return __ValidateDistHeaderAbstract(Abstract) =20 -## __ValidateDistHeader +# __ValidateDistHeader # # @param Key: Key # @param Value: Value # + + def __ValidateDistHeader(Key, Value): ValidateMap =3D { - 'Name' : __ValidateDistHeaderName, - 'BaseName' : __ValidateDistHeaderBaseName, - 'Abstract' : __ValidateDistHeaderAbstract, - 'Vendor' : __ValidateDistHeaderAbstract + 'Name': __ValidateDistHeaderName, + 'BaseName': __ValidateDistHeaderBaseName, + 'Abstract': __ValidateDistHeaderAbstract, + 'Vendor': __ValidateDistHeaderAbstract } return not (Value and Key in ValidateMap and not ValidateMap[Key](Valu= e)) =20 -## __ValidateOtherHeader +# __ValidateOtherHeader # # @param Key: Key # @param Value: Value # + + def __ValidateOtherHeader(Key, Value): ValidateMap =3D { - 'Name' : __ValidateDistHeaderName, - 'Abstract' : __ValidateOtherHeaderAbstract + 'Name': __ValidateDistHeaderName, + 'Abstract': __ValidateOtherHeaderAbstract } return not (Value and Key in ValidateMap and not ValidateMap[Key](Valu= e)) =20 -## Convert ini file to xml file +# Convert ini file to xml file # # @param IniFile # + + def IniToXml(IniFile): if not os.path.exists(IniFile): Logger.Error("UPT", FILE_NOT_FOUND, ST.ERR_TEMPLATE_NOTFOUND % Ini= File) =20 - DistMap =3D {'ReadOnly' : '', 'RePackage' : '', 'Name' : '', - 'BaseName' : '', 'GUID' : '', 'Version' : '', 'Vendor' : '', - 'Date' : '', 'Copyright' : '', 'License' : '', 'Abstract' := '', - 'Description' : '', 'Signature' : '', 'XmlSpecification' : = '' - } + DistMap =3D {'ReadOnly': '', 'RePackage': '', 'Name': '', + 'BaseName': '', 'GUID': '', 'Version': '', 'Vendor': '', + 'Date': '', 'Copyright': '', 'License': '', 'Abstract': '', + 'Description': '', 'Signature': '', 'XmlSpecification': '' + } =20 - ToolsMap =3D {'Name' : '', 'Copyright' : '', 'License' : '', - 'Abstract' : '', 'Description' : '', 'FileList' : []} + ToolsMap =3D {'Name': '', 'Copyright': '', 'License': '', + 'Abstract': '', 'Description': '', 'FileList': []} # # Only FileList is a list: [['file1', {}], ['file2', {}], ...] # - MiscMap =3D {'Name' : '', 'Copyright' : '', 'License' : '', - 'Abstract' : '', 'Description' : '', 'FileList' : []} + MiscMap =3D {'Name': '', 'Copyright': '', 'License': '', + 'Abstract': '', 'Description': '', 'FileList': []} =20 SectionMap =3D { - 'DistributionHeader' : DistMap, - 'ToolsHeader' : ToolsMap, - 'MiscellaneousFilesHeader' : MiscMap - } + 'DistributionHeader': DistMap, + 'ToolsHeader': ToolsMap, + 'MiscellaneousFilesHeader': MiscMap + } =20 PathValidator =3D { - 'ToolsHeader' : ValidateToolsFile, - 'MiscellaneousFilesHeader' : ValidateMiscFile - } + 'ToolsHeader': ValidateToolsFile, + 'MiscellaneousFilesHeader': ValidateMiscFile + } =20 ParsedSection =3D [] =20 @@ -332,11 +364,11 @@ def IniToXml(IniFile): SectionName =3D Line[1:-1].strip() if SectionName not in SectionMap: IniParseError(ST.ERR_SECTION_NAME_INVALID % SectionName, - IniFile, Index+1) + IniFile, Index+1) =20 if SectionName in ParsedSection: IniParseError(ST.ERR_SECTION_REDEFINE % SectionName, - IniFile, Index+1) + IniFile, Index+1) else: ParsedSection.append(SectionName) =20 @@ -419,7 +451,7 @@ def IniToXml(IniFile): return CreateXml(DistMap, ToolsMap, MiscMap, IniFile) =20 =20 -## CheckMdtKeys +# CheckMdtKeys # # @param MdtDistKeys: All mandatory keys # @param DistMap: Dist content @@ -428,7 +460,8 @@ def IniToXml(IniFile): # @param Maps: Tools and Misc section name and map. (('section_name', map)= ,*) # def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps): - MdtDistKeys =3D ['Name', 'GUID', 'Version', 'Vendor', 'Copyright', 'Li= cense', 'Abstract', 'XmlSpecification'] + MdtDistKeys =3D ['Name', 'GUID', 'Version', 'Vendor', + 'Copyright', 'License', 'Abstract', 'XmlSpecification'] for Key in MdtDistKeys: if Key not in DistMap or DistMap[Key] =3D=3D '': IniParseError(ST.ERR_KEYWORD_MANDATORY % Key, IniFile, LastInd= ex+1) @@ -460,22 +493,26 @@ def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps): NonEmptyKey +=3D 1 =20 if NonEmptyKey > 0 and not Map['FileList']: - IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.FileList= '), IniFile, LastIndex+1) + IniParseError(ST.ERR_KEYWORD_MANDATORY % + (Item[0] + '.FileList'), IniFile, LastIndex+1) =20 if NonEmptyKey > 0 and not Map['Name']: - IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.Name'), = IniFile, LastIndex+1) + IniParseError(ST.ERR_KEYWORD_MANDATORY % + (Item[0] + '.Name'), IniFile, LastIndex+1) =20 -## CreateXml +# CreateXml # # @param DistMap: Dist Content # @param ToolsMap: Tools Content # @param MiscMap: Misc Content # @param IniFile: Ini File # + + def CreateXml(DistMap, ToolsMap, MiscMap, IniFile): Attrs =3D [['xmlns', 'http://www.uefi.org/2011/1.1'], ['xmlns:xsi', 'http:/www.w3.org/2001/XMLSchema-instance'], - ] + ] Root =3D CreateXmlElement('DistributionPackage', '', [], Attrs) CreateHeaderXml(DistMap, Root) CreateToolsXml(ToolsMap, Root, 'Tools') @@ -489,8 +526,7 @@ def CreateXml(DistMap, ToolsMap, MiscMap, IniFile): File =3D open(FileName, 'w') =20 try: - File.write(Root.toprettyxml(indent =3D ' ')) + File.write(Root.toprettyxml(indent=3D' ')) finally: File.close() return FileName - diff --git a/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py b/Base= Tools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py index 741da908047c..f1548725219e 100644 --- a/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py +++ b/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a Module file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -48,7 +48,7 @@ from Xml.XmlParserMisc import GetHelpTextList from Library import GlobalData from Library.Misc import GetSplitValueList =20 -## BinaryFileXml +# BinaryFileXml # # represent the following XML item # @@ -62,6 +62,8 @@ from Library.Misc import GetSplitValueList # ... {0,} # {1,} # + + class BinaryFileXml(object): def __init__(self): self.FileNames =3D [] @@ -117,7 +119,8 @@ class BinaryFileXml(object): BuildFlagList =3D [] for SubItem in XmlList(Item, '%s/AsBuilt/BuildFlags' % Key= ): BuildFlag =3D BuildFlagXml() - BuildFlagList.append(BuildFlag.FromXml2(SubItem, 'Buil= dFlags')) + BuildFlagList.append( + BuildFlag.FromXml2(SubItem, 'BuildFlags')) AsBuilt.SetBuildFlagsList(BuildFlagList) AsBuiltList.append(AsBuilt) BinaryFile.SetAsBuiltList(AsBuiltList) @@ -156,17 +159,20 @@ class BinaryFileXml(object): for LibGuidVer in LibGuidVerList: if LibGuidVer.GetLibGuid() and IsMatchArch(LibGuidVer.GetSupAr= chList(), SupportArch): GuiVerElem =3D \ - CreateXmlElement('GUID', LibGuidVer.GetLibGuid(), [], [['V= ersion', LibGuidVer.GetLibVersion()]]) + CreateXmlElement('GUID', LibGuidVer.GetLibGuid(), [], [ + ['Version', LibGuidVer.GetLibVersion(= )]]) GuiVerElemList.append(GuiVerElem) if len(GuiVerElemList) > 0: - LibGuidVerElem =3D CreateXmlElement('LibraryInstances', '', Gu= iVerElemList, []) + LibGuidVerElem =3D CreateXmlElement( + 'LibraryInstances', '', GuiVerElemList, []) AsBuiltNodeList.append(LibGuidVerElem) =20 for BuildFlag in BuildFlagList: if IsMatchArch(BuildFlag.GetSupArchList(), SupportArch): for Item in BuildFlag.GetAsBuildList(): Tmp =3D BuildFlagXml() - Elem =3D CreateXmlElement('BuildFlags', ''.join(Item),= [], []) + Elem =3D CreateXmlElement( + 'BuildFlags', ''.join(Item), [], []) AsBuiltNodeList.append(Elem) =20 if len(AsBuiltNodeList) > 0: @@ -194,6 +200,8 @@ class BinaryFileXml(object): ## # PackageXml # + + class PackageXml(object): def __init__(self): self.Description =3D '' @@ -211,7 +219,8 @@ class PackageXml(object): PackageDependency.SetPackage(self.Description) PackageDependency.SetGuid(self.Guid) PackageDependency.SetVersion(self.Version) - PackageDependency.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefin= es.FeatureFlag)) + PackageDependency.SetFeatureFlag( + ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)) PackageDependency.SetSupArchList(self.CommonDefines.SupArchList) =20 return PackageDependency @@ -223,7 +232,8 @@ class PackageXml(object): ['FeatureFlag', ConvertNEToNOTEQ(PackageDependenc= y.GetFeatureFlag())], ] Element1 =3D CreateXmlElement('GUID', PackageDependency.GetGuid(),= [], [['Version', PackageDependency.GetVers= ion()]]) - NodeList =3D [['Description', PackageDependency.GetPackage()], Ele= ment1, ] + NodeList =3D [['Description', PackageDependency.GetPackage()], + Element1, ] Root =3D CreateXmlElement('%s' % Key, '', NodeList, AttributeList) =20 return Root @@ -235,6 +245,8 @@ class PackageXml(object): ## # ExternXml # + + class ExternXml(object): def __init__(self): self.CommonDefines =3D CommonDefinesXml() @@ -290,6 +302,8 @@ class ExternXml(object): ## # DepexXml # + + class DepexXml(object): def __init__(self): self.CommonDefines =3D CommonDefinesXml() @@ -337,6 +351,8 @@ class DepexXml(object): ## # BootModeXml # + + class BootModeXml(object): def __init__(self): self.SupportedBootModes =3D '' @@ -345,7 +361,7 @@ class BootModeXml(object): =20 def FromXml(self, Item, Key): self.SupportedBootModes =3D \ - XmlElement(Item, '%s/SupportedBootModes' % Key) + XmlElement(Item, '%s/SupportedBootModes' % Key) self.CommonDefines.FromXml(Item, Key) for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): HelpTextObj =3D HelpTextXml() @@ -372,13 +388,16 @@ class BootModeXml(object): return Root =20 def __str__(self): - Str =3D "SupportedBootModes =3D %s %s" % (self.SupportedBootModes,= self.CommonDefines) + Str =3D "SupportedBootModes =3D %s %s" % ( + self.SupportedBootModes, self.CommonDefines) for Item in self.HelpText: Str =3D Str + '\n\t' + str(Item) return Str ## # EventXml # + + class EventXml(object): def __init__(self): self.EventType =3D '' @@ -407,7 +426,7 @@ class EventXml(object): pass AttributeList =3D [['EventType', Event.GetEventType()], ['Usage', Event.GetUsage()], - ] + ] NodeList =3D [] for Item in Event.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -424,6 +443,8 @@ class EventXml(object): ## # HobXml # + + class HobXml(object): def __init__(self): self.HobType =3D '' @@ -471,6 +492,8 @@ class HobXml(object): ## # SourceFileXml # + + class SourceFileXml(object): def __init__(self): self.SourceFile =3D '' @@ -483,7 +506,8 @@ class SourceFileXml(object): self.SourceFile =3D XmlElement(Item, 'Filename') self.CommonDefines.FromXml(Item, Key) =20 - self.CommonDefines.FeatureFlag =3D ConvertNOTEQToNE(self.CommonDef= ines.FeatureFlag) + self.CommonDefines.FeatureFlag =3D ConvertNOTEQToNE( + self.CommonDefines.FeatureFlag) =20 SourceFile =3D SourceFileObject() SourceFile.SetSourceFile(self.SourceFile) @@ -500,12 +524,15 @@ class SourceFileXml(object): AttributeList =3D [['SupArchList', GetStringOfList(SourceFile.GetS= upArchList())], ['Family', SourceFile.GetFamily()], ['FeatureFlag', FeatureFlag], ] - Root =3D CreateXmlElement('%s' % Key, SourceFile.GetSourceFile(), = [], AttributeList) + Root =3D CreateXmlElement( + '%s' % Key, SourceFile.GetSourceFile(), [], AttributeList) return Root =20 ## # ModulePropertyXml # + + class ModulePropertyXml(object): def __init__(self): self.CommonDefines =3D CommonDefinesXml() @@ -525,11 +552,14 @@ class ModulePropertyXml(object): self.ModuleType =3D XmlElement(Item, '%s/ModuleType' % Key) self.Path =3D XmlElement(Item, '%s/Path' % Key) self.PcdIsDriver =3D XmlElement(Item, '%s/PcdIsDriver' % Key) - self.UefiSpecificationVersion =3D XmlElement(Item, '%s/UefiSpecifi= cationVersion' % Key) - self.PiSpecificationVersion =3D XmlElement(Item, '%s/PiSpecificati= onVersion' % Key) + self.UefiSpecificationVersion =3D XmlElement( + Item, '%s/UefiSpecificationVersion' % Key) + self.PiSpecificationVersion =3D XmlElement( + Item, '%s/PiSpecificationVersion' % Key) for SubItem in XmlList(Item, '%s/Specification' % Key): Specification =3D XmlElement(SubItem, '/Specification') - Version =3D XmlAttribute(XmlNode(SubItem, '/Specification'), '= Version') + Version =3D XmlAttribute( + XmlNode(SubItem, '/Specification'), 'Version') self.SpecificationList.append((Specification, Version)) for SubItem in XmlList(Item, '%s/BootMode' % Key): Axml =3D BootModeXml() @@ -558,21 +588,23 @@ class ModulePropertyXml(object): =20 return Header, self.BootModes, self.Events, self.HOBs =20 - def ToXml(self, Header, BootModes, Events, Hobs, Key): if self.ModuleType: pass - AttributeList =3D [['SupArchList', GetStringOfList(Header.GetSupAr= chList())], ] + AttributeList =3D [ + ['SupArchList', GetStringOfList(Header.GetSupArchList())], ] =20 NodeList =3D [['ModuleType', Header.GetModuleType()], ['Path', Header.GetModulePath()], ['PcdIsDriver', Header.GetPcdIsDriver()], - ['UefiSpecificationVersion', Header.GetUefiSpecificati= onVersion()], + ['UefiSpecificationVersion', + Header.GetUefiSpecificationVersion()], ['PiSpecificationVersion', Header.GetPiSpecificationVe= rsion()], - ] + ] for Item in Header.GetSpecList(): Spec, Version =3D Item - SpecElem =3D CreateXmlElement('Specification', Spec, [], [['Ve= rsion', Version]]) + SpecElem =3D CreateXmlElement( + 'Specification', Spec, [], [['Version', Version]]) NodeList.append(SpecElem) =20 for Item in BootModes: @@ -591,9 +623,9 @@ class ModulePropertyXml(object): def __str__(self): Str =3D "ModuleType =3D %s Path =3D %s PcdIsDriver =3D %s UefiSpec= ificationVersion =3D %s PiSpecificationVersion =3D %s \ Specification =3D %s SpecificationVersion =3D %s %s" % \ - (self.ModuleType, self.Path, self.PcdIsDriver, \ - self.UefiSpecificationVersion, self.PiSpecificationVersion, \ - self.SpecificationList, self.SpecificationVersion, self.CommonDef= ines) + (self.ModuleType, self.Path, self.PcdIsDriver, + self.UefiSpecificationVersion, self.PiSpecificationVersion, + self.SpecificationList, self.SpecificationVersion, self.Commo= nDefines) for Item in self.BootModes: Str =3D Str + '\n\t' + str(Item) for Item in self.Events: @@ -605,6 +637,8 @@ class ModulePropertyXml(object): ## # ModuleXml # + + class ModuleSurfaceAreaXml(object): def __init__(self, Package=3D''): self.Module =3D None @@ -649,7 +683,8 @@ class ModuleSurfaceAreaXml(object): # # MiscellaneousFile Tmp =3D MiscellaneousFileXml() - MiscFileList =3D Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/Mis= cellaneousFiles'), 'MiscellaneousFiles') + MiscFileList =3D Tmp.FromXml( + XmlNode(Item, '/ModuleSurfaceArea/MiscellaneousFiles'), 'Misce= llaneousFiles') if MiscFileList: Module.SetMiscFileList([MiscFileList]) else: @@ -661,7 +696,8 @@ class ModuleSurfaceAreaXml(object): for Item in XmlList(Item, '/ModuleSurfaceArea/UserExtensions'): Tmp =3D UserExtensionsXml() UserExtension =3D Tmp.FromXml(Item, 'UserExtensions') - Module.SetUserExtensionList(Module.GetUserExtensionList() + [U= serExtension]) + Module.SetUserExtensionList( + Module.GetUserExtensionList() + [UserExtension]) =20 return Module =20 @@ -671,7 +707,8 @@ class ModuleSurfaceAreaXml(object): # Header # Tmp =3D HeaderXml() - Module =3D Tmp.FromXml(XmlNode(Item, '/%s/Header' % Key), 'Header'= , True, IsStandAlongModule) + Module =3D Tmp.FromXml(XmlNode(Item, '/%s/Header' % + Key), 'Header', True, IsStandAlongModule) Module.SetBinaryModule(IsBinaryModule) =20 if IsBinaryModule: @@ -682,7 +719,8 @@ class ModuleSurfaceAreaXml(object): # Tmp =3D ModulePropertyXml() (Module, BootModes, Events, HOBs) =3D \ - Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/ModuleProperties'), = 'ModuleProperties', Module) + Tmp.FromXml(XmlNode( + Item, '/ModuleSurfaceArea/ModuleProperties'), 'ModulePrope= rties', Module) Module.SetBootModeList(BootModes) Module.SetEventList(Events) Module.SetHobList(HOBs) @@ -690,7 +728,8 @@ class ModuleSurfaceAreaXml(object): # ClonedFrom # Tmp =3D ClonedFromXml() - ClonedFrom =3D Tmp.FromXml(XmlNode(Item, '/ModuleSurfaceArea/Clone= dFrom'), 'ClonedFrom') + ClonedFrom =3D Tmp.FromXml( + XmlNode(Item, '/ModuleSurfaceArea/ClonedFrom'), 'ClonedFrom') if ClonedFrom: Module.SetClonedFrom(ClonedFrom) =20 @@ -700,7 +739,8 @@ class ModuleSurfaceAreaXml(object): for SubItem in XmlList(Item, '/ModuleSurfaceArea/LibraryClassDefin= itions/LibraryClass'): Tmp =3D LibraryClassXml() LibraryClass =3D Tmp.FromXml(SubItem, 'LibraryClass') - Module.SetLibraryClassList(Module.GetLibraryClassList() + [Lib= raryClass]) + Module.SetLibraryClassList( + Module.GetLibraryClassList() + [LibraryClass]) =20 if XmlList(Item, '/ModuleSurfaceArea/LibraryClassDefinitions') and= \ not XmlList(Item, '/ModuleSurfaceArea/LibraryClassDefinitions/L= ibraryClass'): @@ -715,7 +755,7 @@ class ModuleSurfaceAreaXml(object): Module.SetSourceFileList(Module.GetSourceFileList() + [SourceF= ile]) =20 if XmlList(Item, '/ModuleSurfaceArea/SourceFiles') and \ - not XmlList(Item, '/ModuleSurfaceArea/SourceFiles/Filename') : + not XmlList(Item, '/ModuleSurfaceArea/SourceFiles/Filename'): Module.SetSourceFileList([None]) =20 # @@ -727,7 +767,7 @@ class ModuleSurfaceAreaXml(object): Module.SetBinaryFileList(Module.GetBinaryFileList() + [BinaryF= ile]) =20 if XmlList(Item, '/ModuleSurfaceArea/BinaryFiles') and \ - not XmlList(Item, '/ModuleSurfaceArea/BinaryFiles/BinaryFile') : + not XmlList(Item, '/ModuleSurfaceArea/BinaryFiles/BinaryFile'): Module.SetBinaryFileList([None]) # # PackageDependencies @@ -735,7 +775,8 @@ class ModuleSurfaceAreaXml(object): for SubItem in XmlList(Item, '/ModuleSurfaceArea/PackageDependenci= es/Package'): Tmp =3D PackageXml() PackageDependency =3D Tmp.FromXml(SubItem, 'Package') - Module.SetPackageDependencyList(Module.GetPackageDependencyLis= t() + [PackageDependency]) + Module.SetPackageDependencyList( + Module.GetPackageDependencyList() + [PackageDependency]) =20 if XmlList(Item, '/ModuleSurfaceArea/PackageDependencies') and \ not XmlList(Item, '/ModuleSurfaceArea/PackageDependencies/Packa= ge'): @@ -758,7 +799,8 @@ class ModuleSurfaceAreaXml(object): for SubItem in XmlList(Item, '/ModuleSurfaceArea/Protocols/Protoco= l'): Tmp =3D ProtocolXml('Module') GuidProtocolPpi =3D Tmp.FromXml(SubItem, 'Protocol') - Module.SetProtocolList(Module.GetProtocolList() + [GuidProtoco= lPpi]) + Module.SetProtocolList( + Module.GetProtocolList() + [GuidProtocolPpi]) =20 if XmlList(Item, '/ModuleSurfaceArea/Protocols') and not XmlList(I= tem, '/ModuleSurfaceArea/Protocols/Protocol'): Module.SetProtocolList([None]) @@ -795,7 +837,7 @@ class ModuleSurfaceAreaXml(object): Module.SetPcdList(Module.GetPcdList() + [PcdEntry]) =20 if XmlList(Item, '/ModuleSurfaceArea/PcdCoded') and \ - not XmlList(Item, '/ModuleSurfaceArea/PcdCoded/PcdEntry'): + not XmlList(Item, '/ModuleSurfaceArea/PcdCoded/PcdEntr= y'): Module.SetPcdList([None]) =20 Module =3D self.FromXml2(Item, Module) @@ -824,21 +866,24 @@ class ModuleSurfaceAreaXml(object): # ModuleProperties # Tmp =3D ModulePropertyXml() - DomModule.appendChild(Tmp.ToXml(Module, Module.GetBootModeList(), = Module.GetEventList(), Module.GetHobList(), \ + DomModule.appendChild(Tmp.ToXml(Module, Module.GetBootModeList(), = Module.GetEventList(), Module.GetHobList(), 'ModuleProperties')) # # ClonedFrom # Tmp =3D ClonedFromXml() if Module.GetClonedFrom(): - DomModule.appendChild(Tmp.ToXml(Module.GetClonedFrom(), 'Clone= dFrom')) + DomModule.appendChild( + Tmp.ToXml(Module.GetClonedFrom(), 'ClonedFrom')) # # LibraryClass # - LibraryClassNode =3D CreateXmlElement('LibraryClassDefinitions', '= ', [], []) + LibraryClassNode =3D CreateXmlElement( + 'LibraryClassDefinitions', '', [], []) for LibraryClass in Module.GetLibraryClassList(): Tmp =3D LibraryClassXml() - LibraryClassNode.appendChild(Tmp.ToXml2(LibraryClass, 'Library= Class')) + LibraryClassNode.appendChild( + Tmp.ToXml2(LibraryClass, 'LibraryClass')) DomModule.appendChild(LibraryClassNode) # # SourceFile @@ -859,10 +904,12 @@ class ModuleSurfaceAreaXml(object): # # PackageDependencies # - PackageDependencyNode =3D CreateXmlElement('PackageDependencies', = '', [], []) + PackageDependencyNode =3D CreateXmlElement( + 'PackageDependencies', '', [], []) for PackageDependency in Module.GetPackageDependencyList(): Tmp =3D PackageXml() - PackageDependencyNode.appendChild(Tmp.ToXml(PackageDependency,= 'Package')) + PackageDependencyNode.appendChild( + Tmp.ToXml(PackageDependency, 'Package')) DomModule.appendChild(PackageDependencyNode) =20 # @@ -871,7 +918,8 @@ class ModuleSurfaceAreaXml(object): GuidProtocolPpiNode =3D CreateXmlElement('Guids', '', [], []) for GuidProtocolPpi in Module.GetGuidList(): Tmp =3D GuidXml('Module') - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Gu= idCName')) + GuidProtocolPpiNode.appendChild( + Tmp.ToXml(GuidProtocolPpi, 'GuidCName')) DomModule.appendChild(GuidProtocolPpiNode) =20 # @@ -880,7 +928,8 @@ class ModuleSurfaceAreaXml(object): GuidProtocolPpiNode =3D CreateXmlElement('Protocols', '', [], []) for GuidProtocolPpi in Module.GetProtocolList(): Tmp =3D ProtocolXml('Module') - GuidProtocolPpiNode.appendChild(Tmp.ToXml(GuidProtocolPpi, 'Pr= otocol')) + GuidProtocolPpiNode.appendChild( + Tmp.ToXml(GuidProtocolPpi, 'Protocol')) DomModule.appendChild(GuidProtocolPpiNode) =20 # @@ -937,20 +986,24 @@ class ModuleSurfaceAreaXml(object): # if Module.GetMiscFileList(): Tmp =3D MiscellaneousFileXml() - DomModule.appendChild(Tmp.ToXml(Module.GetMiscFileList()[0], '= MiscellaneousFiles')) + DomModule.appendChild( + Tmp.ToXml(Module.GetMiscFileList()[0], 'MiscellaneousFiles= ')) # # UserExtensions # if Module.GetUserExtensionList(): for UserExtension in Module.GetUserExtensionList(): Tmp =3D UserExtensionsXml() - DomModule.appendChild(Tmp.ToXml(UserExtension, 'UserExtens= ions')) + DomModule.appendChild( + Tmp.ToXml(UserExtension, 'UserExtensions')) =20 return DomModule =20 ## # BuildFlagXml used to generate BuildFlag for # + + class BuildFlagXml(object): def __init__(self): self.Target =3D '' diff --git a/BaseTools/Source/Python/UPT/Xml/PackageSurfaceAreaXml.py b/Bas= eTools/Source/Python/UPT/Xml/PackageSurfaceAreaXml.py index 103939023bcf..9e1df1faf56d 100644 --- a/BaseTools/Source/Python/UPT/Xml/PackageSurfaceAreaXml.py +++ b/BaseTools/Source/Python/UPT/Xml/PackageSurfaceAreaXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a Package file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -35,6 +35,8 @@ from Xml.PcdXml import PcdEntryXml ## # IndustryStandardHeaderXml # + + class IndustryStandardHeaderXml(object): def __init__(self): self.HeaderFile =3D '' @@ -72,6 +74,8 @@ class IndustryStandardHeaderXml(object): ## # PackageIncludeHeaderXml # + + class PackageIncludeHeaderXml(object): def __init__(self): self.HeaderFile =3D '' @@ -80,7 +84,8 @@ class PackageIncludeHeaderXml(object): =20 def FromXml(self, Item, Key): self.HeaderFile =3D XmlElement(Item, '%s/HeaderFile' % Key) - self.CommonDefines.FromXml(XmlNode(Item, '%s/HeaderFile' % Key), '= HeaderFile') + self.CommonDefines.FromXml( + XmlNode(Item, '%s/HeaderFile' % Key), 'HeaderFile') for HelpTextItem in XmlList(Item, '%s/HelpText' % Key): HelpTextObj =3D HelpTextXml() HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key) @@ -98,10 +103,11 @@ class PackageIncludeHeaderXml(object): def ToXml(self, PackageIncludeHeader, Key): if self.HeaderFile: pass - AttributeList =3D [['SupArchList', GetStringOfList(PackageIncludeH= eader.GetSupArchList())], \ + AttributeList =3D [['SupArchList', GetStringOfList(PackageIncludeH= eader.GetSupArchList())], ['SupModList', GetStringOfList(PackageIncludeHead= er.GetSupModuleList())], ] =20 - HeaderFileNode =3D CreateXmlElement('HeaderFile', PackageIncludeHe= ader.FilePath, [], AttributeList) + HeaderFileNode =3D CreateXmlElement( + 'HeaderFile', PackageIncludeHeader.FilePath, [], AttributeList) =20 NodeList =3D [HeaderFileNode] for Item in PackageIncludeHeader.GetHelpTextList(): @@ -121,6 +127,8 @@ class PackageIncludeHeaderXml(object): ## # PcdCheckXml # + + class PcdCheckXml(object): def __init__(self): self.PcdCheck =3D '' @@ -144,6 +152,8 @@ class PcdCheckXml(object): ## # PackageSurfaceAreaXml # + + class PackageSurfaceAreaXml(object): def __init__(self): self.Package =3D None @@ -159,13 +169,15 @@ class PackageSurfaceAreaXml(object): # Header # Tmp =3D PackageHeaderXml() - Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/Header'), 'Header',= Package) + Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/Header'), + 'Header', Package) # # ClonedFrom # Tmp =3D ClonedFromXml() if XmlNode(Item, '/PackageSurfaceArea/ClonedFrom'): - ClonedFrom =3D Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/= ClonedFrom'), 'ClonedFrom') + ClonedFrom =3D Tmp.FromXml( + XmlNode(Item, '/PackageSurfaceArea/ClonedFrom'), 'ClonedFr= om') Package.SetClonedFromList([ClonedFrom]) # # LibraryClass @@ -174,7 +186,8 @@ class PackageSurfaceAreaXml(object): for SubItem in XmlList(Item, '/PackageSurfaceArea/LibraryClassDecl= arations/LibraryClass'): Tmp =3D LibraryClassXml() LibraryClass =3D Tmp.FromXml(SubItem, 'LibraryClass') - Package.SetLibraryClassList(Package.GetLibraryClassList() + [L= ibraryClass]) + Package.SetLibraryClassList( + Package.GetLibraryClassList() + [LibraryClass]) =20 if XmlList(Item, '/PackageSurfaceArea/LibraryClassDeclarations') a= nd \ not XmlList(Item, '/PackageSurfaceArea/LibraryClassDeclarations= /LibraryClass'): @@ -186,20 +199,21 @@ class PackageSurfaceAreaXml(object): for SubItem in XmlList(Item, '/PackageSurfaceArea/IndustryStandard= Includes/IndustryStandardHeader'): Tmp =3D IndustryStandardHeaderXml() Include =3D Tmp.FromXml(SubItem, 'IndustryStandardHeader') - Package.SetStandardIncludeFileList(Package.GetStandardIncludeF= ileList() + [Include]) + Package.SetStandardIncludeFileList( + Package.GetStandardIncludeFileList() + [Include]) =20 if XmlList(Item, '/PackageSurfaceArea/IndustryStandardIncludes') a= nd \ - not XmlList(Item, '/PackageSurfaceArea/IndustryStandardIncludes/In= dustryStandardHeader'): + not XmlList(Item, '/PackageSurfaceArea/IndustryStandardInc= ludes/IndustryStandardHeader'): Package.SetStandardIncludeFileList([None]) =20 - # # PackageHeader # for SubItem in XmlList(Item, '/PackageSurfaceArea/PackageIncludes/= PackageHeader'): Tmp =3D PackageIncludeHeaderXml() Include =3D Tmp.FromXml(SubItem, 'PackageHeader') - Package.SetPackageIncludeFileList(Package.GetPackageIncludeFil= eList() + [Include]) + Package.SetPackageIncludeFileList( + Package.GetPackageIncludeFileList() + [Include]) =20 if XmlList(Item, '/PackageSurfaceArea/PackageIncludes') and not \ XmlList(Item, '/PackageSurfaceArea/PackageIncludes/PackageHeade= r'): @@ -223,7 +237,8 @@ class PackageSurfaceAreaXml(object): for SubItem in XmlList(Item, '/PackageSurfaceArea/ProtocolDeclarat= ions/Entry'): Tmp =3D ProtocolXml('Package') GuidProtocolPpi =3D Tmp.FromXml(SubItem, 'Entry') - Package.SetProtocolList(Package.GetProtocolList() + [GuidProto= colPpi]) + Package.SetProtocolList( + Package.GetProtocolList() + [GuidProtocolPpi]) =20 if XmlList(Item, '/PackageSurfaceArea/ProtocolDeclarations') and n= ot \ XmlList(Item, '/PackageSurfaceArea/ProtocolDeclarations/Entry'): @@ -256,8 +271,7 @@ class PackageSurfaceAreaXml(object): PcdErrorMessageList =3D PcdErrorObj.GetErrorMessageList() if PcdErrorMessageList: Package.PcdErrorCommentDict[(PcdEntry.GetTokenSpaceGui= dCName(), PcdErrorObj.GetErrorNumber())] =3D \ - PcdErrorMessageList - + PcdErrorMessageList =20 if XmlList(Item, '/PackageSurfaceArea/PcdDeclarations') and not \ XmlList(Item, '/PackageSurfaceArea/PcdDeclarations/PcdEntry'): @@ -277,13 +291,15 @@ class PackageSurfaceAreaXml(object): for SubItem in XmlList(Item, '/PackageSurfaceArea/Modules/ModuleSu= rfaceArea'): Tmp =3D ModuleSurfaceAreaXml() Module =3D Tmp.FromXml(SubItem, 'ModuleSurfaceArea') - ModuleDictKey =3D (Module.GetGuid(), Module.GetVersion(), Modu= le.GetName(), Module.GetModulePath()) + ModuleDictKey =3D (Module.GetGuid(), Module.GetVersion(), + Module.GetName(), Module.GetModulePath()) Package.ModuleDict[ModuleDictKey] =3D Module # # MiscellaneousFile # Tmp =3D MiscellaneousFileXml() - MiscFileList =3D Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/Mi= scellaneousFiles'), 'MiscellaneousFiles') + MiscFileList =3D Tmp.FromXml( + XmlNode(Item, '/PackageSurfaceArea/MiscellaneousFiles'), 'Misc= ellaneousFiles') if MiscFileList: Package.SetMiscFileList([MiscFileList]) else: @@ -317,30 +333,37 @@ class PackageSurfaceAreaXml(object): # Tmp =3D ClonedFromXml() if Package.GetClonedFromList() !=3D []: - DomPackage.appendChild(Tmp.ToXml(Package.GetClonedFromList[0],= 'ClonedFrom')) + DomPackage.appendChild( + Tmp.ToXml(Package.GetClonedFromList[0], 'ClonedFrom')) # # LibraryClass # - LibraryClassNode =3D CreateXmlElement('LibraryClassDeclarations', = '', [], []) + LibraryClassNode =3D CreateXmlElement( + 'LibraryClassDeclarations', '', [], []) for LibraryClass in Package.GetLibraryClassList(): Tmp =3D LibraryClassXml() - LibraryClassNode.appendChild(Tmp.ToXml(LibraryClass, 'LibraryC= lass')) + LibraryClassNode.appendChild( + Tmp.ToXml(LibraryClass, 'LibraryClass')) DomPackage.appendChild(LibraryClassNode) # # IndustryStandardHeader # - IndustryStandardHeaderNode =3D CreateXmlElement('IndustryStandardI= ncludes', '', [], []) + IndustryStandardHeaderNode =3D CreateXmlElement( + 'IndustryStandardIncludes', '', [], []) for Include in Package.GetStandardIncludeFileList(): Tmp =3D IndustryStandardHeaderXml() - IndustryStandardHeaderNode.appendChild(Tmp.ToXml(Include, 'Ind= ustryStandardHeader')) + IndustryStandardHeaderNode.appendChild( + Tmp.ToXml(Include, 'IndustryStandardHeader')) DomPackage.appendChild(IndustryStandardHeaderNode) # # PackageHeader # - PackageIncludeHeaderNode =3D CreateXmlElement('PackageIncludes', '= ', [], []) + PackageIncludeHeaderNode =3D CreateXmlElement( + 'PackageIncludes', '', [], []) for Include in Package.GetPackageIncludeFileList(): Tmp =3D PackageIncludeHeaderXml() - PackageIncludeHeaderNode.appendChild(Tmp.ToXml(Include, 'Packa= geHeader')) + PackageIncludeHeaderNode.appendChild( + Tmp.ToXml(Include, 'PackageHeader')) DomPackage.appendChild(PackageIncludeHeaderNode) ModuleNode =3D CreateXmlElement('Modules', '', [], []) for Module in Package.GetModuleDict().values(): @@ -353,18 +376,18 @@ class PackageSurfaceAreaXml(object): GuidProtocolPpiNode =3D CreateXmlElement('GuidDeclarations', '', [= ], []) for GuidProtocolPpi in Package.GetGuidList(): Tmp =3D GuidXml('Package') - GuidProtocolPpiNode.appendChild(Tmp.ToXml\ + GuidProtocolPpiNode.appendChild(Tmp.ToXml (GuidProtocolPpi, 'Entry')) DomPackage.appendChild(GuidProtocolPpiNode) # # Protocol # GuidProtocolPpiNode =3D \ - CreateXmlElement('ProtocolDeclarations', '', [], []) + CreateXmlElement('ProtocolDeclarations', '', [], []) for GuidProtocolPpi in Package.GetProtocolList(): Tmp =3D ProtocolXml('Package') - GuidProtocolPpiNode.appendChild\ - (Tmp.ToXml(GuidProtocolPpi, 'Entry')) + GuidProtocolPpiNode.appendChild( + Tmp.ToXml(GuidProtocolPpi, 'Entry')) DomPackage.appendChild(GuidProtocolPpiNode) # # Ppi @@ -372,8 +395,8 @@ class PackageSurfaceAreaXml(object): GuidProtocolPpiNode =3D CreateXmlElement('PpiDeclarations', '', []= , []) for GuidProtocolPpi in Package.GetPpiList(): Tmp =3D PpiXml('Package') - GuidProtocolPpiNode.appendChild\ - (Tmp.ToXml(GuidProtocolPpi, 'Entry')) + GuidProtocolPpiNode.appendChild( + Tmp.ToXml(GuidProtocolPpi, 'Entry')) DomPackage.appendChild(GuidProtocolPpiNode) # # PcdEntry @@ -389,7 +412,8 @@ class PackageSurfaceAreaXml(object): # Tmp =3D MiscellaneousFileXml() if Package.GetMiscFileList(): - DomPackage.appendChild(Tmp.ToXml(Package.GetMiscFileList()[0],= 'MiscellaneousFiles')) + DomPackage.appendChild( + Tmp.ToXml(Package.GetMiscFileList()[0], 'MiscellaneousFile= s')) =20 # # UserExtensions @@ -397,6 +421,7 @@ class PackageSurfaceAreaXml(object): if Package.GetUserExtensionList(): for UserExtension in Package.GetUserExtensionList(): Tmp =3D UserExtensionsXml() - DomPackage.appendChild(Tmp.ToXml(UserExtension, 'UserExten= sions')) + DomPackage.appendChild( + Tmp.ToXml(UserExtension, 'UserExtensions')) =20 return DomPackage diff --git a/BaseTools/Source/Python/UPT/Xml/PcdXml.py b/BaseTools/Source/P= ython/UPT/Xml/PcdXml.py index bbcee45a0132..22fa048afbc3 100644 --- a/BaseTools/Source/Python/UPT/Xml/PcdXml.py +++ b/BaseTools/Source/Python/UPT/Xml/PcdXml.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a PCD file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -35,6 +35,8 @@ import re ## # PcdErrorXml # + + class PcdErrorXml(object): def __init__(self): self.ValidValueList =3D '' @@ -47,14 +49,15 @@ class PcdErrorXml(object): def FromXml(self, Item, Key): self.ValidValueList =3D XmlElement(Item, '%s/ValidValueList' % Key) self.ValidValueListLang =3D \ - XmlAttribute(XmlNode(Item, '%s/ValidValueList' % Key), 'Lang') - self.ValidValueRange =3D self.TransferValidEpxr2ValidRange(XmlElem= ent(Item, '%s/ValidValueRange' % Key)) + XmlAttribute(XmlNode(Item, '%s/ValidValueList' % Key), 'Lang') + self.ValidValueRange =3D self.TransferValidEpxr2ValidRange( + XmlElement(Item, '%s/ValidValueRange' % Key)) self.Expression =3D XmlElement(Item, '%s/Expression' % Key) self.ErrorNumber =3D XmlElement(Item, '%s/ErrorNumber' % Key) for ErrMsg in XmlList(Item, '%s/ErrorMessage' % Key): ErrorMessageString =3D XmlElement(ErrMsg, 'ErrorMessage') ErrorMessageLang =3D \ - XmlAttribute(XmlNode(ErrMsg, 'ErrorMessage'), 'Lang') + XmlAttribute(XmlNode(ErrMsg, 'ErrorMessage'), 'Lang') self.ErrorMessage.append((ErrorMessageLang, ErrorMessageString= )) =20 Error =3D PcdErrorObject() @@ -74,16 +77,16 @@ class PcdErrorXml(object): NodeList =3D [] if PcdError.GetValidValue(): Element1 =3D \ - CreateXmlElement('ValidValueList', PcdError.GetValidValue(), [= ], \ - [['Lang', PcdError.GetValidValueLang()]]) + CreateXmlElement('ValidValueList', PcdError.GetValidValue(= ), [], + [['Lang', PcdError.GetValidValueLang()]]) NodeList.append(Element1) if PcdError.GetValidValueRange(): TansferedRangeStr =3D self.TransferValidRange2Expr(PcdError.Ge= tTokenSpaceGuidCName(), PcdError.GetC= Name(), PcdError.GetV= alidValueRange()) Element1 =3D \ - CreateXmlElement('ValidValueRange', \ - TansferedRangeStr, [], []) + CreateXmlElement('ValidValueRange', + TansferedRangeStr, [], []) NodeList.append(Element1) if PcdError.GetExpression(): NodeList.append(['Expression', PcdError.GetExpression()]) @@ -91,7 +94,8 @@ class PcdErrorXml(object): NodeList.append(['ErrorNumber', PcdError.GetErrorNumber()]) for Item in PcdError.GetErrorMessageList(): Element =3D \ - CreateXmlElement('ErrorMessage', Item[1], [], [['Lang', Item[0= ]]]) + CreateXmlElement('ErrorMessage', Item[1], [], [ + ['Lang', Item[0]]]) NodeList.append(Element) Root =3D CreateXmlElement('%s' % Key, '', NodeList, AttributeList) =20 @@ -137,7 +141,8 @@ class PcdErrorXml(object): for MatchStr in HexMatchedList: RangeItemList =3D MatchStr.strip().split('-') TransferedRangeStr =3D '(%s GE %s) AND (%s LE %s)' % \ - (PcdName, RangeItemList[0].strip(), PcdName, RangeItemList= [1].strip()) + (PcdName, RangeItemList[0].strip(), + PcdName, RangeItemList[1].strip()) ValidRange =3D ValidRange.replace(MatchStr, TransferedRangeStr) # # Convert INT1 format range @@ -148,7 +153,8 @@ class PcdErrorXml(object): for MatchStr in IntMatchedList: RangeItemList =3D MatchStr.strip().split('-') TransferedRangeStr =3D '(%s GE %s) AND (%s LE %s)' % \ - (PcdName, RangeItemList[0].strip(), PcdName, RangeItemList= [1].strip()) + (PcdName, RangeItemList[0].strip(), + PcdName, RangeItemList[1].strip()) ValidRange =3D ValidRange.replace(MatchStr, TransferedRangeStr) =20 return ValidRange @@ -158,18 +164,20 @@ class PcdErrorXml(object): pass =20 PCD_PATTERN =3D \ - '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_= ]*[\t\s]*' + '[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z= 0-9_]*[\t\s]*' IntPattern1 =3D \ - '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+\d+[\t\s]*\)[\t\s]= +AND[\t\s]+\([\t\s]*'+\ - PCD_PATTERN+'[\t\s]+LE[\t\s]+\d+[\t\s]*\)' + '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+\d+[\t\s]*\)[\= t\s]+AND[\t\s]+\([\t\s]*' +\ + PCD_PATTERN+'[\t\s]+LE[\t\s]+\d+[\t\s]*\)' IntPattern1 =3D IntPattern1.replace(' ', '') - IntPattern2 =3D '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)= [\t\s]+\d+[\t\s]*' + IntPattern2 =3D '[\t\s]*'+PCD_PATTERN + \ + '[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*' =20 HexPattern1 =3D \ - '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+0[xX][0-9a-fA-F]+[= \t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\ - PCD_PATTERN+'[\t\s]+LE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)' + '[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+0[xX][0-9a-fA-= F]+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*' +\ + PCD_PATTERN+'[\t\s]+LE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)' HexPattern1 =3D HexPattern1.replace(' ', '') - HexPattern2 =3D '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)= [\t\s]+0[xX][0-9a-zA-Z]+[\t\s]*' + HexPattern2 =3D '[\t\s]*'+PCD_PATTERN + \ + '[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][0-9a-zA-Z]+[\t\s]*' =20 # # Do the Hex1 conversion @@ -180,7 +188,8 @@ class PcdErrorXml(object): # # To match items on both sides of '-' # - RangeItemList =3D re.compile('[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*'= ).findall(HexMatchedItem) + RangeItemList =3D re.compile( + '[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*').findall(HexMatchedItem) if RangeItemList and len(RangeItemList) =3D=3D 2: HexRangeDict[HexMatchedItem] =3D RangeItemList =20 @@ -204,7 +213,8 @@ class PcdErrorXml(object): # # To match items on both sides of '-' # - RangeItemList =3D re.compile('[\t\s]*\d+[\t\s]*').findall(Matc= hedItem) + RangeItemList =3D re.compile( + '[\t\s]*\d+[\t\s]*').findall(MatchedItem) if RangeItemList and len(RangeItemList) =3D=3D 2: IntRangeDict[MatchedItem] =3D RangeItemList =20 @@ -236,17 +246,17 @@ class PcdErrorXml(object): =20 return ValidRangeExpr =20 - - def __str__(self): return "ValidValueList =3D %s ValidValueListLang =3D %s ValidValue= Range \ =3D %s Expression =3D %s ErrorNumber =3D %s %s" % \ - (self.ValidValueList, self.ValidValueListLang, self.ValidValueRang= e, \ - self.Expression, self.ErrorNumber, self.ErrorMessage) + (self.ValidValueList, self.ValidValueListLang, self.ValidValue= Range, + self.Expression, self.ErrorNumber, self.ErrorMessage) =20 ## # PcdEntryXml # + + class PcdEntryXml(object): def __init__(self): self.PcdItemType =3D '' @@ -272,12 +282,12 @@ class PcdEntryXml(object): # def FromXml(self, Item, Key): self.PcdItemType =3D \ - XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType') + XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType') self.PcdUsage =3D XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdUsag= e') self.TokenSpaceGuidCName =3D \ - XmlElement(Item, '%s/TokenSpaceGuidCname' % Key) + XmlElement(Item, '%s/TokenSpaceGuidCname' % Key) self.TokenSpaceGuidValue =3D \ - XmlElement(Item, '%s/TokenSpaceGuidValue' % Key) + XmlElement(Item, '%s/TokenSpaceGuidValue' % Key) self.Token =3D XmlElement(Item, '%s/Token' % Key) self.CName =3D XmlElement(Item, '%s/CName' % Key) self.PcdCName =3D XmlElement(Item, '%s/PcdCName' % Key) @@ -315,7 +325,8 @@ class PcdEntryXml(object): PcdEntry.SetValidUsage(self.ValidUsage) PcdEntry.SetDefaultValue(self.DefaultValue) PcdEntry.SetMaxDatumSize(self.MaxDatumSize) - PcdEntry.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.Featur= eFlag)) + PcdEntry.SetFeatureFlag(ConvertNOTEQToNE( + self.CommonDefines.FeatureFlag)) PcdEntry.SetItemType(self.PcdItemType) =20 PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText)) @@ -325,9 +336,10 @@ class PcdEntryXml(object): ## # Package will use FromXml2 # + def FromXml2(self, Item, Key): self.TokenSpaceGuidCName =3D \ - XmlElement(Item, '%s/TokenSpaceGuidCname' % Key) + XmlElement(Item, '%s/TokenSpaceGuidCname' % Key) self.Token =3D XmlElement(Item, '%s/Token' % Key) self.CName =3D XmlElement(Item, '%s/CName' % Key) self.DatumType =3D XmlElement(Item, '%s/DatumType' % Key) @@ -360,7 +372,8 @@ class PcdEntryXml(object): PcdEntry.SetValidUsage(self.ValidUsage) PcdEntry.SetDefaultValue(self.DefaultValue) PcdEntry.SetMaxDatumSize(self.MaxDatumSize) - PcdEntry.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.Featur= eFlag)) + PcdEntry.SetFeatureFlag(ConvertNOTEQToNE( + self.CommonDefines.FeatureFlag)) =20 PcdEntry.SetPromptList(GetPromptList(self.Prompt)) PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText)) @@ -373,10 +386,10 @@ class PcdEntryXml(object): # def FromXml3(self, Item, Key): self.PcdItemType =3D \ - XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType') + XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType') self.PcdUsage =3D XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdUsag= e') self.TokenSpaceGuidCName =3D \ - XmlElement(Item, '%s/TokenSpaceGuidCName' % Key) + XmlElement(Item, '%s/TokenSpaceGuidCName' % Key) self.CName =3D XmlElement(Item, '%s/CName' % Key) self.DefaultValue =3D XmlElement(Item, '%s/DefaultValue' % Key) self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key) @@ -397,7 +410,8 @@ class PcdEntryXml(object): PcdEntry.SetCName(self.CName) PcdEntry.SetValidUsage(self.PcdUsage) PcdEntry.SetDefaultValue(self.DefaultValue) - PcdEntry.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.Featur= eFlag)) + PcdEntry.SetFeatureFlag(ConvertNOTEQToNE( + self.CommonDefines.FeatureFlag)) PcdEntry.SetItemType(self.PcdItemType) =20 PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText)) @@ -412,11 +426,11 @@ class PcdEntryXml(object): DefaultValue =3D ConvertNEToNOTEQ(PcdEntry.GetDefaultValue()) =20 AttributeList =3D \ - [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \ - ['PcdUsage', PcdEntry.GetValidUsage()], \ - ['PcdItemType', PcdEntry.GetItemType()], \ - ['FeatureFlag', PcdEntry.GetFeatureFlag()], - ] + [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], + ['PcdUsage', PcdEntry.GetValidUsage()], + ['PcdItemType', PcdEntry.GetItemType()], + ['FeatureFlag', PcdEntry.GetFeatureFlag()], + ] NodeList =3D [['TokenSpaceGuidCname', PcdEntry.GetTokenSpaceGuidCN= ame()], ['TokenSpaceGuidValue', PcdEntry.GetTokenSpaceGuidValu= e()], ['Token', PcdEntry.GetToken()], @@ -426,7 +440,7 @@ class PcdEntryXml(object): ['DefaultValue', DefaultValue], ['MaxDatumSize', PcdEntry.GetMaxDatumSize()], ['Offset', PcdEntry.GetOffset()], - ] + ] =20 for Item in PcdEntry.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -441,6 +455,7 @@ class PcdEntryXml(object): ## # Package will use ToXml2 # + def ToXml2(self, PcdEntry, Key): if self.PcdCName: pass @@ -448,9 +463,9 @@ class PcdEntryXml(object): DefaultValue =3D ConvertNEToNOTEQ(PcdEntry.GetDefaultValue()) =20 AttributeList =3D \ - [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \ - ['SupModList', GetStringOfList(PcdEntry.GetSupModuleList())] - ] + [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], + ['SupModList', GetStringOfList(PcdEntry.GetSupModuleList())] + ] NodeList =3D [['TokenSpaceGuidCname', PcdEntry.GetTokenSpaceGuidCN= ame()], ['Token', PcdEntry.GetToken()], ['CName', PcdEntry.GetCName()], @@ -458,7 +473,7 @@ class PcdEntryXml(object): ['ValidUsage', GetStringOfList(PcdEntry.GetValidUsage(= ))], ['DefaultValue', DefaultValue], ['MaxDatumSize', PcdEntry.GetMaxDatumSize()], - ] + ] for Item in PcdEntry.GetPromptList(): Tmp =3D PromptXml() NodeList.append(Tmp.ToXml(Item)) @@ -477,6 +492,7 @@ class PcdEntryXml(object): ## # Module will use ToXml3 # + def ToXml3(self, PcdEntry, Key): if self.PcdCName: pass @@ -484,15 +500,15 @@ class PcdEntryXml(object): DefaultValue =3D ConvertNEToNOTEQ(PcdEntry.GetDefaultValue()) =20 AttributeList =3D \ - [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \ - ['PcdUsage', PcdEntry.GetValidUsage()], \ - ['PcdItemType', PcdEntry.GetItemType()], \ - ['FeatureFlag', ConvertNEToNOTEQ(PcdEntry.GetFeatureFlag())], - ] + [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], + ['PcdUsage', PcdEntry.GetValidUsage()], + ['PcdItemType', PcdEntry.GetItemType()], + ['FeatureFlag', ConvertNEToNOTEQ(PcdEntry.GetFeatureFlag()= )], + ] NodeList =3D [['CName', PcdEntry.GetCName()], ['TokenSpaceGuidCName', PcdEntry.GetTokenSpaceGuidCNam= e()], ['DefaultValue', DefaultValue], - ] + ] =20 for Item in PcdEntry.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -517,14 +533,14 @@ class PcdEntryXml(object): AttributeList =3D [] =20 NodeList =3D [ - ['TokenSpaceGuidValue', PcdEntry.GetTokenSpaceGuidValu= e()], - ['PcdCName', PcdEntry.GetCName()], - ['Token', PcdEntry.GetToken()], - ['DatumType', PcdEntry.GetDatumType()], - ['MaxDatumSize', PcdEntry.GetMaxDatumSize()], - ['Value', DefaultValue], - ['Offset', PcdEntry.GetOffset()] - ] + ['TokenSpaceGuidValue', PcdEntry.GetTokenSpaceGuidValue()], + ['PcdCName', PcdEntry.GetCName()], + ['Token', PcdEntry.GetToken()], + ['DatumType', PcdEntry.GetDatumType()], + ['MaxDatumSize', PcdEntry.GetMaxDatumSize()], + ['Value', DefaultValue], + ['Offset', PcdEntry.GetOffset()] + ] =20 for Item in PcdEntry.GetHelpTextList(): Tmp =3D HelpTextXml() @@ -537,17 +553,16 @@ class PcdEntryXml(object): =20 return Root =20 - def __str__(self): Str =3D \ - ('PcdItemType =3D %s PcdUsage =3D %s TokenSpaceGuidCName =3D %s \ + ('PcdItemType =3D %s PcdUsage =3D %s TokenSpaceGuidCName =3D %= s \ TokenSpaceGuidValue =3D %s Token =3D %s CName =3D %s PcdCName =3D = %s \ DatumType =3D %s ValidUsage =3D %s DefaultValue =3D %s MaxDatumSiz= e =3D %s \ Value =3D %s Offset =3D %s %s') % \ - (self.PcdItemType, self.PcdUsage, self.TokenSpaceGuidCName, \ - self.TokenSpaceGuidValue, self.Token, self.CName, self.PcdCName, \ - self.DatumType, self.ValidUsage, self.DefaultValue, \ - self.MaxDatumSize, self.Value, self.Offset, self.CommonDefines) + (self.PcdItemType, self.PcdUsage, self.TokenSpaceGuidCName, + self.TokenSpaceGuidValue, self.Token, self.CName, self.PcdCNa= me, + self.DatumType, self.ValidUsage, self.DefaultValue, + self.MaxDatumSize, self.Value, self.Offset, self.CommonDefine= s) for Item in self.HelpText: Str =3D Str + "\n\t" + str(Item) for Item in self.PcdError: diff --git a/BaseTools/Source/Python/UPT/Xml/XmlParser.py b/BaseTools/Sourc= e/Python/UPT/Xml/XmlParser.py index 8e22a280f655..789c8b958c75 100644 --- a/BaseTools/Source/Python/UPT/Xml/XmlParser.py +++ b/BaseTools/Source/Python/UPT/Xml/XmlParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a xml file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -48,12 +48,14 @@ import Logger.Log as Logger ## # DistributionPackageXml # + + class DistributionPackageXml(object): def __init__(self): self.DistP =3D DistributionPackageClass() self.Pkg =3D '' =20 - ## ValidateDistributionPackage + # ValidateDistributionPackage # # Check if any required item is missing in DistributionPackage # @@ -64,7 +66,7 @@ class DistributionPackageXml(object): # Check DistributionPackage -> DistributionHeader # XmlTreeLevel =3D ['DistributionPackage', ''] - CheckDict =3D {'DistributionHeader':self.DistP.Header } + CheckDict =3D {'DistributionHeader': self.DistP.Header} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 if self.DistP.Header: @@ -110,7 +112,8 @@ class DistributionPackageXml(object): # Check Each Module # for Key in self.DistP.ModuleSurfaceArea: - ValidateMS(self.DistP.ModuleSurfaceArea[Key], ['Distributi= onPackage', 'ModuleSurfaceArea']) + ValidateMS(self.DistP.ModuleSurfaceArea[Key], [ + 'DistributionPackage', 'ModuleSurfaceArea']) =20 # # Check Each Tool @@ -133,16 +136,19 @@ class DistributionPackageXml(object): # Check Each Misc File # if self.DistP.MiscellaneousFiles: - XmlTreeLevel =3D ['DistributionPackage', 'MiscellaneousFil= es', 'Header'] + XmlTreeLevel =3D ['DistributionPackage', + 'MiscellaneousFiles', 'Header'] CheckDict =3D {'Name': self.DistP.MiscellaneousFiles.GetNa= me(), } IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 if not self.DistP.MiscellaneousFiles.GetFileList(): - XmlTreeLevel =3D ['DistributionPackage', 'Miscellaneou= sFiles'] + XmlTreeLevel =3D [ + 'DistributionPackage', 'MiscellaneousFiles'] CheckDict =3D {'FileName': None, } IsRequiredItemListNull(CheckDict, XmlTreeLevel) for Item in self.DistP.MiscellaneousFiles.GetFileList(): - XmlTreeLevel =3D ['DistributionPackage', 'Miscellaneou= sFiles'] + XmlTreeLevel =3D [ + 'DistributionPackage', 'MiscellaneousFiles'] CheckDict =3D {'FileName': Item.GetURI(), } IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 @@ -154,7 +160,6 @@ class DistributionPackageXml(object): CheckDict =3D {'UserId': Item.GetUserID(), } IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - def FromXml(self, Filename=3DNone): if Filename is not None: self.DistP =3D DistributionPackageClass() @@ -168,7 +173,8 @@ class DistributionPackageXml(object): # Tmp =3D DistributionPackageHeaderXml() DistributionPackageHeader =3D \ - Tmp.FromXml(XmlNode(self.Pkg, '/DistributionPackage/Distributi= onHeader'), 'DistributionHeader') + Tmp.FromXml(XmlNode( + self.Pkg, '/DistributionPackage/DistributionHeader'), = 'DistributionHeader') self.DistP.Header =3D DistributionPackageHeader # # Parse each PackageSurfaceArea @@ -176,40 +182,43 @@ class DistributionPackageXml(object): for Item in XmlList(self.Pkg, '/DistributionPackage/PackageSur= faceArea'): Psa =3D PackageSurfaceAreaXml() Package =3D Psa.FromXml(Item, 'PackageSurfaceArea') - self.DistP.PackageSurfaceArea[(Package.GetGuid(), \ - Package.GetVersion(), \ + self.DistP.PackageSurfaceArea[(Package.GetGuid(), + Package.GetVersion(), Package.GetPackagePath())] = =3D \ - Package + Package # # Parse each ModuleSurfaceArea # for Item in XmlList(self.Pkg, '/DistributionPackage/ModuleSurf= aceArea'): Msa =3D ModuleSurfaceAreaXml() Module =3D Msa.FromXml(Item, 'ModuleSurfaceArea', True) - ModuleKey =3D (Module.GetGuid(), Module.GetVersion(), Modu= le.GetName(), Module.GetModulePath()) + ModuleKey =3D (Module.GetGuid(), Module.GetVersion(), + Module.GetName(), Module.GetModulePath()) self.DistP.ModuleSurfaceArea[ModuleKey] =3D Module =20 # # Parse Tools # Tmp =3D MiscellaneousFileXml() - self.DistP.Tools =3D Tmp.FromXml2(XmlNode(self.Pkg, '/Distribu= tionPackage/Tools'), 'Tools') + self.DistP.Tools =3D Tmp.FromXml2( + XmlNode(self.Pkg, '/DistributionPackage/Tools'), 'Tools') =20 # # Parse MiscFiles # Tmp =3D MiscellaneousFileXml() self.DistP.MiscellaneousFiles =3D \ - Tmp.FromXml2(XmlNode(self.Pkg, \ - '/DistributionPackage/MiscellaneousFiles'= ), \ - 'MiscellaneousFiles') + Tmp.FromXml2(XmlNode(self.Pkg, + '/DistributionPackage/MiscellaneousFi= les'), + 'MiscellaneousFiles') =20 # # Parse UserExtensions # for Item in XmlList(self.Pkg, '/DistributionPackage/UserExtens= ions'): Tmp =3D UserExtensionsXml() - self.DistP.UserExtensions.append(Tmp.FromXml2(Item, 'UserE= xtensions')) + self.DistP.UserExtensions.append( + Tmp.FromXml2(Item, 'UserExtensions')) =20 # # Check Required Items for XML @@ -264,7 +273,6 @@ class DistributionPackageXml(object): =20 XmlContent =3D Root.toprettyxml(indent=3D' ') =20 - # # Remove empty element # @@ -280,58 +288,62 @@ class DistributionPackageXml(object): # Remove SupArchList=3D"COMMON" or "common" # XmlContent =3D \ - re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]*CO= MMON' - '[\s\r\n]*"', '', XmlContent) + re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n= ]*COMMON' + '[\s\r\n]*"', '', XmlContent) XmlContent =3D \ - re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]*co= mmon' - '[\s\r\n]*"', '', XmlContent) + re.sub(r'[\s\r\n]*SupArchList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n= ]*common' + '[\s\r\n]*"', '', XmlContent) # # Remove COMMON # XmlContent =3D \ - re.sub(r'[\s\r\n]*[\s\r\n]*COMMON[\s\r\n]*' - '[\s\r\n]*', '', XmlContent) + re.sub(r'[\s\r\n]*[\s\r\n]*COMMON[\s\r\n]*' + '[\s\r\n]*', '', XmlContent) =20 # # Remove common # XmlContent =3D \ - re.sub(r'[\s\r\n]*[\s\r\n]*' - 'common[\s\r\n]*[\s\r\n]*', '', XmlContent) + re.sub(r'[\s\r\n]*[\s\r\n]*' + 'common[\s\r\n]*[\s\r\n]*', '', XmlCo= ntent) =20 # # Remove SupModList=3D"COMMON" or "common" # XmlContent =3D \ - re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]*COM= MON' - '[\s\r\n]*"', '', XmlContent) + re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]= *COMMON' + '[\s\r\n]*"', '', XmlContent) XmlContent =3D \ - re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]*com= mon' - '[\s\r\n]*"', '', XmlContent) + re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=3D[\s\r\n]*"[\s\r\n]= *common' + '[\s\r\n]*"', '', XmlContent) =20 return XmlContent =20 return '' =20 -## ValidateMS +# ValidateMS # # Check if any required item is missing in ModuleSurfaceArea # # @param Module: The ModuleSurfaceArea to be checked # @param XmlTreeLevel: The top level of Module # + + def ValidateMS(Module, TopXmlTreeLevel): ValidateMS1(Module, TopXmlTreeLevel) ValidateMS2(Module, TopXmlTreeLevel) ValidateMS3(Module, TopXmlTreeLevel) =20 -## ValidateMS1 +# ValidateMS1 # # Check if any required item is missing in ModuleSurfaceArea # # @param Module: The ModuleSurfaceArea to be checked # @param XmlTreeLevel: The top level of Module # + + def ValidateMS1(Module, TopXmlTreeLevel): # # Check Guids -> GuidCName @@ -339,21 +351,22 @@ def ValidateMS1(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['Guids'] for Item in Module.GetGuidList(): if Item is None: - CheckDict =3D {'GuidCName':''} + CheckDict =3D {'GuidCName': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['Guids', 'GuidCName'] for Item in Module.GetGuidList(): - CheckDict =3D {'CName':Item.GetCName(), - 'GuidType':Item.GetGuidTypeList(), - 'Usage':Item.GetUsage()} + CheckDict =3D {'CName': Item.GetCName(), + 'GuidType': Item.GetGuidTypeList(), + 'Usage': Item.GetUsage()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 if Item.GetVariableName(): Result =3D ConvertVariableName(Item.GetVariableName()) if Result is None: Msg =3D "->".join(Node for Node in XmlTreeLevel) - ErrorMsg =3D ERR_XML_INVALID_VARIABLENAME % (Item.GetVaria= bleName(), Item.GetCName(), Msg) + ErrorMsg =3D ERR_XML_INVALID_VARIABLENAME % ( + Item.GetVariableName(), Item.GetCName(), Msg) Logger.Error('\nUPT', PARSER_ERROR, ErrorMsg, RaiseError= =3DTrue) else: Item.SetVariableName(Result) @@ -364,13 +377,13 @@ def ValidateMS1(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['Protocols'] for Item in Module.GetProtocolList(): if Item is None: - CheckDict =3D {'Protocol':''} + CheckDict =3D {'Protocol': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['Protocols', 'Protocol'] for Item in Module.GetProtocolList(): - CheckDict =3D {'CName':Item.GetCName(), - 'Usage':Item.GetUsage()} + CheckDict =3D {'CName': Item.GetCName(), + 'Usage': Item.GetUsage()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -379,13 +392,13 @@ def ValidateMS1(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['PPIs'] for Item in Module.GetPpiList(): if Item is None: - CheckDict =3D {'Ppi':''} + CheckDict =3D {'Ppi': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['PPIs', 'Ppi'] for Item in Module.GetPpiList(): - CheckDict =3D {'CName':Item.GetCName(), - 'Usage':Item.GetUsage()} + CheckDict =3D {'CName': Item.GetCName(), + 'Usage': Item.GetUsage()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -394,15 +407,15 @@ def ValidateMS1(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['PcdCoded'] for Item in Module.GetPcdList(): if Item is None: - CheckDict =3D {'PcdEntry':''} + CheckDict =3D {'PcdEntry': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['PcdCoded', 'PcdEntry'] for Item in Module.GetPcdList(): - CheckDict =3D {'TokenSpaceGuidCname':Item.GetTokenSpaceGuidCName(), - 'CName':Item.GetCName(), - 'PcdUsage':Item.GetValidUsage(), - 'PcdItemType':Item.GetItemType()} + CheckDict =3D {'TokenSpaceGuidCname': Item.GetTokenSpaceGuidCName(= ), + 'CName': Item.GetCName(), + 'PcdUsage': Item.GetValidUsage(), + 'PcdItemType': Item.GetItemType()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -411,7 +424,7 @@ def ValidateMS1(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['Externs'] for Item in Module.GetExternList(): if Item is None: - CheckDict =3D {'Extern':''} + CheckDict =3D {'Extern': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -426,7 +439,8 @@ def ValidateMS1(Module, TopXmlTreeLevel): if not IsEqualList(Item.SupArchList, Module.SupArchList): Logger.Error('\nUPT', PARSER_ERROR, - ERR_XML_INVALID_EXTERN_SUPARCHLIST % (str(Ite= m.SupArchList), str(Module.SupArchList)), + ERR_XML_INVALID_EXTERN_SUPARCHLIST % ( + str(Item.SupArchList), str(Module.SupArch= List)), RaiseError=3DTrue) =20 # @@ -434,7 +448,8 @@ def ValidateMS1(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['UserExtensions'] for Item in Module.GetUserExtensionList(): - CheckDict =3D {'UserId':Item.GetUserID(), 'Identifier':Item.GetIde= ntifier()} + CheckDict =3D {'UserId': Item.GetUserID( + ), 'Identifier': Item.GetIdentifier()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -448,13 +463,15 @@ def ValidateMS1(Module, TopXmlTreeLevel): for File in Item.GetFileList(): CheckDict =3D {'Filename': File.GetURI(), } =20 -## ValidateMS2 +# ValidateMS2 # # Check if any required item is missing in ModuleSurfaceArea # # @param Module: The ModuleSurfaceArea to be checked # @param XmlTreeLevel: The top level of Module # + + def ValidateMS2(Module, TopXmlTreeLevel): # # Check Header @@ -471,20 +488,21 @@ def ValidateMS2(Module, TopXmlTreeLevel): # Check ModuleProperties # XmlTreeLevel =3D TopXmlTreeLevel + ['ModuleProperties'] - CheckDict =3D {'ModuleType':Module.GetModuleType(), - 'Path':Module.GetModulePath()} + CheckDict =3D {'ModuleType': Module.GetModuleType(), + 'Path': Module.GetModulePath()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 if not IsValidInstallPath(Module.GetModulePath()): - Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % Modul= e.GetModulePath()) + Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % + Module.GetModulePath()) =20 # # Check ModuleProperties->BootMode # XmlTreeLevel =3D TopXmlTreeLevel + ['ModuleProperties'] + ['BootMode'] for Item in Module.GetBootModeList(): - CheckDict =3D {'Usage':Item.GetUsage(), - 'SupportedBootModes':Item.GetSupportedBootModes()} + CheckDict =3D {'Usage': Item.GetUsage(), + 'SupportedBootModes': Item.GetSupportedBootModes()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -492,8 +510,8 @@ def ValidateMS2(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['ModuleProperties'] + ['Event'] for Item in Module.GetEventList(): - CheckDict =3D {'Usage':Item.GetUsage(), - 'EventType':Item.GetEventType()} + CheckDict =3D {'Usage': Item.GetUsage(), + 'EventType': Item.GetEventType()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -501,8 +519,8 @@ def ValidateMS2(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['ModuleProperties'] + ['HOB'] for Item in Module.GetHobList(): - CheckDict =3D {'Usage':Item.GetUsage(), - 'HobType':Item.GetHobType()} + CheckDict =3D {'Usage': Item.GetUsage(), + 'HobType': Item.GetHobType()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -513,11 +531,11 @@ def ValidateMS2(Module, TopXmlTreeLevel): if Module.ModuleType =3D=3D "UEFI_RUNTIME_DRIVER": Module.ModuleType =3D "DXE_RUNTIME_DRIVER" DxeObj =3D DepexObject() - DxeObj.SetDepex("gEfiBdsArchProtocolGuid AND \ngEfiCpuArchProtocol= Guid AND\n" + \ - "gEfiMetronomeArchProtocolGuid AND \ngEfiMonotonic= CounterArchProtocolGuid AND\n" + \ - "gEfiRealTimeClockArchProtocolGuid AND \ngEfiReset= ArchProtocolGuid AND\n" + \ - "gEfiRuntimeArchProtocolGuid AND \ngEfiSecurityArc= hProtocolGuid AND\n" + \ - "gEfiTimerArchProtocolGuid AND \ngEfiVariableWrite= ArchProtocolGuid AND\n" + \ + DxeObj.SetDepex("gEfiBdsArchProtocolGuid AND \ngEfiCpuArchProtocol= Guid AND\n" + + "gEfiMetronomeArchProtocolGuid AND \ngEfiMonotonic= CounterArchProtocolGuid AND\n" + + "gEfiRealTimeClockArchProtocolGuid AND \ngEfiReset= ArchProtocolGuid AND\n" + + "gEfiRuntimeArchProtocolGuid AND \ngEfiSecurityArc= hProtocolGuid AND\n" + + "gEfiTimerArchProtocolGuid AND \ngEfiVariableWrite= ArchProtocolGuid AND\n" + "gEfiVariableArchProtocolGuid AND \ngEfiWatchdogTi= merArchProtocolGuid") DxeObj.SetModuleType(['DXE_RUNTIME_DRIVER']) Module.PeiDepex =3D [] @@ -531,16 +549,17 @@ def ValidateMS2(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['LibraryClassDefinitions'] for Item in Module.GetLibraryClassList(): if Item is None: - CheckDict =3D {'LibraryClass':''} + CheckDict =3D {'LibraryClass': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D TopXmlTreeLevel + ['LibraryClassDefinitions', 'Librar= yClass'] + XmlTreeLevel =3D TopXmlTreeLevel + \ + ['LibraryClassDefinitions', 'LibraryClass'] =20 IsLibraryModule =3D False LibrarySupModList =3D [] for Item in Module.GetLibraryClassList(): - CheckDict =3D {'Keyword':Item.GetLibraryClass(), - 'Usage':Item.GetUsage()} + CheckDict =3D {'Keyword': Item.GetLibraryClass(), + 'Usage': Item.GetUsage()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) # # If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CL= ASS entry must have the list @@ -559,14 +578,14 @@ def ValidateMS2(Module, TopXmlTreeLevel): if not IsValidInfMoudleType(SupModule): Logger.Error('\nUPT', PARSER_ERROR, - ERR_XML_INVALID_LIB_SUPMODLIST % (Item.Li= braryClass, str(SupModule)), + ERR_XML_INVALID_LIB_SUPMODLIST % ( + Item.LibraryClass, str(SupModule)), RaiseError=3DTrue) =20 if Item.Usage =3D=3D 'PRODUCES' or Item.Usage =3D=3D 'SOMETIMES_PR= ODUCES': IsLibraryModule =3D True LibrarySupModList =3D Item.SupModuleList =20 - # # For Library modules (indicated by a LIBRARY_CLASS statement in the [= Defines] section) # If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element= does not match the Supported Module @@ -580,9 +599,10 @@ def ValidateMS2(Module, TopXmlTreeLevel): if hasattr(Item, 'SupModList') and len(Item.SupModList) > = 0 and \ not IsEqualList(Item.SupModList, LibrarySupModList): Logger.Error('\nUPT', - PARSER_ERROR, - ERR_XML_INVALID_EXTERN_SUPMODLIST % (str(Item.Sup= ModList), str(LibrarySupModList)), - RaiseError=3DTrue) + PARSER_ERROR, + ERR_XML_INVALID_EXTERN_SUPMODLIST % ( + str(Item.SupModList), str(LibrarySupM= odList)), + RaiseError=3DTrue) =20 # # If the module is not a library module, the MODULE_TYPE listed in the= ModuleSurfaceArea.Header must match the @@ -594,21 +614,22 @@ def ValidateMS2(Module, TopXmlTreeLevel): if hasattr(Item, 'SupModList') and len(Item.SupModList) > 0 an= d \ not IsEqualList(Item.SupModList, [Module.ModuleType]): Logger.Error('\nUPT', - PARSER_ERROR, - ERR_XML_INVALID_EXTERN_SUPMODLIST_NOT_LIB % (str(Modu= le.ModuleType), str(Item.SupModList)), - RaiseError=3DTrue) + PARSER_ERROR, + ERR_XML_INVALID_EXTERN_SUPMODLIST_NOT_LIB % ( + str(Module.ModuleType), str(Item.SupModLi= st)), + RaiseError=3DTrue) # # Check SourceFiles # XmlTreeLevel =3D TopXmlTreeLevel + ['SourceFiles'] for Item in Module.GetSourceFileList(): if Item is None: - CheckDict =3D {'Filename':''} + CheckDict =3D {'Filename': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['SourceFiles'] for Item in Module.GetSourceFileList(): - CheckDict =3D {'Filename':Item.GetSourceFile()} + CheckDict =3D {'Filename': Item.GetSourceFile()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 for ItemCount in range(len(Module.GetBinaryFileList())): @@ -617,13 +638,15 @@ def ValidateMS2(Module, TopXmlTreeLevel): Item.FileNamList[0].FileType =3D 'SUBTYPE_GUID' Module.GetBinaryFileList()[ItemCount] =3D Item =20 -## ValidateMS3 +# ValidateMS3 # # Check if any required item is missing in ModuleSurfaceArea # # @param Module: The ModuleSurfaceArea to be checked # @param XmlTreeLevel: The top level of Module # + + def ValidateMS3(Module, TopXmlTreeLevel): # # Check PackageDependencies -> Package @@ -631,12 +654,12 @@ def ValidateMS3(Module, TopXmlTreeLevel): XmlTreeLevel =3D TopXmlTreeLevel + ['PackageDependencies'] for Item in Module.GetPackageDependencyList(): if Item is None: - CheckDict =3D {'Package':''} + CheckDict =3D {'Package': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['PackageDependencies', 'Package'] for Item in Module.GetPackageDependencyList(): - CheckDict =3D {'GUID':Item.GetGuid()} + CheckDict =3D {'GUID': Item.GetGuid()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -645,50 +668,53 @@ def ValidateMS3(Module, TopXmlTreeLevel): for Item in Module.GetBinaryFileList(): if Item is None: XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles'] - CheckDict =3D {'BinaryFile':''} + CheckDict =3D {'BinaryFile': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) if not Item.GetFileNameList(): XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'BinaryFile= '] - CheckDict =3D {'Filename':''} + CheckDict =3D {'Filename': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'BinaryFile'] for File in Item.GetFileNameList(): - CheckDict =3D {'Filename':File.GetFilename(), - 'FileType':File.GetFileType()} + CheckDict =3D {'Filename': File.GetFilename(), + 'FileType': File.GetFileType()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) for AsBuilt in Item.GetAsBuiltList(): # # Check LibInstance # if len(AsBuilt.LibraryInstancesList) =3D=3D 1 and not AsBuilt.= LibraryInstancesList[0]: - CheckDict =3D {'GUID':''} - XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Binary= File', 'AsBuilt', 'LibraryInstances'] + CheckDict =3D {'GUID': ''} + XmlTreeLevel =3D TopXmlTreeLevel + \ + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'LibraryInsta= nces'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 for LibItem in AsBuilt.LibraryInstancesList: - CheckDict =3D {'Guid':LibItem.Guid, - 'Version':LibItem.Version} - XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Binary= File', 'AsBuilt', 'LibraryInstances'] + CheckDict =3D {'Guid': LibItem.Guid, + 'Version': LibItem.Version} + XmlTreeLevel =3D TopXmlTreeLevel + \ + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'LibraryInsta= nces'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check PatchPcd # for PatchPcdItem in AsBuilt.PatchPcdList: - CheckDict =3D {'TokenSpaceGuidValue':PatchPcdItem.TokenSpa= ceGuidValue, - 'PcdCName':PatchPcdItem.PcdCName, - 'Token':PatchPcdItem.Token, - 'DatumType':PatchPcdItem.DatumType, - 'Value':PatchPcdItem.DefaultValue, - 'Offset':PatchPcdItem.Offset} - XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Binary= File', 'AsBuilt', 'PatchPcdValue'] + CheckDict =3D {'TokenSpaceGuidValue': PatchPcdItem.TokenSp= aceGuidValue, + 'PcdCName': PatchPcdItem.PcdCName, + 'Token': PatchPcdItem.Token, + 'DatumType': PatchPcdItem.DatumType, + 'Value': PatchPcdItem.DefaultValue, + 'Offset': PatchPcdItem.Offset} + XmlTreeLevel =3D TopXmlTreeLevel + \ + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'PatchPcdValu= e'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) # # Check PcdError # for PcdErrorItem in PatchPcdItem.PcdErrorsList: - CheckDict =3D {'ErrorNumber':PcdErrorItem.ErrorNumber} + CheckDict =3D {'ErrorNumber': PcdErrorItem.ErrorNumber} XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Bi= naryFile', 'AsBuilt', 'PatchPcdValue', 'Pc= dError'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) @@ -696,16 +722,17 @@ def ValidateMS3(Module, TopXmlTreeLevel): # Check PcdEx # for PcdExItem in AsBuilt.PcdExValueList: - CheckDict =3D {'TokenSpaceGuidValue':PcdExItem.TokenSpaceG= uidValue, - 'Token':PcdExItem.Token, - 'DatumType':PcdExItem.DatumType} - XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Binary= File', 'AsBuilt', 'PcdExValue'] + CheckDict =3D {'TokenSpaceGuidValue': PcdExItem.TokenSpace= GuidValue, + 'Token': PcdExItem.Token, + 'DatumType': PcdExItem.DatumType} + XmlTreeLevel =3D TopXmlTreeLevel + \ + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'PcdExValue'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) # # Check PcdError # for PcdErrorItem in PcdExItem.PcdErrorsList: - CheckDict =3D {'ErrorNumber':PcdErrorItem.ErrorNumber} + CheckDict =3D {'ErrorNumber': PcdErrorItem.ErrorNumber} XmlTreeLevel =3D TopXmlTreeLevel + ['BinaryFiles', 'Bi= naryFile', 'AsBuilt', 'PcdExValue', 'PcdEr= ror'] IsRequiredItemListNull(CheckDict, XmlTreeLevel) @@ -714,7 +741,7 @@ def ValidateMS3(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['SmmDepex'] for Item in Module.GetSmmDepex(): - CheckDict =3D {'Expression':Item.GetDepex()} + CheckDict =3D {'Expression': Item.GetDepex()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -722,7 +749,7 @@ def ValidateMS3(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['PeiDepex'] for Item in Module.GetPeiDepex(): - CheckDict =3D {'Expression':Item.GetDepex()} + CheckDict =3D {'Expression': Item.GetDepex()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -730,7 +757,7 @@ def ValidateMS3(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['DxeDepex'] for Item in Module.GetDxeDepex(): - CheckDict =3D {'Expression':Item.GetDepex()} + CheckDict =3D {'Expression': Item.GetDepex()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # @@ -738,13 +765,16 @@ def ValidateMS3(Module, TopXmlTreeLevel): # XmlTreeLevel =3D TopXmlTreeLevel + ['UserExtensions'] for Item in Module.GetUserExtensionList(): - CheckDict =3D {'UserId':Item.GetUserID(), 'Identifier':Item.GetIde= ntifier()} + CheckDict =3D {'UserId': Item.GetUserID( + ), 'Identifier': Item.GetIdentifier()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 -## ValidatePS1 +# ValidatePS1 # # ValidatePS1 # + + def ValidatePS1(Package): # # Check DistributionPackage -> PackageSurfaceArea -> Header @@ -759,7 +789,8 @@ def ValidatePS1(Package): =20 IsRequiredItemListNull(CheckDict, XmlTreeLevel) if not IsValidInstallPath(Package.GetPackagePath()): - Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % Packa= ge.GetPackagePath()) + Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % + Package.GetPackagePath()) =20 # # Check DistributionPackage -> PackageSurfaceArea -> ClonedFrom @@ -779,134 +810,154 @@ def ValidatePS1(Package): # # Check DistributionPackage -> PackageSurfaceArea -> LibraryClassDecla= rations -> LibraryClass # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Librar= yClassDeclarations'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'LibraryClassDeclarations'] for Item in Package.GetLibraryClassList(): if Item is None: - CheckDict =3D {'LibraryClass':''} + CheckDict =3D {'LibraryClass': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Librar= yClassDeclarations', 'LibraryClass'] + XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', + 'LibraryClassDeclarations', 'LibraryClass'] for Item in Package.GetLibraryClassList(): - CheckDict =3D {'Keyword':Item.GetLibraryClass(), - 'HeaderFile':Item.GetIncludeHeader()} + CheckDict =3D {'Keyword': Item.GetLibraryClass(), + 'HeaderFile': Item.GetIncludeHeader()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> IndustryStandardI= ncludes -> IndustryStandardHeader # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Indust= ryStandardIncludes'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'IndustryStandardIncludes'] for Item in Package.GetStandardIncludeFileList(): if Item is None: - CheckDict =3D {'IndustryStandardHeader':''} + CheckDict =3D {'IndustryStandardHeader': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Indust= ryStandardIncludes', 'IndustryStandardHeader'] + XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', + 'IndustryStandardIncludes', 'IndustryStandardHeader'] for Item in Package.GetStandardIncludeFileList(): - CheckDict =3D {'HeaderFile':Item.GetFilePath()} + CheckDict =3D {'HeaderFile': Item.GetFilePath()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> PackageIncludes -= > PackageHeader # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Packag= eIncludes'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PackageIncludes'] for Item in Package.GetPackageIncludeFileList(): if Item is None: - CheckDict =3D {'PackageHeader':''} + CheckDict =3D {'PackageHeader': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Packag= eIncludes', 'PackageHeader'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PackageIncludes', 'PackageHeade= r'] for Item in Package.GetPackageIncludeFileList(): - CheckDict =3D {'HeaderFile':Item.GetFilePath()} + CheckDict =3D {'HeaderFile': Item.GetFilePath()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 -## ValidatePS2 +# ValidatePS2 # # ValidatePS2 # + + def ValidatePS2(Package): # # Check DistributionPackage -> PackageSurfaceArea -> Modules -> Module= SurfaceArea # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Module= s', 'ModuleSurfaceArea'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'Modules', 'ModuleSurfaceArea'] for Item in Package.GetModuleDict().values(): ValidateMS(Item, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> GuidDeclarations = Entry # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'GuidDe= clarations'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'GuidDeclarations'] for Item in Package.GetGuidList(): if Item is None: - CheckDict =3D {'Entry':''} + CheckDict =3D {'Entry': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'GuidDe= clarations', 'Entry'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'GuidDeclarations', 'Entry'] for Item in Package.GetGuidList(): - CheckDict =3D {'CName':Item.GetCName(), - 'GuidValue':Item.GetGuid()} + CheckDict =3D {'CName': Item.GetCName(), + 'GuidValue': Item.GetGuid()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> ProtocolDeclarati= ons -> Entry # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Protoc= olDeclarations'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'ProtocolDeclarations'] for Item in Package.GetProtocolList(): if Item is None: - CheckDict =3D {'Entry':''} + CheckDict =3D {'Entry': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Protoc= olDeclarations', 'Entry'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'ProtocolDeclarations', 'Entry'] for Item in Package.GetProtocolList(): - CheckDict =3D {'CName':Item.GetCName(), - 'GuidValue':Item.GetGuid()} + CheckDict =3D {'CName': Item.GetCName(), + 'GuidValue': Item.GetGuid()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> PpiDeclarations -= > Entry # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'PpiDec= larations'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PpiDeclarations'] for Item in Package.GetPpiList(): if Item is None: - CheckDict =3D {'Entry':''} + CheckDict =3D {'Entry': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'PpiDec= larations', 'Entry'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PpiDeclarations', 'Entry'] for Item in Package.GetPpiList(): - CheckDict =3D {'CName':Item.GetCName(), - 'GuidValue':Item.GetGuid()} + CheckDict =3D {'CName': Item.GetCName(), + 'GuidValue': Item.GetGuid()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> PcdDeclarations -= > Entry # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'PcdDec= larations'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PcdDeclarations'] for Item in Package.GetPcdList(): if Item is None: - CheckDict =3D {'PcdEntry':''} + CheckDict =3D {'PcdEntry': ''} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'PcdDec= larations', 'PcdEntry'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'PcdDeclarations', 'PcdEntry'] for Item in Package.GetPcdList(): - CheckDict =3D {'TokenSpaceGuidCname':Item.GetTokenSpaceGuidCName(), - 'Token':Item.GetToken(), - 'CName':Item.GetCName(), - 'DatumType':Item.GetDatumType(), - 'ValidUsage':Item.GetValidUsage(), - 'DefaultValue':Item.GetDefaultValue()} + CheckDict =3D {'TokenSpaceGuidCname': Item.GetTokenSpaceGuidCName(= ), + 'Token': Item.GetToken(), + 'CName': Item.GetCName(), + 'DatumType': Item.GetDatumType(), + 'ValidUsage': Item.GetValidUsage(), + 'DefaultValue': Item.GetDefaultValue()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> UserExtensions # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'UserEx= tensions'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'UserExtensions'] for Item in Package.GetUserExtensionList(): - CheckDict =3D {'UserId':Item.GetUserID(), 'Identifier':Item.GetIde= ntifier()} + CheckDict =3D {'UserId': Item.GetUserID( + ), 'Identifier': Item.GetIdentifier()} IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 # # Check DistributionPackage -> PackageSurfaceArea -> MiscellaneousFile= s -> Filename # - XmlTreeLevel =3D ['DistributionPackage', 'PackageSurfaceArea', 'Miscel= laneousFiles'] + XmlTreeLevel =3D ['DistributionPackage', + 'PackageSurfaceArea', 'MiscellaneousFiles'] for Item in Package.GetMiscFileList(): if not Item.GetFileList(): CheckDict =3D {'Filename': '', } @@ -915,12 +966,14 @@ def ValidatePS2(Package): CheckDict =3D {'Filename': File.GetURI(), } IsRequiredItemListNull(CheckDict, XmlTreeLevel) =20 -## ValidatePackageSurfaceArea +# ValidatePackageSurfaceArea # # Check if any required item is missing in PackageSurfaceArea # # @param Package: The PackageSurfaceArea to be checked # + + def ValidatePackageSurfaceArea(Package): ValidatePS1(Package) ValidatePS2(Package) diff --git a/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py b/BaseTools/S= ource/Python/UPT/Xml/XmlParserMisc.py index 48381ee8c6bf..3680f667ae57 100644 --- a/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py +++ b/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse a xml file of .PKG file # # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
        @@ -14,7 +14,7 @@ from Logger.StringTable import ERR_XML_PARSER_REQUIRED_IT= EM_MISSING from Logger.ToolError import PARSER_ERROR import Logger.Log as Logger =20 -## ConvertVariableName() +# ConvertVariableName() # Convert VariableName to be L"string", # input of UCS-2 format Hex Array or L"string" (C style.) could be convert= ed successfully, # others will not. @@ -22,6 +22,8 @@ import Logger.Log as Logger # @param VariableName: string need to be converted # @retval: the L quoted string converted if success, else None will be ret= urned # + + def ConvertVariableName(VariableName): VariableName =3D VariableName.strip() # @@ -34,7 +36,7 @@ def ConvertVariableName(VariableName): # check for Hex Array, it should be little endian even number of hex n= umbers # ValueList =3D VariableName.split(' ') - if len(ValueList)%2 =3D=3D 1: + if len(ValueList) % 2 =3D=3D 1: return None =20 TransferedStr =3D '' @@ -49,18 +51,20 @@ def ConvertVariableName(VariableName): =20 if FirstByte not in range(0x20, 0x7F): return None - TransferedStr +=3D ('%c')%FirstByte + TransferedStr +=3D ('%c') % FirstByte Index =3D Index + 2 =20 return 'L"' + TransferedStr + '"' =20 -## IsRequiredItemListNull +# IsRequiredItemListNull # # Check if a required XML section item/attribue is NULL # # @param ItemList: The list of items to be checked # @param XmlTreeLevel: The error message tree level # + + def IsRequiredItemListNull(ItemDict, XmlTreeLevel): for Key in ItemDict: if not ItemDict[Key]: @@ -68,10 +72,12 @@ def IsRequiredItemListNull(ItemDict, XmlTreeLevel): ErrorMsg =3D ERR_XML_PARSER_REQUIRED_ITEM_MISSING % (Key, Msg) Logger.Error('\nUPT', PARSER_ERROR, ErrorMsg, RaiseError=3DTru= e) =20 -## Get help text +# Get help text # # @param HelpText # + + def GetHelpTextList(HelpText): HelpTextList =3D [] for HelT in HelpText: @@ -81,10 +87,12 @@ def GetHelpTextList(HelpText): HelpTextList.append(HelpTextObj) return HelpTextList =20 -## Get Prompt text +# Get Prompt text # # @param Prompt # + + def GetPromptList(Prompt): PromptList =3D [] for SubPrompt in Prompt: diff --git a/BaseTools/Source/Python/UPT/Xml/__init__.py b/BaseTools/Source= /Python/UPT/Xml/__init__.py index 172e498451b8..03dedeed636e 100644 --- a/BaseTools/Source/Python/UPT/Xml/__init__.py +++ b/BaseTools/Source/Python/UPT/Xml/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Library' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTo= ols/Source/Python/Workspace/BuildClassObject.py index ef873720f455..08c32ca08c2c 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to define each component of the build database # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
        @@ -10,7 +10,7 @@ from Common.DataType import * import collections import re from collections import OrderedDict -from Common.Misc import CopyDict,ArrayIndex +from Common.Misc import CopyDict, ArrayIndex import copy from CommonDataClass.DataClass import * import Common.EdkLogger as EdkLogger @@ -19,7 +19,7 @@ from Common.BuildToolError import OPTION_VALUE_INVALID from Common.caching import cached_property StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') =20 -## PcdClassObject +# PcdClassObject # # This Class is used for PcdObject # @@ -45,8 +45,10 @@ StructPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]= *$') # @var IsOverrided: To store value for IsOverrided # @var Phase: To store value for Phase, default is "DXE" # + + class PcdClassObject(object): - def __init__(self, Name =3D None, Guid =3D None, Type =3D None, DatumT= ype =3D None, Value =3D None, Token =3D None, MaxDatumSize =3D None, SkuInf= oList =3D None, IsOverrided =3D False, GuidValue =3D None, validateranges = =3D None, validlists =3D None, expressions =3D None, IsDsc =3D False, UserD= efinedDefaultStoresFlag =3D False): + def __init__(self, Name=3DNone, Guid=3DNone, Type=3DNone, DatumType=3D= None, Value=3DNone, Token=3DNone, MaxDatumSize=3DNone, SkuInfoList=3DNone, = IsOverrided=3DFalse, GuidValue=3DNone, validateranges=3DNone, validlists=3D= None, expressions=3DNone, IsDsc=3DFalse, UserDefinedDefaultStoresFlag=3DFal= se): self.TokenCName =3D Name self.TokenSpaceGuidCName =3D Guid self.TokenSpaceGuidValue =3D GuidValue @@ -72,7 +74,7 @@ class PcdClassObject(object): self.DscDefaultValue =3D Value self.PcdValueFromComm =3D "" self.PcdValueFromFdf =3D "" - self.PcdValueFromComponents =3D {} #{ModuleGuid:value, file_path,l= ineNo} + self.PcdValueFromComponents =3D {} # {ModuleGuid:value, file_path= ,lineNo} self.CustomAttribute =3D {} self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresFlag self._Capacity =3D None @@ -86,7 +88,8 @@ class PcdClassObject(object): maxsize =3D item.lstrip("[").rstrip("]").strip() if not maxsize: maxsize =3D "-1" - maxsize =3D str(int(maxsize,16)) if maxsize.startswith(("0= x","0X")) else maxsize + maxsize =3D str(int(maxsize, 16)) if maxsize.startswith( + ("0x", "0X")) else maxsize self._Capacity.append(maxsize) if hasattr(self, "SkuOverrideValues"): for sku in self.SkuOverrideValues: @@ -98,10 +101,11 @@ class PcdClassObject(object): for i in range(len(deme)): if int(deme[i].lstrip("[").rstrip("]").str= ip()) >=3D int(self._Capacity[i]): if self._Capacity[i] !=3D "-1": - firstfieldinfo =3D list(fieldinfo.= values())[0] + firstfieldinfo =3D list( + fieldinfo.values())[0] EdkLogger.error('Build', OPTION_VA= LUE_INVALID, "For Pcd %s, Array Index exceed the Array size. From %s Line %= s \n " % - (".".join((self.TokenSpaceGuidCName, s= elf.TokenCName)), firstfieldinfo[1],firstfieldinfo[2] )) - if hasattr(self,"DefaultValues"): + (".".join((self.To= kenSpaceGuidCName, self.TokenCName)), firstfieldinfo[1], firstfieldinfo[2])) + if hasattr(self, "DefaultValues"): for demesionattr in self.DefaultValues: fieldinfo =3D self.DefaultValues[demesionattr] deme =3D ArrayIndex.findall(demesionattr) @@ -110,7 +114,7 @@ class PcdClassObject(object): if self._Capacity[i] !=3D "-1": firstfieldinfo =3D list(fieldinfo.values()= )[0] EdkLogger.error('Build', OPTION_VALUE_INVA= LID, "For Pcd %s, Array Index exceed the Array size. From %s Line %s \n " % - (".".join((self.TokenSpaceGuidCName, s= elf.TokenCName)), firstfieldinfo[1],firstfieldinfo[2] )) + (".".join((self.TokenSpace= GuidCName, self.TokenCName)), firstfieldinfo[1], firstfieldinfo[2])) return self._Capacity =20 def PcdArraySize(self): @@ -120,12 +124,13 @@ class PcdClassObject(object): for de in self.Capacity: size =3D size * int(de) return size + @property def DatumType(self): return self._DatumType =20 @DatumType.setter - def DatumType(self,DataType): + def DatumType(self, DataType): self._DatumType =3D DataType self._Capacity =3D None =20 @@ -135,6 +140,7 @@ class PcdClassObject(object): return self._DatumType[:self._DatumType.index("[")] else: return self._DatumType + def IsArray(self): return True if len(self.Capacity) else False =20 @@ -153,31 +159,32 @@ class PcdClassObject(object): @staticmethod def GetPcdMaxSizeWorker(PcdString, MaxSize): if PcdString.startswith("{") and PcdString.endswith("}"): - return max([len(PcdString.split(",")),MaxSize]) + return max([len(PcdString.split(",")), MaxSize]) =20 if PcdString.startswith("\"") or PcdString.startswith("\'"): - return max([len(PcdString)-2+1,MaxSize]) + return max([len(PcdString)-2+1, MaxSize]) =20 if PcdString.startswith("L\""): - return max([2*(len(PcdString)-3+1),MaxSize]) + return max([2*(len(PcdString)-3+1), MaxSize]) =20 - return max([len(PcdString),MaxSize]) + return max([len(PcdString), MaxSize]) =20 - ## Get the maximum number of bytes + # Get the maximum number of bytes def GetPcdMaxSize(self): if self.DatumType in TAB_PCD_NUMERIC_TYPES: return MAX_SIZE_TYPE[self.DatumType] =20 MaxSize =3D int(self.MaxDatumSize, 10) if self.MaxDatumSize else 0 if self.PcdValueFromFdf: - MaxSize =3D self.GetPcdMaxSizeWorker(self.PcdValueFromFdf,MaxS= ize) + MaxSize =3D self.GetPcdMaxSizeWorker(self.PcdValueFromFdf, Max= Size) if self.PcdValueFromComm: - MaxSize =3D self.GetPcdMaxSizeWorker(self.PcdValueFromComm,Max= Size) + MaxSize =3D self.GetPcdMaxSizeWorker(self.PcdValueFromComm, Ma= xSize) if hasattr(self, "DefaultValueFromDec"): - MaxSize =3D self.GetPcdMaxSizeWorker(self.DefaultValueFromDec,= MaxSize) + MaxSize =3D self.GetPcdMaxSizeWorker( + self.DefaultValueFromDec, MaxSize) return MaxSize =20 - ## Get the number of bytes + # Get the number of bytes def GetPcdSize(self): if self.DatumType in TAB_PCD_NUMERIC_TYPES: return MAX_SIZE_TYPE[self.DatumType] @@ -190,14 +197,14 @@ class PcdClassObject(object): else: return len(self.DefaultValue) - 1 =20 - - ## Convert the class to a string + # Convert the class to a string # # Convert each member of the class to string # Organize to a single line format string # # @retval Rtn Formatted String # + def __str__(self): Rtn =3D '\tTokenCName=3D' + str(self.TokenCName) + ', ' + \ 'TokenSpaceGuidCName=3D' + str(self.TokenSpaceGuidCName) + '= , ' + \ @@ -212,7 +219,7 @@ class PcdClassObject(object): =20 return Rtn =20 - ## Override __eq__ function + # Override __eq__ function # # Check whether pcds are the same # @@ -222,7 +229,7 @@ class PcdClassObject(object): def __eq__(self, Other): return Other and self.TokenCName =3D=3D Other.TokenCName and self.= TokenSpaceGuidCName =3D=3D Other.TokenSpaceGuidCName =20 - ## Override __hash__ function + # Override __hash__ function # # Use (TokenCName, TokenSpaceGuidCName) as key in hash table # @@ -233,14 +240,15 @@ class PcdClassObject(object): =20 @cached_property def _fullname(self): - return ".".join((self.TokenSpaceGuidCName,self.TokenCName)) + return ".".join((self.TokenSpaceGuidCName, self.TokenCName)) =20 - def __lt__(self,pcd): + def __lt__(self, pcd): return self._fullname < pcd._fullname - def __gt__(self,pcd): + + def __gt__(self, pcd): return self._fullname > pcd._fullname =20 - def sharedcopy(self,new_pcd): + def sharedcopy(self, new_pcd): new_pcd.TokenCName =3D self.TokenCName new_pcd.TokenSpaceGuidCName =3D self.TokenSpaceGuidCName new_pcd.TokenSpaceGuidValue =3D self.TokenSpaceGuidValue @@ -265,16 +273,18 @@ class PcdClassObject(object): new_pcd.validateranges =3D [item for item in self.validateranges] new_pcd.validlists =3D [item for item in self.validlists] new_pcd.expressions =3D [item for item in self.expressions] - new_pcd.SkuInfoList =3D {key: copy.deepcopy(skuobj) for key,skuobj= in self.SkuInfoList.items()} + new_pcd.SkuInfoList =3D {key: copy.deepcopy( + skuobj) for key, skuobj in self.SkuInfoList.items()} return new_pcd =20 - def __deepcopy__(self,memo): + def __deepcopy__(self, memo): new_pcd =3D PcdClassObject() self.sharedcopy(new_pcd) return new_pcd =20 + class StructurePcd(PcdClassObject): - def __init__(self, StructuredPcdIncludeFile=3DNone, Packages=3DNone, N= ame=3DNone, Guid=3DNone, Type=3DNone, DatumType=3DNone, Value=3DNone, Token= =3DNone, MaxDatumSize=3DNone, SkuInfoList=3DNone, IsOverrided=3DFalse, Guid= Value=3DNone, validateranges=3DNone, validlists=3DNone, expressions=3DNone,= default_store =3D TAB_DEFAULT_STORES_DEFAULT): + def __init__(self, StructuredPcdIncludeFile=3DNone, Packages=3DNone, N= ame=3DNone, Guid=3DNone, Type=3DNone, DatumType=3DNone, Value=3DNone, Token= =3DNone, MaxDatumSize=3DNone, SkuInfoList=3DNone, IsOverrided=3DFalse, Guid= Value=3DNone, validateranges=3DNone, validlists=3DNone, expressions=3DNone,= default_store=3DTAB_DEFAULT_STORES_DEFAULT): if SkuInfoList is None: SkuInfoList =3D {} if validateranges is None: @@ -285,8 +295,10 @@ class StructurePcd(PcdClassObject): expressions =3D [] if Packages is None: Packages =3D [] - super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Va= lue, Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validaterang= es, validlists, expressions) - self.StructuredPcdIncludeFile =3D [] if StructuredPcdIncludeFile i= s None else StructuredPcdIncludeFile + super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Va= lue, Token, MaxDatumSize, + SkuInfoList, IsOverrided, GuidV= alue, validateranges, validlists, expressions) + self.StructuredPcdIncludeFile =3D [ + ] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile self.PackageDecs =3D Packages self.DefaultStoreName =3D [default_store] self.DefaultValues =3D OrderedDict() @@ -300,41 +312,49 @@ class StructurePcd(PcdClassObject): self.ValueChain =3D set() self.PcdFieldValueFromComm =3D OrderedDict() self.PcdFieldValueFromFdf =3D OrderedDict() - self.DefaultFromDSC=3DNone + self.DefaultFromDSC =3D None self.PcdFiledValueFromDscComponent =3D OrderedDict() + def __repr__(self): return self.TypeName =20 - def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo=3D0= ,DimensionAttr =3D"-1"): + def AddDefaultValue(self, FieldName, Value, FileName=3D"", LineNo=3D0,= DimensionAttr=3D"-1"): if DimensionAttr not in self.DefaultValues: self.DefaultValues[DimensionAttr] =3D collections.OrderedDict() if FieldName in self.DefaultValues[DimensionAttr]: del self.DefaultValues[DimensionAttr][FieldName] - self.DefaultValues[DimensionAttr][FieldName] =3D [Value.strip(), F= ileName, LineNo] + self.DefaultValues[DimensionAttr][FieldName] =3D [ + Value.strip(), FileName, LineNo] return self.DefaultValues[DimensionAttr][FieldName] =20 - def SetDecDefaultValue(self, DefaultValue,decpath=3DNone,lineno=3DNone= ): + def SetDecDefaultValue(self, DefaultValue, decpath=3DNone, lineno=3DNo= ne): self.DefaultValueFromDec =3D DefaultValue - self.DefaultValueFromDecInfo =3D (decpath,lineno) - def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreNam= e, FileName=3D"", LineNo=3D0, DimensionAttr =3D '-1'): + self.DefaultValueFromDecInfo =3D (decpath, lineno) + + def AddOverrideValue(self, FieldName, Value, SkuName, DefaultStoreName= , FileName=3D"", LineNo=3D0, DimensionAttr=3D'-1'): if SkuName not in self.SkuOverrideValues: self.SkuOverrideValues[SkuName] =3D OrderedDict() if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] =3D OrderedD= ict() if DimensionAttr not in self.SkuOverrideValues[SkuName][DefaultSto= reName]: - self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAtt= r] =3D collections.OrderedDict() + self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAtt= r] =3D collections.OrderedDict( + ) if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][= DimensionAttr]: del self.SkuOverrideValues[SkuName][DefaultStoreName][Dimensio= nAttr][FieldName] - self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][F= ieldName] =3D [Value.strip(), FileName, LineNo] + self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][F= ieldName] =3D [ + Value.strip(), FileName, LineNo] return self.SkuOverrideValues[SkuName][DefaultStoreName][Dimension= Attr][FieldName] =20 - def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid, FileN= ame=3D"", LineNo=3D0, DimensionAttr =3D '-1'): - self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid, OrderedD= ict()) - self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(Dimensio= nAttr,OrderedDict()) - self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][Fiel= dName] =3D [Value.strip(), FileName, LineNo] + def AddComponentOverrideValue(self, FieldName, Value, ModuleGuid, File= Name=3D"", LineNo=3D0, DimensionAttr=3D'-1'): + self.PcdFiledValueFromDscComponent.setdefault( + ModuleGuid, OrderedDict()) + self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault( + DimensionAttr, OrderedDict()) + self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][Fiel= dName] =3D [ + Value.strip(), FileName, LineNo] return self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAtt= r][FieldName] =20 - def SetPcdMode (self, PcdMode): + def SetPcdMode(self, PcdMode): self.PcdMode =3D PcdMode =20 def copy(self, PcdObject): @@ -343,7 +363,7 @@ class StructurePcd(PcdClassObject): self.TokenSpaceGuidValue =3D PcdObject.TokenSpaceGuidValue if PcdO= bject.TokenSpaceGuidValue else self.TokenSpaceGuidValue self.Type =3D PcdObject.Type if PcdObject.Type else self.Type self._DatumType =3D PcdObject.DatumType if PcdObject.DatumType els= e self.DatumType - self.DefaultValue =3D PcdObject.DefaultValue if PcdObject.Default= Value else self.DefaultValue + self.DefaultValue =3D PcdObject.DefaultValue if PcdObject.DefaultV= alue else self.DefaultValue self.TokenValue =3D PcdObject.TokenValue if PcdObject.TokenValue e= lse self.TokenValue self.MaxDatumSize =3D PcdObject.MaxDatumSize if PcdObject.MaxDatum= Size else self.MaxDatumSize self.SkuInfoList =3D PcdObject.SkuInfoList if PcdObject.SkuInfoLis= t else self.SkuInfoList @@ -377,7 +397,7 @@ class StructurePcd(PcdClassObject): self.PcdFieldValueFromFdf =3D PcdObject.PcdFieldValueFromFdf i= f PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf self.PcdFiledValueFromDscComponent =3D PcdObject.PcdFiledValue= FromDscComponent if PcdObject.PcdFiledValueFromDscComponent else self.PcdFi= ledValueFromDscComponent =20 - def __deepcopy__(self,memo): + def __deepcopy__(self, memo): new_pcd =3D StructurePcd() self.sharedcopy(new_pcd) =20 @@ -387,53 +407,58 @@ class StructurePcd(PcdClassObject): new_pcd.StructName =3D self.DatumType new_pcd.PcdDefineLineNo =3D self.PcdDefineLineNo new_pcd.PkgPath =3D self.PkgPath - new_pcd.StructuredPcdIncludeFile =3D [item for item in self.Struct= uredPcdIncludeFile] + new_pcd.StructuredPcdIncludeFile =3D [ + item for item in self.StructuredPcdIncludeFile] new_pcd.PackageDecs =3D [item for item in self.PackageDecs] new_pcd.DefaultValues =3D CopyDict(self.DefaultValues) - new_pcd.DefaultFromDSC=3DCopyDict(self.DefaultFromDSC) + new_pcd.DefaultFromDSC =3D CopyDict(self.DefaultFromDSC) new_pcd.SkuOverrideValues =3D CopyDict(self.SkuOverrideValues) new_pcd.PcdFieldValueFromComm =3D CopyDict(self.PcdFieldValueFromC= omm) new_pcd.PcdFieldValueFromFdf =3D CopyDict(self.PcdFieldValueFromFd= f) - new_pcd.PcdFiledValueFromDscComponent =3D CopyDict(self.PcdFiledVa= lueFromDscComponent) + new_pcd.PcdFiledValueFromDscComponent =3D CopyDict( + self.PcdFiledValueFromDscComponent) new_pcd.ValueChain =3D {item for item in self.ValueChain} return new_pcd =20 -LibraryClassObject =3D namedtuple('LibraryClassObject', ['LibraryClass','S= upModList']) + +LibraryClassObject =3D namedtuple( + 'LibraryClassObject', ['LibraryClass', 'SupModList']) + =20 class BuildData(object): # dict used to convert PCD type in database to string used by build to= ol =20 _PCD_TYPE_STRING_ =3D { - MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD, - MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE, - MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG, - MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC, - MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC, - MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII, - MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD, - MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII, - MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD, + MODEL_PCD_FIXED_AT_BUILD: TAB_PCDS_FIXED_AT_BUILD, + MODEL_PCD_PATCHABLE_IN_MODULE: TAB_PCDS_PATCHABLE_IN_MODULE, + MODEL_PCD_FEATURE_FLAG: TAB_PCDS_FEATURE_FLAG, + MODEL_PCD_DYNAMIC: TAB_PCDS_DYNAMIC, + MODEL_PCD_DYNAMIC_DEFAULT: TAB_PCDS_DYNAMIC, + MODEL_PCD_DYNAMIC_HII: TAB_PCDS_DYNAMIC_HII, + MODEL_PCD_DYNAMIC_VPD: TAB_PCDS_DYNAMIC_VPD, + MODEL_PCD_DYNAMIC_EX: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_EX_DEFAULT: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_EX_HII: TAB_PCDS_DYNAMIC_EX_HII, + MODEL_PCD_DYNAMIC_EX_VPD: TAB_PCDS_DYNAMIC_EX_VPD, } =20 def UpdatePcdTypeDict(self): - if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_PCD_DYNAMIC_= AS_DYNAMICEX,"FALSE").upper() =3D=3D "TRUE": + if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_PCD_DYNAMIC_= AS_DYNAMICEX, "FALSE").upper() =3D=3D "TRUE": self._PCD_TYPE_STRING_ =3D { - MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUIL= D, - MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_= MODULE, - MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG, - MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_EX_HI= I, - MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_EX_VP= D, - MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX, - MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HI= I, - MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VP= D, + MODEL_PCD_FIXED_AT_BUILD: TAB_PCDS_FIXED_AT_BUILD, + MODEL_PCD_PATCHABLE_IN_MODULE: TAB_PCDS_PATCHABLE_IN_MOD= ULE, + MODEL_PCD_FEATURE_FLAG: TAB_PCDS_FEATURE_FLAG, + MODEL_PCD_DYNAMIC: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_DEFAULT: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_HII: TAB_PCDS_DYNAMIC_EX_HII, + MODEL_PCD_DYNAMIC_VPD: TAB_PCDS_DYNAMIC_EX_VPD, + MODEL_PCD_DYNAMIC_EX: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_EX_DEFAULT: TAB_PCDS_DYNAMIC_EX, + MODEL_PCD_DYNAMIC_EX_HII: TAB_PCDS_DYNAMIC_EX_HII, + MODEL_PCD_DYNAMIC_EX_VPD: TAB_PCDS_DYNAMIC_EX_VPD, } =20 - ## Convert the class to a string + # Convert the class to a string # # Convert member MetaFile of the class to a string # @@ -442,7 +467,7 @@ class BuildData(object): def __str__(self): return str(self.MetaFile) =20 - ## Override __eq__ function + # Override __eq__ function # # Check whether ModuleBuildClassObjects are the same # @@ -452,7 +477,7 @@ class BuildData(object): def __eq__(self, Other): return self.MetaFile =3D=3D Other =20 - ## Override __hash__ function + # Override __hash__ function # # Use MetaFile as key in hash table # @@ -461,7 +486,7 @@ class BuildData(object): def __hash__(self): return hash(self.MetaFile) =20 -## ModuleBuildClassObject +# ModuleBuildClassObject # # This Class defines ModuleBuildClass # @@ -505,41 +530,43 @@ class BuildData(object): # { [BuildOptionKey] : BuildOptionValue} # @var Depex: To store value for Depex # + + class ModuleBuildClassObject(BuildData): def __init__(self): - self.AutoGenVersion =3D 0 - self.MetaFile =3D '' - self.BaseName =3D '' - self.ModuleType =3D '' - self.Guid =3D '' - self.Version =3D '' - self.PcdIsDriver =3D '' - self.BinaryModule =3D '' - self.Shadow =3D '' - self.CustomMakefile =3D {} - self.Specification =3D {} - self.LibraryClass =3D [] - self.ModuleEntryPointList =3D [] - self.ModuleUnloadImageList =3D [] - self.ConstructorList =3D [] - self.DestructorList =3D [] + self.AutoGenVersion =3D 0 + self.MetaFile =3D '' + self.BaseName =3D '' + self.ModuleType =3D '' + self.Guid =3D '' + self.Version =3D '' + self.PcdIsDriver =3D '' + self.BinaryModule =3D '' + self.Shadow =3D '' + self.CustomMakefile =3D {} + self.Specification =3D {} + self.LibraryClass =3D [] + self.ModuleEntryPointList =3D [] + self.ModuleUnloadImageList =3D [] + self.ConstructorList =3D [] + self.DestructorList =3D [] =20 - self.Binaries =3D [] - self.Sources =3D [] - self.LibraryClasses =3D OrderedDict() - self.Libraries =3D [] - self.Protocols =3D [] - self.Ppis =3D [] - self.Guids =3D [] - self.Includes =3D [] - self.Packages =3D [] - self.Pcds =3D {} - self.BuildOptions =3D {} - self.Depex =3D {} - self.StrPcdSet =3D [] - self.StrPcdOverallValue =3D {} + self.Binaries =3D [] + self.Sources =3D [] + self.LibraryClasses =3D OrderedDict() + self.Libraries =3D [] + self.Protocols =3D [] + self.Ppis =3D [] + self.Guids =3D [] + self.Includes =3D [] + self.Packages =3D [] + self.Pcds =3D {} + self.BuildOptions =3D {} + self.Depex =3D {} + self.StrPcdSet =3D [] + self.StrPcdOverallValue =3D {} =20 -## PackageBuildClassObject +# PackageBuildClassObject # # This Class defines PackageBuildClass # @@ -562,21 +589,23 @@ class ModuleBuildClassObject(BuildData): # @var Pcds: To store value for Pcds, it is a set structure as # { [(PcdCName, PcdGuidCName)] : PcdClassObject} # + + class PackageBuildClassObject(BuildData): def __init__(self): - self.MetaFile =3D '' - self.PackageName =3D '' - self.Guid =3D '' - self.Version =3D '' + self.MetaFile =3D '' + self.PackageName =3D '' + self.Guid =3D '' + self.Version =3D '' =20 - self.Protocols =3D {} - self.Ppis =3D {} - self.Guids =3D {} - self.Includes =3D [] - self.LibraryClasses =3D {} - self.Pcds =3D {} + self.Protocols =3D {} + self.Ppis =3D {} + self.Guids =3D {} + self.Includes =3D [] + self.LibraryClasses =3D {} + self.Pcds =3D {} =20 -## PlatformBuildClassObject +# PlatformBuildClassObject # # This Class defines PlatformBuildClass # @@ -603,21 +632,23 @@ class PackageBuildClassObject(BuildData): # @var BuildOptions: To store value for BuildOptions, it is a set str= ucture as # { [BuildOptionKey] : BuildOptionValue } # + + class PlatformBuildClassObject(BuildData): def __init__(self): - self.MetaFile =3D '' - self.PlatformName =3D '' - self.Guid =3D '' - self.Version =3D '' - self.DscSpecification =3D '' - self.OutputDirectory =3D '' - self.FlashDefinition =3D '' - self.BuildNumber =3D '' + self.MetaFile =3D '' + self.PlatformName =3D '' + self.Guid =3D '' + self.Version =3D '' + self.DscSpecification =3D '' + self.OutputDirectory =3D '' + self.FlashDefinition =3D '' + self.BuildNumber =3D '' =20 - self.SkuIds =3D {} - self.Modules =3D [] - self.LibraryInstances =3D [] - self.LibraryClasses =3D {} - self.Libraries =3D {} - self.Pcds =3D {} - self.BuildOptions =3D {} + self.SkuIds =3D {} + self.Modules =3D [] + self.LibraryInstances =3D [] + self.LibraryClasses =3D {} + self.Libraries =3D {} + self.Pcds =3D {} + self.BuildOptions =3D {} diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/= Source/Python/Workspace/DecBuildData.py index eeb7c490ac8c..5f23904d9985 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by build tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -15,11 +15,13 @@ from Workspace.BuildClassObject import PackageBuildClas= sObject, StructurePcd, Pc from Common.GlobalData import gGlobalDefines from re import compile =20 -## Platform build information from DEC file +# Platform build information from DEC file # # This class is used to retrieve information stored in database and conve= rt them # into PackageBuildClassObject form for easier use for AutoGen. # + + class DecBuildData(PackageBuildClassObject): =20 # dict used to convert part of [Defines] to members of DecBuildData di= rectly @@ -27,13 +29,13 @@ class DecBuildData(PackageBuildClassObject): # # Required Fields # - TAB_DEC_DEFINES_PACKAGE_NAME : "_PackageName", - TAB_DEC_DEFINES_PACKAGE_GUID : "_Guid", - TAB_DEC_DEFINES_PACKAGE_VERSION : "_Version", - TAB_DEC_DEFINES_PKG_UNI_FILE : "_PkgUniFile", + TAB_DEC_DEFINES_PACKAGE_NAME: "_PackageName", + TAB_DEC_DEFINES_PACKAGE_GUID: "_Guid", + TAB_DEC_DEFINES_PACKAGE_VERSION: "_Version", + TAB_DEC_DEFINES_PKG_UNI_FILE: "_PkgUniFile", } =20 - ## Constructor of DecBuildData + # Constructor of DecBuildData # # Initialize object of DecBuildData # @@ -63,43 +65,43 @@ class DecBuildData(PackageBuildClassObject): def __getitem__(self, key): return self.__dict__[self._PROPERTY_[key]] =20 - ## "in" test support + # "in" test support def __contains__(self, key): return key in self._PROPERTY_ =20 - ## Set all internal used members of DecBuildData to None + # Set all internal used members of DecBuildData to None def _Clear(self): - self._Header =3D None - self._PackageName =3D None - self._Guid =3D None - self._Version =3D None - self._PkgUniFile =3D None - self._Protocols =3D None - self._Ppis =3D None - self._Guids =3D None - self._Includes =3D None - self._CommonIncludes =3D None - self._LibraryClasses =3D None - self._Pcds =3D None - self._MacroDict =3D None - self._PrivateProtocols =3D None - self._PrivatePpis =3D None - self._PrivateGuids =3D None - self._PrivateIncludes =3D None + self._Header =3D None + self._PackageName =3D None + self._Guid =3D None + self._Version =3D None + self._PkgUniFile =3D None + self._Protocols =3D None + self._Ppis =3D None + self._Guids =3D None + self._Includes =3D None + self._CommonIncludes =3D None + self._LibraryClasses =3D None + self._Pcds =3D None + self._MacroDict =3D None + self._PrivateProtocols =3D None + self._PrivatePpis =3D None + self._PrivateGuids =3D None + self._PrivateIncludes =3D None =20 - ## Get current effective macros + # Get current effective macros @property def _Macros(self): if self._MacroDict is None: self._MacroDict =3D dict(gGlobalDefines) return self._MacroDict =20 - ## Get architecture + # Get architecture @property def Arch(self): return self._Arch =20 - ## Retrieve all information in [Defines] section + # Retrieve all information in [Defines] section # # (Retrieving all [Defines] information in one-shot is just to save = time.) # @@ -111,27 +113,29 @@ class DecBuildData(PackageBuildClassObject): self[Name] =3D Record[2] self._Header =3D 'DUMMY' =20 - ## Retrieve package name + # Retrieve package name @property def PackageName(self): if self._PackageName is None: if self._Header is None: self._GetHeaderInfo() if self._PackageName is None: - EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACK= AGE_NAME", File=3Dself.MetaFile) + EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, + "No PACKAGE_NAME", File=3Dself.MetaFile) return self._PackageName =20 - ## Retrieve file guid + # Retrieve file guid @property def PackageName(self): if self._Guid is None: if self._Header is None: self._GetHeaderInfo() if self._Guid is None: - EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACK= AGE_GUID", File=3Dself.MetaFile) + EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, + "No PACKAGE_GUID", File=3Dself.MetaFile) return self._Guid =20 - ## Retrieve package version + # Retrieve package version @property def Version(self): if self._Version is None: @@ -141,7 +145,7 @@ class DecBuildData(PackageBuildClassObject): self._Version =3D '' return self._Version =20 - ## Retrieve protocol definitions (name/value pairs) + # Retrieve protocol definitions (name/value pairs) @property def Protocols(self): if self._Protocols is None: @@ -162,12 +166,14 @@ class DecBuildData(PackageBuildClassObject): PrivateNameList.append(Name) PrivateProtocolDict[Arch, Name] =3D Guid if Name in PublicNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) else: if Name not in PublicNameList: PublicNameList.append(Name) if Name in PrivateNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) if Name not in NameList: NameList.append(Name) ProtocolDict[Arch, Name] =3D Guid @@ -184,7 +190,7 @@ class DecBuildData(PackageBuildClassObject): self._PrivateProtocols[Name] =3D PrivateProtocolDict[self.= _Arch, Name] return self._Protocols =20 - ## Retrieve PPI definitions (name/value pairs) + # Retrieve PPI definitions (name/value pairs) @property def Ppis(self): if self._Ppis is None: @@ -205,12 +211,14 @@ class DecBuildData(PackageBuildClassObject): PrivateNameList.append(Name) PrivatePpiDict[Arch, Name] =3D Guid if Name in PublicNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) else: if Name not in PublicNameList: PublicNameList.append(Name) if Name in PrivateNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) if Name not in NameList: NameList.append(Name) PpiDict[Arch, Name] =3D Guid @@ -227,7 +235,7 @@ class DecBuildData(PackageBuildClassObject): self._PrivatePpis[Name] =3D PrivatePpiDict[self._Arch, Nam= e] return self._Ppis =20 - ## Retrieve GUID definitions (name/value pairs) + # Retrieve GUID definitions (name/value pairs) @property def Guids(self): if self._Guids is None: @@ -248,12 +256,14 @@ class DecBuildData(PackageBuildClassObject): PrivateNameList.append(Name) PrivateGuidDict[Arch, Name] =3D Guid if Name in PublicNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) else: if Name not in PublicNameList: PublicNameList.append(Name) if Name in PrivateNameList: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % Name, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % Name, File=3Dself.MetaFile, Line=3DLineNo) if Name not in NameList: NameList.append(Name) GuidDict[Arch, Name] =3D Guid @@ -270,7 +280,7 @@ class DecBuildData(PackageBuildClassObject): self._PrivateGuids[Name] =3D PrivateGuidDict[self._Arch, N= ame] return self._Guids =20 - ## Retrieve public include paths declared in this package + # Retrieve public include paths declared in this package @property def Includes(self): if self._Includes is None or self._CommonIncludes is None: @@ -281,12 +291,14 @@ class DecBuildData(PackageBuildClassObject): RecordList =3D self._RawData[MODEL_EFI_INCLUDE, self._Arch] Macros =3D self._Macros for Record in RecordList: - File =3D PathClass(NormPath(Record[0], Macros), self._Pack= ageDir, Arch=3Dself._Arch) + File =3D PathClass( + NormPath(Record[0], Macros), self._PackageDir, Arch=3D= self._Arch) LineNo =3D Record[-1] # validate the path ErrorCode, ErrorInfo =3D File.Validate() if ErrorCode !=3D 0: - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorI= nfo, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3D= self.MetaFile, Line=3DLineNo) =20 # avoid duplicate include path if File not in self._Includes: @@ -295,17 +307,19 @@ class DecBuildData(PackageBuildClassObject): if File not in self._PrivateIncludes: self._PrivateIncludes.append(File) if File in PublicInclues: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % File, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % File, File=3Dself.MetaFile, Line=3DLineNo) else: if File not in PublicInclues: PublicInclues.append(File) if File in self._PrivateIncludes: - EdkLogger.error('build', OPTION_CONFLICT, "Can't d= etermine %s's attribute, it is both defined as Private and non-Private attr= ibute in DEC file." % File, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', OPTION_CONFLICT, "Can't determine %s'= s attribute, it is both defined as Private and non-Private attribute in DEC= file." % File, File=3Dself.MetaFile, Line=3DLineNo) if Record[3] =3D=3D TAB_COMMON: self._CommonIncludes.append(File) return self._Includes =20 - ## Retrieve library class declarations (not used in build at present) + # Retrieve library class declarations (not used in build at present) @property def LibraryClasses(self): if self._LibraryClasses is None: @@ -318,11 +332,13 @@ class DecBuildData(PackageBuildClassObject): RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Ar= ch] Macros =3D self._Macros for LibraryClass, File, Dummy, Arch, PrivateFlag, ID, LineNo i= n RecordList: - File =3D PathClass(NormPath(File, Macros), self._PackageDi= r, Arch=3Dself._Arch) + File =3D PathClass(NormPath(File, Macros), + self._PackageDir, Arch=3Dself._Arch) # check the file validation ErrorCode, ErrorInfo =3D File.Validate() if ErrorCode !=3D 0: - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorI= nfo, File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3D= self.MetaFile, Line=3DLineNo) LibraryClassSet.add(LibraryClass) LibraryClassDict[Arch, LibraryClass] =3D File self._LibraryClasses =3D OrderedDict() @@ -330,7 +346,7 @@ class DecBuildData(PackageBuildClassObject): self._LibraryClasses[LibraryClass] =3D LibraryClassDict[se= lf._Arch, LibraryClass] return self._LibraryClasses =20 - ## Retrieve PCD declarations + # Retrieve PCD declarations @property def Pcds(self): if self._Pcds is None: @@ -342,7 +358,7 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return self._Pcds =20 - def ParsePcdName(self,TokenCName): + def ParsePcdName(self, TokenCName): TokenCName =3D TokenCName.strip() if TokenCName.startswith("["): if "." in TokenCName: @@ -355,7 +371,7 @@ class DecBuildData(PackageBuildClassObject): Demesionattr =3D "" Fields =3D TokenCName =20 - return Demesionattr,Fields + return Demesionattr, Fields =20 def ProcessStructurePcd(self, StructurePcdRawDataSet): s_pcd_set =3D OrderedDict() @@ -372,25 +388,30 @@ class DecBuildData(PackageBuildClassObject): if not item.TokenCName: continue if "" in item.TokenCName: - struct_pcd.StructuredPcdIncludeFile.append(item.Defaul= tValue) + struct_pcd.StructuredPcdIncludeFile.append( + item.DefaultValue) elif "" in item.TokenCName: dep_pkgs.append(item.DefaultValue) elif item.DatumType =3D=3D item.TokenCName: struct_pcd.copy(item) - struct_pcd.TokenValue =3D struct_pcd.TokenValue.strip(= "{").strip() - struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = =3D pcdname.split(".") + struct_pcd.TokenValue =3D struct_pcd.TokenValue.strip( + "{").strip() + struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = =3D pcdname.split( + ".") struct_pcd.PcdDefineLineNo =3D LineNo struct_pcd.PkgPath =3D self.MetaFile.File - struct_pcd.SetDecDefaultValue(item.DefaultValue,self.M= etaFile.File,LineNo) + struct_pcd.SetDecDefaultValue( + item.DefaultValue, self.MetaFile.File, LineNo) else: DemesionAttr, Fields =3D self.ParsePcdName(item.TokenC= Name) - struct_pcd.AddDefaultValue(Fields, item.DefaultValue, = self.MetaFile.File, LineNo,DemesionAttr) + struct_pcd.AddDefaultValue( + Fields, item.DefaultValue, self.MetaFile.File, Lin= eNo, DemesionAttr) =20 struct_pcd.PackageDecs =3D dep_pkgs str_pcd_set.append(struct_pcd) return str_pcd_set =20 - ## Retrieve PCD declarations for given type + # Retrieve PCD declarations for given type def _GetPcd(self, Type): Pcds =3D OrderedDict() # @@ -420,38 +441,43 @@ class DecBuildData(PackageBuildClassObject): continue =20 DefaultValue, DatumType, TokenNumber =3D AnalyzePcdData(Settin= g) - validateranges, validlists, expressions =3D self._RawData.GetV= alidExpression(TokenSpaceGuid, PcdCName) + validateranges, validlists, expressions =3D self._RawData.GetV= alidExpression( + TokenSpaceGuid, PcdCName) PcdObj =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - self._PCD_TYPE_STRING_[Type], - DatumType, - DefaultValue, - TokenNumber, - '', - {}, - False, - None, - list(validateranges), - list(validlists), - list(expressions) - ) + PcdCName, + TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type], + DatumType, + DefaultValue, + TokenNumber, + '', + {}, + False, + None, + list(validateranges), + list(validlists), + list(expressions) + ) DefinitionPosition[PcdObj] =3D (self.MetaFile.File, LineNo) if "." in TokenSpaceGuid: StrPcdSet.append((PcdObj, LineNo)) else: - Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type= ]] =3D PcdObj + Pcds[PcdCName, TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type]] =3D PcdObj =20 StructurePcds =3D self.ProcessStructurePcd(StrPcdSet) for pcd in StructurePcds: - Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_S= TRING_[Type]] =3D pcd + Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, + self._PCD_TYPE_STRING_[Type]] =3D pcd StructPattern =3D compile(r'[_a-zA-Z][0-9A-Za-z_]*$') for pcd in Pcds.values(): if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TA= B_UINT64, TAB_VOID, "BOOLEAN"]: if not pcd.IsAggregateDatumType(): - EdkLogger.error('build', FORMAT_INVALID, "DatumType on= ly support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct = name.", DefinitionPosition[pcd][0], DefinitionPosition[pcd][1]) + EdkLogger.error('build', FORMAT_INVALID, "DatumType on= ly support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct = name.", + DefinitionPosition[pcd][0], Definition= Position[pcd][1]) elif not pcd.IsArray() and not pcd.StructuredPcdIncludeFil= e: - EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The= structure Pcd %s.%s header file is not found in %s line %s \n" % (pcd.Toke= nSpaceGuidCName, pcd.TokenCName, pcd.DefinitionPosition[0], pcd.DefinitionP= osition[1] )) + EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The= structure Pcd %s.%s header file is not found in %s line %s \n" % ( + pcd.TokenSpaceGuidCName, pcd.TokenCName, pcd.Defin= itionPosition[0], pcd.DefinitionPosition[1])) return Pcds =20 @property diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index e9f68384b429..fe1f8369a220 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by build tool # # Copyright (c) 2008 - 2020, Intel Corporation. All rights reserved.
        @@ -6,12 +6,13 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Platform build information from DSC file +# Platform build information from DSC file # # This class is used to retrieve information stored in database and conve= rt them # into PlatformBuildClassObject form for easier use for AutoGen. # from __future__ import print_function +from AutoGen.GenMake import gIncludePattern from __future__ import absolute_import from Common.StringUtils import * from Common.DataType import * @@ -19,15 +20,15 @@ from Common.Misc import * from types import * from Common.Expression import * from CommonDataClass.CommonClass import SkuInfoClass -from Common.TargetTxtClassObject import TargetTxtDict,gDefaultTargetTxtFile -from Common.ToolDefClassObject import ToolDefDict,gDefaultToolsDefFile +from Common.TargetTxtClassObject import TargetTxtDict, gDefaultTargetTxtFi= le +from Common.ToolDefClassObject import ToolDefDict, gDefaultToolsDefFile from .MetaDataTable import * from .MetaFileTable import * from .MetaFileParser import * =20 from .WorkspaceCommon import GetDeclaredPcd from Common.Misc import AnalyzeDscPcd -from Common.Misc import ProcessDuplicatedInf,RemoveCComments,ArrayIndex +from Common.Misc import ProcessDuplicatedInf, RemoveCComments, ArrayIndex import re from Common.Parsing import IsValidWord from Common.VariableAttributes import VariableAttributes @@ -38,11 +39,12 @@ from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, Structure= Pcd, PcdClassObject, ModuleBuildClassObject from collections import OrderedDict, defaultdict =20 -def _IsFieldValueAnArray (Value): + +def _IsFieldValueAnArray(Value): Value =3D Value.strip() if Value.startswith(TAB_GUID) and Value.endswith(')'): return True - if Value.startswith('L"') and Value.endswith('"') and len(list(Value[= 2:-1])) > 1: + if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2= :-1])) > 1: return True if Value[0] =3D=3D '"' and Value[-1] =3D=3D '"' and len(list(Value[1:-= 1])) > 1: return True @@ -54,6 +56,7 @@ def _IsFieldValueAnArray (Value): return True return False =20 + PcdValueInitName =3D 'PcdValueInit' PcdValueCommonName =3D 'PcdValueCommon' =20 @@ -109,13 +112,12 @@ LIBS =3D -lCommon =20 variablePattern =3D re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$') SkuIdPattern =3D re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$') -## regular expressions for finding decimal and hex numbers +# regular expressions for finding decimal and hex numbers Pattern =3D re.compile('^[1-9]\d*|0$') HexPattern =3D re.compile(r'0[xX][0-9a-fA-F]+$') -## Regular expression for finding header file inclusions -from AutoGen.GenMake import gIncludePattern +# Regular expression for finding header file inclusions =20 -## Find dependencies for one source file +# Find dependencies for one source file # # By searching recursively "#include" directive in file, find out all the # files needed by given source file. The dependecies will be only searched @@ -125,6 +127,8 @@ from AutoGen.GenMake import gIncludePattern # # @retval list The list of files the given source file de= pends on # + + def GetDependencyList(FileStack, SearchPathList): DepDb =3D dict() DependencySet =3D set(FileStack) @@ -139,7 +143,8 @@ def GetDependencyList(FileStack, SearchPathList): Fd =3D open(F, 'r') FileContent =3D Fd.read() except BaseException as X: - EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=3DF = + "\n\t" + str(X)) + EdkLogger.error("build", FILE_OPEN_FAILURE, + ExtraData=3DF + "\n\t" + str(X)) finally: if "Fd" in dir(locals()): Fd.close() @@ -179,6 +184,7 @@ def GetDependencyList(FileStack, SearchPathList): =20 return DependencyList =20 + class DscBuildData(PlatformBuildClassObject): =20 # dict used to convert part of [Defines] to members of DscBuildData di= rectly @@ -186,19 +192,19 @@ class DscBuildData(PlatformBuildClassObject): # # Required Fields # - TAB_DSC_DEFINES_PLATFORM_NAME : "_PlatformName", - TAB_DSC_DEFINES_PLATFORM_GUID : "_Guid", - TAB_DSC_DEFINES_PLATFORM_VERSION : "_Version", - TAB_DSC_DEFINES_DSC_SPECIFICATION : "_DscSpecification", + TAB_DSC_DEFINES_PLATFORM_NAME: "_PlatformName", + TAB_DSC_DEFINES_PLATFORM_GUID: "_Guid", + TAB_DSC_DEFINES_PLATFORM_VERSION: "_Version", + TAB_DSC_DEFINES_DSC_SPECIFICATION: "_DscSpecification", # TAB_DSC_DEFINES_OUTPUT_DIRECTORY : "_OutputDirectory", # TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES : "_SupArchList", # TAB_DSC_DEFINES_BUILD_TARGETS : "_BuildTargets", - TAB_DSC_DEFINES_SKUID_IDENTIFIER : "_SkuName", + TAB_DSC_DEFINES_SKUID_IDENTIFIER: "_SkuName", # TAB_DSC_DEFINES_FLASH_DEFINITION : "_FlashDefinition", - TAB_DSC_DEFINES_BUILD_NUMBER : "_BuildNumber", - TAB_DSC_DEFINES_MAKEFILE_NAME : "_MakefileName", - TAB_DSC_DEFINES_BS_BASE_ADDRESS : "_BsBaseAddress", - TAB_DSC_DEFINES_RT_BASE_ADDRESS : "_RtBaseAddress", + TAB_DSC_DEFINES_BUILD_NUMBER: "_BuildNumber", + TAB_DSC_DEFINES_MAKEFILE_NAME: "_MakefileName", + TAB_DSC_DEFINES_BS_BASE_ADDRESS: "_BsBaseAddress", + TAB_DSC_DEFINES_RT_BASE_ADDRESS: "_RtBaseAddress", # TAB_DSC_DEFINES_RFC_LANGUAGES : "_RFCLanguages", # TAB_DSC_DEFINES_ISO_LANGUAGES : "_ISOLanguages", } @@ -206,7 +212,7 @@ class DscBuildData(PlatformBuildClassObject): # used to compose dummy library class name for those forced library in= stances _NullLibraryNumber =3D 0 =20 - ## Constructor of DscBuildData + # Constructor of DscBuildData # # Initialize object of DscBuildData # @@ -226,10 +232,12 @@ class DscBuildData(PlatformBuildClassObject): self._Toolchain =3D Toolchain self._ToolChainFamily =3D None self._Clear() - self.WorkspaceDir =3D os.getenv("WORKSPACE") if os.getenv("WORKSPA= CE") else "" + self.WorkspaceDir =3D os.getenv( + "WORKSPACE") if os.getenv("WORKSPACE") else "" self.DefaultStores =3D None self.SkuIdMgr =3D SkuClass(self.SkuName, self.SkuIds) self.UpdatePcdTypeDict() + @property def OutputPath(self): if os.getenv("WORKSPACE"): @@ -245,46 +253,46 @@ class DscBuildData(PlatformBuildClassObject): def __getitem__(self, key): return self.__dict__[self._PROPERTY_[key]] =20 - ## "in" test support + # "in" test support def __contains__(self, key): return key in self._PROPERTY_ =20 - ## Set all internal used members of DscBuildData to None + # Set all internal used members of DscBuildData to None def _Clear(self): - self._Header =3D None - self._PlatformName =3D None - self._Guid =3D None - self._Version =3D None - self._DscSpecification =3D None - self._OutputDirectory =3D None - self._SupArchList =3D None - self._BuildTargets =3D None - self._SkuName =3D None - self._PcdInfoFlag =3D None - self._VarCheckFlag =3D None - self._FlashDefinition =3D None - self._Prebuild =3D None - self._Postbuild =3D None - self._BuildNumber =3D None - self._MakefileName =3D None - self._BsBaseAddress =3D None - self._RtBaseAddress =3D None - self._SkuIds =3D None - self._Modules =3D None - self._LibraryInstances =3D None - self._LibraryClasses =3D None - self._Pcds =3D None - self._DecPcds =3D None - self._BuildOptions =3D None + self._Header =3D None + self._PlatformName =3D None + self._Guid =3D None + self._Version =3D None + self._DscSpecification =3D None + self._OutputDirectory =3D None + self._SupArchList =3D None + self._BuildTargets =3D None + self._SkuName =3D None + self._PcdInfoFlag =3D None + self._VarCheckFlag =3D None + self._FlashDefinition =3D None + self._Prebuild =3D None + self._Postbuild =3D None + self._BuildNumber =3D None + self._MakefileName =3D None + self._BsBaseAddress =3D None + self._RtBaseAddress =3D None + self._SkuIds =3D None + self._Modules =3D None + self._LibraryInstances =3D None + self._LibraryClasses =3D None + self._Pcds =3D None + self._DecPcds =3D None + self._BuildOptions =3D None self._ModuleTypeOptions =3D None - self._LoadFixAddress =3D None - self._RFCLanguages =3D None - self._ISOLanguages =3D None - self._VpdToolGuid =3D None - self._MacroDict =3D None - self.DefaultStores =3D None + self._LoadFixAddress =3D None + self._RFCLanguages =3D None + self._ISOLanguages =3D None + self._VpdToolGuid =3D None + self._MacroDict =3D None + self.DefaultStores =3D None =20 - ## Get current effective macros + # Get current effective macros @property def _Macros(self): if self._MacroDict is None: @@ -294,15 +302,16 @@ class DscBuildData(PlatformBuildClassObject): self._MacroDict.update(GlobalData.gCommandLineDefines) return self._MacroDict =20 - ## Get architecture + # Get architecture @property def Arch(self): return self._Arch + @property def Dir(self): return self.MetaFile.Dir =20 - ## Retrieve all information in [Defines] section + # Retrieve all information in [Defines] section # # (Retrieving all [Defines] information in one-shot is just to save = time.) # @@ -320,7 +329,8 @@ class DscBuildData(PlatformBuildClassObject): File=3Dself.MetaFile, Line=3DRecord[-1= ], ExtraData=3Dself._OutputDirectory) elif Name =3D=3D TAB_DSC_DEFINES_FLASH_DEFINITION: - self._FlashDefinition =3D PathClass(NormPath(Record[2], se= lf._Macros), GlobalData.gWorkspace) + self._FlashDefinition =3D PathClass( + NormPath(Record[2], self._Macros), GlobalData.gWorkspa= ce) ErrorCode, ErrorInfo =3D self._FlashDefinition.Validate('.= fdf') if ErrorCode !=3D 0: EdkLogger.error('build', ErrorCode, File=3Dself.MetaFi= le, Line=3DRecord[-1], @@ -330,7 +340,7 @@ class DscBuildData(PlatformBuildClassObject): if Record[2][0] =3D=3D '"': if Record[2][-1] !=3D '"': EdkLogger.error('build', FORMAT_INVALID, 'Missing = double quotes in the end of %s statement.' % TAB_DSC_PREBUILD, - File=3Dself.MetaFile, Line=3DRecord[-1= ]) + File=3Dself.MetaFile, Line=3DRecor= d[-1]) PrebuildValue =3D Record[2][1:-1] self._Prebuild =3D PrebuildValue elif Name =3D=3D TAB_DSC_POSTBUILD: @@ -338,11 +348,12 @@ class DscBuildData(PlatformBuildClassObject): if Record[2][0] =3D=3D '"': if Record[2][-1] !=3D '"': EdkLogger.error('build', FORMAT_INVALID, 'Missing = double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD, - File=3Dself.MetaFile, Line=3DRecord[-1= ]) + File=3Dself.MetaFile, Line=3DRecor= d[-1]) PostbuildValue =3D Record[2][1:-1] self._Postbuild =3D PostbuildValue elif Name =3D=3D TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES: - self._SupArchList =3D GetSplitValueList(Record[2], TAB_VAL= UE_SPLIT) + self._SupArchList =3D GetSplitValueList( + Record[2], TAB_VALUE_SPLIT) elif Name =3D=3D TAB_DSC_DEFINES_BUILD_TARGETS: self._BuildTargets =3D GetSplitValueList(Record[2]) elif Name =3D=3D TAB_DSC_DEFINES_SKUID_IDENTIFIER: @@ -356,9 +367,10 @@ class DscBuildData(PlatformBuildClassObject): self._VarCheckFlag =3D Record[2] elif Name =3D=3D TAB_FIX_LOAD_TOP_MEMORY_ADDRESS: try: - self._LoadFixAddress =3D int (Record[2], 0) + self._LoadFixAddress =3D int(Record[2], 0) except: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_= TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (Record[2])) + EdkLogger.error( + "build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_A= DDRESS %s is not valid dec or hex string" % (Record[2])) elif Name =3D=3D TAB_DSC_DEFINES_RFC_LANGUAGES: if not Record[2] or Record[2][0] !=3D '"' or Record[2][-1]= !=3D '"' or len(Record[2]) =3D=3D 1: EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'langua= ge code for RFC_LANGUAGES must have double quotes around it, for example: R= FC_LANGUAGES =3D "en-us;zh-hans"', @@ -367,7 +379,8 @@ class DscBuildData(PlatformBuildClassObject): if not LanguageCodes: EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or= more RFC4646 format language code must be provided for RFC_LANGUAGES state= ment', File=3Dself.MetaFile, Line=3DRecord[-1= ]) - LanguageList =3D GetSplitValueList(LanguageCodes, TAB_SEMI= _COLON_SPLIT) + LanguageList =3D GetSplitValueList( + LanguageCodes, TAB_SEMI_COLON_SPLIT) # check whether there is empty entries in the list if None in LanguageList: EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or= more empty language code is in RFC_LANGUAGES statement', @@ -390,7 +403,8 @@ class DscBuildData(PlatformBuildClassObject): self._ISOLanguages =3D LanguageList elif Name =3D=3D TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_ST= ORE: if TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_STORE not in= gCommandLineDefines: - gCommandLineDefines[TAB_DSC_DEFINES_VPD_AUTHENTICATED_= VARIABLE_STORE] =3D Record[2].strip() + gCommandLineDefines[TAB_DSC_DEFINES_VPD_AUTHENTICATED_= VARIABLE_STORE] =3D Record[2].strip( + ) =20 elif Name =3D=3D TAB_DSC_DEFINES_VPD_TOOL_GUID: # @@ -400,88 +414,97 @@ class DscBuildData(PlatformBuildClassObject): try: uuid.UUID(Record[2]) except: - EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID= format for VPD_TOOL_GUID", File=3Dself.MetaFile) + EdkLogger.error( + "build", FORMAT_INVALID, "Invalid GUID format for = VPD_TOOL_GUID", File=3Dself.MetaFile) self._VpdToolGuid =3D Record[2] elif Name =3D=3D TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX: if TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX not in gComman= dLineDefines: - gCommandLineDefines[TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYN= AMICEX] =3D Record[2].strip() + gCommandLineDefines[TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYN= AMICEX] =3D Record[2].strip( + ) elif Name in self: self[Name] =3D Record[2] # set _Header to non-None in order to avoid database re-querying self._Header =3D 'DUMMY' =20 - ## Retrieve platform name + # Retrieve platform name @property def PlatformName(self): if self._PlatformName is None: if self._Header is None: self._GetHeaderInfo() if self._PlatformName is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLAT= FORM_NAME", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No PLATFORM_NAME", File=3Dself.MetaFile) return self._PlatformName =20 @property def Platform(self): return self.PlatformName =20 - ## Retrieve file guid + # Retrieve file guid @property def Guid(self): if self._Guid is None: if self._Header is None: self._GetHeaderInfo() if self._Guid is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLAT= FORM_GUID", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No PLATFORM_GUID", File=3Dself.MetaFile) return self._Guid =20 - ## Retrieve platform version + # Retrieve platform version @property def Version(self): if self._Version is None: if self._Header is None: self._GetHeaderInfo() if self._Version is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLAT= FORM_VERSION", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No PLATFORM_VERSION", File=3Dself.MetaFil= e) return self._Version =20 - ## Retrieve platform description file version + # Retrieve platform description file version @property def DscSpecification(self): if self._DscSpecification is None: if self._Header is None: self._GetHeaderInfo() if self._DscSpecification is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No DSC_= SPECIFICATION", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No DSC_SPECIFICATION", File=3Dself.MetaFi= le) return self._DscSpecification =20 - ## Retrieve OUTPUT_DIRECTORY + # Retrieve OUTPUT_DIRECTORY @property def OutputDirectory(self): if self._OutputDirectory is None: if self._Header is None: self._GetHeaderInfo() if self._OutputDirectory is None: - self._OutputDirectory =3D os.path.join("Build", self._Plat= formName) + self._OutputDirectory =3D os.path.join( + "Build", self._PlatformName) return self._OutputDirectory =20 - ## Retrieve SUPPORTED_ARCHITECTURES + # Retrieve SUPPORTED_ARCHITECTURES @property def SupArchList(self): if self._SupArchList is None: if self._Header is None: self._GetHeaderInfo() if self._SupArchList is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No SUPP= ORTED_ARCHITECTURES", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No SUPPORTED_ARCHITECTURES", File=3Dself.= MetaFile) return self._SupArchList =20 - ## Retrieve BUILD_TARGETS + # Retrieve BUILD_TARGETS @property def BuildTargets(self): if self._BuildTargets is None: if self._Header is None: self._GetHeaderInfo() if self._BuildTargets is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUIL= D_TARGETS", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No BUILD_TARGETS", File=3Dself.MetaFile) return self._BuildTargets =20 @property @@ -512,7 +535,7 @@ class DscBuildData(PlatformBuildClassObject): self._SkuName =3D TAB_DEFAULT return self._SkuName =20 - ## Override SKUID_IDENTIFIER + # Override SKUID_IDENTIFIER @SkuName.setter def SkuName(self, Value): self._SkuName =3D Value @@ -544,7 +567,7 @@ class DscBuildData(PlatformBuildClassObject): self._Postbuild =3D '' return self._Postbuild =20 - ## Retrieve FLASH_DEFINITION + # Retrieve FLASH_DEFINITION @property def BuildNumber(self): if self._BuildNumber is None: @@ -554,7 +577,7 @@ class DscBuildData(PlatformBuildClassObject): self._BuildNumber =3D '' return self._BuildNumber =20 - ## Retrieve MAKEFILE_NAME + # Retrieve MAKEFILE_NAME @property def MakefileName(self): if self._MakefileName is None: @@ -564,7 +587,7 @@ class DscBuildData(PlatformBuildClassObject): self._MakefileName =3D '' return self._MakefileName =20 - ## Retrieve BsBaseAddress + # Retrieve BsBaseAddress @property def BsBaseAddress(self): if self._BsBaseAddress is None: @@ -574,7 +597,7 @@ class DscBuildData(PlatformBuildClassObject): self._BsBaseAddress =3D '' return self._BsBaseAddress =20 - ## Retrieve RtBaseAddress + # Retrieve RtBaseAddress @property def RtBaseAddress(self): if self._RtBaseAddress is None: @@ -584,7 +607,7 @@ class DscBuildData(PlatformBuildClassObject): self._RtBaseAddress =3D '' return self._RtBaseAddress =20 - ## Retrieve the top address for the load fix address + # Retrieve the top address for the load fix address @property def LoadFixAddress(self): if self._LoadFixAddress is None: @@ -592,30 +615,36 @@ class DscBuildData(PlatformBuildClassObject): self._GetHeaderInfo() =20 if self._LoadFixAddress is None: - self._LoadFixAddress =3D self._Macros.get(TAB_FIX_LOAD_TOP= _MEMORY_ADDRESS, '0') + self._LoadFixAddress =3D self._Macros.get( + TAB_FIX_LOAD_TOP_MEMORY_ADDRESS, '0') =20 try: - self._LoadFixAddress =3D int (self._LoadFixAddress, 0) + self._LoadFixAddress =3D int(self._LoadFixAddress, 0) except: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS %s is not valid dec or hex string" % (self._LoadFixAddress)) + EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS %s is not valid dec or hex string" % ( + self._LoadFixAddress)) =20 # # If command line defined, should override the value in DSC file. # if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines: try: - self._LoadFixAddress =3D int(GlobalData.gCommandLineDefine= s['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0) + self._LoadFixAddress =3D int( + GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_AD= DRESS'], 0) except: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS %s is not valid dec or hex string" % (GlobalData.gCommandLin= eDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'])) + EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS %s is not valid dec or hex string" % ( + GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_AD= DRESS'])) =20 if self._LoadFixAddress < 0: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMO= RY_ADDRESS is set to the invalid negative value 0x%x" % (self._LoadFixAddre= ss)) + EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMO= RY_ADDRESS is set to the invalid negative value 0x%x" % ( + self._LoadFixAddress)) if self._LoadFixAddress !=3D 0xFFFFFFFFFFFFFFFF and self._LoadFixA= ddress % 0x1000 !=3D 0: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMO= RY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % (self._LoadFixA= ddress)) + EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMO= RY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % ( + self._LoadFixAddress)) =20 return self._LoadFixAddress =20 - ## Retrieve RFCLanguage filter + # Retrieve RFCLanguage filter @property def RFCLanguages(self): if self._RFCLanguages is None: @@ -625,7 +654,7 @@ class DscBuildData(PlatformBuildClassObject): self._RFCLanguages =3D [] return self._RFCLanguages =20 - ## Retrieve ISOLanguage filter + # Retrieve ISOLanguage filter @property def ISOLanguages(self): if self._ISOLanguages is None: @@ -635,7 +664,7 @@ class DscBuildData(PlatformBuildClassObject): self._ISOLanguages =3D [] return self._ISOLanguages =20 - ## Retrieve the GUID string for VPD tool + # Retrieve the GUID string for VPD tool @property def VpdToolGuid(self): if self._VpdToolGuid is None: @@ -645,7 +674,7 @@ class DscBuildData(PlatformBuildClassObject): self._VpdToolGuid =3D '' return self._VpdToolGuid =20 - ## Retrieve [SkuIds] section information + # Retrieve [SkuIds] section information @property def SkuIds(self): if self._SkuIds is None: @@ -664,7 +693,8 @@ class DscBuildData(PlatformBuildClassObject): if not SkuIdPattern.match(Record[1]) or (Record[2] and not= SkuIdPattern.match(Record[2])): EdkLogger.error('build', FORMAT_INVALID, "The format o= f the Sku ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*= '", File=3Dself.MetaFile, Line=3DRecord[-1= ]) - self._SkuIds[Record[1].upper()] =3D (str(DscBuildData.ToIn= t(Record[0])), Record[1].upper(), Record[2].upper()) + self._SkuIds[Record[1].upper()] =3D ( + str(DscBuildData.ToInt(Record[0])), Record[1].upper(),= Record[2].upper()) if TAB_DEFAULT not in self._SkuIds: self._SkuIds[TAB_DEFAULT] =3D ("0", TAB_DEFAULT, TAB_DEFAU= LT) if TAB_COMMON not in self._SkuIds: @@ -692,9 +722,11 @@ class DscBuildData(PlatformBuildClassObject): if not IsValidWord(Record[1]): EdkLogger.error('build', FORMAT_INVALID, "The format o= f the DefaultStores ID name is invalid. The correct format is '(a-zA-Z0-9_)= (a-zA-Z0-9_-.)*'", File=3Dself.MetaFile, Line=3DRecord[-1= ]) - self.DefaultStores[Record[1].upper()] =3D (DscBuildData.To= Int(Record[0]), Record[1].upper()) + self.DefaultStores[Record[1].upper()] =3D ( + DscBuildData.ToInt(Record[0]), Record[1].upper()) if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: - self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] =3D (0, TAB= _DEFAULT_STORES_DEFAULT) + self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] =3D ( + 0, TAB_DEFAULT_STORES_DEFAULT) GlobalData.gDefaultStores =3D sorted(self.DefaultStores.keys()) return self.DefaultStores =20 @@ -704,32 +736,38 @@ class DscBuildData(PlatformBuildClassObject): Components =3D {} for Record in RecordList: ModuleId =3D Record[6] - file_guid =3D self._RawData[MODEL_META_DATA_HEADER, self._Arch= , None, ModuleId] + file_guid =3D self._RawData[MODEL_META_DATA_HEADER, + self._Arch, None, ModuleId] file_guid_str =3D file_guid[0][2] if file_guid else "NULL" - ModuleFile =3D PathClass(NormPath(Record[0], Macros), GlobalDa= ta.gWorkspace, Arch=3Dself._Arch) - if self._Arch !=3D TAB_ARCH_COMMON and (file_guid_str,str(Modu= leFile)) in Components: - self._RawData.DisableOverrideComponent(Components[(file_gu= id_str,str(ModuleFile))]) - Components[(file_guid_str,str(ModuleFile))] =3D ModuleId + ModuleFile =3D PathClass( + NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch= =3Dself._Arch) + if self._Arch !=3D TAB_ARCH_COMMON and (file_guid_str, str(Mod= uleFile)) in Components: + self._RawData.DisableOverrideComponent( + Components[(file_guid_str, str(ModuleFile))]) + Components[(file_guid_str, str(ModuleFile))] =3D ModuleId self._RawData._PostProcessed =3D False =20 - ## Retrieve packages this Platform depends on + # Retrieve packages this Platform depends on @cached_property def Packages(self): RetVal =3D set() RecordList =3D self._RawData[MODEL_META_DATA_PACKAGE, self._Arch] Macros =3D self._Macros for Record in RecordList: - File =3D PathClass(NormPath(Record[0], Macros), GlobalData.gWo= rkspace, Arch=3Dself._Arch) + File =3D PathClass( + NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch= =3Dself._Arch) # check the file validation ErrorCode, ErrorInfo =3D File.Validate('.dec') if ErrorCode !=3D 0: LineNo =3D Record[-1] - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorInfo,= File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3Dself= .MetaFile, Line=3DLineNo) # parse this package now. we need it to get protocol/ppi/guid = value - RetVal.add(self._Bdb[File, self._Arch, self._Target, self._Too= lchain]) + RetVal.add(self._Bdb[File, self._Arch, + self._Target, self._Toolchain]) return RetVal =20 - ## Retrieve [Components] section information + # Retrieve [Components] section information @property def Modules(self): if self._Modules is not None: @@ -739,7 +777,8 @@ class DscBuildData(PlatformBuildClassObject): RecordList =3D self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] Macros =3D self._Macros for Record in RecordList: - ModuleFile =3D PathClass(NormPath(Record[0], Macros), GlobalDa= ta.gWorkspace, Arch=3Dself._Arch) + ModuleFile =3D PathClass( + NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch= =3Dself._Arch) ModuleId =3D Record[6] LineNo =3D Record[7] =20 @@ -749,15 +788,18 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', ErrorCode, File=3Dself.MetaFile, = Line=3DLineNo, ExtraData=3DErrorInfo) =20 - ModuleBuildData =3D self._Bdb[ModuleFile, self._Arch, self._Ta= rget, self._Toolchain] + ModuleBuildData =3D self._Bdb[ModuleFile, + self._Arch, self._Target, self._To= olchain] Module =3D ModuleBuildClassObject() Module.MetaFile =3D ModuleFile Module.Guid =3D ModuleBuildData.Guid # get module private library instance - RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Ar= ch, None, ModuleId] + RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, + self._Arch, None, ModuleId] for Record in RecordList: LibraryClass =3D Record[0] - LibraryPath =3D PathClass(NormPath(Record[1], Macros), Glo= balData.gWorkspace, Arch=3Dself._Arch) + LibraryPath =3D PathClass( + NormPath(Record[1], Macros), GlobalData.gWorkspace, Ar= ch=3Dself._Arch) LineNo =3D Record[-1] =20 # check the file validation @@ -769,13 +811,14 @@ class DscBuildData(PlatformBuildClassObject): if LibraryClass =3D=3D '' or LibraryClass =3D=3D 'NULL': self._NullLibraryNumber +=3D 1 LibraryClass =3D 'NULL%d' % self._NullLibraryNumber - EdkLogger.verbose("Found forced library for %s\n\t%s [= %s]" % (ModuleFile, LibraryPath, LibraryClass)) + EdkLogger.verbose("Found forced library for %s\n\t%s [= %s]" % ( + ModuleFile, LibraryPath, LibraryClass)) Module.LibraryClasses[LibraryClass] =3D LibraryPath if LibraryPath not in self.LibraryInstances: self.LibraryInstances.append(LibraryPath) S_PcdSet =3D [] # get module private PCD setting - for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_= MODULE, \ + for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_= MODULE, MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_= PCD_DYNAMIC_EX]: RecordList =3D self._RawData[Type, self._Arch, None, Modul= eId] for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dum= my3, Dummy4, Dummy5 in RecordList: @@ -788,45 +831,52 @@ class DscBuildData(PlatformBuildClassObject): MaxDatumSize =3D '' TypeString =3D self._PCD_TYPE_STRING_[Type] =20 - TCName,PCName,DimensionAttr,Field =3D self.ParsePcdNam= eStruct(TokenSpaceGuid, PcdCName) + TCName, PCName, DimensionAttr, Field =3D self.ParsePcd= NameStruct( + TokenSpaceGuid, PcdCName) =20 if ("." in TokenSpaceGuid or "[" in PcdCName): - S_PcdSet.append([ TCName,PCName,DimensionAttr,Fiel= d, ModuleBuildData.Guid, "", Dummy5, AnalyzePcdExpression(Setting)[0]]) + S_PcdSet.append([TCName, PCName, DimensionAttr, Fi= eld, + ModuleBuildData.Guid, "", Dummy5, = AnalyzePcdExpression(Setting)[0]]) DefaultValue =3D '' - if ( PCName,TCName) not in Module.Pcds: + if (PCName, TCName) not in Module.Pcds: Pcd =3D PcdClassObject( - PCName, - TCName, - TypeString, - '', - DefaultValue, - '', - MaxDatumSize, - {}, - False, - None, - IsDsc=3DTrue) + PCName, + TCName, + TypeString, + '', + DefaultValue, + '', + MaxDatumSize, + {}, + False, + None, + IsDsc=3DTrue) Module.Pcds[PCName, TCName] =3D Pcd =20 Module.StrPcdSet =3D S_PcdSet - for TCName,PCName, _,_,_,_,_,_ in S_PcdSet: - if (PCName,TCName) in Module.Pcds: - Module.StrPcdOverallValue[(PCName,TCName)] =3D Module.= Pcds[(PCName,TCName)].DefaultValue, self.MetaFile,Dummy5 + for TCName, PCName, _, _, _, _, _, _ in S_PcdSet: + if (PCName, TCName) in Module.Pcds: + Module.StrPcdOverallValue[(PCName, TCName)] =3D Module= .Pcds[( + PCName, TCName)].DefaultValue, self.MetaFile, Dumm= y5 # get module private build options - RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, sel= f._Arch, None, ModuleId] + RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, + self._Arch, None, ModuleId] for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3= , Dummy4, Dummy5 in RecordList: if (ToolChainFamily, ToolChain) not in Module.BuildOptions: Module.BuildOptions[ToolChainFamily, ToolChain] =3D Op= tion else: OptionString =3D Module.BuildOptions[ToolChainFamily, = ToolChain] - Module.BuildOptions[ToolChainFamily, ToolChain] =3D Op= tionString + " " + Option + Module.BuildOptions[ToolChainFamily, + ToolChain] =3D OptionString + " " = + Option =20 - RecordList =3D self._RawData[MODEL_META_DATA_HEADER, self._Arc= h, None, ModuleId] + RecordList =3D self._RawData[MODEL_META_DATA_HEADER, + self._Arch, None, ModuleId] if RecordList: if len(RecordList) !=3D 1: EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GU= ID can be listed in section.', File=3Dself.MetaFile, ExtraData=3Dstr(= ModuleFile), Line=3DLineNo) - ModuleFile =3D ProcessDuplicatedInf(ModuleFile, RecordList= [0][2], GlobalData.gWorkspace) + ModuleFile =3D ProcessDuplicatedInf( + ModuleFile, RecordList[0][2], GlobalData.gWorkspace) ModuleFile.Arch =3D self._Arch Module.Guid =3D RecordList[0][2] for item in Module.StrPcdSet: @@ -834,14 +884,14 @@ class DscBuildData(PlatformBuildClassObject): self._Modules[ModuleFile] =3D Module return self._Modules =20 - ## Retrieve all possible library instances used in this platform + # Retrieve all possible library instances used in this platform @property def LibraryInstances(self): if self._LibraryInstances is None: self.LibraryClasses return self._LibraryInstances =20 - ## Retrieve [LibraryClasses] information + # Retrieve [LibraryClasses] information @property def LibraryClasses(self): if self._LibraryClasses is None: @@ -853,16 +903,19 @@ class DscBuildData(PlatformBuildClassObject): LibraryClassDict =3D tdict(True, 3) # track all library class names LibraryClassSet =3D set() - RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Ar= ch, None, -1] + RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, + self._Arch, None, -1] Macros =3D self._Macros for Record in RecordList: LibraryClass, LibraryInstance, Dummy, Arch, ModuleType, Du= mmy, Dummy, LineNo =3D Record if LibraryClass =3D=3D '' or LibraryClass =3D=3D 'NULL': self._NullLibraryNumber +=3D 1 LibraryClass =3D 'NULL%d' % self._NullLibraryNumber - EdkLogger.verbose("Found forced library for arch=3D%s\= n\t%s [%s]" % (Arch, LibraryInstance, LibraryClass)) + EdkLogger.verbose("Found forced library for arch=3D%s\= n\t%s [%s]" % ( + Arch, LibraryInstance, LibraryClass)) LibraryClassSet.add(LibraryClass) - LibraryInstance =3D PathClass(NormPath(LibraryInstance, Ma= cros), GlobalData.gWorkspace, Arch=3Dself._Arch) + LibraryInstance =3D PathClass( + NormPath(LibraryInstance, Macros), GlobalData.gWorkspa= ce, Arch=3Dself._Arch) # check the file validation ErrorCode, ErrorInfo =3D LibraryInstance.Validate('.inf') if ErrorCode !=3D 0: @@ -872,7 +925,8 @@ class DscBuildData(PlatformBuildClassObject): if ModuleType !=3D TAB_COMMON and ModuleType not in SUP_MO= DULE_LIST: EdkLogger.error('build', OPTION_UNKNOWN, "Unknown modu= le type [%s]" % ModuleType, File=3Dself.MetaFile, ExtraData=3DLibr= aryInstance, Line=3DLineNo) - LibraryClassDict[Arch, ModuleType, LibraryClass] =3D Libra= ryInstance + LibraryClassDict[Arch, ModuleType, + LibraryClass] =3D LibraryInstance if LibraryInstance not in self._LibraryInstances: self._LibraryInstances.append(LibraryInstance) =20 @@ -881,14 +935,17 @@ class DscBuildData(PlatformBuildClassObject): for LibraryClass in LibraryClassSet: # try all possible module types for ModuleType in SUP_MODULE_LIST: - LibraryInstance =3D LibraryClassDict[self._Arch, Modul= eType, LibraryClass] + LibraryInstance =3D LibraryClassDict[self._Arch, + ModuleType, Library= Class] if LibraryInstance is None: continue - self._LibraryClasses[LibraryClass, ModuleType] =3D Lib= raryInstance + self._LibraryClasses[LibraryClass, + ModuleType] =3D LibraryInstance =20 RecordList =3D self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self.= _Arch] for Record in RecordList: - File =3D PathClass(NormPath(Record[0], Macros), GlobalData= .gWorkspace, Arch=3Dself._Arch) + File =3D PathClass( + NormPath(Record[0], Macros), GlobalData.gWorkspace, Ar= ch=3Dself._Arch) LineNo =3D Record[-1] # check the file validation ErrorCode, ErrorInfo =3D File.Validate('.inf') @@ -902,7 +959,8 @@ class DscBuildData(PlatformBuildClassObject): # to parse it here. (self._Bdb[] will trigger a file parse= if it # hasn't been parsed) # - Library =3D self._Bdb[File, self._Arch, self._Target, self= ._Toolchain] + Library =3D self._Bdb[File, self._Arch, + self._Target, self._Toolchain] self._LibraryClasses[Library.BaseName, ':dummy:'] =3D Libr= ary return self._LibraryClasses =20 @@ -915,21 +973,26 @@ class DscBuildData(PlatformBuildClassObject): =20 PkgSet =3D set() for Inf in FdfInfList: - ModuleFile =3D PathClass(NormPath(Inf), GlobalData.gWorksp= ace, Arch=3Dself._Arch) + ModuleFile =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, Arch=3Dself._Arc= h) if ModuleFile in self._Modules: continue - ModuleData =3D self._Bdb[ModuleFile, self._Arch, self._Tar= get, self._Toolchain] + ModuleData =3D self._Bdb[ModuleFile, + self._Arch, self._Target, self._Too= lchain] PkgSet.update(ModuleData.Packages) if self.Packages: PkgSet.update(self.Packages) - self._DecPcds, self._GuidDict =3D GetDeclaredPcd(self, self._B= db, self._Arch, self._Target, self._Toolchain, PkgSet) + self._DecPcds, self._GuidDict =3D GetDeclaredPcd( + self, self._Bdb, self._Arch, self._Target, self._Toolchain= , PkgSet) self._GuidDict.update(GlobalData.gPlatformPcds) =20 if (PcdCName, TokenSpaceGuid) not in self._DecPcds: EdkLogger.error('build', PARSER_ERROR, - "Pcd (%s.%s) defined in DSC is not declared in= DEC files referenced in INF files in FDF. Arch: ['%s']" % (TokenSpaceGuid,= PcdCName, self._Arch), + "Pcd (%s.%s) defined in DSC is not declared in= DEC files referenced in INF files in FDF. Arch: ['%s']" % ( + TokenSpaceGuid, PcdCName, self._Arch), File=3Dself.MetaFile, Line=3DLineNo) - ValueList, IsValid, Index =3D AnalyzeDscPcd(Setting, PcdType, self= ._DecPcds[PcdCName, TokenSpaceGuid].DatumType) + ValueList, IsValid, Index =3D AnalyzeDscPcd( + Setting, PcdType, self._DecPcds[PcdCName, TokenSpaceGuid].Datu= mType) if not IsValid: if PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_= BUILD]: EdkLogger.error('build', FORMAT_INVALID, "Pcd format incor= rect.", File=3Dself.MetaFile, Line=3DLineNo, @@ -937,16 +1000,17 @@ class DscBuildData(PlatformBuildClassObject): else: if ValueList[2] =3D=3D '-1': EdkLogger.error('build', FORMAT_INVALID, "Pcd format i= ncorrect.", File=3Dself.MetaFile, Line=3DLineNo, - ExtraData=3D"%s.%s|%s" % (TokenSpaceGuid, = PcdCName, Setting)) + ExtraData=3D"%s.%s|%s" % (TokenSpaceGu= id, PcdCName, Setting)) if ValueList[Index]: DatumType =3D self._DecPcds[PcdCName, TokenSpaceGuid].DatumType if "{CODE(" not in ValueList[Index]: try: - ValueList[Index] =3D ValueExpressionEx(ValueList[Index= ], DatumType, self._GuidDict)(True) + ValueList[Index] =3D ValueExpressionEx( + ValueList[Index], DatumType, self._GuidDict)(True) except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, Value, File= =3Dself.MetaFile, Line=3DLineNo, ExtraData=3D"PCD [%s.%s] Value \"%s\" = " % ( - TokenSpaceGuid, PcdCName, ValueList[In= dex])) + TokenSpaceGuid, PcdCName, ValueLis= t[Index])) except EvaluationException as Excpt: if hasattr(Excpt, 'Pcd'): if Excpt.Pcd in GlobalData.gPlatformOtherPcds: @@ -962,7 +1026,8 @@ class DscBuildData(PlatformBuildClassObject): File=3Dself.MetaFile, Line=3DLineN= o) =20 if ValueList[Index]: - Valid, ErrStr =3D CheckPcdDatum(self._DecPcds[PcdCName, TokenS= paceGuid].DatumType, ValueList[Index]) + Valid, ErrStr =3D CheckPcdDatum( + self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueLi= st[Index]) if not Valid: EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=3Dse= lf.MetaFile, Line=3DLineNo, ExtraData=3D"%s.%s" % (TokenSpaceGuid, Pcd= CName)) @@ -970,14 +1035,16 @@ class DscBuildData(PlatformBuildClassObject): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip= () !=3D ValueList[1].strip(): DecPcd =3D self._DecPcds[PcdCName, TokenSpaceGuid] EdkLogger.error('build', FORMAT_INVALID, - "Pcd datumtype used in DSC file is not= the same as its declaration. DatumType:%s"%DecPcd.DatumType, + "Pcd datumtype used in DSC file is not= the same as its declaration. DatumType:%s" % DecPcd.DatumType, File=3Dself.MetaFile, Line=3DLineNo, - ExtraData=3D"Dsc:%s.%s|%s\n Dec:%s.= %s|%s|%s|%s" % (TokenSpaceGuid, PcdCName, Setting, TokenSpaceGuid, \ - PcdCName, DecPcd.DefaultValue, DecPcd.= DatumType, DecPcd.TokenValue)) + ExtraData=3D"Dsc:%s.%s|%s\n Dec:%s.= %s|%s|%s|%s" % (TokenSpaceGuid, PcdCName, Setting, TokenSpaceGuid, + = PcdCName, DecPcd.DefaultValue, DecPcd.DatumType, DecPcd.Token= Value)) if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds: if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != =3D ValueList[Index]: - GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = =3D ValueList[Index] - GlobalData.gPlatformFinalPcds[TokenSpaceGuid + '.' + PcdCName]= =3D ValueList[Index] + GlobalData.gPlatformPcds[TokenSpaceGuid + + '.' + PcdCName] =3D ValueList[Ind= ex] + GlobalData.gPlatformFinalPcds[TokenSpaceGuid + + '.' + PcdCName] =3D ValueList[In= dex] return ValueList =20 def _FilterPcdBySkuUsage(self, Pcds): @@ -986,38 +1053,47 @@ class DscBuildData(PlatformBuildClassObject): if sku_usage =3D=3D SkuClass.SINGLE: for pcdname in Pcds: pcd =3D Pcds[pcdname] - Pcds[pcdname].SkuInfoList =3D {TAB_DEFAULT:pcd.SkuInfoList= [skuid] for skuid in pcd.SkuInfoList if skuid in available_sku} + Pcds[pcdname].SkuInfoList =3D {TAB_DEFAULT: pcd.SkuInfoLis= t[skuid] + for skuid in pcd.SkuInfoList = if skuid in available_sku} if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues: - Pcds[pcdname].SkuOverrideValues =3D {TAB_DEFAULT:pcd.S= kuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in avai= lable_sku} + Pcds[pcdname].SkuOverrideValues =3D { + TAB_DEFAULT: pcd.SkuOverrideValues[skuid] for skui= d in pcd.SkuOverrideValues if skuid in available_sku} else: for pcdname in Pcds: pcd =3D Pcds[pcdname] - Pcds[pcdname].SkuInfoList =3D {skuid:pcd.SkuInfoList[skuid= ] for skuid in pcd.SkuInfoList if skuid in available_sku} + Pcds[pcdname].SkuInfoList =3D {skuid: pcd.SkuInfoList[skui= d] + for skuid in pcd.SkuInfoList = if skuid in available_sku} if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues: - Pcds[pcdname].SkuOverrideValues =3D {skuid:pcd.SkuOver= rideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_= sku} + Pcds[pcdname].SkuOverrideValues =3D { + skuid: pcd.SkuOverrideValues[skuid] for skuid in p= cd.SkuOverrideValues if skuid in available_sku} return Pcds =20 def CompleteHiiPcdsDefaultStores(self, Pcds): - HiiPcd =3D [Pcds[pcd] for pcd in Pcds if Pcds[pcd].Type in [self._= PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX_HII]]] + HiiPcd =3D [Pcds[pcd] for pcd in Pcds if Pcds[pcd].Type in [self._= PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAM= IC_EX_HII]]] DefaultStoreMgr =3D DefaultStore(self.DefaultStores) for pcd in HiiPcd: for skuid in pcd.SkuInfoList: skuobj =3D pcd.SkuInfoList.get(skuid) if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDi= ct: - PcdDefaultStoreSet =3D set(defaultstorename for defau= ltstorename in skuobj.DefaultStoreDict) - mindefaultstorename =3D DefaultStoreMgr.GetMin(PcdDefa= ultStoreSet) + PcdDefaultStoreSet =3D set( + defaultstorename for defaultstorename in skuobj.De= faultStoreDict) + mindefaultstorename =3D DefaultStoreMgr.GetMin( + PcdDefaultStoreSet) skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = =3D skuobj.DefaultStoreDict[mindefaultstorename] return Pcds =20 def RecoverCommandLinePcd(self): def UpdateCommandLineValue(pcd): if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUIL= D], - self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE]]: + self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_= MODULE]]: pcd.PcdValueFromComm =3D pcd.DefaultValue elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII= ], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: - pcd.PcdValueFromComm =3D pcd.SkuInfoList.get(TAB_DEFAULT).= HiiDefaultValue + pcd.PcdValueFromComm =3D pcd.SkuInfoList.get( + TAB_DEFAULT).HiiDefaultValue else: - pcd.PcdValueFromComm =3D pcd.SkuInfoList.get(TAB_DEFAULT).= DefaultValue + pcd.PcdValueFromComm =3D pcd.SkuInfoList.get( + TAB_DEFAULT).DefaultValue for pcd in self._Pcds: if isinstance(self._Pcds[pcd], StructurePcd) and (self._Pcds[p= cd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm): UpdateCommandLineValue(self._Pcds[pcd]) @@ -1029,7 +1105,8 @@ class DscBuildData(PlatformBuildClassObject): continue (pcdname, pcdvalue) =3D pcd.split('=3D') if not pcdvalue: - EdkLogger.error('build', AUTOGEN_ERROR, "No Value spec= ified for the PCD %s." % (pcdname)) + EdkLogger.error( + 'build', AUTOGEN_ERROR, "No Value specified for th= e PCD %s." % (pcdname)) if '.' in pcdname: (Name1, Name2) =3D pcdname.split('.', 1) if "." in Name2: @@ -1048,7 +1125,7 @@ class DscBuildData(PlatformBuildClassObject): HasTokenSpace =3D True TokenCName =3D Name2 TokenSpaceGuidCName =3D Name1 - FieldName =3D"" + FieldName =3D "" else: FieldName =3D Name2 TokenCName =3D Name1 @@ -1070,48 +1147,59 @@ class DscBuildData(PlatformBuildClassObject): PcdItem =3D self.DecPcds[key] if TokenCName =3D=3D PcdItem.TokenCName: if not PcdItem.TokenSpaceGuidCName in TokenSpa= ceGuidCNameList: - if len (TokenSpaceGuidCNameList) < 1: - TokenSpaceGuidCNameList.append(PcdItem= .TokenSpaceGuidCName) + if len(TokenSpaceGuidCNameList) < 1: + TokenSpaceGuidCNameList.append( + PcdItem.TokenSpaceGuidCName) TokenSpaceGuidCName =3D PcdItem.TokenS= paceGuidCName PcdDatumType =3D PcdItem.DatumType FoundFlag =3D True else: EdkLogger.error( - 'build', - AUTOGEN_ERROR, - "The Pcd %s is found under mul= tiple different TokenSpaceGuid: %s and %s." % (DisplayName, PcdItem.TokenSp= aceGuidCName, TokenSpaceGuidCNameList[0]) - ) + 'build', + AUTOGEN_ERROR, + "The Pcd %s is found under multipl= e different TokenSpaceGuid: %s and %s." % ( + DisplayName, PcdItem.TokenSpac= eGuidCName, TokenSpaceGuidCNameList[0]) + ) else: if (TokenCName, TokenSpaceGuidCName) in self.DecPcds: - PcdDatumType =3D self.DecPcds[(TokenCName, TokenSp= aceGuidCName)].DatumType + PcdDatumType =3D self.DecPcds[( + TokenCName, TokenSpaceGuidCName)].DatumType FoundFlag =3D True if not FoundFlag: if HasTokenSpace: - EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %= s.%s is not found in the DEC file." % (TokenSpaceGuidCName, DisplayName)) + EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %= s.%s is not found in the DEC file." % ( + TokenSpaceGuidCName, DisplayName)) else: - EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %= s is not found in the DEC file." % (DisplayName)) - pcdvalue =3D pcdvalue.replace("\\\\\\'", '\\\\\\"').replac= e('\\\'', '\'').replace('\\\\\\"', "\\'") + EdkLogger.error( + 'build', AUTOGEN_ERROR, "The Pcd %s is not fou= nd in the DEC file." % (DisplayName)) + pcdvalue =3D pcdvalue.replace("\\\\\\'", '\\\\\\"').replac= e( + '\\\'', '\'').replace('\\\\\\"', "\\'") if FieldName: - pcdvalue =3D DscBuildData.HandleFlexiblePcd(TokenSpace= GuidCName, TokenCName, pcdvalue, PcdDatumType, self._GuidDict, FieldName) + pcdvalue =3D DscBuildData.HandleFlexiblePcd( + TokenSpaceGuidCName, TokenCName, pcdvalue, PcdDatu= mType, self._GuidDict, FieldName) else: - pcdvalue =3D DscBuildData.HandleFlexiblePcd(TokenSpace= GuidCName, TokenCName, pcdvalue, PcdDatumType, self._GuidDict) + pcdvalue =3D DscBuildData.HandleFlexiblePcd( + TokenSpaceGuidCName, TokenCName, pcdvalue, PcdDatu= mType, self._GuidDict) IsValid, Cause =3D CheckPcdDatum(PcdDatumType, pcdvalu= e) if not IsValid: - EdkLogger.error("build", FORMAT_INVALID, Cause, Ex= traData=3D"%s.%s" % (TokenSpaceGuidCName, TokenCName)) - GlobalData.BuildOptionPcd[i] =3D (TokenSpaceGuidCName, Tok= enCName, FieldName, pcdvalue, ("build command options", 1)) + EdkLogger.error("build", FORMAT_INVALID, Cause, Ex= traData=3D"%s.%s" % ( + TokenSpaceGuidCName, TokenCName)) + GlobalData.BuildOptionPcd[i] =3D ( + TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, = ("build command options", 1)) =20 if GlobalData.BuildOptionPcd: - inf_objs =3D [item for item in self._Bdb._CACHE_.values() if i= tem.Arch =3D=3D self.Arch and item.MetaFile.Ext.lower() =3D=3D '.inf'] + inf_objs =3D [item for item in self._Bdb._CACHE_.values( + ) if item.Arch =3D=3D self.Arch and item.MetaFile.Ext.lower() = =3D=3D '.inf'] for pcd in GlobalData.BuildOptionPcd: (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = =3D pcd for BuildData in inf_objs: for key in BuildData.Pcds: PcdItem =3D BuildData.Pcds[key] - if (TokenSpaceGuidCName, TokenCName) =3D=3D (PcdIt= em.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =3D=3D"": + if (TokenSpaceGuidCName, TokenCName) =3D=3D (PcdIt= em.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =3D=3D "": PcdItem.DefaultValue =3D pcdvalue PcdItem.PcdValueFromComm =3D pcdvalue - #In command line, the latter full assign value in commandLine shou= ld override the former field assign value. - #For example, --pcd Token.pcd.field=3D"" --pcd Token.pcd=3DH"{}" + # In command line, the latter full assign value in commandLine sho= uld override the former field assign value. + # For example, --pcd Token.pcd.field=3D"" --pcd Token.pcd=3DH"{}" delete_assign =3D [] field_assign =3D {} if GlobalData.BuildOptionPcd: @@ -1123,7 +1211,8 @@ class DscBuildData(PlatformBuildClassObject): field_assign[TokenSpaceGuid, Token].append(pcdTuple) else: if (TokenSpaceGuid, Token) in field_assign: - delete_assign.extend(field_assign[TokenSpaceGuid, = Token]) + delete_assign.extend( + field_assign[TokenSpaceGuid, Token]) field_assign[TokenSpaceGuid, Token] =3D [] for item in delete_assign: GlobalData.BuildOptionPcd.remove(item) @@ -1140,7 +1229,8 @@ class DscBuildData(PlatformBuildClassObject): if FieldName and not IsArray: return PcdValue try: - PcdValue =3D ValueExpressionEx(PcdValue[1:], PcdDatumType,= GuidDict)(True) + PcdValue =3D ValueExpressionEx( + PcdValue[1:], PcdDatumType, GuidDict)(True) except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Val= ue "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) @@ -1151,7 +1241,8 @@ class DscBuildData(PlatformBuildClassObject): if FieldName and not IsArray: return PcdValue try: - PcdValue =3D ValueExpressionEx(PcdValue, PcdDatumType, Gui= dDict)(True) + PcdValue =3D ValueExpressionEx( + PcdValue, PcdDatumType, GuidDict)(True) except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Val= ue "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) @@ -1163,7 +1254,8 @@ class DscBuildData(PlatformBuildClassObject): if FieldName and not IsArray: return PcdValue try: - PcdValue =3D ValueExpressionEx(PcdValue, PcdDatumType, Gui= dDict)(True) + PcdValue =3D ValueExpressionEx( + PcdValue, PcdDatumType, GuidDict)(True) except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Val= ue "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) @@ -1192,13 +1284,14 @@ class DscBuildData(PlatformBuildClassObject): if not IsArray: return PcdValue try: - PcdValue =3D ValueExpressionEx(PcdValue, PcdDatumType, Gui= dDict)(True) + PcdValue =3D ValueExpressionEx( + PcdValue, PcdDatumType, GuidDict)(True) except BadExpression as Value: EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Val= ue "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) return PcdValue =20 - ## Retrieve all PCD settings in platform + # Retrieve all PCD settings in platform @property def Pcds(self): if self._Pcds is None: @@ -1210,14 +1303,16 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_DEFAUL= T)) self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_HII= )) self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_VPD= )) - self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEF= AULT)) + self._Pcds.update(self._GetDynamicPcd( + MODEL_PCD_DYNAMIC_EX_DEFAULT)) self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_= HII)) self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_= VPD)) =20 self._Pcds =3D self.CompletePcdValues(self._Pcds) self._Pcds =3D self.OverrideByFdfOverAll(self._Pcds) self._Pcds =3D self.OverrideByCommOverAll(self._Pcds) - self._Pcds =3D self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, = self._Pcds) + self._Pcds =3D self.UpdateStructuredPcds( + MODEL_PCD_TYPE_LIST, self._Pcds) self._Pcds =3D self.CompleteHiiPcdsDefaultStores(self._Pcds) self._Pcds =3D self._FilterPcdBySkuUsage(self._Pcds) =20 @@ -1233,7 +1328,8 @@ class DscBuildData(PlatformBuildClassObject): # Retrieve build option for EDKII and EDK style module # for CodeBase in (EDKII_NAME, EDK_NAME): - RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION,= self._Arch, CodeBase] + RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, + self._Arch, CodeBase] for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Du= mmy3, Dummy4, Dummy5 in RecordList: if Dummy3.upper() !=3D TAB_COMMON: continue @@ -1247,6 +1343,7 @@ class DscBuildData(PlatformBuildClassObject): if ' ' + Option not in self._BuildOptions[CurKey]: self._BuildOptions[CurKey] +=3D ' ' + Option return self._BuildOptions + def GetBuildOptionsByPkg(self, Module, ModuleType): =20 local_pkg =3D os.path.split(Module.LocalPkg())[0] @@ -1254,10 +1351,10 @@ class DscBuildData(PlatformBuildClassObject): self._ModuleTypeOptions =3D OrderedDict() if ModuleType not in self._ModuleTypeOptions: options =3D OrderedDict() - self._ModuleTypeOptions[ ModuleType] =3D options + self._ModuleTypeOptions[ModuleType] =3D options RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, sel= f._Arch] for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3= , Dummy4, Dummy5 in RecordList: - if Dummy2 not in (TAB_COMMON,local_pkg.upper(),"EDKII"): + if Dummy2 not in (TAB_COMMON, local_pkg.upper(), "EDKII"): continue Type =3D Dummy3 if Type.upper() =3D=3D ModuleType.upper(): @@ -1268,6 +1365,7 @@ class DscBuildData(PlatformBuildClassObject): if ' ' + Option not in options[Key]: options[Key] +=3D ' ' + Option return self._ModuleTypeOptions[ModuleType] + def GetBuildOptionsByModuleType(self, Edk, ModuleType): if self._ModuleTypeOptions is None: self._ModuleTypeOptions =3D OrderedDict() @@ -1297,29 +1395,31 @@ class DscBuildData(PlatformBuildClassObject): return structure_pcd_data =20 @staticmethod - def OverrideByFdf(StruPcds,workspace): + def OverrideByFdf(StruPcds, workspace): if GlobalData.gFdfParser is None: return StruPcds StructurePcdInFdf =3D OrderedDict() fdfpcd =3D GlobalData.gFdfParser.Profile.PcdDict fdfpcdlocation =3D GlobalData.gFdfParser.Profile.PcdLocalDict - for item in fdfpcd : - if len(item[2]) and (item[0],item[1]) in StruPcds: - StructurePcdInFdf[(item[1],item[0],item[2] )] =3D fdfpcd[i= tem] - GlobalPcds =3D {(item[0],item[1]) for item in StructurePcdInFdf} + for item in fdfpcd: + if len(item[2]) and (item[0], item[1]) in StruPcds: + StructurePcdInFdf[(item[1], item[0], item[2])] =3D fdfpcd[= item] + GlobalPcds =3D {(item[0], item[1]) for item in StructurePcdInFdf} for Pcd in StruPcds.values(): - if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds: + if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) not in GlobalPcds: continue FieldValues =3D OrderedDict() for item in StructurePcdInFdf: - if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) =3D=3D (item[0= ],item[1]) and item[2]: + if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) =3D=3D (item[= 0], item[1]) and item[2]: FieldValues[item[2]] =3D StructurePcdInFdf[item] for field in FieldValues: if field not in Pcd.PcdFieldValueFromFdf: - Pcd.PcdFieldValueFromFdf[field] =3D ["","",""] + Pcd.PcdFieldValueFromFdf[field] =3D ["", "", ""] Pcd.PcdFieldValueFromFdf[field][0] =3D FieldValues[field] - Pcd.PcdFieldValueFromFdf[field][1] =3D os.path.relpath(fdf= pcdlocation[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName,field)][0],workspace) - Pcd.PcdFieldValueFromFdf[field][2] =3D fdfpcdlocation[(Pcd= .TokenCName,Pcd.TokenSpaceGuidCName,field)][1] + Pcd.PcdFieldValueFromFdf[field][1] =3D os.path.relpath( + fdfpcdlocation[(Pcd.TokenCName, Pcd.TokenSpaceGuidCNam= e, field)][0], workspace) + Pcd.PcdFieldValueFromFdf[field][2] =3D fdfpcdlocation[( + Pcd.TokenCName, Pcd.TokenSpaceGuidCName, field)][1] =20 return StruPcds =20 @@ -1328,7 +1428,8 @@ class DscBuildData(PlatformBuildClassObject): StructurePcdInCom =3D OrderedDict() for item in GlobalData.BuildOptionPcd: if len(item) =3D=3D 5 and (item[1], item[0]) in StruPcds: - StructurePcdInCom[(item[0], item[1], item[2] )] =3D (item[= 3], item[4]) + StructurePcdInCom[(item[0], item[1], item[2]) + ] =3D (item[3], item[4]) GlobalPcds =3D {(item[0], item[1]) for item in StructurePcdInCom} for Pcd in StruPcds.values(): if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) not in GlobalPcds: @@ -1345,7 +1446,7 @@ class DscBuildData(PlatformBuildClassObject): Pcd.PcdFieldValueFromComm[field][2] =3D FieldValues[field]= [1][1] return StruPcds =20 - def OverrideByCommOverAll(self,AllPcds): + def OverrideByCommOverAll(self, AllPcds): def CheckStructureInComm(commpcds): if not commpcds: return False @@ -1356,7 +1457,8 @@ class DscBuildData(PlatformBuildClassObject): if CheckStructureInComm(GlobalData.BuildOptionPcd): StructurePcdInCom =3D OrderedDict() for item in GlobalData.BuildOptionPcd: - StructurePcdInCom[(item[0], item[1], item[2] )] =3D (item[= 3], item[4]) + StructurePcdInCom[(item[0], item[1], item[2]) + ] =3D (item[3], item[4]) for item in StructurePcdInCom: if not item[2]: NoFiledValues[(item[0], item[1])] =3D StructurePcdInCo= m[item] @@ -1367,24 +1469,32 @@ class DscBuildData(PlatformBuildClassObject): if (Name, Guid) in AllPcds: Pcd =3D AllPcds.get((Name, Guid)) if isinstance(self._DecPcds.get((Pcd.TokenCName, Pcd.Token= SpaceGuidCName), None), StructurePcd): - self._DecPcds.get((Pcd.TokenCName, Pcd.TokenSpaceGuidC= Name)).PcdValueFromComm =3D NoFiledValues[(Pcd.TokenSpaceGuidCName, Pcd.Tok= enCName)][0] + self._DecPcds.get((Pcd.TokenCName, Pcd.TokenSpaceGuidC= Name)).PcdValueFromComm =3D NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][0] else: - Pcd.PcdValueFromComm =3D NoFiledValues[(Pcd.TokenSpace= GuidCName, Pcd.TokenCName)][0] - Pcd.DefaultValue =3D NoFiledValues[(Pcd.TokenSpaceGuid= CName, Pcd.TokenCName)][0] + Pcd.PcdValueFromComm =3D NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][0] + Pcd.DefaultValue =3D NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][0] for sku in Pcd.SkuInfoList: SkuInfo =3D Pcd.SkuInfoList[sku] if SkuInfo.DefaultValue: - SkuInfo.DefaultValue =3D NoFiledValues[(Pcd.To= kenSpaceGuidCName, Pcd.TokenCName)][0] + SkuInfo.DefaultValue =3D NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][= 0] else: - SkuInfo.HiiDefaultValue =3D NoFiledValues[(Pcd= .TokenSpaceGuidCName, Pcd.TokenCName)][0] + SkuInfo.HiiDefaultValue =3D NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][= 0] for defaultstore in SkuInfo.DefaultStoreDict: - SkuInfo.DefaultStoreDict[defaultstore] =3D= NoFiledValues[(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)][0] + SkuInfo.DefaultStoreDict[defaultstore] =3D= NoFiledValues[( + Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e)][0] if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAM= IC_EX_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII]]: if Pcd.DatumType =3D=3D TAB_VOID: if not Pcd.MaxDatumSize: Pcd.MaxDatumSize =3D '0' - CurrentSize =3D int(Pcd.MaxDatumSize, 16) if P= cd.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize) - OptionSize =3D len((StringToArray(Pcd.PcdValue= FromComm)).split(",")) + CurrentSize =3D int(Pcd.MaxDatumSize, 16) if P= cd.MaxDatumSize.upper( + ).startswith("0X") else int(Pcd.MaxDatumSize) + OptionSize =3D len( + (StringToArray(Pcd.PcdValueFromComm)).spli= t(",")) MaxSize =3D max(CurrentSize, OptionSize) Pcd.MaxDatumSize =3D str(MaxSize) else: @@ -1392,30 +1502,36 @@ class DscBuildData(PlatformBuildClassObject): if PcdInDec: PcdInDec.PcdValueFromComm =3D NoFiledValues[(Guid, Nam= e)][0] if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_= FIXED_AT_BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE], - self._PCD_TYPE_STRING_[MODEL_PCD_F= EATURE_FLAG], - self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC], - self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX]]: + self._PCD_TYPE_STRING_[ + MODEL_PCD_PATCHABLE_IN_MODULE= ], + self._PCD_TYPE_STRING_[ + MODEL_PCD_FEATURE_FLAG], + self._PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC], + self._PCD_TYPE_STRING_[MODEL_PCD_= DYNAMIC_EX]]: self._Pcds[Name, Guid] =3D copy.deepcopy(PcdInDec) - self._Pcds[Name, Guid].DefaultValue =3D NoFiledVal= ues[( Guid, Name)][0] + self._Pcds[Name, Guid].DefaultValue =3D NoFiledVal= ues[( + Guid, Name)][0] if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_= DYNAMIC], - self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX]]: - self._Pcds[Name, Guid].SkuInfoList =3D {TAB_DEFAUL= T:SkuInfoClass(TAB_DEFAULT, self.SkuIds[TAB_DEFAULT][0], '', '', '', '', ''= , NoFiledValues[( Guid, Name)][0])} + self._PCD_TYPE_STRING_[MODEL_PCD_= DYNAMIC_EX]]: + self._Pcds[Name, Guid].SkuInfoList =3D {TAB_DEFAUL= T: SkuInfoClass( + TAB_DEFAULT, self.SkuIds[TAB_DEFAULT][0], '', = '', '', '', '', NoFiledValues[(Guid, Name)][0])} return AllPcds =20 - def OverrideByFdfOverAll(self,AllPcds): + def OverrideByFdfOverAll(self, AllPcds): =20 if GlobalData.gFdfParser is None: return AllPcds NoFiledValues =3D GlobalData.gFdfParser.Profile.PcdDict - for Name,Guid,Field in NoFiledValues: + for Name, Guid, Field in NoFiledValues: if len(Field): continue - Value =3D NoFiledValues[(Name,Guid,Field)] - if (Name,Guid) in AllPcds: - Pcd =3D AllPcds.get((Name,Guid)) - if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenS= paceGuidCName), None),StructurePcd): - self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCN= ame)).PcdValueFromComm =3D Value + Value =3D NoFiledValues[(Name, Guid, Field)] + if (Name, Guid) in AllPcds: + Pcd =3D AllPcds.get((Name, Guid)) + if isinstance(self._DecPcds.get((Pcd.TokenCName, Pcd.Token= SpaceGuidCName), None), StructurePcd): + self._DecPcds.get( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName)).PcdValu= eFromComm =3D Value else: Pcd.PcdValueFromComm =3D Value Pcd.DefaultValue =3D Value @@ -1431,22 +1547,25 @@ class DscBuildData(PlatformBuildClassObject): if Pcd.DatumType =3D=3D TAB_VOID: if not Pcd.MaxDatumSize: Pcd.MaxDatumSize =3D '0' - CurrentSize =3D int(Pcd.MaxDatumSize,16) if Pc= d.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize) - OptionSize =3D len((StringToArray(Pcd.PcdValue= FromComm)).split(",")) + CurrentSize =3D int(Pcd.MaxDatumSize, 16) if P= cd.MaxDatumSize.upper( + ).startswith("0X") else int(Pcd.MaxDatumSize) + OptionSize =3D len( + (StringToArray(Pcd.PcdValueFromComm)).spli= t(",")) MaxSize =3D max(CurrentSize, OptionSize) Pcd.MaxDatumSize =3D str(MaxSize) else: - PcdInDec =3D self.DecPcds.get((Name,Guid)) + PcdInDec =3D self.DecPcds.get((Name, Guid)) if PcdInDec: PcdInDec.PcdValueFromFdf =3D Value if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_= FIXED_AT_BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE], - self._PCD_TYPE_STRING_[MODEL_PCD_F= EATURE_FLAG]]: + self._PCD_TYPE_STRING_[ + MODEL_PCD_PATCHABLE_IN_MODULE= ], + self._PCD_TYPE_STRING_[MODEL_PCD_= FEATURE_FLAG]]: self._Pcds[Name, Guid] =3D copy.deepcopy(PcdInDec) self._Pcds[Name, Guid].DefaultValue =3D Value return AllPcds =20 - def ParsePcdNameStruct(self,NamePart1,NamePart2): + def ParsePcdNameStruct(self, NamePart1, NamePart2): TokenSpaceCName =3D PcdCName =3D DimensionAttr =3D Field =3D "" if "." in NamePart1: TokenSpaceCName, TempPcdCName =3D NamePart1.split(".") @@ -1464,22 +1583,23 @@ class DscBuildData(PlatformBuildClassObject): else: PcdCName =3D NamePart2 =20 - return TokenSpaceCName,PcdCName,DimensionAttr,Field + return TokenSpaceCName, PcdCName, DimensionAttr, Field =20 def UpdateStructuredPcds(self, TypeList, AllPcds): =20 DynamicPcdType =3D [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAU= LT], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAUL= T], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]] + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFA= ULT], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]] =20 Pcds =3D AllPcds DefaultStoreMgr =3D DefaultStore(self.DefaultStores) SkuIds =3D self.SkuIds - self.SkuIdMgr.AvailableSkuIdSet.update({TAB_DEFAULT:0}) - DefaultStores =3D {storename for pcdobj in AllPcds.values() for sk= uobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDic= t} + self.SkuIdMgr.AvailableSkuIdSet.update({TAB_DEFAULT: 0}) + DefaultStores =3D {storename for pcdobj in AllPcds.values( + ) for skuobj in pcdobj.SkuInfoList.values() for storename in skuob= j.DefaultStoreDict} DefaultStores.add(TAB_DEFAULT_STORES_DEFAULT) =20 S_PcdSet =3D [] @@ -1495,28 +1615,34 @@ class DscBuildData(PlatformBuildClassObject): SkuName =3D TAB_DEFAULT if SkuName =3D=3D TAB_COMMON else SkuN= ame if SkuName not in SkuIds: continue - TCName,PCName,DimensionAttr,Field =3D self.ParsePcdNameStruct(= TokenSpaceGuid, PcdCName) - pcd_in_dec =3D self._DecPcds.get((PCName,TCName), None) + TCName, PCName, DimensionAttr, Field =3D self.ParsePcdNameStru= ct( + TokenSpaceGuid, PcdCName) + pcd_in_dec =3D self._DecPcds.get((PCName, TCName), None) if pcd_in_dec is None: EdkLogger.error('build', PARSER_ERROR, - "Pcd (%s.%s) defined in DSC is not declared in= DEC files. Arch: ['%s']" % (TCName, PCName, self._Arch), - File=3Dself.MetaFile, Line =3D Dummy5) + "Pcd (%s.%s) defined in DSC is not declare= d in DEC files. Arch: ['%s']" % ( + TCName, PCName, self._Arch), + File=3Dself.MetaFile, Line=3DDummy5) if SkuName in SkuIds and ("." in TokenSpaceGuid or "[" in PcdC= Name): - if not isinstance (pcd_in_dec, StructurePcd): + if not isinstance(pcd_in_dec, StructurePcd): EdkLogger.error('build', PARSER_ERROR, - "Pcd (%s.%s) is not declared as Structure = PCD in DEC files. Arch: ['%s']" % (TCName, PCName, self._Arch), - File=3Dself.MetaFile, Line =3D Dummy5) + "Pcd (%s.%s) is not declared as Struct= ure PCD in DEC files. Arch: ['%s']" % ( + TCName, PCName, self._Arch), + File=3Dself.MetaFile, Line=3DDummy5) =20 - S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuNa= me, default_store, Dummy5, AnalyzePcdExpression(Setting)[0]]) + S_PcdSet.append([TCName, PCName, DimensionAttr, Field, Sku= Name, + default_store, Dummy5, AnalyzePcdExpressio= n(Setting)[0]]) ModuleScopeOverallValue =3D {} for m in self.Modules.values(): mguid =3D m.Guid if m.StrPcdSet: S_PcdSet.extend(m.StrPcdSet) mguid =3D m.StrPcdSet[0][4] - for (PCName,TCName) in m.StrPcdOverallValue: - Value, dsc_file, lineNo =3D m.StrPcdOverallValue[(PCName,T= CName)] - ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mgu= id] =3D Value, dsc_file, lineNo + for (PCName, TCName) in m.StrPcdOverallValue: + Value, dsc_file, lineNo =3D m.StrPcdOverallValue[( + PCName, TCName)] + ModuleScopeOverallValue.setdefault((PCName, TCName), {})[ + mguid] =3D Value, dsc_file, lineNo # handle pcd value override StrPcdSet =3D DscBuildData.GetStructurePcdInfo(S_PcdSet) S_pcd_set =3D OrderedDict() @@ -1528,17 +1654,23 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in Default= Stores} for skuname in str_pcd_obj.SkuInfoList} + str_pcd_obj_str.DefaultFromDSC =3D {skuname: {defaults= tore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get( + defaultstore, str_pcd_obj.SkuInfoList[skuname].Hii= DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj= .SkuInfoList} else: - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultSto= res} for skuname in str_pcd_obj.SkuInfoList} + str_pcd_obj_str.DefaultFromDSC =3D {skuname: {defaults= tore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get( + defaultstore, str_pcd_obj.SkuInfoList[skuname].Def= aultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.Sk= uInfoList} for str_pcd_data in StrPcdSet[str_pcd]: if str_pcd_data[4] in SkuIds: - str_pcd_obj_str.AddOverrideValue(str_pcd_data[3], str(= str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] =3D=3D TAB_COMMON else str= _pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D=3D TAB_COMM= ON else str_pcd_data[5], self.MetaFile.File if self.WorkspaceDir not in sel= f.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.Work= spaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:], LineNo=3Dst= r_pcd_data[6],DimensionAttr =3D str_pcd_data[2]) + str_pcd_obj_str.AddOverrideValue(str_pcd_data[3], str(= str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] =3D=3D TAB_COMMON else str= _pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D=3D TAB_COMM= ON else str_pcd_data[5], + self.MetaFile.File if= self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(se= lf.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.W= orkspaceDir)+1:], LineNo=3Dstr_pcd_data[6], DimensionAttr=3Dstr_pcd_data[2]) elif GlobalData.gGuidPattern.match(str_pcd_data[4]): - str_pcd_obj_str.AddComponentOverrideValue(str_pcd_data= [3], str(str_pcd_data[7]), str_pcd_data[4].replace("-","S"), self.MetaFile.= File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File= [len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len= (self.WorkspaceDir)+1:], LineNo=3Dstr_pcd_data[6],DimensionAttr =3D str_pcd= _data[2]) - PcdComponentValue =3D ModuleScopeOverallValue.get((str= _pcd_obj_str.TokenCName,str_pcd_obj_str.TokenSpaceGuidCName)) + str_pcd_obj_str.AddComponentOverrideValue(str_pcd_data= [3], str(str_pcd_data[7]), str_pcd_data[4].replace("-", "S"), self.MetaFile= .File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.Fil= e[len( + self.WorkspaceDir) if self.WorkspaceDir.endswith(o= s.path.sep) else len(self.WorkspaceDir)+1:], LineNo=3Dstr_pcd_data[6], Dime= nsionAttr=3Dstr_pcd_data[2]) + PcdComponentValue =3D ModuleScopeOverallValue.get( + (str_pcd_obj_str.TokenCName, str_pcd_obj_str.Token= SpaceGuidCName)) for module_guid in PcdComponentValue: - str_pcd_obj_str.PcdValueFromComponents[module_guid= .replace("-","S")] =3D PcdComponentValue[module_guid] + str_pcd_obj_str.PcdValueFromComponents[module_guid= .replace( + "-", "S")] =3D PcdComponentValue[module_guid] S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str =20 # Add the Structure PCD that only defined in DEC, don't have overr= ide in DSC file @@ -1551,9 +1683,11 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj: str_pcd_obj_str.copy(str_pcd_obj) if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MOD= EL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{d= efaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaults= tore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in= DefaultStores} for skuname in str_pcd_obj.SkuInfoList} + str_pcd_obj_str.DefaultFromDSC =3D {skuname: {= defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get( + defaultstore, str_pcd_obj.SkuInfoList[skun= ame].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str= _pcd_obj.SkuInfoList} else: - str_pcd_obj_str.DefaultFromDSC =3D {skuname:{d= efaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaults= tore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in De= faultStores} for skuname in str_pcd_obj.SkuInfoList} + str_pcd_obj_str.DefaultFromDSC =3D {skuname: {= defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get( + defaultstore, str_pcd_obj.SkuInfoList[skun= ame].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pc= d_obj.SkuInfoList} S_pcd_set[Pcd] =3D str_pcd_obj_str if S_pcd_set: GlobalData.gStructurePcd[self.Arch] =3D S_pcd_set.copy() @@ -1570,12 +1704,13 @@ class DscBuildData(PlatformBuildClassObject): NoDefault =3D True break nextskuid =3D self.SkuIdMgr.GetNextSkuId(nextskuid) - stru_pcd.SkuOverrideValues[skuid] =3D copy.deepcopy(st= ru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({d= efaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStor= es} if DefaultStores else {}) #{TAB_DEFAULT_STORES_DEFAULT:stru_pcd.Default= Values}) + stru_pcd.SkuOverrideValues[skuid] =3D copy.deepcopy(st= ru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy( + {defaultstorename: stru_pcd.DefaultValues for defa= ultstorename in DefaultStores} if DefaultStores else {}) # {TAB_DEFAULT_ST= ORES_DEFAULT:stru_pcd.DefaultValues}) if not NoDefault: stru_pcd.ValueChain.add((skuid, '')) if 'DEFAULT' in stru_pcd.SkuOverrideValues and not GlobalD= ata.gPcdSkuOverrides.get((stru_pcd.TokenCName, stru_pcd.TokenSpaceGuidCName= )): GlobalData.gPcdSkuOverrides.update( - {(stru_pcd.TokenCName, stru_pcd.TokenSpaceGuidCNam= e): {'DEFAULT':stru_pcd.SkuOverrideValues['DEFAULT']}}) + {(stru_pcd.TokenCName, stru_pcd.TokenSpaceGuidCNam= e): {'DEFAULT': stru_pcd.SkuOverrideValues['DEFAULT']}}) if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_= HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: for skuid in SkuIds: nextskuid =3D skuid @@ -1588,14 +1723,17 @@ class DscBuildData(PlatformBuildClassObject): nextskuid =3D self.SkuIdMgr.GetNextSkuId(nexts= kuid) if NoDefault: continue - PcdDefaultStoreSet =3D set(defaultstorename for defau= ltstorename in stru_pcd.SkuOverrideValues[nextskuid]) - mindefaultstorename =3D DefaultStoreMgr.GetMin(PcdDefa= ultStoreSet) + PcdDefaultStoreSet =3D set( + defaultstorename for defaultstorename in stru_pcd.= SkuOverrideValues[nextskuid]) + mindefaultstorename =3D DefaultStoreMgr.GetMin( + PcdDefaultStoreSet) =20 for defaultstoreid in DefaultStores: if defaultstoreid not in stru_pcd.SkuOverrideValue= s[skuid]: - stru_pcd.SkuOverrideValues[skuid][defaultstore= id] =3D CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]) + stru_pcd.SkuOverrideValues[skuid][defaultstore= id] =3D CopyDict( + stru_pcd.SkuOverrideValues[nextskuid][mind= efaultstorename]) stru_pcd.ValueChain.add((skuid, defaultstoreid= )) - S_pcd_set =3D DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceD= ir) + S_pcd_set =3D DscBuildData.OverrideByFdf(S_pcd_set, self.Workspace= Dir) S_pcd_set =3D DscBuildData.OverrideByComm(S_pcd_set) =20 # Create a tool to caculate structure pcd value @@ -1610,21 +1748,24 @@ class DscBuildData(PlatformBuildClassObject): if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX_HII]]: if skuname not in str_pcd_obj.SkuInfoList: - str_pcd_obj.SkuInfoList[skuname] =3D SkuInfoClass(= SkuIdName=3Dskuname, SkuId=3Dself.SkuIds[skuname][0], HiiDefaultValue=3DPcd= Value, DefaultStore =3D {StoreName:PcdValue}) + str_pcd_obj.SkuInfoList[skuname] =3D SkuInfoClass( + SkuIdName=3Dskuname, SkuId=3Dself.SkuIds[skuna= me][0], HiiDefaultValue=3DPcdValue, DefaultStore=3D{StoreName: PcdValue}) else: str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue = =3D PcdValue - str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.= update({StoreName:PcdValue}) + str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.= update( + {StoreName: PcdValue}) elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD= _FIXED_AT_BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE]]: + self._PCD_TYPE_STRING_[MODEL_PCD= _PATCHABLE_IN_MODULE]]: if skuname in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT,= TAB_COMMON): str_pcd_obj.DefaultValue =3D PcdValue else: - #Module Scope Structure Pcd - moduleguid =3D skuname.replace("S","-") + # Module Scope Structure Pcd + moduleguid =3D skuname.replace("S", "-") if GlobalData.gGuidPattern.match(moduleguid): for component in self.Modules.values(): if component.Guid =3D=3D moduleguid: - component.Pcds[(PcdName, PcdGuid)].Def= aultValue =3D PcdValue + component.Pcds[( + PcdName, PcdGuid)].DefaultValue = =3D PcdValue =20 else: if skuname not in str_pcd_obj.SkuInfoList: @@ -1635,25 +1776,32 @@ class DscBuildData(PlatformBuildClassObject): NoDefault =3D True break nextskuid =3D self.SkuIdMgr.GetNextSkuId(nexts= kuid) - str_pcd_obj.SkuInfoList[skuname] =3D copy.deepcopy= (str_pcd_obj.SkuInfoList[nextskuid]) if not NoDefault else SkuInfoClass(Sku= IdName=3Dskuname, SkuId=3Dself.SkuIds[skuname][0], DefaultValue=3DPcdValue) + str_pcd_obj.SkuInfoList[skuname] =3D copy.deepcopy= (str_pcd_obj.SkuInfoList[nextskuid]) if not NoDefault else SkuInfoClass( + SkuIdName=3Dskuname, SkuId=3Dself.SkuIds[skuna= me][0], DefaultValue=3DPcdValue) str_pcd_obj.SkuInfoList[skuname].SkuId =3D self.Sk= uIds[skuname][0] str_pcd_obj.SkuInfoList[skuname].SkuIdName =3D sku= name else: str_pcd_obj.SkuInfoList[skuname].DefaultValue =3D = PcdValue for str_pcd_obj in S_pcd_set.values(): if str_pcd_obj.Type not in [self._PCD_TYPE_STRING_[MODEL_P= CD_DYNAMIC_HII], - self._PCD_TYPE_STRING_[MODEL_PCD_D= YNAMIC_EX_HII]]: + self._PCD_TYPE_STRING_[MODEL_P= CD_DYNAMIC_EX_HII]]: continue - PcdDefaultStoreSet =3D set(defaultstorename for skuobj in = str_pcd_obj.SkuInfoList.values() for defaultstorename in skuobj.DefaultStor= eDict) + PcdDefaultStoreSet =3D set(defaultstorename for skuobj in = str_pcd_obj.SkuInfoList.values( + ) for defaultstorename in skuobj.DefaultStoreDict) DefaultStoreObj =3D DefaultStore(self._GetDefaultStores()) - mindefaultstorename =3D DefaultStoreObj.GetMin(PcdDefaultS= toreSet) - str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefa= ultValue =3D str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].DefaultStor= eDict[mindefaultstorename] + mindefaultstorename =3D DefaultStoreObj.GetMin( + PcdDefaultStoreSet) + str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefa= ultValue =3D str_pcd_obj.SkuInfoList[ + self.SkuIdMgr.SystemSkuId].DefaultStoreDict[mindefault= storename] =20 for str_pcd_obj in S_pcd_set.values(): =20 - str_pcd_obj.MaxDatumSize =3D DscBuildData.GetStructurePcdM= axSize(str_pcd_obj) - Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCNa= me] =3D str_pcd_obj - Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCNa= me].CustomAttribute['IsStru']=3DTrue + str_pcd_obj.MaxDatumSize =3D DscBuildData.GetStructurePcdM= axSize( + str_pcd_obj) + Pcds[str_pcd_obj.TokenCName, + str_pcd_obj.TokenSpaceGuidCName] =3D str_pcd_obj + Pcds[str_pcd_obj.TokenCName, + str_pcd_obj.TokenSpaceGuidCName].CustomAttribute['IsS= tru'] =3D True =20 for pcdkey in Pcds: pcd =3D Pcds[pcdkey] @@ -1663,31 +1811,36 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.= SkuInfoList: del pcd.SkuInfoList[TAB_COMMON] =20 - list(map(self.FilterSkuSettings, [Pcds[pcdkey] for pcdkey in Pcds = if Pcds[pcdkey].Type in DynamicPcdType])) + list(map(self.FilterSkuSettings, [ + Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in Dynam= icPcdType])) return Pcds + @cached_property def PlatformUsedPcds(self): FdfInfList =3D [] if GlobalData.gFdfParser: FdfInfList =3D GlobalData.gFdfParser.Profile.InfList - FdfModuleList =3D [PathClass(NormPath(Inf), GlobalData.gWorkspace,= Arch=3Dself._Arch) for Inf in FdfInfList] + FdfModuleList =3D [PathClass( + NormPath(Inf), GlobalData.gWorkspace, Arch=3Dself._Arch) for I= nf in FdfInfList] AllModulePcds =3D set() ModuleSet =3D set(list(self._Modules.keys()) + FdfModuleList) for ModuleFile in ModuleSet: - ModuleData =3D self._Bdb[ModuleFile, self._Arch, self._Target,= self._Toolchain] + ModuleData =3D self._Bdb[ModuleFile, + self._Arch, self._Target, self._Toolcha= in] AllModulePcds =3D AllModulePcds | ModuleData.PcdsName for ModuleFile in self.LibraryInstances: - ModuleData =3D self._Bdb.CreateBuildObject(ModuleFile, self._A= rch, self._Target, self._Toolchain) + ModuleData =3D self._Bdb.CreateBuildObject( + ModuleFile, self._Arch, self._Target, self._Toolchain) AllModulePcds =3D AllModulePcds | ModuleData.PcdsName return AllModulePcds =20 - #Filter the StrucutrePcd that is not used by any module in dsc file an= d fdf file. + # Filter the StrucutrePcd that is not used by any module in dsc file a= nd fdf file. def FilterStrcturePcd(self, S_pcd_set): UnusedStruPcds =3D set(S_pcd_set.keys()) - self.PlatformUsedPcds for (Token, TokenSpaceGuid) in UnusedStruPcds: del S_pcd_set[(Token, TokenSpaceGuid)] =20 - ## Retrieve non-dynamic PCD settings + # Retrieve non-dynamic PCD settings # # @param Type PCD type # @@ -1711,7 +1864,7 @@ class DscBuildData(PlatformBuildClassObject): SkuName =3D TAB_DEFAULT if SkuName =3D=3D TAB_COMMON else SkuN= ame if SkuName not in AvailableSkuIdSet: EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is no= t defined in [SkuIds] section' % SkuName, - File=3Dself.MetaFile, Line=3DD= ummy5) + File=3Dself.MetaFile, Line=3DDummy5) if SkuName in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT, TAB_COM= MON): if "." not in TokenSpaceGuid and "[" not in PcdCName and (= PcdCName, TokenSpaceGuid, SkuName, Dummy5) not in PcdList: PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dum= my5)) @@ -1721,7 +1874,8 @@ class DscBuildData(PlatformBuildClassObject): Setting =3D PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuN= ame] if Setting is None: continue - PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd(PcdCNa= me, TokenSpaceGuid, Setting, Type, Dummy4) + PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd( + PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) if MaxDatumSize: if int(MaxDatumSize, 0) > 0xFFFF: EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), @@ -1730,47 +1884,51 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), File=3Dself.MetaFile, Line=3DDummy4) if (PcdCName, TokenSpaceGuid) in PcdValueDict: - PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] =3D (PcdVa= lue, DatumType, MaxDatumSize,Dummy4) + PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] =3D ( + PcdValue, DatumType, MaxDatumSize, Dummy4) else: - PcdValueDict[PcdCName, TokenSpaceGuid] =3D {SkuName:(PcdVa= lue, DatumType, MaxDatumSize,Dummy4)} + PcdValueDict[PcdCName, TokenSpaceGuid] =3D { + SkuName: (PcdValue, DatumType, MaxDatumSize, Dummy4)} =20 for ((PcdCName, TokenSpaceGuid), PcdSetting) in PcdValueDict.items= (): if self.SkuIdMgr.SystemSkuId in PcdSetting: - PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[self.Sk= uIdMgr.SystemSkuId] + PcdValue, DatumType, MaxDatumSize, _ =3D PcdSetting[self.S= kuIdMgr.SystemSkuId] elif TAB_DEFAULT in PcdSetting: - PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[TAB_DE= FAULT] + PcdValue, DatumType, MaxDatumSize, _ =3D PcdSetting[TAB_DE= FAULT] elif TAB_COMMON in PcdSetting: - PcdValue, DatumType, MaxDatumSize,_ =3D PcdSetting[TAB_CO= MMON] + PcdValue, DatumType, MaxDatumSize, _ =3D PcdSetting[TAB_CO= MMON] else: PcdValue =3D None DatumType =3D None MaxDatumSize =3D None =20 Pcds[PcdCName, TokenSpaceGuid] =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - self._PCD_TYPE_STRING_[Typ= e], - DatumType, - PcdValue, - '', - MaxDatumSize, - {}, - False, - None, - IsDsc=3DTrue) + PcdCName, + TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type], + DatumType, + PcdValue, + '', + MaxDatumSize, + {}, + False, + None, + IsDsc=3DTrue) for SkuName in PcdValueDict[PcdCName, TokenSpaceGuid]: Settings =3D PcdValueDict[PcdCName, TokenSpaceGuid][SkuNam= e] if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawVal= ue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] = =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName= ] =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DE= FAULT_STORES_DEFAULT] =3D Settings[0] - Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TA= B_DEFAULT_STORES_DEFAULT] =3D (self.MetaFile.File,Settings[3]) + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TA= B_DEFAULT_STORES_DEFAULT] =3D ( + self.MetaFile.File, Settings[3]) return Pcds =20 @staticmethod def GetStructurePcdMaxSize(str_pcd): pcd_default_value =3D str_pcd.DefaultValue - sku_values =3D [skuobj.HiiDefaultValue if str_pcd.Type in [DscBuil= dData._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], DscBuildData._PCD_TYPE_STRI= NG_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue for skuobj in str_p= cd.SkuInfoList.values()] + sku_values =3D [skuobj.HiiDefaultValue if str_pcd.Type in [DscBuil= dData._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], + DscBuildD= ata._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue f= or skuobj in str_pcd.SkuInfoList.values()] sku_values.append(pcd_default_value) =20 def get_length(value): @@ -1788,7 +1946,7 @@ class DscBuildData(PlatformBuildClassObject): if (Value[0] =3D=3D '{' and Value[-1] =3D=3D '}'): return len(Value.split(",")) if Value.startswith("L'") and Value.endswith("'") and len(= list(Value[2:-1])) > 1: - return len(list(Value[2:-1])) + return len(list(Value[2:-1])) if Value[0] =3D=3D "'" and Value[-1] =3D=3D "'" and len(li= st(Value[1:-1])) > 1: return len(Value) - 2 return len(Value) @@ -1796,18 +1954,20 @@ class DscBuildData(PlatformBuildClassObject): return str(max(get_length(item) for item in sku_values)) =20 @staticmethod - def ExecuteCommand (Command): + def ExecuteCommand(Command): try: - Process =3D subprocess.Popen(Command, stdout=3Dsubprocess.PIPE= , stderr=3Dsubprocess.PIPE, shell=3DTrue) + Process =3D subprocess.Popen( + Command, stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.PIP= E, shell=3DTrue) except: - EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute com= mand: %s' % Command) + EdkLogger.error('Build', COMMAND_FAILURE, + 'Can not execute command: %s' % Command) Result =3D Process.communicate() return Process.returncode, Result[0].decode(errors=3D'ignore'), Re= sult[1].decode(errors=3D'ignore') =20 @staticmethod def IntToCString(Value, ValueSize): Result =3D '"' - if not isinstance (Value, str): + if not isinstance(Value, str): for Index in range(0, ValueSize): Result =3D Result + '\\x%02x' % (Value & 0xff) Value =3D Value >> 8 @@ -1816,38 +1976,51 @@ class DscBuildData(PlatformBuildClassObject): =20 def GenerateSizeFunction(self, Pcd): CApp =3D "// Default Value in Dec \n" - CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.Toke= nSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + \ + "void Cal_%s_%s_Size(UINT32 *Size){\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) =20 if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": - CApp +=3D " *Size =3D (sizeof (%s) > *Size ? sizeof (%s) : *S= ize);\n" % (Pcd.DatumType,Pcd.DatumType) + CApp +=3D " *Size =3D (sizeof (%s) > *Size ? sizeof (%s) : *S= ize);\n" % ( + Pcd.DatumType, Pcd.DatumType) else: if "{CODE(" in Pcd.DefaultValueFromDec: - CApp +=3D " *Size =3D (sizeof (%s_%s_INIT_Value) > *Size = ? sizeof (%s_%s_INIT_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCName,Pcd.Tok= enCName,Pcd.TokenSpaceGuidCName,Pcd.TokenCName) + CApp +=3D " *Size =3D (sizeof (%s_%s_INIT_Value) > *Size = ? sizeof (%s_%s_INIT_Value) : *Size);\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.TokenSpac= eGuidCName, Pcd.TokenCName) if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_EX_TYPE_SET: for skuname in Pcd.SkuInfoList: skuobj =3D Pcd.SkuInfoList[skuname] if skuobj.VariableName: for defaultstore in skuobj.DefaultStoreDict: - pcddef =3D self.GetPcdDscRawDefaultValue(Pcd,s= kuname,defaultstore) + pcddef =3D self.GetPcdDscRawDefaultValue( + Pcd, skuname, defaultstore) if pcddef: if "{CODE(" in pcddef: - CApp +=3D " *Size =3D (sizeof (%s_%s_= %s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.Token= SpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Pcd.TokenSpaceGuidCName,= Pcd.TokenCName,skuname,defaultstore) + CApp +=3D " *Size =3D (sizeof (%s_%s_= %s_%s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.Token= CName, skuname, defaultstore, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, skun= ame, defaultstore) else: - CApp +=3D " *Size =3D %s > *Size ? %s= : *Size;\n" % (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSiz= e(Pcd)) + CApp +=3D " *Size =3D %s > *Size ? %s= : *Size;\n" % ( + self.GetStructurePcdMaxSize(Pcd), = self.GetStructurePcdMaxSize(Pcd)) else: - pcddef =3D self.GetPcdDscRawDefaultValue(Pcd,skuna= me,TAB_DEFAULT_STORES_DEFAULT) + pcddef =3D self.GetPcdDscRawDefaultValue( + Pcd, skuname, TAB_DEFAULT_STORES_DEFAULT) if pcddef: - if "{CODE(" in pcddef: - CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%= s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpac= eGuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT,Pcd.TokenSpace= GuidCName,Pcd.TokenCName,skuname,TAB_DEFAULT_STORES_DEFAULT) + if "{CODE(" in pcddef: + CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%= s_Value) > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpac= eGuidCName, + = Pcd.TokenCName, s= kuname, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName= , skuname, TAB_DEFAULT_STORES_DEFAULT) else: - CApp +=3D " *Size =3D %s > *Size ? %s : *= Size;\n" % (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSize(Pc= d)) + CApp +=3D " *Size =3D %s > *Size ? %s : *= Size;\n" % ( + self.GetStructurePcdMaxSize(Pcd), self= .GetStructurePcdMaxSize(Pcd)) else: - pcddef =3D self.GetPcdDscRawDefaultValue(Pcd,TAB_DEFAULT,T= AB_DEFAULT_STORES_DEFAULT) + pcddef =3D self.GetPcdDscRawDefaultValue( + Pcd, TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) if pcddef: if "{CODE(" in pcddef: - CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Value)= > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCNa= me,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT,Pcd.TokenSpaceGuid= CName,Pcd.TokenCName,TAB_DEFAULT,TAB_DEFAULT_STORES_DEFAULT) + CApp +=3D " *Size =3D (sizeof (%s_%s_%s_%s_Value)= > *Size ? sizeof (%s_%s_%s_%s_Value) : *Size);\n" % (Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName, + = TAB_DEFAULT, TAB_DEFAULT_= STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, TAB_DEFAULT, TAB_D= EFAULT_STORES_DEFAULT) else: - CApp +=3D " *Size =3D %s > *Size ? %s : *Size;\n"= % (self.GetStructurePcdMaxSize(Pcd),self.GetStructurePcdMaxSize(Pcd)) + CApp +=3D " *Size =3D %s > *Size ? %s : *Size;\n"= % ( + self.GetStructurePcdMaxSize(Pcd), self.GetStru= cturePcdMaxSize(Pcd)) ActualCap =3D [] for index in Pcd.DefaultValues: if index: @@ -1857,33 +2030,41 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: FieldName =3D "." + FieldName - IsArray =3D _IsFieldValueAnArray(FieldList[FieldName.strip= (".")][0]) + IsArray =3D _IsFieldValueAnArray( + FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].sta= rtswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value =3D ValueExpressionEx(FieldList[FieldName.st= rip(".")][0], TAB_VOID, self._GuidDict)(True) + Value =3D ValueExpressionEx( + FieldList[FieldName.strip(".")][0], TAB_VOID, = self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1= ], FieldList[FieldName.strip(".")][2])) Value, ValueSize =3D ParseFieldValue(Value) if not Pcd.IsArray(): - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, = %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ?= 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.stri= p("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.Datu= mType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[= FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, = %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ?= 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.stri= p( + "."), ValueSize, Pcd.DatumType, FieldName.stri= p("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName= .strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.st= rip(".")][0]) else: NewFieldName =3D '' FieldName_ori =3D FieldName.strip('.') - while '[' in FieldName: - NewFieldName =3D NewFieldName + FieldName.split('[= ', 1)[0] + '[0]' - Array_Index =3D int(FieldName.split('[', 1)[1].spl= it(']', 1)[0]) + while '[' in FieldName: + NewFieldName =3D NewFieldName + \ + FieldName.split('[', 1)[0] + '[0]' + Array_Index =3D int(FieldName.split( + '[', 1)[1].split(']', 1)[0]) FieldName =3D FieldName.split(']', 1)[1] FieldName =3D NewFieldName + FieldName while '[' in FieldName and not Pcd.IsArray(): FieldName =3D FieldName.rsplit('[', 1)[0] - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, = %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."),= Array_Index + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2],= FieldList[FieldName_ori][0]) + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, = %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip( + "."), Array_Index + 1, FieldList[FieldName_ori= ][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) flexisbale_size_statement_cache =3D set() for skuname in Pcd.SkuOverrideValues: if skuname =3D=3D TAB_COMMON: continue for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]: - CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \n"= % (skuname, defaultstorenameitem) + CApp =3D CApp + \ + "// SkuName: %s, DefaultStoreName: %s \n" % ( + skuname, defaultstorenameitem) for index in Pcd.SkuOverrideValues[skuname][defaultstorena= meitem]: if index: ActualCap.append(index) @@ -1896,85 +2077,107 @@ class DscBuildData(PlatformBuildClassObject): continue flexisbale_size_statement_cache.add(fieldinfo) FieldName =3D "." + FieldName - IsArray =3D _IsFieldValueAnArray(FieldList[Fie= ldName.strip(".")][0]) + IsArray =3D _IsFieldValueAnArray( + FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(= ".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswit= h('}')): try: - Value =3D ValueExpressionEx(FieldList[= FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) + Value =3D ValueExpressionEx( + FieldList[FieldName.strip(".")][0]= , TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALI= D, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSp= aceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.s= trip(".")][1], FieldList[FieldName.strip(".")][2])) Value, ValueSize =3D ParseFieldValue(Value) if not Pcd.IsArray(): - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZ= E(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, Fiel= dName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize= , Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], = FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]); + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZ= E(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, Fiel= dName.strip( + "."), ValueSize, Pcd.DatumType, Fi= eldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldLi= st[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[= FieldName.strip(".")][0]) else: NewFieldName =3D '' FieldName_ori =3D FieldName.strip('.') - while '[' in FieldName: - NewFieldName =3D NewFieldName + FieldN= ame.split('[', 1)[0] + '[0]' - Array_Index =3D int(FieldName.split('[= ', 1)[1].split(']', 1)[0]) + while '[' in FieldName: + NewFieldName =3D NewFieldName + \ + FieldName.split('[', 1)[0] + '[0]' + Array_Index =3D int(FieldName.split( + '[', 1)[1].split(']', 1)[0]) FieldName =3D FieldName.split(']', 1)[= 1] FieldName =3D NewFieldName + FieldName while '[' in FieldName and not Pcd.IsArray= (): FieldName =3D FieldName.rsplit('[', 1)= [0] - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldNam= e.strip("."), Array_Index + 1, FieldList[FieldName_ori][1], FieldList[Field= Name_ori][2], FieldList[FieldName_ori][0]) + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Si= ze, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldNam= e.strip( + "."), Array_Index + 1, FieldList[F= ieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0]) if Pcd.PcdFieldValueFromFdf: CApp =3D CApp + "// From fdf \n" for FieldName in Pcd.PcdFieldValueFromFdf: FieldName =3D "." + FieldName - IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[Fiel= dName.strip(".")][0]) + IsArray =3D _IsFieldValueAnArray( + Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromFdf[FieldName.strip("= .")][0].startswith('{GUID') and Pcd.PcdFieldValueFromFdf[FieldName.strip(".= ")][0].endswith('}')): try: - Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromFdf[F= ieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) + Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromFdf[F= ieldName.strip( + ".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromFdf[FieldName.st= rip(".")][1], Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][2])) Value, ValueSize =3D ParseFieldValue(Value) if not Pcd.IsArray(): - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d /= __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 := 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip(".")= , ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType,= FieldName.strip("."), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], P= cd.PcdFieldValueFromFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[= FieldName.strip(".")][0]); + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d /= __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 := 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip(".")= , ValueSize, Pcd.DatumType, FieldName.strip( + "."), ValueSize, Pcd.DatumType, FieldName.strip(".= "), Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][1], Pcd.PcdFieldValueFro= mFdf[FieldName.strip(".")][2], Pcd.PcdFieldValueFromFdf[FieldName.strip("."= )][0]) else: NewFieldName =3D '' FieldName_ori =3D FieldName.strip('.') - while '[' in FieldName: - NewFieldName =3D NewFieldName + FieldName.split('[', 1= )[0] + '[0]' - Array_Index =3D int(FieldName.split('[', 1)[1].split('= ]', 1)[0]) + while '[' in FieldName: + NewFieldName =3D NewFieldName + \ + FieldName.split('[', 1)[0] + '[0]' + Array_Index =3D int(FieldName.split( + '[', 1)[1].split(']', 1)[0]) FieldName =3D FieldName.split(']', 1)[1] FieldName =3D NewFieldName + FieldName while '[' in FieldName: FieldName =3D FieldName.rsplit('[', 1)[0] - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %s Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Ar= ray_Index + 1, Pcd.PcdFieldValueFromFdf[FieldName_ori][1], Pcd.PcdFieldValu= eFromFdf[FieldName_ori][2], Pcd.PcdFieldValueFromFdf[FieldName_ori][0]) + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %s Value %s \n' % (Pcd.DatumType, FieldName.strip( + "."), Array_Index + 1, Pcd.PcdFieldValueFromFdf[Fi= eldName_ori][1], Pcd.PcdFieldValueFromFdf[FieldName_ori][2], Pcd.PcdFieldVa= lueFromFdf[FieldName_ori][0]) if Pcd.PcdFieldValueFromComm: CApp =3D CApp + "// From Command Line \n" for FieldName in Pcd.PcdFieldValueFromComm: FieldName =3D "." + FieldName - IsArray =3D _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[Fie= ldName.strip(".")][0]) + IsArray =3D _IsFieldValueAnArray( + Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(= ".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(= ".")][0].endswith('}')): try: - Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromComm[= FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) + Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromComm[= FieldName.strip( + ".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.s= trip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) Value, ValueSize =3D ParseFieldValue(Value) if not Pcd.IsArray(): - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d /= __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 := 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip(".")= , ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType,= FieldName.strip("."), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], = Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromCo= mm[FieldName.strip(".")][0]); + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d /= __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 := 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip(".")= , ValueSize, Pcd.DatumType, FieldName.strip( + "."), ValueSize, Pcd.DatumType, FieldName.strip(".= "), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFr= omComm[FieldName.strip(".")][2], Pcd.PcdFieldValueFromComm[FieldName.strip(= ".")][0]) else: NewFieldName =3D '' FieldName_ori =3D FieldName.strip('.') - while '[' in FieldName: - NewFieldName =3D NewFieldName + FieldName.split('[', 1= )[0] + '[0]' - Array_Index =3D int(FieldName.split('[', 1)[1].split('= ]', 1)[0]) + while '[' in FieldName: + NewFieldName =3D NewFieldName + \ + FieldName.split('[', 1)[0] + '[0]' + Array_Index =3D int(FieldName.split( + '[', 1)[1].split(']', 1)[0]) FieldName =3D FieldName.split(']', 1)[1] FieldName =3D NewFieldName + FieldName while '[' in FieldName and not Pcd.IsArray(): FieldName =3D FieldName.rsplit('[', 1)[0] - CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Ar= ray_Index + 1, Pcd.PcdFieldValueFromComm[FieldName_ori][1], Pcd.PcdFieldVal= ueFromComm[FieldName_ori][2], Pcd.PcdFieldValueFromComm[FieldName_ori][0]) + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip( + "."), Array_Index + 1, Pcd.PcdFieldValueFromComm[F= ieldName_ori][1], Pcd.PcdFieldValueFromComm[FieldName_ori][2], Pcd.PcdField= ValueFromComm[FieldName_ori][0]) if Pcd.GetPcdMaxSize(): - CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // The= Pcd maxsize is %d \n" % (Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.Get= PcdMaxSize()) + CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // The= Pcd maxsize is %d \n" % ( + Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSize(), Pcd.GetPcdMaxSiz= e()) ArraySizeByAssign =3D self.CalculateActualCap(ActualCap) if ArraySizeByAssign > 1: - CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); \n" % = (ArraySizeByAssign, ArraySizeByAssign) + CApp =3D CApp + \ + " *Size =3D (%d > *Size ? %d : *Size); \n" % (ArraySizeBy= Assign, + ArraySizeByAs= sign) CApp =3D CApp + "}\n" return CApp - def CalculateActualCap(self,ActualCap): + + def CalculateActualCap(self, ActualCap): if not ActualCap: return 1 maxsize =3D 1 @@ -1986,22 +2189,23 @@ class DscBuildData(PlatformBuildClassObject): if not index_num: # Not support flexiable pcd array assignment return 1 - index_num =3D int(index_num,16) if index_num.startswith(("= 0x","0X")) else int(index_num) + index_num =3D int(index_num, 16) if index_num.startswith( + ("0x", "0X")) else int(index_num) rt =3D rt * (index_num+1) - if rt >maxsize: + if rt > maxsize: maxsize =3D rt =20 return maxsize =20 @staticmethod - def GenerateSizeStatments(Pcd,skuname,defaultstorename): + def GenerateSizeStatments(Pcd, skuname, defaultstorename): if Pcd.IsArray(): r_datatype =3D [Pcd.BaseDatumType] lastoneisEmpty =3D False for dem in Pcd.Capacity: if lastoneisEmpty: EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. " % - (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName)))) + (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName)))) if dem =3D=3D '0' or dem =3D=3D "-1": r_datatype.append("[1]") lastoneisEmpty =3D True @@ -2009,45 +2213,54 @@ class DscBuildData(PlatformBuildClassObject): r_datatype.append("[" + dem + "]") =20 if Pcd.Type in [MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_HI= I]: - PcdDefValue =3D Pcd.SkuInfoList.get(skuname).DefaultStoreD= ict.get(defaultstorename) - elif Pcd.Type in [MODEL_PCD_DYNAMIC_EX_DEFAULT,MODEL_PCD_DYNAM= IC_VPD,MODEL_PCD_DYNAMIC_DEFAULT,MODEL_PCD_DYNAMIC_EX_VPD]: + PcdDefValue =3D Pcd.SkuInfoList.get( + skuname).DefaultStoreDict.get(defaultstorename) + elif Pcd.Type in [MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNA= MIC_VPD, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_VPD]: PcdDefValue =3D Pcd.SkuInfoList.get(skuname).DefaultValue else: PcdDefValue =3D Pcd.DefaultValue if lastoneisEmpty: if "{CODE(" not in PcdDefValue: - sizebasevalue_plus =3D "(%s / sizeof(%s) + 1)" % ((Dsc= BuildData.GetStructurePcdMaxSize(Pcd), Pcd.BaseDatumType)) - sizebasevalue =3D "(%s / sizeof(%s))" % ((DscBuildData= .GetStructurePcdMaxSize(Pcd), Pcd.BaseDatumType)) + sizebasevalue_plus =3D "(%s / sizeof(%s) + 1)" % ( + (DscBuildData.GetStructurePcdMaxSize(Pcd), Pcd.Bas= eDatumType)) + sizebasevalue =3D "(%s / sizeof(%s))" % ( + (DscBuildData.GetStructurePcdMaxSize(Pcd), Pcd.Bas= eDatumType)) sizeof =3D "sizeof(%s)" % Pcd.BaseDatumType - CApp =3D ' int ArraySize =3D %s %% %s ? %s : %s ;\n' = % ( (DscBuildData.GetStructurePcdMaxSize(Pcd), sizeof, sizebasevalue_plus, = sizebasevalue)) + CApp =3D ' int ArraySize =3D %s %% %s ? %s : %s ;\n' = % ( + (DscBuildData.GetStructurePcdMaxSize(Pcd), sizeof,= sizebasevalue_plus, sizebasevalue)) CApp +=3D ' Size =3D ArraySize * sizeof(%s); \n' % Pc= d.BaseDatumType else: CApp =3D " Size =3D 0;\n" else: - CApp =3D ' Size =3D sizeof(%s);\n' % ("".join(r_datatype)= ) + CApp =3D ' Size =3D sizeof(%s);\n' % ("".join(r_datatype)) else: CApp =3D ' Size =3D sizeof(%s);\n' % (Pcd.DatumType) - CApp =3D CApp + ' Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuid= CName, Pcd.TokenCName) + CApp =3D CApp + \ + ' Cal_%s_%s_Size(&Size);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) return CApp =20 - def GetIndicator(self,index,FieldName,Pcd): + def GetIndicator(self, index, FieldName, Pcd): def cleanupindex(indexstr): return indexstr.strip("[").strip("]").strip() index_elements =3D ArrayIndex.findall(index) pcd_capacity =3D Pcd.Capacity if index: indicator =3D "(Pcd" - if len(pcd_capacity)>2: - for i in range(0,len(index_elements)): + if len(pcd_capacity) > 2: + for i in range(0, len(index_elements)): index_ele =3D index_elements[i] index_num =3D index_ele.strip("[").strip("]").strip() - if i =3D=3D len(index_elements) -2: - indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" %(i= nt(cleanupindex(index_elements[i+1])),Pcd.BaseDatumType,reduce(lambda x,y: = int(x)*int(y),pcd_capacity[:-1]), cleanupindex(index_elements[i])) + if i =3D=3D len(index_elements) - 2: + indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" % (= int(cleanupindex(index_elements[i+1])), Pcd.BaseDatumType, reduce( + lambda x, y: int(x)*int(y), pcd_capacity[:-1])= , cleanupindex(index_elements[i])) break else: - indicator +=3D " + %d*%s*Size/sizeof(%s)/%d" %(int= (cleanupindex(index_elements[i])),reduce(lambda x,y: int(x)*int(y),pcd_capa= city[i+1:-1]),Pcd.BaseDatumType,reduce(lambda x,y: int(x)*int(y),pcd_capaci= ty[:-1])) + indicator +=3D " + %d*%s*Size/sizeof(%s)/%d" % (in= t(cleanupindex(index_elements[i])), reduce(lambda x, y: int( + x)*int(y), pcd_capacity[i+1:-1]), Pcd.BaseDatu= mType, reduce(lambda x, y: int(x)*int(y), pcd_capacity[:-1])) elif len(pcd_capacity) =3D=3D 2: - indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" %(int(clean= upindex(index_elements[0])),Pcd.BaseDatumType,int(pcd_capacity[0]), index_e= lements[1].strip("[").strip("]").strip()) + indicator +=3D "+ %d*Size/sizeof(%s)/%d + %s)" % (int(clea= nupindex(index_elements[0])), Pcd.BaseDatumType, int( + pcd_capacity[0]), index_elements[1].strip("[").strip("= ]").strip()) elif len(pcd_capacity) =3D=3D 1: index_ele =3D index_elements[0] index_num =3D index_ele.strip("[").strip("]").strip() @@ -2058,16 +2271,18 @@ class DscBuildData(PlatformBuildClassObject): indicator +=3D "->" + FieldName return indicator =20 - def GetStarNum(self,Pcd): + def GetStarNum(self, Pcd): if not Pcd.IsArray(): return 1 elif Pcd.IsSimpleTypeArray(): return len(Pcd.Capacity) else: return len(Pcd.Capacity) + 1 + def GenerateDefaultValueAssignFunction(self, Pcd): CApp =3D "// Default value in Dec \n" - CApp =3D CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (P= cd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) + CApp =3D CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' CApp =3D CApp + ' UINT32 PcdArraySize;\n' @@ -2075,12 +2290,13 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D _IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: - DefaultValueFromDec =3D ValueExpressionEx(Pcd.DefaultValue= FromDec, TAB_VOID)(True) + DefaultValueFromDec =3D ValueExpressionEx( + Pcd.DefaultValueFromDec, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value fo= rmat for %s.%s, from DEC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, = DefaultValueFromDec)) DefaultValueFromDec =3D StringToArray(DefaultValueFromDec) - Value, ValueSize =3D ParseFieldValue (DefaultValueFromDec) + Value, ValueSize =3D ParseFieldValue(DefaultValueFromDec) if IsArray: # # Use memcpy() to copy value into field @@ -2089,24 +2305,34 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize() if "{CODE(" in Pcd.DefaultValueFromDec: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_INIT= _Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capabil= ity %s"); // From %s Line %s \n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName, Pcd.TokenCName,P= cd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.DefaultValueFromDecInfo[1]) - CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT_V= alue);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) - CApp =3D CApp + ' memcpy (Pcd, %s_%s_INIT_Value,PcdAr= raySize);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_INIT= _Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dec exceed the array capabil= ity %s"); // From %s Line %s \n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, pcdar= raysize, Pcd.BaseDatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.Da= tumType, Pcd.DefaultValueFromDecInfo[0], Pcd.DefaultValueFromDecInfo[1]) + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT_V= alue);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' memcpy (Pcd, %s_%s_INIT_Value,PcdAr= raySize);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) else: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(%d < %d * sizeof(= %s), "Pcd %s.%s Value in Dec exceed the array capability %s"); // From %s L= ine %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType,Pcd.DefaultValueFromDecInfo[0],Pcd.Defaul= tValueFromDecInfo[1]) + CApp =3D CApp + '__STATIC_ASSERT(%d < %d * sizeof(= %s), "Pcd %s.%s Value in Dec exceed the array capability %s"); // From %s L= ine %s \n' % ( + ValueSize, pcdarraysize, Pcd.BaseDatumType, Pc= d.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, Pcd.DefaultValueFromD= ecInfo[0], Pcd.DefaultValueFromDecInfo[1]) CApp =3D CApp + ' PcdArraySize =3D %d;\n' % ValueSize - CApp =3D CApp + ' Value =3D %s; // From DEC Defau= lt Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultV= alueFromDec) + CApp =3D CApp + ' Value =3D %s; // From DEC Defau= lt Value %s\n' % ( + DscBuildData.IntToCString(Value, ValueSize), Pcd.D= efaultValueFromDec) CApp =3D CApp + ' memcpy (Pcd, Value, PcdArraySize);\= n' else: if "{CODE(" in Pcd.DefaultValueFromDec: - CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT_= Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) - CApp =3D CApp + ' memcpy (Pcd, &%s_%s_INIT_Value,PcdA= rraySize);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_INIT_= Value);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_INIT_Value,PcdA= rraySize);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) else: - CApp =3D CApp + ' Value =3D %s; // From DEC Defau= lt Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.DefaultV= alueFromDec) + CApp =3D CApp + ' Value =3D %s; // From DEC Defau= lt Value %s\n' % ( + DscBuildData.IntToCString(Value, ValueSize), Pcd.D= efaultValueFromDec) CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) elif isinstance(Value, str): - CApp =3D CApp + ' Pcd =3D %s; // From DEC Default Value %s\n'= % (Value, Pcd.DefaultValueFromDec) + CApp =3D CApp + \ + ' Pcd =3D %s; // From DEC Default Value %s\n' % ( + Value, Pcd.DefaultValueFromDec) for index in Pcd.DefaultValues: FieldList =3D Pcd.DefaultValues[index] if not FieldList: @@ -2115,100 +2341,128 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx( + FieldList[FieldName][0], TAB_VOID, self._GuidD= ict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) =20 try: - Value, ValueSize =3D ParseFieldValue (FieldList[FieldN= ame][0]) + Value, ValueSize =3D ParseFieldValue(FieldList[FieldNa= me][0]) except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]= )) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldNam= e)), FieldList[FieldName][1], FieldList[FieldName][2])) =20 - indicator =3D self.GetIndicator(index, FieldName,Pcd) + indicator =3D self.GetIndicator(index, FieldName, Pcd) if IsArray: # # Use memcpy() to copy value into field # - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s);= \n' % (Pcd.BaseDatumType, FieldName) - CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList[Fie= ldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldNa= me, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], Field= List[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' memcpy (&%s, Value, (FieldSize > 0 = && FieldSize < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize) + CApp =3D CApp + \ + ' FieldSize =3D __FIELD_SIZE(%s, %s);\n' % ( + Pcd.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), FieldList[FieldName][1], FieldL= ist[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % ( + Pcd.BaseDatumType, FieldName, ValueSize, Pcd.BaseD= atumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], Fiel= dList[FieldName][0]) + CApp =3D CApp + ' memcpy (&%s, Value, (FieldSize > 0 = && FieldSize < %d) ? FieldSize : %d);\n' % ( + indicator, ValueSize, ValueSize) elif isinstance(Value, str): - CApp =3D CApp + ' %s =3D %s; // From %s Line %d Value= %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2= ], FieldList[FieldName][0]) + CApp =3D CApp + ' %s =3D %s; // From %s Line %d Value= %s\n' % ( + indicator, Value, FieldList[FieldName][1], FieldLi= st[FieldName][2], FieldList[FieldName][0]) else: if '[' in FieldName and ']' in FieldName: Index =3D int(FieldName.split('[')[1].split(']')[0= ]) - CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.spli= t('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[Fiel= dName][2], FieldName) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % ( + Index, FieldName.split('[')[0], FieldName.spli= t('[')[0], FieldList[FieldName][1], FieldList[FieldName][2], FieldName) if ValueSize > 4: - CApp =3D CApp + ' %s =3D %dULL; // From %s Line %= d Value %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[Field= Name][2], FieldList[FieldName][0]) + CApp =3D CApp + ' %s =3D %dULL; // From %s Line %= d Value %s\n' % ( + indicator, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) else: - CApp =3D CApp + ' %s =3D %d; // From %s Line %d V= alue %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[FieldNam= e][2], FieldList[FieldName][0]) + CApp =3D CApp + ' %s =3D %d; // From %s Line %d V= alue %s\n' % ( + indicator, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 @staticmethod def GenerateDefaultValueAssignStatement(Pcd): - CApp =3D ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd.TokenSpaceG= uidCName, Pcd.TokenCName) + CApp =3D ' Assign_%s_%s_Default_Value(Pcd);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) return CApp =20 - def GetPcdDscRawDefaultValue(self,Pcd, SkuName,DefaultStoreName): + def GetPcdDscRawDefaultValue(self, Pcd, SkuName, DefaultStoreName): if Pcd.Type in PCD_DYNAMIC_TYPE_SET or Pcd.Type in PCD_DYNAMIC_EX_= TYPE_SET: if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFAUL= T_STORES_DEFAULT): - pcddefaultvalue =3D Pcd.DefaultFromDSC.get(TAB_DEFAULT, {}= ).get(TAB_DEFAULT_STORES_DEFAULT) if Pcd.DefaultFromDSC else None + pcddefaultvalue =3D Pcd.DefaultFromDSC.get(TAB_DEFAULT, {}= ).get( + TAB_DEFAULT_STORES_DEFAULT) if Pcd.DefaultFromDSC else= None else: - pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, {}).get(D= efaultStoreName) + pcddefaultvalue =3D Pcd.DscRawValue.get( + SkuName, {}).get(DefaultStoreName) else: - pcddefaultvalue =3D Pcd.DscRawValue.get(SkuName, {}).get(TAB_D= EFAULT_STORES_DEFAULT) + pcddefaultvalue =3D Pcd.DscRawValue.get( + SkuName, {}).get(TAB_DEFAULT_STORES_DEFAULT) =20 return pcddefaultvalue - def GetPcdDscRawValueInfo(self,Pcd, SkuName,DefaultStoreName): - DscValueInfo =3D Pcd.DscRawValueInfo.get(SkuName, {}).get(DefaultS= toreName) + + def GetPcdDscRawValueInfo(self, Pcd, SkuName, DefaultStoreName): + DscValueInfo =3D Pcd.DscRawValueInfo.get( + SkuName, {}).get(DefaultStoreName) if DscValueInfo: - dscfilepath,lineno =3D DscValueInfo + dscfilepath, lineno =3D DscValueInfo else: dscfilepath =3D self.MetaFile.File lineno =3D "" - return dscfilepath,lineno + return dscfilepath, lineno =20 def GenerateInitValueFunction(self, Pcd, SkuName, DefaultStoreName): - CApp =3D "// Value in Dsc for Sku: %s, DefaultStore %s\n" % (SkuNa= me, DefaultStoreName) - CApp =3D CApp + "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % (Pcd= .TokenSpaceGuidCName, Pcd.TokenCName, SkuName, DefaultStoreName, Pcd.BaseDa= tumType) + CApp =3D "// Value in Dsc for Sku: %s, DefaultStore %s\n" % ( + SkuName, DefaultStoreName) + CApp =3D CApp + "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuName, DefaultStore= Name, Pcd.BaseDatumType) CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' CApp =3D CApp + ' UINT32 PcdArraySize;\n' =20 - CApp =3D CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_= DEFAULT, TAB_DEFAULT_STORES_DEFAULT) + CApp =3D CApp + \ + "// SkuName: %s, DefaultStoreName: %s \n" % ( + TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) inherit_OverrideValues =3D Pcd.SkuOverrideValues[SkuName] - dscfilepath,lineno =3D self.GetPcdDscRawValueInfo(Pcd, SkuName, De= faultStoreName) + dscfilepath, lineno =3D self.GetPcdDscRawValueInfo( + Pcd, SkuName, DefaultStoreName) if lineno: - valuefrom =3D "%s Line %s" % (dscfilepath,str(lineno)) + valuefrom =3D "%s Line %s" % (dscfilepath, str(lineno)) else: valuefrom =3D dscfilepath =20 - pcddefaultvalue =3D self.GetPcdDscRawDefaultValue(Pcd, SkuName, De= faultStoreName) + pcddefaultvalue =3D self.GetPcdDscRawDefaultValue( + Pcd, SkuName, DefaultStoreName) if pcddefaultvalue: FieldList =3D pcddefaultvalue IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: if "{CODE(" not in FieldList: try: - FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) + FieldList =3D ValueExpressionEx( + FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from DSC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) - Value, ValueSize =3D ParseFieldValue (FieldList) + Value, ValueSize =3D ParseFieldValue(FieldList) =20 if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFAUL= T_STORES_DEFAULT): if isinstance(Value, str): if "{CODE(" in Value: if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": pcdarraysize =3D Pcd.PcdArraySize() - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Sk= uName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType, valuefrom) - CApp =3D CApp+ ' PcdArraySize =3D sizeof(%s_%s_%s_= %s_Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultS= toreName) - CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= ,PcdArraySize);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName) + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName, pcdarraysize, Pcd.BaseDatumType, Pcd.TokenSpaceGu= idCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_%s= _%s_Value);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuNa= me, DefaultStoreName) + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= ,PcdArraySize);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuNa= me, DefaultStoreName) else: - CApp =3D CApp + ' Pcd =3D %s; // From DSC Default= Value %s\n' % (Value, Pcd.DefaultFromDSC.get(TAB_DEFAULT, {}).get(TAB_DEFA= ULT_STORES_DEFAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.Defaul= tValue) + CApp =3D CApp + ' Pcd =3D %s; // From DSC Default= Value %s\n' % (Value, Pcd.DefaultFromDSC.get( + TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAUL= T, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) elif IsArray: # # Use memcpy() to copy value into field @@ -2217,32 +2471,46 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize() if "{CODE(" in pcddefaultvalue: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceG= uidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom) - CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%= s_%s_%s_Value);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName) - CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, = DefaultStoreName) + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e, SkuName, DefaultStoreName, pcdarraysize, Pcd.BaseDatumType, Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%= s_%s_%s_Value);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) else: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName,Pcd.DatumType,valuefrom) + CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % ( + ValueSize, pcdarraysize, Pcd.BaseDatum= Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) CApp =3D CApp + ' PcdArraySize =3D %d;\n' % Va= lueSize - CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DefaultFromDSC.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.Def= aultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) - CApp =3D CApp + ' memcpy (Pcd, Value, PcdArra= ySize);\n' + CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DefaultFromDSC.get( + TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DE= FAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp =3D CApp + \ + ' memcpy (Pcd, Value, PcdArraySize);\n' else: if "{CODE(" in pcddefaultvalue: - CApp =3D CApp + ' PcdArraySize =3D %d < sizeo= f(%s) * %d ? %d: sizeof(%s) * %d;\n ' % (ValueSize,Pcd.BaseDatumType,pcdarr= aysize,ValueSize,Pcd.BaseDatumType,pcdarraysize) - CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_V= alue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName,= DefaultStoreName) + CApp =3D CApp + ' PcdArraySize =3D %d < sizeo= f(%s) * %d ? %d: sizeof(%s) * %d;\n ' % ( + ValueSize, Pcd.BaseDatumType, pcdarraysize= , ValueSize, Pcd.BaseDatumType, pcdarraysize) + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_V= alue, PcdArraySize);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) else: - CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DefaultFromDSC.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.Def= aultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) - CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n'= % (ValueSize) + CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DefaultFromDSC.get( + TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DE= FAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp =3D CApp + \ + ' memcpy (Pcd, Value, %d);\n' % (ValueSiz= e) else: if isinstance(Value, str): if "{CODE(" in Value: if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": pcdarraysize =3D Pcd.PcdArraySize() - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Sk= uName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName,Pcd.DatumType,valuefrom) - CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_%s= _%s_Value);\n '% (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultS= toreName) - CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= , PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, Def= aultStoreName) + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s_%s_= %s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array ca= pability %s"); // From %s \n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName, pcdarraysize, Pcd.BaseDatumType, Pcd.TokenSpaceGu= idCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) + CApp =3D CApp + ' PcdArraySize =3D sizeof(%s_%s_%s= _%s_Value);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuNa= me, DefaultStoreName) + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_Value= , PcdArraySize);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuNa= me, DefaultStoreName) else: - CApp =3D CApp + ' Pcd =3D %s; // From DSC Default= Value %s\n' % (Value, Pcd.DscRawValue.get(SkuName, {}).get(DefaultStoreNam= e)) + CApp =3D CApp + ' Pcd =3D %s; // From DSC Default= Value %s\n' % ( + Value, Pcd.DscRawValue.get(SkuName, {}).get(De= faultStoreName)) elif IsArray: # # Use memcpy() to copy value into field @@ -2251,22 +2519,32 @@ class DscBuildData(PlatformBuildClassObject): pcdarraysize =3D Pcd.PcdArraySize() if "{CODE(" in pcddefaultvalue: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me,SkuName, DefaultStoreName,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceG= uidCName, Pcd.TokenCName,Pcd.DatumType,valuefrom) - CApp + ' PcdArraySize =3D sizeof(%s_%s_%s_%s_V= alue);\n ' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, DefaultStore= Name) - CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName, = DefaultStoreName) + CApp =3D CApp + '__STATIC_ASSERT(sizeof(%s= _%s_%s_%s_Value) < %d * sizeof(%s), "Pcd %s.%s Value in Dsc exceed the arra= y capability %s"); // From %s \n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e, SkuName, DefaultStoreName, pcdarraysize, Pcd.BaseDatumType, Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) + CApp + ' PcdArraySize =3D sizeof(%s_%s_%s_%s_V= alue);\n ' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) + CApp =3D CApp + ' memcpy (Pcd, %s_%s_%s_%s_Va= lue, PcdArraySize);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) else: if Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % (ValueSize,pcdarraysize,Pcd.BaseDatumType,Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName,Pcd.DatumType,valuefrom) + CApp =3D CApp + '__STATIC_ASSERT(%d < %d *= sizeof(%s), "Pcd %s.%s Value in Dsc exceed the array capability %s"); // F= rom %s \n' % ( + ValueSize, pcdarraysize, Pcd.BaseDatum= Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, valuefrom) CApp =3D CApp + ' PcdArraySize =3D %d;\n' % Va= lueSize - CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DscRawValue.get(TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DEFAULT, Pcd.Defaul= tValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) - CApp =3D CApp + ' memcpy (Pcd, Value, PcdArra= ySize);\n' + CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DscRawValue.get( + TAB_DEFAULT, {}).get(TAB_DEFAULT_STORES_DE= FAULT, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue) + CApp =3D CApp + \ + ' memcpy (Pcd, Value, PcdArraySize);\n' else: if "{CODE(" in pcddefaultvalue: - CApp =3D CApp + ' PcdArraySize =3D %d < sizeo= f(%s) * %d ? %d: sizeof(%s) * %d;\n ' % (ValueSize,Pcd.BaseDatumType,pcdarr= aysize,ValueSize,Pcd.BaseDatumType,pcdarraysize) - CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_V= alue, PcdArraySize);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName,= DefaultStoreName) + CApp =3D CApp + ' PcdArraySize =3D %d < sizeo= f(%s) * %d ? %d: sizeof(%s) * %d;\n ' % ( + ValueSize, Pcd.BaseDatumType, pcdarraysize= , ValueSize, Pcd.BaseDatumType, pcdarraysize) + CApp =3D CApp + ' memcpy (Pcd, &%s_%s_%s_%s_V= alue, PcdArraySize);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, S= kuName, DefaultStoreName) else: - CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), Pcd.= DscRawValue.get(SkuName, {}).get(DefaultStoreName)) - CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n'= % (ValueSize) + CApp =3D CApp + ' Value =3D %s; // From D= SC Default Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), Pcd.DscRawValue.get(Sku= Name, {}).get(DefaultStoreName)) + CApp =3D CApp + \ + ' memcpy (Pcd, Value, %d);\n' % (ValueSiz= e) =20 inheritvalue =3D inherit_OverrideValues.get(DefaultStoreName) if not inheritvalue: @@ -2275,49 +2553,63 @@ class DscBuildData(PlatformBuildClassObject): FieldList =3D inheritvalue[index] if not FieldList: continue - if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFAUL= T_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName= , DefaultStoreName) not in Pcd.ValueChain )): + if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFAUL= T_STORES_DEFAULT) or (((SkuName, '') not in Pcd.ValueChain) and ((SkuName, = DefaultStoreName) not in Pcd.ValueChain)): for FieldName in FieldList: - indicator =3D self.GetIndicator(index, FieldName,Pcd) + indicator =3D self.GetIndicator(index, FieldName, Pcd) IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][= 0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx( + FieldList[FieldName][0], TAB_VOID, self._G= uidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[Field= Name][2])) try: - Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0]) + Value, ValueSize =3D ParseFieldValue( + FieldList[FieldName][0]) except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Fiel= dName)), FieldList[FieldName][1], FieldList[FieldName][2])) if isinstance(Value, str): - CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, = %s);\n' % (Pcd.BaseDatumType, FieldName) - CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList= [FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, Fie= ldName, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], F= ieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' memcpy (&%s, Value, (FieldSize = > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (indicator, ValueSize, Value= Size) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + \ + ' FieldSize =3D __FIELD_SIZE(%s, %s);\n' % ( + Pcd.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), FieldList[FieldName][1], Fi= eldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % ( + Pcd.BaseDatumType, FieldName, ValueSize, Pcd.B= aseDatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], = FieldList[FieldName][0]) + CApp =3D CApp + ' memcpy (&%s, Value, (FieldSize = > 0 && FieldSize < %d) ? FieldSize : %d);\n' % ( + indicator, ValueSize, ValueSize) else: if '[' in FieldName and ']' in FieldName: Index =3D int(FieldName.split('[')[1].split(']= ')[0]) - CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.= split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[= FieldName][2], FieldName) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % ( + Index, FieldName.split('[')[0], FieldName.= split('[')[0], FieldList[FieldName][1], FieldList[FieldName][2], FieldName) if ValueSize > 4: - CApp =3D CApp + ' %s =3D %dULL; // From %s Li= ne %d Value %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[F= ieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' %s =3D %dULL; // From %s Li= ne %d Value %s\n' % ( + indicator, Value, FieldList[FieldName][1],= FieldList[FieldName][2], FieldList[FieldName][0]) else: - CApp =3D CApp + ' %s =3D %d; // From %s Line = %d Value %s\n' % (indicator, Value, FieldList[FieldName][1], FieldList[Fiel= dName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' %s =3D %d; // From %s Line = %d Value %s\n' % ( + indicator, Value, FieldList[FieldName][1],= FieldList[FieldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 @staticmethod def GenerateInitValueStatement(Pcd, SkuName, DefaultStoreName): - CApp =3D ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd.TokenSpaceGui= dCName, Pcd.TokenCName, SkuName, DefaultStoreName) + CApp =3D ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, SkuName, DefaultStore= Name) return CApp =20 def GenerateCommandLineValue(self, Pcd): CApp =3D "// Value in CommandLine\n" - CApp =3D CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" = % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) + CApp =3D CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" = % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' =20 @@ -2329,53 +2621,67 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) + FieldList =3D ValueExpressionEx( + FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from Command: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) - Value, ValueSize =3D ParseFieldValue (FieldList) + Value, ValueSize =3D ParseFieldValue(FieldList) =20 if isinstance(Value, str): - CApp =3D CApp + ' Pcd =3D %s; // From Command Line \n= ' % (Value) + CApp =3D CApp + \ + ' Pcd =3D %s; // From Command Line \n' % (Value) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' Value =3D %s; // From Command L= ine.\n' % (DscBuildData.IntToCString(Value, ValueSize)) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + ' Value =3D %s; // From Command L= ine.\n' % ( + DscBuildData.IntToCString(Value, ValueSize)) CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) continue for FieldName in FieldList: IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx( + FieldList[FieldName][0], TAB_VOID, self._GuidD= ict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) except: print("error") try: - Value, ValueSize =3D ParseFieldValue (FieldList[FieldN= ame][0]) + Value, ValueSize =3D ParseFieldValue(FieldList[FieldNa= me][0]) except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]= )) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldNam= e)), FieldList[FieldName][1], FieldList[FieldName][2])) if isinstance(Value, str): - CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %d = Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldNa= me][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %d = Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], FieldLi= st[FieldName][2], FieldList[FieldName][0]) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s);= \n' % (Pcd.BaseDatumType, FieldName) - CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList[Fie= ldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldNa= me, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], Field= List[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSize= > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, Valu= eSize) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + \ + ' FieldSize =3D __FIELD_SIZE(%s, %s);\n' % ( + Pcd.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), FieldList[FieldName][1], FieldL= ist[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % ( + Pcd.BaseDatumType, FieldName, ValueSize, Pcd.BaseD= atumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], Fiel= dList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSize= > 0 && FieldSize < %d) ? FieldSize : %d);\n' % ( + FieldName, ValueSize, ValueSize) else: if '[' in FieldName and ']' in FieldName: Index =3D int(FieldName.split('[')[1].split(']')[0= ]) - CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.spli= t('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[Fiel= dName][2], FieldName) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % ( + Index, FieldName.split('[')[0], FieldName.spli= t('[')[0], FieldList[FieldName][1], FieldList[FieldName][2], FieldName) if ValueSize > 4: - CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s L= ine %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[= FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s L= ine %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) else: - CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 @@ -2383,31 +2689,36 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D "// Value in Dsc Module scope \n" for ModuleGuid in Pcd.PcdFiledValueFromDscComponent: =20 - CApp =3D CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" % (Pc= d.TokenSpaceGuidCName, Pcd.TokenCName, ModuleGuid,Pcd.BaseDatumType) + CApp =3D CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, ModuleGuid, Pcd.B= aseDatumType) CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' - pcddefaultvalue, file_path,lineNo =3D Pcd.PcdValueFromComponen= ts.get(ModuleGuid,(None,None,None)) + pcddefaultvalue, file_path, lineNo =3D Pcd.PcdValueFromCompone= nts.get( + ModuleGuid, (None, None, None)) =20 if pcddefaultvalue: IsArray =3D _IsFieldValueAnArray(pcddefaultvalue) if IsArray: try: - FieldList =3D ValueExpressionEx(pcddefaultvalue, T= AB_VOID)(True) + FieldList =3D ValueExpressionEx( + pcddefaultvalue, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from %s Line %s: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, file_path, lineNo, FieldList)) - Value, ValueSize =3D ParseFieldValue (FieldList) + Value, ValueSize =3D ParseFieldValue(FieldList) =20 if isinstance(Value, str): - CApp =3D CApp + ' Pcd =3D %s; // From %s Line %s \n' = % (Value, file_path, lineNo) + CApp =3D CApp + \ + ' Pcd =3D %s; // From %s Line %s \n' % ( + Value, file_path, lineNo) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' Value =3D %s; // From %s Line %= s.\n' % (DscBuildData.IntToCString(Value, ValueSize), file_path, lineNo) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + ' Value =3D %s; // From %s Line %= s.\n' % ( + DscBuildData.IntToCString(Value, ValueSize), file_= path, lineNo) CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) =20 - PcdFiledValue =3D Pcd.PcdFiledValueFromDscComponent.get(Module= Guid) for index in PcdFiledValue: FieldList =3D PcdFiledValue[index] @@ -2417,118 +2728,151 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][= 0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx( + FieldList[FieldName][0], TAB_VOID, self._G= uidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[Field= Name][2])) except: print("error") try: - Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0]) + Value, ValueSize =3D ParseFieldValue( + FieldList[FieldName][0]) except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Fiel= dName)), FieldList[FieldName][1], FieldList[FieldName][2])) if isinstance(Value, str): - CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, = %s);\n' % (Pcd.BaseDatumType, FieldName) - CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList= [FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, Fie= ldName, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], F= ieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (Field= Size > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, = ValueSize) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + \ + ' FieldSize =3D __FIELD_SIZE(%s, %s);\n' % ( + Pcd.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), FieldList[FieldName][1], Fi= eldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % ( + Pcd.BaseDatumType, FieldName, ValueSize, Pcd.B= aseDatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], = FieldList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (Field= Size > 0 && FieldSize < %d) ? FieldSize : %d);\n' % ( + FieldName, ValueSize, ValueSize) else: if '[' in FieldName and ']' in FieldName: Index =3D int(FieldName.split('[')[1].split(']= ')[0]) - CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.= split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[= FieldName][2], FieldName) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % ( + Index, FieldName.split('[')[0], FieldName.= split('[')[0], FieldList[FieldName][1], FieldList[FieldName][2], FieldName) if ValueSize > 4: - CApp =3D CApp + ' Pcd->%s =3D %dULL; // From = %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldL= ist[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From = %s Line %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1],= FieldList[FieldName][2], FieldList[FieldName][0]) else: - CApp =3D CApp + ' Pcd->%s =3D %d; // From %s = Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList= [FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %d; // From %s = Line %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1],= FieldList[FieldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 @staticmethod def GenerateCommandLineValueStatement(Pcd): - CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSp= aceGuidCName, Pcd.TokenCName) + CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) return CApp - def GenerateFdfValue(self,Pcd): + + def GenerateFdfValue(self, Pcd): CApp =3D "// Value in Fdf\n" - CApp =3D CApp + "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % (Pcd.T= okenSpaceGuidCName, Pcd.TokenCName,Pcd.BaseDatumType) + CApp =3D CApp + "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.BaseDatumType) CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' =20 pcddefaultvalue =3D Pcd.PcdValueFromFdf - for FieldList in [pcddefaultvalue,Pcd.PcdFieldValueFromFdf]: + for FieldList in [pcddefaultvalue, Pcd.PcdFieldValueFromFdf]: if not FieldList: continue if pcddefaultvalue and FieldList =3D=3D pcddefaultvalue: IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) + FieldList =3D ValueExpressionEx( + FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from Fdf: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) - Value, ValueSize =3D ParseFieldValue (FieldList) + Value, ValueSize =3D ParseFieldValue(FieldList) =20 if isinstance(Value, str): CApp =3D CApp + ' Pcd =3D %s; // From Fdf \n' % (Valu= e) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' Value =3D %s; // From Fdf .\n' = % (DscBuildData.IntToCString(Value, ValueSize)) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + \ + ' Value =3D %s; // From Fdf .\n' % ( + DscBuildData.IntToCString(Value, ValueSize)) CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) continue for FieldName in FieldList: IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx( + FieldList[FieldName][0], TAB_VOID, self._GuidD= ict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2])) except: print("error") try: - Value, ValueSize =3D ParseFieldValue (FieldList[FieldN= ame][0]) + Value, ValueSize =3D ParseFieldValue(FieldList[FieldNa= me][0]) except Exception: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd= .TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2])) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join( + (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldNam= e)), FieldList[FieldName][1], FieldList[FieldName][2])) if isinstance(Value, str): - CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %d = Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldNa= me][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %d = Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], FieldLi= st[FieldName][2], FieldList[FieldName][0]) elif IsArray: - # - # Use memcpy() to copy value into field - # - CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s);= \n' % (Pcd.BaseDatumType, FieldName) - CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList[Fie= ldName][1], FieldList[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldNa= me, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], Field= List[FieldName][2], FieldList[FieldName][0]) - CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSize= > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, Valu= eSize) + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + \ + ' FieldSize =3D __FIELD_SIZE(%s, %s);\n' % ( + Pcd.BaseDatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (DscBuildData.IntToCString( + Value, ValueSize), FieldList[FieldName][1], FieldL= ist[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%s, %= s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds the b= uffer array"); // From %s Line %d Value %s\n' % ( + Pcd.BaseDatumType, FieldName, ValueSize, Pcd.BaseD= atumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2], Fiel= dList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSize= > 0 && FieldSize < %d) ? FieldSize : %d);\n' % ( + FieldName, ValueSize, ValueSize) else: if '[' in FieldName and ']' in FieldName: Index =3D int(FieldName.split('[')[1].split(']')[0= ]) - CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.spli= t('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[Fiel= dName][2], FieldName) + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARRAY_S= IZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds the= array number"); // From %s Line %d Index of %s\n' % ( + Index, FieldName.split('[')[0], FieldName.spli= t('[')[0], FieldList[FieldName][1], FieldList[FieldName][2], FieldName) if ValueSize > 4: - CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s L= ine %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[= FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s L= ine %d Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) else: - CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %s Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %s Value %s\n' % ( + FieldName, Value, FieldList[FieldName][1], Fie= ldList[FieldName][2], FieldList[FieldName][0]) CApp =3D CApp + "}\n" return CApp =20 @staticmethod def GenerateFdfValueStatement(Pcd): - CApp =3D ' Assign_%s_%s_Fdf_Value(Pcd);\n' % (Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName) + CApp =3D ' Assign_%s_%s_Fdf_Value(Pcd);\n' % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName) return CApp =20 @staticmethod def GenerateModuleValueStatement(module_guid, Pcd): - CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % (Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName, module_guid) + CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % ( + Pcd.TokenSpaceGuidCName, Pcd.TokenCName, module_guid) return CApp - def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd, InitByteValu= e, CApp): + + def GenerateModuleScopeInitializeFunc(self, SkuName, Pcd, InitByteVal= ue, CApp): for module_guid in Pcd.PcdFiledValueFromDscComponent: CApp =3D CApp + 'void\n' - CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (module_guid, TA= B_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % ( + module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGui= dCName, Pcd.TokenCName) CApp =3D CApp + ' void\n' CApp =3D CApp + ' )\n' CApp =3D CApp + '{\n' @@ -2538,16 +2882,19 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' UINT32 OriginalSize;\n' CApp =3D CApp + ' VOID *OriginalPcd;\n' =20 - CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % (Pc= d.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % ( + Pcd.BaseDatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo) =20 CApp =3D CApp + '\n' =20 PcdDefaultValue =3D StringToArray(Pcd.DefaultValueFromDec.stri= p()) - InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, TAB_D= EFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumTy= pe, PcdDefaultValue) + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, TAB_D= EFAULT_STORES_DEFAULT, + Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName, Pcd.DatumType, PcdDefaultValue) # # Get current PCD value and size # - CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % ( + module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGui= dCName, Pcd.TokenCName) =20 # # Determine the size of the PCD. For simple structures, sizeo= f(TYPE) provides @@ -2557,18 +2904,25 @@ class DscBuildData(PlatformBuildClassObject): # in a structure. The size formula for this case is: # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (H= ighestIndex + 1) # - CApp =3D CApp + DscBuildData.GenerateSizeStatments(Pcd,SkuName= ,TAB_DEFAULT_STORES_DEFAULT) + CApp =3D CApp + \ + DscBuildData.GenerateSizeStatments( + Pcd, SkuName, TAB_DEFAULT_STORES_DEFAULT) if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % (Pcd.BaseDatumType,Pcd.PcdArr= aySize(),Pcd.BaseDatumType,Pcd.PcdArraySize()) - CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.Ba= seDatumType,Pcd.PcdArraySize()) + CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % ( + Pcd.BaseDatumType, Pcd.PcdArraySize(), Pcd.BaseDatumTy= pe, Pcd.PcdArraySize()) + CApp =3D CApp + \ + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.BaseDatumType, + Pcd.PcdArraySize()) =20 # # Allocate and zero buffer for the PCD # Must handle cases where current value is smaller, larger, or= same size # Always keep that larger one as the current size # - CApp =3D CApp + ' Size =3D (OriginalSize > Size ? OriginalSiz= e : Size);\n' - CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.= BaseDatumType,) + CApp =3D CApp + \ + ' Size =3D (OriginalSize > Size ? OriginalSize : Size);\n' + CApp =3D CApp + \ + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.BaseDatumTyp= e,) CApp =3D CApp + ' memset (Pcd, 0, Size);\n' =20 # @@ -2582,15 +2936,18 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + DscBuildData.GenerateDefaultValueAssignStateme= nt(Pcd) =20 CApp =3D CApp + "// SkuName: %s, DefaultStoreName: STANDARD \= n" % self.SkuIdMgr.SystemSkuId - CApp =3D CApp + DscBuildData.GenerateInitValueStatement(Pcd, s= elf.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) - CApp =3D CApp + DscBuildData.GenerateModuleValueStatement(modu= le_guid,Pcd) + CApp =3D CApp + DscBuildData.GenerateInitValueStatement( + Pcd, self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) + CApp =3D CApp + \ + DscBuildData.GenerateModuleValueStatement(module_guid, Pcd) CApp =3D CApp + DscBuildData.GenerateFdfValueStatement(Pcd) CApp =3D CApp + DscBuildData.GenerateCommandLineValueStatement= (Pcd) =20 # # Set new PCD value and size # - CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName,= Pcd.TokenCName) + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % ( + module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGui= dCName, Pcd.TokenCName) =20 # # Free PCD @@ -2598,17 +2955,18 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' free (Pcd);\n' CApp =3D CApp + '}\n' CApp =3D CApp + '\n' - return InitByteValue,CApp + return InitByteValue, CApp =20 def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteV= alue, CApp): - OverrideValues =3D {DefaultStore:{}} + OverrideValues =3D {DefaultStore: {}} if Pcd.SkuOverrideValues: OverrideValues =3D Pcd.SkuOverrideValues[SkuName] if not OverrideValues: - OverrideValues =3D {TAB_DEFAULT_STORES_DEFAULT:Pcd.DefaultValu= es} + OverrideValues =3D {TAB_DEFAULT_STORES_DEFAULT: Pcd.DefaultVal= ues} for DefaultStoreName in OverrideValues: CApp =3D CApp + 'void\n' - CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, Defaul= tStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % ( + SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.To= kenCName) CApp =3D CApp + ' void\n' CApp =3D CApp + ' )\n' CApp =3D CApp + '{\n' @@ -2618,18 +2976,21 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' UINT32 OriginalSize;\n' CApp =3D CApp + ' VOID *OriginalPcd;\n' =20 - CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % (Pc= d.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo) + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % ( + Pcd.BaseDatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo) =20 CApp =3D CApp + '\n' =20 PcdDefaultValue =3D StringToArray(Pcd.DefaultValueFromDec.stri= p()) =20 - InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (SkuName, DefaultSt= oreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, PcdDefault= Value) + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % ( + SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.To= kenCName, Pcd.DatumType, PcdDefaultValue) =20 # # Get current PCD value and size # - CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, P= cd.TokenCName) + CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % ( + SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.To= kenCName) =20 # # Determine the size of the PCD. For simple structures, sizeo= f(TYPE) provides @@ -2639,18 +3000,25 @@ class DscBuildData(PlatformBuildClassObject): # in a structure. The size formula for this case is: # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (H= ighestIndex + 1) # - CApp =3D CApp + DscBuildData.GenerateSizeStatments(Pcd,SkuName= ,DefaultStoreName) + CApp =3D CApp + \ + DscBuildData.GenerateSizeStatments( + Pcd, SkuName, DefaultStoreName) if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1": - CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % (Pcd.BaseDatumType,Pcd.PcdArr= aySize(),Pcd.BaseDatumType,Pcd.PcdArraySize()) - CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.Ba= seDatumType,Pcd.PcdArraySize()) + CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % ( + Pcd.BaseDatumType, Pcd.PcdArraySize(), Pcd.BaseDatumTy= pe, Pcd.PcdArraySize()) + CApp =3D CApp + \ + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.BaseDatumType, + Pcd.PcdArraySize()) =20 # # Allocate and zero buffer for the PCD # Must handle cases where current value is smaller, larger, or= same size # Always keep that larger one as the current size # - CApp =3D CApp + ' Size =3D (OriginalSize > Size ? OriginalSiz= e : Size);\n' - CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.= BaseDatumType,) + CApp =3D CApp + \ + ' Size =3D (OriginalSize > Size ? OriginalSize : Size);\n' + CApp =3D CApp + \ + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.BaseDatumTyp= e,) CApp =3D CApp + ' memset (Pcd, 0, Size);\n' =20 # @@ -2663,23 +3031,30 @@ class DscBuildData(PlatformBuildClassObject): # CApp =3D CApp + DscBuildData.GenerateDefaultValueAssignStateme= nt(Pcd) if Pcd.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_= BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: + self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE= _IN_MODULE]]: for skuname in self.SkuIdMgr.GetSkuChain(SkuName): - storeset =3D [DefaultStoreName] if DefaultStoreName = =3D=3D TAB_DEFAULT_STORES_DEFAULT else [TAB_DEFAULT_STORES_DEFAULT, Default= StoreName] + storeset =3D [DefaultStoreName] if DefaultStoreName = =3D=3D TAB_DEFAULT_STORES_DEFAULT else [ + TAB_DEFAULT_STORES_DEFAULT, DefaultStoreName] for defaultstorenameitem in storeset: - CApp =3D CApp + "// SkuName: %s, DefaultStoreName= : %s \n" % (skuname, defaultstorenameitem) - CApp =3D CApp + DscBuildData.GenerateInitValueStat= ement(Pcd, skuname, defaultstorenameitem) + CApp =3D CApp + \ + "// SkuName: %s, DefaultStoreName: %s \n" % ( + skuname, defaultstorenameitem) + CApp =3D CApp + \ + DscBuildData.GenerateInitValueStatement( + Pcd, skuname, defaultstorenameitem) if skuname =3D=3D SkuName: break else: CApp =3D CApp + "// SkuName: %s, DefaultStoreName: STANDA= RD \n" % self.SkuIdMgr.SystemSkuId - CApp =3D CApp + DscBuildData.GenerateInitValueStatement(Pc= d, self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) + CApp =3D CApp + DscBuildData.GenerateInitValueStatement( + Pcd, self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEF= AULT) CApp =3D CApp + DscBuildData.GenerateFdfValueStatement(Pcd) CApp =3D CApp + DscBuildData.GenerateCommandLineValueStatement= (Pcd) # # Set new PCD value and size # - CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e) + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % ( + SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.To= kenCName) =20 # # Free PCD @@ -2699,37 +3074,48 @@ class DscBuildData(PlatformBuildClassObject): =20 Value =3D Pcd.DefaultValueFromDec if "{CODE(" in Pcd.DefaultValueFromDec: - realvalue =3D Pcd.DefaultValueFromDec.strip()[6:-2] # "{CODE("= ).rstrip(")}" - CApp +=3D "static %s %s_%s_INIT_Value%s =3D %s;\n" % (Pcd.Base= DatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,Demesion,realvalue) + # "{CODE(").rstrip(")}" + realvalue =3D Pcd.DefaultValueFromDec.strip()[6:-2] + CApp +=3D "static %s %s_%s_INIT_Value%s =3D %s;\n" % ( + Pcd.BaseDatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName= , Demesion, realvalue) =20 if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_EX_TYPE_SET: for skuname in Pcd.SkuInfoList: skuinfo =3D Pcd.SkuInfoList[skuname] if skuinfo.VariableName: for defaultstore in skuinfo.DefaultStoreDict: - pcddscrawdefaultvalue =3D self.GetPcdDscRawDefault= Value(Pcd, skuname, defaultstore) + pcddscrawdefaultvalue =3D self.GetPcdDscRawDefault= Value( + Pcd, skuname, defaultstore) if pcddscrawdefaultvalue: Value =3D skuinfo.DefaultStoreDict[defaultstor= e] if "{CODE(" in Value: - realvalue =3D Value.strip()[6:-2] # "{CODE= (").rstrip(")}" - CApp +=3D "static %s %s_%s_%s_%s_Value%s = =3D %s;\n" % (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skun= ame,defaultstore,Demesion,realvalue) + # "{CODE(").rstrip(")}" + realvalue =3D Value.strip()[6:-2] + CApp +=3D "static %s %s_%s_%s_%s_Value%s = =3D %s;\n" % ( + Pcd.BaseDatumType, Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, skuname, defaultstore, Demesion, realvalue) else: - pcddscrawdefaultvalue =3D self.GetPcdDscRawDefaultValu= e(Pcd, skuname, TAB_DEFAULT_STORES_DEFAULT) + pcddscrawdefaultvalue =3D self.GetPcdDscRawDefaultValu= e( + Pcd, skuname, TAB_DEFAULT_STORES_DEFAULT) if pcddscrawdefaultvalue: Value =3D skuinfo.DefaultValue if "{CODE(" in Value: - realvalue =3D Value.strip()[6:-2] # "{CODE(").= rstrip(")}" - CApp +=3D "static %s %s_%s_%s_%s_Value%s =3D %= s;\n" % (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,T= AB_DEFAULT_STORES_DEFAULT,Demesion,realvalue) + # "{CODE(").rstrip(")}" + realvalue =3D Value.strip()[6:-2] + CApp +=3D "static %s %s_%s_%s_%s_Value%s =3D %= s;\n" % ( + Pcd.BaseDatumType, Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, skuname, TAB_DEFAULT_STORES_DEFAULT, Demesion, realvalue) else: - pcddscrawdefaultvalue =3D self.GetPcdDscRawDefaultValue(Pcd, T= AB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) + pcddscrawdefaultvalue =3D self.GetPcdDscRawDefaultValue( + Pcd, TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) if pcddscrawdefaultvalue: if "{CODE(" in Pcd.DefaultValue: - realvalue =3D Pcd.DefaultValue.strip()[6:-2] # "{CODE(= ").rstrip(")}" - CApp +=3D "static %s %s_%s_DEFAULT_STANDARD_Value%s = =3D %s;\n" % (Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,Deme= sion,realvalue) + # "{CODE(").rstrip(")}" + realvalue =3D Pcd.DefaultValue.strip()[6:-2] + CApp +=3D "static %s %s_%s_DEFAULT_STANDARD_Value%s = =3D %s;\n" % ( + Pcd.BaseDatumType, Pcd.TokenSpaceGuidCName, Pcd.To= kenCName, Demesion, realvalue) =20 return CApp =20 - def SkuOverrideValuesEmpty(self,OverrideValues): + def SkuOverrideValuesEmpty(self, OverrideValues): if not OverrideValues: return True for key in OverrideValues: @@ -2743,14 +3129,15 @@ class DscBuildData(PlatformBuildClassObject): i =3D 0 while i < len(ccflaglist): item =3D ccflaglist[i].strip() - if item in (r"/D", r"/U","-D","-U"): - ccflags.add(" ".join((ccflaglist[i],ccflaglist[i+1]))) + if item in (r"/D", r"/U", "-D", "-U"): + ccflags.add(" ".join((ccflaglist[i], ccflaglist[i+1]))) i =3D i+1 - elif item.startswith((r"/D", r"/U","-D","-U")): + elif item.startswith((r"/D", r"/U", "-D", "-U")): ccflags.add(item) - i +=3D1 + i +=3D 1 return ccflags - def GenerateByteArrayValue (self, StructuredPcds): + + def GenerateByteArrayValue(self, StructuredPcds): # # Generate/Compile/Run C application to determine if there are any= flexible array members # @@ -2773,10 +3160,10 @@ class DscBuildData(PlatformBuildClassObject): for PcdName in sorted(StructuredPcds.keys()): Pcd =3D StructuredPcds[PcdName] =20 - #create void void Cal_tocken_cname_Size functions + # create void void Cal_tocken_cname_Size functions CApp =3D CApp + self.GenerateSizeFunction(Pcd) =20 - #create void Assign_ functions + # create void Assign_ functions =20 # From DEC CApp =3D CApp + self.GenerateDefaultValueAssignFunction(Pcd) @@ -2787,30 +3174,36 @@ class DscBuildData(PlatformBuildClassObject): =20 # From Dsc Global setting if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: - CApp =3D CApp + self.GenerateInitValueFunction(Pcd, self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT) + = self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: + CApp =3D CApp + self.GenerateInitValueFunction( + Pcd, self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEF= AULT) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]: - CApp =3D CApp + self.GenerateInitValueFunction(Pcd= , SkuName, DefaultStoreName) + CApp =3D CApp + \ + self.GenerateInitValueFunction( + Pcd, SkuName, DefaultStoreName) =20 # From Dsc module scope setting CApp =3D CApp + self.GenerateModuleScopeValue(Pcd) =20 - #create Initialize_ functions + # create Initialize_ functions if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], - self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: - InitByteValue, CApp =3D self.GenerateInitializeFunc(self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp) - InitByteValue, CApp =3D self.GenerateModuleScopeInitializ= eFunc(self.SkuIdMgr.SystemSkuId,Pcd,InitByteValue,CApp) + = self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: + InitByteValue, CApp =3D self.GenerateInitializeFunc( + self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT,= Pcd, InitByteValue, CApp) + InitByteValue, CApp =3D self.GenerateModuleScopeInitialize= Func( + self.SkuIdMgr.SystemSkuId, Pcd, InitByteValue, CApp) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in Pcd.SkuOverrideValues: continue for DefaultStoreName in Pcd.DefaultStoreName: Pcd =3D StructuredPcds[PcdName] - InitByteValue, CApp =3D self.GenerateInitializeFun= c(SkuName, DefaultStoreName, Pcd, InitByteValue, CApp) + InitByteValue, CApp =3D self.GenerateInitializeFun= c( + SkuName, DefaultStoreName, Pcd, InitByteValue,= CApp) =20 CApp =3D CApp + 'VOID\n' CApp =3D CApp + 'PcdEntryPoint(\n' @@ -2819,15 +3212,18 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + '{\n' for Pcd in StructuredPcds.values(): if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_ST= RING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: - CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.Sk= uIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pc= d.TokenCName) + CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.Sk= uIdMgr.SystemSkuId, + TAB_DEFAU= LT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) for ModuleGuid in Pcd.PcdFiledValueFromDscComponent: - CApp +=3D " Initialize_%s_%s_%s_%s();\n" % (ModuleGui= d,TAB_DEFAULT_STORES_DEFAULT ,Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp +=3D " Initialize_%s_%s_%s_%s();\n" % (ModuleGui= d, TAB_DEFAULT_STORES_DEFAULT, + Pcd.TokenSp= aceGuidCName, Pcd.TokenCName) else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): if SkuName not in self.SkuIdMgr.AvailableSkuIdSet: continue for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]: - CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % = (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) + CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % = (SkuName, DefaultStoreName, + P= cd.TokenSpaceGuidCName, Pcd.TokenCName) CApp =3D CApp + '}\n' =20 CApp =3D CApp + PcdMainCEntry + '\n' @@ -2840,11 +3236,13 @@ class DscBuildData(PlatformBuildClassObject): # start generating makefile MakeApp =3D PcdMakefileHeader if sys.platform =3D=3D "win32": - MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Output= Path, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECT= S =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.joi= n(self.OutputPath, PcdValueCommonName)) + 'INC =3D ' + MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Output= Path, PcdValueInitName) + 'APPNAME =3D %s\n' % ( + PcdValueInitName) + 'OBJECTS =3D %s\%s.obj %s.obj\n' % (se= lf.OutputPath, PcdValueInitName, os.path.join(self.OutputPath, PcdValueComm= onName)) + 'INC =3D ' else: MakeApp =3D MakeApp + PcdGccMakefile MakeApp =3D MakeApp + 'APPFILE =3D %s/%s\n' % (self.OutputPath= , PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECTS = =3D %s/%s.o %s.o\n' % (self.OutputPath, PcdValueInitName, os.path.join(self= .OutputPath, PcdValueCommonName)) + \ - 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'TO= OL_INCLUDE +=3D' + 'include $(MAKEROOT)/Makefiles/app.makefile\n' + \ + 'TOOL_INCLUDE +=3D' =20 IncSearchList =3D [] PlatformInc =3D OrderedDict() @@ -2854,15 +3252,19 @@ class DscBuildData(PlatformBuildClassObject): if Cache.Includes: if str(Cache.MetaFile.Path) not in PlatformInc: PlatformInc[str(Cache.MetaFile.Path)] =3D [] - PlatformInc[str(Cache.MetaFile.Path)].append (os.path.= dirname(Cache.MetaFile.Path)) - PlatformInc[str(Cache.MetaFile.Path)].extend (Cache.Co= mmonIncludes) + PlatformInc[str(Cache.MetaFile.Path)].append( + os.path.dirname(Cache.MetaFile.Path)) + PlatformInc[str(Cache.MetaFile.Path)].extend( + Cache.CommonIncludes) =20 PcdDependDEC =3D [] for Pcd in StructuredPcds.values(): for PackageDec in Pcd.PackageDecs: - Package =3D os.path.normpath(mws.join(GlobalData.gWorkspac= e, PackageDec)) + Package =3D os.path.normpath( + mws.join(GlobalData.gWorkspace, PackageDec)) if not os.path.exists(Package): - EdkLogger.error('Build', RESOURCE_NOT_AVAILABLE, "The = dependent Package %s of PCD %s.%s is not exist." % (PackageDec, Pcd.TokenSp= aceGuidCName, Pcd.TokenCName)) + EdkLogger.error('Build', RESOURCE_NOT_AVAILABLE, "The = dependent Package %s of PCD %s.%s is not exist." % ( + PackageDec, Pcd.TokenSpaceGuidCName, Pcd.TokenCNam= e)) if Package not in PcdDependDEC: PcdDependDEC.append(Package) =20 @@ -2873,7 +3275,7 @@ class DscBuildData(PlatformBuildClassObject): # # Get list of files in potential -I include path # - FileList =3D os.listdir (str(inc)) + FileList =3D os.listdir(str(inc)) # # Skip -I include path if one of the include files= required # by PcdValueInit.c are present in the include pat= hs from @@ -2881,12 +3283,12 @@ class DscBuildData(PlatformBuildClassObject): # files from the host compiler. # if 'stdio.h' in FileList: - continue + continue if 'stdlib.h' in FileList: - continue + continue if 'string.h' in FileList: - continue - MakeApp +=3D '-I' + str(inc) + ' ' + continue + MakeApp +=3D '-I' + str(inc) + ' ' IncSearchList.append(inc) MakeApp =3D MakeApp + '\n' =20 @@ -2910,52 +3312,71 @@ class DscBuildData(PlatformBuildClassObject): if 'COMMON' not in BuildOptions: BuildOptions['COMMON'] =3D set() if Arch =3D=3D TAB_STAR: - BuildOptions['COMMON']|=3D self.ParseCCFlags(self.= BuildOptions[Options]) + BuildOptions['COMMON'] |=3D self.ParseCCFlags( + self.BuildOptions[Options]) if Arch in self.SupArchList: if Arch not in BuildOptions: BuildOptions[Arch] =3D set() - BuildOptions[Arch] |=3D self.ParseCCFlags(self.Bui= ldOptions[Options]) + BuildOptions[Arch] |=3D self.ParseCCFlags( + self.BuildOptions[Options]) =20 if BuildOptions: - ArchBuildOptions =3D {arch:flags for arch,flags in BuildOption= s.items() if arch !=3D 'COMMON'} + ArchBuildOptions =3D {arch: flags for arch, + flags in BuildOptions.items() if arch !=3D= 'COMMON'} if len(ArchBuildOptions.keys()) =3D=3D 1: BuildOptions['COMMON'] |=3D (list(ArchBuildOptions.values(= ))[0]) elif len(ArchBuildOptions.keys()) > 1: - CommonBuildOptions =3D reduce(lambda x,y: x&y, ArchBuildOp= tions.values()) + CommonBuildOptions =3D reduce( + lambda x, y: x & y, ArchBuildOptions.values()) BuildOptions['COMMON'] |=3D CommonBuildOptions - ValueList =3D [item for item in BuildOptions['COMMON'] if item= .startswith((r"/U","-U"))] - ValueList.extend([item for item in BuildOptions['COMMON'] if i= tem.startswith((r"/D", "-D"))]) + ValueList =3D [item for item in BuildOptions['COMMON'] + if item.startswith((r"/U", "-U"))] + ValueList.extend( + [item for item in BuildOptions['COMMON'] if item.startswit= h((r"/D", "-D"))]) CC_FLAGS +=3D " ".join(ValueList) MakeApp +=3D CC_FLAGS =20 if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + PcdMakefileEnd - MakeApp =3D MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(= APPFILE) /y """) + MakeApp =3D MakeApp + \ + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """) else: - MakeApp =3D MakeApp + AppTarget % ("""\tcp -p $(APPLICATION) $= (APPFILE) """) + MakeApp =3D MakeApp + \ + AppTarget % ("""\tcp -p $(APPLICATION) $(APPFILE) """) MakeApp =3D MakeApp + '\n' IncludeFileFullPaths =3D [] for includefile in IncludeFiles: for includepath in IncSearchList: includefullpath =3D os.path.join(str(includepath), include= file) if os.path.exists(includefullpath): - IncludeFileFullPaths.append(os.path.normpath(includefu= llpath)) + IncludeFileFullPaths.append( + os.path.normpath(includefullpath)) break SearchPathList =3D [] - SearchPathList.append(os.path.normpath(mws.join(GlobalData.gGlobal= Defines["EDK_TOOLS_PATH"], "BaseTools/Source/C/Include"))) - SearchPathList.append(os.path.normpath(mws.join(GlobalData.gGlobal= Defines["EDK_TOOLS_PATH"], "BaseTools/Source/C/Common"))) + SearchPathList.append(os.path.normpath(mws.join( + GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "BaseTools/Source= /C/Include"))) + SearchPathList.append(os.path.normpath(mws.join( + GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "BaseTools/Source= /C/Common"))) SearchPathList.extend(str(item) for item in IncSearchList) IncFileList =3D GetDependencyList(IncludeFileFullPaths, SearchPath= List) for include_file in IncFileList: MakeApp +=3D "$(OBJECTS) : %s\n" % include_file if sys.platform =3D=3D "win32": - PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData.gG= lobalDefines["EDK_TOOLS_PATH"], "Source\C\Common\PcdValueCommon.c")) - MakeApp =3D MakeApp + '%s\PcdValueCommon.c : %s\n' % (self.Out= putPath, PcdValueCommonPath) + PcdValueCommonPath =3D os.path.normpath(mws.join( + GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source\C\Com= mon\PcdValueCommon.c")) + MakeApp =3D MakeApp + \ + '%s\PcdValueCommon.c : %s\n' % ( + self.OutputPath, PcdValueCommonPath) MakeApp =3D MakeApp + '\tcopy /y %s $@\n' % (PcdValueCommonPat= h) else: - PcdValueCommonPath =3D os.path.normpath(mws.join(GlobalData.gG= lobalDefines["EDK_TOOLS_PATH"], "Source/C/Common/PcdValueCommon.c")) - MakeApp =3D MakeApp + '%s/PcdValueCommon.c : %s\n' % (self.Out= putPath, PcdValueCommonPath) - MakeApp =3D MakeApp + '\tcp -p -f %s %s/PcdValueCommon.c\n' % = (PcdValueCommonPath, self.OutputPath) + PcdValueCommonPath =3D os.path.normpath(mws.join( + GlobalData.gGlobalDefines["EDK_TOOLS_PATH"], "Source/C/Com= mon/PcdValueCommon.c")) + MakeApp =3D MakeApp + \ + '%s/PcdValueCommon.c : %s\n' % (self.OutputPath, + PcdValueCommonPath) + MakeApp =3D MakeApp + \ + '\tcp -p -f %s %s/PcdValueCommon.c\n' % ( + PcdValueCommonPath, self.OutputPath) MakeFileName =3D os.path.join(self.OutputPath, 'Makefile') MakeApp +=3D "$(OBJECTS) : %s\n" % MakeFileName SaveFileOnChange(MakeFileName, MakeApp, False) @@ -2967,48 +3388,52 @@ class DscBuildData(PlatformBuildClassObject): =20 Dest_PcdValueInitExe =3D PcdValueInitName if not sys.platform =3D=3D "win32": - Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName) + Dest_PcdValueInitExe =3D os.path.join( + self.OutputPath, PcdValueInitName) else: - Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName) +".exe" + Dest_PcdValueInitExe =3D os.path.join( + self.OutputPath, PcdValueInitName) + ".exe" =20 - #start building the structure pcd value tool + # start building the structure pcd value tool Messages =3D '' if sys.platform =3D=3D "win32": MakeCommand =3D 'nmake -f %s' % (MakeFileName) - returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Ma= keCommand) + returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand( + MakeCommand) Messages =3D StdOut else: MakeCommand =3D 'make -f %s' % (MakeFileName) - returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Ma= keCommand) + returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand( + MakeCommand) Messages =3D StdErr =20 - EdkLogger.verbose ('%s\n%s\n%s' % (MakeCommand, StdOut, StdErr)) + EdkLogger.verbose('%s\n%s\n%s' % (MakeCommand, StdOut, StdErr)) Messages =3D Messages.split('\n') MessageGroup =3D [] if returncode !=3D 0: CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValueIni= tName) - File =3D open (CAppBaseFileName + '.c', 'r') + File =3D open(CAppBaseFileName + '.c', 'r') FileData =3D File.readlines() File.close() for Message in Messages: if " error" in Message or "warning" in Message: try: FileInfo =3D Message.strip().split('(') - if len (FileInfo) > 1: - FileName =3D FileInfo [0] - FileLine =3D FileInfo [1].split (')')[0] + if len(FileInfo) > 1: + FileName =3D FileInfo[0] + FileLine =3D FileInfo[1].split(')')[0] else: FileInfo =3D Message.strip().split(':') if len(FileInfo) < 2: continue - FileName =3D FileInfo [0] - FileLine =3D FileInfo [1] + FileName =3D FileInfo[0] + FileLine =3D FileInfo[1] except: continue if "PcdValueInit.c" not in FileName: continue if FileLine.isdigit(): - error_line =3D FileData[int (FileLine) - 1] + error_line =3D FileData[int(FileLine) - 1] if r"//" in error_line: c_line, dsc_line =3D error_line.split(r"//") else: @@ -3025,33 +3450,39 @@ class DscBuildData(PlatformBuildClassObject): Index =3D message_itmes.index(item) message_itmes[Index] =3D dsc_line.stri= p() break - MessageGroup.append(":".join(message_itmes[Ind= ex:]).strip()) + MessageGroup.append( + ":".join(message_itmes[Index:]).strip()) continue else: MessageGroup.append(Message) if MessageGroup: - EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".joi= n(MessageGroup) ) + EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, + "\n".join(MessageGroup)) else: - EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute= command: %s\n%s\n%s' % (MakeCommand, StdOut, StdErr)) + EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute= command: %s\n%s\n%s' % ( + MakeCommand, StdOut, StdErr)) =20 - #start executing the structure pcd value tool + # start executing the structure pcd value tool if DscBuildData.NeedUpdateOutput(OutputValueFile, Dest_PcdValueIni= tExe, InputValueFile): - Command =3D Dest_PcdValueInitExe + ' -i %s -o %s' % (InputValu= eFile, OutputValueFile) - returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Co= mmand) - EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut, StdErr)) + Command =3D Dest_PcdValueInitExe + \ + ' -i %s -o %s' % (InputValueFile, OutputValueFile) + returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand(Com= mand) + EdkLogger.verbose('%s\n%s\n%s' % (Command, StdOut, StdErr)) if returncode !=3D 0: - EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect = output from command: %s\n%s\n%s\n' % (Command, StdOut, StdErr)) + EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect = output from command: %s\n%s\n%s\n' % ( + Command, StdOut, StdErr)) =20 - #start update structure pcd final value - File =3D open (OutputValueFile, 'r') + # start update structure pcd final value + File =3D open(OutputValueFile, 'r') FileBuffer =3D File.readlines() File.close() =20 StructurePcdSet =3D [] for Pcd in FileBuffer: - PcdValue =3D Pcd.split ('|') - PcdInfo =3D PcdValue[0].split ('.') - StructurePcdSet.append((PcdInfo[0], PcdInfo[1], PcdInfo[2], Pc= dInfo[3], PcdValue[2].strip())) + PcdValue =3D Pcd.split('|') + PcdInfo =3D PcdValue[0].split('.') + StructurePcdSet.append( + (PcdInfo[0], PcdInfo[1], PcdInfo[2], PcdInfo[3], PcdValue[= 2].strip())) return StructurePcdSet =20 @staticmethod @@ -3064,7 +3495,7 @@ class DscBuildData(PlatformBuildClassObject): return True return False =20 - ## Retrieve dynamic PCD settings + # Retrieve dynamic PCD settings # # @param Type PCD type # @@ -3072,7 +3503,6 @@ class DscBuildData(PlatformBuildClassObject): # def _GetDynamicPcd(self, Type): =20 - Pcds =3D OrderedDict() # # tdict is a special dict kind of type, used for selecting correct @@ -3084,13 +3514,12 @@ class DscBuildData(PlatformBuildClassObject): RecordList =3D self._RawData[Type, self._Arch] AvailableSkuIdSet =3D copy.copy(self.SkuIds) =20 - for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dumm= y4, Dummy5 in RecordList: SkuName =3D SkuName.upper() SkuName =3D TAB_DEFAULT if SkuName =3D=3D TAB_COMMON else SkuN= ame if SkuName not in AvailableSkuIdSet: EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not= defined in [SkuIds] section' % SkuName, - File=3Dself.MetaFile, Line=3DD= ummy5) + File=3Dself.MetaFile, Line=3DDummy5) if "." not in TokenSpaceGuid and "[" not in PcdCName and (PcdC= Name, TokenSpaceGuid, SkuName, Dummy5) not in PcdList: PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] =3D Setting @@ -3102,7 +3531,8 @@ class DscBuildData(PlatformBuildClassObject): if Setting is None: continue =20 - PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd(PcdCNa= me, TokenSpaceGuid, Setting, Type, Dummy4) + PcdValue, DatumType, MaxDatumSize =3D self._ValidatePcd( + PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) if MaxDatumSize: if int(MaxDatumSize, 0) > 0xFFFF: EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), @@ -3110,7 +3540,8 @@ class DscBuildData(PlatformBuildClassObject): if int(MaxDatumSize, 0) < 0: EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), File=3Dself.MetaFile, Line=3DDummy4) - SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', '', PcdValue) + SkuInfo =3D SkuInfoClass( + SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdV= alue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo @@ -3126,33 +3557,36 @@ class DscBuildData(PlatformBuildClassObject): pcdObject.MaxDatumSize =3D str(CurrentMaxSize) else: Pcds[PcdCName, TokenSpaceGuid] =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - self._PCD_TYPE_STRING_= [Type], - DatumType, - PcdValue, - '', - MaxDatumSize, - OrderedDict({SkuName := SkuInfo}), - False, - None, - IsDsc=3DTrue) + PcdCName, + TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type], + DatumType, + PcdValue, + '', + MaxDatumSize, + OrderedDict({SkuName: SkuInfo}), + False, + None, + IsDsc=3DTrue) =20 if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFAUL= T_STORES_DEFAULT] =3D PcdValue - Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_DE= FAULT_STORES_DEFAULT] =3D (self.MetaFile.File,Dummy4) + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_DE= FAULT_STORES_DEFAULT] =3D ( + self.MetaFile.File, Dummy4) =20 for pcd in Pcds.values(): - pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpaceG= uidCName] + pcdDecObject =3D self._DecPcds[pcd.TokenCName, + pcd.TokenSpaceGuidCName] # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): if not sku.DefaultValue: sku.DefaultValue =3D pcdDecObject.DefaultValue if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pc= d.SkuInfoList: valuefromDec =3D pcdDecObject.DefaultValue - SkuInfo =3D SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '',= '', valuefromDec) + SkuInfo =3D SkuInfoClass( + TAB_DEFAULT, '0', '', '', '', '', '', valuefromDec) pcd.SkuInfoList[TAB_DEFAULT] =3D SkuInfo elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.= SkuInfoList: pcd.SkuInfoList[TAB_DEFAULT] =3D pcd.SkuInfoList[TAB_COMMO= N] @@ -3169,12 +3603,13 @@ class DscBuildData(PlatformBuildClassObject): if self.SkuIdMgr.SkuUsageType =3D=3D self.SkuIdMgr.SINGLE: if TAB_DEFAULT in PcdObj.SkuInfoList and self.SkuIdMgr.SystemS= kuId not in PcdObj.SkuInfoList: PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] =3D PcdObj.S= kuInfoList[TAB_DEFAULT] - PcdObj.SkuInfoList =3D {TAB_DEFAULT:PcdObj.SkuInfoList[self.Sk= uIdMgr.SystemSkuId]} + PcdObj.SkuInfoList =3D { + TAB_DEFAULT: PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]} PcdObj.SkuInfoList[TAB_DEFAULT].SkuIdName =3D TAB_DEFAULT PcdObj.SkuInfoList[TAB_DEFAULT].SkuId =3D '0' =20 elif self.SkuIdMgr.SkuUsageType =3D=3D self.SkuIdMgr.DEFAULT: - PcdObj.SkuInfoList =3D {TAB_DEFAULT:PcdObj.SkuInfoList[TAB_DEF= AULT]} + PcdObj.SkuInfoList =3D {TAB_DEFAULT: PcdObj.SkuInfoList[TAB_DE= FAULT]} =20 return PcdObj =20 @@ -3194,24 +3629,31 @@ class DscBuildData(PlatformBuildClassObject): def CompletePcdValues(self, PcdSet): Pcds =3D OrderedDict() DefaultStoreObj =3D DefaultStore(self._GetDefaultStores()) - SkuIds =3D {skuname:skuid for skuname, skuid in self.SkuIdMgr.Avai= lableSkuIdSet.items() if skuname !=3D TAB_COMMON} - DefaultStores =3D set(storename for pcdobj in PcdSet.values() for = skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreD= ict) + SkuIds =3D {skuname: skuid for skuname, + skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skun= ame !=3D TAB_COMMON} + DefaultStores =3D set(storename for pcdobj in PcdSet.values( + ) for skuobj in pcdobj.SkuInfoList.values() for storename in skuob= j.DefaultStoreDict) for PcdCName, TokenSpaceGuid in PcdSet: PcdObj =3D PcdSet[(PcdCName, TokenSpaceGuid)] =20 if PcdObj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMI= C_DEFAULT], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAUL= T], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], - self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]]: - Pcds[PcdCName, TokenSpaceGuid]=3D PcdObj + self._PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC_HII], + self._PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC_VPD], + self._PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC_EX_DEFAULT], + self._PCD_TYPE_STRING_[ + MODEL_PCD_DYNAMIC_EX_HII], + self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMI= C_EX_VPD]]: + Pcds[PcdCName, TokenSpaceGuid] =3D PcdObj continue PcdType =3D PcdObj.Type if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], = self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: for skuid in PcdObj.SkuInfoList: skuobj =3D PcdObj.SkuInfoList[skuid] - mindefaultstorename =3D DefaultStoreObj.GetMin(set(def= aultstorename for defaultstorename in skuobj.DefaultStoreDict)) + mindefaultstorename =3D DefaultStoreObj.GetMin( + set(defaultstorename for defaultstorename in skuob= j.DefaultStoreDict)) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: skuobj.DefaultStoreDict[defaultstorename] =3D = skuobj.DefaultStoreDict[mindefaultstorename] @@ -3221,19 +3663,22 @@ class DscBuildData(PlatformBuildClassObject): nextskuid =3D self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: nextskuid =3D self.SkuIdMgr.GetNextSkuId(nextskuid) - PcdObj.SkuInfoList[skuname] =3D copy.deepcopy(PcdObj.S= kuInfoList[nextskuid]) + PcdObj.SkuInfoList[skuname] =3D copy.deepcopy( + PcdObj.SkuInfoList[nextskuid]) PcdObj.SkuInfoList[skuname].SkuId =3D skuid PcdObj.SkuInfoList[skuname].SkuIdName =3D skuname if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], = self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: - PcdObj.DefaultValue =3D list(PcdObj.SkuInfoList.values())[= 0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType =3D=3D self.SkuIdMgr.SINGL= E else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultValue - Pcds[PcdCName, TokenSpaceGuid]=3D PcdObj + PcdObj.DefaultValue =3D list(PcdObj.SkuInfoList.values())[ + 0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType =3D= =3D self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList[TAB_DEFAULT].HiiDefaultVal= ue + Pcds[PcdCName, TokenSpaceGuid] =3D PcdObj return Pcds - ## Retrieve dynamic HII PCD settings + # Retrieve dynamic HII PCD settings # # @param Type PCD type # # @retval a dict object contains settings of given PCD type # + def _GetDynamicHiiPcd(self, Type): =20 VariableAttrs =3D {} @@ -3258,31 +3703,34 @@ class DscBuildData(PlatformBuildClassObject): if DefaultStore =3D=3D TAB_COMMON: DefaultStore =3D TAB_DEFAULT_STORES_DEFAULT else: - #The end user define [DefaultStores] and [SKUID_IDENTIFIER= .Menufacturing] in DSC + # The end user define [DefaultStores] and [SKUID_IDENTIFIE= R.Menufacturing] in DSC UserDefinedDefaultStores.append((PcdCName, TokenSpaceGuid)) if SkuName not in AvailableSkuIdSet: EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not= defined in [SkuIds] section' % SkuName, - File=3Dself.MetaFile, Line=3DD= ummy5) + File=3Dself.MetaFile, Line=3DDummy5) if DefaultStore not in DefaultStoresDefine: EdkLogger.error('build', PARAMETER_INVALID, 'DefaultStores= %s is not defined in [DefaultStores] section' % DefaultStore, - File=3Dself.MetaFile, Line=3DD= ummy5) + File=3Dself.MetaFile, Line=3DDummy5) if "." not in TokenSpaceGuid and "[" not in PcdCName and (PcdC= Name, TokenSpaceGuid, SkuName, DefaultStore, Dummy5) not in PcdList: - PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Default= Store, Dummy5)) - PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid, DefaultStore]= =3D Setting - + PcdList.append((PcdCName, TokenSpaceGuid, + SkuName, DefaultStore, Dummy5)) + PcdDict[Arch, SkuName, PcdCName, + TokenSpaceGuid, DefaultStore] =3D Setting =20 # Remove redundant PCD candidates, per the ARCH and SKU - for index,(PcdCName, TokenSpaceGuid, SkuName, DefaultStore, Dummy4= ) in enumerate(PcdList): + for index, (PcdCName, TokenSpaceGuid, SkuName, DefaultStore, Dummy= 4) in enumerate(PcdList): =20 - Setting =3D PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceG= uid, DefaultStore] + Setting =3D PcdDict[self._Arch, SkuName, + PcdCName, TokenSpaceGuid, DefaultStore] if Setting is None: continue - VariableName, VariableGuid, VariableOffset, DefaultValue, VarA= ttribute =3D self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dum= my4) + VariableName, VariableGuid, VariableOffset, DefaultValue, VarA= ttribute =3D self._ValidatePcd( + PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) =20 rt, Msg =3D VariableAttributes.ValidateVarAttributes(VarAttrib= ute) if not rt: EdkLogger.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR, "V= ariable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSp= aceGuid, PcdCName)), Msg), - ExtraData=3D"[%s]" % VarAttribute) + ExtraData=3D"[%s]" % VarAttribute) ExceedMax =3D False FormatCorrect =3D True if VariableOffset.isdigit(): @@ -3301,42 +3749,49 @@ class DscBuildData(PlatformBuildClassObject): else: FormatCorrect =3D False if not FormatCorrect: - EdkLogger.error('Build', FORMAT_INVALID, "Invalid syntax o= r format of the variable offset value is incorrect for %s." % ".".join((Tok= enSpaceGuid, PcdCName))) + EdkLogger.error('Build', FORMAT_INVALID, "Invalid syntax o= r format of the variable offset value is incorrect for %s." % ".".join( + (TokenSpaceGuid, PcdCName))) =20 if ExceedMax: - EdkLogger.error('Build', OPTION_VALUE_INVALID, "The variab= le offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s= ." % ".".join((TokenSpaceGuid, PcdCName))) + EdkLogger.error('Build', OPTION_VALUE_INVALID, "The variab= le offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s= ." % ".".join( + (TokenSpaceGuid, PcdCName))) if (VariableName, VariableGuid) not in VariableAttrs: VariableAttrs[(VariableName, VariableGuid)] =3D VarAttribu= te else: if not DscBuildData.CompareVarAttr(VariableAttrs[(Variable= Name, VariableGuid)], VarAttribute): - EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFL= ICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attribut= es [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAtt= rs[(VariableName, VariableGuid)])) + EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFL= ICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attribut= es [%s] and [%s] " % ( + VariableGuid, VariableName, VarAttribute, Variable= Attrs[(VariableName, VariableGuid)])) =20 pcdDecObject =3D self._DecPcds[PcdCName, TokenSpaceGuid] if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] if SkuName in pcdObject.SkuInfoList: Skuitem =3D pcdObject.SkuInfoList[SkuName] - Skuitem.DefaultStoreDict.update({DefaultStore:DefaultV= alue}) + Skuitem.DefaultStoreDict.update( + {DefaultStore: DefaultValue}) else: - SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName]= [0], VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttr= ibute=3DVarAttribute, DefaultStore=3D{DefaultStore:DefaultValue}) + SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName]= [0], VariableName, VariableGuid, VariableOffset, + DefaultValue, VariableAttribute= =3DVarAttribute, DefaultStore=3D{DefaultStore: DefaultValue}) pcdObject.SkuInfoList[SkuName] =3D SkuInfo else: - SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0],= VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttribut= e=3DVarAttribute, DefaultStore=3D{DefaultStore:DefaultValue}) + SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0],= VariableName, VariableGuid, VariableOffset, + DefaultValue, VariableAttribute=3DV= arAttribute, DefaultStore=3D{DefaultStore: DefaultValue}) PcdClassObj =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - self._PCD_TYPE_STRING_[Typ= e], - '', - DefaultValue, - '', - '', - OrderedDict({SkuName : Sku= Info}), - False, - None, - pcdDecObject.validaterange= s, - pcdDecObject.validlists, - pcdDecObject.expressions, - IsDsc=3DTrue) + PcdCName, + TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type], + '', + DefaultValue, + '', + '', + OrderedDict( + {SkuName: SkuInfo}), + False, + None, + pcdDecObject.validateranges, + pcdDecObject.validlists, + pcdDecObject.expressions, + IsDsc=3DTrue) if (PcdCName, TokenSpaceGuid) in UserDefinedDefaultStores: PcdClassObj.UserDefinedDefaultStoresFlag =3D True Pcds[PcdCName, TokenSpaceGuid] =3D PcdClassObj @@ -3346,21 +3801,24 @@ class DscBuildData(PlatformBuildClassObject): Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][DefaultSto= re] =3D DefaultValue - Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][Defaul= tStore] =3D (self.MetaFile.File,Dummy4) + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][Defaul= tStore] =3D ( + self.MetaFile.File, Dummy4) for pcd in Pcds.values(): - pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpaceG= uidCName] + pcdDecObject =3D self._DecPcds[pcd.TokenCName, + pcd.TokenSpaceGuidCName] pcd.DatumType =3D pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): if (sku.HiiDefaultValue =3D=3D "" or sku.HiiDefaultValue i= s None): sku.HiiDefaultValue =3D pcdDecObject.DefaultValue for default_store in sku.DefaultStoreDict: - sku.DefaultStoreDict[default_store]=3DpcdDecObject= .DefaultValue + sku.DefaultStoreDict[default_store] =3D pcdDecObje= ct.DefaultValue pcd.DefaultValue =3D pcdDecObject.DefaultValue if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pc= d.SkuInfoList: SkuInfoObj =3D list(pcd.SkuInfoList.values())[0] valuefromDec =3D pcdDecObject.DefaultValue - SkuInfo =3D SkuInfoClass(TAB_DEFAULT, '0', SkuInfoObj.Vari= ableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,= VariableAttribute=3DSkuInfoObj.VariableAttribute, DefaultStore=3D{DefaultS= tore:valuefromDec}) + SkuInfo =3D SkuInfoClass(TAB_DEFAULT, '0', SkuInfoObj.Vari= ableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, + valuefromDec, VariableAttribute=3DS= kuInfoObj.VariableAttribute, DefaultStore=3D{DefaultStore: valuefromDec}) pcd.SkuInfoList[TAB_DEFAULT] =3D SkuInfo elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.= SkuInfoList: pcd.SkuInfoList[TAB_DEFAULT] =3D pcd.SkuInfoList[TAB_COMMO= N] @@ -3375,18 +3833,21 @@ class DscBuildData(PlatformBuildClassObject): if pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: for (_, skuobj) in pcd.SkuInfoList.items(): datalen =3D 0 - skuobj.HiiDefaultValue =3D StringToArray(skuobj.HiiDef= aultValue) + skuobj.HiiDefaultValue =3D StringToArray( + skuobj.HiiDefaultValue) datalen =3D len(skuobj.HiiDefaultValue.split(",")) if datalen > MaxSize: MaxSize =3D datalen for defaultst in skuobj.DefaultStoreDict: - skuobj.DefaultStoreDict[defaultst] =3D StringToArr= ay(skuobj.DefaultStoreDict[defaultst]) + skuobj.DefaultStoreDict[defaultst] =3D StringToArr= ay( + skuobj.DefaultStoreDict[defaultst]) pcd.DefaultValue =3D StringToArray(pcd.DefaultValue) pcd.MaxDatumSize =3D str(MaxSize) rt, invalidhii =3D DscBuildData.CheckVariableNameAssignment(Pcds) if not rt: invalidpcd =3D ",".join(invalidhii) - EdkLogger.error('build', PCD_VARIABLE_INFO_ERROR, Message=3D'T= he same HII PCD must map to the same EFI variable for all SKUs', File=3Dsel= f.MetaFile, ExtraData=3Dinvalidpcd) + EdkLogger.error('build', PCD_VARIABLE_INFO_ERROR, + Message=3D'The same HII PCD must map to the sa= me EFI variable for all SKUs', File=3Dself.MetaFile, ExtraData=3Dinvalidpcd) =20 list(map(self.FilterSkuSettings, Pcds.values())) =20 @@ -3397,22 +3858,23 @@ class DscBuildData(PlatformBuildClassObject): invalidhii =3D [] for pcdname in Pcds: pcd =3D Pcds[pcdname] - varnameset =3D set(sku.VariableName for (skuid, sku) in pcd.Sk= uInfoList.items()) + varnameset =3D set(sku.VariableName for ( + skuid, sku) in pcd.SkuInfoList.items()) if len(varnameset) > 1: invalidhii.append(".".join((pcdname[1], pcdname[0]))) if len(invalidhii): return False, invalidhii else: return True, [] - ## Retrieve dynamic VPD PCD settings + # Retrieve dynamic VPD PCD settings # # @param Type PCD type # # @retval a dict object contains settings of given PCD type # + def _GetDynamicVpdPcd(self, Type): =20 - Pcds =3D OrderedDict() # # tdict is a special dict kind of type, used for selecting correct @@ -3430,7 +3892,7 @@ class DscBuildData(PlatformBuildClassObject): SkuName =3D TAB_DEFAULT if SkuName =3D=3D TAB_COMMON else SkuN= ame if SkuName not in AvailableSkuIdSet: EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not= defined in [SkuIds] section' % SkuName, - File=3Dself.MetaFile, Line=3DD= ummy5) + File=3Dself.MetaFile, Line=3DDummy5) if "." not in TokenSpaceGuid and "[" not in PcdCName and (PcdC= Name, TokenSpaceGuid, SkuName, Dummy5) not in PcdList: PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5)) PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] =3D Setting @@ -3446,7 +3908,8 @@ class DscBuildData(PlatformBuildClassObject): # At this point, we put all the data into the PcdClssObject fo= r we don't know the PCD's datumtype # until the DEC parser has been called. # - VpdOffset, MaxDatumSize, InitialValue =3D self._ValidatePcd(Pc= dCName, TokenSpaceGuid, Setting, Type, Dummy4) + VpdOffset, MaxDatumSize, InitialValue =3D self._ValidatePcd( + PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) if MaxDatumSize: if int(MaxDatumSize, 0) > 0xFFFF: EdkLogger.error('build', FORMAT_INVALID, "The size val= ue must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join= ((TokenSpaceGuid, PcdCName)), @@ -3454,7 +3917,8 @@ class DscBuildData(PlatformBuildClassObject): if int(MaxDatumSize, 0) < 0: EdkLogger.error('build', FORMAT_INVALID, "The size val= ue can't be set to negative value for %s." % ".".join((TokenSpaceGuid, PcdC= Name)), File=3Dself.MetaFile, Line=3DDummy4) - SkuInfo =3D SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '',= '', '', '', VpdOffset, InitialValue) + SkuInfo =3D SkuInfoClass( + SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffse= t, InitialValue) if (PcdCName, TokenSpaceGuid) in Pcds: pcdObject =3D Pcds[PcdCName, TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] =3D SkuInfo @@ -3470,25 +3934,28 @@ class DscBuildData(PlatformBuildClassObject): pcdObject.MaxDatumSize =3D str(CurrentMaxSize) else: Pcds[PcdCName, TokenSpaceGuid] =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - self._PCD_TYPE_STRING_[Typ= e], - '', - InitialValue, - '', - MaxDatumSize, - OrderedDict({SkuName : Sku= Info}), - False, - None, - IsDsc=3DTrue) + PcdCName, + TokenSpaceGuid, + self._PCD_TYPE_STRING_[Type], + '', + InitialValue, + '', + MaxDatumSize, + OrderedDict( + {SkuName: SkuInfo}), + False, + None, + IsDsc=3DTrue) =20 if SkuName not in Pcds[PcdCName, TokenSpaceGuid].DscRawValue: Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName] =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName] = =3D {} Pcds[PcdCName, TokenSpaceGuid].DscRawValue[SkuName][TAB_DEFAUL= T_STORES_DEFAULT] =3D InitialValue - Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_DE= FAULT_STORES_DEFAULT] =3D (self.MetaFile.File,Dummy4) + Pcds[PcdCName, TokenSpaceGuid].DscRawValueInfo[SkuName][TAB_DE= FAULT_STORES_DEFAULT] =3D ( + self.MetaFile.File, Dummy4) for pcd in Pcds.values(): - pcdDecObject =3D self._DecPcds[pcd.TokenCName, pcd.TokenSpaceG= uidCName] + pcdDecObject =3D self._DecPcds[pcd.TokenCName, + pcd.TokenSpaceGuidCName] pcd.DatumType =3D pcdDecObject.DatumType # Only fix the value while no value provided in DSC file. for sku in pcd.SkuInfoList.values(): @@ -3497,7 +3964,8 @@ class DscBuildData(PlatformBuildClassObject): if TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON not in pc= d.SkuInfoList: SkuInfoObj =3D list(pcd.SkuInfoList.values())[0] valuefromDec =3D pcdDecObject.DefaultValue - SkuInfo =3D SkuInfoClass(TAB_DEFAULT, '0', '', '', '', '',= SkuInfoObj.VpdOffset, valuefromDec) + SkuInfo =3D SkuInfoClass( + TAB_DEFAULT, '0', '', '', '', '', SkuInfoObj.VpdOffset= , valuefromDec) pcd.SkuInfoList[TAB_DEFAULT] =3D SkuInfo elif TAB_DEFAULT not in pcd.SkuInfoList and TAB_COMMON in pcd.= SkuInfoList: pcd.SkuInfoList[TAB_DEFAULT] =3D pcd.SkuInfoList[TAB_COMMO= N] @@ -3505,20 +3973,22 @@ class DscBuildData(PlatformBuildClassObject): elif TAB_DEFAULT in pcd.SkuInfoList and TAB_COMMON in pcd.SkuI= nfoList: del pcd.SkuInfoList[TAB_COMMON] =20 - #For the same one VOID* pcd, if the default value type of one SKU = is "Unicode string", - #the other SKUs are "OtherVOID*"(ASCII string or byte array),Then = convert "Unicode string" to "byte array". + # For the same one VOID* pcd, if the default value type of one SKU= is "Unicode string", + # the other SKUs are "OtherVOID*"(ASCII string or byte array),Then= convert "Unicode string" to "byte array". for pcd in Pcds.values(): PcdValueTypeSet =3D set() for sku in pcd.SkuInfoList.values(): - PcdValueTypeSet.add("UnicodeString" if sku.DefaultValue.st= artswith(('L"',"L'")) else "OtherVOID*") + PcdValueTypeSet.add("UnicodeString" if sku.DefaultValue.st= artswith( + ('L"', "L'")) else "OtherVOID*") if len(PcdValueTypeSet) > 1: for sku in pcd.SkuInfoList.values(): - sku.DefaultValue =3D StringToArray(sku.DefaultValue) i= f sku.DefaultValue.startswith(('L"',"L'")) else sku.DefaultValue + sku.DefaultValue =3D StringToArray(sku.DefaultValue) i= f sku.DefaultValue.startswith( + ('L"', "L'")) else sku.DefaultValue =20 list(map(self.FilterSkuSettings, Pcds.values())) return Pcds =20 - ## Add external modules + # Add external modules # # The external modules are mostly those listed in FDF file, which do= n't # need "build". @@ -3537,13 +4007,16 @@ class DscBuildData(PlatformBuildClassObject): self._ToolChainFamily =3D TAB_COMPILER_MSFT TargetObj =3D TargetTxtDict() TargetTxt =3D TargetObj.Target - BuildConfigurationFile =3D os.path.normpath(os.path.join(GlobalDat= a.gConfDirectory, gDefaultTargetTxtFile)) + BuildConfigurationFile =3D os.path.normpath(os.path.join( + GlobalData.gConfDirectory, gDefaultTargetTxtFile)) if os.path.isfile(BuildConfigurationFile) =3D=3D True: ToolDefinitionFile =3D TargetTxt.TargetTxtDictionary[DataType.= TAB_TAT_DEFINES_TOOL_CHAIN_CONF] if ToolDefinitionFile =3D=3D '': - ToolDefinitionFile =3D os.path.normpath(mws.join(self.Work= spaceDir, 'Conf', gDefaultToolsDefFile)) + ToolDefinitionFile =3D os.path.normpath( + mws.join(self.WorkspaceDir, 'Conf', gDefaultToolsDefFi= le)) if os.path.isfile(ToolDefinitionFile) =3D=3D True: - ToolDefObj =3D ToolDefDict((os.path.join(os.getenv("WORKSP= ACE"), "Conf"))) + ToolDefObj =3D ToolDefDict( + (os.path.join(os.getenv("WORKSPACE"), "Conf"))) ToolDefinition =3D ToolDefObj.ToolDef.ToolsDefTxtDatabase if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \ or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINE= S_FAMILY] \ @@ -3553,7 +4026,7 @@ class DscBuildData(PlatformBuildClassObject): self._ToolChainFamily =3D ToolDefinition[TAB_TOD_DEFIN= ES_FAMILY][self._Toolchain] return self._ToolChainFamily =20 - ## Add external PCDs + # Add external PCDs # # The external PCDs are mostly those listed in FDF file to specify a= ddress # or offset information. @@ -3564,7 +4037,8 @@ class DscBuildData(PlatformBuildClassObject): # def AddPcd(self, Name, Guid, Value): if (Name, Guid) not in self.Pcds: - self.Pcds[Name, Guid] =3D PcdClassObject(Name, Guid, '', '', '= ', '', '', {}, False, None) + self.Pcds[Name, Guid] =3D PcdClassObject( + Name, Guid, '', '', '', '', '', {}, False, None) self.Pcds[Name, Guid].DefaultValue =3D Value =20 @property @@ -3575,13 +4049,16 @@ class DscBuildData(PlatformBuildClassObject): FdfInfList =3D GlobalData.gFdfParser.Profile.InfList PkgSet =3D set() for Inf in FdfInfList: - ModuleFile =3D PathClass(NormPath(Inf), GlobalData.gWorksp= ace, Arch=3Dself._Arch) + ModuleFile =3D PathClass( + NormPath(Inf), GlobalData.gWorkspace, Arch=3Dself._Arc= h) if ModuleFile in self._Modules: continue - ModuleData =3D self._Bdb[ModuleFile, self._Arch, self._Tar= get, self._Toolchain] + ModuleData =3D self._Bdb[ModuleFile, + self._Arch, self._Target, self._Too= lchain] PkgSet.update(ModuleData.Packages) if self.Packages: PkgSet.update(self.Packages) - self._DecPcds, self._GuidDict =3D GetDeclaredPcd(self, self._B= db, self._Arch, self._Target, self._Toolchain, PkgSet) + self._DecPcds, self._GuidDict =3D GetDeclaredPcd( + self, self._Bdb, self._Arch, self._Target, self._Toolchain= , PkgSet) self._GuidDict.update(GlobalData.gPlatformPcds) return self._DecPcds diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index e4ff1c668666..4a28c0991c3a 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by build tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -16,7 +16,7 @@ from collections import OrderedDict from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClas= sObject, PcdClassObject from Common.Expression import ValueExpressionEx, PcdPattern =20 -## Get Protocol value from given packages +# Get Protocol value from given packages # # @param CName The CName of the GUID # @param PackageList List of packages looking-up in @@ -25,17 +25,20 @@ from Common.Expression import ValueExpressionEx, PcdPat= tern # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # -def _ProtocolValue(CName, PackageList, Inffile =3D None): + + +def _ProtocolValue(CName, PackageList, Inffile=3DNone): for P in PackageList: ProtocolKeys =3D list(P.Protocols.keys()) if Inffile and P._PrivateProtocols: if not Inffile.startswith(P.MetaFile.Dir): - ProtocolKeys =3D [x for x in P.Protocols if x not in P._Pr= ivateProtocols] + ProtocolKeys =3D [ + x for x in P.Protocols if x not in P._PrivateProtocols] if CName in ProtocolKeys: return P.Protocols[CName] return None =20 -## Get PPI value from given packages +# Get PPI value from given packages # # @param CName The CName of the GUID # @param PackageList List of packages looking-up in @@ -44,7 +47,9 @@ def _ProtocolValue(CName, PackageList, Inffile =3D None): # @retval GuidValue if the CName is found in any given package # @retval None if the CName is not found in all given packages # -def _PpiValue(CName, PackageList, Inffile =3D None): + + +def _PpiValue(CName, PackageList, Inffile=3DNone): for P in PackageList: PpiKeys =3D list(P.Ppis.keys()) if Inffile and P._PrivatePpis: @@ -54,11 +59,13 @@ def _PpiValue(CName, PackageList, Inffile =3D None): return P.Ppis[CName] return None =20 -## Module build information from INF file +# Module build information from INF file # # This class is used to retrieve information stored in database and conve= rt them # into ModuleBuildClassObject form for easier use for AutoGen. # + + class InfBuildData(ModuleBuildClassObject): =20 # dict used to convert part of [Defines] to members of InfBuildData di= rectly @@ -66,35 +73,35 @@ class InfBuildData(ModuleBuildClassObject): # # Required Fields # - TAB_INF_DEFINES_BASE_NAME : "_BaseName", - TAB_INF_DEFINES_FILE_GUID : "_Guid", - TAB_INF_DEFINES_MODULE_TYPE : "_ModuleType", + TAB_INF_DEFINES_BASE_NAME: "_BaseName", + TAB_INF_DEFINES_FILE_GUID: "_Guid", + TAB_INF_DEFINES_MODULE_TYPE: "_ModuleType", # # Optional Fields # # TAB_INF_DEFINES_INF_VERSION : "_AutoGenVersion", - TAB_INF_DEFINES_COMPONENT_TYPE : "_ComponentType", - TAB_INF_DEFINES_MAKEFILE_NAME : "_MakefileName", + TAB_INF_DEFINES_COMPONENT_TYPE: "_ComponentType", + TAB_INF_DEFINES_MAKEFILE_NAME: "_MakefileName", # TAB_INF_DEFINES_CUSTOM_MAKEFILE : "_CustomMakefile", - TAB_INF_DEFINES_DPX_SOURCE :"_DxsFile", - TAB_INF_DEFINES_VERSION_NUMBER : "_Version", - TAB_INF_DEFINES_VERSION_STRING : "_Version", - TAB_INF_DEFINES_VERSION : "_Version", - TAB_INF_DEFINES_PCD_IS_DRIVER : "_PcdIsDriver", - TAB_INF_DEFINES_SHADOW : "_Shadow" + TAB_INF_DEFINES_DPX_SOURCE: "_DxsFile", + TAB_INF_DEFINES_VERSION_NUMBER: "_Version", + TAB_INF_DEFINES_VERSION_STRING: "_Version", + TAB_INF_DEFINES_VERSION: "_Version", + TAB_INF_DEFINES_PCD_IS_DRIVER: "_PcdIsDriver", + TAB_INF_DEFINES_SHADOW: "_Shadow" } =20 # regular expression for converting XXX_FLAGS in [nmake] section to ne= w type - _NMAKE_FLAG_PATTERN_ =3D re.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|A= RCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE) + _NMAKE_FLAG_PATTERN_ =3D re.compile( + "(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?",= re.UNICODE) # dict used to convert old tool name used in [nmake] section to new on= es _TOOL_CODE_ =3D { - "C" : "CC", - BINARY_FILE_TYPE_LIB : "SLINK", - "LINK" : "DLINK", + "C": "CC", + BINARY_FILE_TYPE_LIB: "SLINK", + "LINK": "DLINK", } =20 - - ## Constructor of InfBuildData + # Constructor of InfBuildData # # Initialize object of InfBuildData # @@ -105,6 +112,7 @@ class InfBuildData(ModuleBuildClassObject): # @param Platform The name of platform employing this mo= dule # @param Macros Macros used for replacement in DSC file # + def __init__(self, FilePath, RawData, BuildDatabase, Arch=3DTAB_ARCH_C= OMMON, Target=3DNone, Toolchain=3DNone): self.MetaFile =3D FilePath self._ModuleDir =3D FilePath.Dir @@ -145,7 +153,7 @@ class InfBuildData(ModuleBuildClassObject): self.LibInstances =3D [] self.ReferenceModules =3D set() =20 - def SetReferenceModule(self,Module): + def SetReferenceModule(self, Module): self.ReferenceModules.add(Module) return self =20 @@ -157,22 +165,22 @@ class InfBuildData(ModuleBuildClassObject): def __getitem__(self, key): return self.__dict__[self._PROPERTY_[key]] =20 - ## "in" test support + # "in" test support def __contains__(self, key): return key in self._PROPERTY_ =20 - ## Get current effective macros + # Get current effective macros @cached_property def _Macros(self): RetVal =3D {} return RetVal =20 - ## Get architecture + # Get architecture @cached_property def Arch(self): return self._Arch =20 - ## Return the name of platform employing this module + # Return the name of platform employing this module @cached_property def Platform(self): return self._Platform @@ -185,15 +193,17 @@ class InfBuildData(ModuleBuildClassObject): def TailComments(self): return [a[0] for a in self._RawData[MODEL_META_DATA_TAIL_COMMENT]] =20 - ## Retrieve all information in [Defines] section + # Retrieve all information in [Defines] section # # (Retrieving all [Defines] information in one-shot is just to save = time.) # @cached_class_function def _GetHeaderInfo(self): - RecordList =3D self._RawData[MODEL_META_DATA_HEADER, self._Arch, s= elf._Platform] + RecordList =3D self._RawData[MODEL_META_DATA_HEADER, + self._Arch, self._Platform] for Record in RecordList: - Name, Value =3D Record[1], ReplaceMacro(Record[2], self._Macro= s, False) + Name, Value =3D Record[1], ReplaceMacro( + Record[2], self._Macros, False) # items defined _PROPERTY_ don't need additional processing if Name in self: self[Name] =3D Value @@ -208,7 +218,8 @@ class InfBuildData(ModuleBuildClassObject): self._Specification[Name] =3D GetHexVerValue(Value) if self._Specification[Name] is None: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, - "'%s' format is not supported for %s" = % (Value, Name), + "'%s' format is not supported for %s" = % ( + Value, Name), File=3Dself.MetaFile, Line=3DRecord[-1= ]) elif Name =3D=3D 'LIBRARY_CLASS': if self._LibraryClass is None: @@ -219,7 +230,8 @@ class InfBuildData(ModuleBuildClassObject): SupModuleList =3D GetSplitValueList(ValueList[1], ' ') else: SupModuleList =3D SUP_MODULE_LIST - self._LibraryClass.append(LibraryClassObject(LibraryClass,= SupModuleList)) + self._LibraryClass.append( + LibraryClassObject(LibraryClass, SupModuleList)) elif Name =3D=3D 'ENTRY_POINT': if self._ModuleEntryPointList is None: self._ModuleEntryPointList =3D [] @@ -266,38 +278,45 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "MODULE_TYPE is not given", File=3Dself.MetaFi= le) if self._ModuleType not in SUP_MODULE_LIST: - RecordList =3D self._RawData[MODEL_META_DATA_HEADER, self._Arc= h, self._Platform] + RecordList =3D self._RawData[MODEL_META_DATA_HEADER, + self._Arch, self._Platform] for Record in RecordList: Name =3D Record[1] if Name =3D=3D "MODULE_TYPE": LineNo =3D Record[6] break EdkLogger.error("build", FORMAT_NOT_SUPPORTED, - "MODULE_TYPE %s is not supported for EDK II, v= alid values are:\n %s" % (self._ModuleType, ' '.join(l for l in SUP_MODULE_= LIST)), + "MODULE_TYPE %s is not supported for EDK II, v= alid values are:\n %s" % ( + self._ModuleType, ' '.join(l for l in SUP_= MODULE_LIST)), File=3Dself.MetaFile, Line=3DLineNo) if (self._Specification is None) or (not 'PI_SPECIFICATION_VERSION= ' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VER= SION'], 16) < 0x0001000A): if self._ModuleType =3D=3D SUP_MODULE_SMM_CORE: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE m= odule type can't be used in the module with PI_SPECIFICATION_VERSION less t= han 0x0001000A", File=3Dself.MetaFile) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "SMM_CORE module type can't be used in the= module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=3Dself.Me= taFile) if (self._Specification is None) or (not 'PI_SPECIFICATION_VERSION= ' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VER= SION'], 16) < 0x00010032): if self._ModuleType =3D=3D SUP_MODULE_MM_CORE_STANDALONE: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_ST= ANDALONE module type can't be used in the module with PI_SPECIFICATION_VERS= ION less than 0x00010032", File=3Dself.MetaFile) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "MM_CORE_STANDALONE module type can't be u= sed in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File= =3Dself.MetaFile) if self._ModuleType =3D=3D SUP_MODULE_MM_STANDALONE: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDAL= ONE module type can't be used in the module with PI_SPECIFICATION_VERSION l= ess than 0x00010032", File=3Dself.MetaFile) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "MM_STANDALONE module type can't be used i= n the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=3Dse= lf.MetaFile) if 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs= \ and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._= Defs: self._BuildType =3D 'UEFI_OPTIONROM' if 'PCI_COMPRESS' in self._Defs: if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'): - EdkLogger.error("build", FORMAT_INVALID, "Expected TRU= E/FALSE for PCI_COMPRESS: %s" % self.MetaFile) + EdkLogger.error( + "build", FORMAT_INVALID, "Expected TRUE/FALSE for = PCI_COMPRESS: %s" % self.MetaFile) =20 elif 'UEFI_HII_RESOURCE_SECTION' in self._Defs \ - and self._Defs['UEFI_HII_RESOURCE_SECTION'] =3D=3D 'TRUE': + and self._Defs['UEFI_HII_RESOURCE_SECTION'] =3D=3D 'TRUE': self._BuildType =3D 'UEFI_HII' else: self._BuildType =3D self._ModuleType.upper() =20 if self._DxsFile: - File =3D PathClass(NormPath(self._DxsFile), self._ModuleDir, A= rch=3Dself._Arch) + File =3D PathClass(NormPath(self._DxsFile), + self._ModuleDir, Arch=3Dself._Arch) # check the file validation ErrorCode, ErrorInfo =3D File.Validate(".dxs", CaseSensitive= =3DFalse) if ErrorCode !=3D 0: @@ -307,11 +326,12 @@ class InfBuildData(ModuleBuildClassObject): self._DependencyFileList =3D [] self._DependencyFileList.append(File) =20 - ## Retrieve file version + # Retrieve file version @cached_property def AutoGenVersion(self): RetVal =3D 0x00010000 - RecordList =3D self._RawData[MODEL_META_DATA_HEADER, self._Arch, s= elf._Platform] + RecordList =3D self._RawData[MODEL_META_DATA_HEADER, + self._Arch, self._Platform] for Record in RecordList: if Record[1] =3D=3D TAB_INF_DEFINES_INF_VERSION: if '.' in Record[2]: @@ -324,16 +344,17 @@ class InfBuildData(ModuleBuildClassObject): break return RetVal =20 - ## Retrieve BASE_NAME + # Retrieve BASE_NAME @cached_property def BaseName(self): if self._BaseName is None: self._GetHeaderInfo() if self._BaseName is None: - EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BASE= _NAME name", File=3Dself.MetaFile) + EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, + "No BASE_NAME name", File=3Dself.MetaFile) return self._BaseName =20 - ## Retrieve DxsFile + # Retrieve DxsFile @cached_property def DxsFile(self): if self._DxsFile is None: @@ -342,7 +363,7 @@ class InfBuildData(ModuleBuildClassObject): self._DxsFile =3D '' return self._DxsFile =20 - ## Retrieve MODULE_TYPE + # Retrieve MODULE_TYPE @cached_property def ModuleType(self): if self._ModuleType is None: @@ -353,7 +374,7 @@ class InfBuildData(ModuleBuildClassObject): self._ModuleType =3D SUP_MODULE_USER_DEFINED return self._ModuleType =20 - ## Retrieve COMPONENT_TYPE + # Retrieve COMPONENT_TYPE @cached_property def ComponentType(self): if self._ComponentType is None: @@ -362,7 +383,7 @@ class InfBuildData(ModuleBuildClassObject): self._ComponentType =3D SUP_MODULE_USER_DEFINED return self._ComponentType =20 - ## Retrieve "BUILD_TYPE" + # Retrieve "BUILD_TYPE" @cached_property def BuildType(self): if self._BuildType is None: @@ -371,7 +392,7 @@ class InfBuildData(ModuleBuildClassObject): self._BuildType =3D SUP_MODULE_BASE return self._BuildType =20 - ## Retrieve file guid + # Retrieve file guid @cached_property def Guid(self): if self._Guid is None: @@ -380,7 +401,7 @@ class InfBuildData(ModuleBuildClassObject): self._Guid =3D '00000000-0000-0000-0000-000000000000' return self._Guid =20 - ## Retrieve module version + # Retrieve module version @cached_property def Version(self): if self._Version is None: @@ -389,7 +410,7 @@ class InfBuildData(ModuleBuildClassObject): self._Version =3D '0.0' return self._Version =20 - ## Retrieve PCD_IS_DRIVER + # Retrieve PCD_IS_DRIVER @cached_property def PcdIsDriver(self): if self._PcdIsDriver is None: @@ -398,7 +419,7 @@ class InfBuildData(ModuleBuildClassObject): self._PcdIsDriver =3D '' return self._PcdIsDriver =20 - ## Retrieve SHADOW + # Retrieve SHADOW @cached_property def Shadow(self): if self._Shadow is None: @@ -409,7 +430,7 @@ class InfBuildData(ModuleBuildClassObject): self._Shadow =3D False return self._Shadow =20 - ## Retrieve CUSTOM_MAKEFILE + # Retrieve CUSTOM_MAKEFILE @cached_property def CustomMakefile(self): if self._CustomMakefile is None: @@ -418,7 +439,7 @@ class InfBuildData(ModuleBuildClassObject): self._CustomMakefile =3D {} return self._CustomMakefile =20 - ## Retrieve EFI_SPECIFICATION_VERSION + # Retrieve EFI_SPECIFICATION_VERSION @cached_property def Specification(self): if self._Specification is None: @@ -427,7 +448,7 @@ class InfBuildData(ModuleBuildClassObject): self._Specification =3D {} return self._Specification =20 - ## Retrieve LIBRARY_CLASS + # Retrieve LIBRARY_CLASS @cached_property def LibraryClass(self): if self._LibraryClass is None: @@ -436,7 +457,7 @@ class InfBuildData(ModuleBuildClassObject): self._LibraryClass =3D [] return self._LibraryClass =20 - ## Retrieve ENTRY_POINT + # Retrieve ENTRY_POINT @cached_property def ModuleEntryPointList(self): if self._ModuleEntryPointList is None: @@ -445,7 +466,7 @@ class InfBuildData(ModuleBuildClassObject): self._ModuleEntryPointList =3D [] return self._ModuleEntryPointList =20 - ## Retrieve UNLOAD_IMAGE + # Retrieve UNLOAD_IMAGE @cached_property def ModuleUnloadImageList(self): if self._ModuleUnloadImageList is None: @@ -454,7 +475,7 @@ class InfBuildData(ModuleBuildClassObject): self._ModuleUnloadImageList =3D [] return self._ModuleUnloadImageList =20 - ## Retrieve CONSTRUCTOR + # Retrieve CONSTRUCTOR @cached_property def ConstructorList(self): if self._ConstructorList is None: @@ -463,7 +484,7 @@ class InfBuildData(ModuleBuildClassObject): self._ConstructorList =3D [] return self._ConstructorList =20 - ## Retrieve DESTRUCTOR + # Retrieve DESTRUCTOR @cached_property def DestructorList(self): if self._DestructorList is None: @@ -472,17 +493,18 @@ class InfBuildData(ModuleBuildClassObject): self._DestructorList =3D [] return self._DestructorList =20 - ## Retrieve definies other than above ones + # Retrieve definies other than above ones @cached_property def Defines(self): self._GetHeaderInfo() return self._Defs =20 - ## Retrieve binary files + # Retrieve binary files @cached_class_function def _GetBinaries(self): RetVal =3D [] - RecordList =3D self._RawData[MODEL_EFI_BINARY_FILE, self._Arch, se= lf._Platform] + RecordList =3D self._RawData[MODEL_EFI_BINARY_FILE, + self._Arch, self._Platform] Macros =3D self._Macros Macros['PROCESSOR'] =3D self._Arch for Record in RecordList: @@ -497,25 +519,28 @@ class InfBuildData(ModuleBuildClassObject): if len(TokenList) > 1: FeatureFlag =3D Record[1:] =20 - File =3D PathClass(NormPath(Record[1], Macros), self._ModuleDi= r, '', FileType, True, self._Arch, '', Target) + File =3D PathClass(NormPath( + Record[1], Macros), self._ModuleDir, '', FileType, True, s= elf._Arch, '', Target) # check the file validation ErrorCode, ErrorInfo =3D File.Validate() if ErrorCode !=3D 0: - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorInfo,= File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3Dself= .MetaFile, Line=3DLineNo) RetVal.append(File) return RetVal =20 - ## Retrieve binary files with error check. + # Retrieve binary files with error check. @cached_property def Binaries(self): RetVal =3D self._GetBinaries() if GlobalData.gIgnoreSource and not RetVal: ErrorInfo =3D "The INF file does not contain any RetVal to use= in creating the image\n" - EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, ExtraData=3DE= rrorInfo, File=3Dself.MetaFile) + EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, + ExtraData=3DErrorInfo, File=3Dself.MetaFile) =20 return RetVal =20 - ## Retrieve source files + # Retrieve source files @cached_property def Sources(self): self._GetHeaderInfo() @@ -524,7 +549,8 @@ class InfBuildData(ModuleBuildClassObject): return [] =20 RetVal =3D [] - RecordList =3D self._RawData[MODEL_EFI_SOURCE_FILE, self._Arch, se= lf._Platform] + RecordList =3D self._RawData[MODEL_EFI_SOURCE_FILE, + self._Arch, self._Platform] Macros =3D self._Macros for Record in RecordList: LineNo =3D Record[-1] @@ -543,7 +569,8 @@ class InfBuildData(ModuleBuildClassObject): # check the file validation ErrorCode, ErrorInfo =3D File.Validate() if ErrorCode !=3D 0: - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorInfo,= File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3Dself= .MetaFile, Line=3DLineNo) =20 RetVal.append(File) # add any previously found dependency files to the source list @@ -551,11 +578,12 @@ class InfBuildData(ModuleBuildClassObject): RetVal.extend(self._DependencyFileList) return RetVal =20 - ## Retrieve library classes employed by this module + # Retrieve library classes employed by this module @cached_property def LibraryClasses(self): RetVal =3D OrderedDict() - RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, = self._Platform] + RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, + self._Arch, self._Platform] for Record in RecordList: Lib =3D Record[0] Instance =3D Record[1] @@ -566,11 +594,12 @@ class InfBuildData(ModuleBuildClassObject): RetVal[Lib] =3D None return RetVal =20 - ## Retrieve library names (for Edk.x style of modules) + # Retrieve library names (for Edk.x style of modules) @cached_property def Libraries(self): RetVal =3D [] - RecordList =3D self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self._Arc= h, self._Platform] + RecordList =3D self._RawData[MODEL_EFI_LIBRARY_INSTANCE, + self._Arch, self._Platform] for Record in RecordList: LibraryName =3D ReplaceMacro(Record[0], self._Macros, False) # in case of name with '.lib' extension, which is unusual in E= dk.x inf @@ -584,12 +613,13 @@ class InfBuildData(ModuleBuildClassObject): self.Protocols return self._ProtocolComments =20 - ## Retrieve protocols consumed/produced by this module + # Retrieve protocols consumed/produced by this module @cached_property def Protocols(self): RetVal =3D OrderedDict() self._ProtocolComments =3D OrderedDict() - RecordList =3D self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self.= _Platform] + RecordList =3D self._RawData[MODEL_EFI_PROTOCOL, + self._Arch, self._Platform] for Record in RecordList: CName =3D Record[0] Value =3D _ProtocolValue(CName, self.Packages, self.MetaFile.P= ath) @@ -599,7 +629,8 @@ class InfBuildData(ModuleBuildClassObject): "Value of Protocol [%s] is not found under= [Protocols] section in" % CName, ExtraData=3DPackageList, File=3Dself.MetaF= ile, Line=3DRecord[-1]) RetVal[CName] =3D Value - CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, self= ._Arch, self._Platform, Record[5]] + CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, + self._Arch, self._Platform, Rec= ord[5]] self._ProtocolComments[CName] =3D [a[0] for a in CommentRecord= s] return RetVal =20 @@ -608,7 +639,7 @@ class InfBuildData(ModuleBuildClassObject): self.Ppis return self._PpiComments =20 - ## Retrieve PPIs consumed/produced by this module + # Retrieve PPIs consumed/produced by this module @cached_property def Ppis(self): RetVal =3D OrderedDict() @@ -623,7 +654,8 @@ class InfBuildData(ModuleBuildClassObject): "Value of PPI [%s] is not found under [Ppi= s] section in " % CName, ExtraData=3DPackageList, File=3Dself.MetaF= ile, Line=3DRecord[-1]) RetVal[CName] =3D Value - CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, self= ._Arch, self._Platform, Record[5]] + CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, + self._Arch, self._Platform, Rec= ord[5]] self._PpiComments[CName] =3D [a[0] for a in CommentRecords] return RetVal =20 @@ -632,7 +664,7 @@ class InfBuildData(ModuleBuildClassObject): self.Guids return self._GuidComments =20 - ## Retrieve GUIDs consumed/produced by this module + # Retrieve GUIDs consumed/produced by this module @cached_property def Guids(self): RetVal =3D OrderedDict() @@ -647,17 +679,20 @@ class InfBuildData(ModuleBuildClassObject): "Value of Guid [%s] is not found under [Gu= ids] section in" % CName, ExtraData=3DPackageList, File=3Dself.MetaF= ile, Line=3DRecord[-1]) RetVal[CName] =3D Value - CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, self= ._Arch, self._Platform, Record[5]] + CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, + self._Arch, self._Platform, Rec= ord[5]] self._GuidComments[CName] =3D [a[0] for a in CommentRecords] =20 - for Type in [MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODUL= E,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX]: + for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODU= LE, MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]: RecordList =3D self._RawData[Type, self._Arch, self._Platform] for TokenSpaceGuid, _, _, _, _, _, LineNo in RecordList: # get the guid value if TokenSpaceGuid not in RetVal: - Value =3D GuidValue(TokenSpaceGuid, self.Packages, sel= f.MetaFile.Path) + Value =3D GuidValue( + TokenSpaceGuid, self.Packages, self.MetaFile.Path) if Value is None: - PackageList =3D "\n\t".join(str(P) for P in self.P= ackages) + PackageList =3D "\n\t".join(str(P) + for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of Guid [%s] is not found u= nder [Guids] section in" % TokenSpaceGuid, ExtraData=3DPackageList, File=3Dse= lf.MetaFile, Line=3DLineNo) @@ -665,13 +700,15 @@ class InfBuildData(ModuleBuildClassObject): self._GuidsUsedByPcd[TokenSpaceGuid] =3D Value return RetVal =20 - ## Retrieve include paths necessary for this module (for Edk.x style o= f modules) + # Retrieve include paths necessary for this module (for Edk.x style of= modules) @cached_property def Includes(self): RetVal =3D [] Macros =3D self._Macros - Macros['PROCESSOR'] =3D GlobalData.gEdkGlobal.get('PROCESSOR', sel= f._Arch) - RecordList =3D self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._= Platform] + Macros['PROCESSOR'] =3D GlobalData.gEdkGlobal.get( + 'PROCESSOR', self._Arch) + RecordList =3D self._RawData[MODEL_EFI_INCLUDE, + self._Arch, self._Platform] for Record in RecordList: File =3D NormPath(Record[0], Macros) if File[0] =3D=3D '.': @@ -683,30 +720,34 @@ class InfBuildData(ModuleBuildClassObject): RetVal.append(File) return RetVal =20 - ## Retrieve packages this module depends on + # Retrieve packages this module depends on @cached_property def Packages(self): RetVal =3D [] - RecordList =3D self._RawData[MODEL_META_DATA_PACKAGE, self._Arch, = self._Platform] + RecordList =3D self._RawData[MODEL_META_DATA_PACKAGE, + self._Arch, self._Platform] Macros =3D self._Macros for Record in RecordList: - File =3D PathClass(NormPath(Record[0], Macros), GlobalData.gWo= rkspace, Arch=3Dself._Arch) + File =3D PathClass( + NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch= =3Dself._Arch) # check the file validation ErrorCode, ErrorInfo =3D File.Validate('.dec') if ErrorCode !=3D 0: LineNo =3D Record[-1] - EdkLogger.error('build', ErrorCode, ExtraData=3DErrorInfo,= File=3Dself.MetaFile, Line=3DLineNo) + EdkLogger.error( + 'build', ErrorCode, ExtraData=3DErrorInfo, File=3Dself= .MetaFile, Line=3DLineNo) # parse this package now. we need it to get protocol/ppi/guid = value - RetVal.append(self._Bdb[File, self._Arch, self._Target, self._= Toolchain]) + RetVal.append(self._Bdb[File, self._Arch, + self._Target, self._Toolchain]) return RetVal =20 - ## Retrieve PCD comments + # Retrieve PCD comments @cached_property def PcdComments(self): self.Pcds return self._PcdComments =20 - ## Retrieve PCDs used in this module + # Retrieve PCDs used in this module @cached_property def Pcds(self): self._PcdComments =3D OrderedDict() @@ -722,6 +763,7 @@ class InfBuildData(ModuleBuildClassObject): def ModulePcdList(self): RetVal =3D self.Pcds return RetVal + @cached_property def LibraryPcdList(self): if bool(self.LibraryClass): @@ -737,21 +779,23 @@ class InfBuildData(ModuleBuildClassObject): PcdsInLibrary[Key] =3D copy.copy(Library.Pcds[Key]) RetVal[Library] =3D PcdsInLibrary return RetVal + @cached_property def PcdsName(self): PcdsName =3D set() - for Type in (MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODUL= E,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX): + for Type in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODU= LE, MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX): RecordList =3D self._RawData[Type, self._Arch, self._Platform] for TokenSpaceGuid, PcdCName, _, _, _, _, _ in RecordList: PcdsName.add((PcdCName, TokenSpaceGuid)) return PcdsName =20 - ## Retrieve build options specific to this module + # Retrieve build options specific to this module @cached_property def BuildOptions(self): if self._BuildOptions is None: self._BuildOptions =3D OrderedDict() - RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, sel= f._Arch, self._Platform] + RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, + self._Arch, self._Platform] for Record in RecordList: ToolChainFamily =3D Record[0] ToolChain =3D Record[1] @@ -761,10 +805,11 @@ class InfBuildData(ModuleBuildClassObject): else: # concatenate the option string if they're for the sam= e tool OptionString =3D self._BuildOptions[ToolChainFamily, T= oolChain] - self._BuildOptions[ToolChainFamily, ToolChain] =3D Opt= ionString + " " + Option + self._BuildOptions[ToolChainFamily, + ToolChain] =3D OptionString + " " += Option return self._BuildOptions =20 - ## Retrieve dependency expression + # Retrieve dependency expression @cached_property def Depex(self): RetVal =3D tdict(False, 2) @@ -777,8 +822,8 @@ class InfBuildData(ModuleBuildClassObject): # PEIM and DXE drivers must have a valid [Depex] section if len(self.LibraryClass) =3D=3D 0 and len(RecordList) =3D=3D 0: if self.ModuleType =3D=3D SUP_MODULE_DXE_DRIVER or self.Module= Type =3D=3D SUP_MODULE_PEIM or self.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DR= IVER or \ - self.ModuleType =3D=3D SUP_MODULE_DXE_SAL_DRIVER or self.M= oduleType =3D=3D SUP_MODULE_DXE_RUNTIME_DRIVER: - EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depe= x] section or no valid expression in [Depex] section for [%s] module" \ + self.ModuleType =3D=3D SUP_MODULE_DXE_SAL_DRIVER or se= lf.ModuleType =3D=3D SUP_MODULE_DXE_RUNTIME_DRIVER: + EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depe= x] section or no valid expression in [Depex] section for [%s] module" % self.ModuleType, File=3Dself.MetaFile) =20 if len(RecordList) !=3D 0 and (self.ModuleType =3D=3D SUP_MODULE_U= SER_DEFINED or self.ModuleType =3D=3D SUP_MODULE_HOST_APPLICATION): @@ -811,21 +856,27 @@ class InfBuildData(ModuleBuildClassObject): # it use the Fixed PCD format if '.' in Token: if tuple(Token.split('.')[::-1]) not in self.Pcds: - EdkLogger.error('build', RESOURCE_NOT_AVAILABL= E, "PCD [{}] used in [Depex] section should be listed in module PCD section= ".format(Token), File=3Dself.MetaFile, Line=3DRecord[-1]) + EdkLogger.error('build', RESOURCE_NOT_AVAILABL= E, "PCD [{}] used in [Depex] section should be listed in module PCD section= ".format( + Token), File=3Dself.MetaFile, Line=3DRecor= d[-1]) else: if self.Pcds[tuple(Token.split('.')[::-1])].Da= tumType !=3D TAB_VOID: - EdkLogger.error('build', FORMAT_INVALID, "= PCD [{}] used in [Depex] section should be VOID* datum type".format(Token),= File=3Dself.MetaFile, Line=3DRecord[-1]) + EdkLogger.error('build', FORMAT_INVALID, "= PCD [{}] used in [Depex] section should be VOID* datum type".format( + Token), File=3Dself.MetaFile, Line=3DR= ecord[-1]) Value =3D Token else: # get the GUID value now - Value =3D _ProtocolValue(Token, self.Packages, sel= f.MetaFile.Path) + Value =3D _ProtocolValue( + Token, self.Packages, self.MetaFile.Path) if Value is None: - Value =3D _PpiValue(Token, self.Packages, self= .MetaFile.Path) + Value =3D _PpiValue( + Token, self.Packages, self.MetaFile.Path) if Value is None: - Value =3D GuidValue(Token, self.Packages, = self.MetaFile.Path) + Value =3D GuidValue( + Token, self.Packages, self.MetaFile.Pa= th) =20 if Value is None: - PackageList =3D "\n\t".join(str(P) for P in self.P= ackages) + PackageList =3D "\n\t".join(str(P) + for P in self.Packages) EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of [%s] is not found in" % = Token, ExtraData=3DPackageList, File=3Dse= lf.MetaFile, Line=3DRecord[-1]) @@ -834,7 +885,7 @@ class InfBuildData(ModuleBuildClassObject): RetVal[Arch, ModuleType] =3D TemporaryDictionary[Arch, ModuleT= ype] return RetVal =20 - ## Retrieve dependency expression + # Retrieve dependency expression @cached_property def DepexExpression(self): RetVal =3D tdict(False, 2) @@ -848,36 +899,41 @@ class InfBuildData(ModuleBuildClassObject): if (Arch, ModuleType) not in TemporaryDictionary: TemporaryDictionary[Arch, ModuleType] =3D '' for Token in TokenList: - TemporaryDictionary[Arch, ModuleType] =3D TemporaryDiction= ary[Arch, ModuleType] + Token.strip() + ' ' + TemporaryDictionary[Arch, ModuleType] =3D TemporaryDiction= ary[Arch, + = ModuleType] + Token.strip() + ' ' for Arch, ModuleType in TemporaryDictionary: RetVal[Arch, ModuleType] =3D TemporaryDictionary[Arch, ModuleT= ype] return RetVal + def LocalPkg(self): module_path =3D self.MetaFile.File subdir =3D os.path.split(module_path)[0] TopDir =3D "" while subdir: - subdir,TopDir =3D os.path.split(subdir) + subdir, TopDir =3D os.path.split(subdir) =20 - for file_name in os.listdir(os.path.join(self.MetaFile.Root,TopDir= )): + for file_name in os.listdir(os.path.join(self.MetaFile.Root, TopDi= r)): if file_name.upper().endswith("DEC"): - pkg =3D os.path.join(TopDir,file_name) + pkg =3D os.path.join(TopDir, file_name) return pkg + @cached_class_function def GetGuidsUsedByPcd(self): self.Guid return self._GuidsUsedByPcd =20 - ## Retrieve PCD for given type + # Retrieve PCD for given type def _GetPcd(self, Type): Pcds =3D OrderedDict() PcdDict =3D tdict(True, 4) PcdList =3D [] RecordList =3D self._RawData[Type, self._Arch, self._Platform] for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Id, LineNo = in RecordList: - PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] =3D (Setting= , LineNo) + PcdDict[Arch, Platform, PcdCName, + TokenSpaceGuid] =3D (Setting, LineNo) PcdList.append((PcdCName, TokenSpaceGuid)) - CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, self= ._Arch, self._Platform, Id] + CommentRecords =3D self._RawData[MODEL_META_DATA_COMMENT, + self._Arch, self._Platform, Id] Comments =3D [] for CmtRec in CommentRecords: Comments.append(CmtRec[0]) @@ -887,23 +943,24 @@ class InfBuildData(ModuleBuildClassObject): _GuidDict =3D self.Guids.copy() for PcdCName, TokenSpaceGuid in PcdList: PcdRealName =3D PcdCName - Setting, LineNo =3D PcdDict[self._Arch, self.Platform, PcdCNam= e, TokenSpaceGuid] + Setting, LineNo =3D PcdDict[self._Arch, + self.Platform, PcdCName, TokenSpaceG= uid] if Setting is None: continue ValueList =3D AnalyzePcdData(Setting) DefaultValue =3D ValueList[0] Pcd =3D PcdClassObject( - PcdCName, - TokenSpaceGuid, - '', - '', - DefaultValue, - '', - '', - {}, - False, - self.Guids[TokenSpaceGuid] - ) + PcdCName, + TokenSpaceGuid, + '', + '', + DefaultValue, + '', + '', + {}, + False, + self.Guids[TokenSpaceGuid] + ) if Type =3D=3D MODEL_PCD_PATCHABLE_IN_MODULE and ValueList[1]: # Patch PCD: TokenSpace.PcdCName|Value|Offset Pcd.Offset =3D ValueList[1] @@ -916,11 +973,13 @@ class InfBuildData(ModuleBuildClassObject): Pcd_Type =3D item[0].split('_')[-1] if Pcd_Type =3D=3D Package.Pcds[key].Type: Value =3D Package.Pcds[key] - Value.TokenCName =3D Package.Pcds[key]= .TokenCName + '_' + Pcd_Type + Value.TokenCName =3D Package.Pcds[key]= .TokenCName + \ + '_' + Pcd_Type if len(key) =3D=3D 2: newkey =3D (Value.TokenCName, key[= 1]) elif len(key) =3D=3D 3: - newkey =3D (Value.TokenCName, key[= 1], key[2]) + newkey =3D (Value.TokenCName, + key[1], key[2]) del Package.Pcds[key] Package.Pcds[newkey] =3D Value break @@ -971,7 +1030,8 @@ class InfBuildData(ModuleBuildClassObject): pass =20 if (PcdCName, TokenSpaceGuid, PcdType) in Package.Pcds: - PcdInPackage =3D Package.Pcds[PcdCName, TokenSpaceGuid= , PcdType] + PcdInPackage =3D Package.Pcds[PcdCName, + TokenSpaceGuid, PcdType] Pcd.Type =3D PcdType Pcd.TokenValue =3D PcdInPackage.TokenValue =20 @@ -980,48 +1040,53 @@ class InfBuildData(ModuleBuildClassObject): # if Pcd.TokenValue is None or Pcd.TokenValue =3D=3D "": EdkLogger.error( - 'build', - FORMAT_INVALID, - "No TokenValue for PCD [%s.%s] in [%s]!" %= (TokenSpaceGuid, PcdRealName, str(Package)), - File=3Dself.MetaFile, Line=3DLineNo, - ExtraData=3DNone - ) + 'build', + FORMAT_INVALID, + "No TokenValue for PCD [%s.%s] in [%s]!" % ( + TokenSpaceGuid, PcdRealName, str(Package)), + File=3Dself.MetaFile, Line=3DLineNo, + ExtraData=3DNone + ) # # Check hexadecimal token value length and format. # - ReIsValidPcdTokenValue =3D re.compile(r"^[0][x|X][0]*[= 0-9a-fA-F]{1,8}$", re.DOTALL) + ReIsValidPcdTokenValue =3D re.compile( + r"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re.DOTALL) if Pcd.TokenValue.startswith("0x") or Pcd.TokenValue.s= tartswith("0X"): if ReIsValidPcdTokenValue.match(Pcd.TokenValue) is= None: EdkLogger.error( + 'build', + FORMAT_INVALID, + "The format of TokenValue [%s] of PCD [%s.= %s] in [%s] is invalid:" % ( + Pcd.TokenValue, TokenSpaceGuid, PcdRea= lName, str(Package)), + File=3Dself.MetaFile, Line=3DLineNo, + ExtraData=3DNone + ) + + # + # Check decimal token value length and format. + # + else: + try: + TokenValueInt =3D int(Pcd.TokenValue, 10) + if (TokenValueInt < 0 or TokenValueInt > 42949= 67295): + EdkLogger.error( 'build', FORMAT_INVALID, - "The format of TokenValue [%s] of PCD = [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName= , str(Package)), + "The format of TokenValue [%s] of PCD = [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!= " % ( + Pcd.TokenValue, TokenSpaceGuid, Pc= dRealName, str(Package)), File=3Dself.MetaFile, Line=3DLineNo, ExtraData=3DNone - ) - - # - # Check decimal token value length and format. - # - else: - try: - TokenValueInt =3D int (Pcd.TokenValue, 10) - if (TokenValueInt < 0 or TokenValueInt > 42949= 67295): - EdkLogger.error( - 'build', - FORMAT_INVALID, - "The format of TokenValue [%s]= of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 429= 4967295!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)), - File=3Dself.MetaFile, Line=3DL= ineNo, - ExtraData=3DNone - ) + ) except: EdkLogger.error( - 'build', - FORMAT_INVALID, - "The format of TokenValue [%s] of = PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!" % (Pc= d.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)), - File=3Dself.MetaFile, Line=3DLineN= o, - ExtraData=3DNone - ) + 'build', + FORMAT_INVALID, + "The format of TokenValue [%s] of PCD [%s.= %s] in [%s] is invalid, it should be hexadecimal or decimal!" % ( + Pcd.TokenValue, TokenSpaceGuid, PcdRea= lName, str(Package)), + File=3Dself.MetaFile, Line=3DLineNo, + ExtraData=3DNone + ) =20 Pcd.DatumType =3D PcdInPackage.DatumType Pcd.MaxDatumSize =3D PcdInPackage.MaxDatumSize @@ -1030,30 +1095,34 @@ class InfBuildData(ModuleBuildClassObject): Pcd.DefaultValue =3D PcdInPackage.DefaultValue else: try: - Pcd.DefaultValue =3D ValueExpressionEx(Pcd.Def= aultValue, Pcd.DatumType, _GuidDict)(True) + Pcd.DefaultValue =3D ValueExpressionEx( + Pcd.DefaultValue, Pcd.DatumType, _GuidDict= )(True) except BadExpression as Value: - EdkLogger.error('Parser', FORMAT_INVALID, 'PCD= [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, V= alue), + EdkLogger.error('Parser', FORMAT_INVALID, 'PCD= [%s.%s] Value "%s", %s' % (TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, = Value), File=3Dself.MetaFile, Line=3DL= ineNo) break else: EdkLogger.error( - 'build', - FORMAT_INVALID, - "PCD [%s.%s] in [%s] is not found in dependent= packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile), - File=3Dself.MetaFile, Line=3DLineNo, - ExtraData=3D"\t%s" % '\n\t'.join(str(P) for P = in self.Packages) - ) + 'build', + FORMAT_INVALID, + "PCD [%s.%s] in [%s] is not found in dependent package= s:" % ( + TokenSpaceGuid, PcdRealName, self.MetaFile), + File=3Dself.MetaFile, Line=3DLineNo, + ExtraData=3D"\t%s" % '\n\t'.join( + str(P) for P in self.Packages) + ) Pcds[PcdCName, TokenSpaceGuid] =3D Pcd =20 return Pcds =20 - ## check whether current module is binary module + # check whether current module is binary module @property def IsBinaryModule(self): if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSourc= e: return True return False - def CheckFeatureFlagPcd(self,Instance): + + def CheckFeatureFlagPcd(self, Instance): Pcds =3D GlobalData.gPlatformFinalPcds.copy() if PcdPattern.search(Instance): PcdTuple =3D tuple(Instance.split('.')[::-1]) @@ -1064,7 +1133,7 @@ class InfBuildData(ModuleBuildClassObject): File=3Dstr(self), ExtraData=3DInstance) if not Instance in Pcds: Pcds[Instance] =3D self.Pcds[PcdTuple].DefaultValue - else: #if PcdTuple not in self.Pcds: + else: # if PcdTuple not in self.Pcds: EdkLogger.error('build', FORMAT_INVALID, "\nFeatureFlagPcd must be defined in [Feat= urePcd] or [FixedPcd] of Inf file", File=3Dstr(self), ExtraData=3DInstance) @@ -1079,22 +1148,27 @@ class InfBuildData(ModuleBuildClassObject): return True return False except: - EdkLogger.warn('build', FORMAT_INVALID,"The FeatureFlagExp= ression cannot be evaluated", File=3Dstr(self), ExtraData=3DInstance) + EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagEx= pression cannot be evaluated", File=3Dstr( + self), ExtraData=3DInstance) return False else: for Name, Guid in self.Pcds: if self.Pcds[(Name, Guid)].Type =3D=3D 'FeatureFlag' or se= lf.Pcds[(Name, Guid)].Type =3D=3D 'FixedAtBuild': - PcdFullName =3D '%s.%s' % (Guid, Name); + PcdFullName =3D '%s.%s' % (Guid, Name) if not PcdFullName in Pcds: - Pcds[PcdFullName] =3D self.Pcds[(Name, Guid)].Defa= ultValue + Pcds[PcdFullName] =3D self.Pcds[( + Name, Guid)].DefaultValue try: Value =3D ValueExpression(Instance, Pcds)() if Value =3D=3D True: return True return False except: - EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagEx= pression cannot be evaluated", File=3Dstr(self), ExtraData=3DInstance) + EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagEx= pression cannot be evaluated", File=3Dstr( + self), ExtraData=3DInstance) return False + + def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict): for Key in CopyFromDict: CopyToDict[Key].extend(CopyFromDict[Key]) diff --git a/BaseTools/Source/Python/Workspace/MetaDataTable.py b/BaseTools= /Source/Python/Workspace/MetaDataTable.py index a20bd147846b..79d21c4140cd 100644 --- a/BaseTools/Source/Python/Workspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Workspace/MetaDataTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase table for files # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -14,11 +14,13 @@ import Common.EdkLogger as EdkLogger from CommonDataClass import DataClass from CommonDataClass.DataClass import FileClass =20 -## Convert to SQL required string format +# Convert to SQL required string format + + def ConvertToSqlString(StringList): return list(map(lambda s: "'" + s.replace("'", "''") + "'", StringList= )) =20 -## TableFile +# TableFile # # This class defined a common table # @@ -27,6 +29,8 @@ def ConvertToSqlString(StringList): # @param Cursor: Cursor of the database # @param TableName: Name of the table # + + class Table(object): _COLUMN_ =3D '' _ID_STEP_ =3D 1 @@ -44,7 +48,7 @@ class Table(object): def __str__(self): return self.Table =20 - ## Create table + # Create table # # Create a table # @@ -52,7 +56,7 @@ class Table(object): self.Db.CreateEmptyTable(self.Table) self.ID =3D self.GetId() =20 - ## Insert table + # Insert table # # Insert a record into a table # @@ -66,18 +70,17 @@ class Table(object): =20 return self.ID =20 - - ## Get count + # Get count # # Get a count of all records of the table # # @retval Count: Total count of all records # + def GetCount(self): tab =3D self.Db.GetTable(self.Table) return len(tab) =20 - def GetId(self): tab =3D self.Db.GetTable(self.Table) Id =3D max([int(item[0]) for item in tab]) @@ -85,14 +88,14 @@ class Table(object): Id =3D self.IdBase return Id =20 - ## Init the ID of the table + # Init the ID of the table # # Init the ID of the table # def InitID(self): self.ID =3D self.GetId() =20 - ## Exec + # Exec # # Exec Sql Command, return result # @@ -110,7 +113,6 @@ class Table(object): Tab =3D self.Db.GetTable(self.Table) Tab.append(self._DUMMY_) =20 - def IsIntegral(self): tab =3D self.Db.GetTable(self.Table) Id =3D min([int(item[0]) for item in tab]) @@ -123,7 +125,7 @@ class Table(object): return tab =20 =20 -## TableFile +# TableFile # # This class defined a table used for file # @@ -140,10 +142,11 @@ class TableFile(Table): TimeStamp SINGLE NOT NULL, FromItem REAL NOT NULL ''' + def __init__(self, Cursor): Table.__init__(self, Cursor, 'File') =20 - ## Insert table + # Insert table # # Insert a record into table File # @@ -155,7 +158,8 @@ class TableFile(Table): # @param TimeStamp: TimeStamp of a File # def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp, From= Item=3D0): - (Name, ExtName, Path, FullPath) =3D ConvertToSqlString((Name, ExtN= ame, Path, FullPath)) + (Name, ExtName, Path, FullPath) =3D ConvertToSqlString( + (Name, ExtName, Path, FullPath)) return Table.Insert( self, Name, @@ -165,9 +169,9 @@ class TableFile(Table): Model, TimeStamp, FromItem - ) + ) =20 - ## InsertFile + # InsertFile # # Insert one file to table # @@ -179,76 +183,82 @@ class TableFile(Table): def InsertFile(self, File, Model, FromItem=3D''): if FromItem: return self.Insert( - File.Name, - File.Ext, - File.Dir, - File.Path, - Model, - File.TimeStamp, - FromItem - ) + File.Name, + File.Ext, + File.Dir, + File.Path, + Model, + File.TimeStamp, + FromItem + ) return self.Insert( - File.Name, - File.Ext, - File.Dir, - File.Path, - Model, - File.TimeStamp - ) + File.Name, + File.Ext, + File.Dir, + File.Path, + Model, + File.TimeStamp + ) =20 - ## Get type of a given file + # Get type of a given file # # @param FileId ID of a file # # @retval file_type Model value of given file in the table # def GetFileType(self, FileId): - QueryScript =3D "select Model from %s where ID =3D '%s'" % (self.T= able, FileId) + QueryScript =3D "select Model from %s where ID =3D '%s'" % ( + self.Table, FileId) RecordList =3D self.Exec(QueryScript) if len(RecordList) =3D=3D 0: return None return RecordList[0][0] =20 - ## Get file timestamp of a given file + # Get file timestamp of a given file # # @param FileId ID of file # # @retval timestamp TimeStamp value of given file in the table # def GetFileTimeStamp(self, FileId): - QueryScript =3D "select TimeStamp from %s where ID =3D '%s'" % (se= lf.Table, FileId) + QueryScript =3D "select TimeStamp from %s where ID =3D '%s'" % ( + self.Table, FileId) RecordList =3D self.Exec(QueryScript) if len(RecordList) =3D=3D 0: return None return RecordList[0][0] =20 - ## Update the timestamp of a given file + # Update the timestamp of a given file # # @param FileId ID of file # @param TimeStamp Time stamp of file # def SetFileTimeStamp(self, FileId, TimeStamp): - self.Exec("update %s set TimeStamp=3D%s where ID=3D'%s'" % (self.T= able, TimeStamp, FileId)) + self.Exec("update %s set TimeStamp=3D%s where ID=3D'%s'" % + (self.Table, TimeStamp, FileId)) =20 - ## Get list of file with given type + # Get list of file with given type # # @param FileType Type value of file # # @retval file_list List of files with the given type # def GetFileList(self, FileType): - RecordList =3D self.Exec("select FullPath from %s where Model=3D%s= " % (self.Table, FileType)) + RecordList =3D self.Exec( + "select FullPath from %s where Model=3D%s" % (self.Table, File= Type)) if len(RecordList) =3D=3D 0: return [] return [R[0] for R in RecordList] =20 -## TableDataModel +# TableDataModel # # This class defined a table used for data model # # @param object: Inherited from object class # # + + class TableDataModel(Table): _COLUMN_ =3D """ ID INTEGER PRIMARY KEY, @@ -256,10 +266,11 @@ class TableDataModel(Table): Name VARCHAR NOT NULL, Description VARCHAR """ + def __init__(self, Cursor): Table.__init__(self, Cursor, 'DataModel') =20 - ## Insert table + # Insert table # # Insert a record into table DataModel # @@ -272,7 +283,7 @@ class TableDataModel(Table): (Name, Description) =3D ConvertToSqlString((Name, Description)) return Table.Insert(self, CrossIndex, Name, Description) =20 - ## Init table + # Init table # # Create all default records of table DataModel # @@ -288,7 +299,7 @@ class TableDataModel(Table): self.Insert(CrossIndex, Name, Description) EdkLogger.verbose("Initialize table DataModel ... DONE!") =20 - ## Get CrossIndex + # Get CrossIndex # # Get a model's cross index from its name # @@ -303,4 +314,3 @@ class TableDataModel(Table): CrossIndex =3D Item[0] =20 return CrossIndex - diff --git a/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py b/B= aseTools/Source/Python/Workspace/MetaFileCommentParser.py index 3737ae3511c2..01363c10a96b 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to check format of comments # # Copyright (c) 2012, Intel Corporation. All rights reserved.
        @@ -20,19 +20,24 @@ UsageList =3D ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES= ", "ALWAYS_PRODUCED", "SOME "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUME= S", "ALWAYS_CONSUMED", "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUME= S") ErrorMsgMap =3D { - MODEL_EFI_GUID : "The usage for this GUID is not listed in this I= NF: %s[%d]:%s", - MODEL_EFI_PPI : "The usage for this PPI is not listed in this IN= F: %s[%d]:%s.", - MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in th= is INF: %s[%d]:%s.", - MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this IN= F: %s[%d]:%s." + MODEL_EFI_GUID: "The usage for this GUID is not listed in this INF: %s= [%d]:%s", + MODEL_EFI_PPI: "The usage for this PPI is not listed in this INF: %s[%= d]:%s.", + MODEL_EFI_PROTOCOL: "The usage for this Protocol is not listed in this= INF: %s[%d]:%s.", + MODEL_PCD_DYNAMIC: "The usage for this PCD is not listed in this INF: = %s[%d]:%s." } =20 + def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList): if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX= , MODEL_PCD_DYNAMIC]: - CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+= ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC]) + CheckUsage(Comments, UsageList, InfFile, LineNo, + ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DY= NAMIC]) elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]: - CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], Err= orMsgMap[SectionType]) + CheckUsage(Comments, UsageList, InfFile, LineNo, + ValueList[0], ErrorMsgMap[SectionType]) elif SectionType =3D=3D MODEL_EFI_PROTOCOL: - CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile= , LineNo, ValueList[0], ErrorMsgMap[SectionType]) + CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), + InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) + =20 def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg): for Comment in Comments: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index 3508591b281e..ea40cc5fcd41 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to parse meta files # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -32,12 +32,14 @@ from .MetaFileTable import MetaFileStorage from .MetaFileCommentParser import CheckInfComment from Common.DataType import TAB_COMMENT_EDK_START, TAB_COMMENT_EDK_END =20 -## RegEx for finding file versions +# RegEx for finding file versions hexVersionPattern =3D re.compile(r'0[xX][\da-f-A-F]{5,8}') decVersionPattern =3D re.compile(r'\d+\.\d+') CODEPattern =3D re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}") =20 -## A decorator used to parse macro definition +# A decorator used to parse macro definition + + def ParseMacro(Parser): def MacroParser(self): Match =3D GlobalData.gMacroDefPattern.match(self._CurrentLine) @@ -46,7 +48,8 @@ def ParseMacro(Parser): Parser(self) return =20 - TokenList =3D GetSplitValueList(self._CurrentLine[Match.end(1):], = TAB_EQUAL_SPLIT, 1) + TokenList =3D GetSplitValueList( + self._CurrentLine[Match.end(1):], TAB_EQUAL_SPLIT, 1) # Syntax check if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No macro name given= ", @@ -103,7 +106,7 @@ def ParseMacro(Parser): =20 return MacroParser =20 -## Base class of parser +# Base class of parser # # This class is used for derivation purpose. The specific parser for one = kind # type file must derive this class and implement some public interfaces. @@ -115,6 +118,8 @@ def ParseMacro(Parser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE= directive) # + + class MetaFileParser(object): # data type (file content) for specific file type DataType =3D {} @@ -122,7 +127,7 @@ class MetaFileParser(object): # Parser objects used to implement singleton MetaFiles =3D {} =20 - ## Factory method + # Factory method # # One file, one parser object. This factory method makes sure that the= re's # only one object constructed for one meta file. @@ -141,7 +146,7 @@ class MetaFileParser(object): Class.MetaFiles[FilePath] =3D ParserObject return ParserObject =20 - ## Constructor of MetaFileParser + # Constructor of MetaFileParser # # Initialize object of MetaFileParser # @@ -152,7 +157,7 @@ class MetaFileParser(object): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INC= LUDE directive) # - def __init__(self, FilePath, FileType, Arch, Table, Owner=3D -1, From= =3D -1): + def __init__(self, FilePath, FileType, Arch, Table, Owner=3D-1, From= =3D-1): self._Table =3D Table self._RawTable =3D Table self._Arch =3D Arch @@ -191,19 +196,19 @@ class MetaFileParser(object): self._PcdDataTypeCODE =3D False self._CurrentPcdName =3D "" =20 - ## Store the parsed data in table + # Store the parsed data in table def _Store(self, *Args): return self._Table.Insert(*Args) =20 - ## Virtual method for starting parse + # Virtual method for starting parse def Start(self): raise NotImplementedError =20 - ## Notify a post-process is needed + # Notify a post-process is needed def DoPostProcess(self): self._PostProcessed =3D False =20 - ## Set parsing complete flag in both class and table + # Set parsing complete flag in both class and table def _Done(self): self._Finished =3D True self._Table.SetEndFlag() @@ -211,17 +216,17 @@ class MetaFileParser(object): def _PostProcess(self): self._PostProcessed =3D True =20 - ## Get the parse complete flag + # Get the parse complete flag @property def Finished(self): return self._Finished =20 - ## Set the complete flag + # Set the complete flag @Finished.setter def Finished(self, Value): self._Finished =3D Value =20 - ## Remove records that do not match given Filter Arch + # Remove records that do not match given Filter Arch def _FilterRecordList(self, RecordList, FilterArch): NewRecordList =3D [] for Record in RecordList: @@ -230,7 +235,7 @@ class MetaFileParser(object): NewRecordList.append(Record) return NewRecordList =20 - ## Use [] style to query data in table, just for readability + # Use [] style to query data in table, just for readability # # DataInfo =3D [data_type, scope1(arch), scope2(platform/moduletype)] # @@ -259,18 +264,19 @@ class MetaFileParser(object): self._Table =3D self._RawTable self._PostProcessed =3D False self.Start() - ## Data parser for the common format in different type of file + # Data parser for the common format in different type of file # # The common format in the meatfile is like # # xxx1 | xxx2 | xxx3 # + @ParseMacro def _CommonParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) self._ValueList[0:len(TokenList)] =3D TokenList =20 - ## Data parser for the format in which there's path + # Data parser for the format in which there's path # # Only path can have macro used. So we need to replace them before u= se. # @@ -281,19 +287,20 @@ class MetaFileParser(object): # Don't do macro replacement for dsc file at this point if not isinstance(self, DscParser): Macros =3D self._Macros - self._ValueList =3D [ReplaceMacro(Value, Macros) for Value in = self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, Macros) + for Value in self._ValueList] =20 - ## Skip unsupported data + # Skip unsupported data def _Skip(self): EdkLogger.warn("Parser", "Unrecognized content", File=3Dself.MetaF= ile, - Line=3Dself._LineIndex + 1, ExtraData=3Dself._Curr= entLine); + Line=3Dself._LineIndex + 1, ExtraData=3Dself._Curre= ntLine) self._ValueList[0:1] =3D [self._CurrentLine] =20 - ## Skip unsupported data for UserExtension Section + # Skip unsupported data for UserExtension Section def _SkipUserExtension(self): self._ValueList[0:1] =3D [self._CurrentLine] =20 - ## Section header parser + # Section header parser # # The section header is always in following format: # @@ -353,14 +360,14 @@ class MetaFileParser(object): # If the section information is needed later, it should be stored = in database self._ValueList[0] =3D self._SectionName =20 - ## [packages] section parser + # [packages] section parser @ParseMacro def _PackageParser(self): self._CurrentLine =3D CleanString(self._CurrentLine) self._Packages.append(self._CurrentLine) self._ValueList[0] =3D self._CurrentLine =20 - ## [defines] section parser + # [defines] section parser @ParseMacro def _DefineParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -372,15 +379,18 @@ class MetaFileParser(object): EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) =20 - self._ValueList =3D [ReplaceMacro(Value, self._Macros) for Value i= n self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, self._Macros) + for Value in self._ValueList] Name, Value =3D self._ValueList[1], self._ValueList[2] MacroUsed =3D GlobalData.gMacroRefPattern.findall(Value) if len(MacroUsed) !=3D 0: for Macro in MacroUsed: if Macro in GlobalData.gGlobalDefines: - EdkLogger.error("Parser", FORMAT_INVALID, "Global macr= o %s is not permitted." % (Macro), ExtraData=3Dself._CurrentLine, File=3Dse= lf.MetaFile, Line=3Dself._LineIndex + 1) + EdkLogger.error("Parser", FORMAT_INVALID, "Global macr= o %s is not permitted." % ( + Macro), ExtraData=3Dself._CurrentLine, File=3Dself= .MetaFile, Line=3Dself._LineIndex + 1) else: - EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined"= % (Macro), ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dsel= f._LineIndex + 1) + EdkLogger.error("Parser", FORMAT_INVALID, "%s not defined"= % ( + Macro), ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) # Sometimes, we need to make differences between EDK and EDK2 modu= les if Name =3D=3D 'INF_VERSION': if hexVersionPattern.match(Value): @@ -402,7 +412,7 @@ class MetaFileParser(object): self._FileLocalMacros[Name] =3D Value self._Defines[Name] =3D Value =20 - ## [BuildOptions] section parser + # [BuildOptions] section parser @ParseMacro def _BuildOptionParser(self): self._CurrentLine =3D CleanString(self._CurrentLine, BuildOption= =3DTrue) @@ -413,18 +423,20 @@ class MetaFileParser(object): self._ValueList[1] =3D TokenList2[1] # keys else: self._ValueList[1] =3D TokenList[0] - if len(TokenList) =3D=3D 2 and not isinstance(self, DscParser): # = value + if len(TokenList) =3D=3D 2 and not isinstance(self, DscParser): #= value self._ValueList[2] =3D ReplaceMacro(TokenList[1], self._Macros) =20 if self._ValueList[1].count('_') !=3D 4: EdkLogger.error( 'Parser', FORMAT_INVALID, - "'%s' must be in format of ____FLAGS" % self._ValueList[1], + "'%s' must be in format of ____FLAGS" % self._ValueList[ + 1], ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex + 1 - ) + ) + def GetValidExpression(self, TokenSpaceGuid, PcdCName): return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName) =20 @@ -435,7 +447,7 @@ class MetaFileParser(object): Macros.update(self._GetApplicableSectionMacro()) return Macros =20 - ## Construct section Macro dict + # Construct section Macro dict def _ConstructSectionMacroDict(self, Name, Value): ScopeKey =3D [(Scope[0], Scope[1], Scope[2]) for Scope in self._Sc= ope] ScopeKey =3D tuple(ScopeKey) @@ -450,8 +462,8 @@ class MetaFileParser(object): =20 self._SectionsMacroDict[SectionDictKey][Name] =3D Value =20 - ## Get section Macros that are applicable to current line, which may c= ome from other sections - ## that share the same name while scope is wider + # Get section Macros that are applicable to current line, which may co= me from other sections + # that share the same name while scope is wider def _GetApplicableSectionMacro(self): Macros =3D {} =20 @@ -468,21 +480,24 @@ class MetaFileParser(object): continue =20 for ActiveScope in self._Scope: - Scope0, Scope1, Scope2=3D ActiveScope[0], ActiveScope[1], = ActiveScope[2] + Scope0, Scope1, Scope2 =3D ActiveScope[0], ActiveScope[1],= ActiveScope[2] if(Scope0, Scope1, Scope2) not in Scope: break else: - SpeSpeMacroDict.update(self._SectionsMacroDict[(SectionTyp= e, Scope)]) + SpeSpeMacroDict.update( + self._SectionsMacroDict[(SectionType, Scope)]) =20 for ActiveScope in self._Scope: Scope0, Scope1, Scope2 =3D ActiveScope[0], ActiveScope[1],= ActiveScope[2] if(Scope0, Scope1, Scope2) not in Scope and (Scope0, TAB_C= OMMON, TAB_COMMON) not in Scope and (TAB_COMMON, Scope1, TAB_COMMON) not in= Scope: break else: - ComSpeMacroDict.update(self._SectionsMacroDict[(SectionTyp= e, Scope)]) + ComSpeMacroDict.update( + self._SectionsMacroDict[(SectionType, Scope)]) =20 if (TAB_COMMON, TAB_COMMON, TAB_COMMON) in Scope: - ComComMacroDict.update(self._SectionsMacroDict[(SectionTyp= e, Scope)]) + ComComMacroDict.update( + self._SectionsMacroDict[(SectionType, Scope)]) =20 Macros.update(ComComMacroDict) Macros.update(ComSpeMacroDict) @@ -490,7 +505,7 @@ class MetaFileParser(object): =20 return Macros =20 - def ProcessMultipleLineCODEValue(self,Content): + def ProcessMultipleLineCODEValue(self, Content): CODEBegin =3D False CODELine =3D "" continuelinecount =3D 0 @@ -499,7 +514,7 @@ class MetaFileParser(object): Line =3D Content[Index] if CODEBegin: CODELine =3D CODELine + Line - continuelinecount +=3D1 + continuelinecount +=3D 1 if ")}" in Line: newContent.append(CODELine) for _ in range(continuelinecount): @@ -525,40 +540,42 @@ class MetaFileParser(object): =20 _SectionParser =3D {} =20 -## INF file parser class +# INF file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file # @param Table Database used to retrieve module/package i= nformation # @param Macros Macros used for replacement in file # + + class InfParser(MetaFileParser): # INF file supported data types (one type per section) DataType =3D { - TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_INF_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DEFINE, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_PACKAGES.upper() : MODEL_META_DATA_PACKAGE, - TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE, - TAB_INF_FIXED_PCD.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_INF_PATCH_PCD.upper() : MODEL_PCD_PATCHABLE_IN_MODULE, - TAB_INF_FEATURE_PCD.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_INF_PCD_EX.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_INF_PCD.upper() : MODEL_PCD_DYNAMIC, - TAB_SOURCES.upper() : MODEL_EFI_SOURCE_FILE, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_DEPEX.upper() : MODEL_EFI_DEPEX, - TAB_BINARIES.upper() : MODEL_EFI_BINARY_FILE, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION + TAB_UNKNOWN.upper(): MODEL_UNKNOWN, + TAB_INF_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_BUILD_OPTIONS.upper(): MODEL_META_DATA_BUILD_OPTION, + TAB_INCLUDES.upper(): MODEL_EFI_INCLUDE, + TAB_LIBRARIES.upper(): MODEL_EFI_LIBRARY_INSTANCE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_PACKAGES.upper(): MODEL_META_DATA_PACKAGE, + TAB_NMAKE.upper(): MODEL_META_DATA_NMAKE, + TAB_INF_FIXED_PCD.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_INF_PATCH_PCD.upper(): MODEL_PCD_PATCHABLE_IN_MODULE, + TAB_INF_FEATURE_PCD.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_INF_PCD_EX.upper(): MODEL_PCD_DYNAMIC_EX, + TAB_INF_PCD.upper(): MODEL_PCD_DYNAMIC, + TAB_SOURCES.upper(): MODEL_EFI_SOURCE_FILE, + TAB_GUIDS.upper(): MODEL_EFI_GUID, + TAB_PROTOCOLS.upper(): MODEL_EFI_PROTOCOL, + TAB_PPIS.upper(): MODEL_EFI_PPI, + TAB_DEPEX.upper(): MODEL_EFI_DEPEX, + TAB_BINARIES.upper(): MODEL_EFI_BINARY_FILE, + TAB_USER_EXTENSIONS.upper(): MODEL_META_DATA_USER_EXTENSION } =20 - ## Constructor of InfParser + # Constructor of InfParser # # Initialize object of InfParser # @@ -574,7 +591,7 @@ class InfParser(MetaFileParser): MetaFileParser.__init__(self, FilePath, FileType, Arch, Table) self.PcdsDict =3D {} =20 - ## Parser starter + # Parser starter def Start(self): NmakeLine =3D '' Content =3D '' @@ -582,7 +599,8 @@ class InfParser(MetaFileParser): with open(str(self.MetaFile), 'r') as File: Content =3D File.readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) =20 # parse the file line by line IsFindBlockComment =3D False @@ -593,7 +611,8 @@ class InfParser(MetaFileParser): =20 for Index in range(0, len(Content)): # skip empty, commented, block commented lines - Line, Comment =3D CleanString2(Content[Index], AllowCppStyleCo= mment=3DTrue) + Line, Comment =3D CleanString2( + Content[Index], AllowCppStyleComment=3DTrue) NextLine =3D '' if Index + 1 < len(Content): NextLine, NextComment =3D CleanString2(Content[Index + 1]) @@ -642,13 +661,15 @@ class InfParser(MetaFileParser): MODEL_EFI_PPI, MODEL_META_DATA_USER_EXTENSIO= N]: EdkLogger.error('Parser', FORMAT_INVALID, - "Section [%s] is not allowed in in= f file without version" % (self._SectionName), + "Section [%s] is not allowed in in= f file without version" % ( + self._SectionName), ExtraData=3Dself._CurrentLine, Fil= e=3Dself.MetaFile, Line=3Dself._LineIndex + 1) elif self._SectionType in [MODEL_EFI_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, MODEL_META_DATA_NMAKE]: EdkLogger.error('Parser', FORMAT_INVALID, - "Section [%s] is not allowed in inf fi= le with version 0x%08x" % (self._SectionName, self._Version), + "Section [%s] is not allowed in inf fi= le with version 0x%08x" % ( + self._SectionName, self._Version), ExtraData=3Dself._CurrentLine, File=3D= self.MetaFile, Line=3Dself._LineIndex + 1) continue # merge two lines specified by '\' in section NMAKE @@ -679,25 +700,26 @@ class InfParser(MetaFileParser): if Comment: Comments.append((Comment, Index + 1)) if GlobalData.gOptions and GlobalData.gOptions.CheckUsage: - CheckInfComment(self._SectionType, Comments, str(self.Meta= File), Index + 1, self._ValueList) + CheckInfComment(self._SectionType, Comments, str( + self.MetaFile), Index + 1, self._ValueList) # # Model, Value1, Value2, Value3, Arch, Platform, BelongsToItem= =3D-1, # LineBegin=3D-1, ColumnBegin=3D-1, LineEnd=3D-1, ColumnEnd=3D= -1, Enabled=3D-1 # for Arch, Platform, _ in self._Scope: LastItem =3D self._Store(self._SectionType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - Arch, - Platform, - self._Owner[-1], - self._LineIndex + 1, - - 1, - self._LineIndex + 1, - - 1, - 0 - ) + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + Arch, + Platform, + self._Owner[-1], + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, + 0 + ) for Comment, LineNo in Comments: self._Store(MODEL_META_DATA_COMMENT, Comment, '', '', = Arch, Platform, LastItem, LineNo, -1, LineNo, -1, 0) @@ -711,10 +733,10 @@ class InfParser(MetaFileParser): # If there are tail comments in INF file, save to database whateve= r the comments are for Comment in TailComments: self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', = TAB_COMMON, - TAB_COMMON, self._Owner[-1], -1, -1, -1, -= 1, 0) + TAB_COMMON, self._Owner[-1], -1, -1, -1, -1, 0) self._Done() =20 - ## Data parser for the format in which there's path + # Data parser for the format in which there's path # # Only path can have macro used. So we need to replace them before u= se. # @@ -729,7 +751,7 @@ class InfParser(MetaFileParser): continue self._ValueList[Index] =3D ReplaceMacro(Value, Macros) =20 - ## Parse [Sources] section + # Parse [Sources] section # # Only path can have macro used. So we need to replace them before u= se. # @@ -745,12 +767,14 @@ class InfParser(MetaFileParser): # For Acpi tables, remove macro like ' TABLE_NAME=3DSata1' if 'COMPONENT_TYPE' in Macros: if self._Defines['COMPONENT_TYPE'].upper() =3D=3D 'ACPITABLE': - self._ValueList[0] =3D GetSplitValueList(self._ValueList[0= ], ' ', 1)[0] + self._ValueList[0] =3D GetSplitValueList( + self._ValueList[0], ' ', 1)[0] if self._Defines['BASE_NAME'] =3D=3D 'Microcode': pass - self._ValueList =3D [ReplaceMacro(Value, Macros) for Value in self= ._ValueList] + self._ValueList =3D [ReplaceMacro(Value, Macros) + for Value in self._ValueList] =20 - ## Parse [Binaries] section + # Parse [Binaries] section # # Only path can have macro used. So we need to replace them before u= se. # @@ -759,20 +783,23 @@ class InfParser(MetaFileParser): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT= , 2) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No file type or pat= h specified", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if not TokenList[0]: EdkLogger.error('Parser', FORMAT_INVALID, "No file type specif= ied", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if not TokenList[1]: EdkLogger.error('Parser', FORMAT_INVALID, "No file path specif= ied", - ExtraData=3Dself._CurrentLine + " ( = | [| ])", + ExtraData=3Dself._CurrentLine + + " ( | [| ])", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) self._ValueList[0:len(TokenList)] =3D TokenList self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], self._Macr= os) =20 - ## [nmake] section parser (Edk.x style only) + # [nmake] section parser (Edk.x style only) def _NmakeParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) self._ValueList[0:len(TokenList)] =3D TokenList @@ -781,70 +808,77 @@ class InfParser(MetaFileParser): # remove self-reference in macro setting #self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], {self._Va= lueList[0]:''}) =20 - ## [FixedPcd], [FeaturePcd], [PatchPcd], [Pcd] and [PcdEx] sections pa= rser + # [FixedPcd], [FeaturePcd], [PatchPcd], [Pcd] and [PcdEx] sections par= ser @ParseMacro def _PcdParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT= , 1) ValueList =3D GetSplitValueList(TokenList[0], TAB_SPLIT) if len(ValueList) !=3D 2: EdkLogger.error('Parser', FORMAT_INVALID, "Illegal token space= GUID and PCD name format", - ExtraData=3Dself._CurrentLine + " (.)", + ExtraData=3Dself._CurrentLine + + " (.)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) self._ValueList[0:1] =3D ValueList if len(TokenList) > 1: self._ValueList[2] =3D TokenList[1] if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID= or PCD name specified", - ExtraData=3Dself._CurrentLine + " (.)", + ExtraData=3Dself._CurrentLine + + " (.)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) =20 # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE'= , replace with integer 1 or 0. if self._ValueList[2] !=3D '': - InfPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_= SPLIT, 1) + InfPcdValueList =3D GetSplitValueList( + TokenList[1], TAB_VALUE_SPLIT, 1) if InfPcdValueList[0] in ['True', 'true', 'TRUE']: - self._ValueList[2] =3D TokenList[1].replace(InfPcdValueLis= t[0], '1', 1) + self._ValueList[2] =3D TokenList[1].replace( + InfPcdValueList[0], '1', 1) elif InfPcdValueList[0] in ['False', 'false', 'FALSE']: - self._ValueList[2] =3D TokenList[1].replace(InfPcdValueLis= t[0], '0', 1) + self._ValueList[2] =3D TokenList[1].replace( + InfPcdValueList[0], '0', 1) elif isinstance(InfPcdValueList[0], str) and InfPcdValueList[0= ].find('$(') >=3D 0: - Value =3D ReplaceExprMacro(InfPcdValueList[0],self._Macros) + Value =3D ReplaceExprMacro(InfPcdValueList[0], self._Macro= s) if Value !=3D '0': self._ValueList[2] =3D Value if (self._ValueList[0], self._ValueList[1]) not in self.PcdsDict: - self.PcdsDict[self._ValueList[0], self._ValueList[1]] =3D self= ._SectionType + self.PcdsDict[self._ValueList[0], + self._ValueList[1]] =3D self._SectionType elif self.PcdsDict[self._ValueList[0], self._ValueList[1]] !=3D se= lf._SectionType: EdkLogger.error('Parser', FORMAT_INVALID, "It is not permissib= le to list a specified PCD in different PCD type sections.", - ExtraData=3Dself._CurrentLine + " (.)", + ExtraData=3Dself._CurrentLine + + " (.)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) =20 - ## [depex] section parser + # [depex] section parser @ParseMacro def _DepexParser(self): self._ValueList[0:1] =3D [self._CurrentLine] =20 _SectionParser =3D { - MODEL_UNKNOWN : MetaFileParser._Skip, - MODEL_META_DATA_HEADER : MetaFileParser._DefineParser, - MODEL_META_DATA_BUILD_OPTION : MetaFileParser._BuildOptionPar= ser, - MODEL_EFI_INCLUDE : _IncludeParser, # for Edk.x mo= dules - MODEL_EFI_LIBRARY_INSTANCE : MetaFileParser._CommonParser, = # for Edk.x modules - MODEL_EFI_LIBRARY_CLASS : MetaFileParser._PathParser, - MODEL_META_DATA_PACKAGE : MetaFileParser._PathParser, - MODEL_META_DATA_NMAKE : _NmakeParser, # for Edk.x modu= les - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC_EX : _PcdParser, - MODEL_PCD_DYNAMIC : _PcdParser, - MODEL_EFI_SOURCE_FILE : _SourceFileParser, - MODEL_EFI_GUID : MetaFileParser._CommonParser, - MODEL_EFI_PROTOCOL : MetaFileParser._CommonParser, - MODEL_EFI_PPI : MetaFileParser._CommonParser, - MODEL_EFI_DEPEX : _DepexParser, - MODEL_EFI_BINARY_FILE : _BinaryFileParser, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser._SkipUserExtens= ion, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_HEADER: MetaFileParser._DefineParser, + MODEL_META_DATA_BUILD_OPTION: MetaFileParser._BuildOptionParser, + MODEL_EFI_INCLUDE: _IncludeParser, # for Edk.x modules + MODEL_EFI_LIBRARY_INSTANCE: MetaFileParser._CommonParser, # for= Edk.x modules + MODEL_EFI_LIBRARY_CLASS: MetaFileParser._PathParser, + MODEL_META_DATA_PACKAGE: MetaFileParser._PathParser, + MODEL_META_DATA_NMAKE: _NmakeParser, # for Edk.x modules + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC_EX: _PcdParser, + MODEL_PCD_DYNAMIC: _PcdParser, + MODEL_EFI_SOURCE_FILE: _SourceFileParser, + MODEL_EFI_GUID: MetaFileParser._CommonParser, + MODEL_EFI_PROTOCOL: MetaFileParser._CommonParser, + MODEL_EFI_PPI: MetaFileParser._CommonParser, + MODEL_EFI_DEPEX: _DepexParser, + MODEL_EFI_BINARY_FILE: _BinaryFileParser, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._SkipUserExtensio= n, } =20 -## DSC file parser class +# DSC file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file @@ -853,37 +887,39 @@ class InfParser(MetaFileParser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INCLUDE= directive) # + + class DscParser(MetaFileParser): # DSC file supported data types (one type per section) DataType =3D { - TAB_SKUIDS.upper() : MODEL_EFI_SKU_ID, - TAB_DEFAULT_STORES.upper() : MODEL_EFI_DEFAULT_= STORES, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_= INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_= CLASS, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BU= ILD_OPTION, - TAB_PACKAGES.upper() : MODEL_META_DATA_PA= CKAGE, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT= _BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABL= E_IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_= FLAG, - TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_= DEFAULT, - TAB_PCDS_DYNAMIC_HII_NULL.upper() : MODEL_PCD_DYNAMIC_= HII, - TAB_PCDS_DYNAMIC_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_= VPD, - TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_DEFAULT, - TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_HII, - TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_= EX_VPD, - TAB_COMPONENTS.upper() : MODEL_META_DATA_CO= MPONENT, - TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HE= ADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DE= FINE, - TAB_DSC_DEFINES_EDKGLOBAL : MODEL_META_DATA_GL= OBAL_DEFINE, - TAB_INCLUDE.upper() : MODEL_META_DATA_IN= CLUDE, - TAB_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IF, - TAB_IF_DEF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IFDEF, - TAB_IF_N_DEF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IFNDEF, - TAB_ELSE_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSEIF, - TAB_ELSE.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSE, - TAB_END_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ENDIF, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_US= ER_EXTENSION, - TAB_ERROR.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ERROR, + TAB_SKUIDS.upper(): MODEL_EFI_SKU_ID, + TAB_DEFAULT_STORES.upper(): MODEL_EFI_DEFAULT_STORES, + TAB_LIBRARIES.upper(): MODEL_EFI_LIBRARY_INSTANCE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_BUILD_OPTIONS.upper(): MODEL_META_DATA_BUILD_OPTION, + TAB_PACKAGES.upper(): MODEL_META_DATA_PACKAGE, + TAB_PCDS_FIXED_AT_BUILD_NULL.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(): MODEL_PCD_PATCHABLE_I= N_MODULE, + TAB_PCDS_FEATURE_FLAG_NULL.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper(): MODEL_PCD_DYNAMIC_DEFAULT, + TAB_PCDS_DYNAMIC_HII_NULL.upper(): MODEL_PCD_DYNAMIC_HII, + TAB_PCDS_DYNAMIC_VPD_NULL.upper(): MODEL_PCD_DYNAMIC_VPD, + TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper(): MODEL_PCD_DYNAMIC_EX_D= EFAULT, + TAB_PCDS_DYNAMIC_EX_HII_NULL.upper(): MODEL_PCD_DYNAMIC_EX_HII, + TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper(): MODEL_PCD_DYNAMIC_EX_VPD, + TAB_COMPONENTS.upper(): MODEL_META_DATA_COMPONENT, + TAB_DSC_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_DSC_DEFINES_EDKGLOBAL: MODEL_META_DATA_GLOBAL_DEFINE, + TAB_INCLUDE.upper(): MODEL_META_DATA_INCLUDE, + TAB_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, + TAB_IF_DEF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, + TAB_IF_N_DEF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_IFND= EF, + TAB_ELSE_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEI= F, + TAB_ELSE.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, + TAB_END_IF.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF, + TAB_USER_EXTENSIONS.upper(): MODEL_META_DATA_USER_EXTENSION, + TAB_ERROR.upper(): MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR, } =20 # Valid names in define section @@ -917,7 +953,7 @@ class DscParser(MetaFileParser): =20 IncludedFiles =3D set() =20 - ## Constructor of DscParser + # Constructor of DscParser # # Initialize object of DscParser # @@ -928,11 +964,12 @@ class DscParser(MetaFileParser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INC= LUDE directive) # - def __init__(self, FilePath, FileType, Arch, Table, Owner=3D -1, From= =3D -1): + def __init__(self, FilePath, FileType, Arch, Table, Owner=3D-1, From= =3D-1): # prevent re-initialization if hasattr(self, "_Table") and self._Table is Table: return - MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, Own= er, From) + MetaFileParser.__init__(self, FilePath, FileType, + Arch, Table, Owner, From) self._Version =3D 0x00010005 # Only EDK2 dsc file is supported # to store conditional directive evaluation result self._DirectiveStack =3D [] @@ -950,18 +987,19 @@ class DscParser(MetaFileParser): # Map the ID between the original table and new table to track # the owner item # - self._IdMapping =3D {-1:-1} + self._IdMapping =3D {-1: -1} =20 self._Content =3D None =20 - ## Parser starter + # Parser starter def Start(self): Content =3D '' try: with open(str(self.MetaFile), 'r') as File: Content =3D File.readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) =20 OwnerId =3D {} =20 @@ -1004,7 +1042,8 @@ class DscParser(MetaFileParser): self._DirectiveParser() continue if Line[0] =3D=3D TAB_OPTION_START and not self._InSubsection: - EdkLogger.error("Parser", FILE_READ_FAILURE, "Missing the = '{' before %s in Line %s" % (Line, Index+1), ExtraData=3Dself.MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, "Missing the = '{' before %s in Line %s" % ( + Line, Index+1), ExtraData=3Dself.MetaFile) =20 if self._InSubsection: SectionType =3D self._SubsectionType @@ -1030,21 +1069,21 @@ class DscParser(MetaFileParser): if self._SubsectionType !=3D MODEL_UNKNOWN and Arch in Own= erId: Owner =3D OwnerId[Arch] self._LastItem =3D self._Store( - self._ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - Arch, - ModuleType, - DefaultStore, - Owner, - self._From, - self._LineIndex + 1, - - 1, - self._LineIndex + 1, - - 1, - self._Enabled - ) + self._ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + Arch, + ModuleType, + DefaultStore, + Owner, + self._From, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, + self._Enabled + ) if self._SubsectionType =3D=3D MODEL_UNKNOWN and self._InS= ubsection: OwnerId[Arch] =3D self._LastItem =20 @@ -1054,7 +1093,7 @@ class DscParser(MetaFileParser): ExtraData=3DText, File=3Dself.MetaFile, Line= =3DLine) self._Done() =20 - ## parser + # parser def _SubsectionHeaderParser(self): self._SubsectionName =3D self._CurrentLine[1:-1].upper() if self._SubsectionName in self.DataType: @@ -1065,7 +1104,7 @@ class DscParser(MetaFileParser): Line=3Dself._LineIndex + 1, ExtraData=3Dself._C= urrentLine) self._ValueList[0] =3D self._SubsectionName =20 - ## Directive statement parser + # Directive statement parser def _DirectiveParser(self): self._ValueList =3D ['', '', ''] TokenList =3D GetSplitValueList(self._CurrentLine, ' ', 1) @@ -1115,7 +1154,8 @@ class DscParser(MetaFileParser): EdkLogger.error("Parser", FORMAT_INVALID, "'!elseif' after= '!else'", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1, ExtraData=3Dself._CurrentLine) - self._DirectiveStack.append((ItemType, self._LineIndex + 1, se= lf._CurrentLine)) + self._DirectiveStack.append( + (ItemType, self._LineIndex + 1, self._CurrentLine)) =20 # # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem= =3D-1, BelongsToFile=3D-1, @@ -1123,23 +1163,23 @@ class DscParser(MetaFileParser): # for Arch, ModuleType, DefaultStore in Scope: self._LastItem =3D self._Store( - ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - Arch, - ModuleType, - DefaultStore, - self._Owner[-1], - self._From, - self._LineIndex + 1, - - 1, - self._LineIndex + 1, - - 1, - 0 - ) + ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + Arch, + ModuleType, + DefaultStore, + self._Owner[-1], + self._From, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, + 0 + ) =20 - ## [defines] section parser + # [defines] section parser @ParseMacro def _DefineParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) @@ -1153,7 +1193,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "No value specified", ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) if (not self._ValueList[1] in self.DefineKeywords and - (self._InSubsection and self._ValueList[1] not in self.SubSect= ionDefineKeywords)): + (self._InSubsection and self._ValueList[1] not in self.Sub= SectionDefineKeywords)): EdkLogger.error('Parser', FORMAT_INVALID, "Unknown keyword found: %s. " "If this is a macro you must " @@ -1170,6 +1210,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '= |[|]'", ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) self._ValueList[0:len(TokenList)] =3D TokenList + @ParseMacro def _DefaultStoresParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) @@ -1178,15 +1219,14 @@ class DscParser(MetaFileParser): ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) self._ValueList[0:len(TokenList)] =3D TokenList =20 - ## Parse Edk style of library modules + # Parse Edk style of library modules @ParseMacro def _LibraryInstanceParser(self): self._ValueList[0] =3D self._CurrentLine =20 - def _DecodeCODEData(self): pass - ## PCD sections parser + # PCD sections parser # # [PcdsFixedAtBuild] # [PcdsPatchableInModule] @@ -1200,12 +1240,14 @@ class DscParser(MetaFileParser): # [PcdsDynamicVpd] # [PcdsDynamicHii] # + @ParseMacro def _PcdParser(self): if self._PcdDataTypeCODE: self._PcdCodeValue =3D self._PcdCodeValue + "\n " + self._Curr= entLine if self._CurrentLine.endswith(")}"): - self._CurrentLine =3D "|".join((self._CurrentPcdName, self= ._PcdCodeValue)) + self._CurrentLine =3D "|".join( + (self._CurrentPcdName, self._PcdCodeValue)) self._PcdDataTypeCODE =3D False self._PcdCodeValue =3D "" else: @@ -1229,14 +1271,17 @@ class DscParser(MetaFileParser): if len(PcdNameTockens) =3D=3D 2: self._ValueList[0], self._ValueList[1] =3D PcdNameTockens[0], = PcdNameTockens[1] elif len(PcdNameTockens) =3D=3D 3: - self._ValueList[0], self._ValueList[1] =3D ".".join((PcdNameTo= ckens[0], PcdNameTockens[1])), PcdNameTockens[2] + self._ValueList[0], self._ValueList[1] =3D ".".join( + (PcdNameTockens[0], PcdNameTockens[1])), PcdNameTockens[2] elif len(PcdNameTockens) > 3: - self._ValueList[0], self._ValueList[1] =3D ".".join((PcdNameTo= ckens[0], PcdNameTockens[1])), ".".join(PcdNameTockens[2:]) + self._ValueList[0], self._ValueList[1] =3D ".".join( + (PcdNameTockens[0], PcdNameTockens[1])), ".".join(PcdNameT= ockens[2:]) if len(TokenList) =3D=3D 2: self._ValueList[2] =3D TokenList[1] if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID= or PCD name specified", - ExtraData=3Dself._CurrentLine + " (.|)", + ExtraData=3Dself._CurrentLine + + " (.|)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if self._ValueList[2] =3D=3D '': # @@ -1245,32 +1290,36 @@ class DscParser(MetaFileParser): if self._SectionType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_P= ATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT= ): return EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value given", - ExtraData=3Dself._CurrentLine + " (.|)", + ExtraData=3Dself._CurrentLine + + " (.|)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) =20 # Validate the datum type of Dynamic Defaul PCD and DynamicEx Defa= ult PCD ValueList =3D GetSplitValueList(self._ValueList[2]) if len(ValueList) > 1 and ValueList[1] in [TAB_UINT8, TAB_UINT16, = TAB_UINT32, TAB_UINT64] \ - and self._ItemType in [MODEL_PCD_DYNAMIC_DEF= AULT, MODEL_PCD_DYNAMIC_EX_DEFAULT]: + and self._ItemType in [MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PC= D_DYNAMIC_EX_DEFAULT]: EdkLogger.error('Parser', FORMAT_INVALID, "The datum type '%s'= of PCD is wrong" % ValueList[1], ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) =20 # Validate the VariableName of DynamicHii and DynamicExHii for PCD= Entry must not be an empty string if self._ItemType in [MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_= HII]: - DscPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_= SPLIT, 1) + DscPcdValueList =3D GetSplitValueList( + TokenList[1], TAB_VALUE_SPLIT, 1) if len(DscPcdValueList[0].replace('L', '').replace('"', '').st= rip()) =3D=3D 0: EdkLogger.error('Parser', FORMAT_INVALID, "The VariableNam= e field in the HII format PCD entry must not be an empty string", - ExtraData=3Dself._CurrentLine, File=3Dself.Met= aFile, Line=3Dself._LineIndex + 1) + ExtraData=3Dself._CurrentLine, File=3Dself= .MetaFile, Line=3Dself._LineIndex + 1) =20 # if value are 'True', 'true', 'TRUE' or 'False', 'false', 'FALSE'= , replace with integer 1 or 0. DscPcdValueList =3D GetSplitValueList(TokenList[1], TAB_VALUE_SPLI= T, 1) if DscPcdValueList[0] in ['True', 'true', 'TRUE']: - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList[0]= , '1', 1); + self._ValueList[2] =3D TokenList[1].replace( + DscPcdValueList[0], '1', 1) elif DscPcdValueList[0] in ['False', 'false', 'FALSE']: - self._ValueList[2] =3D TokenList[1].replace(DscPcdValueList[0]= , '0', 1); + self._ValueList[2] =3D TokenList[1].replace( + DscPcdValueList[0], '0', 1) =20 + # [components] section parser =20 - ## [components] section parser @ParseMacro def _ComponentParser(self): if self._CurrentLine[-1] =3D=3D '{': @@ -1280,27 +1329,30 @@ class DscParser(MetaFileParser): else: self._ValueList[0] =3D self._CurrentLine =20 - ## [LibraryClasses] section + # [LibraryClasses] section @ParseMacro def _LibraryClassParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No library class or= instance specified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if TokenList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No library class sp= ecified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No library instance= specified", - ExtraData=3Dself._CurrentLine + " (|)", + ExtraData=3Dself._CurrentLine + + " (|)", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) =20 self._ValueList[0:len(TokenList)] =3D TokenList =20 + # [BuildOptions] section parser =20 - ## [BuildOptions] section parser @ParseMacro def _BuildOptionParser(self): self._CurrentLine =3D CleanString(self._CurrentLine, BuildOption= =3DTrue) @@ -1318,13 +1370,14 @@ class DscParser(MetaFileParser): EdkLogger.error( 'Parser', FORMAT_INVALID, - "'%s' must be in format of ____FLAGS" % self._ValueList[1], + "'%s' must be in format of ____FLAGS" % self._ValueList[ + 1], ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex + 1 - ) + ) =20 - ## Override parent's method since we'll do all macro replacements in p= arser + # Override parent's method since we'll do all macro replacements in pa= rser @property def _Macros(self): Macros =3D {} @@ -1347,40 +1400,41 @@ class DscParser(MetaFileParser): =20 def _PostProcess(self): Processer =3D { - MODEL_META_DATA_SECTION_HEADER : self.__Pro= cessSectionHeader, - MODEL_META_DATA_SUBSECTION_HEADER : self.__Pro= cessSubsectionHeader, - MODEL_META_DATA_HEADER : self.__Pro= cessDefine, - MODEL_META_DATA_DEFINE : self.__Pro= cessDefine, - MODEL_META_DATA_GLOBAL_DEFINE : self.__Pro= cessDefine, - MODEL_META_DATA_INCLUDE : self.__Pro= cessDirective, - MODEL_META_DATA_PACKAGE : self.__Pro= cessPackages, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF : self.__Pro= cessDirective, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF : self.__Pro= cessDirective, - MODEL_EFI_SKU_ID : self.__Pro= cessSkuId, - MODEL_EFI_DEFAULT_STORES : self.__Pro= cessDefaultStores, - MODEL_EFI_LIBRARY_INSTANCE : self.__Pro= cessLibraryInstance, - MODEL_EFI_LIBRARY_CLASS : self.__Pro= cessLibraryClass, - MODEL_PCD_FIXED_AT_BUILD : self.__Pro= cessPcd, - MODEL_PCD_PATCHABLE_IN_MODULE : self.__Pro= cessPcd, - MODEL_PCD_FEATURE_FLAG : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_DEFAULT : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_HII : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_VPD : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_DEFAULT : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_HII : self.__Pro= cessPcd, - MODEL_PCD_DYNAMIC_EX_VPD : self.__Pro= cessPcd, - MODEL_META_DATA_COMPONENT : self.__Pro= cessComponent, - MODEL_META_DATA_BUILD_OPTION : self.__Pro= cessBuildOption, - MODEL_UNKNOWN : self._Skip, - MODEL_META_DATA_USER_EXTENSION : self._Skip= UserExtension, - MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR : self._Proc= essError, + MODEL_META_DATA_SECTION_HEADER: self.__ProcessSectionHeader, + MODEL_META_DATA_SUBSECTION_HEADER: self.__ProcessSubsectionH= eader, + MODEL_META_DATA_HEADER: self.__ProcessDefine, + MODEL_META_DATA_DEFINE: self.__ProcessDefine, + MODEL_META_DATA_GLOBAL_DEFINE: self.__ProcessDefine, + MODEL_META_DATA_INCLUDE: self.__ProcessDirective, + MODEL_META_DATA_PACKAGE: self.__ProcessPackages, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IF: self.__ProcessDire= ctive, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE: self.__ProcessDi= rective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF: self.__ProcessD= irective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF: self.__Process= Directive, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF: self.__ProcessD= irective, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF: self.__Process= Directive, + MODEL_EFI_SKU_ID: self.__ProcessSkuId, + MODEL_EFI_DEFAULT_STORES: self.__ProcessDefaultStores, + MODEL_EFI_LIBRARY_INSTANCE: self.__ProcessLibraryInstance, + MODEL_EFI_LIBRARY_CLASS: self.__ProcessLibraryClass, + MODEL_PCD_FIXED_AT_BUILD: self.__ProcessPcd, + MODEL_PCD_PATCHABLE_IN_MODULE: self.__ProcessPcd, + MODEL_PCD_FEATURE_FLAG: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_DEFAULT: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_HII: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_VPD: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_DEFAULT: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_HII: self.__ProcessPcd, + MODEL_PCD_DYNAMIC_EX_VPD: self.__ProcessPcd, + MODEL_META_DATA_COMPONENT: self.__ProcessComponent, + MODEL_META_DATA_BUILD_OPTION: self.__ProcessBuildOption, + MODEL_UNKNOWN: self._Skip, + MODEL_META_DATA_USER_EXTENSION: self._SkipUserExtension, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR: self._ProcessEr= ror, } =20 - self._Table =3D MetaFileStorage(self._RawTable.DB, self.MetaFile, = MODEL_FILE_DSC, True) + self._Table =3D MetaFileStorage( + self._RawTable.DB, self.MetaFile, MODEL_FILE_DSC, True) self._DirectiveStack =3D [] self._DirectiveEvalStack =3D [] self._FileWithError =3D self.MetaFile @@ -1393,7 +1447,7 @@ class DscParser(MetaFileParser): self._Content =3D self._RawTable.GetAll() self._ContentIndex =3D 0 self._InSubsection =3D False - while self._ContentIndex < len(self._Content) : + while self._ContentIndex < len(self._Content): Id, self._ItemType, V1, V2, V3, S1, S2, S3, Owner, self._From,= \ LineStart, ColStart, LineEnd, ColEnd, Enabled =3D self._Co= ntent[self._ContentIndex] =20 @@ -1438,52 +1492,60 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Cannot = use this PCD (%s) in an expression as" " it must be defined in a [PcdsFix= edAtBuild] or [PcdsFeatureFlag] section" " of the DSC file, and it is curre= ntly defined in this section:" - " %s, line #: %d." % (Excpt.Pcd, I= nfo[0], Info[1]), - File=3Dself._FileWithError, ExtraData= =3D' '.join(self._ValueList), - Line=3Dself._LineIndex + 1) + " %s, line #: %d." % ( + Excpt.Pcd, Info[0], Info[1]), + File=3Dself._FileWithError, ExtraD= ata=3D' '.join( + self._ValueList), + Line=3Dself._LineIndex + 1) else: EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s= ) is not defined in DSC file" % Excpt.Pcd, - File=3Dself._FileWithError, ExtraData= =3D' '.join(self._ValueList), - Line=3Dself._LineIndex + 1) + File=3Dself._FileWithError, ExtraD= ata=3D' '.join( + self._ValueList), + Line=3Dself._LineIndex + 1) else: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid exp= ression: %s" % str(Excpt), - File=3Dself._FileWithError, ExtraData= =3D' '.join(self._ValueList), + File=3Dself._FileWithError, ExtraData= =3D' '.join( + self._ValueList), Line=3Dself._LineIndex + 1) except MacroException as Excpt: EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt), - File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList), + File=3Dself._FileWithError, ExtraData=3D' = '.join( + self._ValueList), Line=3Dself._LineIndex + 1) =20 if self._ValueList is None: continue =20 NewOwner =3D self._IdMapping.get(Owner, -1) - self._Enabled =3D int((not self._DirectiveEvalStack) or (False= not in self._DirectiveEvalStack)) + self._Enabled =3D int((not self._DirectiveEvalStack) or ( + False not in self._DirectiveEvalStack)) self._LastItem =3D self._Store( - self._ItemType, - self._ValueList[0], - self._ValueList[1], - self._ValueList[2], - S1, - S2, - S3, - NewOwner, - self._From, - self._LineIndex + 1, - - 1, - self._LineIndex + 1, - - 1, - self._Enabled - ) + self._ItemType, + self._ValueList[0], + self._ValueList[1], + self._ValueList[2], + S1, + S2, + S3, + NewOwner, + self._From, + self._LineIndex + 1, + - 1, + self._LineIndex + 1, + - 1, + self._Enabled + ) self._IdMapping[Id] =3D self._LastItem =20 GlobalData.gPlatformDefines.update(self._FileLocalMacros) self._PostProcessed =3D True self._Content =3D None + def _ProcessError(self): if not self._Enabled: return - EdkLogger.error('Parser', ERROR_STATEMENT, self._ValueList[1], Fil= e=3Dself.MetaFile, Line=3Dself._LineIndex + 1) + EdkLogger.error('Parser', ERROR_STATEMENT, + self._ValueList[1], File=3Dself.MetaFile, Line=3Ds= elf._LineIndex + 1) =20 def __ProcessSectionHeader(self): self._SectionName =3D self._ValueList[0] @@ -1504,20 +1566,22 @@ class DscParser(MetaFileParser): with open(str(self.MetaFile), 'r') as File: Content =3D File.readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) =20 GlobalData.gPlatformOtherPcds['DSCFILE'] =3D str(self.MetaFile) for PcdType in (MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_D= EFAULT, MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAUL= T, MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_EX_VPD): - Records =3D self._RawTable.Query(PcdType, BelongsToItem=3D -1.= 0) + Records =3D self._RawTable.Query(PcdType, BelongsToItem=3D-1.0) for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, Dummy4, ID= , Line in Records: Name =3D TokenSpaceGuid + '.' + PcdName if Name not in GlobalData.gPlatformOtherPcds: PcdLine =3D Line while not Content[Line - 1].lstrip().startswith(TAB_SE= CTION_START): Line -=3D 1 - GlobalData.gPlatformOtherPcds[Name] =3D (CleanString(C= ontent[Line - 1]), PcdLine, PcdType) + GlobalData.gPlatformOtherPcds[Name] =3D ( + CleanString(Content[Line - 1]), PcdLine, PcdType) =20 def __ProcessDefine(self): if not self._Enabled: @@ -1557,7 +1621,8 @@ class DscParser(MetaFileParser): try: Result =3D ValueExpression(self._ValueList[1], Macros)() except SymbolNotFound as Exc: - EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueLi= st[1]) + EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), + self._ValueList[1]) Result =3D False except WrnExpression as Excpt: # @@ -1565,8 +1630,9 @@ class DscParser(MetaFileParser): # the precise number of line and return the evaluation res= ult # EdkLogger.warn('Parser', "Suspicious expression: %s" % str= (Excpt), - File=3Dself._FileWithError, ExtraData=3D' = '.join(self._ValueList), - Line=3Dself._LineIndex + 1) + File=3Dself._FileWithError, ExtraData=3D' '= .join( + self._ValueList), + Line=3Dself._LineIndex + 1) Result =3D Excpt.result =20 if self._ItemType in [MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, @@ -1577,7 +1643,8 @@ class DscParser(MetaFileParser): Result =3D bool(Result) else: Macro =3D self._ValueList[1] - Macro =3D Macro[2:-1] if (Macro.startswith("$(") and Macro= .endswith(")")) else Macro + Macro =3D Macro[2:-1] if (Macro.startswith("$(") + and Macro.endswith(")")) else Macro Result =3D Macro in self._Macros if self._ItemType =3D=3D MODEL_META_DATA_CONDITIONAL_STATE= MENT_IFNDEF: Result =3D not Result @@ -1611,7 +1678,8 @@ class DscParser(MetaFileParser): # __IncludeMacros.update(self._Macros) =20 - IncludedFile =3D NormPath(ReplaceMacro(self._ValueList[1], __I= ncludeMacros, RaiseError=3DTrue)) + IncludedFile =3D NormPath(ReplaceMacro( + self._ValueList[1], __IncludeMacros, RaiseError=3DTrue)) # # First search the include file under the same directory as DS= C file # @@ -1622,7 +1690,8 @@ class DscParser(MetaFileParser): # # Also search file under the WORKSPACE directory # - IncludedFile1 =3D PathClass(IncludedFile, GlobalData.g= Workspace) + IncludedFile1 =3D PathClass( + IncludedFile, GlobalData.gWorkspace) ErrorCode, ErrorInfo2 =3D IncludedFile1.Validate() if ErrorCode !=3D 0: EdkLogger.error('parser', ErrorCode, File=3Dself._= FileWithError, @@ -1635,11 +1704,12 @@ class DscParser(MetaFileParser): Owner =3D self._Content[self._ContentIndex - 1][8] else: Owner =3D self._Content[self._ContentIndex - 1][0] - IncludedFileTable =3D MetaFileStorage(self._RawTable.DB, I= ncludedFile1, MODEL_FILE_DSC, False, FromItem=3DFromItem) + IncludedFileTable =3D MetaFileStorage( + self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, Fals= e, FromItem=3DFromItem) Parser =3D DscParser(IncludedFile1, self._FileType, self._= Arch, IncludedFileTable, Owner=3DOwner, From=3DFromItem) =20 - self.IncludedFiles.add (IncludedFile1) + self.IncludedFiles.add(IncludedFile1) =20 # set the parser status with current status Parser._SectionName =3D self._SectionName @@ -1664,22 +1734,27 @@ class DscParser(MetaFileParser): def __ProcessSkuId(self): self._ValueList =3D [ReplaceMacro(Value, self._Macros, RaiseError= =3DTrue) for Value in self._ValueList] + def __ProcessDefaultStores(self): self._ValueList =3D [ReplaceMacro(Value, self._Macros, RaiseError= =3DTrue) for Value in self._ValueList] =20 def __ProcessLibraryInstance(self): - self._ValueList =3D [ReplaceMacro(Value, self._Macros) for Value i= n self._ValueList] + self._ValueList =3D [ReplaceMacro(Value, self._Macros) + for Value in self._ValueList] =20 def __ProcessLibraryClass(self): - self._ValueList[1] =3D ReplaceMacro(self._ValueList[1], self._Macr= os, RaiseError=3DTrue) + self._ValueList[1] =3D ReplaceMacro( + self._ValueList[1], self._Macros, RaiseError=3DTrue) =20 def __ProcessPcd(self): if self._ItemType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_= AT_BUILD]: - self._ValueList[2] =3D ReplaceMacro(self._ValueList[2], self._= Macros, RaiseError=3DTrue) + self._ValueList[2] =3D ReplaceMacro( + self._ValueList[2], self._Macros, RaiseError=3DTrue) return =20 - ValList, Valid, Index =3D AnalyzeDscPcd(self._ValueList[2], self._= ItemType) + ValList, Valid, Index =3D AnalyzeDscPcd( + self._ValueList[2], self._ItemType) if not Valid: if self._ItemType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYN= AMIC_EX_DEFAULT, MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE): if ValList[1] !=3D TAB_VOID and StructPattern.match(ValLis= t[1]) is None and ValList[2]: @@ -1702,7 +1777,8 @@ class DscParser(MetaFileParser): ValList[Index] =3D '0' =20 if (not self._DirectiveEvalStack) or (False not in self._Directive= EvalStack): - GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])]= =3D PcdValue + GlobalData.gPlatformPcds[TAB_SPLIT.join( + self._ValueList[0:2])] =3D PcdValue self._Symbols[TAB_SPLIT.join(self._ValueList[0:2])] =3D PcdVal= ue try: self._ValueList[2] =3D '|'.join(ValList) @@ -1716,61 +1792,63 @@ class DscParser(MetaFileParser): self._ValueList =3D [ReplaceMacro(Value, self._Macros, RaiseError= =3DFalse) for Value in self._ValueList] =20 - def DisableOverrideComponent(self,module_id): + def DisableOverrideComponent(self, module_id): for ori_id in self._IdMapping: if self._IdMapping[ori_id] =3D=3D module_id: self._RawTable.DisableComponent(ori_id) =20 _SectionParser =3D { - MODEL_META_DATA_HEADER : _DefineParser, - MODEL_EFI_SKU_ID : _SkuIdParser, - MODEL_EFI_DEFAULT_STORES : _DefaultStores= Parser, - MODEL_EFI_LIBRARY_INSTANCE : _LibraryInstan= ceParser, - MODEL_EFI_LIBRARY_CLASS : _LibraryClassP= arser, - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC_DEFAULT : _PcdParser, - MODEL_PCD_DYNAMIC_HII : _PcdParser, - MODEL_PCD_DYNAMIC_VPD : _PcdParser, - MODEL_PCD_DYNAMIC_EX_DEFAULT : _PcdParser, - MODEL_PCD_DYNAMIC_EX_HII : _PcdParser, - MODEL_PCD_DYNAMIC_EX_VPD : _PcdParser, - MODEL_META_DATA_COMPONENT : _ComponentPars= er, - MODEL_META_DATA_BUILD_OPTION : _BuildOptionPa= rser, - MODEL_UNKNOWN : MetaFileParser= ._Skip, - MODEL_META_DATA_PACKAGE : MetaFileParser= ._PackageParser, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser= ._SkipUserExtension, - MODEL_META_DATA_SECTION_HEADER : MetaFileParser= ._SectionHeaderParser, - MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHea= derParser, + MODEL_META_DATA_HEADER: _DefineParser, + MODEL_EFI_SKU_ID: _SkuIdParser, + MODEL_EFI_DEFAULT_STORES: _DefaultStoresParser, + MODEL_EFI_LIBRARY_INSTANCE: _LibraryInstanceParser, + MODEL_EFI_LIBRARY_CLASS: _LibraryClassParser, + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC_DEFAULT: _PcdParser, + MODEL_PCD_DYNAMIC_HII: _PcdParser, + MODEL_PCD_DYNAMIC_VPD: _PcdParser, + MODEL_PCD_DYNAMIC_EX_DEFAULT: _PcdParser, + MODEL_PCD_DYNAMIC_EX_HII: _PcdParser, + MODEL_PCD_DYNAMIC_EX_VPD: _PcdParser, + MODEL_META_DATA_COMPONENT: _ComponentParser, + MODEL_META_DATA_BUILD_OPTION: _BuildOptionParser, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_PACKAGE: MetaFileParser._PackageParser, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._SkipUserExtensio= n, + MODEL_META_DATA_SECTION_HEADER: MetaFileParser._SectionHeaderPar= ser, + MODEL_META_DATA_SUBSECTION_HEADER: _SubsectionHeaderParser, } =20 -## DEC file parser class +# DEC file parser class # # @param FilePath The path of platform description file # @param FileType The raw data of DSC file # @param Table Database used to retrieve module/package i= nformation # @param Macros Macros used for replacement in file # + + class DecParser(MetaFileParser): # DEC file supported data types (one type per section) DataType =3D { - TAB_DEC_DEFINES.upper() : MODEL_META_DATA_HE= ADER, - TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DE= FINE, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_= CLASS, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT= _BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABL= E_IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_= FLAG, - TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC, - TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_= EX, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_US= ER_EXTENSION, + TAB_DEC_DEFINES.upper(): MODEL_META_DATA_HEADER, + TAB_DSC_DEFINES_DEFINE: MODEL_META_DATA_DEFINE, + TAB_INCLUDES.upper(): MODEL_EFI_INCLUDE, + TAB_LIBRARY_CLASSES.upper(): MODEL_EFI_LIBRARY_CLASS, + TAB_GUIDS.upper(): MODEL_EFI_GUID, + TAB_PPIS.upper(): MODEL_EFI_PPI, + TAB_PROTOCOLS.upper(): MODEL_EFI_PROTOCOL, + TAB_PCDS_FIXED_AT_BUILD_NULL.upper(): MODEL_PCD_FIXED_AT_BUILD, + TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper(): MODEL_PCD_PATCHABLE_I= N_MODULE, + TAB_PCDS_FEATURE_FLAG_NULL.upper(): MODEL_PCD_FEATURE_FLAG, + TAB_PCDS_DYNAMIC_NULL.upper(): MODEL_PCD_DYNAMIC, + TAB_PCDS_DYNAMIC_EX_NULL.upper(): MODEL_PCD_DYNAMIC_EX, + TAB_USER_EXTENSIONS.upper(): MODEL_META_DATA_USER_EXTENSION, } =20 - ## Constructor of DecParser + # Constructor of DecParser # # Initialize object of DecParser # @@ -1786,7 +1864,7 @@ class DecParser(MetaFileParser): MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, -1) self._Comments =3D [] self._Version =3D 0x00010005 # Only EDK2 dec file is supported - self._AllPCDs =3D [] # Only for check duplicate PCD + self._AllPCDs =3D [] # Only for check duplicate PCD self._AllPcdDict =3D {} =20 self._CurrentStructurePcdName =3D "" @@ -1795,14 +1873,15 @@ class DecParser(MetaFileParser): =20 self._RestofValue =3D "" =20 - ## Parser starter + # Parser starter def Start(self): Content =3D '' try: with open(str(self.MetaFile), 'r') as File: Content =3D File.readlines() except: - EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=3Dself.= MetaFile) + EdkLogger.error("Parser", FILE_READ_FAILURE, + ExtraData=3Dself.MetaFile) =20 Content =3D self.ProcessMultipleLineCODEValue(Content) =20 @@ -1829,7 +1908,7 @@ class DecParser(MetaFileParser): if self._SectionType =3D=3D MODEL_UNKNOWN: EdkLogger.error("Parser", FORMAT_INVALID, "" - "Not able to determine \"%s\" in which sec= tion."%self._CurrentLine, + "Not able to determine \"%s\" in which sec= tion." % self._CurrentLine, self.MetaFile, self._LineIndex + 1) elif len(self._SectionType) =3D=3D 0: self._Comments =3D [] @@ -1861,7 +1940,7 @@ class DecParser(MetaFileParser): self._LineIndex + 1, - 1, 0 - ) + ) for Comment, LineNo in self._Comments: self._Store( MODEL_META_DATA_COMMENT, @@ -1876,21 +1955,23 @@ class DecParser(MetaFileParser): LineNo, - 1, 0 - ) + ) self._Comments =3D [] if self._DefinesCount > 1: - EdkLogger.error('Parser', FORMAT_INVALID, 'Multiple [Defines] = section is exist.', self.MetaFile ) + EdkLogger.error('Parser', FORMAT_INVALID, + 'Multiple [Defines] section is exist.', self.M= etaFile) if self._DefinesCount =3D=3D 0: - EdkLogger.error('Parser', FORMAT_INVALID, 'No [Defines] sectio= n exist.', self.MetaFile) + EdkLogger.error('Parser', FORMAT_INVALID, + 'No [Defines] section exist.', self.MetaFile) self._Done() =20 - - ## Section header parser + # Section header parser # # The section header is always in following format: # # [section_name.arch<.platform|module_type>] # + def _SectionHeaderParser(self): self._Scope =3D [] self._SectionName =3D '' @@ -1919,13 +2000,13 @@ class DecParser(MetaFileParser): =20 if MODEL_PCD_FEATURE_FLAG in self._SectionType and len(self._S= ectionType) > 1: EdkLogger.error( - 'Parser', - FORMAT_INVALID, - "%s must not be in the same section of other t= ypes of PCD" % TAB_PCDS_FEATURE_FLAG_NULL, - File=3Dself.MetaFile, - Line=3Dself._LineIndex + 1, - ExtraData=3Dself._CurrentLine - ) + 'Parser', + FORMAT_INVALID, + "%s must not be in the same section of other types of = PCD" % TAB_PCDS_FEATURE_FLAG_NULL, + File=3Dself.MetaFile, + Line=3Dself._LineIndex + 1, + ExtraData=3Dself._CurrentLine + ) # S1 is always Arch if len(ItemList) > 1: S1 =3D ItemList[1].upper() @@ -1956,33 +2037,36 @@ class DecParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Can't mix section t= ags without the Private attribute with section tags with the Private attrib= ute", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1, ExtraData=3Dself._CurrentLine) =20 - ## [guids], [ppis] and [protocols] section parser + # [guids], [ppis] and [protocols] section parser @ParseMacro def _GuidParser(self): TokenList =3D GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT= , 1) if len(TokenList) < 2: EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name or val= ue specified", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if TokenList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID name specif= ied", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No GUID value speci= fied", - ExtraData=3Dself._CurrentLine + " ( =3D= )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) if TokenList[1][0] !=3D '{' or TokenList[1][-1] !=3D '}' or GuidSt= ructureStringToGuidString(TokenList[1]) =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Invalid GUID value = format", - ExtraData=3Dself._CurrentLine + \ - " ( =3D )", + ExtraData=3Dself._CurrentLine + + " ( =3D )", File=3Dself.MetaFile, Line=3Dself._LineIndex += 1) self._ValueList[0] =3D TokenList[0] self._ValueList[1] =3D TokenList[1] if self._ValueList[0] not in self._GuidDict: self._GuidDict[self._ValueList[0]] =3D self._ValueList[1] =20 - def ParsePcdName(self,namelist): + def ParsePcdName(self, namelist): if "[" in namelist[1]: pcdname =3D namelist[1][:namelist[1].index("[")] arrayindex =3D namelist[1][namelist[1].index("["):] @@ -1990,10 +2074,10 @@ class DecParser(MetaFileParser): if len(namelist) =3D=3D 2: namelist.append(arrayindex) else: - namelist[2] =3D ".".join((arrayindex,namelist[2])) + namelist[2] =3D ".".join((arrayindex, namelist[2])) return namelist =20 - ## PCD sections parser + # PCD sections parser # # [PcdsFixedAtBuild] # [PcdsPatchableInModule] @@ -2020,10 +2104,12 @@ class DecParser(MetaFileParser): return =20 if self._include_flag: - self._ValueList[1] =3D "_" + md5(self._Cu= rrentLine.encode('utf-8')).hexdigest() + self._ValueList[1] =3D "_" + \ + md5(self._CurrentLine.encode('utf-8')).hexdigest() self._ValueList[2] =3D self._CurrentLine if self._package_flag and "}" !=3D self._CurrentLine: - self._ValueList[1] =3D "_" + md5(self._Curre= ntLine.encode('utf-8')).hexdigest() + self._ValueList[1] =3D "_" + \ + md5(self._CurrentLine.encode('utf-8')).hexdigest() self._ValueList[2] =3D self._CurrentLine if self._CurrentLine =3D=3D "}": self._package_flag =3D False @@ -2037,7 +2123,8 @@ class DecParser(MetaFileParser): if PcdNames[1].strip().endswith("]"): PcdName =3D PcdNames[1][:PcdNames[1].index('[')] Index =3D PcdNames[1][PcdNames[1].index('['):] - self._ValueList[0] =3D TAB_SPLIT.join((PcdNames[0]= ,PcdName)) + self._ValueList[0] =3D TAB_SPLIT.join( + (PcdNames[0], PcdName)) self._ValueList[1] =3D Index self._ValueList[2] =3D PcdTockens[1] else: @@ -2045,22 +2132,24 @@ class DecParser(MetaFileParser): else: if self._CurrentStructurePcdName !=3D TAB_SPLIT.join(P= cdNames[:2]): EdkLogger.error('Parser', FORMAT_INVALID, "Pcd Nam= e does not match: %s and %s " % (self._CurrentStructurePcdName, TAB_SPLIT.j= oin(PcdNames[:2])), - File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) + File=3Dself.MetaFile, Line=3Dself.= _LineIndex + 1) self._ValueList[1] =3D TAB_SPLIT.join(PcdNames[2:]) self._ValueList[2] =3D PcdTockens[1] if not self._CurrentStructurePcdName: if self._PcdDataTypeCODE: if ")}" in self._CurrentLine: - ValuePart,RestofValue =3D self._CurrentLine.split(")}") + ValuePart, RestofValue =3D self._CurrentLine.split(")}= ") self._PcdCodeValue =3D self._PcdCodeValue + "\n " + Va= luePart - self._CurrentLine =3D "|".join((self._CurrentPcdName, = self._PcdCodeValue,RestofValue)) + self._CurrentLine =3D "|".join( + (self._CurrentPcdName, self._PcdCodeValue, RestofV= alue)) self._PcdDataTypeCODE =3D False self._PcdCodeValue =3D "" else: self._PcdCodeValue =3D self._PcdCodeValue + "\n " + se= lf._CurrentLine self._ValueList =3D None return - TokenList =3D GetSplitValueList(self._CurrentLine, TAB_VALUE_S= PLIT, 1) + TokenList =3D GetSplitValueList( + self._CurrentLine, TAB_VALUE_SPLIT, 1) self._CurrentPcdName =3D TokenList[0] if len(TokenList) =3D=3D 2 and TokenList[1].strip().startswith= ("{CODE"): if ")}" in self._CurrentLine: @@ -2077,29 +2166,28 @@ class DecParser(MetaFileParser): # check PCD information if self._ValueList[0] =3D=3D '' or self._ValueList[1] =3D=3D '= ': EdkLogger.error('Parser', FORMAT_INVALID, "No token space = GUID or PCD name specified", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check format of token space GUID CName if not ValueRe.match(self._ValueList[0]): EdkLogger.error('Parser', FORMAT_INVALID, "The format of t= he token space GUID CName is invalid. The correct format is '(a-zA-Z_)[a-zA= -Z0-9_]*'", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check format of PCD CName if not ValueRe.match(self._ValueList[1]): EdkLogger.error('Parser', FORMAT_INVALID, "The format of t= he PCD CName is invalid. The correct format is '(a-zA-Z_)[a-zA-Z0-9_]*'", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check PCD datum information if len(TokenList) < 2 or TokenList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum in= formation given", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) =20 - ValueRe =3D re.compile(r'^\s*L?\".*\|.*\"') PtrValue =3D ValueRe.findall(TokenList[1]) =20 @@ -2111,39 +2199,40 @@ class DecParser(MetaFileParser): else: ValueList =3D AnalyzePcdExpression(TokenList[1]) =20 - # check if there's enough datum information given if len(ValueList) !=3D 3: EdkLogger.error('Parser', FORMAT_INVALID, "Invalid PCD Dat= um information given", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check default value if ValueList[0] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing Default= Value in PCD Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check datum type if ValueList[1] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing DatumTy= pe in PCD Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) # check token of the PCD if ValueList[2] =3D=3D '': EdkLogger.error('Parser', FORMAT_INVALID, "Missing Token i= n PCD Datum information", - ExtraData=3Dself._CurrentLine + \ - " (.|||)", + ExtraData=3Dself._CurrentLine + + " (.|||)", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) =20 PcdValue =3D ValueList[0] if PcdValue: try: self._GuidDict.update(self._AllPcdDict) - ValueList[0] =3D ValueExpressionEx(ValueList[0], Value= List[1], self._GuidDict)(True) + ValueList[0] =3D ValueExpressionEx( + ValueList[0], ValueList[1], self._GuidDict)(True) except BadExpression as Value: - EdkLogger.error('Parser', FORMAT_INVALID, Value, Extra= Data=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) + EdkLogger.error('Parser', FORMAT_INVALID, Value, Extra= Data=3Dself._CurrentLine, + File=3Dself.MetaFile, Line=3Dself._Lin= eIndex + 1) # check format of default value against the datum type IsValid, Cause =3D CheckPcdDatum(ValueList[1], ValueList[0]) if not IsValid: @@ -2151,7 +2240,8 @@ class DecParser(MetaFileParser): File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1) =20 if Cause =3D=3D "StructurePcd": - self._CurrentStructurePcdName =3D TAB_SPLIT.join(self._Val= ueList[0:2]) + self._CurrentStructurePcdName =3D TAB_SPLIT.join( + self._ValueList[0:2]) self._ValueList[0] =3D self._CurrentStructurePcdName self._ValueList[1] =3D ValueList[1].strip() =20 @@ -2166,27 +2256,31 @@ class DecParser(MetaFileParser): "The same PCD name and GUID have been alre= ady defined", ExtraData=3Dself._CurrentLine, File=3Dself= .MetaFile, Line=3Dself._LineIndex + 1) else: - self._AllPCDs.append((self._Scope[0], self._ValueList[0], = self._ValueList[1])) - self._AllPcdDict[TAB_SPLIT.join(self._ValueList[0:2])] =3D= ValueList[0] + self._AllPCDs.append( + (self._Scope[0], self._ValueList[0], self._ValueList[1= ])) + self._AllPcdDict[TAB_SPLIT.join( + self._ValueList[0:2])] =3D ValueList[0] =20 - self._ValueList[2] =3D ValueList[0].strip() + '|' + ValueList[= 1].strip() + '|' + ValueList[2].strip() + self._ValueList[2] =3D ValueList[0].strip( + ) + '|' + ValueList[1].strip() + '|' + ValueList[2].strip() =20 _SectionParser =3D { - MODEL_META_DATA_HEADER : MetaFileParser._DefineParser, - MODEL_EFI_INCLUDE : MetaFileParser._PathParser, - MODEL_EFI_LIBRARY_CLASS : MetaFileParser._PathParser, - MODEL_EFI_GUID : _GuidParser, - MODEL_EFI_PPI : _GuidParser, - MODEL_EFI_PROTOCOL : _GuidParser, - MODEL_PCD_FIXED_AT_BUILD : _PcdParser, - MODEL_PCD_PATCHABLE_IN_MODULE : _PcdParser, - MODEL_PCD_FEATURE_FLAG : _PcdParser, - MODEL_PCD_DYNAMIC : _PcdParser, - MODEL_PCD_DYNAMIC_EX : _PcdParser, - MODEL_UNKNOWN : MetaFileParser._Skip, - MODEL_META_DATA_USER_EXTENSION : MetaFileParser._SkipUserExtens= ion, + MODEL_META_DATA_HEADER: MetaFileParser._DefineParser, + MODEL_EFI_INCLUDE: MetaFileParser._PathParser, + MODEL_EFI_LIBRARY_CLASS: MetaFileParser._PathParser, + MODEL_EFI_GUID: _GuidParser, + MODEL_EFI_PPI: _GuidParser, + MODEL_EFI_PROTOCOL: _GuidParser, + MODEL_PCD_FIXED_AT_BUILD: _PcdParser, + MODEL_PCD_PATCHABLE_IN_MODULE: _PcdParser, + MODEL_PCD_FEATURE_FLAG: _PcdParser, + MODEL_PCD_DYNAMIC: _PcdParser, + MODEL_PCD_DYNAMIC_EX: _PcdParser, + MODEL_UNKNOWN: MetaFileParser._Skip, + MODEL_META_DATA_USER_EXTENSION: MetaFileParser._SkipUserExtensio= n, } =20 + ## # # This acts like the main() function for the script, unless it is 'import'= ed into another @@ -2194,4 +2288,3 @@ class DecParser(MetaFileParser): # if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools= /Source/Python/Workspace/MetaFileTable.py index bebf9062e8e5..307a709fb57d 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create/update/query/erase a meta file table # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -15,15 +15,16 @@ import Common.EdkLogger as EdkLogger from Common.BuildToolError import FORMAT_INVALID =20 from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODE= L_FILE_INF, \ - MODEL_FILE_OTHERS + MODEL_FILE_OTHERS from Common.DataType import * =20 + class MetaFileTable(): # TRICK: use file ID as the part before '.' _ID_STEP_ =3D 1 _ID_MAX_ =3D 99999999 =20 - ## Constructor + # Constructor def __init__(self, DB, MetaFile, FileType, Temporary, FromItem=3DNone): self.MetaFile =3D MetaFile self.TableName =3D "" @@ -32,16 +33,17 @@ class MetaFileTable(): =20 self.CurrentContent =3D [] DB.TblFile.append([MetaFile.Name, - MetaFile.Ext, - MetaFile.Dir, - MetaFile.Path, - FileType, - MetaFile.TimeStamp, - FromItem]) + MetaFile.Ext, + MetaFile.Dir, + MetaFile.Path, + FileType, + MetaFile.TimeStamp, + FromItem]) self.FileId =3D len(DB.TblFile) self.ID =3D self.FileId * 10**8 if Temporary: - self.TableName =3D "_%s_%s_%s" % (FileType, len(DB.TblFile), u= uid.uuid4().hex) + self.TableName =3D "_%s_%s_%s" % ( + FileType, len(DB.TblFile), uuid.uuid4().hex) else: self.TableName =3D "_%s_%s" % (FileType, len(DB.TblFile)) =20 @@ -62,9 +64,11 @@ class MetaFileTable(): self.CurrentContent.append(self._DUMMY_) =20 def GetAll(self): - return [item for item in self.CurrentContent if item[0] >=3D 0 and= item[-1]>=3D0] + return [item for item in self.CurrentContent if item[0] >=3D 0 and= item[-1] >=3D 0] + +# Python class representation of table storing module data + =20 -## Python class representation of table storing module data class ModuleTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -82,13 +86,14 @@ class ModuleTable(MetaFileTable): Enabled INTEGER DEFAULT 0 ''' # used as table end flag, in case the changes to database is not commi= tted to db file - _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1] + _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', + '=3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1] =20 - ## Constructor + # Constructor def __init__(self, Db, MetaFile, Temporary): MetaFileTable.__init__(self, Db, MetaFile, MODEL_FILE_INF, Tempora= ry) =20 - ## Insert a record into table Inf + # Insert a record into table Inf # # @param Model: Model of a Inf item # @param Value1: Value1 of a Inf item @@ -106,29 +111,30 @@ class ModuleTable(MetaFileTable): def Insert(self, Model, Value1, Value2, Value3, Scope1=3DTAB_ARCH_COMM= ON, Scope2=3DTAB_COMMON, BelongsToItem=3D-1, StartLine=3D-1, StartColumn=3D-1, EndLi= ne=3D-1, EndColumn=3D-1, Enabled=3D0): =20 - (Value1, Value2, Value3, Scope1, Scope2) =3D (Value1.strip(), Valu= e2.strip(), Value3.strip(), Scope1.strip(), Scope2.strip()) + (Value1, Value2, Value3, Scope1, Scope2) =3D (Value1.strip(), + Value2.strip(), Value3= .strip(), Scope1.strip(), Scope2.strip()) self.ID =3D self.ID + self._ID_STEP_ if self.ID >=3D (MODEL_FILE_INF + self._ID_MAX_): self.ID =3D MODEL_FILE_INF + self._ID_STEP_ =20 - row =3D [ self.ID, - Model, - Value1, - Value2, - Value3, - Scope1, - Scope2, - BelongsToItem, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ] + row =3D [self.ID, + Model, + Value1, + Value2, + Value3, + Scope1, + Scope2, + BelongsToItem, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ] self.CurrentContent.append(row) return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # @param Arch: The Arch attribute of Record @@ -139,7 +145,8 @@ class ModuleTable(MetaFileTable): def Query(self, Model, Arch=3DNone, Platform=3DNone, BelongsToItem=3DN= one): =20 QueryTab =3D self.CurrentContent - result =3D [item for item in QueryTab if item[1] =3D=3D Model and = item[-1]>=3D0 ] + result =3D [item for item in QueryTab if item[1] + =3D=3D Model and item[-1] >=3D 0] =20 if Arch is not None and Arch !=3D TAB_ARCH_COMMON: ArchList =3D set(['COMMON']) @@ -147,17 +154,19 @@ class ModuleTable(MetaFileTable): result =3D [item for item in result if item[5] in ArchList] =20 if Platform is not None and Platform !=3D TAB_COMMON: - Platformlist =3D set( ['COMMON','DEFAULT']) + Platformlist =3D set(['COMMON', 'DEFAULT']) Platformlist.add(Platform) result =3D [item for item in result if item[6] in Platformlist] =20 if BelongsToItem is not None: result =3D [item for item in result if item[7] =3D=3D BelongsT= oItem] =20 - result =3D [ [r[2],r[3],r[4],r[5],r[6],r[0],r[8]] for r in result ] + result =3D [[r[2], r[3], r[4], r[5], r[6], r[0], r[8]] for r in re= sult] return result =20 -## Python class representation of table storing package data +# Python class representation of table storing package data + + class PackageTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -175,13 +184,15 @@ class PackageTable(MetaFileTable): Enabled INTEGER DEFAULT 0 ''' # used as table end flag, in case the changes to database is not commi= tted to db file - _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1] + _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', + '=3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1] =20 - ## Constructor + # Constructor def __init__(self, Cursor, MetaFile, Temporary): - MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DEC, Tem= porary) + MetaFileTable.__init__(self, Cursor, MetaFile, + MODEL_FILE_DEC, Temporary) =20 - ## Insert table + # Insert table # # Insert a record into table Dec # @@ -200,27 +211,28 @@ class PackageTable(MetaFileTable): # def Insert(self, Model, Value1, Value2, Value3, Scope1=3DTAB_ARCH_COMM= ON, Scope2=3DTAB_COMMON, BelongsToItem=3D-1, StartLine=3D-1, StartColumn=3D-1, EndLi= ne=3D-1, EndColumn=3D-1, Enabled=3D0): - (Value1, Value2, Value3, Scope1, Scope2) =3D (Value1.strip(), Valu= e2.strip(), Value3.strip(), Scope1.strip(), Scope2.strip()) + (Value1, Value2, Value3, Scope1, Scope2) =3D (Value1.strip(), + Value2.strip(), Value3= .strip(), Scope1.strip(), Scope2.strip()) self.ID =3D self.ID + self._ID_STEP_ =20 - row =3D [ self.ID, - Model, - Value1, - Value2, - Value3, - Scope1, - Scope2, - BelongsToItem, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ] + row =3D [self.ID, + Model, + Value1, + Value2, + Value3, + Scope1, + Scope2, + BelongsToItem, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ] self.CurrentContent.append(row) return self.ID =20 - ## Query table + # Query table # # @param Model: The Model of Record # @param Arch: The Arch attribute of Record @@ -230,7 +242,8 @@ class PackageTable(MetaFileTable): def Query(self, Model, Arch=3DNone): =20 QueryTab =3D self.CurrentContent - result =3D [item for item in QueryTab if item[1] =3D=3D Model and = item[-1]>=3D0 ] + result =3D [item for item in QueryTab if item[1] + =3D=3D Model and item[-1] >=3D 0] =20 if Arch is not None and Arch !=3D TAB_ARCH_COMMON: ArchList =3D set(['COMMON']) @@ -242,7 +255,8 @@ class PackageTable(MetaFileTable): def GetValidExpression(self, TokenSpaceGuid, PcdCName): =20 QueryTab =3D self.CurrentContent - result =3D [[item[2], item[8]] for item in QueryTab if item[3] =3D= =3D TokenSpaceGuid and item[4] =3D=3D PcdCName] + result =3D [[item[2], item[8]] for item in QueryTab if item[3] + =3D=3D TokenSpaceGuid and item[4] =3D=3D PcdCName] validateranges =3D [] validlists =3D [] expressions =3D [] @@ -276,7 +290,9 @@ class PackageTable(MetaFileTable): return set(), set(), set() return set(validateranges), set(validlists), set(expressions) =20 -## Python class representation of table storing platform data +# Python class representation of table storing platform data + + class PlatformTable(MetaFileTable): _COLUMN_ =3D ''' ID REAL PRIMARY KEY, @@ -296,13 +312,15 @@ class PlatformTable(MetaFileTable): Enabled INTEGER DEFAULT 0 ''' # used as table end flag, in case the changes to database is not commi= tted to db file - _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D','=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1] + _DUMMY_ =3D [-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', + '=3D=3D=3D=3D', '=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1] =20 - ## Constructor + # Constructor def __init__(self, Cursor, MetaFile, Temporary, FromItem=3D0): - MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Tem= porary, FromItem) + MetaFileTable.__init__(self, Cursor, MetaFile, + MODEL_FILE_DSC, Temporary, FromItem) =20 - ## Insert table + # Insert table # # Insert a record into table Dsc # @@ -320,32 +338,32 @@ class PlatformTable(MetaFileTable): # @param EndColumn: EndColumn of a Dsc item # @param Enabled: If this item enabled # - def Insert(self, Model, Value1, Value2, Value3, Scope1=3DTAB_ARCH_COMM= ON, Scope2=3DTAB_COMMON, Scope3=3DTAB_DEFAULT_STORES_DEFAULT,BelongsToItem= =3D-1, + def Insert(self, Model, Value1, Value2, Value3, Scope1=3DTAB_ARCH_COMM= ON, Scope2=3DTAB_COMMON, Scope3=3DTAB_DEFAULT_STORES_DEFAULT, BelongsToItem= =3D-1, FromItem=3D-1, StartLine=3D-1, StartColumn=3D-1, EndLine=3D= -1, EndColumn=3D-1, Enabled=3D1): - (Value1, Value2, Value3, Scope1, Scope2, Scope3) =3D (Value1.strip= (), Value2.strip(), Value3.strip(), Scope1.strip(), Scope2.strip(), Scope3.= strip()) + (Value1, Value2, Value3, Scope1, Scope2, Scope3) =3D (Value1.strip= (), Value2.strip( + ), Value3.strip(), Scope1.strip(), Scope2.strip(), Scope3.strip()) self.ID =3D self.ID + self._ID_STEP_ =20 - row =3D [ self.ID, - Model, - Value1, - Value2, - Value3, - Scope1, - Scope2, - Scope3, - BelongsToItem, - FromItem, - StartLine, - StartColumn, - EndLine, - EndColumn, - Enabled - ] + row =3D [self.ID, + Model, + Value1, + Value2, + Value3, + Scope1, + Scope2, + Scope3, + BelongsToItem, + FromItem, + StartLine, + StartColumn, + EndLine, + EndColumn, + Enabled + ] self.CurrentContent.append(row) return self.ID =20 - - ## Query table + # Query table # # @param Model: The Model of Record # @param Scope1: Arch of a Dsc item @@ -355,15 +373,17 @@ class PlatformTable(MetaFileTable): # # @retval: A recordSet of all found records # + def Query(self, Model, Scope1=3DNone, Scope2=3DNone, BelongsToItem=3DN= one, FromItem=3DNone): =20 QueryTab =3D self.CurrentContent - result =3D [item for item in QueryTab if item[1] =3D=3D Model and = item[-1]>0 ] + result =3D [item for item in QueryTab if item[1] + =3D=3D Model and item[-1] > 0] if Scope1 is not None and Scope1 !=3D TAB_ARCH_COMMON: Sc1 =3D set(['COMMON']) Sc1.add(Scope1) result =3D [item for item in result if item[5] in Sc1] - Sc2 =3D set( ['COMMON','DEFAULT']) + Sc2 =3D set(['COMMON', 'DEFAULT']) if Scope2 and Scope2 !=3D TAB_COMMON: if '.' in Scope2: Index =3D Scope2.index('.') @@ -379,33 +399,37 @@ class PlatformTable(MetaFileTable): if FromItem is not None: result =3D [item for item in result if item[9] =3D=3D FromItem] =20 - result =3D [ [r[2],r[3],r[4],r[5],r[6],r[7],r[0],r[10]] for r in r= esult ] + result =3D [[r[2], r[3], r[4], r[5], r[6], r[7], r[0], r[10]] + for r in result] return result =20 - def DisableComponent(self,comp_id): + def DisableComponent(self, comp_id): for item in self.CurrentContent: if item[0] =3D=3D comp_id or item[8] =3D=3D comp_id: item[-1] =3D -1 =20 -## Factory class to produce different storage for different type of meta-f= ile +# Factory class to produce different storage for different type of meta-fi= le + + class MetaFileStorage(object): _FILE_TABLE_ =3D { - MODEL_FILE_INF : ModuleTable, - MODEL_FILE_DEC : PackageTable, - MODEL_FILE_DSC : PlatformTable, - MODEL_FILE_OTHERS : MetaFileTable, + MODEL_FILE_INF: ModuleTable, + MODEL_FILE_DEC: PackageTable, + MODEL_FILE_DSC: PlatformTable, + MODEL_FILE_OTHERS: MetaFileTable, } =20 _FILE_TYPE_ =3D { - ".inf" : MODEL_FILE_INF, - ".dec" : MODEL_FILE_DEC, - ".dsc" : MODEL_FILE_DSC, + ".inf": MODEL_FILE_INF, + ".dec": MODEL_FILE_DEC, + ".dsc": MODEL_FILE_DSC, } _ObjectCache =3D {} - ## Constructor + # Constructor + def __new__(Class, Cursor, MetaFile, FileType=3DNone, Temporary=3DFals= e, FromItem=3DNone): # no type given, try to find one - key =3D (MetaFile.Path, FileType,Temporary,FromItem) + key =3D (MetaFile.Path, FileType, Temporary, FromItem) if key in Class._ObjectCache: return Class._ObjectCache[key] if not FileType: @@ -427,4 +451,3 @@ class MetaFileStorage(object): if not Temporary: Class._ObjectCache[key] =3D reval return reval - diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseToo= ls/Source/Python/Workspace/WorkspaceCommon.py index 9e506fc646b1..c14bf28d812e 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -1,4 +1,4 @@ -## @file +# @file # Common routines used by workspace # # Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.
        @@ -17,6 +17,7 @@ from Common.BuildToolError import OPTION_MISSING from Common.BuildToolError import BUILD_ERROR import Common.EdkLogger as EdkLogger =20 + class OrderedListDict(OrderedDict): def __init__(self, *args, **kwargs): super(OrderedListDict, self).__init__(*args, **kwargs) @@ -26,7 +27,7 @@ class OrderedListDict(OrderedDict): self[key] =3D Value =3D self.default_factory() return Value =20 -## Get all packages from platform for specified arch, target and toolchain +# Get all packages from platform for specified arch, target and toolchain # # @param Platform: DscBuildData instance # @param BuildDatabase: The database saves all data for all metafiles @@ -35,6 +36,8 @@ class OrderedListDict(OrderedDict): # @param Toolchain: Current toolchain # @retval: List of packages which are DecBuildData instances # + + def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain): PkgSet =3D set() if Platform.Packages: @@ -46,7 +49,7 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target,= Toolchain): PkgSet.update(Lib.Packages) return list(PkgSet) =20 -## Get all declared PCD from platform for specified arch, target and toolc= hain +# Get all declared PCD from platform for specified arch, target and toolch= ain # # @param Platform: DscBuildData instance # @param BuildDatabase: The database saves all data for all metafiles @@ -56,6 +59,8 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target,= Toolchain): # @retval: A dictionary contains instances of PcdClassObject with key (Pc= dCName, TokenSpaceGuid) # @retval: A dictionary contains real GUIDs of TokenSpaceGuid # + + def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain, addit= ionalPkgs): PkgList =3D GetPackageList(Platform, BuildDatabase, Arch, Target, Tool= chain) PkgList =3D set(PkgList) @@ -77,7 +82,7 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target,= Toolchain, additionalP DecPcds[PcdCName, PcdTokenName] =3D Pkg.Pcds[Pcd] return DecPcds, GuidDict =20 -## Get all dependent libraries for a module +# Get all dependent libraries for a module # # @param Module: InfBuildData instance # @param Platform: DscBuildData instance @@ -87,10 +92,13 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Targe= t, Toolchain, additionalP # @param Toolchain: Current toolchain # @retval: List of dependent libraries which are InfBuildData instances # + + def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, To= olchain): - return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Ta= rget, Toolchain,Platform.MetaFile,EdkLogger) + return GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Ta= rget, Toolchain, Platform.MetaFile, EdkLogger) =20 -def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, T= oolchain, FileName =3D '', EdkLogger =3D None): + +def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, T= oolchain, FileName=3D'', EdkLogger=3DNone): if Module.LibInstances: return Module.LibInstances ModuleType =3D Module.ModuleType @@ -103,12 +111,14 @@ def GetModuleLibInstances(Module, Platform, BuildData= base, Arch, Target, Toolcha if Module.ModuleType !=3D SUP_MODULE_USER_DEFINED: for LibraryClass in Platform.LibraryClasses.GetKeys(): if LibraryClass.startswith("NULL") and Platform.LibraryClasses= [LibraryClass, Module.ModuleType]: - Module.LibraryClasses[LibraryClass] =3D Platform.LibraryCl= asses[LibraryClass, Module.ModuleType] + Module.LibraryClasses[LibraryClass] =3D Platform.LibraryCl= asses[LibraryClass, + = Module.ModuleType] =20 # add forced library instances (specified in module overrides) for LibraryClass in Platform.Modules[str(Module)].LibraryClasses: if LibraryClass.startswith("NULL"): - Module.LibraryClasses[LibraryClass] =3D Platform.Modules[str(M= odule)].LibraryClasses[LibraryClass] + Module.LibraryClasses[LibraryClass] =3D Platform.Modules[str( + Module)].LibraryClasses[LibraryClass] =20 # EdkII module LibraryConsumerList =3D [Module] @@ -118,14 +128,16 @@ def GetModuleLibInstances(Module, Platform, BuildData= base, Arch, Target, Toolcha =20 if not Module.LibraryClass: EdkLogger.verbose("") - EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(= Module), Arch)) + EdkLogger.verbose( + "Library instances of module [%s] [%s]:" % (str(Module), Arch)) =20 while len(LibraryConsumerList) > 0: M =3D LibraryConsumerList.pop() for LibraryClassName in M.LibraryClasses: if LibraryClassName not in LibraryInstance: # override library instance for this module - LibraryPath =3D Platform.Modules[str(Module)].LibraryClass= es.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleTyp= e]) + LibraryPath =3D Platform.Modules[str(Module)].LibraryClass= es.get( + LibraryClassName, Platform.LibraryClasses[LibraryClass= Name, ModuleType]) if LibraryPath is None: LibraryPath =3D M.LibraryClasses.get(LibraryClassName) if LibraryPath is None: @@ -137,20 +149,22 @@ def GetModuleLibInstances(Module, Platform, BuildData= base, Arch, Target, Toolcha else: return [] =20 - LibraryModule =3D BuildDatabase[LibraryPath, Arch, Target,= Toolchain] + LibraryModule =3D BuildDatabase[LibraryPath, + Arch, Target, Toolchain] # for those forced library instance (NULL library), add a = fake library class if LibraryClassName.startswith("NULL"): - LibraryModule.LibraryClass.append(LibraryClassObject(L= ibraryClassName, [ModuleType])) + LibraryModule.LibraryClass.append( + LibraryClassObject(LibraryClassName, [ModuleType])) elif LibraryModule.LibraryClass is None \ - or len(LibraryModule.LibraryClass) =3D=3D 0 \ - or (ModuleType !=3D SUP_MODULE_USER_DEFINED and Modul= eType !=3D SUP_MODULE_HOST_APPLICATION - and ModuleType not in LibraryModule.LibraryClass[= 0].SupModList): + or len(LibraryModule.LibraryClass) =3D=3D 0 \ + or (ModuleType !=3D SUP_MODULE_USER_DEFINED and Module= Type !=3D SUP_MODULE_HOST_APPLICATION + and ModuleType not in LibraryModule.LibraryClass[0= ].SupModList): # only USER_DEFINED can link against any library insta= nce despite of its SupModList if not Module.LibraryClass: EdkLogger.error("build", OPTION_MISSING, - "Module type [%s] is not supported= by library instance [%s]" \ + "Module type [%s] is not supported= by library instance [%s]" % (ModuleType, LibraryPath), File= =3DFileName, - ExtraData=3D"consumed by library i= nstance [%s] which is consumed by module [%s]" \ + ExtraData=3D"consumed by library i= nstance [%s] which is consumed by module [%s]" % (str(M), str(Module)) ) else: @@ -159,7 +173,8 @@ def GetModuleLibInstances(Module, Platform, BuildDataba= se, Arch, Target, Toolcha LibraryInstance[LibraryClassName] =3D LibraryModule LibraryConsumerList.append(LibraryModule) if not Module.LibraryClass: - EdkLogger.verbose("\t" + str(LibraryClassName) + " : "= + str(LibraryModule)) + EdkLogger.verbose( + "\t" + str(LibraryClassName) + " : " + str(Library= Module)) else: LibraryModule =3D LibraryInstance[LibraryClassName] =20 @@ -181,7 +196,7 @@ def GetModuleLibInstances(Module, Platform, BuildDataba= se, Arch, Target, Toolcha # # Q <- Set of all nodes with no incoming edges # - LibraryList =3D [] #LibraryInstance.values() + LibraryList =3D [] # LibraryInstance.values() Q =3D [] for LibraryClassName in LibraryInstance: M =3D LibraryInstance[LibraryClassName] @@ -240,7 +255,9 @@ def GetModuleLibInstances(Module, Platform, BuildDataba= se, Arch, Target, Toolcha for Item in LibraryList: if ConsumedByList[Item] and Item in Constructor and len(Constructo= r) > 1: if not Module.LibraryClass: - ErrorMessage =3D "\tconsumed by " + "\n\tconsumed by ".joi= n(str(L) for L in ConsumedByList[Item]) + ErrorMessage =3D "\tconsumed by " + \ + "\n\tconsumed by ".join(str(L) + for L in ConsumedByList[Item]) EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with c= onstructors has a cycle' % str(Item), ExtraData=3DErrorMessage, File=3DFileName) else: @@ -254,5 +271,6 @@ def GetModuleLibInstances(Module, Platform, BuildDataba= se, Arch, Target, Toolcha # SortedLibraryList.reverse() Module.LibInstances =3D SortedLibraryList - SortedLibraryList =3D [lib.SetReferenceModule(Module) for lib in Sorte= dLibraryList] + SortedLibraryList =3D [lib.SetReferenceModule( + Module) for lib in SortedLibraryList] return SortedLibraryList diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseT= ools/Source/Python/Workspace/WorkspaceDatabase.py index d955c78b258f..09e235b23bc5 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -1,4 +1,4 @@ -## @file +# @file # This file is used to create a database used by build tool # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -23,7 +23,7 @@ from Workspace.DecBuildData import DecBuildData from Workspace.DscBuildData import DscBuildData from Workspace.InfBuildData import InfBuildData =20 -## Database +# Database # # This class defined the build database for all modules, packages and pl= atform. # It will call corresponding parser for the given file if it cannot find i= t in @@ -33,6 +33,8 @@ from Workspace.InfBuildData import InfBuildData # @param GlobalMacros Global macros used for replacement during file= parsing # @param RenewDb=3DFalse Create new database file if it's already the= re # + + class WorkspaceDatabase(object): =20 # @@ -42,26 +44,27 @@ class WorkspaceDatabase(object): class BuildObjectFactory(object): =20 _FILE_TYPE_ =3D { - ".inf" : MODEL_FILE_INF, - ".dec" : MODEL_FILE_DEC, - ".dsc" : MODEL_FILE_DSC, + ".inf": MODEL_FILE_INF, + ".dec": MODEL_FILE_DEC, + ".dsc": MODEL_FILE_DSC, } =20 # file parser _FILE_PARSER_ =3D { - MODEL_FILE_INF : InfParser, - MODEL_FILE_DEC : DecParser, - MODEL_FILE_DSC : DscParser, + MODEL_FILE_INF: InfParser, + MODEL_FILE_DEC: DecParser, + MODEL_FILE_DSC: DscParser, } =20 # convert to xxxBuildData object _GENERATOR_ =3D { - MODEL_FILE_INF : InfBuildData, - MODEL_FILE_DEC : DecBuildData, - MODEL_FILE_DSC : DscBuildData, + MODEL_FILE_INF: InfBuildData, + MODEL_FILE_DEC: DecBuildData, + MODEL_FILE_DSC: DscBuildData, } =20 _CACHE_ =3D {} # (FilePath, Arch) : + def GetCache(self): return self._CACHE_ =20 @@ -101,10 +104,12 @@ class WorkspaceDatabase(object): return self._CACHE_[Key] =20 # check file type - BuildObject =3D self.CreateBuildObject(FilePath, Arch, Target,= Toolchain) + BuildObject =3D self.CreateBuildObject( + FilePath, Arch, Target, Toolchain) self._CACHE_[Key] =3D BuildObject return BuildObject - def CreateBuildObject(self,FilePath, Arch, Target, Toolchain): + + def CreateBuildObject(self, FilePath, Arch, Target, Toolchain): Ext =3D FilePath.Type if Ext not in self._FILE_TYPE_: return None @@ -114,22 +119,22 @@ class WorkspaceDatabase(object): =20 # get the parser ready for this file MetaFile =3D self._FILE_PARSER_[FileType]( - FilePath, - FileType, - Arch, - MetaFileStorage(self.WorkspaceDb, FilePath= , FileType) - ) + FilePath, + FileType, + Arch, + MetaFileStorage(self.WorkspaceDb, FilePath, FileType) + ) # always do post-process, in case of macros change MetaFile.DoPostProcess() # object the build is based on BuildObject =3D self._GENERATOR_[FileType]( - FilePath, - MetaFile, - self, - Arch, - Target, - Toolchain - ) + FilePath, + MetaFile, + self, + Arch, + Target, + Toolchain + ) return BuildObject =20 # placeholder for file format conversion @@ -141,7 +146,7 @@ class WorkspaceDatabase(object): def __getitem__(self, Key): pass =20 - ## Constructor of WorkspaceDatabase + # Constructor of WorkspaceDatabase # # @param DbPath Path of database file # @param GlobalMacros Global macros used for replacement during = file parsing @@ -158,8 +163,8 @@ class WorkspaceDatabase(object): self.BuildObject =3D WorkspaceDatabase.BuildObjectFactory(self) self.TransformObject =3D WorkspaceDatabase.TransformObjectFactory(= self) =20 + # Summarize all packages in the database =20 - ## Summarize all packages in the database def GetPackageList(self, Platform, Arch, TargetName, ToolChainTag): self.Platform =3D Platform PackageList =3D [] @@ -168,7 +173,8 @@ class WorkspaceDatabase(object): # Get Package related to Modules # for Module in Pa.Modules: - ModuleObj =3D self.BuildObject[Module, Arch, TargetName, ToolC= hainTag] + ModuleObj =3D self.BuildObject[Module, + Arch, TargetName, ToolChainTag] for Package in ModuleObj.Packages: if Package not in PackageList: PackageList.append(Package) @@ -190,9 +196,11 @@ class WorkspaceDatabase(object): def MapPlatform(self, Dscfile): Platform =3D self.BuildObject[PathClass(Dscfile), TAB_COMMON] if Platform is None: - EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC f= ile: %s" % Dscfile) + EdkLogger.error('build', PARSER_ERROR, + "Failed to parser DSC file: %s" % Dscfile) return Platform =20 + BuildDB =3D WorkspaceDatabase() ## # @@ -201,4 +209,3 @@ BuildDB =3D WorkspaceDatabase() # if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/Workspace/__init__.py b/BaseTools/Sour= ce/Python/Workspace/__init__.py index 85ae9937c43f..400adb76a0aa 100644 --- a/BaseTools/Source/Python/Workspace/__init__.py +++ b/BaseTools/Source/Python/Workspace/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'Workspace' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index 468772930ca1..673ef7528150 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1,4 +1,4 @@ -## @file +# @file # Routines for generating build report. # # This module contains the functionality to generate build report after @@ -8,7 +8,7 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # =20 -## Import Modules +# Import Modules # import Common.LongFilePathOs as os import re @@ -42,86 +42,91 @@ import collections from Common.Expression import * from GenFds.AprioriSection import DXE_APRIORI_GUID, PEI_APRIORI_GUID =20 -## Pattern to extract contents in EDK DXS files -gDxsDependencyPattern =3D re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END"= , re.DOTALL) +# Pattern to extract contents in EDK DXS files +gDxsDependencyPattern =3D re.compile( + r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL) =20 -## Pattern to find total FV total size, occupied size in flash report inte= rmediate file +# Pattern to find total FV total size, occupied size in flash report inter= mediate file gFvTotalSizePattern =3D re.compile(r"EFI_FV_TOTAL_SIZE =3D (0x[0-9a-fA-F]+= )") gFvTakenSizePattern =3D re.compile(r"EFI_FV_TAKEN_SIZE =3D (0x[0-9a-fA-F]+= )") =20 -## Pattern to find module size and time stamp in module summary report int= ermediate file +# Pattern to find module size and time stamp in module summary report inte= rmediate file gModuleSizePattern =3D re.compile(r"MODULE_SIZE =3D (\d+)") -gTimeStampPattern =3D re.compile(r"TIME_STAMP =3D (\d+)") +gTimeStampPattern =3D re.compile(r"TIME_STAMP =3D (\d+)") =20 -## Pattern to find GUID value in flash description files +# Pattern to find GUID value in flash description files gPcdGuidPattern =3D re.compile(r"PCD\((\w+)[.](\w+)\)") =20 -## Pattern to collect offset, GUID value pair in the flash report intermed= iate file +# Pattern to collect offset, GUID value pair in the flash report intermedi= ate file gOffsetGuidPattern =3D re.compile(r"(0x[0-9A-Fa-f]+) ([-A-Fa-f0-9]+)") =20 -## Pattern to find module base address and entry point in fixed flash map = file +# Pattern to find module base address and entry point in fixed flash map f= ile gModulePattern =3D r"\n[-\w]+\s*\(([^,]+),\s*BaseAddress=3D%(Address)s,\s*= EntryPoint=3D%(Address)s,\s*Type=3D\w+\)\s*\(GUID=3D([-0-9A-Fa-f]+)[^)]*\)" -gMapFileItemPattern =3D re.compile(gModulePattern % {"Address" : "(-?0[xX]= [0-9A-Fa-f]+)"}) +gMapFileItemPattern =3D re.compile( + gModulePattern % {"Address": "(-?0[xX][0-9A-Fa-f]+)"}) =20 -## Pattern to find all module referenced header files in source files -gIncludePattern =3D re.compile(r'#include\s*["<]([^">]+)[">]') +# Pattern to find all module referenced header files in source files +gIncludePattern =3D re.compile(r'#include\s*["<]([^">]+)[">]') gIncludePattern2 =3D re.compile(r"#include\s+EFI_([A-Z_]+)\s*[(]\s*(\w+)\s= *[)]") =20 -## Pattern to find the entry point for EDK module using EDKII Glue library -gGlueLibEntryPoint =3D re.compile(r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*= =3D\s*(\w+)") +# Pattern to find the entry point for EDK module using EDKII Glue library +gGlueLibEntryPoint =3D re.compile( + r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*=3D\s*(\w+)") =20 -## Tags for MaxLength of line in report +# Tags for MaxLength of line in report gLineMaxLength =3D 120 =20 -## Tags for end of line in report +# Tags for end of line in report gEndOfLine =3D "\r\n" =20 -## Tags for section start, end and separator +# Tags for section start, end and separator gSectionStart =3D ">" + "=3D" * (gLineMaxLength - 2) + "<" gSectionEnd =3D "<" + "=3D" * (gLineMaxLength - 2) + ">" + "\n" gSectionSep =3D "=3D" * gLineMaxLength =20 -## Tags for subsection start, end and separator +# Tags for subsection start, end and separator gSubSectionStart =3D ">" + "-" * (gLineMaxLength - 2) + "<" gSubSectionEnd =3D "<" + "-" * (gLineMaxLength - 2) + ">" gSubSectionSep =3D "-" * gLineMaxLength =20 =20 -## The look up table to map PCD type to pair of report display type and DE= C type +# The look up table to map PCD type to pair of report display type and DEC= type gPcdTypeMap =3D { - TAB_PCDS_FIXED_AT_BUILD : ('FIXED', TAB_PCDS_FIXED_AT_BUILD), - TAB_PCDS_PATCHABLE_IN_MODULE: ('PATCH', TAB_PCDS_PATCHABLE_IN_MODULE), - TAB_PCDS_FEATURE_FLAG : ('FLAG', TAB_PCDS_FEATURE_FLAG), - TAB_PCDS_DYNAMIC : ('DYN', TAB_PCDS_DYNAMIC), - TAB_PCDS_DYNAMIC_HII : ('DYNHII', TAB_PCDS_DYNAMIC), - TAB_PCDS_DYNAMIC_VPD : ('DYNVPD', TAB_PCDS_DYNAMIC), - TAB_PCDS_DYNAMIC_EX : ('DEX', TAB_PCDS_DYNAMIC_EX), - TAB_PCDS_DYNAMIC_EX_HII : ('DEXHII', TAB_PCDS_DYNAMIC_EX), - TAB_PCDS_DYNAMIC_EX_VPD : ('DEXVPD', TAB_PCDS_DYNAMIC_EX), - } + TAB_PCDS_FIXED_AT_BUILD: ('FIXED', TAB_PCDS_FIXED_AT_BUILD), + TAB_PCDS_PATCHABLE_IN_MODULE: ('PATCH', TAB_PCDS_PATCHABLE_IN_MODULE), + TAB_PCDS_FEATURE_FLAG: ('FLAG', TAB_PCDS_FEATURE_FLAG), + TAB_PCDS_DYNAMIC: ('DYN', TAB_PCDS_DYNAMIC), + TAB_PCDS_DYNAMIC_HII: ('DYNHII', TAB_PCDS_DYNAMIC), + TAB_PCDS_DYNAMIC_VPD: ('DYNVPD', TAB_PCDS_DYNAMIC), + TAB_PCDS_DYNAMIC_EX: ('DEX', TAB_PCDS_DYNAMIC_EX), + TAB_PCDS_DYNAMIC_EX_HII: ('DEXHII', TAB_PCDS_DYNAMIC_EX), + TAB_PCDS_DYNAMIC_EX_VPD: ('DEXVPD', TAB_PCDS_DYNAMIC_EX), +} =20 -## The look up table to map module type to driver type +# The look up table to map module type to driver type gDriverTypeMap =3D { - SUP_MODULE_SEC : '0x3 (SECURITY_CORE)', - SUP_MODULE_PEI_CORE : '0x4 (PEI_CORE)', - SUP_MODULE_PEIM : '0x6 (PEIM)', - SUP_MODULE_DXE_CORE : '0x5 (DXE_CORE)', - SUP_MODULE_DXE_DRIVER : '0x7 (DRIVER)', - SUP_MODULE_DXE_SAL_DRIVER : '0x7 (DRIVER)', - SUP_MODULE_DXE_SMM_DRIVER : '0x7 (DRIVER)', - SUP_MODULE_DXE_RUNTIME_DRIVER: '0x7 (DRIVER)', - SUP_MODULE_UEFI_DRIVER : '0x7 (DRIVER)', - SUP_MODULE_UEFI_APPLICATION : '0x9 (APPLICATION)', - SUP_MODULE_SMM_CORE : '0xD (SMM_CORE)', - 'SMM_DRIVER' : '0xA (SMM)', # Extension of module type to support= PI 1.1 SMM drivers - SUP_MODULE_MM_STANDALONE : '0xE (MM_STANDALONE)', - SUP_MODULE_MM_CORE_STANDALONE : '0xF (MM_CORE_STANDALONE)' - } + SUP_MODULE_SEC: '0x3 (SECURITY_CORE)', + SUP_MODULE_PEI_CORE: '0x4 (PEI_CORE)', + SUP_MODULE_PEIM: '0x6 (PEIM)', + SUP_MODULE_DXE_CORE: '0x5 (DXE_CORE)', + SUP_MODULE_DXE_DRIVER: '0x7 (DRIVER)', + SUP_MODULE_DXE_SAL_DRIVER: '0x7 (DRIVER)', + SUP_MODULE_DXE_SMM_DRIVER: '0x7 (DRIVER)', + SUP_MODULE_DXE_RUNTIME_DRIVER: '0x7 (DRIVER)', + SUP_MODULE_UEFI_DRIVER: '0x7 (DRIVER)', + SUP_MODULE_UEFI_APPLICATION: '0x9 (APPLICATION)', + SUP_MODULE_SMM_CORE: '0xD (SMM_CORE)', + # Extension of module type to support PI 1.1 SMM drivers + 'SMM_DRIVER': '0xA (SMM)', + SUP_MODULE_MM_STANDALONE: '0xE (MM_STANDALONE)', + SUP_MODULE_MM_CORE_STANDALONE: '0xF (MM_CORE_STANDALONE)' +} =20 -## The look up table of the supported opcode in the dependency expression = binaries -gOpCodeList =3D ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "F= ALSE", "END", "SOR"] +# The look up table of the supported opcode in the dependency expression b= inaries +gOpCodeList =3D ["BEFORE", "AFTER", "PUSH", "AND", + "OR", "NOT", "TRUE", "FALSE", "END", "SOR"] =20 -## Save VPD Pcd +# Save VPD Pcd VPDPcdList =3D [] =20 ## @@ -134,11 +139,14 @@ VPDPcdList =3D [] # @String The string to be written to the file # @Wrapper Indicates whether to wrap the string # + + def FileWrite(File, String, Wrapper=3DFalse): if Wrapper: String =3D textwrap.fill(String, 120) File.append(String + gEndOfLine) =20 + def ByteArrayForamt(Value): IsByteArray =3D False SplitNum =3D 16 @@ -157,7 +165,7 @@ def ByteArrayForamt(Value): Id =3D 0 while (Id <=3D Len): End =3D min(SplitNum*(Id+1), len(ValueList)) - Str =3D ','.join(ValueList[SplitNum*Id : End]) + Str =3D ','.join(ValueList[SplitNum*Id: End]) if End =3D=3D len(ValueList): Str +=3D '}' ArrayList.append(Str) @@ -181,6 +189,8 @@ def ByteArrayForamt(Value): # @IncludePathList The list of include path to find the source f= ile. # @IncludeFiles The dictionary of current found include files. # + + def FindIncludeFiles(Source, IncludePathList, IncludeFiles): FileContents =3D open(Source).read() # @@ -191,7 +201,8 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFi= les): for Dir in [os.path.dirname(Source)] + IncludePathList: FullFileName =3D os.path.normpath(os.path.join(Dir, FileName)) if os.path.exists(FullFileName): - IncludeFiles[FullFileName.lower().replace("\\", "/")] =3D = FullFileName + IncludeFiles[FullFileName.lower().replace( + "\\", "/")] =3D FullFileName break =20 # @@ -201,22 +212,23 @@ def FindIncludeFiles(Source, IncludePathList, Include= Files): Key =3D Match.group(2) Type =3D Match.group(1) if "ARCH_PROTOCOL" in Type: - FileName =3D "ArchProtocol/%(Key)s/%(Key)s.h" % {"Key" : Key} + FileName =3D "ArchProtocol/%(Key)s/%(Key)s.h" % {"Key": Key} elif "PROTOCOL" in Type: - FileName =3D "Protocol/%(Key)s/%(Key)s.h" % {"Key" : Key} + FileName =3D "Protocol/%(Key)s/%(Key)s.h" % {"Key": Key} elif "PPI" in Type: - FileName =3D "Ppi/%(Key)s/%(Key)s.h" % {"Key" : Key} + FileName =3D "Ppi/%(Key)s/%(Key)s.h" % {"Key": Key} elif TAB_GUID in Type: - FileName =3D "Guid/%(Key)s/%(Key)s.h" % {"Key" : Key} + FileName =3D "Guid/%(Key)s/%(Key)s.h" % {"Key": Key} else: continue for Dir in IncludePathList: FullFileName =3D os.path.normpath(os.path.join(Dir, FileName)) if os.path.exists(FullFileName): - IncludeFiles[FullFileName.lower().replace("\\", "/")] =3D = FullFileName + IncludeFiles[FullFileName.lower().replace( + "\\", "/")] =3D FullFileName break =20 -## Split each lines in file +# Split each lines in file # # This method is used to split the lines in file to make the length of ea= ch line # less than MaxLength. @@ -224,6 +236,8 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFi= les): # @param Content The content of file # @param MaxLength The Max Length of the line # + + def FileLinesSplit(Content=3DNone, MaxLength=3DNone): ContentList =3D Content.split(TAB_LINE_BREAK) NewContent =3D '' @@ -234,7 +248,8 @@ def FileLinesSplit(Content=3DNone, MaxLength=3DNone): LineSlashIndex =3D Line.rfind(TAB_SLASH, 0, MaxLength) LineBackSlashIndex =3D Line.rfind(TAB_BACK_SLASH, 0, MaxLength) if max(LineSpaceIndex, LineSlashIndex, LineBackSlashIndex) > 0: - LineBreakIndex =3D max(LineSpaceIndex, LineSlashIndex, Lin= eBackSlashIndex) + LineBreakIndex =3D max( + LineSpaceIndex, LineSlashIndex, LineBackSlashIndex) else: LineBreakIndex =3D MaxLength NewContentList.append(Line[:LineBreakIndex]) @@ -244,11 +259,11 @@ def FileLinesSplit(Content=3DNone, MaxLength=3DNone): for NewLine in NewContentList: NewContent +=3D NewLine + TAB_LINE_BREAK =20 - NewContent =3D NewContent.replace(gEndOfLine, TAB_LINE_BREAK).replace(= '\r\r\n', gEndOfLine) + NewContent =3D NewContent.replace( + gEndOfLine, TAB_LINE_BREAK).replace('\r\r\n', gEndOfLine) return NewContent =20 =20 - ## # Parse binary dependency expression section # @@ -270,19 +285,23 @@ class DepexParser(object): for Pa in Wa.AutoGenObjectList: for Package in Pa.PackageList: for Protocol in Package.Protocols: - GuidValue =3D GuidStructureStringToGuidString(Package.= Protocols[Protocol]) + GuidValue =3D GuidStructureStringToGuidString( + Package.Protocols[Protocol]) self._GuidDb[GuidValue.upper()] =3D Protocol for Ppi in Package.Ppis: - GuidValue =3D GuidStructureStringToGuidString(Package.= Ppis[Ppi]) + GuidValue =3D GuidStructureStringToGuidString( + Package.Ppis[Ppi]) self._GuidDb[GuidValue.upper()] =3D Ppi for Guid in Package.Guids: - GuidValue =3D GuidStructureStringToGuidString(Package.= Guids[Guid]) + GuidValue =3D GuidStructureStringToGuidString( + Package.Guids[Guid]) self._GuidDb[GuidValue.upper()] =3D Guid for Ma in Pa.ModuleAutoGenList: for Pcd in Ma.FixedVoidTypePcds: PcdValue =3D Ma.FixedVoidTypePcds[Pcd] if len(PcdValue.split(',')) =3D=3D 16: - GuidValue =3D GuidStructureByteArrayToGuidString(P= cdValue) + GuidValue =3D GuidStructureByteArrayToGuidString( + PcdValue) self._GuidDb[GuidValue.upper()] =3D Pcd ## # Parse the binary dependency expression files. @@ -293,6 +312,7 @@ class DepexParser(object): # @param self The object pointer # @param DepexFileName The file name of binary dependency expression= file. # + def ParseDepexFile(self, DepexFileName): DepexFile =3D open(DepexFileName, "rb") DepexStatement =3D [] @@ -301,7 +321,8 @@ class DepexParser(object): Statement =3D gOpCodeList[struct.unpack("B", OpCode)[0]] if Statement in ["BEFORE", "AFTER", "PUSH"]: GuidValue =3D "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02= X%02X" % \ - struct.unpack(PACK_PATTERN_GUID, DepexFile.rea= d(16)) + struct.unpack(PACK_PATTERN_GUID, + DepexFile.read(16)) GuidString =3D self._GuidDb.get(GuidValue, GuidValue) Statement =3D "%s %s" % (Statement, GuidString) DepexStatement.append(Statement) @@ -314,6 +335,8 @@ class DepexParser(object): # # This class reports the module library subsection in the build report fil= e. # + + class LibraryReport(object): ## # Constructor function for class LibraryReport @@ -337,7 +360,8 @@ class LibraryReport(object): if LibInfPath =3D=3D LibAutoGen.MetaFile.Path: LibTime =3D LibAutoGen.BuildTime break - self.LibraryList.append((LibInfPath, LibClassList, LibConstruc= torList, LibDesstructorList, LibDepexList, LibTime)) + self.LibraryList.append( + (LibInfPath, LibClassList, LibConstructorList, LibDesstruc= torList, LibDepexList, LibTime)) =20 ## # Generate report for module library information @@ -383,6 +407,8 @@ class LibraryReport(object): # # This class reports the module dependency expression subsection in the bu= ild report file. # + + class DepexReport(object): ## # Constructor function for class DepexReport @@ -398,7 +424,8 @@ class DepexReport(object): # def __init__(self, M): self.Depex =3D "" - self._DepexFileName =3D os.path.join(M.BuildDir, "OUTPUT", M.Modul= e.BaseName + ".depex") + self._DepexFileName =3D os.path.join( + M.BuildDir, "OUTPUT", M.Module.BaseName + ".depex") ModuleType =3D M.ModuleType if not ModuleType: ModuleType =3D COMPONENT_TO_MODULE_MAP_DICT.get(M.ComponentTyp= e, "") @@ -415,13 +442,15 @@ class DepexReport(object): break else: self.Depex =3D M.DepexExpressionDict.get(M.ModuleType, "") - self.ModuleDepex =3D " ".join(M.Module.DepexExpression[M.Arch,= M.ModuleType]) + self.ModuleDepex =3D " ".join( + M.Module.DepexExpression[M.Arch, M.ModuleType]) if not self.ModuleDepex: self.ModuleDepex =3D "(None)" =20 LibDepexList =3D [] for Lib in M.DependentLibraryList: - LibDepex =3D " ".join(Lib.DepexExpression[M.Arch, M.Module= Type]).strip() + LibDepex =3D " ".join( + Lib.DepexExpression[M.Arch, M.ModuleType]).strip() if LibDepex !=3D "": LibDepexList.append("(" + LibDepex + ")") self.LibraryDepex =3D " AND ".join(LibDepexList) @@ -444,13 +473,16 @@ class DepexReport(object): FileWrite(File, gSubSectionStart) if os.path.isfile(self._DepexFileName): try: - DepexStatements =3D GlobalDepexParser.ParseDepexFile(self.= _DepexFileName) - FileWrite(File, "Final Dependency Expression (DEPEX) Instr= uctions") + DepexStatements =3D GlobalDepexParser.ParseDepexFile( + self._DepexFileName) + FileWrite( + File, "Final Dependency Expression (DEPEX) Instruction= s") for DepexStatement in DepexStatements: FileWrite(File, " %s" % DepexStatement) FileWrite(File, gSubSectionSep) except: - EdkLogger.warn(None, "Dependency expression file is corrup= ted", self._DepexFileName) + EdkLogger.warn( + None, "Dependency expression file is corrupted", self.= _DepexFileName) =20 FileWrite(File, "Dependency Expression (DEPEX) from %s" % self.Sou= rce) =20 @@ -468,6 +500,8 @@ class DepexReport(object): # # This class reports the module build flags subsection in the build report= file. # + + class BuildFlagsReport(object): ## # Constructor function for class BuildFlagsReport @@ -516,7 +550,8 @@ class BuildFlagsReport(object): self.ToolChainTag =3D M.ToolChain self.BuildFlags =3D {} for Tool in BuildOptions: - self.BuildFlags[Tool + "_FLAGS"] =3D M.BuildOption.get(Tool, {= }).get("FLAGS", "") + self.BuildFlags[Tool + + "_FLAGS"] =3D M.BuildOption.get(Tool, {}).get(= "FLAGS", "") =20 ## # Generate report for module build flags information @@ -567,17 +602,21 @@ class ModuleReport(object): if not M.IsLibrary: ModuleType =3D M.ModuleType if not ModuleType: - ModuleType =3D COMPONENT_TO_MODULE_MAP_DICT.get(M.Componen= tType, "") + ModuleType =3D COMPONENT_TO_MODULE_MAP_DICT.get( + M.ComponentType, "") # # If a module complies to PI 1.1, promote Module type to "SMM_= DRIVER" # if ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRIVER: - PiSpec =3D M.Module.Specification.get("PI_SPECIFICATION_VE= RSION", "0x00010000") + PiSpec =3D M.Module.Specification.get( + "PI_SPECIFICATION_VERSION", "0x00010000") if int(PiSpec, 0) >=3D 0x0001000A: ModuleType =3D "SMM_DRIVER" self.DriverType =3D gDriverTypeMap.get(ModuleType, "0x2 (FREE_= FORM)") - self.UefiSpecVersion =3D M.Module.Specification.get("UEFI_SPECIFIC= ATION_VERSION", "") - self.PiSpecVersion =3D M.Module.Specification.get("PI_SPECIFICATIO= N_VERSION", "") + self.UefiSpecVersion =3D M.Module.Specification.get( + "UEFI_SPECIFICATION_VERSION", "") + self.PiSpecVersion =3D M.Module.Specification.get( + "PI_SPECIFICATION_VERSION", "") self.PciDeviceId =3D M.Module.Defines.get("PCI_DEVICE_ID", "") self.PciVendorId =3D M.Module.Defines.get("PCI_VENDOR_ID", "") self.PciClassCode =3D M.Module.Defines.get("PCI_CLASS_CODE", "") @@ -591,7 +630,8 @@ class ModuleReport(object): # It also saves module INF default values of them in case they= exist. # for Pcd in M.ModulePcdList + M.LibraryPcdList: - self.ModulePcdSet.setdefault((Pcd.TokenCName, Pcd.TokenSpa= ceGuidCName, Pcd.Type), (Pcd.InfDefaultValue, Pcd.DefaultValue)) + self.ModulePcdSet.setdefault( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Type), (= Pcd.InfDefaultValue, Pcd.DefaultValue)) =20 self.LibraryReport =3D None if "LIBRARY" in ReportType: @@ -604,7 +644,6 @@ class ModuleReport(object): if "BUILD_FLAGS" in ReportType: self.BuildFlagsReport =3D BuildFlagsReport(M) =20 - ## # Generate report for module information # @@ -618,10 +657,12 @@ class ModuleReport(object): # @param GlobalDepexParser The platform global Dependency express= ion parser object # @param ReportType The kind of report items in the final = report file # + def GenerateReport(self, File, GlobalPcdReport, GlobalPredictionReport= , GlobalDepexParser, ReportType): FileWrite(File, gSectionStart) =20 - FwReportFileName =3D os.path.join(self._BuildDir, "OUTPUT", self.M= oduleName + ".txt") + FwReportFileName =3D os.path.join( + self._BuildDir, "OUTPUT", self.ModuleName + ".txt") if os.path.isfile(FwReportFileName): try: FileContents =3D open(FwReportFileName).read() @@ -631,25 +672,32 @@ class ModuleReport(object): =20 Match =3D gTimeStampPattern.search(FileContents) if Match: - self.BuildTimeStamp =3D datetime.utcfromtimestamp(int(= Match.group(1))) + self.BuildTimeStamp =3D datetime.utcfromtimestamp( + int(Match.group(1))) except IOError: - EdkLogger.warn(None, "Fail to read report file", FwReportF= ileName) + EdkLogger.warn(None, "Fail to read report file", + FwReportFileName) =20 if "HASH" in ReportType: OutputDir =3D os.path.join(self._BuildDir, "OUTPUT") DefaultEFIfile =3D os.path.join(OutputDir, self.ModuleName + "= .efi") if os.path.isfile(DefaultEFIfile): - Tempfile =3D os.path.join(OutputDir, self.ModuleName + "_h= ash.tmp") + Tempfile =3D os.path.join( + OutputDir, self.ModuleName + "_hash.tmp") # rebase the efi image since its base address may not zero - cmd =3D ["GenFw", "--rebase", str(0), "-o", Tempfile, Defa= ultEFIfile] + cmd =3D ["GenFw", "--rebase", + str(0), "-o", Tempfile, DefaultEFIfile] try: - PopenObject =3D subprocess.Popen(' '.join(cmd), stdout= =3Dsubprocess.PIPE, stderr=3Dsubprocess.PIPE, shell=3DTrue) + PopenObject =3D subprocess.Popen( + ' '.join(cmd), stdout=3Dsubprocess.PIPE, stderr=3D= subprocess.PIPE, shell=3DTrue) except Exception as X: - EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData=3D= "%s: %s" % (str(X), cmd[0])) + EdkLogger.error("GenFw", COMMAND_FAILURE, + ExtraData=3D"%s: %s" % (str(X), cmd[0]= )) EndOfProcedure =3D threading.Event() EndOfProcedure.clear() if PopenObject.stderr: - StdErrThread =3D threading.Thread(target=3DReadMessage= , args=3D(PopenObject.stderr, EdkLogger.quiet, EndOfProcedure)) + StdErrThread =3D threading.Thread(target=3DReadMessage= , args=3D( + PopenObject.stderr, EdkLogger.quiet, EndOfProcedur= e)) StdErrThread.setName("STDERR-Redirector") StdErrThread.setDaemon(False) StdErrThread.start() @@ -658,7 +706,8 @@ class ModuleReport(object): if PopenObject.stderr: StdErrThread.join() if PopenObject.returncode !=3D 0: - EdkLogger.error("GenFw", COMMAND_FAILURE, "Failed to g= enerate firmware hash image for %s" % (DefaultEFIfile)) + EdkLogger.error( + "GenFw", COMMAND_FAILURE, "Failed to generate firm= ware hash image for %s" % (DefaultEFIfile)) if os.path.isfile(Tempfile): self.Hash =3D hashlib.sha1() buf =3D open(Tempfile, 'rb').read() @@ -673,9 +722,11 @@ class ModuleReport(object): FileWrite(File, "Module INF Path: %s" % self.ModuleInfPath) FileWrite(File, "File GUID: %s" % self.FileGuid) if self.Size: - FileWrite(File, "Size: 0x%X (%.2fK)" % (self.S= ize, self.Size / 1024.0)) + FileWrite(File, "Size: 0x%X (%.2fK)" % + (self.Size, self.Size / 1024.0)) if self.Hash: - FileWrite(File, "SHA1 HASH: %s *%s" % (self.Hash, s= elf.ModuleName + ".efi")) + FileWrite(File, "SHA1 HASH: %s *%s" % + (self.Hash, self.ModuleName + ".efi")) if self.BuildTimeStamp: FileWrite(File, "Build Time Stamp: %s" % self.BuildTimeSta= mp) if self.BuildTime: @@ -696,7 +747,8 @@ class ModuleReport(object): FileWrite(File, gSectionSep) =20 if "PCD" in ReportType: - GlobalPcdReport.GenerateReport(File, self.ModulePcdSet,self.Fi= leGuid) + GlobalPcdReport.GenerateReport( + File, self.ModulePcdSet, self.FileGuid) =20 if "LIBRARY" in ReportType: self.LibraryReport.GenerateReport(File) @@ -712,6 +764,7 @@ class ModuleReport(object): =20 FileWrite(File, gSectionEnd) =20 + def ReadMessage(From, To, ExitFlag): while True: # read one line a time @@ -730,6 +783,8 @@ def ReadMessage(From, To, ExitFlag): # This class reports the platform PCD section and module PCD subsection # in the build report file. # + + class PcdReport(object): ## # Constructor function for class PcdReport @@ -767,7 +822,8 @@ class PcdReport(object): # GUID C Names # for Pcd in Pa.AllPcdList: - PcdList =3D self.AllPcds.setdefault(Pcd.TokenSpaceGuidCNam= e, {}).setdefault(Pcd.Type, []) + PcdList =3D self.AllPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) if Pcd not in PcdList: PcdList.append(Pcd) if len(Pcd.TokenCName) > self.MaxLen: @@ -776,11 +832,13 @@ class PcdReport(object): # Collect the PCD defined in DSC/FDF file, but not used in mod= ule # UnusedPcdFullList =3D [] - StructPcdDict =3D GlobalData.gStructurePcd.get(self.Arch, coll= ections.OrderedDict()) + StructPcdDict =3D GlobalData.gStructurePcd.get( + self.Arch, collections.OrderedDict()) for Name, Guid in StructPcdDict: if (Name, Guid) not in Pa.Platform.Pcds: Pcd =3D StructPcdDict[(Name, Guid)] - PcdList =3D self.AllPcds.setdefault(Guid, {}).setdefau= lt(Pcd.Type, []) + PcdList =3D self.AllPcds.setdefault( + Guid, {}).setdefault(Pcd.Type, []) if Pcd not in PcdList and Pcd not in UnusedPcdFullList: UnusedPcdFullList.append(Pcd) for item in Pa.Platform.Pcds: @@ -788,7 +846,8 @@ class PcdReport(object): if not Pcd.Type: # check the Pcd in FDF file, whether it is used in mod= ule first for T in PCD_TYPE_LIST: - PcdList =3D self.AllPcds.setdefault(Pcd.TokenSpace= GuidCName, {}).setdefault(T, []) + PcdList =3D self.AllPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(T, []) if Pcd in PcdList: Pcd.Type =3D T break @@ -800,7 +859,8 @@ class PcdReport(object): Pcd.Type =3D T PcdTypeFlag =3D True if not Pcd.DatumType: - Pcd.DatumType =3D package.Pcds[(Pcd.To= kenCName, Pcd.TokenSpaceGuidCName, T)].DatumType + Pcd.DatumType =3D package.Pcds[( + Pcd.TokenCName, Pcd.TokenSpaceGuid= CName, T)].DatumType break if PcdTypeFlag: break @@ -813,11 +873,14 @@ class PcdReport(object): PcdType =3D TAB_PCDS_DYNAMIC for package in Pa.PackageList: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, PcdTy= pe) in package.Pcds: - Pcd.DatumType =3D package.Pcds[(Pcd.TokenCName= , Pcd.TokenSpaceGuidCName, PcdType)].DatumType + Pcd.DatumType =3D package.Pcds[( + Pcd.TokenCName, Pcd.TokenSpaceGuidCName, P= cdType)].DatumType break =20 - PcdList =3D self.AllPcds.setdefault(Pcd.TokenSpaceGuidCNam= e, {}).setdefault(Pcd.Type, []) - UnusedPcdList =3D self.UnusedPcds.setdefault(Pcd.TokenSpac= eGuidCName, {}).setdefault(Pcd.Type, []) + PcdList =3D self.AllPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) + UnusedPcdList =3D self.UnusedPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) if Pcd in UnusedPcdList: UnusedPcdList.remove(Pcd) if Pcd not in PcdList and Pcd not in UnusedPcdFullList: @@ -830,8 +893,10 @@ class PcdReport(object): if '.' in PcdItem: (TokenSpaceGuidCName, TokenCName) =3D PcdItem.spli= t('.') if (TokenCName, TokenSpaceGuidCName) in Pa.Platfor= m.Pcds: - Pcd =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)] - PcdList =3D self.ConditionalPcds.setdefault(Pc= d.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) + Pcd =3D Pa.Platform.Pcds[( + TokenCName, TokenSpaceGuidCName)] + PcdList =3D self.ConditionalPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(Pc= d.Type, []) if Pcd not in PcdList: PcdList.append(Pcd) =20 @@ -843,7 +908,8 @@ class PcdReport(object): UnusedPcdList.append(Pcd) =20 for Pcd in UnusedPcdList: - PcdList =3D self.UnusedPcds.setdefault(Pcd.TokenSpaceGuidC= Name, {}).setdefault(Pcd.Type, []) + PcdList =3D self.UnusedPcds.setdefault( + Pcd.TokenSpaceGuidCName, {}).setdefault(Pcd.Type, []) if Pcd not in PcdList: PcdList.append(Pcd) =20 @@ -856,8 +922,8 @@ class PcdReport(object): TokenSpaceGuid =3D ModulePcd.TokenSpaceGuidCName ModuleDefault =3D ModulePcd.DefaultValue ModulePath =3D os.path.basename(Module.M.MetaFile.File) - self.ModulePcdOverride.setdefault((TokenCName, TokenSp= aceGuid), {})[ModulePath] =3D ModuleDefault - + self.ModulePcdOverride.setdefault((TokenCName, TokenSp= aceGuid), {})[ + ModulePath] =3D ModuleDefault =20 # # Collect PCD DEC default value. @@ -869,19 +935,23 @@ class PcdReport(object): Guids =3D Package.Guids self._GuidDict.update(Guids) for (TokenCName, TokenSpaceGuidCName, DecType) in Package.= Pcds: - DecDefaultValue =3D Package.Pcds[TokenCName, TokenSpac= eGuidCName, DecType].DefaultValue - self.DecPcdDefault.setdefault((TokenCName, TokenSpaceG= uidCName, DecType), DecDefaultValue) + DecDefaultValue =3D Package.Pcds[TokenCName, + TokenSpaceGuidCName, De= cType].DefaultValue + self.DecPcdDefault.setdefault( + (TokenCName, TokenSpaceGuidCName, DecType), DecDef= aultValue) # # Collect PCDs defined in DSC common section # self.DscPcdDefault =3D {} for Pa in Wa.AutoGenObjectList: for (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds: - DscDefaultValue =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)].DscDefaultValue + DscDefaultValue =3D Pa.Platform.Pcds[( + TokenCName, TokenSpaceGuidCName)].DscDefaultValue if DscDefaultValue: - self.DscPcdDefault[(TokenCName, TokenSpaceGuidCName)] = =3D DscDefaultValue + self.DscPcdDefault[( + TokenCName, TokenSpaceGuidCName)] =3D DscDefaultVa= lue =20 - def GenerateReport(self, File, ModulePcdSet,ModuleGuid=3DNone): + def GenerateReport(self, File, ModulePcdSet, ModuleGuid=3DNone): if not ModulePcdSet: if self.ConditionalPcds: self.GenerateReportDetail(File, ModulePcdSet, 1) @@ -897,7 +967,7 @@ class PcdReport(object): break if not IsEmpty: self.GenerateReportDetail(File, ModulePcdSet, 2) - self.GenerateReportDetail(File, ModulePcdSet,ModuleGuid =3D Module= Guid) + self.GenerateReportDetail(File, ModulePcdSet, ModuleGuid=3DModuleG= uid) =20 ## # Generate report for PCD information @@ -913,7 +983,7 @@ class PcdReport(object): # directives section report, 2 means Unused Pcd= s section report # @param DscOverridePcds Module DSC override PCDs set # - def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =3D 0= ,ModuleGuid=3DNone): + def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType=3D0, = ModuleGuid=3DNone): PcdDict =3D self.AllPcds if ReportSubType =3D=3D 1: PcdDict =3D self.ConditionalPcds @@ -923,9 +993,11 @@ class PcdReport(object): if not ModulePcdSet: FileWrite(File, gSectionStart) if ReportSubType =3D=3D 1: - FileWrite(File, "Conditional Directives used by the build = system") + FileWrite( + File, "Conditional Directives used by the build system= ") elif ReportSubType =3D=3D 2: - FileWrite(File, "PCDs not used by modules or in conditiona= l directives") + FileWrite( + File, "PCDs not used by modules or in conditional dire= ctives") else: FileWrite(File, "Platform Configuration Database Report") =20 @@ -971,8 +1043,10 @@ class PcdReport(object): # # Get PCD default value and their override relationship # - DecDefaultValue =3D self.DecPcdDefault.get((Pcd.TokenCName= , Pcd.TokenSpaceGuidCName, DecType)) - DscDefaultValue =3D self.DscPcdDefault.get((Pcd.TokenCName= , Pcd.TokenSpaceGuidCName)) + DecDefaultValue =3D self.DecPcdDefault.get( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, DecType)) + DscDefaultValue =3D self.DscPcdDefault.get( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName)) DscDefaultValBak =3D DscDefaultValue Field =3D '' for (CName, Guid, Field) in self.FdfPcdSet: @@ -981,32 +1055,37 @@ class PcdReport(object): break if DscDefaultValue !=3D DscDefaultValBak: try: - DscDefaultValue =3D ValueExpressionEx(DscDefaultVa= lue, Pcd.DatumType, self._GuidDict)(True) + DscDefaultValue =3D ValueExpressionEx( + DscDefaultValue, Pcd.DatumType, self._GuidDict= )(True) except BadExpression as DscDefaultValue: - EdkLogger.error('BuildReport', FORMAT_INVALID, "PC= D Value: %s, Type: %s" %(DscDefaultValue, Pcd.DatumType)) + EdkLogger.error('BuildReport', FORMAT_INVALID, "PC= D Value: %s, Type: %s" % ( + DscDefaultValue, Pcd.DatumType)) =20 InfDefaultValue =3D None =20 PcdValue =3D DecDefaultValue if DscDefaultValue: PcdValue =3D DscDefaultValue - #The DefaultValue of StructurePcd already be the latest, n= o need to update. + # The DefaultValue of StructurePcd already be the latest, = no need to update. if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceG= uidCName): Pcd.DefaultValue =3D PcdValue PcdComponentValue =3D None if ModulePcdSet is not None: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not= in ModulePcdSet: continue - InfDefaultValue, PcdComponentValue =3D ModulePcdSet[Pc= d.TokenCName, Pcd.TokenSpaceGuidCName, Type] + InfDefaultValue, PcdComponentValue =3D ModulePcdSet[Pc= d.TokenCName, + Pcd.= TokenSpaceGuidCName, Type] PcdValue =3D PcdComponentValue - #The DefaultValue of StructurePcd already be the lates= t, no need to update. + # The DefaultValue of StructurePcd already be the late= st, no need to update. if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSp= aceGuidCName): Pcd.DefaultValue =3D PcdValue if InfDefaultValue: try: - InfDefaultValue =3D ValueExpressionEx(InfDefau= ltValue, Pcd.DatumType, self._GuidDict)(True) + InfDefaultValue =3D ValueExpressionEx( + InfDefaultValue, Pcd.DatumType, self._Guid= Dict)(True) except BadExpression as InfDefaultValue: - EdkLogger.error('BuildReport', FORMAT_INVALID,= "PCD Value: %s, Type: %s" % (InfDefaultValue, Pcd.DatumType)) + EdkLogger.error('BuildReport', FORMAT_INVALID,= "PCD Value: %s, Type: %s" % ( + InfDefaultValue, Pcd.DatumType)) if InfDefaultValue =3D=3D "": InfDefaultValue =3D None =20 @@ -1017,7 +1096,7 @@ class PcdReport(object): if pcd[2]: continue PcdValue =3D pcd[3] - #The DefaultValue of StructurePcd already be t= he latest, no need to update. + # The DefaultValue of StructurePcd already be = the latest, no need to update. if not self.IsStructurePcd(Pcd.TokenCName, Pcd= .TokenSpaceGuidCName): Pcd.DefaultValue =3D PcdValue BuildOptionMatch =3D True @@ -1029,7 +1108,6 @@ class PcdReport(object): FileWrite(File, Key) First =3D False =20 - if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: if PcdValue.startswith('0') and not PcdValue.lower().s= tartswith('0x') and \ len(PcdValue) > 1 and PcdValue.lstrip('0'): @@ -1065,26 +1143,31 @@ class PcdReport(object): if DecDefaultValue is None: DecMatch =3D True else: - DecMatch =3D (DecDefaultValue.strip() =3D=3D PcdVa= lue.strip()) + DecMatch =3D (DecDefaultValue.strip() + =3D=3D PcdValue.strip()) =20 if InfDefaultValue is None: InfMatch =3D True else: - InfMatch =3D (InfDefaultValue.strip() =3D=3D PcdVa= lue.strip()) + InfMatch =3D (InfDefaultValue.strip() + =3D=3D PcdValue.strip()) =20 if DscDefaultValue is None: DscMatch =3D True else: - DscMatch =3D (DscDefaultValue.strip() =3D=3D PcdVa= lue.strip()) + DscMatch =3D (DscDefaultValue.strip() + =3D=3D PcdValue.strip()) =20 IsStructure =3D False if self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidC= Name): IsStructure =3D True if TypeName in ('DYNVPD', 'DEXVPD'): SkuInfoList =3D Pcd.SkuInfoList - Pcd =3D GlobalData.gStructurePcd[self.Arch][(Pcd.Token= CName, Pcd.TokenSpaceGuidCName)] + Pcd =3D GlobalData.gStructurePcd[self.Arch][( + Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] if ModulePcdSet and ModulePcdSet.get((Pcd.TokenCName, = Pcd.TokenSpaceGuidCName, Type)): - InfDefaultValue, PcdComponentValue =3D ModulePcdSe= t[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] + InfDefaultValue, PcdComponentValue =3D ModulePcdSe= t[Pcd.TokenCName, + = Pcd.TokenSpaceGuidCName, Type] DscDefaultValBak =3D Pcd.DefaultValue Pcd.DefaultValue =3D PcdComponentValue =20 @@ -1116,18 +1199,23 @@ class PcdReport(object): for Data in OverrideValues.val= ues(): Struct =3D list(Data.value= s()) if Struct: - DscOverride =3D self.P= arseStruct(Struct[0]) + DscOverride =3D self.P= arseStruct( + Struct[0]) break else: - SkuList =3D sorted(Pcd.SkuInfoList= .keys()) + SkuList =3D sorted( + Pcd.SkuInfoList.keys()) for Sku in SkuList: SkuInfo =3D Pcd.SkuInfoList[Sk= u] if SkuInfo.DefaultStoreDict: - DefaultStoreList =3D sorte= d(SkuInfo.DefaultStoreDict.keys()) + DefaultStoreList =3D sorte= d( + SkuInfo.DefaultStoreDi= ct.keys()) for DefaultStore in Defaul= tStoreList: - OverrideValues =3D Pcd= .SkuOverrideValues.get(Sku) + OverrideValues =3D Pcd= .SkuOverrideValues.get( + Sku) if OverrideValues: - DscOverride =3D se= lf.ParseStruct(OverrideValues[DefaultStore]) + DscOverride =3D se= lf.ParseStruct( + OverrideValues= [DefaultStore]) if DscOverride: break if DscOverride: @@ -1139,7 +1227,7 @@ class PcdReport(object): else: DecMatch =3D True else: - if Pcd.DscRawValue or (ModuleGuid and ModuleGu= id.replace("-","S") in Pcd.PcdValueFromComponents): + if Pcd.DscRawValue or (ModuleGuid and ModuleGu= id.replace("-", "S") in Pcd.PcdValueFromComponents): DscDefaultValue =3D True DscMatch =3D True DecMatch =3D False @@ -1160,20 +1248,25 @@ class PcdReport(object): if Pcd.DefaultValue: Pcd.DefaultValue =3D str(int(Pcd.DefaultValue, 0)) if DecMatch: - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, ' ') + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, + DscDefaultValBak, InfMatch, InfDefa= ultValue, DecMatch, DecDefaultValue, ' ') elif InfDefaultValue and InfMatch: - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*M') + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, + DscDefaultValBak, InfMatch, InfDefa= ultValue, DecMatch, DecDefaultValue, '*M') elif BuildOptionMatch: - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*B') + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, + DscDefaultValBak, InfMatch, InfDefa= ultValue, DecMatch, DecDefaultValue, '*B') else: if PcdComponentValue: - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, InfMatch, PcdComponentValue, = DecMatch, DecDefaultValue, '*M', ModuleGuid) + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, + InfMatch, PcdComponentValue, De= cMatch, DecDefaultValue, '*M', ModuleGuid) elif DscDefaultValue and DscMatch: if (Pcd.TokenCName, Key, Field) in self.FdfPcdSet: - self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*F') + self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, + DscDefaultValBak, InfMatch,= InfDefaultValue, DecMatch, DecDefaultValue, '*F') else: - self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*P') - + self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, + DscDefaultValBak, InfMatch,= InfDefaultValue, DecMatch, DecDefaultValue, '*P') =20 if ModulePcdSet is None: if IsStructure: @@ -1181,34 +1274,44 @@ class PcdReport(object): if not TypeName in ('PATCH', 'FLAG', 'FIXED'): continue if not BuildOptionMatch: - ModuleOverride =3D self.ModulePcdOverride.get((Pcd= .TokenCName, Pcd.TokenSpaceGuidCName), {}) + ModuleOverride =3D self.ModulePcdOverride.get( + (Pcd.TokenCName, Pcd.TokenSpaceGuidCName), {}) for ModulePath in ModuleOverride: ModuleDefault =3D ModuleOverride[ModulePath] if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: if ModuleDefault.startswith('0') and not M= oduleDefault.lower().startswith('0x') and \ len(ModuleDefault) > 1 and ModuleD= efault.lstrip('0'): ModuleDefault =3D ModuleDefault.lstrip= ('0') - ModulePcdDefaultValueNumber =3D int(Module= Default.strip(), 0) - Match =3D (ModulePcdDefaultValueNumber =3D= =3D PcdValueNumber) + ModulePcdDefaultValueNumber =3D int( + ModuleDefault.strip(), 0) + Match =3D (ModulePcdDefaultValueNumber =3D= =3D + PcdValueNumber) if Pcd.DatumType =3D=3D 'BOOLEAN': - ModuleDefault =3D str(ModulePcdDefault= ValueNumber) + ModuleDefault =3D str( + ModulePcdDefaultValueNumber) else: - Match =3D (ModuleDefault.strip() =3D=3D Pc= dValue.strip()) + Match =3D (ModuleDefault.strip() + =3D=3D PcdValue.strip()) if Match: continue - IsByteArray, ArrayList =3D ByteArrayForamt(Mod= uleDefault.strip()) + IsByteArray, ArrayList =3D ByteArrayForamt( + ModuleDefault.strip()) if IsByteArray: - FileWrite(File, ' *M %-*s =3D %s' % (s= elf.MaxLen + 15, ModulePath, '{')) + FileWrite(File, ' *M %-*s =3D %s' % + (self.MaxLen + 15, ModulePath, '= {')) for Array in ArrayList: FileWrite(File, Array) else: - Value =3D ModuleDefault.strip() + Value =3D ModuleDefault.strip() if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_= TYPES: if Value.startswith(('0x', '0X')): - Value =3D '{} ({:d})'.format(Value= , int(Value, 0)) + Value =3D '{} ({:d})'.format( + Value, int(Value, 0)) else: - Value =3D "0x{:X} ({})".format(int= (Value, 0), Value) - FileWrite(File, ' *M %-*s =3D %s' % (s= elf.MaxLen + 15, ModulePath, Value)) + Value =3D "0x{:X} ({})".format( + int(Value, 0), Value) + FileWrite(File, ' *M %-*s =3D %s' % + (self.MaxLen + 15, ModulePath, V= alue)) =20 if ModulePcdSet is None: FileWrite(File, gSectionEnd) @@ -1233,7 +1336,8 @@ class PcdReport(object): Value =3D DscDefaultValue.strip() IsByteArray, ArrayList =3D ByteArrayForamt(Value) if IsByteArray: - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'DSC= DEFAULT', "{")) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'DSC DEFAULT', "{")) for Array in ArrayList: FileWrite(File, Array) else: @@ -1242,12 +1346,14 @@ class PcdReport(object): Value =3D '{} ({:d})'.format(Value, int(Value, 0)) else: Value =3D "0x{:X} ({})".format(int(Value, 0), Valu= e) - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'DSC= DEFAULT', Value)) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'DSC DEFAULT', Value)) if not InfMatch and InfDefaultValue is not None: Value =3D InfDefaultValue.strip() IsByteArray, ArrayList =3D ByteArrayForamt(Value) if IsByteArray: - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'INF= DEFAULT', "{")) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'INF DEFAULT', "{")) for Array in ArrayList: FileWrite(File, Array) else: @@ -1256,13 +1362,15 @@ class PcdReport(object): Value =3D '{} ({:d})'.format(Value, int(Value, 0)) else: Value =3D "0x{:X} ({})".format(int(Value, 0), Valu= e) - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'INF= DEFAULT', Value)) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'INF DEFAULT', Value)) =20 if not DecMatch and DecDefaultValue is not None: Value =3D DecDefaultValue.strip() IsByteArray, ArrayList =3D ByteArrayForamt(Value) if IsByteArray: - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'DEC= DEFAULT', "{")) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'DEC DEFAULT', "{")) for Array in ArrayList: FileWrite(File, Array) else: @@ -1271,7 +1379,8 @@ class PcdReport(object): Value =3D '{} ({:d})'.format(Value, int(Value, 0)) else: Value =3D "0x{:X} ({})".format(int(Value, 0), Valu= e) - FileWrite(File, ' %*s =3D %s' % (self.MaxLen + 19, 'DEC= DEFAULT', Value)) + FileWrite(File, ' %*s =3D %s' % + (self.MaxLen + 19, 'DEC DEFAULT', Value)) if IsStructure: for filedvalues in Pcd.DefaultValues.values(): self.PrintStructureInfo(File, filedvalues) @@ -1279,12 +1388,13 @@ class PcdReport(object): for filedvalues in Pcd.DefaultValues.values(): self.PrintStructureInfo(File, filedvalues) =20 - def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag =3D ' ',ModuleGuid=3DNone): + def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag=3D' ', ModuleGuid=3DNone): if not Pcd.SkuInfoList: Value =3D Pcd.DefaultValue IsByteArray, ArrayList =3D ByteArrayForamt(Value) if IsByteArray: - FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{')) + FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumTy= pe + ')', '{')) for Array in ArrayList: FileWrite(File, Array) else: @@ -1295,11 +1405,13 @@ class PcdReport(object): Value =3D '{} ({:d})'.format(Value, int(Value, 0)) else: Value =3D "0x{:X} ({})".format(int(Value, 0), Valu= e) - FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) + FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumTy= pe + ')', Value)) if IsStructure: FiledOverrideFlag =3D False - if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in GlobalData.= gPcdSkuOverrides: - OverrideValues =3D GlobalData.gPcdSkuOverrides[(Pcd.To= kenCName,Pcd.TokenSpaceGuidCName)] + if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData= .gPcdSkuOverrides: + OverrideValues =3D GlobalData.gPcdSkuOverrides[( + Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] else: OverrideValues =3D Pcd.SkuOverrideValues FieldOverrideValues =3D None @@ -1310,16 +1422,19 @@ class PcdReport(object): FieldOverrideValues =3D Struct[0] FiledOverrideFlag =3D True break - if Pcd.PcdFiledValueFromDscComponent and ModuleGuid and Mo= duleGuid.replace("-","S") in Pcd.PcdFiledValueFromDscComponent: - FieldOverrideValues =3D Pcd.PcdFiledValueFromDscCompon= ent[ModuleGuid.replace("-","S")] + if Pcd.PcdFiledValueFromDscComponent and ModuleGuid and Mo= duleGuid.replace("-", "S") in Pcd.PcdFiledValueFromDscComponent: + FieldOverrideValues =3D Pcd.PcdFiledValueFromDscCompon= ent[ModuleGuid.replace( + "-", "S")] if FieldOverrideValues: - OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, F= ieldOverrideValues) + OverrideFieldStruct =3D self.OverrideFieldValue( + Pcd, FieldOverrideValues) self.PrintStructureInfo(File, OverrideFieldStruct) =20 if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or= Pcd.PcdFieldValueFromFdf): OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, {= }) self.PrintStructureInfo(File, OverrideFieldStruct) - self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefa= ultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) + self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefa= ultValue, + InfMatch, InfDefaultValue, DecMatch, DecD= efaultValue) else: FirstPrint =3D True SkuList =3D sorted(Pcd.SkuInfoList.keys()) @@ -1328,7 +1443,8 @@ class PcdReport(object): SkuIdName =3D SkuInfo.SkuIdName if TypeName in ('DYNHII', 'DEXHII'): if SkuInfo.DefaultStoreDict: - DefaultStoreList =3D sorted(SkuInfo.DefaultStoreDi= ct.keys()) + DefaultStoreList =3D sorted( + SkuInfo.DefaultStoreDict.keys()) for DefaultStore in DefaultStoreList: Value =3D SkuInfo.DefaultStoreDict[DefaultStor= e] IsByteArray, ArrayList =3D ByteArrayForamt(Val= ue) @@ -1338,62 +1454,86 @@ class PcdReport(object): FirstPrint =3D False if IsByteArray: if self.DefaultStoreSingle and self.Sk= uSingle: - FileWrite(File, ' %-*s : %6s %10= s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.D= atumType + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s =3D %s' % ( + self.MaxLen, Flag + ' ' + PcdT= okenCName, TypeName, '(' + Pcd.DatumType + ')', '{')) elif self.DefaultStoreSingle and not s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + = Pcd.DatumType + ')', '(' + SkuIdName + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName,= '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '{')) elif not self.DefaultStoreSingle and s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + = Pcd.DatumType + ')', '(' + DefaultStore + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName,= '(' + Pcd.DatumType + ')', '(' + DefaultStore + ')', '{')) else: - FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '= (' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', = '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, + TypeName, '(' + Pcd.Datu= mType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{')) for Array in ArrayList: FileWrite(File, Array) else: if Pcd.DatumType in TAB_PCD_CLEAN_NUME= RIC_TYPES: if Value.startswith(('0x', '0X')): - Value =3D '{} ({:d})'.format(V= alue, int(Value, 0)) + Value =3D '{} ({:d})'.format( + Value, int(Value, 0)) else: - Value =3D "0x{:X} ({})".format= (int(Value, 0), Value) + Value =3D "0x{:X} ({})".format( + int(Value, 0), Value) if self.DefaultStoreSingle and self.Sk= uSingle: - FileWrite(File, ' %-*s : %6s %10= s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.D= atumType + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s =3D %s' % ( + self.MaxLen, Flag + ' ' + PcdT= okenCName, TypeName, '(' + Pcd.DatumType + ')', Value)) elif self.DefaultStoreSingle and not s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + = Pcd.DatumType + ')', '(' + SkuIdName + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName,= '(' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value)) elif not self.DefaultStoreSingle and s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + = Pcd.DatumType + ')', '(' + DefaultStore + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName,= '(' + Pcd.DatumType + ')', '(' + DefaultStore + ')', Value)) else: - FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '= (' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', = Value)) + FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, + TypeName, '(' + Pcd.Datu= mType + ')', '(' + SkuIdName + ')', '(' + DefaultStore + ')', Value)) else: if IsByteArray: if self.DefaultStoreSingle and self.Sk= uSingle: - FileWrite(File, ' %-*s : %6s %10= s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', '{')) elif self.DefaultStoreSingle and not s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(= ' + SkuIdName + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', '(' + SkuIdName + ')', '{')) elif not self.DefaultStoreSingle and s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(= ' + DefaultStore + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', '(' + DefaultStore + ')', '{')) else: - FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')= ', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{')) + FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, ' ', TypeName, + '(' + Pcd.DatumType + ')= ', '(' + SkuIdName + ')', '(' + DefaultStore + ')', '{')) for Array in ArrayList: FileWrite(File, Array) else: if Pcd.DatumType in TAB_PCD_CLEAN_NUME= RIC_TYPES: if Value.startswith(('0x', '0X')): - Value =3D '{} ({:d})'.format(V= alue, int(Value, 0)) + Value =3D '{} ({:d})'.format( + Value, int(Value, 0)) else: - Value =3D "0x{:X} ({})".format= (int(Value, 0), Value) + Value =3D "0x{:X} ({})".format( + int(Value, 0), Value) if self.DefaultStoreSingle and self.Sk= uSingle: - FileWrite(File, ' %-*s : %6s %10= s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', Value)) elif self.DefaultStoreSingle and not s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(= ' + SkuIdName + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', '(' + SkuIdName + ')', Value)) elif not self.DefaultStoreSingle and s= elf.SkuSingle: - FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(= ' + DefaultStore + ')', Value)) + FileWrite(File, ' %-*s : %6s %10= s %10s =3D %s' % ( + self.MaxLen, ' ', TypeName, '(= ' + Pcd.DatumType + ')', '(' + DefaultStore + ')', Value)) else: - FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')= ', '(' + SkuIdName + ')', '(' + DefaultStore + ')', Value)) - FileWrite(File, '%*s: %s: %s' % (self.MaxLen += 4, SkuInfo.VariableGuid, SkuInfo.VariableName, SkuInfo.VariableOffset)) + FileWrite(File, ' %-*s : %6s %10= s %10s %10s =3D %s' % (self.MaxLen, ' ', TypeName, + '(' + Pcd.DatumType + ')= ', '(' + SkuIdName + ')', '(' + DefaultStore + ')', Value)) + FileWrite(File, '%*s: %s: %s' % (self.MaxLen += 4, SkuInfo.VariableGuid, + SkuInfo.VariableName, SkuInfo.Variab= leOffset)) if IsStructure: OverrideValues =3D Pcd.SkuOverrideValues.g= et(Sku) if OverrideValues: - OverrideFieldStruct =3D self.OverrideF= ieldValue(Pcd, OverrideValues[DefaultStore]) - self.PrintStructureInfo(File, Override= FieldStruct) - self.PrintPcdDefault(File, Pcd, IsStructure, D= scMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultVa= lue) + OverrideFieldStruct =3D self.OverrideF= ieldValue( + Pcd, OverrideValues[DefaultStore]) + self.PrintStructureInfo( + File, OverrideFieldStruct) + self.PrintPcdDefault( + File, Pcd, IsStructure, DscMatch, DscDefau= ltValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) else: Value =3D SkuInfo.DefaultValue IsByteArray, ArrayList =3D ByteArrayForamt(Value) @@ -1403,44 +1543,59 @@ class PcdReport(object): FirstPrint =3D False if IsByteArray: if self.SkuSingle: - FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType= + ')', "{")) + FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, Flag + + ' ' + PcdTokenCName, TypeName, '= (' + Pcd.DatumType + ')', "{")) else: - FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.Dat= umType + ')', '(' + SkuIdName + ')', "{")) + FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName, '(' + P= cd.DatumType + ')', '(' + SkuIdName + ')', "{")) for Array in ArrayList: FileWrite(File, Array) else: if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPE= S: if Value.startswith(('0x', '0X')): - Value =3D '{} ({:d})'.format(Value, in= t(Value, 0)) + Value =3D '{} ({:d})'.format( + Value, int(Value, 0)) else: - Value =3D "0x{:X} ({})".format(int(Val= ue, 0), Value) + Value =3D "0x{:X} ({})".format( + int(Value, 0), Value) if self.SkuSingle: - FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType= + ')', Value)) + FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, Flag + + ' ' + PcdTokenCName, TypeName, '= (' + Pcd.DatumType + ')', Value)) else: - FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.Dat= umType + ')', '(' + SkuIdName + ')', Value)) + FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, Flag + ' ' + + PcdTokenCName, TypeName, '(' + P= cd.DatumType + ')', '(' + SkuIdName + ')', Value)) else: if IsByteArray: if self.SkuSingle: - FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', "{")) + FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, + ' ', TypeName, '(' + Pcd.DatumTy= pe + ')', "{")) else: - FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + Sku= IdName + ')', "{")) + FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, ' ', + TypeName, '(' + Pcd.DatumType + = ')', '(' + SkuIdName + ')', "{")) for Array in ArrayList: FileWrite(File, Array) else: if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPE= S: if Value.startswith(('0x', '0X')): - Value =3D '{} ({:d})'.format(Value, in= t(Value, 0)) + Value =3D '{} ({:d})'.format( + Value, int(Value, 0)) else: - Value =3D "0x{:X} ({})".format(int(Val= ue, 0), Value) + Value =3D "0x{:X} ({})".format( + int(Value, 0), Value) if self.SkuSingle: - FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', Value)) + FileWrite(File, ' %-*s : %6s %10s =3D %s= ' % (self.MaxLen, + ' ', TypeName, '(' + Pcd.DatumTy= pe + ')', Value)) else: - FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, ' ', TypeName, '(' + Pcd.DatumType + ')', '(' + Sku= IdName + ')', Value)) + FileWrite(File, ' %-*s : %6s %10s %10s = =3D %s' % (self.MaxLen, ' ', + TypeName, '(' + Pcd.DatumType + = ')', '(' + SkuIdName + ')', Value)) if TypeName in ('DYNVPD', 'DEXVPD'): - FileWrite(File, '%*s' % (self.MaxLen + 4, SkuInfo.= VpdOffset)) - VPDPcdItem =3D (Pcd.TokenSpaceGuidCName + '.' + Pc= dTokenCName, SkuIdName, SkuInfo.VpdOffset, Pcd.MaxDatumSize, SkuInfo.Defaul= tValue) + FileWrite(File, '%*s' % + (self.MaxLen + 4, SkuInfo.VpdOffset)) + VPDPcdItem =3D (Pcd.TokenSpaceGuidCName + '.' + Pc= dTokenCName, SkuIdName, + SkuInfo.VpdOffset, Pcd.MaxDatumSize,= SkuInfo.DefaultValue) if VPDPcdItem not in VPDPcdList: - PcdGuidList =3D self.UnusedPcds.get(Pcd.TokenS= paceGuidCName) + PcdGuidList =3D self.UnusedPcds.get( + Pcd.TokenSpaceGuidCName) if PcdGuidList: PcdList =3D PcdGuidList.get(Pcd.Type) if not PcdList: @@ -1455,19 +1610,22 @@ class PcdReport(object): OverrideValues =3D Pcd.SkuOverrideValues.get(Sku) if OverrideValues: Keys =3D list(OverrideValues.keys()) - OverrideFieldStruct =3D self.OverrideFieldValu= e(Pcd, OverrideValues[Keys[0]]) + OverrideFieldStruct =3D self.OverrideFieldValu= e( + Pcd, OverrideValues[Keys[0]]) self.PrintStructureInfo(File, OverrideFieldStr= uct) FiledOverrideFlag =3D True if not FiledOverrideFlag and (Pcd.PcdFieldValueFro= mComm or Pcd.PcdFieldValueFromFdf): - OverrideFieldStruct =3D self.OverrideFieldValu= e(Pcd, {}) + OverrideFieldStruct =3D self.OverrideFieldValu= e( + Pcd, {}) self.PrintStructureInfo(File, OverrideFieldStr= uct) - self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch,= DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue) + self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch,= DscDefaultValue, + InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue) =20 def OverrideFieldValue(self, Pcd, OverrideStruct): OverrideFieldStruct =3D collections.OrderedDict() if OverrideStruct: for _, Values in OverrideStruct.items(): - for Key,value in Values.items(): + for Key, value in Values.items(): if value[1] and value[1].endswith('.dsc'): OverrideFieldStruct[Key] =3D value if Pcd.PcdFieldValueFromFdf: @@ -1485,11 +1643,14 @@ class PcdReport(object): def PrintStructureInfo(self, File, Struct): for Key, Value in sorted(Struct.items(), key=3Dlambda x: x[0]): if Value[1] and 'build command options' in Value[1]: - FileWrite(File, ' *B %-*s =3D %s' % (self.MaxLen + 4, = '.' + Key, Value[0])) + FileWrite(File, ' *B %-*s =3D %s' % + (self.MaxLen + 4, '.' + Key, Value[0])) elif Value[1] and Value[1].endswith('.fdf'): - FileWrite(File, ' *F %-*s =3D %s' % (self.MaxLen + 4, = '.' + Key, Value[0])) + FileWrite(File, ' *F %-*s =3D %s' % + (self.MaxLen + 4, '.' + Key, Value[0])) else: - FileWrite(File, ' %-*s =3D %s' % (self.MaxLen + 4, = '.' + Key, Value[0])) + FileWrite(File, ' %-*s =3D %s' % + (self.MaxLen + 4, '.' + Key, Value[0])) =20 def StrtoHex(self, value): try: @@ -1533,6 +1694,8 @@ class PcdReport(object): # This class reports the platform execution order prediction section and # module load fixed address prediction subsection in the build report file. # + + class PredictionReport(object): ## # Constructor function for class PredictionReport @@ -1575,24 +1738,28 @@ class PredictionReport(object): for Source in Module.SourceFileList: if os.path.splitext(str(Source))[1].lower() =3D=3D ".c= ": self._SourceList.append(" " + str(Source)) - FindIncludeFiles(Source.Path, Module.IncludePathLi= st, IncludeList) + FindIncludeFiles( + Source.Path, Module.IncludePathList, IncludeLi= st) for IncludeFile in IncludeList.values(): self._SourceList.append(" " + IncludeFile) =20 for Guid in Module.PpiList: - self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g(Module.PpiList[Guid]) + self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g( + Module.PpiList[Guid]) for Guid in Module.ProtocolList: - self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g(Module.ProtocolList[Guid]) + self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g( + Module.ProtocolList[Guid]) for Guid in Module.GuidList: - self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g(Module.GuidList[Guid]) + self._GuidMap[Guid] =3D GuidStructureStringToGuidStrin= g( + Module.GuidList[Guid]) =20 if Module.Guid and not Module.IsLibrary: EntryPoint =3D " ".join(Module.Module.ModuleEntryPoint= List) =20 RealEntryPoint =3D "_ModuleEntryPoint" =20 - self._FfsEntryPoint[Module.Guid.upper()] =3D (EntryPoi= nt, RealEntryPoint) - + self._FfsEntryPoint[Module.Guid.upper()] =3D ( + EntryPoint, RealEntryPoint) =20 # # Collect platform firmware volume list as the input of EOT. @@ -1617,7 +1784,6 @@ class PredictionReport(object): except AttributeError: pass =20 - ## # Parse platform fixed address map files # @@ -1627,6 +1793,7 @@ class PredictionReport(object): # # @param self: The object pointer # + def _ParseMapFile(self): if self._MapFileParsed: return @@ -1643,7 +1810,8 @@ class PredictionReport(object): List.append((AddressType, BaseAddress, "*I")) List.append((AddressType, EntryPoint, "*E")) except: - EdkLogger.warn(None, "Cannot open file to read", self._Map= FileName) + EdkLogger.warn(None, "Cannot open file to read", + self._MapFileName) =20 ## # Invokes EOT tool to get the predicted the execution order. @@ -1693,7 +1861,8 @@ class PredictionReport(object): Eot(CommandLineOption=3DFalse, SourceFileList=3DSourceList, Gu= idList=3DGuidList, FvFileList=3D' '.join(FvFileList), Dispatch=3DDispatchList= , IsInit=3DTrue) EotEndTime =3D time.time() - EotDuration =3D time.strftime("%H:%M:%S", time.gmtime(int(roun= d(EotEndTime - EotStartTime)))) + EotDuration =3D time.strftime("%H:%M:%S", time.gmtime( + int(round(EotEndTime - EotStartTime)))) EdkLogger.quiet("EOT run time: %s\n" % EotDuration) =20 # @@ -1708,9 +1877,10 @@ class PredictionReport(object): self.MaxLen =3D len(Symbol) self.ItemList.append((Phase, Symbol, FilePath)) except: - EdkLogger.quiet("(Python %s on %s\n%s)" % (platform.python_ver= sion(), sys.platform, traceback.format_exc())) - EdkLogger.warn(None, "Failed to generate execution order predi= ction report, for some error occurred in executing EOT.") - + EdkLogger.quiet("(Python %s on %s\n%s)" % ( + platform.python_version(), sys.platform, traceback.format_= exc())) + EdkLogger.warn( + None, "Failed to generate execution order prediction repor= t, for some error occurred in executing EOT.") =20 ## # Generate platform execution order report @@ -1720,6 +1890,7 @@ class PredictionReport(object): # @param self The object pointer # @param File The file object for report # + def _GenerateExecutionOrderReport(self, File): self._InvokeEotTool() if len(self.ItemList) =3D=3D 0: @@ -1731,10 +1902,12 @@ class PredictionReport(object): FileWrite(File, "*E Module INF entry point name") FileWrite(File, "*N Module notification function name") =20 - FileWrite(File, "Type %-*s %s" % (self.MaxLen, "Symbol", "Module I= NF Path")) + FileWrite(File, "Type %-*s %s" % + (self.MaxLen, "Symbol", "Module INF Path")) FileWrite(File, gSectionSep) for Item in self.ItemList: - FileWrite(File, "*%sE %-*s %s" % (Item[0], self.MaxLen, Item[= 1], Item[2])) + FileWrite(File, "*%sE %-*s %s" % + (Item[0], self.MaxLen, Item[1], Item[2])) =20 FileWrite(File, gSectionStart) =20 @@ -1774,7 +1947,8 @@ class PredictionReport(object): if Symbol =3D=3D "*I": Name =3D "(Image Base)" elif Symbol =3D=3D "*E": - Name =3D self._FfsEntryPoint.get(Guid, ["", "_ModuleEntryP= oint"])[1] + Name =3D self._FfsEntryPoint.get( + Guid, ["", "_ModuleEntryPoint"])[1] elif Symbol in NotifyList: Name =3D Symbol Symbol =3D "*N" @@ -1823,6 +1997,8 @@ class PredictionReport(object): # If there are nesting FVs, the nested FVs will list immediate after # this FD region subsection # + + class FdRegionReport(object): ## # Discover all the nested FV name list. @@ -1836,7 +2012,7 @@ class FdRegionReport(object): # @param Wa Workspace context information # def _DiscoverNestedFvList(self, FvName, Wa): - FvDictKey=3DFvName.upper() + FvDictKey =3D FvName.upper() if FvDictKey in Wa.FdfProfile.FvDict: for Ffs in Wa.FdfProfile.FvDict[FvName.upper()].FfsList: for Section in Ffs.SectionList: @@ -1844,7 +2020,8 @@ class FdRegionReport(object): for FvSection in Section.SectionList: if FvSection.FvName in self.FvList: continue - self._GuidsDb[Ffs.NameGuid.upper()] =3D FvSect= ion.FvName + self._GuidsDb[Ffs.NameGuid.upper() + ] =3D FvSection.FvName self.FvList.append(FvSection.FvName) self.FvInfo[FvSection.FvName] =3D ("Nested FV"= , 0, 0) self._DiscoverNestedFvList(FvSection.FvName, W= a) @@ -1897,15 +2074,19 @@ class FdRegionReport(object): for Pa in Wa.AutoGenObjectList: for Package in Pa.PackageList: for (TokenCName, TokenSpaceGuidCName, DecType) in Package.= Pcds: - DecDefaultValue =3D Package.Pcds[TokenCName, TokenSpac= eGuidCName, DecType].DefaultValue - PlatformPcds[(TokenCName, TokenSpaceGuidCName)] =3D De= cDefaultValue + DecDefaultValue =3D Package.Pcds[TokenCName, + TokenSpaceGuidCName, De= cType].DefaultValue + PlatformPcds[(TokenCName, TokenSpaceGuidCName) + ] =3D DecDefaultValue # # Collect PCDs defined in DSC file # for Pa in Wa.AutoGenObjectList: for (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds: - DscDefaultValue =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)].DefaultValue - PlatformPcds[(TokenCName, TokenSpaceGuidCName)] =3D DscDef= aultValue + DscDefaultValue =3D Pa.Platform.Pcds[( + TokenCName, TokenSpaceGuidCName)].DefaultValue + PlatformPcds[(TokenCName, TokenSpaceGuidCName) + ] =3D DscDefaultValue =20 # # Add PEI and DXE a priori files GUIDs defined in PI specification. @@ -1921,13 +2102,14 @@ class FdRegionReport(object): for ModuleKey in Pa.Platform.Modules: M =3D Pa.Platform.Modules[ModuleKey].M InfPath =3D mws.join(Wa.WorkspaceDir, M.MetaFile.File) - self._GuidsDb[M.Guid.upper()] =3D "%s (%s)" % (M.Module.Ba= seName, InfPath) + self._GuidsDb[M.Guid.upper()] =3D "%s (%s)" % ( + M.Module.BaseName, InfPath) =20 # # Collect the GUID map in the FV firmware volume # for FvName in self.FvList: - FvDictKey=3DFvName.upper() + FvDictKey =3D FvName.upper() if FvDictKey in Wa.FdfProfile.FvDict: for Ffs in Wa.FdfProfile.FvDict[FvName.upper()].FfsList: try: @@ -1940,18 +2122,20 @@ class FdRegionReport(object): PcdTokenspace =3D Match.group(1) PcdToken =3D Match.group(2) if (PcdToken, PcdTokenspace) in PlatformPcds: - GuidValue =3D PlatformPcds[(PcdToken, PcdT= okenspace)] - Guid =3D GuidStructureByteArrayToGuidStrin= g(GuidValue).upper() + GuidValue =3D PlatformPcds[( + PcdToken, PcdTokenspace)] + Guid =3D GuidStructureByteArrayToGuidStrin= g( + GuidValue).upper() for Section in Ffs.SectionList: try: - ModuleSectFile =3D mws.join(Wa.WorkspaceDi= r, Section.SectFileName) + ModuleSectFile =3D mws.join( + Wa.WorkspaceDir, Section.SectFileName) self._GuidsDb[Guid] =3D ModuleSectFile except AttributeError: pass except AttributeError: pass =20 - ## # Internal worker function to generate report for the FD region # @@ -1965,6 +2149,7 @@ class FdRegionReport(object): # @param Size The size of the FD region # @param FvName The FV name if the FD region is a firmware vo= lume # + def _GenerateReport(self, File, Title, Type, BaseAddress, Size=3D0, Fv= Name=3DNone): FileWrite(File, gSubSectionStart) FileWrite(File, Title) @@ -1974,7 +2159,7 @@ class FdRegionReport(object): if self.Type =3D=3D BINARY_FILE_TYPE_FV: FvTotalSize =3D 0 FvTakenSize =3D 0 - FvFreeSize =3D 0 + FvFreeSize =3D 0 if FvName.upper().endswith('.FV'): FileExt =3D FvName + ".txt" else: @@ -1999,10 +2184,14 @@ class FdRegionReport(object): # # Write size information to the report file. # - FileWrite(File, "Size: 0x%X (%.0fK)" % (FvTo= talSize, FvTotalSize / 1024.0)) - FileWrite(File, "Fv Name: %s (%.1f%% Full)" % (= FvName, FvTakenSize * 100.0 / FvTotalSize)) - FileWrite(File, "Occupied Size: 0x%X (%.0fK)" % (FvTa= kenSize, FvTakenSize / 1024.0)) - FileWrite(File, "Free Size: 0x%X (%.0fK)" % (FvFr= eeSize, FvFreeSize / 1024.0)) + FileWrite(File, "Size: 0x%X (%.0fK)" % + (FvTotalSize, FvTotalSize / 1024.0)) + FileWrite(File, "Fv Name: %s (%.1f%% Full)" % + (FvName, FvTakenSize * 100.0 / FvTotalSize)) + FileWrite(File, "Occupied Size: 0x%X (%.0fK)" % + (FvTakenSize, FvTakenSize / 1024.0)) + FileWrite(File, "Free Size: 0x%X (%.0fK)" % + (FvFreeSize, FvFreeSize / 1024.0)) FileWrite(File, "Offset Module") FileWrite(File, gSubSectionSep) # @@ -2014,11 +2203,13 @@ class FdRegionReport(object): OffsetInfo[Match.group(1)] =3D self._GuidsDb.get(Guid,= Guid) OffsetList =3D sorted(OffsetInfo.keys()) for Offset in OffsetList: - FileWrite (File, "%s %s" % (Offset, OffsetInfo[Offset]= )) + FileWrite(File, "%s %s" % (Offset, OffsetInfo[Offset])) except IOError: - EdkLogger.warn(None, "Fail to read report file", FvReportF= ileName) + EdkLogger.warn(None, "Fail to read report file", + FvReportFileName) else: - FileWrite(File, "Size: 0x%X (%.0fK)" % (Size, Si= ze / 1024.0)) + FileWrite(File, "Size: 0x%X (%.0fK)" % + (Size, Size / 1024.0)) FileWrite(File, gSubSectionEnd) =20 ## @@ -2033,9 +2224,11 @@ class FdRegionReport(object): if (len(self.FvList) > 0): for FvItem in self.FvList: Info =3D self.FvInfo[FvItem] - self._GenerateReport(File, Info[0], TAB_FV_DIRECTORY, Info= [1], Info[2], FvItem) + self._GenerateReport( + File, Info[0], TAB_FV_DIRECTORY, Info[1], Info[2], FvI= tem) else: - self._GenerateReport(File, "FD Region", self.Type, self.BaseAd= dress, self.Size) + self._GenerateReport(File, "FD Region", self.Type, + self.BaseAddress, self.Size) =20 ## # Reports FD information @@ -2043,6 +2236,8 @@ class FdRegionReport(object): # This class reports the FD section in the build report file. # It collects flash device information for a platform. # + + class FdReport(object): ## # Constructor function for class FdReport @@ -2058,7 +2253,8 @@ class FdReport(object): self.FdName =3D Fd.FdUiName self.BaseAddress =3D Fd.BaseAddress self.Size =3D Fd.Size - self.FdRegionList =3D [FdRegionReport(FdRegion, Wa) for FdRegion i= n Fd.RegionList] + self.FdRegionList =3D [FdRegionReport( + FdRegion, Wa) for FdRegion in Fd.RegionList] self.FvPath =3D os.path.join(Wa.BuildDir, TAB_FV_DIRECTORY) self.VPDBaseAddress =3D 0 self.VPDSize =3D 0 @@ -2081,7 +2277,8 @@ class FdReport(object): FileWrite(File, "Firmware Device (FD)") FileWrite(File, "FD Name: %s" % self.FdName) FileWrite(File, "Base Address: %s" % self.BaseAddress) - FileWrite(File, "Size: 0x%X (%.0fK)" % (self.Size, s= elf.Size / 1024.0)) + FileWrite(File, "Size: 0x%X (%.0fK)" % + (self.Size, self.Size / 1024.0)) if len(self.FdRegionList) > 0: FileWrite(File, gSectionSep) for FdRegionItem in self.FdRegionList: @@ -2092,26 +2289,28 @@ class FdReport(object): FileWrite(File, gSubSectionStart) FileWrite(File, "FD VPD Region") FileWrite(File, "Base Address: 0x%X" % self.VPDBaseAddre= ss) - FileWrite(File, "Size: 0x%X (%.0fK)" % (self.VPD= Size, self.VPDSize / 1024.0)) + FileWrite(File, "Size: 0x%X (%.0fK)" % + (self.VPDSize, self.VPDSize / 1024.0)) FileWrite(File, gSubSectionSep) for item in VPDPcdList: # Add BaseAddress for offset Offset =3D '0x%08X' % (int(item[2], 16) + self.VPDBaseAddr= ess) IsByteArray, ArrayList =3D ByteArrayForamt(item[-1]) Skuinfo =3D item[1] - if len(GlobalData.gSkuids) =3D=3D 1 : + if len(GlobalData.gSkuids) =3D=3D 1: Skuinfo =3D GlobalData.gSkuids[0] if IsByteArray: - FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], S= kuinfo, Offset, item[3], '{')) + FileWrite(File, "%s | %s | %s | %s | %s" % + (item[0], Skuinfo, Offset, item[3], '{')) for Array in ArrayList: FileWrite(File, Array) else: - FileWrite(File, "%s | %s | %s | %s | %s" % (item[0], S= kuinfo, Offset, item[3], item[-1])) + FileWrite(File, "%s | %s | %s | %s | %s" % + (item[0], Skuinfo, Offset, item[3], item[-1]= )) FileWrite(File, gSubSectionEnd) FileWrite(File, gSectionEnd) =20 =20 - ## # Reports platform information # @@ -2146,7 +2345,8 @@ class PlatformReport(object): self.FdReportList =3D [] if "FLASH" in ReportType and Wa.FdfProfile and MaList is None: for Fd in Wa.FdfProfile.FdDict: - self.FdReportList.append(FdReport(Wa.FdfProfile.FdDict[Fd]= , Wa)) + self.FdReportList.append( + FdReport(Wa.FdfProfile.FdDict[Fd], Wa)) =20 self.PredictionReport =3D None if "FIXED_ADDRESS" in ReportType or "EXECUTION_ORDER" in ReportTyp= e: @@ -2171,16 +2371,17 @@ class PlatformReport(object): if Pa.Arch in GlobalData.gFdfParser.Profile.InfDict: INFList =3D GlobalData.gFdfParser.Profile.InfDict[= Pa.Arch] for InfName in INFList: - InfClass =3D PathClass(NormPath(InfName), Wa.W= orkspaceDir, Pa.Arch) - Ma =3D ModuleAutoGen(Wa, InfClass, Pa.BuildTar= get, Pa.ToolChain, Pa.Arch, Wa.MetaFile, Pa.DataPipe) + InfClass =3D PathClass( + NormPath(InfName), Wa.WorkspaceDir, Pa.Arc= h) + Ma =3D ModuleAutoGen( + Wa, InfClass, Pa.BuildTarget, Pa.ToolChain= , Pa.Arch, Wa.MetaFile, Pa.DataPipe) if Ma is None: continue if Ma not in ModuleAutoGenList: ModuleAutoGenList.append(Ma) for MGen in ModuleAutoGenList: - self.ModuleReportList.append(ModuleReport(MGen, Report= Type)) - - + self.ModuleReportList.append( + ModuleReport(MGen, ReportType)) =20 ## # Generate report for the whole platform. @@ -2197,6 +2398,7 @@ class PlatformReport(object): # @param GenFdsTime The total time of GenFds Phase # @param ReportType The kind of report items in the final report = file # + def GenerateReport(self, File, BuildDuration, AutoGenTime, MakeTime, G= enFdsTime, ReportType): FileWrite(File, "Platform Summary") FileWrite(File, "Platform Name: %s" % self.PlatformName) @@ -2205,9 +2407,11 @@ class PlatformReport(object): FileWrite(File, "Tool Chain: %s" % self.ToolChain) FileWrite(File, "Target: %s" % self.Target) if GlobalData.gSkuids: - FileWrite(File, "SKUID: %s" % " ".join(GlobalDa= ta.gSkuids)) + FileWrite(File, "SKUID: %s" % + " ".join(GlobalData.gSkuids)) if GlobalData.gDefaultStores: - FileWrite(File, "DefaultStore: %s" % " ".join(GlobalDa= ta.gDefaultStores)) + FileWrite(File, "DefaultStore: %s" % + " ".join(GlobalData.gDefaultStores)) FileWrite(File, "Output Path: %s" % self.OutputPath) FileWrite(File, "Build Environment: %s" % self.BuildEnvironment) FileWrite(File, "Build Duration: %s" % BuildDuration) @@ -2236,17 +2440,20 @@ class PlatformReport(object): FdReportListItem.GenerateReport(File) =20 for ModuleReportItem in self.ModuleReportList: - ModuleReportItem.GenerateReport(File, self.PcdReport, self.Pre= dictionReport, self.DepexParser, ReportType) + ModuleReportItem.GenerateReport( + File, self.PcdReport, self.PredictionReport, self.DepexPar= ser, ReportType) =20 if not self._IsModuleBuild: if "EXECUTION_ORDER" in ReportType: self.PredictionReport.GenerateReport(File, None) =20 -## BuildReport class +# BuildReport class # # This base class contain the routines to collect data and then # applies certain format to the output report # + + class BuildReport(object): ## # Constructor function for class BuildReport @@ -2269,7 +2476,8 @@ class BuildReport(object): if ReportTypeItem not in self.ReportType: self.ReportType.append(ReportTypeItem) else: - self.ReportType =3D ["PCD", "LIBRARY", "BUILD_FLAGS", "DEP= EX", "HASH", "FLASH", "FIXED_ADDRESS"] + self.ReportType =3D ["PCD", "LIBRARY", "BUILD_FLAGS", + "DEPEX", "HASH", "FLASH", "FIXED_ADDRES= S"] ## # Adds platform report to the list # @@ -2279,6 +2487,7 @@ class BuildReport(object): # @param Wa Workspace context information # @param MaList The list of modules in the platform build # + def AddPlatformReport(self, Wa, MaList=3DNone): if self.ReportFile: self.ReportList.append((Wa, MaList)) @@ -2300,17 +2509,22 @@ class BuildReport(object): try: File =3D [] for (Wa, MaList) in self.ReportList: - PlatformReport(Wa, MaList, self.ReportType).GenerateRe= port(File, BuildDuration, AutoGenTime, MakeTime, GenFdsTime, self.ReportTyp= e) + PlatformReport(Wa, MaList, self.ReportType).GenerateRe= port( + File, BuildDuration, AutoGenTime, MakeTime, GenFds= Time, self.ReportType) Content =3D FileLinesSplit(''.join(File), gLineMaxLength) SaveFileOnChange(self.ReportFile, Content, False) - EdkLogger.quiet("Build report can be found at %s" % os.pat= h.abspath(self.ReportFile)) + EdkLogger.quiet("Build report can be found at %s" % + os.path.abspath(self.ReportFile)) except IOError: - EdkLogger.error(None, FILE_WRITE_FAILURE, ExtraData=3Dself= .ReportFile) + EdkLogger.error(None, FILE_WRITE_FAILURE, + ExtraData=3Dself.ReportFile) except: - EdkLogger.error("BuildReport", CODE_ERROR, "Unknown fatal = error when generating build report", ExtraData=3Dself.ReportFile, RaiseErro= r=3DFalse) - EdkLogger.quiet("(Python %s on %s\n%s)" % (platform.python= _version(), sys.platform, traceback.format_exc())) + EdkLogger.error("BuildReport", CODE_ERROR, "Unknown fatal = error when generating build report", + ExtraData=3Dself.ReportFile, RaiseError=3D= False) + EdkLogger.quiet("(Python %s on %s\n%s)" % ( + platform.python_version(), sys.platform, traceback.for= mat_exc())) + =20 # This acts like the main() function for the script, unless it is 'import'= ed into another script. if __name__ =3D=3D '__main__': pass - diff --git a/BaseTools/Source/Python/build/__init__.py b/BaseTools/Source/P= ython/build/__init__.py index 41a3808ae9ee..e2c52cf372a2 100644 --- a/BaseTools/Source/Python/build/__init__.py +++ b/BaseTools/Source/Python/build/__init__.py @@ -1,4 +1,4 @@ -## @file +# @file # Python 'build' package initialization file. # # This file is required to make Python interpreter treat the directory diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 07187c03618a..00f8bf490dd3 100755 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -1,4 +1,4 @@ -## @file +# @file # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
        @@ -23,16 +23,16 @@ import time import platform import traceback import multiprocessing -from threading import Thread,Event,BoundedSemaphore +from threading import Thread, Event, BoundedSemaphore import threading from linecache import getlines -from subprocess import Popen,PIPE, STDOUT +from subprocess import Popen, PIPE, STDOUT from collections import OrderedDict, defaultdict =20 from AutoGen.PlatformAutoGen import PlatformAutoGen from AutoGen.ModuleAutoGen import ModuleAutoGen from AutoGen.WorkspaceAutoGen import WorkspaceAutoGen -from AutoGen.AutoGenWorker import AutoGenWorkerInProcess,AutoGenManager,\ +from AutoGen.AutoGenWorker import AutoGenWorkerInProcess, AutoGenManager,\ LogAgent from AutoGen import GenMake from Common import Misc as Utils @@ -40,7 +40,7 @@ from Common import Misc as Utils from Common.TargetTxtClassObject import TargetTxtDict from Common.ToolDefClassObject import ToolDefDict from buildoptions import MyOptionParser -from Common.Misc import PathClass,SaveFileOnChange,RemoveDirectory +from Common.Misc import PathClass, SaveFileOnChange, RemoveDirectory from Common.StringUtils import NormPath from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.BuildToolError import * @@ -50,7 +50,7 @@ import Common.EdkLogger as EdkLogger from Workspace.WorkspaceDatabase import BuildDB =20 from BuildReport import BuildReport -from GenPatchPcdTable.GenPatchPcdTable import PeImageClass,parsePcdInfoFro= mMapFile +from GenPatchPcdTable.GenPatchPcdTable import PeImageClass, parsePcdInfoFr= omMapFile from PatchPcdValue.PatchPcdValue import PatchBinaryFile =20 import Common.GlobalData as GlobalData @@ -64,17 +64,20 @@ from AutoGen.IncludesAutoGen import IncludesAutoGen from GenFds.GenFds import resetFdsGlobalVariable from AutoGen.AutoGen import CalculatePriorityValue =20 -## standard targets of build command -gSupportedTarget =3D ['all', 'genc', 'genmake', 'modules', 'libraries', 'f= ds', 'clean', 'cleanall', 'cleanlib', 'run'] +# standard targets of build command +gSupportedTarget =3D ['all', 'genc', 'genmake', 'modules', + 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', '= run'] =20 TemporaryTablePattern =3D re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$') TmpTableDict =3D {} =20 -## Check environment PATH variable to make sure the specified tool is found +# Check environment PATH variable to make sure the specified tool is found # # If the tool is found in the PATH, then True is returned # Otherwise, False is returned # + + def IsToolInPath(tool): if 'PATHEXT' in os.environ: extns =3D os.environ['PATHEXT'].split(os.path.pathsep) @@ -86,7 +89,7 @@ def IsToolInPath(tool): return True return False =20 -## Check environment variables +# Check environment variables # # Check environment variables that must be set for build. Currently they = are # @@ -97,6 +100,8 @@ def IsToolInPath(tool): # If any of above environment variable is not set or has error, the build # will be broken. # + + def CheckEnvVariable(): # check WORKSPACE if "WORKSPACE" not in os.environ: @@ -105,7 +110,8 @@ def CheckEnvVariable(): =20 WorkspaceDir =3D os.path.normcase(os.path.normpath(os.environ["WORKSPA= CE"])) if not os.path.exists(WorkspaceDir): - EdkLogger.error("build", FILE_NOT_FOUND, "WORKSPACE doesn't exist"= , ExtraData=3DWorkspaceDir) + EdkLogger.error("build", FILE_NOT_FOUND, + "WORKSPACE doesn't exist", ExtraData=3DWorkspaceDi= r) elif ' ' in WorkspaceDir: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowe= d in WORKSPACE path", ExtraData=3DWorkspaceDir) @@ -117,12 +123,14 @@ def CheckEnvVariable(): if mws.PACKAGES_PATH: for Path in mws.PACKAGES_PATH: if not os.path.exists(Path): - EdkLogger.error("build", FILE_NOT_FOUND, "One Path in PACK= AGES_PATH doesn't exist", ExtraData=3DPath) + EdkLogger.error( + "build", FILE_NOT_FOUND, "One Path in PACKAGES_PATH do= esn't exist", ExtraData=3DPath) elif ' ' in Path: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space i= s allowed in PACKAGES_PATH", ExtraData=3DPath) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, + "No space is allowed in PACKAGES_PATH", Ex= traData=3DPath) =20 - - os.environ["EDK_TOOLS_PATH"] =3D os.path.normcase(os.environ["EDK_TOOL= S_PATH"]) + os.environ["EDK_TOOLS_PATH"] =3D os.path.normcase( + os.environ["EDK_TOOLS_PATH"]) =20 # check EDK_TOOLS_PATH if "EDK_TOOLS_PATH" not in os.environ: @@ -136,10 +144,10 @@ def CheckEnvVariable(): =20 GlobalData.gWorkspace =3D WorkspaceDir =20 - GlobalData.gGlobalDefines["WORKSPACE"] =3D WorkspaceDir + GlobalData.gGlobalDefines["WORKSPACE"] =3D WorkspaceDir GlobalData.gGlobalDefines["EDK_TOOLS_PATH"] =3D os.environ["EDK_TOOLS_= PATH"] =20 -## Get normalized file path +# Get normalized file path # # Convert the path to be local format, and remove the WORKSPACE path at the # beginning if the file path is given in full path. @@ -149,6 +157,8 @@ def CheckEnvVariable(): # # @retval string The normalized file path # + + def NormFile(FilePath, Workspace): # check if the path is absolute or relative if os.path.isabs(FilePath): @@ -159,7 +169,8 @@ def NormFile(FilePath, Workspace): =20 # check if the file path exists or not if not os.path.isfile(FileFullPath): - EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=3D"\t%s (Please= give file in absolute path or relative to WORKSPACE)" % FileFullPath) + EdkLogger.error("build", FILE_NOT_FOUND, + ExtraData=3D"\t%s (Please give file in absolute pa= th or relative to WORKSPACE)" % FileFullPath) =20 # remove workspace directory from the beginning part of the file path if Workspace[-1] in ["\\", "/"]: @@ -167,7 +178,7 @@ def NormFile(FilePath, Workspace): else: return FileFullPath[(len(Workspace) + 1):] =20 -## Get the output of an external program +# Get the output of an external program # # This is the entrance method of thread reading output of an external prog= ram and # putting them in STDOUT/STDERR of current program. @@ -176,7 +187,9 @@ def NormFile(FilePath, Workspace): # @param To The stream message put on # @param ExitFlag The flag used to indicate stopping reading # -def ReadMessage(From, To, ExitFlag,MemTo=3DNone): + + +def ReadMessage(From, To, ExitFlag, MemTo=3DNone): while True: # read one line a time Line =3D From.readline() @@ -184,7 +197,7 @@ def ReadMessage(From, To, ExitFlag,MemTo=3DNone): if Line is not None and Line !=3D b"": LineStr =3D Line.rstrip().decode(encoding=3D'utf-8', errors=3D= 'ignore') if MemTo is not None: - if "Note: including file:" =3D=3D LineStr.lstrip()[:21]: + if "Note: including file:" =3D=3D LineStr.lstrip()[:21]: MemTo.append(LineStr) else: To(LineStr) @@ -196,12 +209,13 @@ def ReadMessage(From, To, ExitFlag,MemTo=3DNone): if ExitFlag.is_set(): break =20 + class MakeSubProc(Popen): - def __init__(self,*args, **argv): - super(MakeSubProc,self).__init__(*args, **argv) + def __init__(self, *args, **argv): + super(MakeSubProc, self).__init__(*args, **argv) self.ProcOut =3D [] =20 -## Launch an external program +# Launch an external program # # This method will call subprocess.Popen to execute an external program wi= th # given options in specified directory. Because of the dead-lock issue dur= ing @@ -211,7 +225,9 @@ class MakeSubProc(Popen): # @param Command A list or string containing the call of th= e program # @param WorkingDir The directory in which the program will be= running # -def LaunchCommand(Command, WorkingDir,ModuleAuto =3D None): + + +def LaunchCommand(Command, WorkingDir, ModuleAuto=3DNone): BeginTime =3D time.time() # if working directory doesn't exist, Popen() will raise an exception if not os.path.isdir(WorkingDir): @@ -230,29 +246,32 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto =3D = None): EndOfProcedure =3D None try: # launch the command - Proc =3D MakeSubProc(Command, stdout=3DPIPE, stderr=3DSTDOUT, env= =3Dos.environ, cwd=3DWorkingDir, bufsize=3D-1, shell=3DTrue) + Proc =3D MakeSubProc(Command, stdout=3DPIPE, stderr=3DSTDOUT, + env=3Dos.environ, cwd=3DWorkingDir, bufsize=3D-= 1, shell=3DTrue) =20 # launch two threads to read the STDOUT and STDERR EndOfProcedure =3D Event() EndOfProcedure.clear() if Proc.stdout: - StdOutThread =3D Thread(target=3DReadMessage, args=3D(Proc.std= out, EdkLogger.info, EndOfProcedure,Proc.ProcOut)) + StdOutThread =3D Thread(target=3DReadMessage, args=3D( + Proc.stdout, EdkLogger.info, EndOfProcedure, Proc.ProcOut)) StdOutThread.name =3D "STDOUT-Redirector" StdOutThread.daemon =3D False StdOutThread.start() =20 - # waiting for program exit Proc.wait() - except: # in case of aborting + except: # in case of aborting # terminate the threads redirecting the program output - EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(),= sys.platform) + traceback.format_exc()) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.format_ex= c()) if EndOfProcedure is not None: EndOfProcedure.set() if Proc is None: if not isinstance(Command, type("")): Command =3D " ".join(Command) - EdkLogger.error("build", COMMAND_FAILURE, "Failed to start com= mand", ExtraData=3D"%s [%s]" % (Command, WorkingDir)) + EdkLogger.error("build", COMMAND_FAILURE, "Failed to start com= mand", + ExtraData=3D"%s [%s]" % (Command, WorkingDir)) =20 if Proc.stdout: StdOutThread.join() @@ -269,9 +288,10 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto =3D N= one): f.close() EdkLogger.info(RespContent) =20 - EdkLogger.error("build", COMMAND_FAILURE, ExtraData=3D"%s [%s]" % = (Command, WorkingDir)) + EdkLogger.error("build", COMMAND_FAILURE, + ExtraData=3D"%s [%s]" % (Command, WorkingDir)) if ModuleAuto: - iau =3D IncludesAutoGen(WorkingDir,ModuleAuto) + iau =3D IncludesAutoGen(WorkingDir, ModuleAuto) if ModuleAuto.ToolChainFamily =3D=3D TAB_COMPILER_MSFT: iau.CreateDepsFileForMsvc(Proc.ProcOut) else: @@ -282,7 +302,7 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto =3D No= ne): iau.CreateDepsTarget() return "%dms" % (int(round((time.time() - BeginTime) * 1000))) =20 -## The smallest unit that can be built in multi-thread build mode +# The smallest unit that can be built in multi-thread build mode # # This is the base class of build unit. The "Obj" parameter must provide # __str__(), __eq__() and __hash__() methods. Otherwise there could be bui= ld units @@ -290,8 +310,10 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto =3D N= one): # # Currently the "Obj" should be only ModuleAutoGen or PlatformAutoGen obje= cts. # + + class BuildUnit: - ## The constructor + # The constructor # # @param self The object pointer # @param Obj The object the build is working on @@ -309,20 +331,20 @@ class BuildUnit: EdkLogger.error("build", OPTION_MISSING, "No build command found for this module. " "Please check your setting of %s_%s_%s_MAKE_PA= TH in Conf/tools_def.txt file." % - (Obj.BuildTarget, Obj.ToolChain, Obj.Arch), + (Obj.BuildTarget, Obj.ToolChain, Obj.Arch), ExtraData=3Dstr(Obj)) =20 - - ## str() method + # str() method # # It just returns the string representation of self.BuildObject # # @param self The object pointer # + def __str__(self): return str(self.BuildObject) =20 - ## "=3D=3D" operator method + # "=3D=3D" operator method # # It just compares self.BuildObject with "Other". So self.BuildObjec= t must # provide its own __eq__() method. @@ -332,10 +354,10 @@ class BuildUnit: # def __eq__(self, Other): return Other and self.BuildObject =3D=3D Other.BuildObject \ - and Other.BuildObject \ - and self.BuildObject.Arch =3D=3D Other.BuildObject.Arch + and Other.BuildObject \ + and self.BuildObject.Arch =3D=3D Other.BuildObject.Arch =20 - ## hash() method + # hash() method # # It just returns the hash value of self.BuildObject which must be h= ashable. # @@ -347,7 +369,7 @@ class BuildUnit: def __repr__(self): return repr(self.BuildObject) =20 -## The smallest module unit that can be built by nmake/make command in mul= ti-thread build mode +# The smallest module unit that can be built by nmake/make command in mult= i-thread build mode # # This class is for module build by nmake/make build system. The "Obj" par= ameter # must provide __str__(), __eq__() and __hash__() methods. Otherwise there= could @@ -355,20 +377,24 @@ class BuildUnit: # # Currently the "Obj" should be only ModuleAutoGen object. # + + class ModuleMakeUnit(BuildUnit): - ## The constructor + # The constructor # # @param self The object pointer # @param Obj The ModuleAutoGen object the build is working = on # @param Target The build target name, one of gSupportedTarget # - def __init__(self, Obj, BuildCommand,Target): - Dependency =3D [ModuleMakeUnit(La, BuildCommand,Target) for La in = Obj.LibraryAutoGenList] - BuildUnit.__init__(self, Obj, BuildCommand, Target, Dependency, Ob= j.MakeFileDir) + def __init__(self, Obj, BuildCommand, Target): + Dependency =3D [ModuleMakeUnit(La, BuildCommand, Target) + for La in Obj.LibraryAutoGenList] + BuildUnit.__init__(self, Obj, BuildCommand, Target, + Dependency, Obj.MakeFileDir) if Target in [None, "", "all"]: self.Target =3D "tbuild" =20 -## The smallest platform unit that can be built by nmake/make command in m= ulti-thread build mode +# The smallest platform unit that can be built by nmake/make command in mu= lti-thread build mode # # This class is for platform build by nmake/make build system. The "Obj" p= arameter # must provide __str__(), __eq__() and __hash__() methods. Otherwise there= could @@ -376,23 +402,30 @@ class ModuleMakeUnit(BuildUnit): # # Currently the "Obj" should be only PlatformAutoGen object. # + + class PlatformMakeUnit(BuildUnit): - ## The constructor + # The constructor # # @param self The object pointer # @param Obj The PlatformAutoGen object the build is workin= g on # @param Target The build target name, one of gSupportedTarget # def __init__(self, Obj, BuildCommand, Target): - Dependency =3D [ModuleMakeUnit(Lib, BuildCommand, Target) for Lib = in self.BuildObject.LibraryAutoGenList] - Dependency.extend([ModuleMakeUnit(Mod, BuildCommand,Target) for Mo= d in self.BuildObject.ModuleAutoGenList]) - BuildUnit.__init__(self, Obj, BuildCommand, Target, Dependency, Ob= j.MakeFileDir) + Dependency =3D [ModuleMakeUnit(Lib, BuildCommand, Target) + for Lib in self.BuildObject.LibraryAutoGenList] + Dependency.extend([ModuleMakeUnit(Mod, BuildCommand, Target) + for Mod in self.BuildObject.ModuleAutoGenList]) + BuildUnit.__init__(self, Obj, BuildCommand, Target, + Dependency, Obj.MakeFileDir) =20 -## The class representing the task of a module build or platform build +# The class representing the task of a module build or platform build # # This class manages the build tasks in multi-thread build mode. Its jobs = include # scheduling thread running, catching thread error, monitor the thread sta= tus, etc. # + + class BuildTask: # queue for tasks waiting for schedule _PendingQueue =3D OrderedDict() @@ -421,14 +454,15 @@ class BuildTask: _SchedulerStopped =3D threading.Event() _SchedulerStopped.set() =20 - ## Start the task scheduler thread + # Start the task scheduler thread # # @param MaxThreadNumber The maximum thread number # @param ExitFlag Flag used to end the scheduler # @staticmethod def StartScheduler(MaxThreadNumber, ExitFlag): - SchedulerThread =3D Thread(target=3DBuildTask.Scheduler, args=3D(M= axThreadNumber, ExitFlag)) + SchedulerThread =3D Thread( + target=3DBuildTask.Scheduler, args=3D(MaxThreadNumber, ExitFla= g)) SchedulerThread.name =3D "Build-Task-Scheduler" SchedulerThread.daemon =3D False SchedulerThread.start() @@ -436,7 +470,7 @@ class BuildTask: while not BuildTask.IsOnGoing(): time.sleep(0.01) =20 - ## Scheduler method + # Scheduler method # # @param MaxThreadNumber The maximum thread number # @param ExitFlag Flag used to end the scheduler @@ -451,7 +485,7 @@ class BuildTask: # scheduling loop, which will exits when no pending/ready task= and # indicated to do so, or there's error in running thread # - while (len(BuildTask._PendingQueue) > 0 or len(BuildTask._Read= yQueue) > 0 \ + while (len(BuildTask._PendingQueue) > 0 or len(BuildTask._Read= yQueue) > 0 or not ExitFlag.is_set()) and not BuildTask._ErrorFlag.= is_set(): EdkLogger.debug(EdkLogger.DEBUG_8, "Pending Queue (%d), Re= ady Queue (%d)" % (len(BuildTask._PendingQueue), len(Build= Task._ReadyQueue))) @@ -466,7 +500,8 @@ class BuildTask: for BuildObject in BuildObjectList: Bt =3D BuildTask._PendingQueue[BuildObject] if Bt.IsReady(): - BuildTask._ReadyQueue[BuildObject] =3D BuildTask._= PendingQueue.pop(BuildObject) + BuildTask._ReadyQueue[BuildObject] =3D BuildTask._= PendingQueue.pop( + BuildObject) BuildTask._PendingQueueLock.release() =20 # launch build thread until the maximum number of threads = is reached @@ -498,8 +533,10 @@ class BuildTask: EdkLogger.quiet("\nWaiting for all build threads exit...") # while not BuildTask._ErrorFlag.is_set() and \ while len(BuildTask._RunningQueue) > 0: - EdkLogger.verbose("Waiting for thread ending...(%d)" % len= (BuildTask._RunningQueue)) - EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".j= oin(Th.name for Th in threading.enumerate())) + EdkLogger.verbose("Waiting for thread ending...(%d)" % + len(BuildTask._RunningQueue)) + EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".j= oin( + Th.name for Th in threading.enumerate())) # avoid tense loop time.sleep(0.1) except BaseException as X: @@ -509,7 +546,8 @@ class BuildTask: # EdkLogger.SetLevel(EdkLogger.ERROR) BuildTask._ErrorFlag.set() - BuildTask._ErrorMessage =3D "build thread scheduler error\n\t%= s" % str(X) + BuildTask._ErrorMessage =3D "build thread scheduler error\n\t%= s" % str( + X) =20 BuildTask._PendingQueue.clear() BuildTask._ReadyQueue.clear() @@ -517,26 +555,26 @@ class BuildTask: BuildTask._TaskQueue.clear() BuildTask._SchedulerStopped.set() =20 - ## Wait for all running method exit + # Wait for all running method exit # @staticmethod def WaitForComplete(): BuildTask._SchedulerStopped.wait() =20 - ## Check if the scheduler is running or not + # Check if the scheduler is running or not # @staticmethod def IsOnGoing(): return not BuildTask._SchedulerStopped.is_set() =20 - ## Abort the build + # Abort the build @staticmethod def Abort(): if BuildTask.IsOnGoing(): BuildTask._ErrorFlag.set() BuildTask.WaitForComplete() =20 - ## Check if there's error in running thread + # Check if there's error in running thread # # Since the main thread cannot catch exceptions in other thread, we = have to # use threading.Event to communicate this formation to main thread. @@ -545,7 +583,7 @@ class BuildTask: def HasError(): return BuildTask._ErrorFlag.is_set() =20 - ## Get error message in running thread + # Get error message in running thread # # Since the main thread cannot catch exceptions in other thread, we = have to # use a static variable to communicate this message to main thread. @@ -554,7 +592,7 @@ class BuildTask: def GetErrorMessage(): return BuildTask._ErrorMessage =20 - ## Factory method to create a BuildTask object + # Factory method to create a BuildTask object # # This method will check if a module is building or has been built. = And if # true, just return the associated BuildTask object in the _TaskQueu= e. If @@ -580,7 +618,7 @@ class BuildTask: =20 return Bt =20 - ## The real constructor of BuildTask + # The real constructor of BuildTask # # @param BuildItem A BuildUnit object representing a build ob= ject # @param Dependency The dependent build object of BuildItem @@ -597,7 +635,7 @@ class BuildTask: # flag indicating build completes, used to avoid unnecessary re-bu= ild self.CompleteFlag =3D False =20 - ## Check if all dependent build tasks are completed or not + # Check if all dependent build tasks are completed or not # def IsReady(self): ReadyFlag =3D True @@ -609,23 +647,25 @@ class BuildTask: =20 return ReadyFlag =20 - ## Add dependent build task + # Add dependent build task # # @param Dependency The list of dependent build objects # def AddDependency(self, Dependency): for Dep in Dependency: if not Dep.BuildObject.IsBinaryModule and not Dep.BuildObject.= CanSkipbyCache(GlobalData.gModuleCacheHit): - self.DependencyList.append(BuildTask.New(Dep)) # BuildT= ask list + self.DependencyList.append( + BuildTask.New(Dep)) # BuildTask list =20 - ## The thread wrapper of LaunchCommand function + # The thread wrapper of LaunchCommand function # # @param Command A list or string contains the call of = the command # @param WorkingDir The directory in which the program wil= l be running # def _CommandThread(self, Command, WorkingDir): try: - self.BuildItem.BuildObject.BuildTime =3D LaunchCommand(Command= , WorkingDir,self.BuildItem.BuildObject) + self.BuildItem.BuildObject.BuildTime =3D LaunchCommand( + Command, WorkingDir, self.BuildItem.BuildObject) self.CompleteFlag =3D True =20 # Run hash operation post dependency to account for libs @@ -645,11 +685,12 @@ class BuildTask: self.Bui= ldItem.BuildObject.Arch, self.Bui= ldItem.BuildObject.ToolChain, self.Bui= ldItem.BuildObject.BuildTarget - ) + ) EdkLogger.SetLevel(EdkLogger.ERROR) BuildTask._ErrorFlag.set() BuildTask._ErrorMessage =3D "%s broken\n %s [%s]" % \ - (threading.current_thread().name, Co= mmand, WorkingDir) + (threading.current_thread().name, + Command, WorkingDir) =20 # indicate there's a thread is available for another build task BuildTask._RunningQueueLock.acquire() @@ -657,20 +698,23 @@ class BuildTask: BuildTask._RunningQueueLock.release() BuildTask._Thread.release() =20 - ## Start build task thread + # Start build task thread # def Start(self): EdkLogger.quiet("Building ... %s" % repr(self.BuildItem)) Command =3D self.BuildItem.BuildCommand + [self.BuildItem.Target] - self.BuildTread =3D Thread(target=3Dself._CommandThread, args=3D(C= ommand, self.BuildItem.WorkingDir)) + self.BuildTread =3D Thread(target=3Dself._CommandThread, args=3D( + Command, self.BuildItem.WorkingDir)) self.BuildTread.name =3D "build thread" self.BuildTread.daemon =3D False self.BuildTread.start() =20 -## The class contains the information related to EFI image +# The class contains the information related to EFI image # + + class PeImageInfo(): - ## Constructor + # Constructor # # Constructor will load all required image information. # @@ -682,15 +726,15 @@ class PeImageInfo(): # @param ImageClass PeImage Information # def __init__(self, BaseName, Guid, Arch, OutputDir, DebugDir, ImageCla= ss): - self.BaseName =3D BaseName - self.Guid =3D Guid - self.Arch =3D Arch - self.OutputDir =3D OutputDir - self.DebugDir =3D DebugDir - self.Image =3D ImageClass - self.Image.Size =3D (self.Image.Size // 0x1000 + 1) * 0x1000 + self.BaseName =3D BaseName + self.Guid =3D Guid + self.Arch =3D Arch + self.OutputDir =3D OutputDir + self.DebugDir =3D DebugDir + self.Image =3D ImageClass + self.Image.Size =3D (self.Image.Size // 0x1000 + 1) * 0x1000 =20 -## The class implementing the EDK2 build process +# The class implementing the EDK2 build process # # The build process includes: # 1. Load configuration from target.txt and tools_def.txt in $(WORKS= PACE)/Conf @@ -700,8 +744,10 @@ class PeImageInfo(): # 5. Create AutoGen files (C code file, depex file, makefile) if nec= essary # 6. Call build command # + + class Build(): - ## Constructor + # Constructor # # Constructor will load all necessary configurations, parse platform, = modules # and packages and the establish a database for AutoGen. @@ -710,53 +756,58 @@ class Build(): # @param WorkspaceDir The directory of workspace # @param BuildOptions Build options passed from command line # - def __init__(self, Target, WorkspaceDir, BuildOptions,log_q): - self.WorkspaceDir =3D WorkspaceDir - self.Target =3D Target - self.PlatformFile =3D BuildOptions.PlatformFile - self.ModuleFile =3D BuildOptions.ModuleFile - self.ArchList =3D BuildOptions.TargetArch - self.ToolChainList =3D BuildOptions.ToolChain - self.BuildTargetList=3D BuildOptions.BuildTarget - self.Fdf =3D BuildOptions.FdfFile - self.FdList =3D BuildOptions.RomImage - self.FvList =3D BuildOptions.FvImage - self.CapList =3D BuildOptions.CapName - self.SilentMode =3D BuildOptions.SilentMode - self.ThreadNumber =3D 1 - self.SkipAutoGen =3D BuildOptions.SkipAutoGen - self.Reparse =3D BuildOptions.Reparse - self.SkuId =3D BuildOptions.SkuId + def __init__(self, Target, WorkspaceDir, BuildOptions, log_q): + self.WorkspaceDir =3D WorkspaceDir + self.Target =3D Target + self.PlatformFile =3D BuildOptions.PlatformFile + self.ModuleFile =3D BuildOptions.ModuleFile + self.ArchList =3D BuildOptions.TargetArch + self.ToolChainList =3D BuildOptions.ToolChain + self.BuildTargetList =3D BuildOptions.BuildTarget + self.Fdf =3D BuildOptions.FdfFile + self.FdList =3D BuildOptions.RomImage + self.FvList =3D BuildOptions.FvImage + self.CapList =3D BuildOptions.CapName + self.SilentMode =3D BuildOptions.SilentMode + self.ThreadNumber =3D 1 + self.SkipAutoGen =3D BuildOptions.SkipAutoGen + self.Reparse =3D BuildOptions.Reparse + self.SkuId =3D BuildOptions.SkuId if self.SkuId: GlobalData.gSKUID_CMD =3D self.SkuId self.ConfDirectory =3D BuildOptions.ConfDirectory - self.SpawnMode =3D True - self.BuildReport =3D BuildReport(BuildOptions.ReportFile, Build= Options.ReportType) - self.AutoGenTime =3D 0 - self.MakeTime =3D 0 - self.GenFdsTime =3D 0 - self.MakeFileName =3D "" + self.SpawnMode =3D True + self.BuildReport =3D BuildReport( + BuildOptions.ReportFile, BuildOptions.ReportType) + self.AutoGenTime =3D 0 + self.MakeTime =3D 0 + self.GenFdsTime =3D 0 + self.MakeFileName =3D "" TargetObj =3D TargetTxtDict() - ToolDefObj =3D ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"C= onf"))) + ToolDefObj =3D ToolDefDict( + (os.path.join(os.getenv("WORKSPACE"), "Conf"))) self.TargetTxt =3D TargetObj.Target self.ToolDef =3D ToolDefObj.ToolDef - GlobalData.BuildOptionPcd =3D BuildOptions.OptionPcd if BuildO= ptions.OptionPcd else [] - #Set global flag for build mode + GlobalData.BuildOptionPcd =3D BuildOptions.OptionPcd if BuildOptio= ns.OptionPcd else [] + # Set global flag for build mode GlobalData.gIgnoreSource =3D BuildOptions.IgnoreSources GlobalData.gUseHashCache =3D BuildOptions.UseHashCache - GlobalData.gBinCacheDest =3D BuildOptions.BinCacheDest + GlobalData.gBinCacheDest =3D BuildOptions.BinCacheDest GlobalData.gBinCacheSource =3D BuildOptions.BinCacheSource GlobalData.gEnableGenfdsMultiThread =3D not BuildOptions.NoGenfdsM= ultiThread GlobalData.gDisableIncludePathCheck =3D BuildOptions.DisableInclud= ePathCheck =20 if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache: - EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--= binary-destination must be used together with --hash.") + EdkLogger.error("build", OPTION_NOT_SUPPORTED, + ExtraData=3D"--binary-destination must be used= together with --hash.") =20 if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache: - EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--= binary-source must be used together with --hash.") + EdkLogger.error("build", OPTION_NOT_SUPPORTED, + ExtraData=3D"--binary-source must be used toge= ther with --hash.") =20 if GlobalData.gBinCacheDest and GlobalData.gBinCacheSource: - EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--= binary-destination can not be used together with --binary-source.") + EdkLogger.error("build", OPTION_NOT_SUPPORTED, + ExtraData=3D"--binary-destination can not be u= sed together with --binary-source.") =20 if GlobalData.gBinCacheSource: BinCacheSource =3D os.path.normpath(GlobalData.gBinCacheSource) @@ -765,7 +816,8 @@ class Build(): GlobalData.gBinCacheSource =3D BinCacheSource else: if GlobalData.gBinCacheSource is not None: - EdkLogger.error("build", OPTION_VALUE_INVALID, ExtraData= =3D"Invalid value of option --binary-source.") + EdkLogger.error("build", OPTION_VALUE_INVALID, + ExtraData=3D"Invalid value of option --bin= ary-source.") =20 if GlobalData.gBinCacheDest: BinCacheDest =3D os.path.normpath(GlobalData.gBinCacheDest) @@ -774,9 +826,11 @@ class Build(): GlobalData.gBinCacheDest =3D BinCacheDest else: if GlobalData.gBinCacheDest is not None: - EdkLogger.error("build", OPTION_VALUE_INVALID, ExtraData= =3D"Invalid value of option --binary-destination.") + EdkLogger.error("build", OPTION_VALUE_INVALID, + ExtraData=3D"Invalid value of option --bin= ary-destination.") =20 - GlobalData.gDatabasePath =3D os.path.normpath(os.path.join(GlobalD= ata.gConfDirectory, GlobalData.gDatabasePath)) + GlobalData.gDatabasePath =3D os.path.normpath(os.path.join( + GlobalData.gConfDirectory, GlobalData.gDatabasePath)) if not os.path.exists(os.path.join(GlobalData.gConfDirectory, '.ca= che')): os.makedirs(os.path.join(GlobalData.gConfDirectory, '.cache')) self.Db =3D BuildDB @@ -784,12 +838,13 @@ class Build(): self.Platform =3D None self.ToolChainFamily =3D None self.LoadFixAddress =3D 0 - self.UniFlag =3D BuildOptions.Flag + self.UniFlag =3D BuildOptions.Flag self.BuildModules =3D [] self.HashSkipModules =3D [] self.Db_Flag =3D False self.LaunchPrebuildFlag =3D False - self.PlatformBuildPath =3D os.path.join(GlobalData.gConfDirectory,= '.cache', '.PlatformBuild') + self.PlatformBuildPath =3D os.path.join( + GlobalData.gConfDirectory, '.cache', '.PlatformBuild') if BuildOptions.CommandLength: GlobalData.gCommandMaxLength =3D BuildOptions.CommandLength =20 @@ -799,19 +854,24 @@ class Build(): EdkLogger.quiet("%-16s =3D %s" % ("WORKSPACE", os.environ["WORKSPA= CE"])) if "PACKAGES_PATH" in os.environ: # WORKSPACE env has been converted before. Print the same path= style with WORKSPACE env. - EdkLogger.quiet("%-16s =3D %s" % ("PACKAGES_PATH", os.path.nor= mcase(os.path.normpath(os.environ["PACKAGES_PATH"])))) - EdkLogger.quiet("%-16s =3D %s" % ("EDK_TOOLS_PATH", os.environ["ED= K_TOOLS_PATH"])) + EdkLogger.quiet("%-16s =3D %s" % ("PACKAGES_PATH", + os.path.normcase(os.path.normpath(os.environ["= PACKAGES_PATH"])))) + EdkLogger.quiet("%-16s =3D %s" % + ("EDK_TOOLS_PATH", os.environ["EDK_TOOLS_PATH"])) if "EDK_TOOLS_BIN" in os.environ: # Print the same path style with WORKSPACE env. - EdkLogger.quiet("%-16s =3D %s" % ("EDK_TOOLS_BIN", os.path.nor= mcase(os.path.normpath(os.environ["EDK_TOOLS_BIN"])))) - EdkLogger.quiet("%-16s =3D %s" % ("CONF_PATH", GlobalData.gConfDir= ectory)) + EdkLogger.quiet("%-16s =3D %s" % ("EDK_TOOLS_BIN", + os.path.normcase(os.path.normpath(os.environ["= EDK_TOOLS_BIN"])))) + EdkLogger.quiet("%-16s =3D %s" % + ("CONF_PATH", GlobalData.gConfDirectory)) if "PYTHON3_ENABLE" in os.environ: PYTHON3_ENABLE =3D os.environ["PYTHON3_ENABLE"] if PYTHON3_ENABLE !=3D "TRUE": PYTHON3_ENABLE =3D "FALSE" EdkLogger.quiet("%-16s =3D %s" % ("PYTHON3_ENABLE", PYTHON3_EN= ABLE)) if "PYTHON_COMMAND" in os.environ: - EdkLogger.quiet("%-16s =3D %s" % ("PYTHON_COMMAND", os.environ= ["PYTHON_COMMAND"])) + EdkLogger.quiet("%-16s =3D %s" % + ("PYTHON_COMMAND", os.environ["PYTHON_COMMAND"= ])) self.InitPreBuild() self.InitPostBuild() if self.Prebuild: @@ -821,7 +881,8 @@ class Build(): if self.Prebuild: self.LaunchPrebuild() TargetObj =3D TargetTxtDict() - ToolDefObj =3D ToolDefDict((os.path.join(os.getenv("WORKSPACE"= ), "Conf"))) + ToolDefObj =3D ToolDefDict( + (os.path.join(os.getenv("WORKSPACE"), "Conf"))) self.TargetTxt =3D TargetObj.Target self.ToolDef =3D ToolDefObj.ToolDef if not (self.LaunchPrebuildFlag and os.path.exists(self.PlatformBu= ildPath)): @@ -831,7 +892,7 @@ class Build(): EdkLogger.info("") os.chdir(self.WorkspaceDir) self.log_q =3D log_q - GlobalData.file_lock =3D mp.Lock() + GlobalData.file_lock =3D mp.Lock() # Init cache data for local only GlobalData.gPackageHashFile =3D dict() GlobalData.gModulePreMakeCacheStatus =3D dict() @@ -843,18 +904,20 @@ class Build(): GlobalData.gModuleAllCacheStatus =3D set() GlobalData.gModuleCacheHit =3D set() =20 - def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,cqueue): + def StartAutoGen(self, mqueue, DataPipe, SkipAutoGen, PcdMaList, cqueu= e): try: if SkipAutoGen: - return True,0 + return True, 0 feedback_q =3D mp.Queue() error_event =3D mp.Event() FfsCmd =3D DataPipe.Get("FfsCommand") if FfsCmd is None: FfsCmd =3D {} GlobalData.FfsCmd =3D FfsCmd - auto_workers =3D [AutoGenWorkerInProcess(mqueue,DataPipe.dump_= file,feedback_q,GlobalData.file_lock,cqueue,self.log_q,error_event) for _ i= n range(self.ThreadNumber)] - self.AutoGenMgr =3D AutoGenManager(auto_workers,feedback_q,err= or_event) + auto_workers =3D [AutoGenWorkerInProcess( + mqueue, DataPipe.dump_file, feedback_q, GlobalData.file_lo= ck, cqueue, self.log_q, error_event) for _ in range(self.ThreadNumber)] + self.AutoGenMgr =3D AutoGenManager( + auto_workers, feedback_q, error_event) self.AutoGenMgr.start() for w in auto_workers: w.start() @@ -866,14 +929,17 @@ class Build(): RetVal =3D PcdMa.SourceFileList # Force cache miss for PCD driver if GlobalData.gUseHashCache and not GlobalData.gBinCac= heDest and self.Target in [None, "", "all"]: - cqueue.put((PcdMa.MetaFile.Path, PcdMa.Arch, "PreM= akeCache", False)) + cqueue.put( + (PcdMa.MetaFile.Path, PcdMa.Arch, "PreMakeCach= e", False)) =20 PcdMa.CreateCodeFile(False) - PcdMa.CreateMakeFile(False,GenFfsList =3D DataPipe.Get= ("FfsCommand").get((PcdMa.MetaFile.Path, PcdMa.Arch),[])) + PcdMa.CreateMakeFile(False, GenFfsList=3DDataPipe.Get( + "FfsCommand").get((PcdMa.MetaFile.Path, PcdMa.Arch= ), [])) PcdMa.CreateAsBuiltInf() # Force cache miss for PCD driver if GlobalData.gBinCacheSource and self.Target in [None= , "", "all"]: - cqueue.put((PcdMa.MetaFile.Path, PcdMa.Arch, "Make= Cache", False)) + cqueue.put( + (PcdMa.MetaFile.Path, PcdMa.Arch, "MakeCache",= False)) =20 self.AutoGenMgr.join() rt =3D self.AutoGenMgr.Status @@ -886,50 +952,56 @@ class Build(): except: return False, UNKNOWN_ERROR =20 - ## Add TOOLCHAIN and FAMILY declared in DSC [BuildOptions] to ToolsDef= TxtDatabase. + # Add TOOLCHAIN and FAMILY declared in DSC [BuildOptions] to ToolsDefT= xtDatabase. # # Loop through the set of build targets, tool chains, and archs provid= ed on either # the command line or in target.txt to discover FAMILY and TOOLCHAIN d= elclarations # in [BuildOptions] sections that may be within !if expressions that m= ay use # $(TARGET), $(TOOLCHAIN), $(TOOLCHAIN_TAG), or $(ARCH) operands. # - def GetToolChainAndFamilyFromDsc (self, File): + def GetToolChainAndFamilyFromDsc(self, File): SavedGlobalDefines =3D GlobalData.gGlobalDefines.copy() for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] =3D BuildTarget for BuildToolChain in self.ToolChainList: - GlobalData.gGlobalDefines['TOOLCHAIN'] =3D BuildToolC= hain + GlobalData.gGlobalDefines['TOOLCHAIN'] =3D BuildToolChain GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] =3D BuildToolC= hain for BuildArch in self.ArchList: GlobalData.gGlobalDefines['ARCH'] =3D BuildArch dscobj =3D self.BuildDatabase[File, BuildArch] for KeyFamily, Key, KeyCodeBase in dscobj.BuildOptions: try: - Target, ToolChain, Arch, Tool, Attr =3D Key.sp= lit('_') + Target, ToolChain, Arch, Tool, Attr =3D Key.sp= lit( + '_') except: continue if ToolChain =3D=3D TAB_STAR or Attr !=3D TAB_TOD_= DEFINES_FAMILY: continue try: - Family =3D dscobj.BuildOptions[(KeyFamily, Key= , KeyCodeBase)] + Family =3D dscobj.BuildOptions[( + KeyFamily, Key, KeyCodeBase)] Family =3D Family.strip().strip('=3D').strip() except: continue if TAB_TOD_DEFINES_FAMILY not in self.ToolDef.Tool= sDefTxtDatabase: - self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_FAMILY] =3D {} + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_FAMILY] =3D { + } if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_FAMILY]: self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_FAMILY][ToolChain] =3D Family if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.Too= lDef.ToolsDefTxtDatabase: - self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_BUILDRULEFAMILY] =3D {} + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_BUILDRULEFAMILY] =3D { + } if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_BUILDRULEFAMILY]: self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_BUILDRULEFAMILY][ToolChain] =3D Family if TAB_TOD_DEFINES_TOOL_CHAIN_TAG not in self.Tool= Def.ToolsDefTxtDatabase: - self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_TOOL_CHAIN_TAG] =3D [] + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_TOOL_CHAIN_TAG] =3D [ + ] if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_TOOL_CHAIN_TAG]: - self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_TOOL_CHAIN_TAG].append(ToolChain) + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_TOOL_CHAIN_TAG].append( + ToolChain) GlobalData.gGlobalDefines =3D SavedGlobalDefines =20 - ## Load configuration + # Load configuration # # This method will parse target.txt and get the build configurations. # @@ -948,14 +1020,16 @@ class Build(): if not self.ToolChainList: self.ToolChainList =3D self.TargetTxt.TargetTxtDictionary[TAB_= TAT_DEFINES_TOOL_CHAIN_TAG] if self.ToolChainList is None or len(self.ToolChainList) =3D= =3D 0: - EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData= =3D"No toolchain given. Don't know how to build.\n") + EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, + ExtraData=3D"No toolchain given. Don't kno= w how to build.\n") =20 if not self.PlatformFile: PlatformFile =3D self.TargetTxt.TargetTxtDictionary[TAB_TAT_DE= FINES_ACTIVE_PLATFORM] if not PlatformFile: # Try to find one in current directory WorkingDirectory =3D os.getcwd() - FileList =3D glob.glob(os.path.normpath(os.path.join(Worki= ngDirectory, '*.dsc'))) + FileList =3D glob.glob(os.path.normpath( + os.path.join(WorkingDirectory, '*.dsc'))) FileNum =3D len(FileList) if FileNum >=3D 2: EdkLogger.error("build", OPTION_MISSING, @@ -966,15 +1040,17 @@ class Build(): EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData=3D"No active platform specif= ied in target.txt or command line! Nothing can be built.\n") =20 - self.PlatformFile =3D PathClass(NormFile(PlatformFile, self.Wo= rkspaceDir), self.WorkspaceDir) + self.PlatformFile =3D PathClass( + NormFile(PlatformFile, self.WorkspaceDir), self.WorkspaceD= ir) =20 - self.GetToolChainAndFamilyFromDsc (self.PlatformFile) + self.GetToolChainAndFamilyFromDsc(self.PlatformFile) =20 # check if the tool chains are defined or not NewToolChainList =3D [] for ToolChain in self.ToolChainList: if ToolChain not in self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_D= EFINES_TOOL_CHAIN_TAG]: - EdkLogger.warn("build", "Tool chain [%s] is not defined" %= ToolChain) + EdkLogger.warn( + "build", "Tool chain [%s] is not defined" % ToolChain) else: NewToolChainList.append(ToolChain) # if no tool chain available, break the build @@ -989,18 +1065,21 @@ class Build(): for Tool in self.ToolChainList: if TAB_TOD_DEFINES_FAMILY not in ToolDefinition or Tool not in= ToolDefinition[TAB_TOD_DEFINES_FAMILY] \ or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]: - EdkLogger.warn("build", "No tool chain family found in con= figuration for %s. Default to MSFT." % Tool) + EdkLogger.warn( + "build", "No tool chain family found in configuration = for %s. Default to MSFT." % Tool) ToolChainFamily.append(TAB_COMPILER_MSFT) else: - ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMI= LY][Tool]) + ToolChainFamily.append( + ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]) self.ToolChainFamily =3D ToolChainFamily =20 - self.ThreadNumber =3D ThreadNum() - ## Initialize build configuration + self.ThreadNumber =3D ThreadNum() + # Initialize build configuration # # This method will parse DSC file and merge the configurations from # command line and target.txt, then get the final build configuratio= ns. # + def InitBuild(self): # parse target.txt, tools_def.txt, and platform file self.LoadConfiguration() @@ -1010,7 +1089,6 @@ class Build(): if ErrorCode !=3D 0: EdkLogger.error("build", ErrorCode, ExtraData=3DErrorInfo) =20 - def InitPreBuild(self): self.LoadConfiguration() ErrorCode, ErrorInfo =3D self.PlatformFile.Validate(".dsc", False) @@ -1026,7 +1104,7 @@ class Build(): if self.ToolChainFamily: GlobalData.gGlobalDefines['FAMILY'] =3D self.ToolChainFamily[0] if 'PREBUILD' in GlobalData.gCommandLineDefines: - self.Prebuild =3D GlobalData.gCommandLineDefines.get('PREBUI= LD') + self.Prebuild =3D GlobalData.gCommandLineDefines.get('PREBUILD= ') else: self.Db_Flag =3D True Platform =3D self.Db.MapPlatform(str(self.PlatformFile)) @@ -1043,7 +1121,7 @@ class Build(): # # Do not modify Arg if it looks like a flag or an absolute= file path # - if Arg.startswith('-') or os.path.isabs(Arg): + if Arg.startswith('-') or os.path.isabs(Arg): PrebuildList.append(Arg) continue # @@ -1061,8 +1139,9 @@ class Build(): if os.path.isfile(Temp): Arg =3D Temp PrebuildList.append(Arg) - self.Prebuild =3D ' '.join(PrebuildList) - self.Prebuild +=3D self.PassCommandOption(self.BuildTargetList= , self.ArchList, self.ToolChainList, self.PlatformFile, self.Target) + self.Prebuild =3D ' '.join(PrebuildList) + self.Prebuild +=3D self.PassCommandOption( + self.BuildTargetList, self.ArchList, self.ToolChainList, s= elf.PlatformFile, self.Target) =20 def InitPostBuild(self): if 'POSTBUILD' in GlobalData.gCommandLineDefines: @@ -1082,7 +1161,7 @@ class Build(): # # Do not modify Arg if it looks like a flag or an absolute= file path # - if Arg.startswith('-') or os.path.isabs(Arg): + if Arg.startswith('-') or os.path.isabs(Arg): PostbuildList.append(Arg) continue # @@ -1100,8 +1179,9 @@ class Build(): if os.path.isfile(Temp): Arg =3D Temp PostbuildList.append(Arg) - self.Postbuild =3D ' '.join(PostbuildList) - self.Postbuild +=3D self.PassCommandOption(self.BuildTargetLis= t, self.ArchList, self.ToolChainList, self.PlatformFile, self.Target) + self.Postbuild =3D ' '.join(PostbuildList) + self.Postbuild +=3D self.PassCommandOption( + self.BuildTargetList, self.ArchList, self.ToolChainList, s= elf.PlatformFile, self.Target) =20 def PassCommandOption(self, BuildTarget, TargetArch, ToolChain, Platfo= rmFile, Target): BuildStr =3D '' @@ -1156,7 +1236,8 @@ class Build(): # and preserve them for the rest of the main build step, becau= se the child process environment will # evaporate as soon as it exits, we cannot get it in build ste= p. # - PrebuildEnvFile =3D os.path.join(GlobalData.gConfDirectory, '.= cache', '.PrebuildEnv') + PrebuildEnvFile =3D os.path.join( + GlobalData.gConfDirectory, '.cache', '.PrebuildEnv') if os.path.isfile(PrebuildEnvFile): os.remove(PrebuildEnvFile) if os.path.isfile(self.PlatformBuildPath): @@ -1172,13 +1253,15 @@ class Build(): EndOfProcedure =3D Event() EndOfProcedure.clear() if Process.stdout: - StdOutThread =3D Thread(target=3DReadMessage, args=3D(Proc= ess.stdout, EdkLogger.info, EndOfProcedure)) + StdOutThread =3D Thread(target=3DReadMessage, args=3D( + Process.stdout, EdkLogger.info, EndOfProcedure)) StdOutThread.name =3D "STDOUT-Redirector" StdOutThread.daemon =3D False StdOutThread.start() =20 if Process.stderr: - StdErrThread =3D Thread(target=3DReadMessage, args=3D(Proc= ess.stderr, EdkLogger.quiet, EndOfProcedure)) + StdErrThread =3D Thread(target=3DReadMessage, args=3D( + Process.stderr, EdkLogger.quiet, EndOfProcedure)) StdErrThread.name =3D "STDERR-Redirector" StdErrThread.daemon =3D False StdErrThread.start() @@ -1189,15 +1272,17 @@ class Build(): StdOutThread.join() if Process.stderr: StdErrThread.join() - if Process.returncode !=3D 0 : - EdkLogger.error("Prebuild", PREBUILD_ERROR, 'Prebuild proc= ess is not success!') + if Process.returncode !=3D 0: + EdkLogger.error("Prebuild", PREBUILD_ERROR, + 'Prebuild process is not success!') =20 if os.path.exists(PrebuildEnvFile): f =3D open(PrebuildEnvFile) envs =3D f.readlines() f.close() - envs =3D [l.split("=3D", 1) for l in envs ] - envs =3D [[I.strip() for I in item] for item in envs if le= n(item) =3D=3D 2] + envs =3D [l.split("=3D", 1) for l in envs] + envs =3D [[I.strip() for I in item] + for item in envs if len(item) =3D=3D 2] os.environ.update(dict(envs)) EdkLogger.info("\n- Prebuild Done -\n") =20 @@ -1205,20 +1290,24 @@ class Build(): if self.Postbuild: EdkLogger.info("\n- Postbuild Start -\n") if sys.platform =3D=3D "win32": - Process =3D Popen(self.Postbuild, stdout=3DPIPE, stderr=3D= PIPE, shell=3DTrue) + Process =3D Popen(self.Postbuild, stdout=3DPIPE, + stderr=3DPIPE, shell=3DTrue) else: - Process =3D Popen(self.Postbuild, stdout=3DPIPE, stderr=3D= PIPE, shell=3DTrue) + Process =3D Popen(self.Postbuild, stdout=3DPIPE, + stderr=3DPIPE, shell=3DTrue) # launch two threads to read the STDOUT and STDERR EndOfProcedure =3D Event() EndOfProcedure.clear() if Process.stdout: - StdOutThread =3D Thread(target=3DReadMessage, args=3D(Proc= ess.stdout, EdkLogger.info, EndOfProcedure)) + StdOutThread =3D Thread(target=3DReadMessage, args=3D( + Process.stdout, EdkLogger.info, EndOfProcedure)) StdOutThread.name =3D "STDOUT-Redirector" StdOutThread.daemon =3D False StdOutThread.start() =20 if Process.stderr: - StdErrThread =3D Thread(target=3DReadMessage, args=3D(Proc= ess.stderr, EdkLogger.quiet, EndOfProcedure)) + StdErrThread =3D Thread(target=3DReadMessage, args=3D( + Process.stderr, EdkLogger.quiet, EndOfProcedure)) StdErrThread.name =3D "STDERR-Redirector" StdErrThread.daemon =3D False StdErrThread.start() @@ -1229,11 +1318,12 @@ class Build(): StdOutThread.join() if Process.stderr: StdErrThread.join() - if Process.returncode !=3D 0 : - EdkLogger.error("Postbuild", POSTBUILD_ERROR, 'Postbuild p= rocess is not success!') + if Process.returncode !=3D 0: + EdkLogger.error("Postbuild", POSTBUILD_ERROR, + 'Postbuild process is not success!') EdkLogger.info("\n- Postbuild Done -\n") =20 - ## Build a module or platform + # Build a module or platform # # Create autogen code and makefile for a module or platform, and the l= aunch # "make" command to build it @@ -1260,21 +1350,30 @@ class Build(): mqueue =3D mp.Queue() for m in AutoGenObject.GetAllModuleInfo: mqueue.put(m) - mqueue.put((None,None,None,None,None,None,None)) - AutoGenObject.DataPipe.DataContainer =3D {"CommandTarget": sel= f.Target} - AutoGenObject.DataPipe.DataContainer =3D {"Workspace_timestamp= ": AutoGenObject.Workspace._SrcTimeStamp} + mqueue.put((None, None, None, None, None, None, None)) + AutoGenObject.DataPipe.DataContainer =3D { + "CommandTarget": self.Target} + AutoGenObject.DataPipe.DataContainer =3D { + "Workspace_timestamp": AutoGenObject.Workspace._SrcTimeSta= mp} AutoGenObject.CreateLibModuelDirs() - AutoGenObject.DataPipe.DataContainer =3D {"LibraryBuildDirecto= ryList":AutoGenObject.LibraryBuildDirectoryList} - AutoGenObject.DataPipe.DataContainer =3D {"ModuleBuildDirector= yList":AutoGenObject.ModuleBuildDirectoryList} - AutoGenObject.DataPipe.DataContainer =3D {"FdsCommandDict": Au= toGenObject.Workspace.GenFdsCommandDict} + AutoGenObject.DataPipe.DataContainer =3D { + "LibraryBuildDirectoryList": AutoGenObject.LibraryBuildDir= ectoryList} + AutoGenObject.DataPipe.DataContainer =3D { + "ModuleBuildDirectoryList": AutoGenObject.ModuleBuildDirec= toryList} + AutoGenObject.DataPipe.DataContainer =3D { + "FdsCommandDict": AutoGenObject.Workspace.GenFdsCommandDic= t} self.Progress.Start("Generating makefile and code") - data_pipe_file =3D os.path.join(AutoGenObject.BuildDir, "Globa= lVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch)) + data_pipe_file =3D os.path.join(AutoGenObject.BuildDir, "Globa= lVar_%s_%s.bin" % ( + str(AutoGenObject.Guid), AutoGenObject.Arch)) AutoGenObject.DataPipe.dump(data_pipe_file) cqueue =3D mp.Queue() - autogen_rt,errorcode =3D self.StartAutoGen(mqueue, AutoGenObje= ct.DataPipe, self.SkipAutoGen, PcdMaList, cqueue) - AutoGenIdFile =3D os.path.join(GlobalData.gConfDirectory,".Aut= oGenIdFile.txt") - with open(AutoGenIdFile,"w") as fw: - fw.write("Arch=3D%s\n" % "|".join((AutoGenObject.Workspace= .ArchList))) + autogen_rt, errorcode =3D self.StartAutoGen( + mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaLis= t, cqueue) + AutoGenIdFile =3D os.path.join( + GlobalData.gConfDirectory, ".AutoGenIdFile.txt") + with open(AutoGenIdFile, "w") as fw: + fw.write("Arch=3D%s\n" % "|".join( + (AutoGenObject.Workspace.ArchList))) fw.write("BuildDir=3D%s\n" % AutoGenObject.Workspace.Build= Dir) fw.write("PlatformGuid=3D%s\n" % str(AutoGenObject.Guid)) self.Progress.Stop("done!") @@ -1297,7 +1396,8 @@ class Build(): EdkLogger.error("build", OPTION_MISSING, "No build command found for this module. " "Please check your setting of %s_%s_%s_MAKE_PA= TH in Conf/tools_def.txt file." % - (AutoGenObject.BuildTarget, AutoGenObject.= ToolChain, AutoGenObject.Arch), + (AutoGenObject.BuildTarget, + AutoGenObject.ToolChain, AutoGenObject.Arch), ExtraData=3Dstr(AutoGenObject)) =20 # run @@ -1325,10 +1425,14 @@ class Build(): DirList =3D [] for Lib in AutoGenObject.LibraryAutoGenList: if not Lib.IsBinaryModule: - DirList.append((os.path.join(AutoGenObject.BuildDir, L= ib.BuildDir),Lib)) + DirList.append( + (os.path.join(AutoGenObject.BuildDir, Lib.BuildDir= ), Lib)) for Lib, LibAutoGen in DirList: - NewBuildCommand =3D BuildCommand + ['-f', os.path.normpath= (os.path.join(Lib, self.MakeFileName)), 'pbuild'] - LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,L= ibAutoGen) + NewBuildCommand =3D BuildCommand + \ + ['-f', os.path.normpath(os.path.join(Lib, + self.MakeFileName)), 'pbuild'] + LaunchCommand(NewBuildCommand, + AutoGenObject.MakeFileDir, LibAutoGen) return True =20 # build module @@ -1336,18 +1440,26 @@ class Build(): DirList =3D [] for Lib in AutoGenObject.LibraryAutoGenList: if not Lib.IsBinaryModule: - DirList.append((os.path.join(AutoGenObject.BuildDir, L= ib.BuildDir),Lib)) + DirList.append( + (os.path.join(AutoGenObject.BuildDir, Lib.BuildDir= ), Lib)) for Lib, LibAutoGen in DirList: - NewBuildCommand =3D BuildCommand + ['-f', os.path.normpath= (os.path.join(Lib, self.MakeFileName)), 'pbuild'] - LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,L= ibAutoGen) + NewBuildCommand =3D BuildCommand + \ + ['-f', os.path.normpath(os.path.join(Lib, + self.MakeFileName)), 'pbuild'] + LaunchCommand(NewBuildCommand, + AutoGenObject.MakeFileDir, LibAutoGen) =20 DirList =3D [] for ModuleAutoGen in AutoGenObject.ModuleAutoGenList: if not ModuleAutoGen.IsBinaryModule: - DirList.append((os.path.join(AutoGenObject.BuildDir, M= oduleAutoGen.BuildDir),ModuleAutoGen)) - for Mod,ModAutoGen in DirList: - NewBuildCommand =3D BuildCommand + ['-f', os.path.normpath= (os.path.join(Mod, self.MakeFileName)), 'pbuild'] - LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir,M= odAutoGen) + DirList.append( + (os.path.join(AutoGenObject.BuildDir, ModuleAutoGe= n.BuildDir), ModuleAutoGen)) + for Mod, ModAutoGen in DirList: + NewBuildCommand =3D BuildCommand + \ + ['-f', os.path.normpath(os.path.join(Mod, + self.MakeFileName)), 'pbuild'] + LaunchCommand(NewBuildCommand, + AutoGenObject.MakeFileDir, ModAutoGen) self.CreateAsBuiltInf() if GlobalData.gBinCacheDest: self.GenDestCache() @@ -1361,36 +1473,42 @@ class Build(): # cleanlib if Target =3D=3D 'cleanlib': for Lib in AutoGenObject.LibraryBuildDirectoryList: - LibMakefile =3D os.path.normpath(os.path.join(Lib, self.Ma= keFileName)) + LibMakefile =3D os.path.normpath( + os.path.join(Lib, self.MakeFileName)) if os.path.exists(LibMakefile): - NewBuildCommand =3D BuildCommand + ['-f', LibMakefile,= 'cleanall'] + NewBuildCommand =3D BuildCommand + \ + ['-f', LibMakefile, 'cleanall'] LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileD= ir) return True =20 # clean if Target =3D=3D 'clean': for Mod in AutoGenObject.ModuleBuildDirectoryList: - ModMakefile =3D os.path.normpath(os.path.join(Mod, self.Ma= keFileName)) + ModMakefile =3D os.path.normpath( + os.path.join(Mod, self.MakeFileName)) if os.path.exists(ModMakefile): - NewBuildCommand =3D BuildCommand + ['-f', ModMakefile,= 'cleanall'] + NewBuildCommand =3D BuildCommand + \ + ['-f', ModMakefile, 'cleanall'] LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileD= ir) for Lib in AutoGenObject.LibraryBuildDirectoryList: - LibMakefile =3D os.path.normpath(os.path.join(Lib, self.Ma= keFileName)) + LibMakefile =3D os.path.normpath( + os.path.join(Lib, self.MakeFileName)) if os.path.exists(LibMakefile): - NewBuildCommand =3D BuildCommand + ['-f', LibMakefile,= 'cleanall'] + NewBuildCommand =3D BuildCommand + \ + ['-f', LibMakefile, 'cleanall'] LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileD= ir) return True =20 # cleanall if Target =3D=3D 'cleanall': try: - #os.rmdir(AutoGenObject.BuildDir) + # os.rmdir(AutoGenObject.BuildDir) RemoveDirectory(AutoGenObject.BuildDir, True) except WindowsError as X: EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=3D= str(X)) return True =20 - ## Build a module or platform + # Build a module or platform # # Create autogen code and makefile for a module or platform, and the l= aunch # "make" command to build it @@ -1423,7 +1541,7 @@ class Build(): if not self.SkipAutoGen or Target =3D=3D 'genmake': self.Progress.Start("Generating makefile") AutoGenObject.CreateMakeFile(CreateDepsMakeFile) - #AutoGenObject.CreateAsBuiltInf() + # AutoGenObject.CreateAsBuiltInf() self.Progress.Stop("done!") if Target =3D=3D "genmake": return True @@ -1440,14 +1558,16 @@ class Build(): EdkLogger.error("build", OPTION_MISSING, "No build command found for this module. " "Please check your setting of %s_%s_%s_MAKE_PA= TH in Conf/tools_def.txt file." % - (AutoGenObject.BuildTarget, AutoGenObject.= ToolChain, AutoGenObject.Arch), + (AutoGenObject.BuildTarget, + AutoGenObject.ToolChain, AutoGenObject.Arch), ExtraData=3Dstr(AutoGenObject)) =20 # build modules if BuildModule: if Target !=3D 'fds': BuildCommand =3D BuildCommand + [Target] - AutoGenObject.BuildTime =3D LaunchCommand(BuildCommand, AutoGe= nObject.MakeFileDir) + AutoGenObject.BuildTime =3D LaunchCommand( + BuildCommand, AutoGenObject.MakeFileDir) self.CreateAsBuiltInf() if GlobalData.gBinCacheDest: self.GenDestCache() @@ -1477,42 +1597,46 @@ class Build(): =20 # not build modules =20 - # cleanall if Target =3D=3D 'cleanall': try: - #os.rmdir(AutoGenObject.BuildDir) + # os.rmdir(AutoGenObject.BuildDir) RemoveDirectory(AutoGenObject.BuildDir, True) except WindowsError as X: EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=3D= str(X)) return True =20 - ## Rebase module image and Get function address for the input module l= ist. + # Rebase module image and Get function address for the input module li= st. # - def _RebaseModule (self, MapBuffer, BaseAddress, ModuleList, AddrIsOff= set =3D True, ModeIsSmm =3D False): + def _RebaseModule(self, MapBuffer, BaseAddress, ModuleList, AddrIsOffs= et=3DTrue, ModeIsSmm=3DFalse): if ModeIsSmm: AddrIsOffset =3D False for InfFile in ModuleList: - sys.stdout.write (".") + sys.stdout.write(".") sys.stdout.flush() ModuleInfo =3D ModuleList[InfFile] ModuleName =3D ModuleInfo.BaseName ModuleOutputImage =3D ModuleInfo.Image.FileName - ModuleDebugImage =3D os.path.join(ModuleInfo.DebugDir, Module= Info.BaseName + '.efi') - ## for SMM module in SMRAM, the SMRAM will be allocated from b= ase to top. + ModuleDebugImage =3D os.path.join( + ModuleInfo.DebugDir, ModuleInfo.BaseName + '.efi') + # for SMM module in SMRAM, the SMRAM will be allocated from ba= se to top. if not ModeIsSmm: BaseAddress =3D BaseAddress - ModuleInfo.Image.Size # # Update Image to new BaseAddress by GenFw tool # - LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r"= , ModuleOutputImage], ModuleInfo.OutputDir) - LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r"= , ModuleDebugImage], ModuleInfo.DebugDir) + LaunchCommand(["GenFw", "--rebase", str(BaseAddress), + "-r", ModuleOutputImage], ModuleInfo.OutputD= ir) + LaunchCommand(["GenFw", "--rebase", str(BaseAddress), + "-r", ModuleDebugImage], ModuleInfo.DebugDir) else: # # Set new address to the section header only for SMM drive= r. # - LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r= ", ModuleOutputImage], ModuleInfo.OutputDir) - LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r= ", ModuleDebugImage], ModuleInfo.DebugDir) + LaunchCommand(["GenFw", "--address", str(BaseAddress), + "-r", ModuleOutputImage], ModuleInfo.OutputD= ir) + LaunchCommand(["GenFw", "--address", str(BaseAddress), + "-r", ModuleDebugImage], ModuleInfo.DebugDir) # # Collect function address from Map file # @@ -1522,32 +1646,37 @@ class Build(): OrigImageBaseAddress =3D 0 ImageMap =3D open(ImageMapTable, 'r') for LinStr in ImageMap: - if len (LinStr.strip()) =3D=3D 0: + if len(LinStr.strip()) =3D=3D 0: continue # # Get the preferred address set on link time. # - if LinStr.find ('Preferred load address is') !=3D -1: + if LinStr.find('Preferred load address is') !=3D -1: StrList =3D LinStr.split() - OrigImageBaseAddress =3D int (StrList[len(StrList)= - 1], 16) + OrigImageBaseAddress =3D int( + StrList[len(StrList) - 1], 16) =20 StrList =3D LinStr.split() - if len (StrList) > 4: + if len(StrList) > 4: if StrList[3] =3D=3D 'f' or StrList[3] =3D=3D 'F': Name =3D StrList[1] - RelativeAddress =3D int (StrList[2], 16) - Ori= gImageBaseAddress - FunctionList.append ((Name, RelativeAddress)) + RelativeAddress =3D int( + StrList[2], 16) - OrigImageBaseAddress + FunctionList.append((Name, RelativeAddress)) =20 ImageMap.close() # # Add general information. # if ModeIsSmm: - MapBuffer.append('\n\n%s (Fixed SMRAM Offset, BaseAddres= s=3D0x%010X, EntryPoint=3D0x%010X)\n' % (ModuleName, BaseAddress, BaseAddr= ess + ModuleInfo.Image.EntryPoint)) + MapBuffer.append('\n\n%s (Fixed SMRAM Offset, BaseAddres= s=3D0x%010X, EntryPoint=3D0x%010X)\n' % ( + ModuleName, BaseAddress, BaseAddress + ModuleInfo.Imag= e.EntryPoint)) elif AddrIsOffset: - MapBuffer.append('\n\n%s (Fixed Memory Offset, BaseAddres= s=3D-0x%010X, EntryPoint=3D-0x%010X)\n' % (ModuleName, 0 - BaseAddress, 0 -= (BaseAddress + ModuleInfo.Image.EntryPoint))) + MapBuffer.append('\n\n%s (Fixed Memory Offset, BaseAddres= s=3D-0x%010X, EntryPoint=3D-0x%010X)\n' % + (ModuleName, 0 - BaseAddress, 0 - (BaseAd= dress + ModuleInfo.Image.EntryPoint))) else: - MapBuffer.append('\n\n%s (Fixed Memory Address, BaseAddres= s=3D0x%010X, EntryPoint=3D0x%010X)\n' % (ModuleName, BaseAddress, BaseAddr= ess + ModuleInfo.Image.EntryPoint)) + MapBuffer.append('\n\n%s (Fixed Memory Address, BaseAddres= s=3D0x%010X, EntryPoint=3D0x%010X)\n' % ( + ModuleName, BaseAddress, BaseAddress + ModuleInfo.Imag= e.EntryPoint)) # # Add guid and general seciton section. # @@ -1559,9 +1688,11 @@ class Build(): elif SectionHeader[0] in ['.data', '.sdata']: DataSectionAddress =3D SectionHeader[1] if AddrIsOffset: - MapBuffer.append('(GUID=3D%s, .textbaseaddress=3D-0x%010X,= .databaseaddress=3D-0x%010X)\n' % (ModuleInfo.Guid, 0 - (BaseAddress + Tex= tSectionAddress), 0 - (BaseAddress + DataSectionAddress))) + MapBuffer.append('(GUID=3D%s, .textbaseaddress=3D-0x%010X,= .databaseaddress=3D-0x%010X)\n' % ( + ModuleInfo.Guid, 0 - (BaseAddress + TextSectionAddress= ), 0 - (BaseAddress + DataSectionAddress))) else: - MapBuffer.append('(GUID=3D%s, .textbaseaddress=3D0x%010X, = .databaseaddress=3D0x%010X)\n' % (ModuleInfo.Guid, BaseAddress + TextSectio= nAddress, BaseAddress + DataSectionAddress)) + MapBuffer.append('(GUID=3D%s, .textbaseaddress=3D0x%010X, = .databaseaddress=3D0x%010X)\n' % ( + ModuleInfo.Guid, BaseAddress + TextSectionAddress, Bas= eAddress + DataSectionAddress)) # # Add debug image full path. # @@ -1571,9 +1702,11 @@ class Build(): # for Function in FunctionList: if AddrIsOffset: - MapBuffer.append(' -0x%010X %s\n' % (0 - (BaseAddr= ess + Function[1]), Function[0])) + MapBuffer.append(' -0x%010X %s\n' % + (0 - (BaseAddress + Function[1]), Fun= ction[0])) else: - MapBuffer.append(' 0x%010X %s\n' % (BaseAddress + = Function[1], Function[0])) + MapBuffer.append(' 0x%010X %s\n' % + (BaseAddress + Function[1], Function[= 0])) ImageMap.close() =20 # @@ -1582,9 +1715,9 @@ class Build(): if ModeIsSmm: BaseAddress =3D BaseAddress + ModuleInfo.Image.Size =20 - ## Collect MAP information of all FVs + # Collect MAP information of all FVs # - def _CollectFvMapBuffer (self, MapBuffer, Wa, ModuleList): + def _CollectFvMapBuffer(self, MapBuffer, Wa, ModuleList): if self.Fdf: # First get the XIP base address for FV map file. GuidPattern =3D re.compile("[-a-fA-F0-9]+") @@ -1594,7 +1727,7 @@ class Build(): if not os.path.exists(FvMapBuffer): continue FvMap =3D open(FvMapBuffer, 'r') - #skip FV size information + # skip FV size information FvMap.readline() FvMap.readline() FvMap.readline() @@ -1607,7 +1740,8 @@ class Build(): # GuidString =3D MatchGuid.group() if GuidString.upper() in ModuleList: - Line =3D Line.replace(GuidString, ModuleList[G= uidString.upper()].Name) + Line =3D Line.replace( + GuidString, ModuleList[GuidString.upper()]= .Name) MapBuffer.append(Line) # # Add the debug image full path. @@ -1616,28 +1750,30 @@ class Build(): if MatchGuid is not None: GuidString =3D MatchGuid.group().split("=3D")[1] if GuidString.upper() in ModuleList: - MapBuffer.append('(IMAGE=3D%s)\n' % (os.path.j= oin(ModuleList[GuidString.upper()].DebugDir, ModuleList[GuidString.upper()]= .Name + '.efi'))) + MapBuffer.append('(IMAGE=3D%s)\n' % (os.path.j= oin(ModuleList[GuidString.upper( + )].DebugDir, ModuleList[GuidString.upper()].Na= me + '.efi'))) =20 FvMap.close() =20 - ## Collect MAP information of all modules + # Collect MAP information of all modules # - def _CollectModuleMapBuffer (self, MapBuffer, ModuleList): - sys.stdout.write ("Generate Load Module At Fix Address Map") + def _CollectModuleMapBuffer(self, MapBuffer, ModuleList): + sys.stdout.write("Generate Load Module At Fix Address Map") sys.stdout.flush() PatchEfiImageList =3D [] - PeiModuleList =3D {} - BtModuleList =3D {} - RtModuleList =3D {} - SmmModuleList =3D {} + PeiModuleList =3D {} + BtModuleList =3D {} + RtModuleList =3D {} + SmmModuleList =3D {} PeiSize =3D 0 - BtSize =3D 0 - RtSize =3D 0 + BtSize =3D 0 + RtSize =3D 0 # reserve 4K size in SMRAM to make SMM module address not from 0. SmmSize =3D 0x1000 for ModuleGuid in ModuleList: Module =3D ModuleList[ModuleGuid] - GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % (Module.Met= aFile, Module.Arch, Module.ToolChain, Module.BuildTarget) + GlobalData.gProcessingFile =3D "%s [%s, %s, %s]" % ( + Module.MetaFile, Module.Arch, Module.ToolChain, Module.Bui= ldTarget) =20 OutputImageFile =3D '' for ResultFile in Module.CodaTargetList: @@ -1645,11 +1781,14 @@ class Build(): # # module list for PEI, DXE, RUNTIME and SMM # - OutputImageFile =3D os.path.join(Module.OutputDir, Mod= ule.Name + '.efi') - ImageClass =3D PeImageClass (OutputImageFile) + OutputImageFile =3D os.path.join( + Module.OutputDir, Module.Name + '.efi') + ImageClass =3D PeImageClass(OutputImageFile) if not ImageClass.IsValid: - EdkLogger.error("build", FILE_PARSE_FAILURE, Extra= Data=3DImageClass.ErrorInfo) - ImageInfo =3D PeImageInfo(Module.Name, Module.Guid, Mo= dule.Arch, Module.OutputDir, Module.DebugDir, ImageClass) + EdkLogger.error("build", FILE_PARSE_FAILURE, + ExtraData=3DImageClass.ErrorInfo) + ImageInfo =3D PeImageInfo( + Module.Name, Module.Guid, Module.Arch, Module.Outp= utDir, Module.DebugDir, ImageClass) if Module.ModuleType in [SUP_MODULE_PEI_CORE, SUP_MODU= LE_PEIM, EDK_COMPONENT_TYPE_COMBINED_PEIM_DRIVER, EDK_COMPONENT_TYPE_PIC_PE= IM, EDK_COMPONENT_TYPE_RELOCATABLE_PEIM, SUP_MODULE_DXE_CORE]: PeiModuleList[Module.MetaFile] =3D ImageInfo PeiSize +=3D ImageInfo.Image.Size @@ -1663,7 +1802,8 @@ class Build(): SmmModuleList[Module.MetaFile] =3D ImageInfo SmmSize +=3D ImageInfo.Image.Size if Module.ModuleType =3D=3D SUP_MODULE_DXE_SMM_DRI= VER: - PiSpecVersion =3D Module.Module.Specification.= get('PI_SPECIFICATION_VERSION', '0x00000000') + PiSpecVersion =3D Module.Module.Specification.= get( + 'PI_SPECIFICATION_VERSION', '0x00000000') # for PI specification < PI1.1, DXE_SMM_DRIVER= also runs as BOOT time driver. if int(PiSpecVersion, 16) < 0x0001000A: BtModuleList[Module.MetaFile] =3D ImageInfo @@ -1691,7 +1831,7 @@ class Build(): # Module includes the patchable load fix address PCDs. # It will be fixed up later. # - PatchEfiImageList.append (OutputImageFile) + PatchEfiImageList.append(OutputImageFile) =20 # # Get Top Memory address @@ -1703,7 +1843,8 @@ class Build(): else: TopMemoryAddress =3D self.LoadFixAddress if TopMemoryAddress < RtSize + BtSize + PeiSize: - EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS is too low to load driver") + EdkLogger.error("build", PARAMETER_INVALID, + "FIX_LOAD_TOP_MEMORY_ADDRESS is too low to= load driver") =20 # # Patch FixAddress related PCDs into EFI image @@ -1722,37 +1863,50 @@ class Build(): for PcdInfo in PcdTable: ReturnValue =3D 0 if PcdInfo[0] =3D=3D TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_P= EI_PAGE_SIZE: - ReturnValue, ErrorInfo =3D PatchBinaryFile (EfiImage, = PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, st= r (PeiSize // 0x1000)) + ReturnValue, ErrorInfo =3D PatchBinaryFile( + EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_= ADDRESS_PEI_PAGE_SIZE_DATA_TYPE, str(PeiSize // 0x1000)) elif PcdInfo[0] =3D=3D TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS= _DXE_PAGE_SIZE: - ReturnValue, ErrorInfo =3D PatchBinaryFile (EfiImage, = PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, st= r (BtSize // 0x1000)) + ReturnValue, ErrorInfo =3D PatchBinaryFile( + EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_= ADDRESS_DXE_PAGE_SIZE_DATA_TYPE, str(BtSize // 0x1000)) elif PcdInfo[0] =3D=3D TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS= _RUNTIME_PAGE_SIZE: - ReturnValue, ErrorInfo =3D PatchBinaryFile (EfiImage, = PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE= , str (RtSize // 0x1000)) - elif PcdInfo[0] =3D=3D TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS= _SMM_PAGE_SIZE and len (SmmModuleList) > 0: - ReturnValue, ErrorInfo =3D PatchBinaryFile (EfiImage, = PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, st= r (SmmSize // 0x1000)) + ReturnValue, ErrorInfo =3D PatchBinaryFile( + EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_= ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE, str(RtSize // 0x1000)) + elif PcdInfo[0] =3D=3D TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS= _SMM_PAGE_SIZE and len(SmmModuleList) > 0: + ReturnValue, ErrorInfo =3D PatchBinaryFile( + EfiImage, PcdInfo[1], TAB_PCDS_PATCHABLE_LOAD_FIX_= ADDRESS_SMM_PAGE_SIZE_DATA_TYPE, str(SmmSize // 0x1000)) if ReturnValue !=3D 0: - EdkLogger.error("build", PARAMETER_INVALID, "Patch PCD= value failed", ExtraData=3DErrorInfo) + EdkLogger.error("build", PARAMETER_INVALID, + "Patch PCD value failed", ExtraData=3D= ErrorInfo) =20 - MapBuffer.append('PEI_CODE_PAGE_NUMBER =3D 0x%x\n' % (PeiSize= // 0x1000)) - MapBuffer.append('BOOT_CODE_PAGE_NUMBER =3D 0x%x\n' % (BtSize = // 0x1000)) - MapBuffer.append('RUNTIME_CODE_PAGE_NUMBER =3D 0x%x\n' % (RtSize = // 0x1000)) - if len (SmmModuleList) > 0: - MapBuffer.append('SMM_CODE_PAGE_NUMBER =3D 0x%x\n' % (Smm= Size // 0x1000)) + MapBuffer.append('PEI_CODE_PAGE_NUMBER =3D 0x%x\n' % + (PeiSize // 0x1000)) + MapBuffer.append('BOOT_CODE_PAGE_NUMBER =3D 0x%x\n' % + (BtSize // 0x1000)) + MapBuffer.append('RUNTIME_CODE_PAGE_NUMBER =3D 0x%x\n' % + (RtSize // 0x1000)) + if len(SmmModuleList) > 0: + MapBuffer.append('SMM_CODE_PAGE_NUMBER =3D 0x%x\n' % + (SmmSize // 0x1000)) =20 PeiBaseAddr =3D TopMemoryAddress - RtSize - BtSize - BtBaseAddr =3D TopMemoryAddress - RtSize - RtBaseAddr =3D TopMemoryAddress - ReservedRuntimeMemorySize + BtBaseAddr =3D TopMemoryAddress - RtSize + RtBaseAddr =3D TopMemoryAddress - ReservedRuntimeMemorySize =20 - self._RebaseModule (MapBuffer, PeiBaseAddr, PeiModuleList, TopMemo= ryAddress =3D=3D 0) - self._RebaseModule (MapBuffer, BtBaseAddr, BtModuleList, TopMemory= Address =3D=3D 0) - self._RebaseModule (MapBuffer, RtBaseAddr, RtModuleList, TopMemory= Address =3D=3D 0) - self._RebaseModule (MapBuffer, 0x1000, SmmModuleList, AddrIsOffset= =3DFalse, ModeIsSmm=3DTrue) + self._RebaseModule(MapBuffer, PeiBaseAddr, + PeiModuleList, TopMemoryAddress =3D=3D 0) + self._RebaseModule(MapBuffer, BtBaseAddr, + BtModuleList, TopMemoryAddress =3D=3D 0) + self._RebaseModule(MapBuffer, RtBaseAddr, + RtModuleList, TopMemoryAddress =3D=3D 0) + self._RebaseModule(MapBuffer, 0x1000, SmmModuleList, + AddrIsOffset=3DFalse, ModeIsSmm=3DTrue) MapBuffer.append('\n\n') - sys.stdout.write ("\n") + sys.stdout.write("\n") sys.stdout.flush() =20 - ## Save platform Map file + # Save platform Map file # - def _SaveMapFile (self, MapBuffer, Wa): + def _SaveMapFile(self, MapBuffer, Wa): # # Map file path is got. # @@ -1762,13 +1916,15 @@ class Build(): # SaveFileOnChange(MapFilePath, ''.join(MapBuffer), False) if self.LoadFixAddress !=3D 0: - sys.stdout.write ("\nLoad Module At Fix Address Map file can b= e found at %s\n" % (MapFilePath)) + sys.stdout.write( + "\nLoad Module At Fix Address Map file can be found at %s\= n" % (MapFilePath)) sys.stdout.flush() =20 - ## Build active platform for different build targets and different too= l chains + # Build active platform for different build targets and different tool= chains # def _BuildPlatform(self): - SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE a= uto-generated\n', False) + SaveFileOnChange(self.PlatformBuildPath, + '# DO NOT EDIT \n# FILE auto-generated\n', False) for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] =3D BuildTarget index =3D 0 @@ -1778,22 +1934,22 @@ class Build(): GlobalData.gGlobalDefines['FAMILY'] =3D self.ToolChainFami= ly[index] index +=3D 1 Wa =3D WorkspaceAutoGen( - self.WorkspaceDir, - self.PlatformFile, - BuildTarget, - ToolChain, - self.ArchList, - self.BuildDatabase, - self.TargetTxt, - self.ToolDef, - self.Fdf, - self.FdList, - self.FvList, - self.CapList, - self.SkuId, - self.UniFlag, - self.Progress - ) + self.WorkspaceDir, + self.PlatformFile, + BuildTarget, + ToolChain, + self.ArchList, + self.BuildDatabase, + self.TargetTxt, + self.ToolDef, + self.Fdf, + self.FdList, + self.FvList, + self.CapList, + self.SkuId, + self.UniFlag, + self.Progress + ) self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) @@ -1805,12 +1961,14 @@ class Build(): CmdListDict =3D self._GenFfsCmd(Wa.ArchList) =20 for Arch in Wa.ArchList: - PcdMaList =3D [] + PcdMaList =3D [] GlobalData.gGlobalDefines['ARCH'] =3D Arch - Pa =3D PlatformAutoGen(Wa, self.PlatformFile, BuildTar= get, ToolChain, Arch) + Pa =3D PlatformAutoGen( + Wa, self.PlatformFile, BuildTarget, ToolChain, Arc= h) for Module in Pa.Platform.Modules: # Get ModuleAutoGen object to generate C code file= and makefile - Ma =3D ModuleAutoGen(Wa, Module, BuildTarget, Tool= Chain, Arch, self.PlatformFile,Pa.DataPipe) + Ma =3D ModuleAutoGen( + Wa, Module, BuildTarget, ToolChain, Arch, self= .PlatformFile, Pa.DataPipe) if Ma is None: continue if Ma.PcdIsDriver: @@ -1818,9 +1976,11 @@ class Build(): Ma.Workspace =3D Wa PcdMaList.append(Ma) self.BuildModules.append(Ma) - Pa.DataPipe.DataContainer =3D {"FfsCommand":CmdListDic= t} - Pa.DataPipe.DataContainer =3D {"Workspace_timestamp": = Wa._SrcTimeStamp} - self._BuildPa(self.Target, Pa, FfsCommand=3DCmdListDic= t,PcdMaList=3DPcdMaList) + Pa.DataPipe.DataContainer =3D {"FfsCommand": CmdListDi= ct} + Pa.DataPipe.DataContainer =3D { + "Workspace_timestamp": Wa._SrcTimeStamp} + self._BuildPa(self.Target, Pa, + FfsCommand=3DCmdListDict, PcdMaList=3DPc= dMaList) =20 # Create MAP file when Load Fix Address is enabled. if self.Target in ["", "all", "fds"]: @@ -1830,7 +1990,8 @@ class Build(): # Check whether the set fix address is above 4G fo= r 32bit image. # if (Arch =3D=3D 'IA32' or Arch =3D=3D 'ARM') and s= elf.LoadFixAddress !=3D 0xFFFFFFFFFFFFFFFF and self.LoadFixAddress >=3D 0x1= 00000000: - EdkLogger.error("build", PARAMETER_INVALID, "F= IX_LOAD_TOP_MEMORY_ADDRESS can't be set to larger than or equal to 4G for t= he platform with IA32 or ARM arch modules") + EdkLogger.error( + "build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS can't be set to larger than or equal to 4G for the platform = with IA32 or ARM arch modules") # # Get Module List # @@ -1860,10 +2021,10 @@ class Build(): # # Save MAP buffer into MAP file. # - self._SaveMapFile (MapBuffer, Wa) + self._SaveMapFile(MapBuffer, Wa) self.CreateGuidedSectionToolsFile(Wa) =20 - ## Build active module for different build targets, different tool cha= ins and different archs + # Build active module for different build targets, different tool chai= ns and different archs # def _BuildModule(self): for BuildTarget in self.BuildTargetList: @@ -1880,23 +2041,23 @@ class Build(): # AutoGen first # Wa =3D WorkspaceAutoGen( - self.WorkspaceDir, - self.PlatformFile, - BuildTarget, - ToolChain, - self.ArchList, - self.BuildDatabase, - self.TargetTxt, - self.ToolDef, - self.Fdf, - self.FdList, - self.FvList, - self.CapList, - self.SkuId, - self.UniFlag, - self.Progress, - self.ModuleFile - ) + self.WorkspaceDir, + self.PlatformFile, + BuildTarget, + ToolChain, + self.ArchList, + self.BuildDatabase, + self.TargetTxt, + self.ToolDef, + self.Fdf, + self.FdList, + self.FvList, + self.CapList, + self.SkuId, + self.UniFlag, + self.Progress, + self.ModuleFile + ) self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress Wa.CreateMakeFile(False) @@ -1912,14 +2073,17 @@ class Build(): MaList =3D [] ExitFlag =3D threading.Event() ExitFlag.clear() - self.AutoGenTime +=3D int(round((time.time() - WorkspaceAu= toGenTime))) + self.AutoGenTime +=3D int(round((time.time() - + WorkspaceAutoGenTime))) for Arch in Wa.ArchList: AutoGenStart =3D time.time() GlobalData.gGlobalDefines['ARCH'] =3D Arch - Pa =3D PlatformAutoGen(Wa, self.PlatformFile, BuildTar= get, ToolChain, Arch) + Pa =3D PlatformAutoGen( + Wa, self.PlatformFile, BuildTarget, ToolChain, Arc= h) for Module in Pa.Platform.Modules: if self.ModuleFile.Dir =3D=3D Module.Dir and self.= ModuleFile.Name =3D=3D Module.Name: - Ma =3D ModuleAutoGen(Wa, Module, BuildTarget, = ToolChain, Arch, self.PlatformFile,Pa.DataPipe) + Ma =3D ModuleAutoGen( + Wa, Module, BuildTarget, ToolChain, Arch, = self.PlatformFile, Pa.DataPipe) if Ma is None: continue if Ma.PcdIsDriver: @@ -1945,7 +2109,8 @@ class Build(): if not self.SkipAutoGen or self.Target =3D= =3D 'genmake': self.Progress.Start("Generating makefi= le") if CmdListDict and self.Fdf and (Modul= e.Path, Arch) in CmdListDict: - Ma.CreateMakeFile(True, CmdListDic= t[Module.Path, Arch]) + Ma.CreateMakeFile( + True, CmdListDict[Module.Path,= Arch]) del CmdListDict[Module.Path, Arch] else: Ma.CreateMakeFile(True) @@ -1964,22 +2129,26 @@ class Build(): MakeStart =3D time.time() for Ma in self.BuildModules: if not Ma.IsBinaryModule: - Bt =3D BuildTask.New(ModuleMakeUnit(Ma, Pa.Bui= ldCommand,self.Target)) + Bt =3D BuildTask.New(ModuleMakeUnit( + Ma, Pa.BuildCommand, self.Target)) # Break build if any build thread has error if BuildTask.HasError(): # we need a full version of makefile for platf= orm ExitFlag.set() BuildTask.WaitForComplete() Pa.CreateMakeFile(False) - EdkLogger.error("build", BUILD_ERROR, "Failed = to build module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build mod= ule", ExtraData=3DGlobalData.gBuildingModule) # Start task scheduler if not BuildTask.IsOnGoing(): - BuildTask.StartScheduler(self.ThreadNumber, Ex= itFlag) + BuildTask.StartScheduler( + self.ThreadNumber, ExitFlag) =20 # in case there's an interruption. we need a full vers= ion of makefile for platform Pa.CreateMakeFile(False) if BuildTask.HasError(): - EdkLogger.error("build", BUILD_ERROR, "Failed to b= uild module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build module"= , ExtraData=3DGlobalData.gBuildingModule) self.MakeTime +=3D int(round((time.time() - MakeStart)= )) =20 MakeContiue =3D time.time() @@ -1995,19 +2164,20 @@ class Build(): self.BuildModules =3D [] self.MakeTime +=3D int(round((time.time() - MakeContiue))) if BuildTask.HasError(): - EdkLogger.error("build", BUILD_ERROR, "Failed to build= module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build module", Ex= traData=3DGlobalData.gBuildingModule) =20 self.BuildReport.AddPlatformReport(Wa, MaList) if MaList =3D=3D []: EdkLogger.error( - 'build', - BUILD_ERROR, - "Module for [%s] is not a component of act= ive platform."\ - " Please make sure that the ARCH and inf f= ile path are"\ - " given in the same as in [%s]" % \ - (', '.join(Wa.ArchList), self.Platform= File), - ExtraData=3Dself.ModuleFile - ) + 'build', + BUILD_ERROR, + "Module for [%s] is not a component of active plat= form." + " Please make sure that the ARCH and inf file path= are" + " given in the same as in [%s]" % + (', '.join(Wa.ArchList), self.PlatformFile), + ExtraData=3Dself.ModuleFile + ) # Create MAP file when Load Fix Address is enabled. if self.Target =3D=3D "fds" and self.Fdf: for Arch in Wa.ArchList: @@ -2015,7 +2185,8 @@ class Build(): # Check whether the set fix address is above 4G fo= r 32bit image. # if (Arch =3D=3D 'IA32' or Arch =3D=3D 'ARM') and s= elf.LoadFixAddress !=3D 0xFFFFFFFFFFFFFFFF and self.LoadFixAddress >=3D 0x1= 00000000: - EdkLogger.error("build", PARAMETER_INVALID, "F= IX_LOAD_TOP_MEMORY_ADDRESS can't be set to larger than or equal to 4G for t= he platorm with IA32 or ARM arch modules") + EdkLogger.error( + "build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS can't be set to larger than or equal to 4G for the platorm w= ith IA32 or ARM arch modules") # # Get Module List # @@ -2046,19 +2217,22 @@ class Build(): # # Save MAP buffer into MAP file. # - self._SaveMapFile (MapBuffer, Wa) + self._SaveMapFile(MapBuffer, Wa) =20 - def _GenFfsCmd(self,ArchList): + def _GenFfsCmd(self, ArchList): # convert dictionary of Cmd:(Inf,Arch) # to a new dictionary of (Inf,Arch):Cmd,Cmd,Cmd... CmdSetDict =3D defaultdict(set) - GenFfsDict =3D GenFds.GenFfsMakefile('', GlobalData.gFdfParser, se= lf, ArchList, GlobalData) + GenFfsDict =3D GenFds.GenFfsMakefile( + '', GlobalData.gFdfParser, self, ArchList, GlobalData) for Cmd in GenFfsDict: tmpInf, tmpArch =3D GenFfsDict[Cmd] CmdSetDict[tmpInf, tmpArch].add(Cmd) return CmdSetDict + def VerifyAutoGenFiles(self): - AutoGenIdFile =3D os.path.join(GlobalData.gConfDirectory,".AutoGen= IdFile.txt") + AutoGenIdFile =3D os.path.join( + GlobalData.gConfDirectory, ".AutoGenIdFile.txt") try: with open(AutoGenIdFile) as fd: lines =3D fd.readlines() @@ -2073,7 +2247,8 @@ class Build(): PlatformGuid =3D line.split("=3D")[1].strip() GlobalVarList =3D [] for arch in ArchList: - global_var =3D os.path.join(BuildDir, "GlobalVar_%s_%s.bin" % = (str(PlatformGuid),arch)) + global_var =3D os.path.join( + BuildDir, "GlobalVar_%s_%s.bin" % (str(PlatformGuid), arch= )) if not os.path.exists(global_var): return None GlobalVarList.append(global_var) @@ -2088,26 +2263,30 @@ class Build(): workspacedir =3D data_pipe.Get("P_Info").get("WorkspaceDir") PackagesPath =3D os.getenv("PACKAGES_PATH") mws.setWs(workspacedir, PackagesPath) - LibraryBuildDirectoryList =3D data_pipe.Get("LibraryBuildDirec= toryList") - ModuleBuildDirectoryList =3D data_pipe.Get("ModuleBuildDirecto= ryList") + LibraryBuildDirectoryList =3D data_pipe.Get( + "LibraryBuildDirectoryList") + ModuleBuildDirectoryList =3D data_pipe.Get( + "ModuleBuildDirectoryList") =20 for m_build_dir in LibraryBuildDirectoryList: - if not os.path.exists(os.path.join(m_build_dir,self.MakeFi= leName)): + if not os.path.exists(os.path.join(m_build_dir, self.MakeF= ileName)): return None for m_build_dir in ModuleBuildDirectoryList: - if not os.path.exists(os.path.join(m_build_dir,self.MakeFi= leName)): + if not os.path.exists(os.path.join(m_build_dir, self.MakeF= ileName)): return None Wa =3D WorkSpaceInfo( - workspacedir,active_p,target,toolchain,archlist - ) - Pa =3D PlatformInfo(Wa, active_p, target, toolchain, Arch,data= _pipe) + workspacedir, active_p, target, toolchain, archlist + ) + Pa =3D PlatformInfo(Wa, active_p, target, toolchain, Arch, dat= a_pipe) Wa.AutoGenObjectList.append(Pa) return Wa - def SetupMakeSetting(self,Wa): + + def SetupMakeSetting(self, Wa): BuildModules =3D [] for Pa in Wa.AutoGenObjectList: for m in Pa._MbList: - ma =3D ModuleAutoGen(Wa,m.MetaFile, Pa.BuildTarget, Wa.Too= lChain, Pa.Arch, Pa.MetaFile,Pa.DataPipe) + ma =3D ModuleAutoGen(Wa, m.MetaFile, Pa.BuildTarget, + Wa.ToolChain, Pa.Arch, Pa.MetaFile, Pa.= DataPipe) BuildModules.append(ma) fdf_file =3D Wa.FlashDefinition if fdf_file: @@ -2119,34 +2298,35 @@ class Build(): for FdRegion in FdDict.RegionList: if str(FdRegion.RegionType) =3D=3D 'FILE' and self.Pla= tform.VpdToolGuid in str(FdRegion.RegionDataList): if int(FdRegion.Offset) % 8 !=3D 0: - EdkLogger.error("build", FORMAT_INVALID, 'The = VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset)) + EdkLogger.error( + "build", FORMAT_INVALID, 'The VPD Base Add= ress %s must be 8-byte aligned.' % (FdRegion.Offset)) Wa.FdfProfile =3D Fdf.Profile self.Fdf =3D Fdf else: self.Fdf =3D None return BuildModules =20 - ## Build a platform in multi-thread mode + # Build a platform in multi-thread mode # - def PerformAutoGen(self,BuildTarget,ToolChain): + def PerformAutoGen(self, BuildTarget, ToolChain): WorkspaceAutoGenTime =3D time.time() Wa =3D WorkspaceAutoGen( - self.WorkspaceDir, - self.PlatformFile, - BuildTarget, - ToolChain, - self.ArchList, - self.BuildDatabase, - self.TargetTxt, - self.ToolDef, - self.Fdf, - self.FdList, - self.FvList, - self.CapList, - self.SkuId, - self.UniFlag, - self.Progress - ) + self.WorkspaceDir, + self.PlatformFile, + BuildTarget, + ToolChain, + self.ArchList, + self.BuildDatabase, + self.TargetTxt, + self.ToolDef, + self.Fdf, + self.FdList, + self.FvList, + self.CapList, + self.SkuId, + self.UniFlag, + self.Progress + ) self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) @@ -2160,10 +2340,11 @@ class Build(): self.AutoGenTime +=3D int(round((time.time() - WorkspaceAutoGenTim= e))) BuildModules =3D [] for Arch in Wa.ArchList: - PcdMaList =3D [] + PcdMaList =3D [] AutoGenStart =3D time.time() GlobalData.gGlobalDefines['ARCH'] =3D Arch - Pa =3D PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, Too= lChain, Arch) + Pa =3D PlatformAutoGen(Wa, self.PlatformFile, + BuildTarget, ToolChain, Arch) if Pa is None: continue ModuleList =3D [] @@ -2176,26 +2357,33 @@ class Build(): if Inf in Pa.Platform.Modules: continue ModuleList.append(Inf) - Pa.DataPipe.DataContainer =3D {"FfsCommand":CmdListDict} - Pa.DataPipe.DataContainer =3D {"Workspace_timestamp": Wa._SrcT= imeStamp} + Pa.DataPipe.DataContainer =3D {"FfsCommand": CmdListDict} + Pa.DataPipe.DataContainer =3D { + "Workspace_timestamp": Wa._SrcTimeStamp} Pa.DataPipe.DataContainer =3D {"CommandTarget": self.Target} Pa.CreateLibModuelDirs() # Fetch the MakeFileName. self.MakeFileName =3D Pa.MakeFileName =20 - Pa.DataPipe.DataContainer =3D {"LibraryBuildDirectoryList":Pa.= LibraryBuildDirectoryList} - Pa.DataPipe.DataContainer =3D {"ModuleBuildDirectoryList":Pa.M= oduleBuildDirectoryList} - Pa.DataPipe.DataContainer =3D {"FdsCommandDict": Wa.GenFdsComm= andDict} + Pa.DataPipe.DataContainer =3D { + "LibraryBuildDirectoryList": Pa.LibraryBuildDirectoryList} + Pa.DataPipe.DataContainer =3D { + "ModuleBuildDirectoryList": Pa.ModuleBuildDirectoryList} + Pa.DataPipe.DataContainer =3D { + "FdsCommandDict": Wa.GenFdsCommandDict} # Prepare the cache share data for multiprocessing - Pa.DataPipe.DataContainer =3D {"gPlatformHashFile":GlobalData.= gPlatformHashFile} + Pa.DataPipe.DataContainer =3D { + "gPlatformHashFile": GlobalData.gPlatformHashFile} ModuleCodaFile =3D {} for ma in Pa.ModuleAutoGenList: - ModuleCodaFile[(ma.MetaFile.File,ma.MetaFile.Root,ma.Arch,= ma.MetaFile.Path)] =3D [item.Target for item in ma.CodaTargetList] - Pa.DataPipe.DataContainer =3D {"ModuleCodaFile":ModuleCodaFile} + ModuleCodaFile[(ma.MetaFile.File, ma.MetaFile.Root, ma.Arc= h, ma.MetaFile.Path)] =3D [ + item.Target for item in ma.CodaTargetList] + Pa.DataPipe.DataContainer =3D {"ModuleCodaFile": ModuleCodaFil= e} # ModuleList contains all driver modules only for Module in ModuleList: # Get ModuleAutoGen object to generate C code file and mak= efile - Ma =3D ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, A= rch, self.PlatformFile,Pa.DataPipe) + Ma =3D ModuleAutoGen( + Wa, Module, BuildTarget, ToolChain, Arch, self.Platfor= mFile, Pa.DataPipe) if Ma is None: continue if Ma.PcdIsDriver: @@ -2209,16 +2397,18 @@ class Build(): cqueue =3D mp.Queue() for m in Pa.GetAllModuleInfo: mqueue.put(m) - module_file,module_root,module_path,module_basename,\ - module_originalpath,module_arch,IsLib =3D m - Ma =3D ModuleAutoGen(Wa, PathClass(module_path, Wa), Build= Target,\ - ToolChain, Arch, self.PlatformFile,Pa.Da= taPipe) + module_file, module_root, module_path, module_basename,\ + module_originalpath, module_arch, IsLib =3D m + Ma =3D ModuleAutoGen(Wa, PathClass(module_path, Wa), Build= Target, + ToolChain, Arch, self.PlatformFile, Pa.= DataPipe) self.AllModules.add(Ma) - data_pipe_file =3D os.path.join(Pa.BuildDir, "GlobalVar_%s_%s.= bin" % (str(Pa.Guid),Pa.Arch)) + data_pipe_file =3D os.path.join( + Pa.BuildDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid), Pa.Arc= h)) Pa.DataPipe.dump(data_pipe_file) =20 - mqueue.put((None,None,None,None,None,None,None)) - autogen_rt, errorcode =3D self.StartAutoGen(mqueue, Pa.DataPip= e, self.SkipAutoGen, PcdMaList, cqueue) + mqueue.put((None, None, None, None, None, None, None)) + autogen_rt, errorcode =3D self.StartAutoGen( + mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList, cqueue) =20 if not autogen_rt: self.AutoGenMgr.TerminateWorkers() @@ -2228,8 +2418,8 @@ class Build(): if GlobalData.gUseHashCache: for item in GlobalData.gModuleAllCacheStatus: (MetaFilePath, Arch, CacheStr, Status) =3D item - Ma =3D ModuleAutoGen(Wa, PathClass(MetaFilePath, Wa), = BuildTarget,\ - ToolChain, Arch, self.PlatformFile,P= a.DataPipe) + Ma =3D ModuleAutoGen(Wa, PathClass(MetaFilePath, Wa), = BuildTarget, + ToolChain, Arch, self.PlatformFile,= Pa.DataPipe) if CacheStr =3D=3D "PreMakeCache" and Status =3D=3D Fa= lse: self.PreMakeCacheMiss.add(Ma) if CacheStr =3D=3D "PreMakeCache" and Status =3D=3D Tr= ue: @@ -2241,8 +2431,9 @@ class Build(): self.MakeCacheHit.add(Ma) GlobalData.gModuleCacheHit.add(Ma) self.AutoGenTime +=3D int(round((time.time() - AutoGenStart))) - AutoGenIdFile =3D os.path.join(GlobalData.gConfDirectory,".AutoGen= IdFile.txt") - with open(AutoGenIdFile,"w") as fw: + AutoGenIdFile =3D os.path.join( + GlobalData.gConfDirectory, ".AutoGenIdFile.txt") + with open(AutoGenIdFile, "w") as fw: fw.write("Arch=3D%s\n" % "|".join((Wa.ArchList))) fw.write("BuildDir=3D%s\n" % Wa.BuildDir) fw.write("PlatformGuid=3D%s\n" % str(Wa.AutoGenObjectList[0].G= uid)) @@ -2258,7 +2449,8 @@ class Build(): return Wa, BuildModules =20 def _MultiThreadBuildPlatform(self): - SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE a= uto-generated\n', False) + SaveFileOnChange(self.PlatformBuildPath, + '# DO NOT EDIT \n# FILE auto-generated\n', False) for BuildTarget in self.BuildTargetList: GlobalData.gGlobalDefines['TARGET'] =3D BuildTarget index =3D 0 @@ -2274,41 +2466,50 @@ class Build(): Wa =3D self.VerifyAutoGenFiles() if Wa is None: self.SkipAutoGen =3D False - Wa, self.BuildModules =3D self.PerformAutoGen(Buil= dTarget,ToolChain) + Wa, self.BuildModules =3D self.PerformAutoGen( + BuildTarget, ToolChain) else: GlobalData.gAutoGenPhase =3D True self.BuildModules =3D self.SetupMakeSetting(Wa) else: - Wa, self.BuildModules =3D self.PerformAutoGen(BuildTar= get,ToolChain) + Wa, self.BuildModules =3D self.PerformAutoGen( + BuildTarget, ToolChain) Pa =3D Wa.AutoGenObjectList[0] GlobalData.gAutoGenPhase =3D False =20 if GlobalData.gBinCacheSource: - EdkLogger.quiet("[cache Summary]: Total module num: %s= " % len(self.AllModules)) - EdkLogger.quiet("[cache Summary]: PreMakecache miss nu= m: %s " % len(self.PreMakeCacheMiss)) - EdkLogger.quiet("[cache Summary]: Makecache miss num: = %s " % len(self.MakeCacheMiss)) + EdkLogger.quiet( + "[cache Summary]: Total module num: %s" % len(self= .AllModules)) + EdkLogger.quiet("[cache Summary]: PreMakecache miss nu= m: %s " % len( + self.PreMakeCacheMiss)) + EdkLogger.quiet( + "[cache Summary]: Makecache miss num: %s " % len(s= elf.MakeCacheMiss)) =20 for Arch in Wa.ArchList: MakeStart =3D time.time() for Ma in set(self.BuildModules): # Generate build task for the module if not Ma.IsBinaryModule: - Bt =3D BuildTask.New(ModuleMakeUnit(Ma, Pa.Bui= ldCommand,self.Target)) + Bt =3D BuildTask.New(ModuleMakeUnit( + Ma, Pa.BuildCommand, self.Target)) # Break build if any build thread has error if BuildTask.HasError(): # we need a full version of makefile for platf= orm ExitFlag.set() BuildTask.WaitForComplete() Pa.CreateMakeFile(False) - EdkLogger.error("build", BUILD_ERROR, "Failed = to build module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build mod= ule", ExtraData=3DGlobalData.gBuildingModule) # Start task scheduler if not BuildTask.IsOnGoing(): - BuildTask.StartScheduler(self.ThreadNumber, Ex= itFlag) + BuildTask.StartScheduler( + self.ThreadNumber, ExitFlag) =20 # in case there's an interruption. we need a full vers= ion of makefile for platform =20 if BuildTask.HasError(): - EdkLogger.error("build", BUILD_ERROR, "Failed to b= uild module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build module"= , ExtraData=3DGlobalData.gBuildingModule) self.MakeTime +=3D int(round((time.time() - MakeStart)= )) =20 MakeContiue =3D time.time() @@ -2336,7 +2537,8 @@ class Build(): # has been signaled. # if BuildTask.HasError(): - EdkLogger.error("build", BUILD_ERROR, "Failed to build= module", ExtraData=3DGlobalData.gBuildingModule) + EdkLogger.error( + "build", BUILD_ERROR, "Failed to build module", Ex= traData=3DGlobalData.gBuildingModule) =20 # Create MAP file when Load Fix Address is enabled. if self.Target in ["", "all", "fds"]: @@ -2345,7 +2547,8 @@ class Build(): # Check whether the set fix address is above 4G fo= r 32bit image. # if (Arch =3D=3D 'IA32' or Arch =3D=3D 'ARM') and s= elf.LoadFixAddress !=3D 0xFFFFFFFFFFFFFFFF and self.LoadFixAddress >=3D 0x1= 00000000: - EdkLogger.error("build", PARAMETER_INVALID, "F= IX_LOAD_TOP_MEMORY_ADDRESS can't be set to larger than or equal to 4G for t= he platorm with IA32 or ARM arch modules") + EdkLogger.error( + "build", PARAMETER_INVALID, "FIX_LOAD_TOP_= MEMORY_ADDRESS can't be set to larger than or equal to 4G for the platorm w= ith IA32 or ARM arch modules") =20 # # Rebase module to the preferred memory address before= GenFds @@ -2376,13 +2579,14 @@ class Build(): self._SaveMapFile(MapBuffer, Wa) self.CreateGuidedSectionToolsFile(Wa) =20 - ## GetFreeSizeThreshold() + # GetFreeSizeThreshold() # # @retval int Threshold value # def GetFreeSizeThreshold(self): Threshold =3D None - Threshold_Str =3D GlobalData.gCommandLineDefines.get('FV_SPARE_SPA= CE_THRESHOLD') + Threshold_Str =3D GlobalData.gCommandLineDefines.get( + 'FV_SPARE_SPACE_THRESHOLD') if Threshold_Str: try: if Threshold_Str.lower().startswith('0x'): @@ -2390,7 +2594,8 @@ class Build(): else: Threshold =3D int(Threshold_Str) except: - EdkLogger.warn("build", 'incorrect value for FV_SPARE_SPAC= E_THRESHOLD %s.Only decimal or hex format is allowed.' % Threshold_Str) + EdkLogger.warn( + "build", 'incorrect value for FV_SPARE_SPACE_THRESHOLD= %s.Only decimal or hex format is allowed.' % Threshold_Str) return Threshold =20 def CheckFreeSizeThreshold(self, Threshold=3DNone, FvDir=3DNone): @@ -2399,10 +2604,12 @@ class Build(): if not isinstance(FvDir, str) or not FvDir: return FdfParserObject =3D GlobalData.gFdfParser - FvRegionNameList =3D [FvName for FvName in FdfParserObject.Profile= .FvDict if FdfParserObject.Profile.FvDict[FvName].FvRegionInFD] + FvRegionNameList =3D [ + FvName for FvName in FdfParserObject.Profile.FvDict if FdfPars= erObject.Profile.FvDict[FvName].FvRegionInFD] for FvName in FdfParserObject.Profile.FvDict: if FvName in FvRegionNameList: - FvSpaceInfoFileName =3D os.path.join(FvDir, FvName.upper()= + '.Fv.map') + FvSpaceInfoFileName =3D os.path.join( + FvDir, FvName.upper() + '.Fv.map') if os.path.exists(FvSpaceInfoFileName): FileLinesList =3D getlines(FvSpaceInfoFileName) for Line in FileLinesList: @@ -2415,9 +2622,9 @@ class Build(): FvName, FreeSizeValue,= Threshold)) break =20 - ## Generate GuidedSectionTools.txt in the FV directories. + # Generate GuidedSectionTools.txt in the FV directories. # - def CreateGuidedSectionToolsFile(self,Wa): + def CreateGuidedSectionToolsFile(self, Wa): for BuildTarget in self.BuildTargetList: for ToolChain in self.ToolChainList: FvDir =3D Wa.FvDir @@ -2434,13 +2641,14 @@ class Build(): continue if Platform.Arch !=3D Arch: continue - if hasattr (Platform, 'BuildOption'): + if hasattr(Platform, 'BuildOption'): for Tool in Platform.BuildOption: if 'GUID' in Platform.BuildOption[Tool]: if 'PATH' in Platform.BuildOption[Tool= ]: value =3D Platform.BuildOption[Too= l]['GUID'] if value in guidList: - EdkLogger.error("build", FORMA= T_INVALID, "Duplicate GUID value %s used with Tool %s in DSC [BuildOptions]= ." % (value, Tool)) + EdkLogger.error( + "build", FORMAT_INVALID, "= Duplicate GUID value %s used with Tool %s in DSC [BuildOptions]." % (value,= Tool)) path =3D Platform.BuildOption[Tool= ]['PATH'] guidList.append(value) guidAttribs.append((value, Tool, p= ath)) @@ -2449,7 +2657,8 @@ class Build(): if 'PATH' in Platform.ToolDefinition[Tool]: value =3D Platform.ToolDefinition[Tool= ]['GUID'] if value in tooldefguidList: - EdkLogger.error("build", FORMAT_IN= VALID, "Duplicate GUID value %s used with Tool %s in tools_def.txt." % (val= ue, Tool)) + EdkLogger.error( + "build", FORMAT_INVALID, "Dupl= icate GUID value %s used with Tool %s in tools_def.txt." % (value, Tool)) tooldefguidList.append(value) if value in guidList: # Already added by platform @@ -2458,7 +2667,7 @@ class Build(): guidList.append(value) guidAttribs.append((value, Tool, path)) # Sort by GuidTool name - guidAttribs =3D sorted (guidAttribs, key=3Dlambda x: x= [1]) + guidAttribs =3D sorted(guidAttribs, key=3Dlambda x: x[= 1]) # Write out GuidedSecTools.txt toolsFile =3D os.path.join(FvDir, 'GuidedSectionTools.= txt') toolsFile =3D open(toolsFile, 'wt') @@ -2466,14 +2675,14 @@ class Build(): print(' '.join(guidedSectionTool), file=3DtoolsFil= e) toolsFile.close() =20 - ## Returns the real path of the tool. + # Returns the real path of the tool. # - def GetRealPathOfTool (self, tool): + def GetRealPathOfTool(self, tool): if os.path.exists(tool): return os.path.realpath(tool) return tool =20 - ## Launch the module or platform build + # Launch the module or platform build # def Launch(self): self.AllDrivers =3D set() @@ -2509,7 +2718,7 @@ class Build(): for Module in self.PreMakeCacheMiss: Module.GenPreMakefileHashList() =20 - ## Do some clean-up works when error occurred + # Do some clean-up works when error occurred def Relinquish(self): OldLogLevel =3D EdkLogger.GetLevel() EdkLogger.SetLevel(EdkLogger.ERROR) @@ -2518,6 +2727,7 @@ class Build(): BuildTask.Abort() EdkLogger.SetLevel(OldLogLevel) =20 + def ParseDefines(DefineList=3D[]): DefineDict =3D {} if DefineList is not None: @@ -2535,18 +2745,20 @@ def ParseDefines(DefineList=3D[]): return DefineDict =20 =20 - def LogBuildTime(Time): if Time: TimeDurStr =3D '' TimeDur =3D time.gmtime(Time) if TimeDur.tm_yday > 1: - TimeDurStr =3D time.strftime("%H:%M:%S", TimeDur) + ", %d day(= s)" % (TimeDur.tm_yday - 1) + TimeDurStr =3D time.strftime( + "%H:%M:%S", TimeDur) + ", %d day(s)" % (TimeDur.tm_yday - = 1) else: TimeDurStr =3D time.strftime("%H:%M:%S", TimeDur) return TimeDurStr else: return None + + def ThreadNum(): OptionParser =3D MyOptionParser() if not OptionParser.BuildOption and not OptionParser.BuildTarget: @@ -2556,7 +2768,8 @@ def ThreadNum(): GlobalData.gCmdConfDir =3D BuildOption.ConfDirectory if ThreadNumber is None: TargetObj =3D TargetTxtDict() - ThreadNumber =3D TargetObj.Target.TargetTxtDictionary[TAB_TAT_DEFI= NES_MAX_CONCURRENT_THREAD_NUMBER] + ThreadNumber =3D TargetObj.Target.TargetTxtDictionary[ + TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER] if ThreadNumber =3D=3D '': ThreadNumber =3D 0 else: @@ -2568,7 +2781,9 @@ def ThreadNum(): except (ImportError, NotImplementedError): ThreadNumber =3D 1 return ThreadNumber -## Tool entrance method + + +# Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -2578,6 +2793,8 @@ def ThreadNum(): # @retval 1 Tool failed # LogQMaxSize =3D ThreadNum() * 10 + + def Main(): StartTime =3D time.time() =20 @@ -2614,7 +2831,7 @@ def Main(): =20 if Option.WarningAsError =3D=3D True: EdkLogger.SetWarningAsError() - Log_Agent =3D LogAgent(LogQ,LogLevel,Option.LogFile) + Log_Agent =3D LogAgent(LogQ, LogLevel, Option.LogFile) Log_Agent.start() =20 if platform.platform().find("Windows") >=3D 0: @@ -2623,7 +2840,8 @@ def Main(): GlobalData.gIsWindows =3D False =20 EdkLogger.quiet("Build environment: %s" % platform.platform()) - EdkLogger.quiet(time.strftime("Build start time: %H:%M:%S, %b.%d %Y\n"= , time.localtime())); + EdkLogger.quiet(time.strftime( + "Build start time: %H:%M:%S, %b.%d %Y\n", time.localtime())) ReturnCode =3D 0 MyBuild =3D None BuildError =3D True @@ -2654,7 +2872,8 @@ def Main(): =20 WorkingDirectory =3D os.getcwd() if not Option.ModuleFile: - FileList =3D glob.glob(os.path.normpath(os.path.join(WorkingDi= rectory, '*.inf'))) + FileList =3D glob.glob(os.path.normpath( + os.path.join(WorkingDirectory, '*.inf'))) FileNum =3D len(FileList) if FileNum >=3D 2: EdkLogger.error("build", OPTION_NOT_SUPPORTED, "There are = %d INF files in %s." % (FileNum, WorkingDirectory), @@ -2663,33 +2882,37 @@ def Main(): Option.ModuleFile =3D NormFile(FileList[0], Workspace) =20 if Option.ModuleFile: - if os.path.isabs (Option.ModuleFile): - if os.path.normcase (os.path.normpath(Option.ModuleFile)).= find (Workspace) =3D=3D 0: - Option.ModuleFile =3D NormFile(os.path.normpath(Option= .ModuleFile), Workspace) + if os.path.isabs(Option.ModuleFile): + if os.path.normcase(os.path.normpath(Option.ModuleFile)).f= ind(Workspace) =3D=3D 0: + Option.ModuleFile =3D NormFile( + os.path.normpath(Option.ModuleFile), Workspace) Option.ModuleFile =3D PathClass(Option.ModuleFile, Workspace) ErrorCode, ErrorInfo =3D Option.ModuleFile.Validate(".inf", Fa= lse) if ErrorCode !=3D 0: EdkLogger.error("build", ErrorCode, ExtraData=3DErrorInfo) =20 if Option.PlatformFile is not None: - if os.path.isabs (Option.PlatformFile): - if os.path.normcase (os.path.normpath(Option.PlatformFile)= ).find (Workspace) =3D=3D 0: - Option.PlatformFile =3D NormFile(os.path.normpath(Opti= on.PlatformFile), Workspace) + if os.path.isabs(Option.PlatformFile): + if os.path.normcase(os.path.normpath(Option.PlatformFile))= .find(Workspace) =3D=3D 0: + Option.PlatformFile =3D NormFile( + os.path.normpath(Option.PlatformFile), Workspace) Option.PlatformFile =3D PathClass(Option.PlatformFile, Workspa= ce) =20 if Option.FdfFile is not None: - if os.path.isabs (Option.FdfFile): - if os.path.normcase (os.path.normpath(Option.FdfFile)).fin= d (Workspace) =3D=3D 0: - Option.FdfFile =3D NormFile(os.path.normpath(Option.Fd= fFile), Workspace) + if os.path.isabs(Option.FdfFile): + if os.path.normcase(os.path.normpath(Option.FdfFile)).find= (Workspace) =3D=3D 0: + Option.FdfFile =3D NormFile( + os.path.normpath(Option.FdfFile), Workspace) Option.FdfFile =3D PathClass(Option.FdfFile, Workspace) ErrorCode, ErrorInfo =3D Option.FdfFile.Validate(".fdf", False) if ErrorCode !=3D 0: EdkLogger.error("build", ErrorCode, ExtraData=3DErrorInfo) =20 if Option.Flag is not None and Option.Flag not in ['-c', '-s']: - EdkLogger.error("build", OPTION_VALUE_INVALID, "UNI flag must = be one of -c or -s") + EdkLogger.error("build", OPTION_VALUE_INVALID, + "UNI flag must be one of -c or -s") =20 - MyBuild =3D Build(Target, Workspace, Option,LogQ) + MyBuild =3D Build(Target, Workspace, Option, LogQ) GlobalData.gCommandLineDefines['ARCH'] =3D ' '.join(MyBuild.ArchLi= st) if not (MyBuild.LaunchPrebuildFlag and os.path.exists(MyBuild.Plat= formBuildPath)): MyBuild.Launch() @@ -2703,7 +2926,8 @@ def Main(): # for multi-thread build exits safely MyBuild.Relinquish() if Option is not None and Option.debug is not None: - EdkLogger.quiet("(Python %s on %s) " % (platform.python_versio= n(), sys.platform) + traceback.format_exc()) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.forma= t_exc()) ReturnCode =3D X.args[0] except Warning as X: # error from Fdf parser @@ -2711,9 +2935,11 @@ def Main(): # for multi-thread build exits safely MyBuild.Relinquish() if Option is not None and Option.debug is not None: - EdkLogger.quiet("(Python %s on %s) " % (platform.python_versio= n(), sys.platform) + traceback.format_exc()) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.forma= t_exc()) else: - EdkLogger.error(X.ToolName, FORMAT_INVALID, File=3DX.FileName,= Line=3DX.LineNumber, ExtraData=3DX.Message, RaiseError=3DFalse) + EdkLogger.error(X.ToolName, FORMAT_INVALID, File=3DX.FileName, + Line=3DX.LineNumber, ExtraData=3DX.Message, Ra= iseError=3DFalse) ReturnCode =3D FORMAT_INVALID except KeyboardInterrupt: if MyBuild is not None: @@ -2722,7 +2948,8 @@ def Main(): MyBuild.Relinquish() ReturnCode =3D ABORT_ERROR if Option is not None and Option.debug is not None: - EdkLogger.quiet("(Python %s on %s) " % (platform.python_versio= n(), sys.platform) + traceback.format_exc()) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.forma= t_exc()) except: if MyBuild is not None: # for multi-thread build exits safely @@ -2736,13 +2963,14 @@ def Main(): MetaFile =3D Tb.tb_frame.f_locals['self'].MetaFile Tb =3D Tb.tb_next EdkLogger.error( - "\nbuild", - CODE_ERROR, - "Unknown fatal error when processing [%s]" % MetaFile, - ExtraData=3D"\n(Please send email to %s for help, atta= ching following call stack trace!)\n" % MSG_EDKII_MAIL_ADDR, - RaiseError=3DFalse - ) - EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(),= sys.platform) + traceback.format_exc()) + "\nbuild", + CODE_ERROR, + "Unknown fatal error when processing [%s]" % MetaFile, + ExtraData=3D"\n(Please send email to %s for help, attaching fo= llowing call stack trace!)\n" % MSG_EDKII_MAIL_ADDR, + RaiseError=3DFalse + ) + EdkLogger.quiet("(Python %s on %s) " % ( + platform.python_version(), sys.platform) + traceback.format_ex= c()) ReturnCode =3D CODE_ERROR finally: Utils.Progressor.Abort() @@ -2763,27 +2991,32 @@ def Main(): BuildDuration =3D time.gmtime(int(round(FinishTime - StartTime))) BuildDurationStr =3D "" if BuildDuration.tm_yday > 1: - BuildDurationStr =3D time.strftime("%H:%M:%S", BuildDuration) + ",= %d day(s)" % (BuildDuration.tm_yday - 1) + BuildDurationStr =3D time.strftime( + "%H:%M:%S", BuildDuration) + ", %d day(s)" % (BuildDuration.tm= _yday - 1) else: BuildDurationStr =3D time.strftime("%H:%M:%S", BuildDuration) if MyBuild is not None: if not BuildError: - MyBuild.BuildReport.GenerateReport(BuildDurationStr, LogBuildT= ime(MyBuild.AutoGenTime), LogBuildTime(MyBuild.MakeTime), LogBuildTime(MyBu= ild.GenFdsTime)) + MyBuild.BuildReport.GenerateReport(BuildDurationStr, LogBuildT= ime( + MyBuild.AutoGenTime), LogBuildTime(MyBuild.MakeTime), LogB= uildTime(MyBuild.GenFdsTime)) =20 EdkLogger.SetLevel(EdkLogger.QUIET) EdkLogger.quiet("\n- %s -" % Conclusion) - EdkLogger.quiet(time.strftime("Build end time: %H:%M:%S, %b.%d %Y", ti= me.localtime())) + EdkLogger.quiet(time.strftime( + "Build end time: %H:%M:%S, %b.%d %Y", time.localtime())) EdkLogger.quiet("Build total time: %s\n" % BuildDurationStr) Log_Agent.kill() Log_Agent.join() return ReturnCode =20 + if __name__ =3D=3D '__main__': try: mp.set_start_method('spawn') except: pass r =3D Main() - ## 0-127 is a safe return range, and 1 is a standard default error - if r < 0 or r > 127: r =3D 1 + # 0-127 is a safe return range, and 1 is a standard default error + if r < 0 or r > 127: + r =3D 1 sys.exit(r) diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Sour= ce/Python/build/buildoptions.py index 39d92cff209d..c662b833c049 100644 --- a/BaseTools/Source/Python/build/buildoptions.py +++ b/BaseTools/Source/Python/build/buildoptions.py @@ -1,4 +1,4 @@ -## @file +# @file # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
        @@ -16,12 +16,15 @@ __version__ =3D "%prog Version " + VersionNumber __copyright__ =3D "Copyright (c) 2007 - 2018, Intel Corporation All right= s reserved." =20 gParamCheck =3D [] + + def SingleCheckCallback(option, opt_str, value, parser): if option not in gParamCheck: setattr(parser.values, option.dest, value) gParamCheck.append(option) else: - parser.error("Option %s only allows one instance in command line!"= % option) + parser.error( + "Option %s only allows one instance in command line!" % option) =20 =20 class MyOptionParser(): @@ -39,67 +42,89 @@ class MyOptionParser(): self.BuildTarget =3D None =20 def GetOption(self): - Parser =3D OptionParser(description=3D__copyright__, version=3D__v= ersion__, prog=3D"build.exe", usage=3D"%prog [options] [all|fds|genc|genmak= e|clean|cleanall|cleanlib|modules|libraries|run]") + Parser =3D OptionParser(description=3D__copyright__, version=3D__v= ersion__, prog=3D"build.exe", + usage=3D"%prog [options] [all|fds|genc|genma= ke|clean|cleanall|cleanlib|modules|libraries|run]") Parser.add_option("-a", "--arch", action=3D"append", dest=3D"Targe= tArch", - help=3D"ARCHS is one of list: IA32, X64, ARM, AARCH64, RISCV64= or EBC, which overrides target.txt's TARGET_ARCH definition. To specify mo= re archs, please repeat this option.") + help=3D"ARCHS is one of list: IA32, X64, ARM, AA= RCH64, RISCV64 or EBC, which overrides target.txt's TARGET_ARCH definition.= To specify more archs, please repeat this option.") Parser.add_option("-p", "--platform", action=3D"callback", type=3D= "string", dest=3D"PlatformFile", callback=3DSingleCheckCallback, - help=3D"Build the platform specified by the DSC file name argu= ment, overriding target.txt's ACTIVE_PLATFORM definition.") + help=3D"Build the platform specified by the DSC = file name argument, overriding target.txt's ACTIVE_PLATFORM definition.") Parser.add_option("-m", "--module", action=3D"callback", type=3D"s= tring", dest=3D"ModuleFile", callback=3DSingleCheckCallback, - help=3D"Build the module specified by the INF file name argume= nt.") + help=3D"Build the module specified by the INF fi= le name argument.") Parser.add_option("-b", "--buildtarget", type=3D"string", dest=3D"= BuildTarget", help=3D"Using the TARGET to build the platform, overriding ta= rget.txt's TARGET definition.", action=3D"append") Parser.add_option("-t", "--tagname", action=3D"append", type=3D"st= ring", dest=3D"ToolChain", - help=3D"Using the Tool Chain Tagname to build the platform, ov= erriding target.txt's TOOL_CHAIN_TAG definition.") + help=3D"Using the Tool Chain Tagname to build th= e platform, overriding target.txt's TOOL_CHAIN_TAG definition.") Parser.add_option("-x", "--sku-id", action=3D"callback", type=3D"s= tring", dest=3D"SkuId", callback=3DSingleCheckCallback, - help=3D"Using this name of SKU ID to build the platform, overr= iding SKUID_IDENTIFIER in DSC file.") + help=3D"Using this name of SKU ID to build the p= latform, overriding SKUID_IDENTIFIER in DSC file.") =20 Parser.add_option("-n", action=3D"callback", type=3D"int", dest=3D= "ThreadNumber", callback=3DSingleCheckCallback, - help=3D"Build the platform using multi-threaded compiler. The = value overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. When value is se= t to 0, tool automatically detect number of "\ - "processor threads, set value to 1 means disable multi-th= read build, and set value to more than 1 means user specify the threads num= ber to build.") + help=3D"Build the platform using multi-threaded = compiler. The value overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. Wh= en value is set to 0, tool automatically detect number of " + "processor threads, set value to 1 means disable= multi-thread build, and set value to more than 1 means user specify the th= reads number to build.") =20 Parser.add_option("-f", "--fdf", action=3D"callback", type=3D"stri= ng", dest=3D"FdfFile", callback=3DSingleCheckCallback, - help=3D"The name of the FDF file to use, which overrides the s= etting in the DSC file.") + help=3D"The name of the FDF file to use, which o= verrides the setting in the DSC file.") Parser.add_option("-r", "--rom-image", action=3D"append", type=3D"= string", dest=3D"RomImage", default=3D[], - help=3D"The name of FD to be generated. The name must be from = [FD] section in FDF file.") + help=3D"The name of FD to be generated. The name= must be from [FD] section in FDF file.") Parser.add_option("-i", "--fv-image", action=3D"append", type=3D"s= tring", dest=3D"FvImage", default=3D[], - help=3D"The name of FV to be generated. The name must be from = [FV] section in FDF file.") + help=3D"The name of FV to be generated. The name= must be from [FV] section in FDF file.") Parser.add_option("-C", "--capsule-image", action=3D"append", type= =3D"string", dest=3D"CapName", default=3D[], - help=3D"The name of Capsule to be generated. The name must be = from [Capsule] section in FDF file.") - Parser.add_option("-u", "--skip-autogen", action=3D"store_true", d= est=3D"SkipAutoGen", help=3D"Skip AutoGen step.") - Parser.add_option("-e", "--re-parse", action=3D"store_true", dest= =3D"Reparse", help=3D"Re-parse all meta-data files.") + help=3D"The name of Capsule to be generated. The= name must be from [Capsule] section in FDF file.") + Parser.add_option("-u", "--skip-autogen", action=3D"store_true", + dest=3D"SkipAutoGen", help=3D"Skip AutoGen step.= ") + Parser.add_option("-e", "--re-parse", action=3D"store_true", + dest=3D"Reparse", help=3D"Re-parse all meta-data= files.") =20 - Parser.add_option("-c", "--case-insensitive", action=3D"store_true= ", dest=3D"CaseInsensitive", default=3DFalse, help=3D"Don't check case of f= ile name.") + Parser.add_option("-c", "--case-insensitive", action=3D"store_true= ", + dest=3D"CaseInsensitive", default=3DFalse, help= =3D"Don't check case of file name.") =20 - Parser.add_option("-w", "--warning-as-error", action=3D"store_true= ", dest=3D"WarningAsError", help=3D"Treat warning in tools as error.") - Parser.add_option("-j", "--log", action=3D"store", dest=3D"LogFile= ", help=3D"Put log in specified file as well as on console.") + Parser.add_option("-w", "--warning-as-error", action=3D"store_true= ", + dest=3D"WarningAsError", help=3D"Treat warning i= n tools as error.") + Parser.add_option("-j", "--log", action=3D"store", dest=3D"LogFile= ", + help=3D"Put log in specified file as well as on = console.") =20 Parser.add_option("-s", "--silent", action=3D"store_true", type=3D= None, dest=3D"SilentMode", - help=3D"Make use of silent mode of (n)make.") - Parser.add_option("-q", "--quiet", action=3D"store_true", type=3DN= one, help=3D"Disable all messages except FATAL ERRORS.") - Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , "\ - = "including library instances selected, final dependency expression= , "\ - = "and warning messages, etc.") - Parser.add_option("-d", "--debug", action=3D"store", type=3D"int",= help=3D"Enable debug messages at specified level.") - Parser.add_option("-D", "--define", action=3D"append", type=3D"str= ing", dest=3D"Macros", help=3D"Macro: \"Name [=3D Value]\".") + help=3D"Make use of silent mode of (n)make.") + Parser.add_option("-q", "--quiet", action=3D"store_true", + type=3DNone, help=3D"Disable all messages except= FATAL ERRORS.") + Parser.add_option("-v", "--verbose", action=3D"store_true", type= =3DNone, help=3D"Turn on verbose output with informational messages printed= , " + "including library instances selected, final dep= endency expression, " + "and warning messages, etc.") + Parser.add_option("-d", "--debug", action=3D"store", type=3D"int", + help=3D"Enable debug messages at specified level= .") + Parser.add_option("-D", "--define", action=3D"append", type=3D"str= ing", + dest=3D"Macros", help=3D"Macro: \"Name [=3D Valu= e]\".") =20 - Parser.add_option("-y", "--report-file", action=3D"store", dest=3D= "ReportFile", help=3D"Create/overwrite the report to the specified filename= .") + Parser.add_option("-y", "--report-file", action=3D"store", dest=3D= "ReportFile", + help=3D"Create/overwrite the report to the speci= fied filename.") Parser.add_option("-Y", "--report-type", action=3D"append", type= =3D"choice", choices=3D['PCD', 'LIBRARY', 'FLASH', 'DEPEX', 'BUILD_FLAGS', = 'FIXED_ADDRESS', 'HASH', 'EXECUTION_ORDER'], dest=3D"ReportType", default= =3D[], - help=3D"Flags that control the type of build report to generat= e. Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS, FIXED_ADDRESS= , HASH, EXECUTION_ORDER]. "\ - "To specify more than one flag, repeat this option on the= command line and the default flag set is [PCD, LIBRARY, FLASH, DEPEX, HASH= , BUILD_FLAGS, FIXED_ADDRESS]") + help=3D"Flags that control the type of build rep= ort to generate. Must be one of: [PCD, LIBRARY, FLASH, DEPEX, BUILD_FLAGS,= FIXED_ADDRESS, HASH, EXECUTION_ORDER]. " + "To specify more than one flag, repeat this opti= on on the command line and the default flag set is [PCD, LIBRARY, FLASH, DE= PEX, HASH, BUILD_FLAGS, FIXED_ADDRESS]") Parser.add_option("-F", "--flag", action=3D"store", type=3D"string= ", dest=3D"Flag", - help=3D"Specify the specific option to parse EDK UNI file. Mus= t be one of: [-c, -s]. -c is for EDK framework UNI file, and -s is for EDK = UEFI UNI file. "\ - "This option can also be specified by setting *_*_*_BUILD= _FLAGS in [BuildOptions] section of platform DSC. If they are both specifie= d, this value "\ - "will override the setting in [BuildOptions] section of p= latform DSC.") - Parser.add_option("-N", "--no-cache", action=3D"store_true", dest= =3D"DisableCache", default=3DFalse, help=3D"Disable build cache mechanism") - Parser.add_option("--conf", action=3D"store", type=3D"string", des= t=3D"ConfDirectory", help=3D"Specify the customized Conf directory.") - Parser.add_option("--check-usage", action=3D"store_true", dest=3D"= CheckUsage", default=3DFalse, help=3D"Check usage content of entries listed= in INF file.") - Parser.add_option("--ignore-sources", action=3D"store_true", dest= =3D"IgnoreSources", default=3DFalse, help=3D"Focus to a binary build and ig= nore all source files") - Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", = help=3D"Set PCD value by command line. Format: \"PcdName=3DValue\" ") - Parser.add_option("-l", "--cmd-len", action=3D"store", type=3D"int= ", dest=3D"CommandLength", help=3D"Specify the maximum line length of build= command. Default is 4096.") - Parser.add_option("--hash", action=3D"store_true", dest=3D"UseHash= Cache", default=3DFalse, help=3D"Enable hash-based caching during build pro= cess.") - Parser.add_option("--binary-destination", action=3D"store", type= =3D"string", dest=3D"BinCacheDest", help=3D"Generate a cache of binary file= s in the specified directory.") - Parser.add_option("--binary-source", action=3D"store", type=3D"str= ing", dest=3D"BinCacheSource", help=3D"Consume a cache of binary files from= the specified directory.") - Parser.add_option("--genfds-multi-thread", action=3D"store_true", = dest=3D"GenfdsMultiThread", default=3DTrue, help=3D"Enable GenFds multi thr= ead to generate ffs file.") - Parser.add_option("--no-genfds-multi-thread", action=3D"store_true= ", dest=3D"NoGenfdsMultiThread", default=3DFalse, help=3D"Disable GenFds mu= lti thread to generate ffs file.") - Parser.add_option("--disable-include-path-check", action=3D"store_= true", dest=3D"DisableIncludePathCheck", default=3DFalse, help=3D"Disable t= he include path check for outside of package.") + help=3D"Specify the specific option to parse EDK= UNI file. Must be one of: [-c, -s]. -c is for EDK framework UNI file, and = -s is for EDK UEFI UNI file. " + "This option can also be specified by setting *_= *_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both= specified, this value " + "will override the setting in [BuildOptions] sec= tion of platform DSC.") + Parser.add_option("-N", "--no-cache", action=3D"store_true", + dest=3D"DisableCache", default=3DFalse, help=3D"= Disable build cache mechanism") + Parser.add_option("--conf", action=3D"store", type=3D"string", + dest=3D"ConfDirectory", help=3D"Specify the cust= omized Conf directory.") + Parser.add_option("--check-usage", action=3D"store_true", dest=3D"= CheckUsage", + default=3DFalse, help=3D"Check usage content of = entries listed in INF file.") + Parser.add_option("--ignore-sources", action=3D"store_true", dest= =3D"IgnoreSources", + default=3DFalse, help=3D"Focus to a binary build= and ignore all source files") + Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", + help=3D"Set PCD value by command line. Format: \= "PcdName=3DValue\" ") + Parser.add_option("-l", "--cmd-len", action=3D"store", type=3D"int= ", dest=3D"CommandLength", + help=3D"Specify the maximum line length of build= command. Default is 4096.") + Parser.add_option("--hash", action=3D"store_true", dest=3D"UseHash= Cache", + default=3DFalse, help=3D"Enable hash-based cachi= ng during build process.") + Parser.add_option("--binary-destination", action=3D"store", type= =3D"string", dest=3D"BinCacheDest", + help=3D"Generate a cache of binary files in the = specified directory.") + Parser.add_option("--binary-source", action=3D"store", type=3D"str= ing", dest=3D"BinCacheSource", + help=3D"Consume a cache of binary files from the= specified directory.") + Parser.add_option("--genfds-multi-thread", action=3D"store_true", = dest=3D"GenfdsMultiThread", + default=3DTrue, help=3D"Enable GenFds multi thre= ad to generate ffs file.") + Parser.add_option("--no-genfds-multi-thread", action=3D"store_true= ", dest=3D"NoGenfdsMultiThread", + default=3DFalse, help=3D"Disable GenFds multi th= read to generate ffs file.") + Parser.add_option("--disable-include-path-check", action=3D"store_= true", dest=3D"DisableIncludePathCheck", + default=3DFalse, help=3D"Disable the include pat= h check for outside of package.") self.BuildOption, self.BuildTarget =3D Parser.parse_args() diff --git a/BaseTools/Source/Python/sitecustomize.py b/BaseTools/Source/Py= thon/sitecustomize.py index 50783e1b3af0..a0bc2546bc92 100644 --- a/BaseTools/Source/Python/sitecustomize.py +++ b/BaseTools/Source/Python/sitecustomize.py @@ -1,4 +1,4 @@ -## @file +# @file # # # Copyright (c) 2009 - 2014, Apple Inc. All rights reserved.
        @@ -8,8 +8,7 @@ import sys import locale =20 if sys.platform =3D=3D "darwin" and sys.version_info[0] < 3: - DefaultLocal =3D locale.getdefaultlocale()[1] - if DefaultLocal is None: - DefaultLocal =3D 'UTF8' - sys.setdefaultencoding(DefaultLocal) - + DefaultLocal =3D locale.getdefaultlocale()[1] + if DefaultLocal is None: + DefaultLocal =3D 'UTF8' + sys.setdefaultencoding(DefaultLocal) diff --git a/BaseTools/Source/Python/tests/Split/test_split.py b/BaseTools/= Source/Python/tests/Split/test_split.py index e4866be390b3..4a7a23ba6464 100644 --- a/BaseTools/Source/Python/tests/Split/test_split.py +++ b/BaseTools/Source/Python/tests/Split/test_split.py @@ -59,15 +59,15 @@ class TestSplit(unittest.TestCase): "Binary.bin", "Binary1.bin", r"output/Binary1.bin", - os.path.abspath( r"output/Binary1.bin") - ] + os.path.abspath(r"output/Binary1.bin") + ] expected_output =3D [ - os.path.join(os.path.dirname(self.binary_file),"Binary.bin1" ), - os.path.join(os.getcwd(),"Binary.bin"), - os.path.join(os.getcwd(),"Binary1.bin"), - os.path.join(os.getcwd(),r"output/Binary1.bin"), - os.path.join(os.path.abspath( r"output/Binary1.bin")) - ] + os.path.join(os.path.dirname(self.binary_file), "Binary.bin1"), + os.path.join(os.getcwd(), "Binary.bin"), + os.path.join(os.getcwd(), "Binary1.bin"), + os.path.join(os.getcwd(), r"output/Binary1.bin"), + os.path.join(os.path.abspath(r"output/Binary1.bin")) + ] for index, o in enumerate(output): try: sp.splitFile(self.binary_file, 123, outputfile1=3Do) @@ -84,26 +84,27 @@ class TestSplit(unittest.TestCase): r"output1/output2", os.path.abspath("output"), "output" - ] + ] output =3D [ None, None, "Binary1.bin", r"output/Binary1.bin", - os.path.abspath( r"output_1/Binary1.bin") - ] + os.path.abspath(r"output_1/Binary1.bin") + ] =20 expected_output =3D [ - os.path.join(os.path.dirname(self.binary_file),"Binary.bin1" ), - os.path.join(os.getcwd(),"output", "Binary.bin1"), - os.path.join(os.getcwd(), r"output1/output2" , "Binary1.bin"), - os.path.join(os.getcwd(),r"output", "output/Binary1.bin"), - os.path.join(os.path.abspath( r"output/Binary1.bin")) - ] + os.path.join(os.path.dirname(self.binary_file), "Binary.bin1"), + os.path.join(os.getcwd(), "output", "Binary.bin1"), + os.path.join(os.getcwd(), r"output1/output2", "Binary1.bin"), + os.path.join(os.getcwd(), r"output", "output/Binary1.bin"), + os.path.join(os.path.abspath(r"output/Binary1.bin")) + ] =20 for index, o in enumerate(outputfolder): try: - sp.splitFile(self.binary_file, 123, outputdir=3Do,outputfi= le1=3Doutput[index]) + sp.splitFile(self.binary_file, 123, outputdir=3Do, + outputfile1=3Doutput[index]) except Exception as e: self.assertTrue(False, msg=3D"splitFile function error") =20 diff --git a/BaseTools/Tests/CToolsTests.py b/BaseTools/Tests/CToolsTests.py index 2bc1b62d40ba..b487dc4f7f05 100644 --- a/BaseTools/Tests/CToolsTests.py +++ b/BaseTools/Tests/CToolsTests.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for C based BaseTools # # Copyright (c) 2008, Intel Corporation. All rights reserved.
        @@ -16,14 +16,14 @@ import unittest import TianoCompress modules =3D ( TianoCompress, - ) +) =20 =20 def TheTestSuite(): suites =3D list(map(lambda module: module.TheTestSuite(), modules)) return unittest.TestSuite(suites) =20 + if __name__ =3D=3D '__main__': allTests =3D TheTestSuite() unittest.TextTestRunner().run(allTests) - diff --git a/BaseTools/Tests/CheckPythonSyntax.py b/BaseTools/Tests/CheckPy= thonSyntax.py index 099920721f5a..cf37e452d8f3 100644 --- a/BaseTools/Tests/CheckPythonSyntax.py +++ b/BaseTools/Tests/CheckPythonSyntax.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for checking syntax of Python source code # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
        @@ -15,6 +15,7 @@ import py_compile =20 import TestTools =20 + class Tests(TestTools.BaseToolsTest): =20 def setUp(self): @@ -26,6 +27,7 @@ class Tests(TestTools.BaseToolsTest): except Exception as e: self.fail('syntax error: %s, Error is %s' % (filename, str(e))) =20 + def MakePythonSyntaxCheckTests(): def GetAllPythonSourceFiles(): pythonSourceFiles =3D [] @@ -33,8 +35,8 @@ def MakePythonSyntaxCheckTests(): for filename in files: if filename.lower().endswith('.py'): pythonSourceFiles.append( - os.path.join(root, filename) - ) + os.path.join(root, filename) + ) return pythonSourceFiles =20 def MakeTestName(filename): @@ -46,16 +48,17 @@ def MakePythonSyntaxCheckTests(): =20 def MakeNewTest(filename): test =3D MakeTestName(filename) - newmethod =3D lambda self: self.SingleFileTest(filename) + def newmethod(self): return self.SingleFileTest(filename) setattr( Tests, test, newmethod - ) + ) =20 for filename in GetAllPythonSourceFiles(): MakeNewTest(filename) =20 + MakePythonSyntaxCheckTests() del MakePythonSyntaxCheckTests =20 @@ -64,5 +67,3 @@ TheTestSuite =3D TestTools.MakeTheTestSuite(locals()) if __name__ =3D=3D '__main__': allTests =3D TheTestSuite() unittest.TextTestRunner().run(allTests) - - diff --git a/BaseTools/Tests/CheckUnicodeSourceFiles.py b/BaseTools/Tests/C= heckUnicodeSourceFiles.py index 1502402619e1..ede49af0e2b1 100644 --- a/BaseTools/Tests/CheckUnicodeSourceFiles.py +++ b/BaseTools/Tests/CheckUnicodeSourceFiles.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for AutoGen.UniClassObject # # Copyright (c) 2015, Intel Corporation. All rights reserved.
        @@ -22,6 +22,7 @@ import AutoGen.UniClassObject as BtUni from Common import EdkLogger EdkLogger.InitializeForUnitTest() =20 + class Tests(TestTools.BaseToolsTest): =20 SampleData =3D u''' @@ -168,6 +169,7 @@ class Tests(TestTools.BaseToolsTest): =20 self.CheckFile(encoding=3DNone, shouldPass=3DFalse, string=3Ddata) =20 + TheTestSuite =3D TestTools.MakeTheTestSuite(locals()) =20 if __name__ =3D=3D '__main__': diff --git a/BaseTools/Tests/PythonTest.py b/BaseTools/Tests/PythonTest.py index ec44c7947086..f5480eb6b611 100644 --- a/BaseTools/Tests/PythonTest.py +++ b/BaseTools/Tests/PythonTest.py @@ -1,4 +1,4 @@ -## @file +# @file # Test whether PYTHON_COMMAND is available # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
        diff --git a/BaseTools/Tests/PythonToolsTests.py b/BaseTools/Tests/PythonTo= olsTests.py index 05b27ab03335..3258c8aa4d27 100644 --- a/BaseTools/Tests/PythonToolsTests.py +++ b/BaseTools/Tests/PythonToolsTests.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for Python based BaseTools # # Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
        @@ -22,7 +22,7 @@ def TheTestSuite(): suites.append(CheckUnicodeSourceFiles.TheTestSuite()) return unittest.TestSuite(suites) =20 + if __name__ =3D=3D '__main__': allTests =3D TheTestSuite() unittest.TextTestRunner().run(allTests) - diff --git a/BaseTools/Tests/RunTests.py b/BaseTools/Tests/RunTests.py index 934683a44654..ae16599bb45f 100644 --- a/BaseTools/Tests/RunTests.py +++ b/BaseTools/Tests/RunTests.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for BaseTools utilities # # Copyright (c) 2008, Intel Corporation. All rights reserved.
        @@ -15,18 +15,21 @@ import unittest =20 import TestTools =20 + def GetCTestSuite(): import CToolsTests return CToolsTests.TheTestSuite() =20 + def GetPythonTestSuite(): import PythonToolsTests return PythonToolsTests.TheTestSuite() =20 + def GetAllTestsSuite(): return unittest.TestSuite([GetCTestSuite(), GetPythonTestSuite()]) =20 + if __name__ =3D=3D '__main__': allTests =3D GetAllTestsSuite() unittest.TextTestRunner(verbosity=3D2).run(allTests) - diff --git a/BaseTools/Tests/TestRegularExpression.py b/BaseTools/Tests/Tes= tRegularExpression.py index 3e6c5f446383..3b6190978714 100644 --- a/BaseTools/Tests/TestRegularExpression.py +++ b/BaseTools/Tests/TestRegularExpression.py @@ -1,4 +1,4 @@ -## @file +# @file # Routines for generating Pcd Database # # Copyright (c) 2018, Intel Corporation. All rights reserved.
        @@ -8,6 +8,7 @@ import unittest from Common.Misc import RemoveCComments from Workspace.BuildClassObject import ArrayIndex =20 + class TestRe(unittest.TestCase): def test_ccomments(self): TestStr1 =3D """ {0x01,0x02} """ @@ -42,7 +43,9 @@ class TestRe(unittest.TestCase): self.assertEquals(['[1]'], ArrayIndex.findall(TestStr1)) =20 TestStr2 =3D """[1][2][0x1][0x01][]""" - self.assertEquals(['[1]','[2]','[0x1]','[0x01]','[]'], ArrayIndex.= findall(TestStr2)) + self.assertEquals(['[1]', '[2]', '[0x1]', '[0x01]', + '[]'], ArrayIndex.findall(TestStr2)) + =20 if __name__ =3D=3D '__main__': unittest.main() diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py index 1099fd4eeaea..3ff294721aef 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -1,5 +1,5 @@ from __future__ import print_function -## @file +# @file # Utility functions and classes for BaseTools unit tests # # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
        @@ -33,6 +33,7 @@ if PythonSourceDir not in sys.path: # sys.path.append(PythonSourceDir) =20 + def MakeTheTestSuite(localItems): tests =3D [] for name, item in localItems.items(): @@ -43,26 +44,30 @@ def MakeTheTestSuite(localItems): tests.append(item()) return lambda: unittest.TestSuite(tests) =20 + def GetBaseToolsPaths(): if sys.platform in ('win32', 'win64'): - return [ os.path.join(BaseToolsDir, 'Bin', sys.platform.title()) ] + return [os.path.join(BaseToolsDir, 'Bin', sys.platform.title())] else: uname =3D os.popen('uname -sm').read().strip() for char in (' ', '/'): uname =3D uname.replace(char, '-') return [ - os.path.join(BaseToolsDir, 'Bin', uname), - os.path.join(BaseToolsDir, 'BinWrappers', uname), - os.path.join(BaseToolsDir, 'BinWrappers', 'PosixLike') - ] + os.path.join(BaseToolsDir, 'Bin', uname), + os.path.join(BaseToolsDir, 'BinWrappers', uname), + os.path.join(BaseToolsDir, 'BinWrappers', 'PosixLike') + ] + =20 BaseToolsBinPaths =3D GetBaseToolsPaths() =20 + class BaseToolsTest(unittest.TestCase): =20 def cleanOutDir(self, dir): for dirItem in os.listdir(dir): - if dirItem in ('.', '..'): continue + if dirItem in ('.', '..'): + continue dirItem =3D os.path.join(dir, dirItem) self.RemoveFileOrDir(dirItem) =20 @@ -103,12 +108,17 @@ class BaseToolsTest(unittest.TestCase): return bin =20 def RunTool(self, *args, **kwd): - if 'toolName' in kwd: toolName =3D kwd['toolName'] - else: toolName =3D None - if 'logFile' in kwd: logFile =3D kwd['logFile'] - else: logFile =3D None + if 'toolName' in kwd: + toolName =3D kwd['toolName'] + else: + toolName =3D None + if 'logFile' in kwd: + logFile =3D kwd['logFile'] + else: + logFile =3D None =20 - if toolName is None: toolName =3D self.toolName + if toolName is None: + toolName =3D self.toolName bin =3D self.FindToolBin(toolName) if logFile is not None: logFile =3D open(os.path.join(self.testDir, logFile), 'w') @@ -121,7 +131,7 @@ class BaseToolsTest(unittest.TestCase): Proc =3D subprocess.Popen( args, executable=3Dbin, stdout=3DpopenOut, stderr=3Dsubprocess.STDOUT - ) + ) =20 if logFile is None: Proc.stdout.read() @@ -131,7 +141,7 @@ class BaseToolsTest(unittest.TestCase): def GetTmpFilePath(self, fileName): return os.path.join(self.testDir, fileName) =20 - def OpenTmpFile(self, fileName, mode =3D 'r'): + def OpenTmpFile(self, fileName, mode=3D'r'): return open(os.path.join(self.testDir, fileName), mode) =20 def ReadTmpFile(self, fileName): @@ -148,19 +158,22 @@ class BaseToolsTest(unittest.TestCase): with codecs.open(self.GetTmpFilePath(fileName), 'w', encoding= =3D'utf-8') as f: f.write(data) =20 - def GenRandomFileData(self, fileName, minlen =3D None, maxlen =3D None= ): - if maxlen is None: maxlen =3D minlen + def GenRandomFileData(self, fileName, minlen=3DNone, maxlen=3DNone): + if maxlen is None: + maxlen =3D minlen f =3D self.OpenTmpFile(fileName, 'w') f.write(self.GetRandomString(minlen, maxlen)) f.close() =20 - def GetRandomString(self, minlen =3D None, maxlen =3D None): - if minlen is None: minlen =3D 1024 - if maxlen is None: maxlen =3D minlen + def GetRandomString(self, minlen=3DNone, maxlen=3DNone): + if minlen is None: + minlen =3D 1024 + if maxlen is None: + maxlen =3D minlen return ''.join( [chr(random.randint(0, 255)) for x in range(random.randint(minlen, maxlen)) - ]) + ]) =20 def setUp(self): self.savedEnvPath =3D os.environ['PATH'] @@ -181,4 +194,3 @@ class BaseToolsTest(unittest.TestCase): =20 os.environ['PATH'] =3D self.savedEnvPath sys.path =3D self.savedSysPath - diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompre= ss.py index 685968b18fb3..ffe0ae61a11f 100644 --- a/BaseTools/Tests/TianoCompress.py +++ b/BaseTools/Tests/TianoCompress.py @@ -1,4 +1,4 @@ -## @file +# @file # Unit tests for TianoCompress utility # # Copyright (c) 2008, Intel Corporation. All rights reserved.
        @@ -17,6 +17,7 @@ import unittest =20 import TestTools =20 + class Tests(TestTools.BaseToolsTest): =20 def setUp(self): @@ -25,7 +26,7 @@ class Tests(TestTools.BaseToolsTest): =20 def testHelp(self): result =3D self.RunTool('--help', logFile=3D'help') - #self.DisplayFile('help') + # self.DisplayFile('help') self.assertTrue(result =3D=3D 0) =20 def compressionTestCycle(self, data): @@ -35,13 +36,13 @@ class Tests(TestTools.BaseToolsTest): '-e', '-o', self.GetTmpFilePath('output1'), self.GetTmpFilePath('input') - ) + ) self.assertTrue(result =3D=3D 0) result =3D self.RunTool( '-d', '-o', self.GetTmpFilePath('output2'), self.GetTmpFilePath('output1') - ) + ) self.assertTrue(result =3D=3D 0) start =3D self.ReadTmpFile('input') finish =3D self.ReadTmpFile('output2') @@ -50,7 +51,8 @@ class Tests(TestTools.BaseToolsTest): print() print('Original data did not match decompress(compress(data))') self.DisplayBinaryData('original data', start) - self.DisplayBinaryData('after compression', self.ReadTmpFile('= output1')) + self.DisplayBinaryData('after compression', + self.ReadTmpFile('output1')) self.DisplayBinaryData('after decompression', finish) self.assertTrue(startEqualsFinish) =20 @@ -60,10 +62,9 @@ class Tests(TestTools.BaseToolsTest): self.compressionTestCycle(data) self.CleanUpTmpDir() =20 + TheTestSuite =3D TestTools.MakeTheTestSuite(locals()) =20 if __name__ =3D=3D '__main__': allTests =3D TheTestSuite() unittest.TextTestRunner().run(allTests) - - --=20 2.37.3 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94950): https://edk2.groups.io/g/devel/message/94950 Mute This Topic: https://groups.io/mt/94244921/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-