BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[mirror_edk2.git] / BaseTools / Source / Python / CommonDataClass / DataClass.py
CommitLineData
30fdf114 1## @file\r
9053bc51 2# This file is used to define class for data structure used in ECC\r
30fdf114 3#\r
97fa0ee9 4# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
30fdf114
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13##\r
14# Import Modules\r
15#\r
16import Common.EdkLogger as EdkLogger\r
17\r
18##\r
19# Static values for data models\r
20#\r
21MODEL_UNKNOWN = 0\r
22\r
23MODEL_FILE_C = 1001\r
24MODEL_FILE_H = 1002\r
25MODEL_FILE_ASM = 1003\r
26MODEL_FILE_INF = 1011\r
27MODEL_FILE_DEC = 1012\r
28MODEL_FILE_DSC = 1013\r
29MODEL_FILE_FDF = 1014\r
30MODEL_FILE_INC = 1015\r
31MODEL_FILE_CIF = 1016\r
97fa0ee9 32MODEL_FILE_UNI = 1017\r
e56468c0 33MODEL_FILE_OTHERS = 1099\r
30fdf114
LG
34\r
35MODEL_IDENTIFIER_FILE_HEADER = 2001\r
36MODEL_IDENTIFIER_FUNCTION_HEADER = 2002\r
37MODEL_IDENTIFIER_COMMENT = 2003\r
38MODEL_IDENTIFIER_PARAMETER = 2004\r
39MODEL_IDENTIFIER_STRUCTURE = 2005\r
40MODEL_IDENTIFIER_VARIABLE = 2006\r
41MODEL_IDENTIFIER_INCLUDE = 2007\r
42MODEL_IDENTIFIER_PREDICATE_EXPRESSION = 2008\r
43MODEL_IDENTIFIER_ENUMERATE = 2009\r
44MODEL_IDENTIFIER_PCD = 2010\r
45MODEL_IDENTIFIER_UNION = 2011\r
46MODEL_IDENTIFIER_MACRO_IFDEF = 2012\r
47MODEL_IDENTIFIER_MACRO_IFNDEF = 2013\r
48MODEL_IDENTIFIER_MACRO_DEFINE = 2014\r
49MODEL_IDENTIFIER_MACRO_ENDIF = 2015\r
50MODEL_IDENTIFIER_MACRO_PROGMA = 2016\r
51MODEL_IDENTIFIER_FUNCTION_CALLING = 2018\r
52MODEL_IDENTIFIER_TYPEDEF = 2017\r
53MODEL_IDENTIFIER_FUNCTION_DECLARATION = 2019\r
54MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION = 2020\r
55\r
56MODEL_EFI_PROTOCOL = 3001\r
57MODEL_EFI_PPI = 3002\r
58MODEL_EFI_GUID = 3003\r
59MODEL_EFI_LIBRARY_CLASS = 3004\r
60MODEL_EFI_LIBRARY_INSTANCE = 3005\r
61MODEL_EFI_PCD = 3006\r
62MODEL_EFI_SOURCE_FILE = 3007\r
63MODEL_EFI_BINARY_FILE = 3008\r
64MODEL_EFI_SKU_ID = 3009\r
65MODEL_EFI_INCLUDE = 3010\r
66MODEL_EFI_DEPEX = 3011\r
67\r
68MODEL_PCD = 4000\r
69MODEL_PCD_FIXED_AT_BUILD = 4001\r
70MODEL_PCD_PATCHABLE_IN_MODULE = 4002\r
71MODEL_PCD_FEATURE_FLAG = 4003\r
72MODEL_PCD_DYNAMIC_EX = 4004\r
73MODEL_PCD_DYNAMIC_EX_DEFAULT = 4005\r
74MODEL_PCD_DYNAMIC_EX_VPD = 4006\r
75MODEL_PCD_DYNAMIC_EX_HII = 4007\r
76MODEL_PCD_DYNAMIC = 4008\r
77MODEL_PCD_DYNAMIC_DEFAULT = 4009\r
78MODEL_PCD_DYNAMIC_VPD = 4010\r
79MODEL_PCD_DYNAMIC_HII = 4011\r
80\r
e8a47801 81MODEL_META_DATA_HEADER_COMMENT = 5000\r
30fdf114
LG
82MODEL_META_DATA_HEADER = 5001\r
83MODEL_META_DATA_INCLUDE = 5002\r
84MODEL_META_DATA_DEFINE = 5003\r
85MODEL_META_DATA_CONDITIONAL_STATEMENT_IF = 5004\r
86MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE = 5005\r
87MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF = 5006\r
88MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF = 5007\r
8d62ae35 89MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR = 5400\r
30fdf114
LG
90MODEL_META_DATA_BUILD_OPTION = 5008\r
91MODEL_META_DATA_COMPONENT = 5009\r
92MODEL_META_DATA_USER_EXTENSION = 5010\r
93MODEL_META_DATA_PACKAGE = 5011\r
94MODEL_META_DATA_NMAKE = 5012\r
0d2711a6 95MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF = 5013\r
30fdf114
LG
96MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF = 5014\r
97MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH = 5015\r
e56468c0 98MODEL_META_DATA_COMMENT = 5016\r
99MODEL_META_DATA_GLOBAL_DEFINE = 5017\r
0d2711a6
LG
100MODEL_META_DATA_SECTION_HEADER = 5100\r
101MODEL_META_DATA_SUBSECTION_HEADER = 5200\r
2bc3256c 102MODEL_META_DATA_TAIL_COMMENT = 5300\r
30fdf114 103\r
9053bc51 104MODEL_EXTERNAL_DEPENDENCY = 10000\r
105\r
30fdf114
LG
106MODEL_LIST = [('MODEL_UNKNOWN', MODEL_UNKNOWN),\r
107 ('MODEL_FILE_C', MODEL_FILE_C),\r
108 ('MODEL_FILE_H', MODEL_FILE_H),\r
109 ('MODEL_FILE_ASM', MODEL_FILE_ASM),\r
110 ('MODEL_FILE_INF', MODEL_FILE_INF),\r
111 ('MODEL_FILE_DEC', MODEL_FILE_DEC),\r
112 ('MODEL_FILE_DSC', MODEL_FILE_DSC),\r
113 ('MODEL_FILE_FDF', MODEL_FILE_FDF),\r
114 ('MODEL_FILE_INC', MODEL_FILE_INC),\r
e56468c0 115 ('MODEL_FILE_CIF', MODEL_FILE_CIF),\r
116 ('MODEL_FILE_OTHERS', MODEL_FILE_OTHERS),\r
30fdf114
LG
117 ('MODEL_IDENTIFIER_FILE_HEADER', MODEL_IDENTIFIER_FILE_HEADER),\r
118 ('MODEL_IDENTIFIER_FUNCTION_HEADER', MODEL_IDENTIFIER_FUNCTION_HEADER),\r
119 ('MODEL_IDENTIFIER_COMMENT', MODEL_IDENTIFIER_COMMENT),\r
120 ('MODEL_IDENTIFIER_PARAMETER', MODEL_IDENTIFIER_PARAMETER),\r
121 ('MODEL_IDENTIFIER_STRUCTURE', MODEL_IDENTIFIER_STRUCTURE),\r
122 ('MODEL_IDENTIFIER_VARIABLE', MODEL_IDENTIFIER_VARIABLE),\r
123 ('MODEL_IDENTIFIER_INCLUDE', MODEL_IDENTIFIER_INCLUDE),\r
124 ('MODEL_IDENTIFIER_PREDICATE_EXPRESSION', MODEL_IDENTIFIER_PREDICATE_EXPRESSION),\r
125 ('MODEL_IDENTIFIER_ENUMERATE', MODEL_IDENTIFIER_ENUMERATE),\r
126 ('MODEL_IDENTIFIER_PCD', MODEL_IDENTIFIER_PCD),\r
127 ('MODEL_IDENTIFIER_UNION', MODEL_IDENTIFIER_UNION),\r
128 ('MODEL_IDENTIFIER_MACRO_IFDEF', MODEL_IDENTIFIER_MACRO_IFDEF),\r
129 ('MODEL_IDENTIFIER_MACRO_IFNDEF', MODEL_IDENTIFIER_MACRO_IFNDEF),\r
130 ('MODEL_IDENTIFIER_MACRO_DEFINE', MODEL_IDENTIFIER_MACRO_DEFINE),\r
131 ('MODEL_IDENTIFIER_MACRO_ENDIF', MODEL_IDENTIFIER_MACRO_ENDIF),\r
132 ('MODEL_IDENTIFIER_MACRO_PROGMA', MODEL_IDENTIFIER_MACRO_PROGMA),\r
133 ('MODEL_IDENTIFIER_FUNCTION_CALLING', MODEL_IDENTIFIER_FUNCTION_CALLING),\r
134 ('MODEL_IDENTIFIER_TYPEDEF', MODEL_IDENTIFIER_TYPEDEF),\r
135 ('MODEL_IDENTIFIER_FUNCTION_DECLARATION', MODEL_IDENTIFIER_FUNCTION_DECLARATION),\r
136 ('MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION', MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION),\r
137 ('MODEL_EFI_PROTOCOL', MODEL_EFI_PROTOCOL),\r
138 ('MODEL_EFI_PPI', MODEL_EFI_PPI),\r
139 ('MODEL_EFI_GUID', MODEL_EFI_GUID),\r
140 ('MODEL_EFI_LIBRARY_CLASS', MODEL_EFI_LIBRARY_CLASS),\r
141 ('MODEL_EFI_LIBRARY_INSTANCE', MODEL_EFI_LIBRARY_INSTANCE),\r
142 ('MODEL_EFI_PCD', MODEL_EFI_PCD),\r
143 ('MODEL_EFI_SKU_ID', MODEL_EFI_SKU_ID),\r
144 ('MODEL_EFI_INCLUDE', MODEL_EFI_INCLUDE),\r
145 ('MODEL_EFI_DEPEX', MODEL_EFI_DEPEX),\r
146 ('MODEL_IDENTIFIER_UNION', MODEL_IDENTIFIER_UNION),\r
147 ('MODEL_EFI_SOURCE_FILE', MODEL_EFI_SOURCE_FILE),\r
148 ('MODEL_EFI_BINARY_FILE', MODEL_EFI_BINARY_FILE),\r
149 ('MODEL_PCD', MODEL_PCD),\r
150 ('MODEL_PCD_FIXED_AT_BUILD', MODEL_PCD_FIXED_AT_BUILD),\r
151 ('MODEL_PCD_PATCHABLE_IN_MODULE', MODEL_PCD_PATCHABLE_IN_MODULE),\r
152 ('MODEL_PCD_FEATURE_FLAG', MODEL_PCD_FEATURE_FLAG),\r
153 ('MODEL_PCD_DYNAMIC_EX', MODEL_PCD_DYNAMIC_EX),\r
154 ('MODEL_PCD_DYNAMIC_EX_DEFAULT', MODEL_PCD_DYNAMIC_EX_DEFAULT),\r
155 ('MODEL_PCD_DYNAMIC_EX_VPD', MODEL_PCD_DYNAMIC_EX_VPD),\r
156 ('MODEL_PCD_DYNAMIC_EX_HII', MODEL_PCD_DYNAMIC_EX_HII),\r
157 ('MODEL_PCD_DYNAMIC', MODEL_PCD_DYNAMIC),\r
158 ('MODEL_PCD_DYNAMIC_DEFAULT', MODEL_PCD_DYNAMIC_DEFAULT),\r
159 ('MODEL_PCD_DYNAMIC_VPD', MODEL_PCD_DYNAMIC_VPD),\r
160 ('MODEL_PCD_DYNAMIC_HII', MODEL_PCD_DYNAMIC_HII),\r
161 ("MODEL_META_DATA_HEADER", MODEL_META_DATA_HEADER),\r
162 ("MODEL_META_DATA_INCLUDE", MODEL_META_DATA_INCLUDE),\r
163 ("MODEL_META_DATA_DEFINE", MODEL_META_DATA_DEFINE),\r
164 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IF),\r
165 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE),\r
166 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF),\r
167 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF),\r
8d62ae35 168 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR", MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR),\r
30fdf114
LG
169 ("MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH", MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH),\r
170 ("MODEL_META_DATA_BUILD_OPTION", MODEL_META_DATA_BUILD_OPTION),\r
171 ("MODEL_META_DATA_COMPONENT", MODEL_META_DATA_COMPONENT),\r
172 ('MODEL_META_DATA_USER_EXTENSION', MODEL_META_DATA_USER_EXTENSION),\r
173 ('MODEL_META_DATA_PACKAGE', MODEL_META_DATA_PACKAGE),\r
e56468c0 174 ('MODEL_META_DATA_NMAKE', MODEL_META_DATA_NMAKE),\r
175 ('MODEL_META_DATA_COMMENT', MODEL_META_DATA_COMMENT)\r
30fdf114
LG
176 ]\r
177\r
178## FunctionClass\r
179#\r
180# This class defines a structure of a function\r
e56468c0 181#\r
30fdf114
LG
182# @param ID: ID of a Function\r
183# @param Header: Header of a Function\r
e56468c0 184# @param Modifier: Modifier of a Function\r
30fdf114
LG
185# @param Name: Name of a Function\r
186# @param ReturnStatement: ReturnStatement of a Funciont\r
187# @param StartLine: StartLine of a Function\r
188# @param StartColumn: StartColumn of a Function\r
189# @param EndLine: EndLine of a Function\r
190# @param EndColumn: EndColumn of a Function\r
191# @param BodyStartLine: BodyStartLine of a Function Body\r
192# @param BodyStartColumn: BodyStartColumn of a Function Body\r
193# @param BelongsToFile: The Function belongs to which file\r
194# @param IdentifierList: IdentifierList of a File\r
195# @param PcdList: PcdList of a File\r
196#\r
197# @var ID: ID of a Function\r
198# @var Header: Header of a Function\r
e56468c0 199# @var Modifier: Modifier of a Function\r
30fdf114
LG
200# @var Name: Name of a Function\r
201# @var ReturnStatement: ReturnStatement of a Funciont\r
202# @var StartLine: StartLine of a Function\r
203# @var StartColumn: StartColumn of a Function\r
204# @var EndLine: EndLine of a Function\r
205# @var EndColumn: EndColumn of a Function\r
206# @var BodyStartLine: StartLine of a Function Body\r
207# @var BodyStartColumn: StartColumn of a Function Body\r
208# @var BelongsToFile: The Function belongs to which file\r
209# @var IdentifierList: IdentifierList of a File\r
210# @var PcdList: PcdList of a File\r
211#\r
212class FunctionClass(object):\r
213 def __init__(self, ID = -1, Header = '', Modifier = '', Name = '', ReturnStatement = '', \\r
214 StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1, \\r
215 BodyStartLine = -1, BodyStartColumn = -1, BelongsToFile = -1, \\r
216 IdentifierList = [], PcdList = [], \\r
217 FunNameStartLine = -1, FunNameStartColumn = -1):\r
218 self.ID = ID\r
219 self.Header = Header\r
e56468c0 220 self.Modifier = Modifier\r
30fdf114
LG
221 self.Name = Name\r
222 self.ReturnStatement = ReturnStatement\r
223 self.StartLine = StartLine\r
224 self.StartColumn = StartColumn\r
225 self.EndLine = EndLine\r
226 self.EndColumn = EndColumn\r
227 self.BodyStartLine = BodyStartLine\r
228 self.BodyStartColumn = BodyStartColumn\r
229 self.BelongsToFile = BelongsToFile\r
230 self.FunNameStartLine = FunNameStartLine\r
231 self.FunNameStartColumn = FunNameStartColumn\r
e56468c0 232\r
30fdf114
LG
233 self.IdentifierList = IdentifierList\r
234 self.PcdList = PcdList\r
235\r
236## IdentifierClass\r
237#\r
238# This class defines a structure of a variable\r
e56468c0 239#\r
30fdf114
LG
240# @param ID: ID of a Identifier\r
241# @param Modifier: Modifier of a Identifier\r
242# @param Type: Type of a Identifier\r
243# @param Name: Name of a Identifier\r
244# @param Value: Value of a Identifier\r
245# @param Model: Model of a Identifier\r
246# @param BelongsToFile: The Identifier belongs to which file\r
247# @param BelongsToFunction: The Identifier belongs to which function\r
248# @param StartLine: StartLine of a Identifier\r
249# @param StartColumn: StartColumn of a Identifier\r
250# @param EndLine: EndLine of a Identifier\r
251# @param EndColumn: EndColumn of a Identifier\r
252#\r
253# @var ID: ID of a Identifier\r
254# @var Modifier: Modifier of a Identifier\r
255# @var Type: Type of a Identifier\r
256# @var Name: Name of a Identifier\r
257# @var Value: Value of a Identifier\r
258# @var Model: Model of a Identifier\r
259# @var BelongsToFile: The Identifier belongs to which file\r
260# @var BelongsToFunction: The Identifier belongs to which function\r
261# @var StartLine: StartLine of a Identifier\r
262# @var StartColumn: StartColumn of a Identifier\r
263# @var EndLine: EndLine of a Identifier\r
264# @var EndColumn: EndColumn of a Identifier\r
265#\r
266class IdentifierClass(object):\r
267 def __init__(self, ID = -1, Modifier = '', Type = '', Name = '', Value = '', Model = MODEL_UNKNOWN, \\r
268 BelongsToFile = -1, BelongsToFunction = -1, StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1):\r
269 self.ID = ID\r
270 self.Modifier = Modifier\r
271 self.Type = Type\r
272 self.Name = Name\r
273 self.Value = Value\r
274 self.Model = Model\r
275 self.BelongsToFile = BelongsToFile\r
276 self.BelongsToFunction = BelongsToFunction\r
277 self.StartLine = StartLine\r
278 self.StartColumn = StartColumn\r
279 self.EndLine = EndLine\r
280 self.EndColumn = EndColumn\r
281\r
282## PcdClass\r
283#\r
284# This class defines a structure of a Pcd\r
e56468c0 285#\r
30fdf114
LG
286# @param ID: ID of a Pcd\r
287# @param CName: CName of a Pcd\r
288# @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd\r
289# @param Token: Token of a Pcd\r
290# @param DatumType: DatumType of a Pcd\r
291# @param Model: Model of a Pcd\r
292# @param BelongsToFile: The Pcd belongs to which file\r
293# @param BelongsToFunction: The Pcd belongs to which function\r
294# @param StartLine: StartLine of a Pcd\r
295# @param StartColumn: StartColumn of a Pcd\r
296# @param EndLine: EndLine of a Pcd\r
297# @param EndColumn: EndColumn of a Pcd\r
298#\r
299# @var ID: ID of a Pcd\r
300# @var CName: CName of a Pcd\r
301# @var TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd\r
302# @var Token: Token of a Pcd\r
303# @var DatumType: DatumType of a Pcd\r
304# @var Model: Model of a Pcd\r
305# @var BelongsToFile: The Pcd belongs to which file\r
306# @var BelongsToFunction: The Pcd belongs to which function\r
307# @var StartLine: StartLine of a Pcd\r
308# @var StartColumn: StartColumn of a Pcd\r
309# @var EndLine: EndLine of a Pcd\r
310# @var EndColumn: EndColumn of a Pcd\r
311#\r
312class PcdDataClass(object):\r
313 def __init__(self, ID = -1, CName = '', TokenSpaceGuidCName = '', Token = '', DatumType = '', Model = MODEL_UNKNOWN, \\r
314 BelongsToFile = -1, BelongsToFunction = -1, StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1):\r
315 self.ID = ID\r
316 self.CName = CName\r
317 self.TokenSpaceGuidCName = TokenSpaceGuidCName\r
318 self.Token = Token\r
319 self.DatumType = DatumType\r
320 self.BelongsToFile = BelongsToFile\r
321 self.BelongsToFunction = BelongsToFunction\r
322 self.StartLine = StartLine\r
323 self.StartColumn = StartColumn\r
324 self.EndLine = EndLine\r
325 self.EndColumn = EndColumn\r
326\r
327## FileClass\r
328#\r
329# This class defines a structure of a file\r
e56468c0 330#\r
30fdf114
LG
331# @param ID: ID of a File\r
332# @param Name: Name of a File\r
333# @param ExtName: ExtName of a File\r
334# @param Path: Path of a File\r
335# @param FullPath: FullPath of a File\r
336# @param Model: Model of a File\r
337# @param TimeStamp: TimeStamp of a File\r
338# @param FunctionList: FunctionList of a File\r
339# @param IdentifierList: IdentifierList of a File\r
340# @param PcdList: PcdList of a File\r
341#\r
342# @var ID: ID of a File\r
343# @var Name: Name of a File\r
344# @var ExtName: ExtName of a File\r
345# @var Path: Path of a File\r
346# @var FullPath: FullPath of a File\r
347# @var Model: Model of a File\r
348# @var TimeStamp: TimeStamp of a File\r
349# @var FunctionList: FunctionList of a File\r
350# @var IdentifierList: IdentifierList of a File\r
351# @var PcdList: PcdList of a File\r
352#\r
353class FileClass(object):\r
354 def __init__(self, ID = -1, Name = '', ExtName = '', Path = '', FullPath = '', Model = MODEL_UNKNOWN, TimeStamp = '', \\r
355 FunctionList = [], IdentifierList = [], PcdList = []):\r
e56468c0 356 self.ID = ID\r
30fdf114 357 self.Name = Name\r
e56468c0 358 self.ExtName = ExtName\r
30fdf114
LG
359 self.Path = Path\r
360 self.FullPath = FullPath\r
361 self.Model = Model\r
362 self.TimeStamp = TimeStamp\r
e56468c0 363\r
30fdf114
LG
364 self.FunctionList = FunctionList\r
365 self.IdentifierList = IdentifierList\r
366 self.PcdList = PcdList\r