summaryrefslogtreecommitdiff
path: root/gentest.py
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-11-06 14:50:18 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-11-06 14:50:18 +0000
commit57b2516af5e2e06c54750b6549723cf5b8edf8a4 (patch)
tree3c0f3dcefa5acd644c137d6af2820cdb75a1ac54 /gentest.py
parent01ca83cd4cf5247607c6ddca45d11cc366675da4 (diff)
downloadlibxml2-57b2516af5e2e06c54750b6549723cf5b8edf8a4.tar.gz
augmented type autogeneration for enums removed direct error reporting.
* gentest.py testapi.c: augmented type autogeneration for enums * xpath.c include/libxml/xpath.h: removed direct error reporting. Daniel
Diffstat (limited to 'gentest.py')
-rwxr-xr-xgentest.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/gentest.py b/gentest.py
index d4790f22..12644410 100755
--- a/gentest.py
+++ b/gentest.py
@@ -319,11 +319,56 @@ if doc == None:
print "Failed to load doc/libxml2-api.xml"
sys.exit(1)
ctxt = doc.xpathNewContext()
-headers = ctxt.xpathEval("/api/files/file")
+
+#
+# Generate constructors and return type handling for all enums
+#
+enums = ctxt.xpathEval("/api/symbols/typedef[@type='enum']")
+for enum in enums:
+ name = enum.xpathEval('string(@name)')
+ if name == None:
+ continue;
+
+ if is_known_param_type(name, name) == 0:
+ values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name)
+ i = 0
+ vals = []
+ for value in values:
+ vname = value.xpathEval('string(@name)')
+ if vname == None:
+ continue;
+ i = i + 1
+ if i >= 5:
+ break;
+ vals.append(vname)
+ if vals == []:
+ print "Didn't found any value for enum %s" % (name)
+ continue
+ test.write("#define gen_nb_%s %d\n" % (name, len(vals)))
+ test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" %
+ (name, name))
+ i = 1
+ for value in vals:
+ test.write(" if (no == %d) return(%s);\n" % (i, value))
+ i = i + 1
+ test.write(""" return(0);
+}
+""");
+ known_param_types.append(name)
+
+ if is_known_return_type(name) == 0:
+ test.write("""static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
+}
+static void desret_%s(%s val ATTRIBUTE_UNUSED) {
+}
+
+""" % (name, name, name, name))
+ known_return_types.append(name)
#
# Load the interfaces
#
+headers = ctxt.xpathEval("/api/files/file")
for file in headers:
name = file.xpathEval('string(@name)')
if (name == None) or (name == ''):