Sync EDKII BaseTools to BaseTools project r1988
[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
33 MODEL_IDENTIFIER_FILE_HEADER = 2001
34 MODEL_IDENTIFIER_FUNCTION_HEADER = 2002
35 MODEL_IDENTIFIER_COMMENT = 2003
36 MODEL_IDENTIFIER_PARAMETER = 2004
37 MODEL_IDENTIFIER_STRUCTURE = 2005
38 MODEL_IDENTIFIER_VARIABLE = 2006
39 MODEL_IDENTIFIER_INCLUDE = 2007
40 MODEL_IDENTIFIER_PREDICATE_EXPRESSION = 2008
41 MODEL_IDENTIFIER_ENUMERATE = 2009
42 MODEL_IDENTIFIER_PCD = 2010
43 MODEL_IDENTIFIER_UNION = 2011
44 MODEL_IDENTIFIER_MACRO_IFDEF = 2012
45 MODEL_IDENTIFIER_MACRO_IFNDEF = 2013
46 MODEL_IDENTIFIER_MACRO_DEFINE = 2014
47 MODEL_IDENTIFIER_MACRO_ENDIF = 2015
48 MODEL_IDENTIFIER_MACRO_PROGMA = 2016
49 MODEL_IDENTIFIER_FUNCTION_CALLING = 2018
50 MODEL_IDENTIFIER_TYPEDEF = 2017
51 MODEL_IDENTIFIER_FUNCTION_DECLARATION = 2019
52 MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION = 2020
53
54 MODEL_EFI_PROTOCOL = 3001
55 MODEL_EFI_PPI = 3002
56 MODEL_EFI_GUID = 3003
57 MODEL_EFI_LIBRARY_CLASS = 3004
58 MODEL_EFI_LIBRARY_INSTANCE = 3005
59 MODEL_EFI_PCD = 3006
60 MODEL_EFI_SOURCE_FILE = 3007
61 MODEL_EFI_BINARY_FILE = 3008
62 MODEL_EFI_SKU_ID = 3009
63 MODEL_EFI_INCLUDE = 3010
64 MODEL_EFI_DEPEX = 3011
65
66 MODEL_PCD = 4000
67 MODEL_PCD_FIXED_AT_BUILD = 4001
68 MODEL_PCD_PATCHABLE_IN_MODULE = 4002
69 MODEL_PCD_FEATURE_FLAG = 4003
70 MODEL_PCD_DYNAMIC_EX = 4004
71 MODEL_PCD_DYNAMIC_EX_DEFAULT = 4005
72 MODEL_PCD_DYNAMIC_EX_VPD = 4006
73 MODEL_PCD_DYNAMIC_EX_HII = 4007
74 MODEL_PCD_DYNAMIC = 4008
75 MODEL_PCD_DYNAMIC_DEFAULT = 4009
76 MODEL_PCD_DYNAMIC_VPD = 4010
77 MODEL_PCD_DYNAMIC_HII = 4011
78
79 MODEL_META_DATA_HEADER = 5001
80 MODEL_META_DATA_INCLUDE = 5002
81 MODEL_META_DATA_DEFINE = 5003
82 MODEL_META_DATA_CONDITIONAL_STATEMENT_IF = 5004
83 MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE = 5005
84 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF = 5006
85 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF = 5007
86 MODEL_META_DATA_BUILD_OPTION = 5008
87 MODEL_META_DATA_COMPONENT = 5009
88 MODEL_META_DATA_USER_EXTENSION = 5010
89 MODEL_META_DATA_PACKAGE = 5011
90 MODEL_META_DATA_NMAKE = 5012
91 MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF = 50013
92 MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF = 5014
93 MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH = 5015
94
95 MODEL_EXTERNAL_DEPENDENCY = 10000
96
97 MODEL_LIST = [('MODEL_UNKNOWN', MODEL_UNKNOWN),
98 ('MODEL_FILE_C', MODEL_FILE_C),
99 ('MODEL_FILE_H', MODEL_FILE_H),
100 ('MODEL_FILE_ASM', MODEL_FILE_ASM),
101 ('MODEL_FILE_INF', MODEL_FILE_INF),
102 ('MODEL_FILE_DEC', MODEL_FILE_DEC),
103 ('MODEL_FILE_DSC', MODEL_FILE_DSC),
104 ('MODEL_FILE_FDF', MODEL_FILE_FDF),
105 ('MODEL_FILE_INC', MODEL_FILE_INC),
106 ('MODEL_IDENTIFIER_FILE_HEADER', MODEL_IDENTIFIER_FILE_HEADER),
107 ('MODEL_IDENTIFIER_FUNCTION_HEADER', MODEL_IDENTIFIER_FUNCTION_HEADER),
108 ('MODEL_IDENTIFIER_COMMENT', MODEL_IDENTIFIER_COMMENT),
109 ('MODEL_IDENTIFIER_PARAMETER', MODEL_IDENTIFIER_PARAMETER),
110 ('MODEL_IDENTIFIER_STRUCTURE', MODEL_IDENTIFIER_STRUCTURE),
111 ('MODEL_IDENTIFIER_VARIABLE', MODEL_IDENTIFIER_VARIABLE),
112 ('MODEL_IDENTIFIER_INCLUDE', MODEL_IDENTIFIER_INCLUDE),
113 ('MODEL_IDENTIFIER_PREDICATE_EXPRESSION', MODEL_IDENTIFIER_PREDICATE_EXPRESSION),
114 ('MODEL_IDENTIFIER_ENUMERATE', MODEL_IDENTIFIER_ENUMERATE),
115 ('MODEL_IDENTIFIER_PCD', MODEL_IDENTIFIER_PCD),
116 ('MODEL_IDENTIFIER_UNION', MODEL_IDENTIFIER_UNION),
117 ('MODEL_IDENTIFIER_MACRO_IFDEF', MODEL_IDENTIFIER_MACRO_IFDEF),
118 ('MODEL_IDENTIFIER_MACRO_IFNDEF', MODEL_IDENTIFIER_MACRO_IFNDEF),
119 ('MODEL_IDENTIFIER_MACRO_DEFINE', MODEL_IDENTIFIER_MACRO_DEFINE),
120 ('MODEL_IDENTIFIER_MACRO_ENDIF', MODEL_IDENTIFIER_MACRO_ENDIF),
121 ('MODEL_IDENTIFIER_MACRO_PROGMA', MODEL_IDENTIFIER_MACRO_PROGMA),
122 ('MODEL_IDENTIFIER_FUNCTION_CALLING', MODEL_IDENTIFIER_FUNCTION_CALLING),
123 ('MODEL_IDENTIFIER_TYPEDEF', MODEL_IDENTIFIER_TYPEDEF),
124 ('MODEL_IDENTIFIER_FUNCTION_DECLARATION', MODEL_IDENTIFIER_FUNCTION_DECLARATION),
125 ('MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION', MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION),
126 ('MODEL_EFI_PROTOCOL', MODEL_EFI_PROTOCOL),
127 ('MODEL_EFI_PPI', MODEL_EFI_PPI),
128 ('MODEL_EFI_GUID', MODEL_EFI_GUID),
129 ('MODEL_EFI_LIBRARY_CLASS', MODEL_EFI_LIBRARY_CLASS),
130 ('MODEL_EFI_LIBRARY_INSTANCE', MODEL_EFI_LIBRARY_INSTANCE),
131 ('MODEL_EFI_PCD', MODEL_EFI_PCD),
132 ('MODEL_EFI_SKU_ID', MODEL_EFI_SKU_ID),
133 ('MODEL_EFI_INCLUDE', MODEL_EFI_INCLUDE),
134 ('MODEL_EFI_DEPEX', MODEL_EFI_DEPEX),
135 ('MODEL_IDENTIFIER_UNION', MODEL_IDENTIFIER_UNION),
136 ('MODEL_EFI_SOURCE_FILE', MODEL_EFI_SOURCE_FILE),
137 ('MODEL_EFI_BINARY_FILE', MODEL_EFI_BINARY_FILE),
138 ('MODEL_PCD', MODEL_PCD),
139 ('MODEL_PCD_FIXED_AT_BUILD', MODEL_PCD_FIXED_AT_BUILD),
140 ('MODEL_PCD_PATCHABLE_IN_MODULE', MODEL_PCD_PATCHABLE_IN_MODULE),
141 ('MODEL_PCD_FEATURE_FLAG', MODEL_PCD_FEATURE_FLAG),
142 ('MODEL_PCD_DYNAMIC_EX', MODEL_PCD_DYNAMIC_EX),
143 ('MODEL_PCD_DYNAMIC_EX_DEFAULT', MODEL_PCD_DYNAMIC_EX_DEFAULT),
144 ('MODEL_PCD_DYNAMIC_EX_VPD', MODEL_PCD_DYNAMIC_EX_VPD),
145 ('MODEL_PCD_DYNAMIC_EX_HII', MODEL_PCD_DYNAMIC_EX_HII),
146 ('MODEL_PCD_DYNAMIC', MODEL_PCD_DYNAMIC),
147 ('MODEL_PCD_DYNAMIC_DEFAULT', MODEL_PCD_DYNAMIC_DEFAULT),
148 ('MODEL_PCD_DYNAMIC_VPD', MODEL_PCD_DYNAMIC_VPD),
149 ('MODEL_PCD_DYNAMIC_HII', MODEL_PCD_DYNAMIC_HII),
150 ("MODEL_META_DATA_HEADER", MODEL_META_DATA_HEADER),
151 ("MODEL_META_DATA_INCLUDE", MODEL_META_DATA_INCLUDE),
152 ("MODEL_META_DATA_DEFINE", MODEL_META_DATA_DEFINE),
153 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IF),
154 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE),
155 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF),
156 ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF),
157 ("MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH", MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH),
158 ("MODEL_META_DATA_BUILD_OPTION", MODEL_META_DATA_BUILD_OPTION),
159 ("MODEL_META_DATA_COMPONENT", MODEL_META_DATA_COMPONENT),
160 ('MODEL_META_DATA_USER_EXTENSION', MODEL_META_DATA_USER_EXTENSION),
161 ('MODEL_META_DATA_PACKAGE', MODEL_META_DATA_PACKAGE),
162 ('MODEL_META_DATA_NMAKE', MODEL_META_DATA_NMAKE)
163 ]
164
165 ## FunctionClass
166 #
167 # This class defines a structure of a function
168 #
169 # @param ID: ID of a Function
170 # @param Header: Header of a Function
171 # @param Modifier: Modifier of a Function
172 # @param Name: Name of a Function
173 # @param ReturnStatement: ReturnStatement of a Funciont
174 # @param StartLine: StartLine of a Function
175 # @param StartColumn: StartColumn of a Function
176 # @param EndLine: EndLine of a Function
177 # @param EndColumn: EndColumn of a Function
178 # @param BodyStartLine: BodyStartLine of a Function Body
179 # @param BodyStartColumn: BodyStartColumn of a Function Body
180 # @param BelongsToFile: The Function belongs to which file
181 # @param IdentifierList: IdentifierList of a File
182 # @param PcdList: PcdList of a File
183 #
184 # @var ID: ID of a Function
185 # @var Header: Header of a Function
186 # @var Modifier: Modifier of a Function
187 # @var Name: Name of a Function
188 # @var ReturnStatement: ReturnStatement of a Funciont
189 # @var StartLine: StartLine of a Function
190 # @var StartColumn: StartColumn of a Function
191 # @var EndLine: EndLine of a Function
192 # @var EndColumn: EndColumn of a Function
193 # @var BodyStartLine: StartLine of a Function Body
194 # @var BodyStartColumn: StartColumn of a Function Body
195 # @var BelongsToFile: The Function belongs to which file
196 # @var IdentifierList: IdentifierList of a File
197 # @var PcdList: PcdList of a File
198 #
199 class FunctionClass(object):
200 def __init__(self, ID = -1, Header = '', Modifier = '', Name = '', ReturnStatement = '', \
201 StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1, \
202 BodyStartLine = -1, BodyStartColumn = -1, BelongsToFile = -1, \
203 IdentifierList = [], PcdList = [], \
204 FunNameStartLine = -1, FunNameStartColumn = -1):
205 self.ID = ID
206 self.Header = Header
207 self.Modifier = Modifier
208 self.Name = Name
209 self.ReturnStatement = ReturnStatement
210 self.StartLine = StartLine
211 self.StartColumn = StartColumn
212 self.EndLine = EndLine
213 self.EndColumn = EndColumn
214 self.BodyStartLine = BodyStartLine
215 self.BodyStartColumn = BodyStartColumn
216 self.BelongsToFile = BelongsToFile
217 self.FunNameStartLine = FunNameStartLine
218 self.FunNameStartColumn = FunNameStartColumn
219
220 self.IdentifierList = IdentifierList
221 self.PcdList = PcdList
222
223 ## IdentifierClass
224 #
225 # This class defines a structure of a variable
226 #
227 # @param ID: ID of a Identifier
228 # @param Modifier: Modifier of a Identifier
229 # @param Type: Type of a Identifier
230 # @param Name: Name of a Identifier
231 # @param Value: Value of a Identifier
232 # @param Model: Model of a Identifier
233 # @param BelongsToFile: The Identifier belongs to which file
234 # @param BelongsToFunction: The Identifier belongs to which function
235 # @param StartLine: StartLine of a Identifier
236 # @param StartColumn: StartColumn of a Identifier
237 # @param EndLine: EndLine of a Identifier
238 # @param EndColumn: EndColumn of a Identifier
239 #
240 # @var ID: ID of a Identifier
241 # @var Modifier: Modifier of a Identifier
242 # @var Type: Type of a Identifier
243 # @var Name: Name of a Identifier
244 # @var Value: Value of a Identifier
245 # @var Model: Model of a Identifier
246 # @var BelongsToFile: The Identifier belongs to which file
247 # @var BelongsToFunction: The Identifier belongs to which function
248 # @var StartLine: StartLine of a Identifier
249 # @var StartColumn: StartColumn of a Identifier
250 # @var EndLine: EndLine of a Identifier
251 # @var EndColumn: EndColumn of a Identifier
252 #
253 class IdentifierClass(object):
254 def __init__(self, ID = -1, Modifier = '', Type = '', Name = '', Value = '', Model = MODEL_UNKNOWN, \
255 BelongsToFile = -1, BelongsToFunction = -1, StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1):
256 self.ID = ID
257 self.Modifier = Modifier
258 self.Type = Type
259 self.Name = Name
260 self.Value = Value
261 self.Model = Model
262 self.BelongsToFile = BelongsToFile
263 self.BelongsToFunction = BelongsToFunction
264 self.StartLine = StartLine
265 self.StartColumn = StartColumn
266 self.EndLine = EndLine
267 self.EndColumn = EndColumn
268
269 ## PcdClass
270 #
271 # This class defines a structure of a Pcd
272 #
273 # @param ID: ID of a Pcd
274 # @param CName: CName of a Pcd
275 # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
276 # @param Token: Token of a Pcd
277 # @param DatumType: DatumType of a Pcd
278 # @param Model: Model of a Pcd
279 # @param BelongsToFile: The Pcd belongs to which file
280 # @param BelongsToFunction: The Pcd belongs to which function
281 # @param StartLine: StartLine of a Pcd
282 # @param StartColumn: StartColumn of a Pcd
283 # @param EndLine: EndLine of a Pcd
284 # @param EndColumn: EndColumn of a Pcd
285 #
286 # @var ID: ID of a Pcd
287 # @var CName: CName of a Pcd
288 # @var TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
289 # @var Token: Token of a Pcd
290 # @var DatumType: DatumType of a Pcd
291 # @var Model: Model of a Pcd
292 # @var BelongsToFile: The Pcd belongs to which file
293 # @var BelongsToFunction: The Pcd belongs to which function
294 # @var StartLine: StartLine of a Pcd
295 # @var StartColumn: StartColumn of a Pcd
296 # @var EndLine: EndLine of a Pcd
297 # @var EndColumn: EndColumn of a Pcd
298 #
299 class PcdDataClass(object):
300 def __init__(self, ID = -1, CName = '', TokenSpaceGuidCName = '', Token = '', DatumType = '', Model = MODEL_UNKNOWN, \
301 BelongsToFile = -1, BelongsToFunction = -1, StartLine = -1, StartColumn = -1, EndLine = -1, EndColumn = -1):
302 self.ID = ID
303 self.CName = CName
304 self.TokenSpaceGuidCName = TokenSpaceGuidCName
305 self.Token = Token
306 self.DatumType = DatumType
307 self.BelongsToFile = BelongsToFile
308 self.BelongsToFunction = BelongsToFunction
309 self.StartLine = StartLine
310 self.StartColumn = StartColumn
311 self.EndLine = EndLine
312 self.EndColumn = EndColumn
313
314 ## FileClass
315 #
316 # This class defines a structure of a file
317 #
318 # @param ID: ID of a File
319 # @param Name: Name of a File
320 # @param ExtName: ExtName of a File
321 # @param Path: Path of a File
322 # @param FullPath: FullPath of a File
323 # @param Model: Model of a File
324 # @param TimeStamp: TimeStamp of a File
325 # @param FunctionList: FunctionList of a File
326 # @param IdentifierList: IdentifierList of a File
327 # @param PcdList: PcdList of a File
328 #
329 # @var ID: ID of a File
330 # @var Name: Name of a File
331 # @var ExtName: ExtName of a File
332 # @var Path: Path of a File
333 # @var FullPath: FullPath of a File
334 # @var Model: Model of a File
335 # @var TimeStamp: TimeStamp of a File
336 # @var FunctionList: FunctionList of a File
337 # @var IdentifierList: IdentifierList of a File
338 # @var PcdList: PcdList of a File
339 #
340 class FileClass(object):
341 def __init__(self, ID = -1, Name = '', ExtName = '', Path = '', FullPath = '', Model = MODEL_UNKNOWN, TimeStamp = '', \
342 FunctionList = [], IdentifierList = [], PcdList = []):
343 self.ID = ID
344 self.Name = Name
345 self.ExtName = ExtName
346 self.Path = Path
347 self.FullPath = FullPath
348 self.Model = Model
349 self.TimeStamp = TimeStamp
350
351 self.FunctionList = FunctionList
352 self.IdentifierList = IdentifierList
353 self.PcdList = PcdList