mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Changed embed script to just do direct regex substitution
This commit is contained in:
parent
80bbce8424
commit
9541e89e6a
@ -22,27 +22,16 @@ class LineMapper:
|
||||
self.idMap = idMap
|
||||
self.outerNamespace = outerNamespace
|
||||
|
||||
def replaceId( self, lineNo, id ):
|
||||
if not self.idMap.has_key( id ):
|
||||
raise ValueError( "Unrecognised macro identifier: '{0}' on line: {1}".format( id, lineNo ) )
|
||||
subst = self.idMap[id]
|
||||
if subst == "":
|
||||
return id
|
||||
else:
|
||||
return subst
|
||||
|
||||
# TBD:
|
||||
# #if, #ifdef, comments after #else
|
||||
def mapLine( self, lineNo, line ):
|
||||
m = ifndefRe.match( line )
|
||||
for idFrom, idTo in self.idMap.iteritems():
|
||||
r = re.compile("(.*)" + idFrom + "(.*)")
|
||||
|
||||
m = r.match( line )
|
||||
if m:
|
||||
return "#ifndef " + self.replaceId( lineNo, m.group(1)) + "\n"
|
||||
m = defineRe.match( line )
|
||||
if m:
|
||||
return "#define {0}{1}{2}\n".format( self.replaceId( lineNo, m.group(1)), m.group(2), m.group(3) )
|
||||
m = endifRe.match( line )
|
||||
if m:
|
||||
return "#endif // " + self.replaceId( lineNo, m.group(1)) + "\n"
|
||||
line = m.group(1) + idTo + m.group(2) + "\n"
|
||||
|
||||
m = nsCloseRe.match( line )
|
||||
if m:
|
||||
originalNs = m.group(3)
|
||||
@ -61,6 +50,7 @@ class LineMapper:
|
||||
if self.outerNamespace.has_key(originalNs):
|
||||
outerNs, innerNs = self.outerNamespace[originalNs]
|
||||
return "{0}{1} {{ namespace {2}{3}{4}\n".format( m.group(1), outerNs, innerNs, m.group(3), m.group(4) )
|
||||
|
||||
return line
|
||||
|
||||
def mapFile(self, filenameIn, filenameOut ):
|
||||
|
@ -15,7 +15,7 @@ idMap = {
|
||||
"CLARA_CONFIG_CONSOLE_WIDTH": "CATCH_CLARA_CONFIG_CONSOLE_WIDTH",
|
||||
"CLARA_TEXTFLOW_HPP_INCLUDED": "CATCH_CLARA_TEXTFLOW_HPP_INCLUDED",
|
||||
"CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH": "CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH",
|
||||
"CLARA_PLATFORM_WINDOWS": ""
|
||||
"CLARA_PLATFORM_WINDOWS": "CATCH_PLATFORM_WINDOWS"
|
||||
}
|
||||
|
||||
# outer namespace to add
|
||||
|
Loading…
Reference in New Issue
Block a user