1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

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
This commit is contained in:
Daniel Veillard 2004-11-06 14:50:18 +00:00
parent 01ca83cd4c
commit 57b2516af5
5 changed files with 1226 additions and 47 deletions

View File

@ -1,3 +1,8 @@
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.

View File

@ -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 == ''):

View File

@ -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;
/*

1194
testapi.c

File diff suppressed because it is too large Load Diff

24
xpath.c
View File

@ -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__); \
if ((ctxt == NULL) || (ctxt->doc == NULL) || \
(ctxt->doc->children == NULL)) { \
xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
return(NULL); \
} \
else if (ctxt->doc == NULL) { \
xmlGenericError(xmlGenericErrorContext, \
"%s:%d Internal error: no document\n", \
__FILE__, __LINE__); \
return(NULL); \
} \
else if (ctxt->doc->children == NULL) { \
xmlGenericError(xmlGenericErrorContext, \
"%s:%d Internal error: document without root\n", \
__FILE__, __LINE__); \
return(NULL); \
} \
}
/**