summaryrefslogtreecommitdiffstats
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/types.c b/types.c
new file mode 100644
index 0000000..1f71198
--- /dev/null
+++ b/types.c
@@ -0,0 +1,119 @@
+/*
+ * types.c: converter functions between the internal representation
+ * and the Python objects
+ *
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * Daniel Veillard <veillard@redhat.com>
+ */
+
+#include "libvir_wrap.h"
+
+PyObject *
+libvir_intWrap(int val)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_intWrap: val = %d\n", val);
+#endif
+ ret = PyInt_FromLong((long) val);
+ return (ret);
+}
+
+PyObject *
+libvir_longWrap(long val)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_longWrap: val = %ld\n", val);
+#endif
+ ret = PyInt_FromLong(val);
+ return (ret);
+}
+
+PyObject *
+libvir_charPtrWrap(char *str)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_xmlcharPtrWrap: str = %s\n", str);
+#endif
+ if (str == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyString_FromString(str);
+ free(str);
+ return (ret);
+}
+
+PyObject *
+libvir_constcharPtrWrap(const char *str)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_xmlcharPtrWrap: str = %s\n", str);
+#endif
+ if (str == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyString_FromString(str);
+ return (ret);
+}
+
+PyObject *
+libvir_charPtrConstWrap(const char *str)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_xmlcharPtrWrap: str = %s\n", str);
+#endif
+ if (str == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret = PyString_FromString(str);
+ return (ret);
+}
+
+PyObject *
+libvir_virDomainPtrWrap(virDomainPtr node)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_virDomainPtrWrap: node = %p\n", node);
+#endif
+ if (node == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret =
+ PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virDomainPtr",
+ NULL);
+ return (ret);
+}
+
+PyObject *
+libvir_virConnectPtrWrap(virConnectPtr node)
+{
+ PyObject *ret;
+
+#ifdef DEBUG
+ printf("libvir_virConnectPtrWrap: node = %p\n", node);
+#endif
+ if (node == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ ret =
+ PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virConnectPtr",
+ NULL);
+ return (ret);
+}