2005-12-19 16:34:11 +00:00
/*
* types . c : converter functions between the internal representation
* and the Python objects
*
2007-12-07 10:08:06 +00:00
* Copyright ( C ) 2005 , 2007 Red Hat , Inc .
2005-12-19 16:34:11 +00:00
*
* Daniel Veillard < veillard @ redhat . com >
*/
2008-01-29 18:15:54 +00:00
# include <config.h>
2007-12-07 10:08:06 +00:00
2008-04-18 18:31:32 +00:00
/* Horrible kludge to work around even more horrible name-space pollution
* via Python . h . That file includes / usr / include / python2 .5 / pyconfig * . h ,
* which has over 180 autoconf - style HAVE_ * definitions . Shame on them . */
# undef HAVE_PTHREAD_H
2006-02-09 17:45:11 +00:00
# include "libvirt_wrap.h"
2005-12-19 16:34:11 +00:00
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_intWrap ( int val )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
ret = PyInt_FromLong ( ( long ) val ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_longWrap ( long val )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
ret = PyInt_FromLong ( val ) ;
return ( ret ) ;
}
2006-11-15 19:40:00 +00:00
PyObject *
libvirt_ulongWrap ( unsigned long val )
{
PyObject * ret ;
ret = PyLong_FromLong ( val ) ;
return ( ret ) ;
2008-02-05 19:27:37 +00:00
}
2006-11-15 19:40:00 +00:00
2006-01-31 10:24:12 +00:00
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_longlongWrap ( long long val )
2006-01-31 10:24:12 +00:00
{
PyObject * ret ;
ret = PyLong_FromUnsignedLongLong ( ( unsigned long long ) val ) ;
return ( ret ) ;
}
2005-12-19 16:34:11 +00:00
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_charPtrWrap ( char * str )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
free ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_constcharPtrWrap ( const char * str )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_charPtrConstWrap ( const char * str )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_virDomainPtrWrap ( virDomainPtr node )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virDomainPtr " ,
NULL ) ;
return ( ret ) ;
}
2007-03-09 15:42:50 +00:00
PyObject *
libvirt_virNetworkPtrWrap ( virNetworkPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virNetworkPtr " ,
NULL ) ;
return ( ret ) ;
}
2008-02-20 15:26:22 +00:00
PyObject *
libvirt_virStoragePoolPtrWrap ( virStoragePoolPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStoragePoolPtr " ,
NULL ) ;
return ( ret ) ;
}
PyObject *
libvirt_virStorageVolPtrWrap ( virStorageVolPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStorageVolPtr " ,
NULL ) ;
return ( ret ) ;
}
2005-12-19 16:34:11 +00:00
PyObject *
2006-02-09 17:45:11 +00:00
libvirt_virConnectPtrWrap ( virConnectPtr node )
2005-12-19 16:34:11 +00:00
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virConnectPtr " ,
NULL ) ;
return ( ret ) ;
}