Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorPhil Nash2017-09-25 15:11:12 -0700
committerPhil Nash2017-09-26 14:13:08 -0700
commit9541e89e6a91b89b45f222053d7131e0fe8dba93 (patch)
treeddd102deb693b4a814e30a4949295bda653fcd14 /scripts
parent80bbce84248cc2e7fcfdbd3f50f3b0bbb6b20c2f (diff)
downloadcatch3-9541e89e6a91b89b45f222053d7131e0fe8dba93.tar.gz
Changed embed script to just do direct regex substitution
Diffstat (limited to 'scripts')
-rw-r--r--scripts/embed.py26
-rw-r--r--scripts/embedClara.py2
2 files changed, 9 insertions, 19 deletions
diff --git a/scripts/embed.py b/scripts/embed.py
index 85a7fcfb..23b157c8 100644
--- a/scripts/embed.py
+++ b/scripts/embed.py
@@ -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 )
- 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"
+ for idFrom, idTo in self.idMap.iteritems():
+ r = re.compile("(.*)" + idFrom + "(.*)")
+
+ m = r.match( line )
+ if m:
+ 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 ):
diff --git a/scripts/embedClara.py b/scripts/embedClara.py
index 3a861549..e7bb9335 100644
--- a/scripts/embedClara.py
+++ b/scripts/embedClara.py
@@ -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