Commit 57b2516a authored by Daniel Veillard's avatar Daniel Veillard

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
parent 01ca83cd
Sat Nov 6 15:50:11 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: augmented type autogeneration for enums
* xpath.c include/libxml/xpath.h: removed direct error reporting.
Sat Nov 6 14:27:18 CET 2004 Daniel Veillard <daniel@veillard.com>
* encoding.c: fixed a regression in iconv support.
......
......@@ -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 == ''):
......
......@@ -62,7 +62,8 @@ typedef enum {
XPTR_SUB_RESOURCE_ERROR,
XPATH_UNDEF_PREFIX_ERROR,
XPATH_ENCODING_ERROR,
XPATH_INVALID_CHAR_ERROR
XPATH_INVALID_CHAR_ERROR,
XPATH_INVALID_CTXT
} xmlXPathError;
/*
......
This diff is collapsed.
......@@ -207,7 +207,8 @@ static const char *xmlXPathErrorMessages[] = {
"Sub resource error\n",
"Undefined namespace prefix\n",
"Encoding error\n",
"Char out of XML range\n"
"Char out of XML range\n",
"Invalid or inclomplete context\n"
};
......@@ -3928,24 +3929,11 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
#define CHECK_CONTEXT(ctxt) \
if (ctxt == NULL) { \
xmlGenericError(xmlGenericErrorContext, \
"%s:%d Internal error: no context\n", \
__FILE__, __LINE__); \
return(NULL); \
} \
else if (ctxt->doc == NULL) { \
xmlGenericError(xmlGenericErrorContext, \
"%s:%d Internal error: no document\n", \
__FILE__, __LINE__); \
if ((ctxt == NULL) || (ctxt->doc == NULL) || \
(ctxt->doc->children == NULL)) { \
xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
return(NULL); \
} \
else if (ctxt->doc->children == NULL) { \
xmlGenericError(xmlGenericErrorContext, \
"%s:%d Internal error: document without root\n", \
__FILE__, __LINE__); \
return(NULL); \
} \
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment