diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-01-04 09:13:40 +0000 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-01-04 09:13:40 +0000 |
| commit | ade4c7ed11aa1e997930a0231d1954fd81109ca8 (patch) | |
| tree | 17a4dab033e341b5ebb7e85548996e6b0648414c /bindings/python | |
| parent | 0f3a96339915688ec97f611ff2e8ce72841407bc (diff) | |
| download | lasso-ade4c7ed11aa1e997930a0231d1954fd81109ca8.tar.gz lasso-ade4c7ed11aa1e997930a0231d1954fd81109ca8.tar.xz lasso-ade4c7ed11aa1e997930a0231d1954fd81109ca8.zip | |
Python binding: add a pyobject->time_t conversion function
Diffstat (limited to 'bindings/python')
| -rw-r--r-- | bindings/python/wrapper_top.c | 22 |
1 files changed, 20 insertions, 2 deletions
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) { |
