]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py
BaseTools: Remove the deprecated hash_key()
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Object / Parser / InfMisc.py
CommitLineData
4234283c
LG
1## @file\r
2# This file is used to define class objects of INF file miscellaneous. \r
3# Include BootMode/HOB/Event and others. It will consumed by InfParser. \r
4#\r
5# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
6#\r
7# This program and the accompanying materials are licensed and made available \r
8# under the terms and conditions of the BSD License which accompanies this \r
9# distribution. The full text of the license may be found at \r
10# http://opensource.org/licenses/bsd-license.php\r
11#\r
12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15'''\r
16InfMisc\r
17'''\r
18\r
19import Logger.Log as Logger\r
20from Logger import ToolError\r
21\r
22from Library import DataType as DT\r
23from Object.Parser.InfCommonObject import InfSectionCommonDef\r
24from Library.Misc import Sdict\r
25\r
26## \r
27# BootModeObject\r
28#\r
29class InfBootModeObject():\r
30 def __init__(self):\r
31 self.SupportedBootModes = ''\r
32 self.HelpString = ''\r
33 self.Usage = ''\r
34 \r
35 def SetSupportedBootModes(self, SupportedBootModes):\r
36 self.SupportedBootModes = SupportedBootModes \r
37 def GetSupportedBootModes(self):\r
38 return self.SupportedBootModes\r
39\r
40 def SetHelpString(self, HelpString):\r
41 self.HelpString = HelpString\r
42 def GetHelpString(self):\r
43 return self.HelpString \r
44\r
45 def SetUsage(self, Usage):\r
46 self.Usage = Usage\r
47 def GetUsage(self):\r
48 return self.Usage\r
49##\r
50# EventObject\r
51#\r
52class InfEventObject():\r
53 def __init__(self):\r
54 self.EventType = ''\r
55 self.HelpString = ''\r
56 self.Usage = ''\r
57 \r
58 def SetEventType(self, EventType):\r
59 self.EventType = EventType\r
60 \r
61 def GetEventType(self):\r
62 return self.EventType\r
63 \r
64 def SetHelpString(self, HelpString):\r
65 self.HelpString = HelpString\r
66 def GetHelpString(self):\r
67 return self.HelpString \r
68 \r
69 def SetUsage(self, Usage):\r
70 self.Usage = Usage\r
71 def GetUsage(self):\r
72 return self.Usage\r
73##\r
74# HobObject\r
75#\r
76class InfHobObject():\r
77 def __init__(self):\r
78 self.HobType = ''\r
79 self.Usage = ''\r
80 self.SupArchList = []\r
81 self.HelpString = ''\r
82 \r
83 def SetHobType(self, HobType):\r
84 self.HobType = HobType\r
85 \r
86 def GetHobType(self):\r
87 return self.HobType\r
88 \r
89 def SetUsage(self, Usage):\r
90 self.Usage = Usage\r
91 def GetUsage(self):\r
92 return self.Usage\r
93 \r
94 def SetSupArchList(self, ArchList):\r
95 self.SupArchList = ArchList\r
96 def GetSupArchList(self):\r
97 return self.SupArchList\r
98 \r
99 def SetHelpString(self, HelpString):\r
100 self.HelpString = HelpString\r
101 def GetHelpString(self):\r
102 return self.HelpString\r
103 \r
104##\r
105# InfSpecialCommentObject\r
106# \r
107class InfSpecialCommentObject(InfSectionCommonDef):\r
108 def __init__(self):\r
109 self.SpecialComments = Sdict()\r
110 InfSectionCommonDef.__init__(self)\r
111 \r
112 def SetSpecialComments(self, SepcialSectionList = None, Type = ''):\r
113 if Type == DT.TYPE_HOB_SECTION or \\r
114 Type == DT.TYPE_EVENT_SECTION or \\r
115 Type == DT.TYPE_BOOTMODE_SECTION:\r
116 for Item in SepcialSectionList:\r
27c4ceb4 117 if Type in self.SpecialComments:\r
4234283c
LG
118 ObjList = self.SpecialComments[Type]\r
119 ObjList.append(Item)\r
120 self.SpecialComments[Type] = ObjList\r
121 else:\r
122 ObjList = []\r
123 ObjList.append(Item)\r
124 self.SpecialComments[Type] = ObjList\r
125 \r
126 return True\r
127 \r
128 def GetSpecialComments(self):\r
129 return self.SpecialComments\r
130\r
131\r
132\r
133## ErrorInInf\r
134# \r
135# An encapsulate of Error for INF parser.\r
136# \r
137def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):\r
4231a819 138 if ErrorCode is None:\r
4234283c 139 ErrorCode = ToolError.FORMAT_INVALID\r
4231a819 140 if LineInfo is None:\r
4234283c
LG
141 LineInfo = ['', -1, '']\r
142 Logger.Error("InfParser", \r
143 ErrorCode, \r
144 Message=Message, \r
145 File=LineInfo[0], \r
146 Line=LineInfo[1],\r
147 ExtraData=LineInfo[2], \r
27c4ceb4 148 RaiseError=RaiseError)\r