fixing #307823 and a couple of assorted bugs fixed conditionals in
* testapi.c runsuite.c runtest.c: fixing #307823 and a couple of
assorted bugs
* python/generator.py python/libxml2-python-api.xml: fixed
conditionals in generator too
* doc/apibuild.py doc/libxml2-api.xml doc/* elfgcchack.h: some
cleanups too and rebuilt
Daniel
diff --git a/python/generator.py b/python/generator.py
index 6144e54..f9a8930 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -114,6 +114,7 @@
self._data = []
self.in_function = 1
self.function = None
+ self.function_cond = None
self.function_args = []
self.function_descr = None
self.function_return = None
@@ -122,6 +123,8 @@
self.function = attrs['name']
if attrs.has_key('file'):
self.function_file = attrs['file']
+ elif tag == 'cond':
+ self._data = []
elif tag == 'info':
self._data = []
elif tag == 'arg':
@@ -156,7 +159,7 @@
if self.function != None:
function(self.function, self.function_descr,
self.function_return, self.function_args,
- self.function_file)
+ self.function_file, self.function_cond)
self.in_function = 0
elif tag == 'arg':
if self.in_function == 1:
@@ -174,10 +177,16 @@
str = str + c
if self.in_function == 1:
self.function_descr = str
+ elif tag == 'cond':
+ str = ''
+ for c in self._data:
+ str = str + c
+ if self.in_function == 1:
+ self.function_cond = str
-def function(name, desc, ret, args, file):
- functions[name] = (desc, ret, args, file)
+def function(name, desc, ret, args, file, cond):
+ functions[name] = (desc, ret, args, file, cond)
def enum(type, name, value):
if not enums.has_key(type):
@@ -390,7 +399,7 @@
global skipped_modules
try:
- (desc, ret, args, file) = functions[name]
+ (desc, ret, args, file, cond) = functions[name]
except:
print "failed to get function %s infos"
return
@@ -486,39 +495,10 @@
unknown_types[ret[0]] = [name]
return -1
- if file == "debugXML":
- include.write("#ifdef LIBXML_DEBUG_ENABLED\n");
- export.write("#ifdef LIBXML_DEBUG_ENABLED\n");
- output.write("#ifdef LIBXML_DEBUG_ENABLED\n");
- elif file == "HTMLtree" or file == "HTMLparser" or name[0:4] == "html":
- include.write("#ifdef LIBXML_HTML_ENABLED\n");
- export.write("#ifdef LIBXML_HTML_ENABLED\n");
- output.write("#ifdef LIBXML_HTML_ENABLED\n");
- elif file == "c14n":
- include.write("#ifdef LIBXML_C14N_ENABLED\n");
- export.write("#ifdef LIBXML_C14N_ENABLED\n");
- output.write("#ifdef LIBXML_C14N_ENABLED\n");
- elif file == "xpathInternals" or file == "xpath":
- include.write("#ifdef LIBXML_XPATH_ENABLED\n");
- export.write("#ifdef LIBXML_XPATH_ENABLED\n");
- output.write("#ifdef LIBXML_XPATH_ENABLED\n");
- elif file == "xpointer":
- include.write("#ifdef LIBXML_XPTR_ENABLED\n");
- export.write("#ifdef LIBXML_XPTR_ENABLED\n");
- output.write("#ifdef LIBXML_XPTR_ENABLED\n");
- elif file == "xinclude":
- include.write("#ifdef LIBXML_XINCLUDE_ENABLED\n");
- export.write("#ifdef LIBXML_XINCLUDE_ENABLED\n");
- output.write("#ifdef LIBXML_XINCLUDE_ENABLED\n");
- elif file == "xmlregexp":
- include.write("#ifdef LIBXML_REGEXP_ENABLED\n");
- export.write("#ifdef LIBXML_REGEXP_ENABLED\n");
- output.write("#ifdef LIBXML_REGEXP_ENABLED\n");
- elif file == "xmlschemas" or file == "xmlschemastypes" or \
- file == "relaxng":
- include.write("#ifdef LIBXML_SCHEMAS_ENABLED\n");
- export.write("#ifdef LIBXML_SCHEMAS_ENABLED\n");
- output.write("#ifdef LIBXML_SCHEMAS_ENABLED\n");
+ if cond != None and cond != "":
+ include.write("#if %s\n" % cond)
+ export.write("#if %s\n" % cond)
+ output.write("#if %s\n" % cond)
include.write("PyObject * ")
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name));
@@ -528,17 +508,17 @@
if file == "python":
# Those have been manually generated
- if name[0:4] == "html":
- include.write("#endif /* LIBXML_HTML_ENABLED */\n");
- export.write("#endif /* LIBXML_HTML_ENABLED */\n");
- output.write("#endif /* LIBXML_HTML_ENABLED */\n");
+ if cond != None and cond != "":
+ include.write("#endif\n");
+ export.write("#endif\n");
+ output.write("#endif\n");
return 1
if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
# Those have been manually generated
- if name[0:4] == "html":
- include.write("#endif /* LIBXML_HTML_ENABLED */\n");
- export.write("#endif /* LIBXML_HTML_ENABLED */\n");
- output.write("#endif /* LIBXML_HTML_ENABLED */\n");
+ if cond != None and cond != "":
+ include.write("#endif\n");
+ export.write("#endif\n");
+ output.write("#endif\n");
return 1
output.write("PyObject *\n")
@@ -563,39 +543,10 @@
output.write(c_call)
output.write(ret_convert)
output.write("}\n\n")
- if file == "debugXML":
- include.write("#endif /* LIBXML_DEBUG_ENABLED */\n");
- export.write("#endif /* LIBXML_DEBUG_ENABLED */\n");
- output.write("#endif /* LIBXML_DEBUG_ENABLED */\n");
- elif file == "HTMLtree" or file == "HTMLparser" or name[0:4] == "html":
- include.write("#endif /* LIBXML_HTML_ENABLED */\n");
- export.write("#endif /* LIBXML_HTML_ENABLED */\n");
- output.write("#endif /* LIBXML_HTML_ENABLED */\n");
- elif file == "c14n":
- include.write("#endif /* LIBXML_C14N_ENABLED */\n");
- export.write("#endif /* LIBXML_C14N_ENABLED */\n");
- output.write("#endif /* LIBXML_C14N_ENABLED */\n");
- elif file == "xpathInternals" or file == "xpath":
- include.write("#endif /* LIBXML_XPATH_ENABLED */\n");
- export.write("#endif /* LIBXML_XPATH_ENABLED */\n");
- output.write("#endif /* LIBXML_XPATH_ENABLED */\n");
- elif file == "xpointer":
- include.write("#endif /* LIBXML_XPTR_ENABLED */\n");
- export.write("#endif /* LIBXML_XPTR_ENABLED */\n");
- output.write("#endif /* LIBXML_XPTR_ENABLED */\n");
- elif file == "xinclude":
- include.write("#endif /* LIBXML_XINCLUDE_ENABLED */\n");
- export.write("#endif /* LIBXML_XINCLUDE_ENABLED */\n");
- output.write("#endif /* LIBXML_XINCLUDE_ENABLED */\n");
- elif file == "xmlregexp":
- include.write("#endif /* LIBXML_REGEXP_ENABLED */\n");
- export.write("#endif /* LIBXML_REGEXP_ENABLED */\n");
- output.write("#endif /* LIBXML_REGEXP_ENABLED */\n");
- elif file == "xmlschemas" or file == "xmlschemastypes" or \
- file == "relaxng":
- include.write("#endif /* LIBXML_SCHEMAS_ENABLED */\n");
- export.write("#endif /* LIBXML_SCHEMAS_ENABLED */\n");
- output.write("#endif /* LIBXML_SCHEMAS_ENABLED */\n");
+ if cond != None and cond != "":
+ include.write("#endif /* %s */\n" % cond)
+ export.write("#endif /* %s */\n" % cond)
+ output.write("#endif /* %s */\n" % cond)
return 1
def buildStubs():
@@ -961,7 +912,7 @@
for name in functions.keys():
found = 0;
- (desc, ret, args, file) = functions[name]
+ (desc, ret, args, file, cond) = functions[name]
for type in ctypes:
classe = classes_type[type][2]
diff --git a/python/libxml2-python-api.xml b/python/libxml2-python-api.xml
index b933290..f77a237 100644
--- a/python/libxml2-python-api.xml
+++ b/python/libxml2-python-api.xml
@@ -2,6 +2,7 @@
<api name='libxml2-python'>
<symbols>
<function name='xmlRegisterXPathFunction' file='python'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Register a Python written function to the XPath interpreter</info>
<return type='int' info="1 in case of success, 0 or -1 in case of error"/>
<arg name='ctx' type='xmlXPathContextPtr' info='the xpathContext'/>
@@ -23,6 +24,7 @@
<arg name='URI' type='xmlChar *' info='The URI used for base computations'/>
</function>
<function name='htmlCreatePushParser' file='python'>
+ <cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Create a progressive HTML parser context to build either an event flow if the SAX object is not None, or a DOM tree otherwise.</info>
<return type='xmlParserCtxtPtr' info="the parser context or None in case of error"/>
<arg name='SAX' type='pythonObject' info='the SAX callback object or None'/>
@@ -38,6 +40,7 @@
<arg name='recover' type='int' info='allow recovery in case of error'/>
</function>
<function name='htmlSAXParseFile' file='python'>
+ <cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Interface to parse an HTML file or resource pointed by an URI to build an event flow to the SAX object</info>
<return type='void'/>
<arg name='SAX' type='pythonObject' info='the SAX callback object or None'/>
@@ -129,48 +132,57 @@
</function>
<!-- xmlXPathContextPtr accessors -->
<function name='xmlXPathParserGetContext' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the xpathContext from an xpathParserContext</info>
<return type='xmlXPathContextPtr' info="The XPath context" field="context"/>
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPath parser context'/>
</function>
<function name='xmlXPathGetContextDoc' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the doc from an xpathContext</info>
<return type='xmlDocPtr' info="The doc context" field="doc"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
</function>
<function name='xmlXPathGetContextNode' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the current node from an xpathContext</info>
<return type='xmlNodePtr' info="The node context" field="node"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
</function>
<function name='xmlXPathSetContextDoc' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Set the doc of an xpathContext</info>
<return type='void'/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
<arg name="doc" type='xmlDocPtr' info="The doc context"/>
</function>
<function name='xmlXPathSetContextNode' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Set the current node of an xpathContext</info>
<return type='void'/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
<arg name="node" type='xmlNodePtr' info="The node context"/>
</function>
<function name='xmlXPathGetContextPosition' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the current node from an xpathContext</info>
<return type='int' info="The node context" field="proximityPosition"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
</function>
<function name='xmlXPathGetContextSize' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the current node from an xpathContext</info>
<return type='int' info="The node context" field="contextSize"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
</function>
<function name='xmlXPathGetFunction' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the current function name xpathContext</info>
<return type='const xmlChar *' info="The function name" field="function"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>
</function>
<function name='xmlXPathGetFunctionURI' file='python_accessor'>
+ <cond>defined(LIBXML_XPATH_ENABLED)</cond>
<info>Get the current function name URI xpathContext</info>
<return type='const xmlChar *' info="The function name URI" field="functionURI"/>
<arg name='ctxt' type='xmlXPathContextPtr' info='the XPath context'/>