]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Object / Parser / InfMisc.py
1 ## @file
2 # This file is used to define class objects of INF file miscellaneous.
3 # Include BootMode/HOB/Event and others. It will consumed by InfParser.
4 #
5 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
6 #
7 # SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 '''
10 InfMisc
11 '''
12
13 import Logger.Log as Logger
14 from Logger import ToolError
15
16 from Library import DataType as DT
17 from Object.Parser.InfCommonObject import InfSectionCommonDef
18 from Library.Misc import Sdict
19
20 ##
21 # BootModeObject
22 #
23 class InfBootModeObject():
24 def __init__(self):
25 self.SupportedBootModes = ''
26 self.HelpString = ''
27 self.Usage = ''
28
29 def SetSupportedBootModes(self, SupportedBootModes):
30 self.SupportedBootModes = SupportedBootModes
31 def GetSupportedBootModes(self):
32 return self.SupportedBootModes
33
34 def SetHelpString(self, HelpString):
35 self.HelpString = HelpString
36 def GetHelpString(self):
37 return self.HelpString
38
39 def SetUsage(self, Usage):
40 self.Usage = Usage
41 def GetUsage(self):
42 return self.Usage
43 ##
44 # EventObject
45 #
46 class InfEventObject():
47 def __init__(self):
48 self.EventType = ''
49 self.HelpString = ''
50 self.Usage = ''
51
52 def SetEventType(self, EventType):
53 self.EventType = EventType
54
55 def GetEventType(self):
56 return self.EventType
57
58 def SetHelpString(self, HelpString):
59 self.HelpString = HelpString
60 def GetHelpString(self):
61 return self.HelpString
62
63 def SetUsage(self, Usage):
64 self.Usage = Usage
65 def GetUsage(self):
66 return self.Usage
67 ##
68 # HobObject
69 #
70 class InfHobObject():
71 def __init__(self):
72 self.HobType = ''
73 self.Usage = ''
74 self.SupArchList = []
75 self.HelpString = ''
76
77 def SetHobType(self, HobType):
78 self.HobType = HobType
79
80 def GetHobType(self):
81 return self.HobType
82
83 def SetUsage(self, Usage):
84 self.Usage = Usage
85 def GetUsage(self):
86 return self.Usage
87
88 def SetSupArchList(self, ArchList):
89 self.SupArchList = ArchList
90 def GetSupArchList(self):
91 return self.SupArchList
92
93 def SetHelpString(self, HelpString):
94 self.HelpString = HelpString
95 def GetHelpString(self):
96 return self.HelpString
97
98 ##
99 # InfSpecialCommentObject
100 #
101 class InfSpecialCommentObject(InfSectionCommonDef):
102 def __init__(self):
103 self.SpecialComments = Sdict()
104 InfSectionCommonDef.__init__(self)
105
106 def SetSpecialComments(self, SepcialSectionList = None, Type = ''):
107 if Type == DT.TYPE_HOB_SECTION or \
108 Type == DT.TYPE_EVENT_SECTION or \
109 Type == DT.TYPE_BOOTMODE_SECTION:
110 for Item in SepcialSectionList:
111 if Type in self.SpecialComments:
112 ObjList = self.SpecialComments[Type]
113 ObjList.append(Item)
114 self.SpecialComments[Type] = ObjList
115 else:
116 ObjList = []
117 ObjList.append(Item)
118 self.SpecialComments[Type] = ObjList
119
120 return True
121
122 def GetSpecialComments(self):
123 return self.SpecialComments
124
125
126
127 ## ErrorInInf
128 #
129 # An encapsulate of Error for INF parser.
130 #
131 def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):
132 if ErrorCode is None:
133 ErrorCode = ToolError.FORMAT_INVALID
134 if LineInfo is None:
135 LineInfo = ['', -1, '']
136 Logger.Error("InfParser",
137 ErrorCode,
138 Message=Message,
139 File=LineInfo[0],
140 Line=LineInfo[1],
141 ExtraData=LineInfo[2],
142 RaiseError=RaiseError)