diff --git a/python/libxml.c b/python/libxml.c index 681091e3..7c0f27fc 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -50,6 +50,8 @@ void initlibxml2mod(void); xmlGenericError(xmlGenericErrorContext, \ "Unimplemented block at %s:%d\n", \ __FILE__, __LINE__); + +#ifdef LIBXML_XPATH_ENABLED /* * the following vars are used for XPath extensions, but * are also referenced within the parser cleanup routine. @@ -66,6 +68,7 @@ typedef libxml_xpathCallback libxml_xpathCallbackArray[]; static int libxml_xpathCallbacksAllocd = 10; static libxml_xpathCallbackArray *libxml_xpathCallbacks = NULL; static int libxml_xpathCallbacksNb = 0; +#endif /* LIBXML_XPATH_ENABLED */ /************************************************************************ * * @@ -160,6 +163,7 @@ PyObject * libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED) { +#ifdef LIBXML_XPATH_ENABLED int ix; /* @@ -178,6 +182,7 @@ libxml_xmlPythonCleanupParser(PyObject *self ATTRIBUTE_UNUSED, xmlFree(libxml_xpathCallbacks); libxml_xpathCallbacks = NULL; } +#endif /* LIBXML_XPATH_ENABLED */ xmlCleanupParser(); @@ -1327,6 +1332,7 @@ static xmlSAXHandler pythonSaxHandler = { * * ************************************************************************/ +#ifdef LIBXML_PUSH_ENABLED PyObject * libxml_xmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) @@ -1383,6 +1389,7 @@ libxml_htmlCreatePushParser(ATTRIBUTE_UNUSED PyObject * self, return (pyret); } #endif /* LIBXML_HTML_ENABLED */ +#endif /* LIBXML_PUSH_ENABLED */ #ifdef LIBXML_SAX1_ENABLED PyObject * @@ -2062,6 +2069,7 @@ libxml_xmlFreeTextReader(ATTRIBUTE_UNUSED PyObject *self, PyObject *args) { * * ************************************************************************/ +#ifdef LIBXML_XPATH_ENABLED static void libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs) { @@ -2236,6 +2244,7 @@ libxml_xmlXPathRegisterVariable(ATTRIBUTE_UNUSED PyObject * self, py_retval = libxml_intWrap(c_retval); return (py_retval); } +#endif /* LIBXML_XPATH_ENABLED */ /************************************************************************ * * @@ -2876,6 +2885,8 @@ libxml_xmlNewNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) * Local Catalog stuff * * * ************************************************************************/ + +#ifdef LIBXML_CATALOG_ENABLED static PyObject * libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) { @@ -2895,6 +2906,7 @@ libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) Py_INCREF(Py_None); return (Py_None); } +#endif /* LIBXML_CATALOG_ENABLED */ #ifdef LIBXML_SCHEMAS_ENABLED @@ -3611,7 +3623,9 @@ static PyMethodDef libxmlMethods[] = { {(char *)"xmlTextReaderGetErrorHandler", libxml_xmlTextReaderGetErrorHandler, METH_VARARGS, NULL }, {(char *)"xmlFreeTextReader", libxml_xmlFreeTextReader, METH_VARARGS, NULL }, #endif +#ifdef LIBXML_CATALOG_ENABLED {(char *)"addLocalCatalog", libxml_addLocalCatalog, METH_VARARGS, NULL }, +#endif #ifdef LIBXML_SCHEMAS_ENABLED {(char *)"xmlRelaxNGSetValidErrors", libxml_xmlRelaxNGSetValidErrors, METH_VARARGS, NULL}, {(char *)"xmlRelaxNGFreeValidCtxt", libxml_xmlRelaxNGFreeValidCtxt, METH_VARARGS, NULL}, diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h index d13c5964..e9cc6e3e 100644 --- a/python/libxml_wrap.h +++ b/python/libxml_wrap.h @@ -89,6 +89,7 @@ typedef struct { xmlNodePtr obj; } PyxmlNode_Object; +#ifdef LIBXML_XPATH_ENABLED #define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \ (((PyxmlXPathContext_Object *)(v))->obj)) @@ -104,6 +105,7 @@ typedef struct { PyObject_HEAD xmlXPathParserContextPtr obj; } PyxmlXPathParserContext_Object; +#endif /* LIBXML_XPATH_ENABLED */ #define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \ (((PyparserCtxt_Object *)(v))->obj)) @@ -121,6 +123,7 @@ typedef struct { xmlValidCtxtPtr obj; } PyValidCtxt_Object; +#ifdef LIBXML_CATALOG_ENABLED #define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \ (((Pycatalog_Object *)(v))->obj)) @@ -128,6 +131,7 @@ typedef struct { PyObject_HEAD xmlCatalogPtr obj; } Pycatalog_Object; +#endif /* LIBXML_CATALOG_ENABLED */ #ifdef LIBXML_REGEXP_ENABLED #define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \ @@ -267,12 +271,17 @@ PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns); PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns); PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns); PyObject * libxml_doubleWrap(double val); -PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt); PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt); +#ifdef LIBXML_XPATH_ENABLED +PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt); PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt); PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj); +xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj); +#endif PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid); +#ifdef LIBXML_CATALOG_ENABLED PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj); +#endif PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri); PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer); PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer); @@ -284,7 +293,6 @@ PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader); PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator); #endif -xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj); #ifdef LIBXML_SCHEMAS_ENABLED PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt); PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt); diff --git a/python/types.c b/python/types.c index 2782a6aa..480c925b 100644 --- a/python/types.c +++ b/python/types.c @@ -424,6 +424,21 @@ libxml_xmlElementPtrWrap(xmlElementPtr elem) return (ret); } +PyObject * +libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) +{ + PyObject *ret; + + if (ctxt == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + + ret = PyCapsule_New((void *) ctxt, (char *) "xmlParserCtxtPtr", NULL); + return (ret); +} + +#ifdef LIBXML_XPATH_ENABLED PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt) { @@ -450,20 +465,6 @@ libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt) return (ret); } -PyObject * -libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt) -{ - PyObject *ret; - - if (ctxt == NULL) { - Py_INCREF(Py_None); - return (Py_None); - } - - ret = PyCapsule_New((void *) ctxt, (char *) "xmlParserCtxtPtr", NULL); - return (ret); -} - /** * libxml_xmlXPathDestructNsNode: * cap: xmlNsPtr namespace node capsule object @@ -758,6 +759,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject *obj) } return (ret); } +#endif /* LIBXML_XPATH_ENABLED */ PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid) @@ -776,6 +778,7 @@ libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid) return (ret); } +#ifdef LIBXML_CATALOG_ENABLED PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) { @@ -790,6 +793,7 @@ libxml_xmlCatalogPtrWrap(xmlCatalogPtr catal) (char *) "xmlCatalogPtr", NULL); return (ret); } +#endif /* LIBXML_CATALOG_ENABLED */ PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer)