From ade4c7ed11aa1e997930a0231d1954fd81109ca8 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 4 Jan 2010 09:13:40 +0000 Subject: Python binding: add a pyobject->time_t conversion function --- bindings/python/wrapper_top.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'bindings/python/wrapper_top.c') diff --git a/bindings/python/wrapper_top.c b/bindings/python/wrapper_top.c index e1256d85..a24a2dba 100644 --- a/bindings/python/wrapper_top.c +++ b/bindings/python/wrapper_top.c @@ -378,10 +378,28 @@ failure: return noneRef(); } -/* wrapper around GObject */ - +/** + * get_time_t: + * @time: a #PyInt + * + * Convert a python integer object to a time_t value, considering it is a unsigned 32 bit integer + * value. + * + * Return: a time_t* value if time is a python integer, NULL otherwise. + */ +static time_t* +get_time_t(PyObject *time) +{ + if (time != Py_None && PyInt_Check(time)) { + time_t *val = malloc(sizeof(time_t)); + *val = (time_t)PyInt_AS_LONG(time); + return val; + } + return NULL; +} +/* wrapper around GObject */ static void PyGObjectPtr_dealloc(PyGObjectPtr *self) { -- cgit