2 * types.c: converter functions between the internal representation
3 * and the Python objects
5 * Copyright (C) 2005, 2007 Red Hat, Inc.
7 * Daniel Veillard <veillard@redhat.com>
12 /* Horrible kludge to work around even more horrible name-space pollution
13 * via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
14 * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
17 #include "typewrappers.h"
20 libvirt_intWrap(int val
)
23 ret
= PyInt_FromLong((long) val
);
28 libvirt_longWrap(long val
)
31 ret
= PyInt_FromLong(val
);
36 libvirt_ulongWrap(unsigned long val
)
39 ret
= PyLong_FromLong(val
);
44 libvirt_longlongWrap(long long val
)
47 ret
= PyLong_FromUnsignedLongLong((unsigned long long) val
);
52 libvirt_charPtrWrap(char *str
)
60 ret
= PyString_FromString(str
);
66 libvirt_constcharPtrWrap(const char *str
)
74 ret
= PyString_FromString(str
);
79 libvirt_charPtrConstWrap(const char *str
)
87 ret
= PyString_FromString(str
);
92 libvirt_virDomainPtrWrap(virDomainPtr node
)
101 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virDomainPtr",
107 libvirt_virNetworkPtrWrap(virNetworkPtr node
)
116 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virNetworkPtr",
122 libvirt_virInterfacePtrWrap(virInterfacePtr node
)
131 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virInterfacePtr",
137 libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node
)
146 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virStoragePoolPtr",
152 libvirt_virStorageVolPtrWrap(virStorageVolPtr node
)
161 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virStorageVolPtr",
167 libvirt_virConnectPtrWrap(virConnectPtr node
)
176 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virConnectPtr",
182 libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node
)
191 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virNodeDevicePtr",
197 libvirt_virSecretPtrWrap(virSecretPtr node
)
205 ret
= PyCObject_FromVoidPtrAndDesc(node
, (char *) "virSecretPtr", NULL
);
210 libvirt_virStreamPtrWrap(virStreamPtr node
)
218 ret
= PyCObject_FromVoidPtrAndDesc(node
, (char *) "virStreamPtr", NULL
);
223 libvirt_virEventHandleCallbackWrap(virEventHandleCallback node
)
229 printf("%s: WARNING - Wrapping None\n", __func__
);
233 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virEventHandleCallback",
239 libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node
)
244 printf("%s: WARNING - Wrapping None\n", __func__
);
249 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virEventTimeoutCallback",
255 libvirt_virFreeCallbackWrap(virFreeCallback node
)
264 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "virFreeCallback",
270 libvirt_virVoidPtrWrap(void* node
)
279 PyCObject_FromVoidPtrAndDesc((void *) node
, (char *) "void*",