diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-06 09:46:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-06 09:46:00 +0400 |
commit | 90efa345c2b512c7dbc615b6210127070ff8b03f (patch) | |
tree | 7a3e0dbc1d1ee3534c9d5b6d5a05ad1858a60728 /source/blender/python/generic/py_capi_utils.c | |
parent | 7b8e07b7d011fe7245499a267ac967d5787a59e9 (diff) |
Python API: utility function for filling a tuple with a single value.
Diffstat (limited to 'source/blender/python/generic/py_capi_utils.c')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 8e90d484a9d..a37933d027e 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -162,6 +162,20 @@ PyObject *PyC_FromArray(const void *array, int length, const PyTypeObject *type, return tuple; } +/** + * Caller needs to ensure tuple is uninitialized. + * Handy for filling a typle with None for eg. + */ +void PyC_Tuple_Fill(PyObject *tuple, PyObject *value) +{ + unsigned int tot = PyTuple_GET_SIZE(tuple); + unsigned int i; + + for (i = 0; i < tot; i++) { + PyTuple_SET_ITEM(tuple, i, value); + Py_INCREF(value); + } +} /* for debugging */ void PyC_ObSpit(const char *name, PyObject *var) |