import re\r
import os\r
from Common.GlobalData import gIdentifierPattern\r
+from UniClassObject import StripComments\r
\r
IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)\r
\r
ImageFileList = []\r
for Line in FileIn.splitlines():\r
Line = Line.strip()\r
- Line = self.StripComments(Line)\r
+ Line = StripComments(Line)\r
if len(Line) == 0:\r
continue\r
\r
if Len == 4 and LineDetails[2] != 'TRANSPARENT':\r
EdkLogger.error("Image Definition File Parser", PARSER_ERROR, 'Please use the keyword "TRANSPARENT" to describe the transparency setting in Line %s of File %s.' % (LineNo, File.Path))\r
MatchString = gIdentifierPattern.match(LineDetails[1])\r
- if MatchString is None or MatchString.end(0) != len(LineDetails[1]):\r
+ if MatchString is None:\r
EdkLogger.error('Image Definition File Parser', FORMAT_INVALID, 'The Image token name %s defined in Idf file %s contains the invalid character.' % (LineDetails[1], File.Path))\r
if LineDetails[1] not in self.ImageIDList:\r
self.ImageIDList.append(LineDetails[1])\r
if ImageFileList:\r
self.ImageFilesDict[File] = ImageFileList\r
\r
- def StripComments(self, Line):\r
- Comment = '//'\r
- CommentPos = Line.find(Comment)\r
- while CommentPos >= 0:\r
- # if there are non matched quotes before the comment header\r
- # then we are in the middle of a string\r
- # but we need to ignore the escaped quotes and backslashes.\r
- if ((Line.count('"', 0, CommentPos) - Line.count('\\"', 0, CommentPos)) & 1) == 1:\r
- CommentPos = Line.find (Comment, CommentPos + 1)\r
- else:\r
- return Line[:CommentPos].strip()\r
- return Line.strip()\r
-\r
- def ImageDecoder(self, File):\r
- pass\r
-\r
def SearchImageID(ImageFileObject, FileList):\r
if FileList == []:\r
return ImageFileObject\r