aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/HFacer.py
diff options
context:
space:
mode:
Diffstat (limited to 'include/HFacer.py')
-rw-r--r--include/HFacer.py56
1 files changed, 26 insertions, 30 deletions
diff --git a/include/HFacer.py b/include/HFacer.py
index c4100fdf9..eb5c6973b 100644
--- a/include/HFacer.py
+++ b/include/HFacer.py
@@ -1,24 +1,24 @@
+# HFacer.py - regenerate the Scintilla.h and SciLexer.h files from the Scintilla.iface interface
+# definition file.
+# The header files are copied to a temporary file apart from the section between a //++Autogenerated
+# comment and a //--Autogenerated comment which is generated by the printHFile and printLexHFile
+# functions. After the temporary file is created, it is copied back to the original file name.
+
import string
import sys
import os
import Face
-def DEFINEName(ifaceName):
- featureDefineName = string.upper(ifaceName)
- if "_" not in featureDefineName:
- featureDefineName = "SCI_" + featureDefineName
- return featureDefineName
-
def Contains(s,sub):
return string.find(s, sub) != -1
-
+
def printLexHFile(f,out):
for name in f.order:
v = f.features[name]
if v["FeatureType"] in ["val"]:
if Contains(name, "SCE_") or Contains(name, "SCLEX_"):
out.write("#define " + name + " " + v["Value"] + "\n")
-
+
def printHFile(f,out):
for name in f.order:
v = f.features[name]
@@ -32,34 +32,30 @@ def printHFile(f,out):
elif v["FeatureType"] in ["val"]:
if not (Contains(name, "SCE_") or Contains(name, "SCLEX_")):
out.write("#define " + name + " " + v["Value"] + "\n")
-
-def CopyWithInsertion(input, output, gen, definition):
+
+def CopyWithInsertion(input, output, genfn, definition):
copying = 1
for line in input.readlines():
if copying:
- out.write(line)
+ output.write(line)
if Contains(line, "//++Autogenerated"):
copying = 0
- gen(definition, out)
+ genfn(definition, output)
if Contains(line, "//--Autogenerated"):
copying = 1
- out.write(line)
-
-f = Face.Face()
-f.ReadFromFile("Scintilla.iface")
+ output.write(line)
-out = open("Sci.h","w")
-hfile = open("Scintilla.h")
-CopyWithInsertion(hfile, out, printHFile, f)
-out.close()
-hfile.close()
-os.unlink("Scintilla.h")
-os.rename("Sci.h", "Scintilla.h")
+def Regenerate(filename, genfn, definition):
+ tempname = "HFacer.tmp"
+ out = open(tempname,"w")
+ hfile = open(filename)
+ CopyWithInsertion(hfile, out, genfn, definition)
+ out.close()
+ hfile.close()
+ os.unlink(filename)
+ os.rename(tempname, filename)
-out = open("SciL.h","w")
-lexhfile = open("SciLexer.h")
-CopyWithInsertion(lexhfile, out, printLexHFile, f)
-out.close()
-lexhfile.close()
-os.unlink("SciLexer.h")
-os.rename("SciL.h", "SciLexer.h")
+f = Face.Face()
+f.ReadFromFile("Scintilla.iface")
+Regenerate("Scintilla.h", printHFile, f)
+Regenerate("SciLexer.h", printLexHFile, f)