2002-02-03 18:08:05 +03:00
/*
* types . c : converter functions between the internal representation
* and the Python objects
*
* See Copyright for the status of this software .
*
* daniel @ veillard . com
*/
# include "libxml_wrap.h"
PyObject *
2002-03-16 01:24:56 +03:00
libxml_intWrap ( int val )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_intWrap: val = %d \n " , val ) ;
# endif
ret = PyInt_FromLong ( ( long ) val ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-03 23:13:06 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_longWrap ( long val )
{
2002-02-03 23:13:06 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_longWrap: val = %ld \n " , val ) ;
# endif
ret = PyInt_FromLong ( val ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 23:13:06 +03:00
}
2002-02-03 18:08:05 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_doubleWrap ( double val )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_doubleWrap: val = %f \n " , val ) ;
# endif
ret = PyFloat_FromDouble ( ( double ) val ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_charPtrWrap ( char * str )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
/* TODO: look at deallocation */
ret = PyString_FromString ( str ) ;
xmlFree ( str ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-08 16:28:40 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_charPtrConstWrap ( const char * str )
{
2002-02-08 16:28:40 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-08 16:28:40 +03:00
}
/* TODO: look at deallocation */
ret = PyString_FromString ( str ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-08 16:28:40 +03:00
}
2002-02-03 18:08:05 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlCharPtrWrap ( xmlChar * str )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlCharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
/* TODO: look at deallocation */
2002-03-16 01:24:56 +03:00
ret = PyString_FromString ( ( char * ) str ) ;
2002-02-03 18:08:05 +03:00
xmlFree ( str ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-08 16:28:40 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlCharPtrConstWrap ( const xmlChar * str )
{
2002-02-08 16:28:40 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlCharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-08 16:28:40 +03:00
}
/* TODO: look at deallocation */
2002-03-16 01:24:56 +03:00
ret = PyString_FromString ( ( char * ) str ) ;
return ( ret ) ;
2002-02-08 16:28:40 +03:00
}
2002-02-03 18:08:05 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_constcharPtrWrap ( const char * str )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
/* TODO: look at deallocation */
ret = PyString_FromString ( str ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_constxmlCharPtrWrap ( const xmlChar * str )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlCharPtrWrap: str = %s \n " , str ) ;
# endif
if ( str = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
/* TODO: look at deallocation */
2002-03-16 01:24:56 +03:00
ret = PyString_FromString ( ( char * ) str ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlDocPtrWrap ( xmlDocPtr doc )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlDocPtrWrap: doc = %p \n " , doc ) ;
# endif
if ( doc = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
/* TODO: look at deallocation */
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) doc , ( char * ) " xmlDocPtr " ,
NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlNodePtrWrap ( xmlNodePtr node )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlNodePtrWrap: node = %p \n " , node ) ;
# endif
if ( node = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " xmlNodePtr " ,
NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-23 13:10:33 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlURIPtrWrap ( xmlURIPtr uri )
{
2002-02-23 13:10:33 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlURIPtrWrap: uri = %p \n " , uri ) ;
# endif
if ( uri = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-23 13:10:33 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) uri , ( char * ) " xmlURIPtr " ,
NULL ) ;
return ( ret ) ;
2002-02-23 13:10:33 +03:00
}
2002-02-03 18:08:05 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlNsPtrWrap ( xmlNsPtr ns )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlNsPtrWrap: node = %p \n " , ns ) ;
# endif
if ( ns = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) ns , ( char * ) " xmlNsPtr " ,
NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlAttrPtrWrap ( xmlAttrPtr attr )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlAttrNodePtrWrap: attr = %p \n " , attr ) ;
# endif
if ( attr = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) attr , ( char * ) " xmlAttrPtr " ,
NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlAttributePtrWrap ( xmlAttributePtr attr )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlAttributePtrWrap: attr = %p \n " , attr ) ;
# endif
if ( attr = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) attr ,
( char * ) " xmlAttributePtr " , NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlElementPtrWrap ( xmlElementPtr elem )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlElementNodePtrWrap: elem = %p \n " , elem ) ;
# endif
if ( elem = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) elem ,
( char * ) " xmlElementPtr " , NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlXPathContextPtrWrap ( xmlXPathContextPtr ctxt )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlXPathContextPtrWrap: ctxt = %p \n " , ctxt ) ;
# endif
if ( ctxt = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) ctxt ,
( char * ) " xmlXPathContextPtr " , NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-07 19:39:11 +03:00
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 ,
2002-03-16 01:24:56 +03:00
( char * ) " xmlXPathParserContextPtr " ,
NULL ) ;
2002-02-07 19:39:11 +03:00
return ( ret ) ;
}
2002-02-03 18:08:05 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlParserCtxtPtrWrap ( xmlParserCtxtPtr ctxt )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlParserCtxtPtrWrap: ctxt = %p \n " , ctxt ) ;
# endif
if ( ctxt = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2003-01-14 14:42:39 +03:00
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) ctxt ,
( char * ) " xmlParserCtxtPtr " , NULL ) ;
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlXPathObjectPtrWrap ( xmlXPathObjectPtr obj )
{
2002-02-03 18:08:05 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlXPathObjectPtrWrap: ctxt = %p \n " , obj ) ;
# endif
if ( obj = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
switch ( obj - > type ) {
2002-10-21 01:31:50 +04:00
case XPATH_XSLT_TREE : {
if ( ( obj - > nodesetval = = NULL ) | |
( obj - > nodesetval - > nodeNr = = 0 ) | |
( obj - > nodesetval - > nodeTab = = NULL ) ) {
ret = PyList_New ( 0 ) ;
} else {
int i , len = 0 ;
xmlNodePtr node ;
node = obj - > nodesetval - > nodeTab [ 0 ] - > children ;
while ( node ! = NULL ) {
len + + ;
node = node - > next ;
}
ret = PyList_New ( len ) ;
node = obj - > nodesetval - > nodeTab [ 0 ] - > children ;
for ( i = 0 ; i < len ; i + + ) {
PyList_SetItem ( ret , i , libxml_xmlNodePtrWrap ( node ) ) ;
node = node - > next ;
}
}
/*
* Return now , do not free the object passed down
*/
return ( ret ) ;
}
2002-02-03 18:08:05 +03:00
case XPATH_NODESET :
2002-03-16 01:24:56 +03:00
if ( ( obj - > nodesetval = = NULL )
2002-10-21 01:31:50 +04:00
| | ( obj - > nodesetval - > nodeNr = = 0 ) ) {
2002-03-16 01:24:56 +03:00
ret = PyList_New ( 0 ) ;
2002-10-21 01:31:50 +04:00
} else {
2002-03-16 01:24:56 +03:00
int i ;
xmlNodePtr node ;
ret = PyList_New ( obj - > nodesetval - > nodeNr ) ;
for ( i = 0 ; i < obj - > nodesetval - > nodeNr ; i + + ) {
node = obj - > nodesetval - > nodeTab [ i ] ;
/* TODO: try to cast directly to the proper node type */
PyList_SetItem ( ret , i , libxml_xmlNodePtrWrap ( node ) ) ;
}
}
break ;
2002-02-03 18:08:05 +03:00
case XPATH_BOOLEAN :
2002-03-16 01:24:56 +03:00
ret = PyInt_FromLong ( ( long ) obj - > boolval ) ;
break ;
2002-02-03 18:08:05 +03:00
case XPATH_NUMBER :
2002-03-16 01:24:56 +03:00
ret = PyFloat_FromDouble ( obj - > floatval ) ;
break ;
2002-02-03 18:08:05 +03:00
case XPATH_STRING :
2002-03-16 01:24:56 +03:00
ret = PyString_FromString ( ( char * ) obj - > stringval ) ;
break ;
2002-02-03 18:08:05 +03:00
case XPATH_POINT :
case XPATH_RANGE :
case XPATH_LOCATIONSET :
2002-03-16 01:24:56 +03:00
default :
printf ( " Unable to convert XPath object type %d \n " , obj - > type ) ;
Py_INCREF ( Py_None ) ;
ret = Py_None ;
2002-02-03 18:08:05 +03:00
}
xmlXPathFreeObject ( obj ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
xmlXPathObjectPtr
2002-03-16 01:24:56 +03:00
libxml_xmlXPathObjectPtrConvert ( PyObject * obj )
{
2002-03-01 16:00:53 +03:00
xmlXPathObjectPtr ret = NULL ;
2002-02-03 18:08:05 +03:00
# ifdef DEBUG
printf ( " libxml_xmlXPathObjectPtrConvert: obj = %p \n " , obj ) ;
# endif
if ( obj = = NULL ) {
2002-03-16 01:24:56 +03:00
return ( NULL ) ;
2002-02-03 18:08:05 +03:00
}
2002-03-16 01:24:56 +03:00
if PyFloat_Check
( obj ) {
ret = xmlXPathNewFloat ( ( double ) PyFloat_AS_DOUBLE ( obj ) ) ;
} else if PyString_Check
( obj ) {
xmlChar * str ;
str = xmlStrndup ( ( const xmlChar * ) PyString_AS_STRING ( obj ) ,
PyString_GET_SIZE ( obj ) ) ;
ret = xmlXPathWrapString ( str ) ;
} else if PyList_Check
( obj ) {
int i ;
PyObject * node ;
xmlNodePtr cur ;
xmlNodeSetPtr set ;
set = xmlXPathNodeSetCreate ( NULL ) ;
for ( i = 0 ; i < PyList_Size ( obj ) ; i + + ) {
node = PyList_GetItem ( obj , i ) ;
if ( ( node = = NULL ) | | ( node - > ob_type = = NULL ) )
continue ;
cur = NULL ;
if ( PyCObject_Check ( node ) ) {
printf ( " Got a CObject \n " ) ;
cur = PyxmlNode_Get ( node ) ;
} else if ( PyInstance_Check ( node ) ) {
PyInstanceObject * inst = ( PyInstanceObject * ) node ;
PyObject * name = inst - > in_class - > cl_name ;
if PyString_Check
( name ) {
char * type = PyString_AS_STRING ( name ) ;
PyObject * wrapper ;
if ( ! strcmp ( type , " xmlNode " ) ) {
wrapper =
PyObject_GetAttrString ( node , ( char * ) " _o " ) ;
if ( wrapper ! = NULL ) {
cur = PyxmlNode_Get ( wrapper ) ;
}
}
}
} else {
printf ( " Unknown object in Python return list \n " ) ;
}
if ( cur ! = NULL ) {
xmlXPathNodeSetAdd ( set , cur ) ;
}
}
ret = xmlXPathWrapNodeSet ( set ) ;
2002-02-03 18:08:05 +03:00
} else {
2002-03-16 01:24:56 +03:00
printf ( " Unable to convert Python Object to XPath " ) ;
2002-02-03 18:08:05 +03:00
}
Py_DECREF ( obj ) ;
2002-03-16 01:24:56 +03:00
return ( ret ) ;
2002-02-03 18:08:05 +03:00
}
2002-02-07 19:39:11 +03:00
PyObject *
2002-03-16 01:24:56 +03:00
libxml_xmlCatalogPtrWrap ( xmlCatalogPtr catal )
{
2002-02-07 19:39:11 +03:00
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlNodePtrWrap: catal = %p \n " , catal ) ;
# endif
if ( catal = = NULL ) {
2002-03-16 01:24:56 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
2002-02-07 19:39:11 +03:00
}
2002-03-16 01:24:56 +03:00
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) catal ,
( char * ) " xmlCatalogPtr " , NULL ) ;
return ( ret ) ;
2002-02-07 19:39:11 +03:00
}
2002-09-12 19:00:57 +04:00
PyObject *
libxml_xmlOutputBufferPtrWrap ( xmlOutputBufferPtr buffer )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlOutputBufferPtrWrap: buffer = %p \n " , buffer ) ;
# endif
if ( buffer = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) buffer ,
( char * ) " xmlOutputBufferPtr " , NULL ) ;
return ( ret ) ;
}
PyObject *
libxml_xmlParserInputBufferPtrWrap ( xmlParserInputBufferPtr buffer )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlParserInputBufferPtrWrap: buffer = %p \n " , buffer ) ;
# endif
if ( buffer = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) buffer ,
( char * ) " xmlParserInputBufferPtr " , NULL ) ;
return ( ret ) ;
}
2002-09-26 02:25:35 +04:00
2003-02-04 19:14:33 +03:00
# ifdef LIBXML_REGEXP_ENABLED
2002-09-26 02:25:35 +04:00
PyObject *
libxml_xmlRegexpPtrWrap ( xmlRegexpPtr regexp )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlRegexpPtrWrap: regexp = %p \n " , regexp ) ;
# endif
if ( regexp = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) regexp ,
( char * ) " xmlRegexpPtr " , NULL ) ;
return ( ret ) ;
}
2003-02-04 19:14:33 +03:00
# endif /* LIBXML_REGEXP_ENABLED */
2002-12-15 02:00:35 +03:00
PyObject *
libxml_xmlTextReaderPtrWrap ( xmlTextReaderPtr reader )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlTextReaderPtrWrap: reader = %p \n " , reader ) ;
# endif
if ( reader = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) reader ,
( char * ) " xmlTextReaderPtr " , NULL ) ;
return ( ret ) ;
}
2003-01-21 00:26:34 +03:00
PyObject *
libxml_xmlTextReaderLocatorPtrWrap ( xmlTextReaderLocatorPtr locator )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlTextReaderLocatorPtrWrap: locator = %p \n " , locator ) ;
# endif
if ( locator = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) locator ,
( char * ) " xmlTextReaderLocatorPtr " , NULL ) ;
return ( ret ) ;
}
2003-02-10 02:33:36 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
PyObject *
libxml_xmlRelaxNGPtrWrap ( xmlRelaxNGPtr ctxt )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlRelaxNGPtrWrap: ctxt = %p \n " , ctxt ) ;
# endif
if ( ctxt = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) ctxt ,
( char * ) " xmlRelaxNGPtr " , NULL ) ;
return ( ret ) ;
}
PyObject *
libxml_xmlRelaxNGParserCtxtPtrWrap ( xmlRelaxNGParserCtxtPtr ctxt )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlRelaxNGParserCtxtPtrWrap: ctxt = %p \n " , ctxt ) ;
# endif
if ( ctxt = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) ctxt ,
( char * ) " xmlRelaxNGParserCtxtPtr " , NULL ) ;
return ( ret ) ;
}
PyObject *
libxml_xmlRelaxNGValidCtxtPtrWrap ( xmlRelaxNGValidCtxtPtr valid )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libxml_xmlRelaxNGValidCtxtPtrWrap: valid = %p \n " , valid ) ;
# endif
if ( valid = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) valid ,
( char * ) " xmlRelaxNGValidCtxtPtr " , NULL ) ;
return ( ret ) ;
}
# endif /* LIBXML_SCHEMAS_ENABLED */