aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/HFacer.py
blob: c4100fdf9204d9b3180c6f7f20283ee1632d07cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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]
		if v["Category"] != "Deprecated":
			if v["FeatureType"] in ["fun", "get", "set"]:
				featureDefineName = "SCI_" + string.upper(name)
				out.write("#define " + featureDefineName + " " + v["Value"] + "\n")
			elif v["FeatureType"] in ["evt"]:
				featureDefineName = "SCN_" + string.upper(name)
				out.write("#define " + featureDefineName + " " + v["Value"] + "\n")
			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):
	copying = 1
	for line in input.readlines():
		if copying:
			out.write(line)
		if Contains(line, "//++Autogenerated"):
			copying = 0
			gen(definition, out)
		if Contains(line, "//--Autogenerated"):
			copying = 1
			out.write(line)
			
f = Face.Face()
f.ReadFromFile("Scintilla.iface")

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")

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")