mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-02 04:21:59 +03:00
* Makefile.am configure.in libvir.spec.in python/*: added a first
version for python bindings, heavilly based on libxml2/libxslt way of doing things, maybe this need to be revisited. Added packaging too. * src/hash.h: fixed the Copyright notice. Daniel
This commit is contained in:
119
types.c
Normal file
119
types.c
Normal file
@ -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);
|
||||
}
|
Reference in New Issue
Block a user