diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2009-09-16 14:03:53 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2009-09-21 14:41:46 +0100 |
commit | a9ea906035bcf5cbe95db64f51ed2ff7cec2b503 (patch) | |
tree | 0f55b2a22a6e4b44ec5c41b267839f82757090af /typewrappers.c | |
parent | a5bab7085e42d87561c817f91c26def384611f2e (diff) | |
download | libvirt-python-v6-a9ea906035bcf5cbe95db64f51ed2ff7cec2b503.tar.gz libvirt-python-v6-a9ea906035bcf5cbe95db64f51ed2ff7cec2b503.tar.xz libvirt-python-v6-a9ea906035bcf5cbe95db64f51ed2ff7cec2b503.zip |
Re-arrange python generator to make it clear what's auto-generated
* README: New file describing what each file is used for
* livvirt-override.c, libvirt-override.py, libvirt-override-api.xml,
libvirt-override-virConnect.py: Manually written code overriding
the generator
* typewrappers.c, typewrappers.h: Data type wrappers
* generator.py: Automatically pre-prend contents of libvirt-override.py
to generated libvirt.py. Output into libvirt.py directly instead of
libvirtclass.py. Don't generate libvirtclass.txt at all. Write C
files into libvirt.c/.h directly
* Makefile.am: Remove rule for creating libvirt.py from libvirt-override.py
and libvirtclass.py, since generator.py does it directly
Diffstat (limited to 'typewrappers.c')
-rw-r--r-- | typewrappers.c | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/typewrappers.c b/typewrappers.c new file mode 100644 index 0000000..0d8ac97 --- /dev/null +++ b/typewrappers.c @@ -0,0 +1,269 @@ +/* + * types.c: converter functions between the internal representation + * and the Python objects + * + * Copyright (C) 2005, 2007 Red Hat, Inc. + * + * Daniel Veillard <veillard@redhat.com> + */ + +#include <config.h> + +/* 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 + +#include "typewrappers.h" + +PyObject * +libvirt_intWrap(int val) +{ + PyObject *ret; + ret = PyInt_FromLong((long) val); + return (ret); +} + +PyObject * +libvirt_longWrap(long val) +{ + PyObject *ret; + ret = PyInt_FromLong(val); + return (ret); +} + +PyObject * +libvirt_ulongWrap(unsigned long val) +{ + PyObject *ret; + ret = PyLong_FromLong(val); + return (ret); +} + +PyObject * +libvirt_longlongWrap(long long val) +{ + PyObject *ret; + ret = PyLong_FromUnsignedLongLong((unsigned long long) val); + return (ret); +} + +PyObject * +libvirt_charPtrWrap(char *str) +{ + PyObject *ret; + + if (str == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyString_FromString(str); + free(str); + return (ret); +} + +PyObject * +libvirt_constcharPtrWrap(const char *str) +{ + PyObject *ret; + + if (str == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyString_FromString(str); + return (ret); +} + +PyObject * +libvirt_charPtrConstWrap(const char *str) +{ + PyObject *ret; + + if (str == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = PyString_FromString(str); + return (ret); +} + +PyObject * +libvirt_virDomainPtrWrap(virDomainPtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virDomainPtr", + NULL); + return (ret); +} + +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); +} + +PyObject * +libvirt_virInterfacePtrWrap(virInterfacePtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virInterfacePtr", + NULL); + return (ret); +} + +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); +} + +PyObject * +libvirt_virConnectPtrWrap(virConnectPtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virConnectPtr", + NULL); + return (ret); +} + +PyObject * +libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virNodeDevicePtr", + NULL); + return (ret); +} + +PyObject * +libvirt_virSecretPtrWrap(virSecretPtr node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + ret = PyCObject_FromVoidPtrAndDesc(node, (char *) "virSecretPtr", NULL); + return (ret); +} + +PyObject * +libvirt_virEventHandleCallbackWrap(virEventHandleCallback node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + printf("%s: WARNING - Wrapping None\n", __func__); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virEventHandleCallback", + NULL); + return (ret); +} + +PyObject * +libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node) +{ + PyObject *ret; + + if (node == NULL) { + printf("%s: WARNING - Wrapping None\n", __func__); + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virEventTimeoutCallback", + NULL); + return (ret); +} + +PyObject * +libvirt_virFreeCallbackWrap(virFreeCallback node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virFreeCallback", + NULL); + return (ret); +} + +PyObject * +libvirt_virVoidPtrWrap(void* node) +{ + PyObject *ret; + + if (node == NULL) { + Py_INCREF(Py_None); + return (Py_None); + } + ret = + PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "void*", + NULL); + return (ret); +} |