cleanup always use stdout if output is NULL don't close filedescriptors
* Makefile.am: cleanup
* debugXML.c: always use stdout if output is NULL
* xmlIO.c: don't close filedescriptors passed to outputBuffers
* python/Makefile.am python/generator.py python/libxml2class.txt
python/libxml_wrap.h python/types.c: augmented the number of bindings
handling FILE * and XPath contexts
* python/tests/Makefile.am: avoid a stupid problem due to the
use of TEST.
Daniel
diff --git a/python/Makefile.am b/python/Makefile.am
index fb1b663..b1e0305 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -33,9 +33,6 @@
$(mkinstalldirs) $(DESTDIR)$(DOCS_DIR)
-@(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done)
-else
-all:
-endif
libxml.o: libxml.c libxml2-export.c libxml_wrap.h
$(CC) $(SHCFLAGS) -c -o libxml.o $(srcdir)/libxml.c
@@ -55,6 +52,9 @@
$(GENERATED): $(srcdir)/$(GENERATE) $(API_DESC)
cd $(srcdir) && $(PYTHON) $(GENERATE)
+else
+all:
+endif
tests: all
cd tests && $(MAKE) tests
diff --git a/python/generator.py b/python/generator.py
index e665a87..0b13c41 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -259,10 +259,13 @@
'const htmlNode *': ('O', "xmlNode", "xmlNodePtr", "xmlNodePtr"),
'xmlXPathContextPtr': ('O', "xmlXPathContext", "xmlXPathContextPtr", "xmlXPathContextPtr"),
'xmlXPathContext *': ('O', "xpathContext", "xmlXPathContextPtr", "xmlXPathContextPtr"),
+ 'xmlXPathParserContextPtr': ('O', "xmlXPathParserContext", "xmlXPathParserContextPtr", "xmlXPathParserContextPtr"),
'xmlParserCtxtPtr': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr"),
'xmlParserCtxt *': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr"),
'htmlParserCtxtPtr': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr"),
'htmlParserCtxt *': ('O', "parserCtxt", "xmlParserCtxtPtr", "xmlParserCtxtPtr"),
+ 'xmlCatalogPtr': ('O', "catalog", "xmlCatalogPtr", "xmlCatalogPtr"),
+ 'FILE *': ('O', "File", "FILEPtr", "FILE *"),
}
py_return_types = {
@@ -459,7 +462,10 @@
print "Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap,
failed, skipped);
-print "Missing type converters: %s" % (unknown_types.keys())
+print "Missing type converters: "
+for type in unknown_types.keys():
+ print "%s:%d " % (type, len(unknown_types[type])),
+print
#######################################################################
#
@@ -492,8 +498,12 @@
"xmlAttributePtr": ("._o", "xmlAttribute(_obj=%s)", "xmlAttribute"),
"xmlAttribute *": ("._o", "xmlAttribute(_obj=%s)", "xmlAttribute"),
"xmlXPathContextPtr": ("._o", "xpathContext(_obj=%s)", "xpathContext"),
+ "xmlXPathContext *": ("._o", "xpathContext(_obj=%s)", "xpathContext"),
+ "xmlXPathParserContext *": ("._o", "xpathParserContext(_obj=%s)", "xpathParserContext"),
+ "xmlXPathParserContextPtr": ("._o", "xpathParserContext(_obj=%s)", "xpathParserContext"),
"xmlParserCtxtPtr": ("._o", "parserCtxt(_obj=%s)", "parserCtxt"),
"xmlParserCtxt *": ("._o", "parserCtxt(_obj=%s)", "parserCtxt"),
+ "xmlCatalogPtr": ("._o", "catalog(_obj=%s)", "catalog"),
}
converter_type = {
@@ -515,6 +525,7 @@
classes_destructors = {
"xpathContext": "xmlXPathFreeContext",
"parserCtxt": "xmlFreeParserCtxt",
+ "catalog": "xmlFreeCatalog",
}
function_classes = {}
@@ -565,6 +576,9 @@
elif name[0:10] == "xmlNodeGet" and file == "python_accessor":
func = name[10:]
func = string.lower(func[0:1]) + func[1:]
+ elif name[0:11] == "xmlACatalog":
+ func = name[11:]
+ func = string.lower(func[0:1]) + func[1:]
elif name[0:l] == classe:
func = name[l:]
func = string.lower(func[0:1]) + func[1:]
diff --git a/python/libxml2class.txt b/python/libxml2class.txt
index 749efdc..00070a5 100644
--- a/python/libxml2class.txt
+++ b/python/libxml2class.txt
@@ -23,6 +23,7 @@
catalogAdd()
catalogCleanup()
catalogConvert()
+catalogDump()
catalogGetPublic()
catalogGetSystem()
catalogRemove()
@@ -32,11 +33,15 @@
catalogResolveURI()
catalogSetDebug()
initializeCatalog()
+loadACatalog()
loadCatalog()
loadCatalogs()
+loadSGMLSuperCatalog()
+newCatalog()
parseCatalogFile()
# functions from module debugXML
+debugDumpString()
shellPrintXPathError()
# functions from module encoding
@@ -147,6 +152,9 @@
# functions from module xmlversion
checkVersion()
+# functions from module xpathInternals
+valuePop()
+
#
# Set of classes of the module
@@ -160,7 +168,11 @@
nsDefs()
# functions from module debugXML
+ debugDumpNode()
+ debugDumpNodeList()
+ debugDumpOneNode()
lsCountNode()
+ lsOneNode()
shellPrintNode()
# functions from module tree
@@ -233,6 +245,19 @@
# functions from module xpathInternals
xpathNewNodeSet()
xpathNewValueTree()
+ xpathNextAncestor()
+ xpathNextAncestorOrSelf()
+ xpathNextAttribute()
+ xpathNextChild()
+ xpathNextDescendant()
+ xpathNextDescendantOrSelf()
+ xpathNextFollowing()
+ xpathNextFollowingSibling()
+ xpathNextNamespace()
+ xpathNextParent()
+ xpathNextPreceding()
+ xpathNextPrecedingSibling()
+ xpathNextSelf()
Class xmlDoc(xmlNode)
@@ -242,12 +267,20 @@
htmlIsAutoClosed()
# functions from module HTMLtree
+ htmlDocDump()
htmlGetMetaEncoding()
+ htmlNodeDumpFile()
+ htmlNodeDumpFileFormat()
htmlSaveFile()
htmlSaveFileEnc()
htmlSaveFileFormat()
htmlSetMetaEncoding()
+ # functions from module debugXML
+ debugDumpDocument()
+ debugDumpDocumentHead()
+ debugDumpEntities()
+
# functions from module entities
addDocEntity()
addDtdEntity()
@@ -262,6 +295,8 @@
copyDoc()
createIntSubset()
docCompressMode()
+ dump()
+ elemDump()
freeDoc()
getRootElement()
intSubset()
@@ -298,7 +333,7 @@
xpathNewContext()
-Class xmlEntity(xmlNode)
+Class xmlAttribute(xmlNode)
Class xmlNs(xmlNode)
@@ -311,19 +346,11 @@
newNode()
-Class xmlAttr(xmlNode)
-
- # functions from module tree
- freeProp()
- freePropList()
- removeProp()
-
-
-Class xmlAttribute(xmlNode)
-
-
Class xmlDtd(xmlNode)
+ # functions from module debugXML
+ debugDumpDTD()
+
# functions from module tree
copyDtd()
freeDtd()
@@ -333,9 +360,65 @@
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
+Class catalog()
+ # functions from module catalog
+ add()
+ catalogIsEmpty()
+ convertSGMLCatalog()
+ dump()
+ freeCatalog()
+ remove()
+ resolve()
+ resolvePublic()
+ resolveSystem()
+ resolveURI()
+Class xpathParserContext()
-Class xmlElement(xmlNode)
+ # functions from module xpathInternals
+ xpathAddValues()
+ xpathBooleanFunction()
+ xpathCeilingFunction()
+ xpathCompareValues()
+ xpathConcatFunction()
+ xpathContainsFunction()
+ xpathCountFunction()
+ xpathDivValues()
+ xpathEqualValues()
+ xpathEvalExpr()
+ xpathFalseFunction()
+ xpathFloorFunction()
+ xpathFreeParserContext()
+ xpathIdFunction()
+ xpathLangFunction()
+ xpathLastFunction()
+ xpathLocalNameFunction()
+ xpathModValues()
+ xpathMultValues()
+ xpathNamespaceURIFunction()
+ xpathNormalizeFunction()
+ xpathNotFunction()
+ xpathNumberFunction()
+ xpathParseNCName()
+ xpathParseName()
+ xpathPopBoolean()
+ xpathPopNumber()
+ xpathPopString()
+ xpathPositionFunction()
+ xpathRoot()
+ xpathRoundFunction()
+ xpathStartsWithFunction()
+ xpathStringFunction()
+ xpathStringLengthFunction()
+ xpathSubValues()
+ xpathSubstringAfterFunction()
+ xpathSubstringBeforeFunction()
+ xpathSubstringFunction()
+ xpathSumFunction()
+ xpathTranslateFunction()
+ xpathTrueFunction()
+ xpathValueFlipSign()
+ xpatherror()
Class parserCtxt()
# accessors
doc()
@@ -358,7 +441,6 @@
# functions from module parserInternals
decodeEntities()
freeParserCtxt()
- handleEntity()
namespaceParseNCName()
namespaceParseNSDef()
nextChar()
@@ -403,6 +485,27 @@
scanName()
skipBlankChars()
stringDecodeEntities()
+
+
+Class xmlElement(xmlNode)
+
+
+Class xmlEntity(xmlNode)
+
+ # functions from module parserInternals
+ handleEntity()
+
+
+Class xmlAttr(xmlNode)
+
+ # functions from module debugXML
+ debugDumpAttr()
+ debugDumpAttrList()
+
+ # functions from module tree
+ freeProp()
+ freePropList()
+ removeProp()
Class xpathContext()
# functions from module python
@@ -414,6 +517,7 @@
# functions from module xpathInternals
xpathFreeContext()
+ xpathNewParserContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h
index 679260a..fb8b79e 100644
--- a/python/libxml_wrap.h
+++ b/python/libxml_wrap.h
@@ -31,6 +31,14 @@
xmlXPathContextPtr obj;
} PyxmlXPathContext_Object;
+#define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
+ (((PyxmlXPathParserContext_Object *)(v))->obj))
+
+typedef struct {
+ PyObject_HEAD
+ xmlXPathParserContextPtr obj;
+} PyxmlXPathParserContext_Object;
+
#define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
(((PyparserCtxt_Object *)(v))->obj))
@@ -39,6 +47,17 @@
xmlParserCtxtPtr obj;
} PyparserCtxt_Object;
+#define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
+ (((Pycatalog_Object *)(v))->obj))
+
+typedef struct {
+ PyObject_HEAD
+ xmlCatalogPtr obj;
+} Pycatalog_Object;
+
+#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
+ (PyFile_Check(v) ? NULL : (PyFile_AsFile(v))))
+
PyObject * libxml_intWrap(int val);
PyObject * libxml_longWrap(long val);
PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
@@ -54,6 +73,8 @@
PyObject * libxml_doubleWrap(double val);
PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
+PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
+PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index c73f0c6..c9481b9 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -1,6 +1,6 @@
EXAMPLE_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)/examples
-TESTS= \
+PYTESTS= \
build.py \
tst.py \
tstxpath.py \
@@ -16,12 +16,12 @@
valid.xml \
invalid.xml
-EXTRA_DIST = $(TESTS) $(XMLS)
+EXTRA_DIST = $(TESTSPY) $(XMLS)
if WITH_PYTHON
-tests: $(TESTS)
+tests: $(TESTSPY)
-@(PYTHONPATH=".." ; export PYTHONPATH; \
- for test in $(TESTS) ; do echo "-- $$test" ; $(PYTHON) $$test ; done)
+ for test in $(TESTSPY) ; do echo "-- $$test" ; $(PYTHON) $$test ; done)
else
tests:
endif
@@ -31,6 +31,6 @@
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(EXAMPLE_DIR)
- -(for test in $(TESTS) $(XMLS); \
+ -(for test in $(TESTSPY) $(XMLS); \
do @INSTALL@ -m 0644 $$test $(DESTDIR)$(EXAMPLE_DIR) ; done)
diff --git a/python/types.c b/python/types.c
index 56f472f..70f7701 100644
--- a/python/types.c
+++ b/python/types.c
@@ -215,6 +215,23 @@
}
PyObject *
+libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libxml_xmlXPathParserContextPtrWrap: ctxt = %p\n", ctxt);
+#endif
+ if (ctxt == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyCObject_FromVoidPtrAndDesc((void *) ctxt,
+ "xmlXPathParserContextPtr", NULL);
+ return (ret);
+}
+
+PyObject *
libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) {
PyObject *ret;
@@ -305,4 +322,19 @@
return(ret);
}
+PyObject *
+libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) {
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libxml_xmlNodePtrWrap: catal = %p\n", catal);
+#endif
+ if (catal == NULL) {
+ Py_INCREF(Py_None);
+ return(Py_None);
+ }
+ ret = PyCObject_FromVoidPtrAndDesc((void *) catal, "xmlCatalogPtr", NULL);
+ return(ret);
+}
+