2 # This file is used to define class objects of INF file [UserExtension] section.
3 # It will consumed by InfParser.
5 # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
7 # This program and the accompanying materials are licensed and made available
8 # under the terms and conditions of the BSD License which accompanies this
9 # distribution. The full text of the license may be found at
10 # http://opensource.org/licenses/bsd-license.php
12 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 InfUserExtensionsObject
19 from Logger
import StringTable
as ST
20 from Logger
import ToolError
21 import Logger
.Log
as Logger
22 from Library
import GlobalData
24 from Library
.Misc
import Sdict
26 class InfUserExtensionItem():
31 self
.Content
= Content
33 self
.IdString
= IdString
36 def SetContent(self
, Content
):
37 self
.Content
= Content
41 def SetUserId(self
, UserId
):
46 def SetIdString(self
, IdString
):
47 self
.IdString
= IdString
48 def GetIdString(self
):
51 def SetSupArchList(self
, SupArchList
):
52 self
.SupArchList
= SupArchList
53 def GetSupArchList(self
):
54 return self
.SupArchList
60 class InfUserExtensionObject():
62 self
.UserExtension
= Sdict()
64 def SetUserExtension(self
, UserExtensionCont
, IdContent
=None, LineNo
=None):
65 if not UserExtensionCont
or UserExtensionCont
== '':
68 # IdContent is a list contain UserId and IdString
69 # For this call the general section header parser, if no definition of
70 # IdString/UserId, it will return 'COMMON'
72 for IdContentItem
in IdContent
:
73 InfUserExtensionItemObj
= InfUserExtensionItem()
74 if IdContentItem
[0] == 'COMMON':
77 UserId
= IdContentItem
[0]
79 if IdContentItem
[1] == 'COMMON':
82 IdString
= IdContentItem
[1]
85 # Fill UserExtensionObj members.
87 InfUserExtensionItemObj
.SetUserId(UserId
)
88 InfUserExtensionItemObj
.SetIdString(IdString
)
89 InfUserExtensionItemObj
.SetContent(UserExtensionCont
)
90 InfUserExtensionItemObj
.SetSupArchList(IdContentItem
[2])
92 # for CheckItem in self.UserExtension:
93 # if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
94 # if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
96 # # For COMMON ARCH type, do special check.
98 # Logger.Error('InfParser',
99 # ToolError.FORMAT_INVALID,
100 # ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
101 # (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
102 # File=GlobalData.gINF_MODULE_NAME,
106 if self
.UserExtension
.has_key(IdContentItem
):
108 # Each UserExtensions section header must have a unique set
109 # of UserId, IdString and Arch values.
110 # This means that the same UserId can be used in more than one
111 # section header, provided the IdString or Arch values are
112 # different. The same IdString values can be used in more than
113 # one section header if the UserId or Arch values are
114 # different. The same UserId and the same IdString can be used
115 # in a section header if the Arch values are different in each
116 # of the section headers.
118 Logger
.Error('InfParser',
119 ToolError
.FORMAT_INVALID
,
120 ST
.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR
%\
121 (IdContentItem
[0] + '.' + IdContentItem
[1] + '.' + IdContentItem
[2]),
122 File
=GlobalData
.gINF_MODULE_NAME
,
126 UserExtensionList
= []
127 UserExtensionList
.append(InfUserExtensionItemObj
)
128 self
.UserExtension
[IdContentItem
] = UserExtensionList
132 def GetUserExtension(self
):
133 return self
.UserExtension