def __init__(self):
     self.CommonDefines = CommonDefinesXml()
     self.EntryPoint = ''
     self.UnloadImage = ''
     self.Constructor = ''
     self.Destructor = ''
     self.SupModList = ''
     self.SupArchList = ''
     self.HelpText = []
 def __init__(self):
     self.CommonDefines = CommonDefinesXml()
     self.ModuleType = ''
     self.Path = ''
     self.PcdIsDriver = ''
     self.UefiSpecificationVersion = ''
     self.PiSpecificationVersion = ''
     self.SpecificationList = []
     self.SpecificationVersion = ''
     self.BootModes = []
     self.Events = []
     self.HOBs = []
Ejemplo n.º 3
0
 def __init__(self):
     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 = CommonDefinesXml()
     self.Prompt = []
     self.HelpText = []
     self.PcdError = []
Ejemplo n.º 4
0
 def __init__(self, Mode):
     self.UiName = ''
     self.GuidTypes = ''
     self.Notify = ''
     self.CName = ''
     self.GuidValue = ''
     self.CommonDefines = CommonDefinesXml()
     self.HelpText = []
     #
     # Guid/Ppi/Library, internal used for indicate return object for
     # FromXml
     #
     self.Type = ''
     #
     # there are slightly different field between package and module
     #
     self.Mode = Mode
     self.GuidType = ''
     self.VariableName = ''
class ExternXml(object):
    def __init__(self):
        self.CommonDefines = CommonDefinesXml()
        self.EntryPoint = ''
        self.UnloadImage = ''
        self.Constructor = ''
        self.Destructor = ''
        self.SupModList = ''
        self.SupArchList = ''
        self.HelpText = []

    def FromXml(self, Item, Key):
        self.CommonDefines.FromXml(Item, Key)
        self.EntryPoint = XmlElement(Item, '%s/EntryPoint' % Key)
        self.UnloadImage = XmlElement(Item, '%s/UnloadImage' % Key)
        self.Constructor = XmlElement(Item, '%s/Constructor' % Key)
        self.Destructor = XmlElement(Item, '%s/Destructor' % Key)

        Extern = ExternObject()
        Extern.SetEntryPoint(self.EntryPoint)
        Extern.SetUnloadImage(self.UnloadImage)
        Extern.SetConstructor(self.Constructor)
        Extern.SetDestructor(self.Destructor)
        if self.CommonDefines.SupModList:
            Extern.SetSupModList(self.CommonDefines.SupModList)
        if self.CommonDefines.SupArchList:
            Extern.SetSupArchList(self.CommonDefines.SupArchList)
        return Extern

    def ToXml(self, Extern, Key):
        if self.HelpText:
            pass

        NodeList = []
        if Extern.GetEntryPoint():
            NodeList.append(['EntryPoint', Extern.GetEntryPoint()])
        if Extern.GetUnloadImage():
            NodeList.append(['UnloadImage', Extern.GetUnloadImage()])
        if Extern.GetConstructor():
            NodeList.append(['Constructor', Extern.GetConstructor()])
        if Extern.GetDestructor():
            NodeList.append(['Destructor', Extern.GetDestructor()])
        Root = CreateXmlElement('%s' % Key, '', NodeList, [])

        return Root

    def __str__(self):
        Str = "EntryPoint = %s UnloadImage = %s Constructor = %s Destructor = %s %s" \
              % (self.EntryPoint, self.UnloadImage, self.Constructor, self.Destructor, self.CommonDefines)
        for Item in self.HelpText:
            Str = Str + '\n\t' + str(Item)
        return Str
class PackageXml(object):
    def __init__(self):
        self.Description = ''
        self.Guid = ''
        self.Version = ''
        self.CommonDefines = CommonDefinesXml()

    def FromXml(self, Item, Key):
        self.Description = XmlElement(Item, '%s/Description' % Key)
        self.Guid = XmlElement(Item, '%s/GUID' % Key)
        self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version')
        self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)

        PackageDependency = PackageDependencyObject()
        PackageDependency.SetPackage(self.Description)
        PackageDependency.SetGuid(self.Guid)
        PackageDependency.SetVersion(self.Version)
        PackageDependency.SetFeatureFlag(
            ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
        PackageDependency.SetSupArchList(self.CommonDefines.SupArchList)

        return PackageDependency

    def ToXml(self, PackageDependency, Key):
        if self.Guid:
            pass
        AttributeList = [
            [
                'SupArchList',
                GetStringOfList(PackageDependency.GetSupArchList())
            ],
            [
                'FeatureFlag',
                ConvertNEToNOTEQ(PackageDependency.GetFeatureFlag())
            ],
        ]
        Element1 = CreateXmlElement(
            'GUID', PackageDependency.GetGuid(), [],
            [['Version', PackageDependency.GetVersion()]])
        NodeList = [
            ['Description', PackageDependency.GetPackage()],
            Element1,
        ]
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = "Description = %s Guid = %s Version = %s %s" \
              % (self.Description, self.Guid, self.Version, self.CommonDefines)
        return Str
class HobXml(object):
    def __init__(self):
        self.HobType = ''
        self.Name = ''
        self.CommonDefines = CommonDefinesXml()
        self.HelpText = []

    def FromXml(self, Item, Key):
        self.HobType = XmlAttribute(XmlNode(Item, '%s' % Key), 'HobType')
        self.Name = XmlElement(Item, '%s' % Key)
        self.CommonDefines.FromXml(Item, Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)

        Hob = HobObject()
        Hob.SetHobType(self.HobType)
        Hob.SetSupArchList(self.CommonDefines.SupArchList)
        Hob.SetUsage(self.CommonDefines.Usage)
        Hob.SetHelpTextList(GetHelpTextList(self.HelpText))

        return Hob

    def ToXml(self, Hob, Key):
        if self.Name:
            pass
        AttributeList = [
            ['HobType', Hob.GetHobType()],
            ['Usage', Hob.GetUsage()],
            ['SupArchList',
             GetStringOfList(Hob.GetSupArchList())],
        ]
        NodeList = []
        for Item in Hob.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item, 'HelpText'))
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = "HobType = %s %s" % (self.HobType, self.CommonDefines)
        for Item in self.HelpText:
            Str = Str + '\n\t' + str(Item)
        return Str
class DepexXml(object):
    def __init__(self):
        self.CommonDefines = CommonDefinesXml()
        self.Expression = None
        self.HelpText = []

    def FromXml(self, Item, Key):
        if not Item:
            return None
        self.CommonDefines.FromXml(Item, Key)
        self.Expression = XmlElement(Item, '%s/Expression' % Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)

        Depex = DepexObject()
        Depex.SetDepex(self.Expression)
        Depex.SetModuleType(self.CommonDefines.SupModList)
        Depex.SetSupArchList(self.CommonDefines.SupArchList)
        Depex.SetFeatureFlag(self.CommonDefines.FeatureFlag)
        Depex.SetHelpTextList(GetHelpTextList(self.HelpText))

        return Depex

    def ToXml(self, Depex, Key):
        if self.HelpText:
            pass
        AttributeList = [[
            'SupArchList',
            GetStringOfList(Depex.GetSupArchList())
        ], ['SupModList', Depex.GetModuleType()]]
        NodeList = [['Expression', Depex.GetDepex()]]
        if Depex.GetHelpText():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Depex.GetHelpText(), 'HelpText'))

        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
        return Root

    def __str__(self):
        Str = "Expression = %s" % (self.Expression)
        for Item in self.HelpText:
            Str = Str + '\n\t' + str(Item)
        return Str
class EventXml(object):
    def __init__(self):
        self.EventType = ''
        self.Name = ''
        self.CommonDefines = CommonDefinesXml()
        self.HelpText = []

    def FromXml(self, Item, Key):
        self.EventType = XmlAttribute(XmlNode(Item, '%s' % Key), 'EventType')
        self.Name = XmlElement(Item, '%s' % Key)
        self.CommonDefines.FromXml(Item, Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)

        Event = EventObject()
        Event.SetEventType(self.EventType)
        Event.SetUsage(self.CommonDefines.Usage)
        Event.SetHelpTextList(GetHelpTextList(self.HelpText))

        return Event

    def ToXml(self, Event, Key):
        if self.HelpText:
            pass
        AttributeList = [
            ['EventType', Event.GetEventType()],
            ['Usage', Event.GetUsage()],
        ]
        NodeList = []
        for Item in Event.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item, 'HelpText'))
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = "EventType = %s %s" % (self.EventType, self.CommonDefines)
        for Item in self.HelpText:
            Str = Str + '\n\t' + str(Item)
        return Str
class BootModeXml(object):
    def __init__(self):
        self.SupportedBootModes = ''
        self.CommonDefines = CommonDefinesXml()
        self.HelpText = []

    def FromXml(self, Item, Key):
        self.SupportedBootModes = \
        XmlElement(Item, '%s/SupportedBootModes' % Key)
        self.CommonDefines.FromXml(Item, Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)

        BootMode = BootModeObject()
        BootMode.SetSupportedBootModes(self.SupportedBootModes)
        BootMode.SetUsage(self.CommonDefines.Usage)
        BootMode.SetHelpTextList(GetHelpTextList(self.HelpText))

        return BootMode

    def ToXml(self, BootMode, Key):
        if self.HelpText:
            pass
        AttributeList = [
            ['Usage', BootMode.GetUsage()],
        ]
        NodeList = [['SupportedBootModes', BootMode.GetSupportedBootModes()]]
        for Item in BootMode.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item, 'HelpText'))
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = "SupportedBootModes = %s %s" % (self.SupportedBootModes,
                                              self.CommonDefines)
        for Item in self.HelpText:
            Str = Str + '\n\t' + str(Item)
        return Str
class SourceFileXml(object):
    def __init__(self):
        self.SourceFile = ''
        self.ToolChainFamily = ''
        self.FileType = ''
        self.CommonDefines = CommonDefinesXml()

    def FromXml(self, Item, Key):
        self.ToolChainFamily = XmlAttribute(Item, 'Family')
        self.SourceFile = XmlElement(Item, 'Filename')
        self.CommonDefines.FromXml(Item, Key)

        self.CommonDefines.FeatureFlag = ConvertNOTEQToNE(
            self.CommonDefines.FeatureFlag)

        SourceFile = SourceFileObject()
        SourceFile.SetSourceFile(self.SourceFile)
        SourceFile.SetFamily(self.ToolChainFamily)
        SourceFile.SetSupArchList(self.CommonDefines.SupArchList)
        SourceFile.SetFeatureFlag(self.CommonDefines.FeatureFlag)

        return SourceFile

    def ToXml(self, SourceFile, Key):
        if self.SourceFile:
            pass
        FeatureFlag = ConvertNEToNOTEQ(SourceFile.GetFeatureFlag())
        AttributeList = [
            ['SupArchList',
             GetStringOfList(SourceFile.GetSupArchList())],
            ['Family', SourceFile.GetFamily()],
            ['FeatureFlag', FeatureFlag],
        ]
        Root = CreateXmlElement('%s' % Key, SourceFile.GetSourceFile(), [],
                                AttributeList)
        return Root
class ModulePropertyXml(object):
    def __init__(self):
        self.CommonDefines = CommonDefinesXml()
        self.ModuleType = ''
        self.Path = ''
        self.PcdIsDriver = ''
        self.UefiSpecificationVersion = ''
        self.PiSpecificationVersion = ''
        self.SpecificationList = []
        self.SpecificationVersion = ''
        self.BootModes = []
        self.Events = []
        self.HOBs = []

    def FromXml(self, Item, Key, Header=None):
        self.CommonDefines.FromXml(Item, Key)
        self.ModuleType = XmlElement(Item, '%s/ModuleType' % Key)
        self.Path = XmlElement(Item, '%s/Path' % Key)
        self.PcdIsDriver = XmlElement(Item, '%s/PcdIsDriver' % Key)
        self.UefiSpecificationVersion = XmlElement(
            Item, '%s/UefiSpecificationVersion' % Key)
        self.PiSpecificationVersion = XmlElement(
            Item, '%s/PiSpecificationVersion' % Key)
        for SubItem in XmlList(Item, '%s/Specification' % Key):
            Specification = XmlElement(SubItem, '/Specification')
            Version = XmlAttribute(XmlNode(SubItem, '/Specification'),
                                   'Version')
            self.SpecificationList.append((Specification, Version))
        for SubItem in XmlList(Item, '%s/BootMode' % Key):
            Axml = BootModeXml()
            BootMode = Axml.FromXml(SubItem, 'BootMode')
            self.BootModes.append(BootMode)
        for SubItem in XmlList(Item, '%s/Event' % Key):
            Axml = EventXml()
            Event = Axml.FromXml(SubItem, 'Event')
            self.Events.append(Event)
        for SubItem in XmlList(Item, '%s/HOB' % Key):
            Axml = HobXml()
            Hob = Axml.FromXml(SubItem, 'HOB')
            self.HOBs.append(Hob)

        if Header is None:
            Header = ModuleObject()

        Header.SetModuleType(self.ModuleType)
        Header.SetSupArchList(self.CommonDefines.SupArchList)
        Header.SetModulePath(self.Path)

        Header.SetPcdIsDriver(self.PcdIsDriver)
        Header.SetUefiSpecificationVersion(self.UefiSpecificationVersion)
        Header.SetPiSpecificationVersion(self.PiSpecificationVersion)
        Header.SetSpecList(self.SpecificationList)

        return Header, self.BootModes, self.Events, self.HOBs

    def ToXml(self, Header, BootModes, Events, Hobs, Key):
        if self.ModuleType:
            pass
        AttributeList = [
            ['SupArchList',
             GetStringOfList(Header.GetSupArchList())],
        ]

        NodeList = [
            ['ModuleType', Header.GetModuleType()],
            ['Path', Header.GetModulePath()],
            ['PcdIsDriver', Header.GetPcdIsDriver()],
            ['UefiSpecificationVersion',
             Header.GetUefiSpecificationVersion()],
            ['PiSpecificationVersion',
             Header.GetPiSpecificationVersion()],
        ]
        for Item in Header.GetSpecList():
            Spec, Version = Item
            SpecElem = CreateXmlElement('Specification', Spec, [],
                                        [['Version', Version]])
            NodeList.append(SpecElem)

        for Item in BootModes:
            Tmp = BootModeXml()
            NodeList.append(Tmp.ToXml(Item, 'BootMode'))
        for Item in Events:
            Tmp = EventXml()
            NodeList.append(Tmp.ToXml(Item, 'Event'))
        for Item in Hobs:
            Tmp = HobXml()
            NodeList.append(Tmp.ToXml(Item, 'HOB'))
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = "ModuleType = %s Path = %s PcdIsDriver = %s UefiSpecificationVersion = %s PiSpecificationVersion = %s \
               Specification = %s SpecificationVersion = %s %s"                                                                % \
        (self.ModuleType, self.Path, self.PcdIsDriver, \
         self.UefiSpecificationVersion, self.PiSpecificationVersion, \
         self.SpecificationList, self.SpecificationVersion, self.CommonDefines)
        for Item in self.BootModes:
            Str = Str + '\n\t' + str(Item)
        for Item in self.Events:
            Str = Str + '\n\t' + str(Item)
        for Item in self.HOBs:
            Str = Str + '\n\t' + str(Item)
        return Str
 def __init__(self):
     self.SourceFile = ''
     self.ToolChainFamily = ''
     self.FileType = ''
     self.CommonDefines = CommonDefinesXml()
 def __init__(self):
     self.HobType = ''
     self.Name = ''
     self.CommonDefines = CommonDefinesXml()
     self.HelpText = []
Ejemplo n.º 15
0
class PcdEntryXml(object):
    def __init__(self):
        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 = CommonDefinesXml()
        self.Prompt = []
        self.HelpText = []
        self.PcdError = []

    ##
    # AsBuilt will use FromXml
    #
    def FromXml(self, Item, Key):
        self.PcdItemType = \
        XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType')
        self.PcdUsage = XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdUsage')
        self.TokenSpaceGuidCName = \
        XmlElement(Item, '%s/TokenSpaceGuidCname' % Key)
        self.TokenSpaceGuidValue = \
        XmlElement(Item, '%s/TokenSpaceGuidValue' % Key)
        self.Token = XmlElement(Item, '%s/Token' % Key)
        self.CName = XmlElement(Item, '%s/CName' % Key)
        self.PcdCName = XmlElement(Item, '%s/PcdCName' % Key)
        self.DatumType = XmlElement(Item, '%s/DatumType' % Key)
        self.ValidUsage = XmlElement(Item, '%s/ValidUsage' % Key)
        if not GlobalData.gIS_BINARY_INF:
            self.DefaultValue = XmlElement(Item, '%s/DefaultValue' % Key)
        else:
            self.DefaultValue = XmlElement(Item, '%s/Value' % Key)
        self.MaxDatumSize = XmlElement(Item, '%s/MaxDatumSize' % Key)
        self.Value = XmlElement(Item, '%s/Value' % Key)
        self.Offset = XmlElement(Item, '%s/Offset' % Key)
        self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)

        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)
        for PcdErrorItem in XmlList(Item, '%s/PcdError' % Key):
            PcdErrorObjXml = PcdErrorXml()
            PcdErrorObj = PcdErrorObjXml.FromXml(PcdErrorItem, 'PcdError')
            self.PcdError.append(PcdErrorObj)

        self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)

        PcdEntry = PcdObject()
        PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
        PcdEntry.SetTokenSpaceGuidCName(self.TokenSpaceGuidCName)
        PcdEntry.SetTokenSpaceGuidValue(self.TokenSpaceGuidValue)
        PcdEntry.SetToken(self.Token)
        PcdEntry.SetOffset(self.Offset)
        PcdEntry.SetCName(self.CName)
        PcdEntry.SetPcdCName(self.PcdCName)
        PcdEntry.SetDatumType(self.DatumType)
        PcdEntry.SetValidUsage(self.ValidUsage)
        PcdEntry.SetDefaultValue(self.DefaultValue)
        PcdEntry.SetMaxDatumSize(self.MaxDatumSize)
        PcdEntry.SetFeatureFlag(
            ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
        PcdEntry.SetItemType(self.PcdItemType)

        PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
        PcdEntry.SetPcdErrorsList(self.PcdError)

        return PcdEntry

    ##
    # Package will use FromXml2
    #
    def FromXml2(self, Item, Key):
        self.TokenSpaceGuidCName = \
        XmlElement(Item, '%s/TokenSpaceGuidCname' % Key)
        self.Token = XmlElement(Item, '%s/Token' % Key)
        self.CName = XmlElement(Item, '%s/CName' % Key)
        self.DatumType = XmlElement(Item, '%s/DatumType' % Key)
        self.ValidUsage = XmlElement(Item, '%s/ValidUsage' % Key)
        self.DefaultValue = XmlElement(Item, '%s/DefaultValue' % Key)
        self.MaxDatumSize = XmlElement(Item, '%s/MaxDatumSize' % Key)
        self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)
        for PromptItem in XmlList(Item, '%s/Prompt' % Key):
            PromptObj = PromptXml()
            PromptObj.FromXml(PromptItem, '%s/Prompt' % Key)
            self.Prompt.append(PromptObj)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)
        for PcdErrorItem in XmlList(Item, '%s/PcdError' % Key):
            PcdErrorObjXml = PcdErrorXml()
            PcdErrorObj = PcdErrorObjXml.FromXml(PcdErrorItem, 'PcdError')
            self.PcdError.append(PcdErrorObj)

        self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)

        PcdEntry = PcdObject()
        PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
        PcdEntry.SetSupModuleList(self.CommonDefines.SupModList)
        PcdEntry.SetTokenSpaceGuidCName(self.TokenSpaceGuidCName)
        PcdEntry.SetToken(self.Token)
        PcdEntry.SetCName(self.CName)
        PcdEntry.SetDatumType(self.DatumType)
        PcdEntry.SetValidUsage(self.ValidUsage)
        PcdEntry.SetDefaultValue(self.DefaultValue)
        PcdEntry.SetMaxDatumSize(self.MaxDatumSize)
        PcdEntry.SetFeatureFlag(
            ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))

        PcdEntry.SetPromptList(GetPromptList(self.Prompt))
        PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
        PcdEntry.SetPcdErrorsList(self.PcdError)

        return PcdEntry

    ##
    # Module will use FromXml3
    #
    def FromXml3(self, Item, Key):
        self.PcdItemType = \
        XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType')
        self.PcdUsage = XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdUsage')
        self.TokenSpaceGuidCName = \
        XmlElement(Item, '%s/TokenSpaceGuidCName' % Key)
        self.CName = XmlElement(Item, '%s/CName' % Key)
        self.DefaultValue = XmlElement(Item, '%s/DefaultValue' % Key)
        self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)
        for PcdErrorItem in XmlList(Item, '%s/PcdError' % Key):
            PcdErrorObj = PcdErrorXml()
            PcdErrorObj.FromXml(PcdErrorItem, 'PcdError')
            self.PcdError.append(PcdErrorObj)

        self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)

        PcdEntry = PcdObject()
        PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
        PcdEntry.SetTokenSpaceGuidCName(self.TokenSpaceGuidCName)
        PcdEntry.SetCName(self.CName)
        PcdEntry.SetValidUsage(self.PcdUsage)
        PcdEntry.SetDefaultValue(self.DefaultValue)
        PcdEntry.SetFeatureFlag(
            ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
        PcdEntry.SetItemType(self.PcdItemType)

        PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
        PcdEntry.SetPcdErrorsList(self.PcdError)

        return PcdEntry

    def ToXml(self, PcdEntry, Key):
        if self.PcdCName:
            pass

        DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())

        AttributeList = \
        [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
         ['PcdUsage', PcdEntry.GetValidUsage()], \
         ['PcdItemType', PcdEntry.GetItemType()], \
         ['FeatureFlag', PcdEntry.GetFeatureFlag()],
        ]
        NodeList = [
            ['TokenSpaceGuidCname',
             PcdEntry.GetTokenSpaceGuidCName()],
            ['TokenSpaceGuidValue',
             PcdEntry.GetTokenSpaceGuidValue()],
            ['Token', PcdEntry.GetToken()],
            ['CName', PcdEntry.GetCName()],
            ['DatumType', PcdEntry.GetDatumType()],
            ['ValidUsage',
             GetStringOfList(PcdEntry.GetValidUsage())],
            ['DefaultValue', DefaultValue],
            ['MaxDatumSize', PcdEntry.GetMaxDatumSize()],
            ['Offset', PcdEntry.GetOffset()],
        ]

        for Item in PcdEntry.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item))
        for Item in PcdEntry.GetPcdErrorsList():
            Tmp = PcdErrorXml()
            NodeList.append(Tmp.ToXml(Item, 'PcdError'))

        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    ##
    # Package will use ToXml2
    #
    def ToXml2(self, PcdEntry, Key):
        if self.PcdCName:
            pass

        DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())

        AttributeList = \
        [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
         ['SupModList', GetStringOfList(PcdEntry.GetSupModuleList())]
        ]
        NodeList = [
            ['TokenSpaceGuidCname',
             PcdEntry.GetTokenSpaceGuidCName()],
            ['Token', PcdEntry.GetToken()],
            ['CName', PcdEntry.GetCName()],
            ['DatumType', PcdEntry.GetDatumType()],
            ['ValidUsage',
             GetStringOfList(PcdEntry.GetValidUsage())],
            ['DefaultValue', DefaultValue],
            ['MaxDatumSize', PcdEntry.GetMaxDatumSize()],
        ]
        for Item in PcdEntry.GetPromptList():
            Tmp = PromptXml()
            NodeList.append(Tmp.ToXml(Item))

        for Item in PcdEntry.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item))

        for Item in PcdEntry.GetPcdErrorsList():
            Tmp = PcdErrorXml()
            NodeList.append(Tmp.ToXml(Item, 'PcdError'))

        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    ##
    # Module will use ToXml3
    #
    def ToXml3(self, PcdEntry, Key):
        if self.PcdCName:
            pass

        DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())

        AttributeList = \
        [['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
         ['PcdUsage', PcdEntry.GetValidUsage()], \
         ['PcdItemType', PcdEntry.GetItemType()], \
         ['FeatureFlag', ConvertNEToNOTEQ(PcdEntry.GetFeatureFlag())],
        ]
        NodeList = [
            ['CName', PcdEntry.GetCName()],
            ['TokenSpaceGuidCName',
             PcdEntry.GetTokenSpaceGuidCName()],
            ['DefaultValue', DefaultValue],
        ]

        for Item in PcdEntry.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item))
        for Item in PcdEntry.GetPcdErrorsList():
            Tmp = PcdErrorXml()
            NodeList.append(Tmp.ToXml(Item, 'PcdError'))

        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    ##
    # AsBuild Module will use ToXml4
    #
    def ToXml4(self, PcdEntry, Key):
        if self.PcdCName:
            pass

        DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())

        AttributeList = []

        NodeList = [['TokenSpaceGuidValue',
                     PcdEntry.GetTokenSpaceGuidValue()],
                    ['PcdCName', PcdEntry.GetCName()],
                    ['Token', PcdEntry.GetToken()],
                    ['DatumType', PcdEntry.GetDatumType()],
                    ['MaxDatumSize',
                     PcdEntry.GetMaxDatumSize()], ['Value', DefaultValue],
                    ['Offset', PcdEntry.GetOffset()]]

        for Item in PcdEntry.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item))
        for Item in PcdEntry.GetPcdErrorsList():
            Tmp = PcdErrorXml()
            NodeList.append(Tmp.ToXml(Item, 'PcdError'))

        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = \
        ('PcdItemType = %s PcdUsage = %s TokenSpaceGuidCName = %s \
        TokenSpaceGuidValue = %s Token = %s CName = %s PcdCName = %s \
        DatumType = %s ValidUsage = %s DefaultValue = %s MaxDatumSize = %s \
        Value = %s Offset = %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)
        for Item in self.HelpText:
            Str = Str + "\n\t" + str(Item)
        for Item in self.PcdError:
            Str = Str + "\n\tPcdError:" + str(Item)
        return Str
 def __init__(self):
     self.CommonDefines = CommonDefinesXml()
     self.Expression = None
     self.HelpText = []
 def __init__(self):
     self.Description = ''
     self.Guid = ''
     self.Version = ''
     self.CommonDefines = CommonDefinesXml()
 def __init__(self):
     self.SupportedBootModes = ''
     self.CommonDefines = CommonDefinesXml()
     self.HelpText = []
Ejemplo n.º 19
0
class GuidProtocolPpiXml(object):
    def __init__(self, Mode):
        self.UiName = ''
        self.GuidTypes = ''
        self.Notify = ''
        self.CName = ''
        self.GuidValue = ''
        self.CommonDefines = CommonDefinesXml()
        self.HelpText = []
        #
        # Guid/Ppi/Library, internal used for indicate return object for
        # FromXml
        #
        self.Type = ''
        #
        # there are slightly different field between package and module
        #
        self.Mode = Mode
        self.GuidType = ''
        self.VariableName = ''

    def FromXml(self, Item, Key):
        self.UiName = XmlAttribute(XmlNode(Item, '%s' % Key), 'UiName')
        self.GuidType = XmlAttribute(XmlNode(Item, '%s' % Key), 'GuidType')
        self.Notify = XmlAttribute(XmlNode(Item, '%s' % Key), 'Notify')
        self.CName = XmlElement(Item, '%s/CName' % Key)
        self.GuidValue = XmlElement(Item, '%s/GuidValue' % Key)
        self.VariableName = XmlElement(Item, '%s/VariableName' % Key)
        self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)
        for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
            HelpTextObj = HelpTextXml()
            HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
            self.HelpText.append(HelpTextObj)

        if self.Type == 'Guid':
            GuidProtocolPpi = GuidObject()
        elif self.Type == 'Protocol':
            GuidProtocolPpi = ProtocolObject()
        else:
            GuidProtocolPpi = PpiObject()
        GuidProtocolPpi.SetHelpTextList(GetHelpTextList(self.HelpText))

        return GuidProtocolPpi

    def ToXml(self, GuidProtocolPpi, Key):
        if self.GuidValue:
            pass
        AttributeList = \
        [['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 = [['CName', GuidProtocolPpi.GetCName()],
                    ['GuidValue', GuidProtocolPpi.GetGuid()],
                    ['VariableName', GuidProtocolPpi.VariableName]]
        for Item in GuidProtocolPpi.GetHelpTextList():
            Tmp = HelpTextXml()
            NodeList.append(Tmp.ToXml(Item))
        Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)

        return Root

    def __str__(self):
        Str = \
        "UiName = %s Notify = %s GuidTypes = %s CName = %s GuidValue = %s %s" \
        % (self.UiName, self.Notify, self.GuidTypes, self.CName, \
           self.GuidValue, self.CommonDefines)
        for Item in self.HelpText:
            Str = Str + "\n\t" + str(Item)
        return Str