mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 508942 - Use Preprocessor.py filters in #defines and #includes. r=ted,r=pike
Original patch by Markus Stange.
This commit is contained in:
parent
3f9b2b76b7
commit
a7c8845018
@ -134,6 +134,11 @@ class Preprocessor:
|
||||
rv.out = self.out
|
||||
return rv
|
||||
|
||||
def applyFilters(self, aLine):
|
||||
for f in self.filters:
|
||||
aLine = f[1](aLine)
|
||||
return aLine
|
||||
|
||||
def write(self, aLine):
|
||||
"""
|
||||
Internal method for handling output.
|
||||
@ -146,8 +151,7 @@ class Preprocessor:
|
||||
'file': self.context['FILE'],
|
||||
'le': self.LE})
|
||||
self.writtenLines = ln
|
||||
for f in self.filters:
|
||||
aLine = f[1](aLine)
|
||||
aLine = self.applyFilters(aLine)
|
||||
# ensure our line ending. Only need to handle \n, as we're reading
|
||||
# with universal line ending support, at least for files.
|
||||
aLine = re.sub('\n', self.LE, aLine)
|
||||
@ -242,7 +246,7 @@ class Preprocessor:
|
||||
raise Preprocessor.Error(self, 'SYNTAX_DEF', args)
|
||||
val = 1
|
||||
if m.group('value'):
|
||||
val = m.group('value')
|
||||
val = self.applyFilters(m.group('value'))
|
||||
try:
|
||||
val = int(val)
|
||||
except:
|
||||
@ -423,6 +427,7 @@ class Preprocessor:
|
||||
if isName:
|
||||
try:
|
||||
args = str(args)
|
||||
args = self.applyFilters(args)
|
||||
if not os.path.isabs(args):
|
||||
args = os.path.join(self.context['DIRECTORY'], args)
|
||||
args = open(args, 'rU')
|
||||
|
@ -404,6 +404,15 @@ FAIL
|
||||
self.pp.do_include(f)
|
||||
self.assertEqual(self.pp.out.getvalue(), "first\rsecond\r")
|
||||
|
||||
def test_filterDefine(self):
|
||||
f = NamedIO('filterDefine.in', '''#filter substitution
|
||||
#define VAR AS
|
||||
#define VAR2 P@VAR@
|
||||
@VAR2@S
|
||||
''')
|
||||
self.pp.do_include(f)
|
||||
self.assertEqual(self.pp.out.getvalue(), "PASS\n")
|
||||
|
||||
def test_number_value_equals(self):
|
||||
f = NamedIO("number_value_equals.in", """#define FOO 1000
|
||||
#if FOO == 1000
|
||||
|
@ -134,6 +134,11 @@ class Preprocessor:
|
||||
rv.out = self.out
|
||||
return rv
|
||||
|
||||
def applyFilters(self, aLine):
|
||||
for f in self.filters:
|
||||
aLine = f[1](aLine)
|
||||
return aLine
|
||||
|
||||
def write(self, aLine):
|
||||
"""
|
||||
Internal method for handling output.
|
||||
@ -146,8 +151,7 @@ class Preprocessor:
|
||||
'file': self.context['FILE'],
|
||||
'le': self.LE})
|
||||
self.writtenLines = ln
|
||||
for f in self.filters:
|
||||
aLine = f[1](aLine)
|
||||
aLine = self.applyFilters(aLine)
|
||||
# ensure our line ending. Only need to handle \n, as we're reading
|
||||
# with universal line ending support, at least for files.
|
||||
aLine = re.sub('\n', self.LE, aLine)
|
||||
@ -242,7 +246,7 @@ class Preprocessor:
|
||||
raise Preprocessor.Error(self, 'SYNTAX_DEF', args)
|
||||
val = 1
|
||||
if m.group('value'):
|
||||
val = m.group('value')
|
||||
val = self.applyFilters(m.group('value'))
|
||||
try:
|
||||
val = int(val)
|
||||
except:
|
||||
@ -423,6 +427,7 @@ class Preprocessor:
|
||||
if isName:
|
||||
try:
|
||||
args = str(args)
|
||||
args = self.applyFilters(args)
|
||||
if not os.path.isabs(args):
|
||||
args = os.path.join(self.context['DIRECTORY'], args)
|
||||
args = open(args, 'rU')
|
||||
|
Loading…
Reference in New Issue
Block a user