diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Face.py | 114 | ||||
-rwxr-xr-x | include/HFacer.py | 81 |
2 files changed, 0 insertions, 195 deletions
diff --git a/include/Face.py b/include/Face.py deleted file mode 100644 index 855d6321a..000000000 --- a/include/Face.py +++ /dev/null @@ -1,114 +0,0 @@ -# Module for reading and parsing Scintilla.iface file - -def sanitiseLine(line): - if line[-1:] == '\n': line = line[:-1] - if line.find("##") != -1: - line = line[:line.find("##")] - line = line.strip() - return line - -def decodeFunction(featureVal): - retType, rest = featureVal.split(" ", 1) - nameIdent, params = rest.split("(") - name, value = nameIdent.split("=") - params, rest = params.split(")") - param1, param2 = params.split(",") - return retType, name, value, param1, param2 - -def decodeEvent(featureVal): - retType, rest = featureVal.split(" ", 1) - nameIdent, params = rest.split("(") - name, value = nameIdent.split("=") - return retType, name, value - -def decodeParam(p): - param = p.strip() - type = "" - name = "" - value = "" - if " " in param: - type, nv = param.split(" ") - if "=" in nv: - name, value = nv.split("=") - else: - name = nv - return type, name, value - -class Face: - - def __init__(self): - self.order = [] - self.features = {} - self.values = {} - self.events = {} - - def ReadFromFile(self, name): - currentCategory = "" - currentComment = [] - currentCommentFinished = 0 - file = open(name) - for line in file.readlines(): - line = sanitiseLine(line) - if line: - if line[0] == "#": - if line[1] == " ": - if currentCommentFinished: - currentComment = [] - currentCommentFinished = 0 - currentComment.append(line[2:]) - else: - currentCommentFinished = 1 - featureType, featureVal = line.split(" ", 1) - if featureType in ["fun", "get", "set"]: - try: - retType, name, value, param1, param2 = decodeFunction(featureVal) - except ValueError: - print("Failed to decode %s" % line) - raise - p1 = decodeParam(param1) - p2 = decodeParam(param2) - self.features[name] = { - "FeatureType": featureType, - "ReturnType": retType, - "Value": value, - "Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2], - "Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2], - "Category": currentCategory, "Comment": currentComment - } - if value in self.values: - raise Exception("Duplicate value " + value + " " + name) - self.values[value] = 1 - self.order.append(name) - elif featureType == "evt": - retType, name, value = decodeEvent(featureVal) - self.features[name] = { - "FeatureType": featureType, - "ReturnType": retType, - "Value": value, - "Category": currentCategory, "Comment": currentComment - } - if value in self.events: - raise Exception("Duplicate event " + value + " " + name) - self.events[value] = 1 - self.order.append(name) - elif featureType == "cat": - currentCategory = featureVal - elif featureType == "val": - try: - name, value = featureVal.split("=", 1) - except ValueError: - print("Failure %s" % featureVal) - raise Exception() - self.features[name] = { - "FeatureType": featureType, - "Category": currentCategory, - "Value": value } - self.order.append(name) - elif featureType == "enu" or featureType == "lex": - name, value = featureVal.split("=", 1) - self.features[name] = { - "FeatureType": featureType, - "Category": currentCategory, - "Value": value } - self.order.append(name) - diff --git a/include/HFacer.py b/include/HFacer.py deleted file mode 100755 index aa6b0f0a2..000000000 --- a/include/HFacer.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# 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 sys -import os -import Face - -def Contains(s,sub): - return s.find(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): - previousCategory = "" - for name in f.order: - v = f.features[name] - if v["Category"] != "Deprecated": - if v["Category"] == "Provisional" and previousCategory != "Provisional": - out.write("#ifndef SCI_DISABLE_PROVISIONAL\n") - previousCategory = v["Category"] - if v["FeatureType"] in ["fun", "get", "set"]: - featureDefineName = "SCI_" + name.upper() - out.write("#define " + featureDefineName + " " + v["Value"] + "\n") - elif v["FeatureType"] in ["evt"]: - featureDefineName = "SCN_" + name.upper() - 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") - out.write("#endif\n") - -def CopyWithInsertion(input, output, genfn, definition): - copying = 1 - for line in input.readlines(): - if copying: - output.write(line) - if Contains(line, "/* ++Autogenerated"): - copying = 0 - genfn(definition, output) - if Contains(line, "/* --Autogenerated"): - copying = 1 - output.write(line) - -def contents(filename): - f = open(filename) - t = f.read() - f.close() - return t - -def Regenerate(filename, genfn, definition): - inText = contents(filename) - tempname = "HFacer.tmp" - out = open(tempname,"w") - hfile = open(filename) - CopyWithInsertion(hfile, out, genfn, definition) - out.close() - hfile.close() - outText = contents(tempname) - if inText == outText: - os.unlink(tempname) - else: - os.unlink(filename) - os.rename(tempname, filename) - -f = Face.Face() -try: - f.ReadFromFile("Scintilla.iface") - Regenerate("Scintilla.h", printHFile, f) - Regenerate("SciLexer.h", printLexHFile, f) - print("Maximum ID is %s" % max([x for x in f.values if int(x) < 3000])) -except: - raise |