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