don't discard iframe children.
[kdelibs.git] / khtml / svg / generateSVGNames.py
blobd465e76fb93e7dc683bcfd143571c2a39ff4a4c4
1 #!/usr/bin/python
3 attrsList = []
4 tagsList = []
6 f = open("svgtags.in", "r")
7 for i in f.xreadlines():
8 i = i.strip()
9 if i == "": continue
10 if i.startswith("#"): continue
11 tagsList.append(i)
12 f.close()
14 f = open("svgattrs.in", "r")
15 for i in f.xreadlines():
16 i = i.strip()
17 if i == "": continue
18 if i.startswith("#"): continue
19 attrsList.append(i)
20 f.close()
22 f = open("SVGNames.h", "w")
23 f.write("#ifndef SVGNAMES_H\n")
24 f.write("#define SVGNAMES_H\n")
25 f.write("\n")
26 f.write("#include \"misc/htmlnames.h\"\n")
27 f.write("#include \"dom/QualifiedName.h\"\n")
28 f.write("#include \"xml/Document.h\"\n")
29 f.write("\n")
30 f.write("#define idAttr ATTR_ID\n")
31 f.write("\n")
32 f.write("namespace WebCore {\n")
33 f.write(" namespace SVGNames {\n")
34 f.write(" void init();\n");
35 initString = ""
36 definition = ""
37 definitionHtml = ""
38 definitionXLink = ""
39 for i in tagsList:
40 f.write(" " * 8 + "extern DOM::QualifiedName %sTag;\n" % (i.replace("-", "_")))
41 definition = definition + (" " * 8 + "DOM::QualifiedName %sTag;\n" % (i.replace("-", "_")))
42 # ID_TEXT is hidden, we need to use ATTR_TEXT instead
43 if i == text:
44 initString = initString + (" %sTag = DOM::QualifiedName(makeId(DOM::svgNamespace, localNamePart(ATTR_%s)), DOM::emptyPrefixName);\n" % (i.replace("-", "_"), i.upper().replace("-", "_")))
45 else:
46 initString = initString + (" %sTag = DOM::QualifiedName(makeId(DOM::svgNamespace, ID_%s), DOM::emptyPrefixName);\n" % (i.replace("-", "_"), i.upper().replace("-", "_")))
47 for i in attrsList:
48 f.write(" " * 8 + "extern DOM::QualifiedName %sAttr;\n" % (i.replace("-", "_")))
49 definition = definition + (" " * 8 + "DOM::QualifiedName %sAttr;\n" % (i.replace("-", "_")))
50 initString = initString + (" %sAttr = DOM::QualifiedName(ATTR_%s, DOM::emptyPrefixName);\n" % (i.replace("-", "_"), i.upper().replace("-", "_")))
51 f.write(" }\n")
52 f.write(" namespace HTMLNames {\n")
53 f.write(" " * 8 + "extern DOM::QualifiedName classAttr;\n")
54 definitionHtml = definitionHtml + (" " * 8 + "DOM::QualifiedName classAttr;\n")
55 initString = initString + (" WebCore::HTMLNames::classAttr = DOM::QualifiedName(ATTR_CLASS, DOM::emptyPrefixName);\n")
56 f.write(" }\n")
57 f.write("}\n")
58 f.write("\n")
59 f.write("#endif\n")
62 ############################################################
63 #generate XLinkAttrs
64 ############################################################
66 xlinkAttrs = []
68 f = open("xlinkattrs.in", "r")
69 for i in f.xreadlines():
70 i = i.strip()
71 if i == "": continue
72 if i.startswith("#"): continue
73 xlinkAttrs.append(i)
74 f.close()
76 f = open("XLinkNames.h", "w")
77 f.write("#ifndef XLinkNames_H\n")
78 f.write("#define XLinkNames_H\n")
79 f.write("\n")
80 f.write("#include \"misc/htmlnames.h\"\n")
81 f.write("#include \"dom/QualifiedName.h\"\n")
82 f.write("#include \"xml/Document.h\"\n")
83 f.write("\n")
84 f.write("namespace WebCore {\n")
85 f.write(" namespace XLinkNames {\n")
86 for i in xlinkAttrs:
87 f.write(" " * 8 + "extern DOM::QualifiedName %sAttr;\n" % (i.replace("-", "_")))
88 definitionXLink = definitionXLink + (" " * 8 + "DOM::QualifiedName %sAttr;\n" % (i.replace("-", "_")))
89 initString = initString + (" WebCore::XLinkNames::%sAttr = DOM::QualifiedName(ATTR_%s, DOM::emptyPrefixName);\n" % (i.replace("-", "_"), i.upper().replace("-", "_")))
90 f.write(" }\n")
91 f.write("}\n")
92 f.write("\n")
93 f.write("#endif\n")
94 f.close()
96 ############################
97 # generate init function
98 ############################
100 f = open("SVGNames.cpp", "w")
101 f.write("#include \"svg/SVGNames.h\"\n\n")
102 f.write("#include \"svg/XLinkNames.h\"\n\n")
103 f.write("namespace WebCore {")
104 f.write("""
105 namespace HTMLNames {
108 namespace XLinkNames {
111 namespace SVGNames {
113 void init()
117 }\n""" % (definitionHtml, definitionXLink, definition, initString))
118 f.write("}\n")
119 f.write("\n")
120 f.close()