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/freestyle/intern | |
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/freestyle/intern')
4 files changed, 17 insertions, 13 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp index dd678ee6fbd..ad54a81f156 100644 --- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp @@ -92,10 +92,11 @@ ContextFunctions_get_border(PyObject *self) { BBox<Vec2i> border(ContextFunctions::GetBorderCF()); PyObject *v = PyTuple_New(4); - PyTuple_SET_ITEM(v, 0, PyLong_FromLong(border.getMin().x())); - PyTuple_SET_ITEM(v, 1, PyLong_FromLong(border.getMin().y())); - PyTuple_SET_ITEM(v, 2, PyLong_FromLong(border.getMax().x())); - PyTuple_SET_ITEM(v, 3, PyLong_FromLong(border.getMax().y())); + PyTuple_SET_ITEMS(v, + PyLong_FromLong(border.getMin().x()), + PyLong_FromLong(border.getMin().y()), + PyLong_FromLong(border.getMax().x()), + PyLong_FromLong(border.getMax().y())); return v; } diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index b0b43acb8da..4e1a0a119aa 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -401,8 +401,9 @@ PyObject *BPy_CurvePoint_from_CurvePoint(CurvePoint& cp) PyObject *BPy_directedViewEdge_from_directedViewEdge(ViewVertex::directedViewEdge& dve) { PyObject *py_dve = PyTuple_New(2); - PyTuple_SET_ITEM(py_dve, 0, BPy_ViewEdge_from_ViewEdge(*(dve.first))); - PyTuple_SET_ITEM(py_dve, 1, PyBool_from_bool(dve.second)); + PyTuple_SET_ITEMS(py_dve, + BPy_ViewEdge_from_ViewEdge(*(dve.first)), + PyBool_from_bool(dve.second)); return py_dve; } diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index e6e763e763e..35c1e58369c 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -92,6 +92,7 @@ extern "C" { /////////////////////////////////////////////////////////////////////////////////////////// #include "mathutils/mathutils.h" +#include "generic/python_utildefines.h" //============================== // C++ => Python diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 6845bc3ed12..1d51bf287af 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -400,13 +400,14 @@ static PyObject *SVertex_curvatures_get(BPy_SVertex *self, void *UNUSED(closure) Vec3r e2(info->e2.x(), info->e2.y(), info->e2.z()); Vec3r er(info->er.x(), info->er.y(), info->er.z()); PyObject *retval = PyTuple_New(7); - PyTuple_SET_ITEM(retval, 0, PyFloat_FromDouble(info->K1)); - PyTuple_SET_ITEM(retval, 2, Vector_from_Vec3r(e1)); - PyTuple_SET_ITEM(retval, 1, PyFloat_FromDouble(info->K2)); - PyTuple_SET_ITEM(retval, 3, Vector_from_Vec3r(e2)); - PyTuple_SET_ITEM(retval, 4, PyFloat_FromDouble(info->Kr)); - PyTuple_SET_ITEM(retval, 5, Vector_from_Vec3r(er)); - PyTuple_SET_ITEM(retval, 6, PyFloat_FromDouble(info->dKr)); + PyTuple_SET_ITEMS(retval, + PyFloat_FromDouble(info->K1), + PyFloat_FromDouble(info->K2), + Vector_from_Vec3r(e1), + Vector_from_Vec3r(e2), + PyFloat_FromDouble(info->Kr), + Vector_from_Vec3r(er), + PyFloat_FromDouble(info->dKr)); return retval; } |