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