diff --git a/ChangeLog b/ChangeLog index 2e466010..96abbf3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Feb 7 17:33:58 CET 2002 Daniel Veillard + + * 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. + Wed Feb 6 23:37:07 CET 2002 Daniel Veillard * configure.in: fixed stupid bug #70738 found by alfons hoogervorst diff --git a/Makefile.am b/Makefile.am index 6d870545..2fff4950 100644 --- a/Makefile.am +++ b/Makefile.am @@ -552,8 +552,8 @@ dist-hook: libxml.spec cleantar: @(rm -f libxslt*.tar.gz) -rpm: cleantar dist - rpm -ta $(distdir).tar.gz +rpm: cleantar + @(unset CDPATH ; $(MAKE) dist && rpm -ta $(distdir).tar.gz) ## We create xml2Conf.sh here and not from configure because we want ## to get the paths expanded correctly. Macros like srcdir are given diff --git a/debugXML.c b/debugXML.c index 41dd37fb..6300455c 100644 --- a/debugXML.c +++ b/debugXML.c @@ -40,6 +40,8 @@ xmlDebugDumpString(FILE * output, const xmlChar * str) { int i; + if (output == NULL) + output = stdout; if (str == NULL) { fprintf(output, "(NULL)"); return; @@ -558,6 +560,8 @@ xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth) { void xmlDebugDumpAttrList(FILE * output, xmlAttrPtr attr, int depth) { + if (output == NULL) + output = stdout; while (attr != NULL) { xmlDebugDumpAttr(output, attr, depth); attr = attr->next; @@ -578,6 +582,8 @@ xmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth) int i; char shift[100]; + if (output == NULL) + output = stdout; for (i = 0; ((i < depth) && (i < 25)); i++) shift[2 * i] = shift[2 * i + 1] = ' '; shift[2 * i] = shift[2 * i + 1] = 0; @@ -740,6 +746,8 @@ xmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth) void xmlDebugDumpNode(FILE * output, xmlNodePtr node, int depth) { + if (output == NULL) + output = stdout; if (node == NULL) { int i; char shift[100]; @@ -768,6 +776,8 @@ xmlDebugDumpNode(FILE * output, xmlNodePtr node, int depth) void xmlDebugDumpNodeList(FILE * output, xmlNodePtr node, int depth) { + if (output == NULL) + output = stdout; while (node != NULL) { xmlDebugDumpNode(output, node, depth); node = node->next; @@ -893,6 +903,8 @@ xmlDebugDumpDocument(FILE * output, xmlDocPtr doc) void xmlDebugDumpDTD(FILE * output, xmlDtdPtr dtd) { + if (output == NULL) + output = stdout; if (dtd == NULL) { fprintf(output, "DTD is NULL\n"); return; diff --git a/python/Makefile.am b/python/Makefile.am index fb1b6632..b1e03056 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -33,9 +33,6 @@ install-data-local: $(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)/libxml2class.py \ $(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 e665a870..0b13c41a 100755 --- a/python/generator.py +++ b/python/generator.py @@ -259,10 +259,13 @@ py_types = { '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 @@ wrapper.close() 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 @@ classes_type = { "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_ancestor = { classes_destructors = { "xpathContext": "xmlXPathFreeContext", "parserCtxt": "xmlFreeParserCtxt", + "catalog": "xmlFreeCatalog", } function_classes = {} @@ -565,6 +576,9 @@ def nameFixup(function, classe, type, file): 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 749efdc3..00070a53 100644 --- a/python/libxml2class.txt +++ b/python/libxml2class.txt @@ -23,6 +23,7 @@ htmlNewDocNoDtD() catalogAdd() catalogCleanup() catalogConvert() +catalogDump() catalogGetPublic() catalogGetSystem() catalogRemove() @@ -32,11 +33,15 @@ catalogResolveSystem() catalogResolveURI() catalogSetDebug() initializeCatalog() +loadACatalog() loadCatalog() loadCatalogs() +loadSGMLSuperCatalog() +newCatalog() parseCatalogFile() # functions from module debugXML +debugDumpString() shellPrintXPathError() # functions from module encoding @@ -147,6 +152,9 @@ registerHTTPPostCallbacks() # functions from module xmlversion checkVersion() +# functions from module xpathInternals +valuePop() + # # Set of classes of the module @@ -160,7 +168,11 @@ Class xmlNode(xmlCore) nsDefs() # functions from module debugXML + debugDumpNode() + debugDumpNodeList() + debugDumpOneNode() lsCountNode() + lsOneNode() shellPrintNode() # functions from module tree @@ -233,6 +245,19 @@ Class xmlNode(xmlCore) # 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 @@ Class xmlDoc(xmlNode) 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 @@ Class xmlDoc(xmlNode) copyDoc() createIntSubset() docCompressMode() + dump() + elemDump() freeDoc() getRootElement() intSubset() @@ -298,7 +333,7 @@ Class xmlDoc(xmlNode) xpathNewContext() -Class xmlEntity(xmlNode) +Class xmlAttribute(xmlNode) Class xmlNs(xmlNode) @@ -311,19 +346,11 @@ Class xmlNs(xmlNode) 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 @@ Class xmlDtd(xmlNode) 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 @@ Class parserCtxt() # functions from module parserInternals decodeEntities() freeParserCtxt() - handleEntity() namespaceParseNCName() namespaceParseNSDef() nextChar() @@ -403,6 +485,27 @@ Class parserCtxt() 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 @@ Class xpathContext() # functions from module xpathInternals xpathFreeContext() + xpathNewParserContext() xpathNsLookup() xpathRegisterAllFunctions() xpathRegisterNs() diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h index 679260a3..fb8b79e8 100644 --- a/python/libxml_wrap.h +++ b/python/libxml_wrap.h @@ -31,6 +31,14 @@ typedef struct { 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 @@ typedef struct { 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_xmlElementPtrWrap(xmlElementPtr ns); 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 c73f0c67..c9481b9e 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 @@ XMLS= \ 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 @@ clean: 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 56f472f3..70f77018 100644 --- a/python/types.c +++ b/python/types.c @@ -214,6 +214,23 @@ libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) { return(ret); } +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 @@ libxml_xmlXPathObjectPtrConvert(PyObject * obj) { 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); +} + diff --git a/xmlIO.c b/xmlIO.c index 291b4d7d..815df620 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1966,7 +1966,7 @@ xmlOutputBufferCreateFd(int fd, xmlCharEncodingHandlerPtr encoder) { if (ret != NULL) { ret->context = (void *) (long) fd; ret->writecallback = xmlFdWrite; - ret->closecallback = xmlFdClose; + ret->closecallback = NULL; } return(ret);