diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-06 08:42:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-06 11:09:11 +0300 |
commit | 9fd569a654ded46901c7f20c5fe080972cbb10d2 (patch) | |
tree | 933b893aeaa0a8bffe230933523512340dfa016d /source/blender/python/bmesh/bmesh_py_types_meshdata.c | |
parent | ee58d449455df9470c4a0a902056b8c2001128bf (diff) |
PyAPI: add utilities PyTuple_SET_ITEMS, Py_INCREF_RET
Setting all values of a tuple is such a common operation that it deserves its own macro.
Also added Py_INCREF_RET to avoid confusing use of comma operator.
Diffstat (limited to 'source/blender/python/bmesh/bmesh_py_types_meshdata.c')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_meshdata.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index df0c39fd3b3..94f38ffdec7 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -45,6 +45,8 @@ #include "bmesh_py_types_meshdata.h" +#include "../generic/python_utildefines.h" + /* Mesh BMTexPoly * ************** */ @@ -684,10 +686,9 @@ static PyObject *bpy_bmdeformvert_items(BPy_BMDeformVert *self) ret = PyList_New(self->data->totweight); for (i = 0; i < self->data->totweight; i++, dw++) { item = PyTuple_New(2); - - PyTuple_SET_ITEM(item, 0, PyLong_FromLong(dw->def_nr)); - PyTuple_SET_ITEM(item, 1, PyFloat_FromDouble(dw->weight)); - + PyTuple_SET_ITEMS(item, + PyLong_FromLong(dw->def_nr), + PyFloat_FromDouble(dw->weight)); PyList_SET_ITEM(ret, i, item); } @@ -721,7 +722,7 @@ static PyObject *bpy_bmdeformvert_get(BPy_BMDeformVert *self, PyObject *args) return PyFloat_FromDouble(dw->weight); } else { - return Py_INCREF(def), def; + return Py_INCREF_RET(def); } } } |