summaryrefslogtreecommitdiffstats
path: root/src/configgen.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/configgen.py')
-rwxr-xr-xsrc/configgen.py133
1 files changed, 129 insertions, 4 deletions
diff --git a/src/configgen.py b/src/configgen.py
index 1647fa2..3b86954 100755
--- a/src/configgen.py
+++ b/src/configgen.py
@@ -353,6 +353,48 @@ def parseGroups(node):
if n.nodeType == Node.ELEMENT_NODE:
parseOption(n)
+def parseGroupMap(node):
+ map = { 'bool':'bool', 'string':'QCString', 'enum':'QCString', 'int':'int', 'list':'QStrList' }
+ for n in node.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ setting = n.getAttribute('setting')
+ if len(setting) > 0:
+ print("#if %s" % (setting))
+ type = n.getAttribute('type')
+ name = n.getAttribute('id')
+ if type in map:
+ print(" %-8s %s;" % (map[type],name))
+ if len(setting) > 0:
+ print("#endif")
+
+def parseGroupInit(node):
+ map = { 'bool':'Bool', 'string':'String', 'enum':'Enum', 'int':'Int', 'list':'List' }
+ for n in node.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ setting = n.getAttribute('setting')
+ if len(setting) > 0:
+ print("#if %s" % (setting))
+ type = n.getAttribute('type')
+ name = n.getAttribute('id')
+ if type in map:
+ print(" %-25s = ConfigImpl::instance()->get%s(__FILE__,__LINE__,\"%s\");" % (name,map[type],name))
+ if len(setting) > 0:
+ print("#endif")
+
+def parseGroupMapInit(node):
+ map = { 'bool':'Bool', 'string':'String', 'enum':'String', 'int':'Int', 'list':'List' }
+ for n in node.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ setting = n.getAttribute('setting')
+ if len(setting) > 0:
+ print("#if %s" % (setting))
+ type = n.getAttribute('type')
+ name = n.getAttribute('id')
+ if type in map:
+ print(" m_map.insert(\"%s\",new Info%s(&ConfigValues::%s));" % (name,map[type],name))
+ if len(setting) > 0:
+ print("#endif")
+
def parseGroupCDocs(node):
for n in node.childNodes:
if n.nodeType == Node.ELEMENT_NODE:
@@ -556,8 +598,8 @@ def parseFooterDoc(node):
def main():
- if len(sys.argv)<3 or (not sys.argv[1] in ['-doc','-cpp','-wiz']):
- sys.exit('Usage: %s -doc|-cpp|-wiz config.xml' % sys.argv[0])
+ if len(sys.argv)<3 or (not sys.argv[1] in ['-doc','-cpp','-wiz','-maph','-maps']):
+ sys.exit('Usage: %s -doc|-cpp|-wiz|-maph|-maps config.xml' % sys.argv[0])
try:
doc = xml.dom.minidom.parse(sys.argv[2])
except Exception as inst:
@@ -597,6 +639,89 @@ def main():
if n.nodeType == Node.ELEMENT_NODE:
if (n.nodeName == "footer"):
parseFooterDoc(n)
+ elif (sys.argv[1] == "-maph"):
+ print("/* WARNING: This file is generated!")
+ print(" * Do not edit this file, but edit config.xml instead and run")
+ print(" * python configgen.py -map config.xml to regenerate this file!")
+ print(" */")
+ print("#ifndef CONFIGVALUES_H")
+ print("#define CONFIGVALUES_H")
+ print("")
+ print("#include <qdict.h>")
+ print("#include <qstrlist.h>")
+ print("#include <qcstring.h>")
+ print("#include \"settings.h\"")
+ print("")
+ print("class ConfigValues")
+ print("{")
+ print(" public:")
+ print(" static ConfigValues &instance() { static ConfigValues theInstance; return theInstance; }")
+ for n in elem.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ if (n.nodeName == "group"):
+ parseGroupMap(n)
+ print(" void init();")
+ print(" struct Info")
+ print(" {")
+ print(" enum Type { Bool, Int, String, List, Unknown };")
+ print(" Info(Type t) : type(t) {}")
+ print(" virtual ~Info() {}")
+ print(" Type type;")
+ print(" };")
+ print(" struct InfoBool : public Info")
+ print(" {")
+ print(" InfoBool(bool ConfigValues::*ptm) : Info(Info::Bool), item(ptm) {}")
+ print(" bool ConfigValues::*item;")
+ print(" };")
+ print(" struct InfoInt : public Info")
+ print(" {")
+ print(" InfoInt(int ConfigValues::*ptm) : Info(Info::Int), item(ptm) {}")
+ print(" int ConfigValues::*item;")
+ print(" };")
+ print(" struct InfoString : public Info")
+ print(" {")
+ print(" InfoString(QCString ConfigValues::*ptm) : Info(Info::String), item(ptm) {}")
+ print(" QCString ConfigValues::*item;")
+ print(" };")
+ print(" struct InfoList : public Info")
+ print(" {")
+ print(" InfoList(QStrList ConfigValues::*ptm) : Info(Info::List), item(ptm) {}")
+ print(" QStrList ConfigValues::*item;")
+ print(" };")
+ print(" const Info *get(const char *tag) const")
+ print(" {")
+ print(" return m_map.find(tag);")
+ print(" }")
+ print(" private:")
+ print(" ConfigValues();")
+ print(" QDict<Info> m_map;")
+ print("};")
+ print("")
+ print("#endif")
+ elif (sys.argv[1] == "-maps"):
+ print("/* WARNING: This file is generated!")
+ print(" * Do not edit this file, but edit config.xml instead and run")
+ print(" * python configgen.py -maps config.xml to regenerate this file!")
+ print(" */")
+ print("#include \"configvalues.h\"")
+ print("#include \"configimpl.h\"")
+ print("")
+ print("ConfigValues::ConfigValues() : m_map(257)")
+ print("{")
+ print(" m_map.setAutoDelete(TRUE);")
+ for n in elem.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ if (n.nodeName == "group"):
+ parseGroupMapInit(n)
+ print("}")
+ print("")
+ print("void ConfigValues::init()")
+ print("{")
+ for n in elem.childNodes:
+ if n.nodeType == Node.ELEMENT_NODE:
+ if (n.nodeName == "group"):
+ parseGroupInit(n)
+ print("}")
elif (sys.argv[1] == "-cpp"):
print("/* WARNING: This file is generated!")
print(" * Do not edit this file, but edit config.xml instead and run")
@@ -604,11 +729,11 @@ def main():
print(" */")
print("")
print("#include \"configoptions.h\"")
- print("#include \"config.h\"")
+ print("#include \"configimpl.h\"")
print("#include \"portable.h\"")
print("#include \"settings.h\"")
print("")
- print("void addConfigOptions(Config *cfg)")
+ print("void addConfigOptions(ConfigImpl *cfg)")
print("{")
print(" ConfigString *cs;")
print(" ConfigEnum *ce;")