2 # This file is used to define class objects of INF file [UserExtension] section.
3 # It will consumed by InfParser.
5 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
7 # SPDX-License-Identifier: BSD-2-Clause-Patent
10 InfUserExtensionsObject
13 from Logger
import StringTable
as ST
14 from Logger
import ToolError
15 import Logger
.Log
as Logger
16 from Library
import GlobalData
18 from Library
.Misc
import Sdict
20 class InfUserExtensionItem():
25 self
.Content
= Content
27 self
.IdString
= IdString
30 def SetContent(self
, Content
):
31 self
.Content
= Content
35 def SetUserId(self
, UserId
):
40 def SetIdString(self
, IdString
):
41 self
.IdString
= IdString
42 def GetIdString(self
):
45 def SetSupArchList(self
, SupArchList
):
46 self
.SupArchList
= SupArchList
47 def GetSupArchList(self
):
48 return self
.SupArchList
54 class InfUserExtensionObject():
56 self
.UserExtension
= Sdict()
58 def SetUserExtension(self
, UserExtensionCont
, IdContent
=None, LineNo
=None):
59 if not UserExtensionCont
or UserExtensionCont
== '':
62 # IdContent is a list contain UserId and IdString
63 # For this call the general section header parser, if no definition of
64 # IdString/UserId, it will return 'COMMON'
66 for IdContentItem
in IdContent
:
67 InfUserExtensionItemObj
= InfUserExtensionItem()
68 if IdContentItem
[0] == 'COMMON':
71 UserId
= IdContentItem
[0]
73 if IdContentItem
[1] == 'COMMON':
76 IdString
= IdContentItem
[1]
79 # Fill UserExtensionObj members.
81 InfUserExtensionItemObj
.SetUserId(UserId
)
82 InfUserExtensionItemObj
.SetIdString(IdString
)
83 InfUserExtensionItemObj
.SetContent(UserExtensionCont
)
84 InfUserExtensionItemObj
.SetSupArchList(IdContentItem
[2])
86 # for CheckItem in self.UserExtension:
87 # if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
88 # if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
90 # # For COMMON ARCH type, do special check.
92 # Logger.Error('InfParser',
93 # ToolError.FORMAT_INVALID,
94 # ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
95 # (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
96 # File=GlobalData.gINF_MODULE_NAME,
100 if IdContentItem
in self
.UserExtension
:
102 # Each UserExtensions section header must have a unique set
103 # of UserId, IdString and Arch values.
104 # This means that the same UserId can be used in more than one
105 # section header, provided the IdString or Arch values are
106 # different. The same IdString values can be used in more than
107 # one section header if the UserId or Arch values are
108 # different. The same UserId and the same IdString can be used
109 # in a section header if the Arch values are different in each
110 # of the section headers.
112 Logger
.Error('InfParser',
113 ToolError
.FORMAT_INVALID
,
114 ST
.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR
%\
115 (IdContentItem
[0] + '.' + IdContentItem
[1] + '.' + IdContentItem
[2]),
116 File
=GlobalData
.gINF_MODULE_NAME
,
120 UserExtensionList
= []
121 UserExtensionList
.append(InfUserExtensionItemObj
)
122 self
.UserExtension
[IdContentItem
] = UserExtensionList
126 def GetUserExtension(self
):
127 return self
.UserExtension