diff options
Diffstat (limited to 'source/blender/python/bmesh/bmesh_py_ops_call.c')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_ops_call.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index 9c9b69186ab..1dc70c3d288 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -27,7 +27,7 @@ * \ingroup pybmesh * * This file provides __call__ aka BPy_BMO_call for - * the bmesh operatorand has been given its own file + * the bmesh operator and has been given its own file * because argument conversion is involved. */ @@ -39,11 +39,11 @@ #include "bmesh.h" -#include "bmesh_py_ops.h" #include "bmesh_py_ops_call.h" /* own include */ #include "bmesh_py_types.h" -#include "bmesh_py_utils.h" + +#include "../generic/python_utildefines.h" static int bpy_bm_op_as_py_error(BMesh *bm) { @@ -69,9 +69,10 @@ static int bpy_bm_op_as_py_error(BMesh *bm) * \param htype Test \a value matches this type. * \param descr Description text. */ -static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char htype, - /* for error messages */ - const char *opname, const char *slot_name, const char *descr) +static int bpy_slot_from_py_elem_check( + BPy_BMElem *value, BMesh *bm, const char htype, + /* for error messages */ + const char *opname, const char *slot_name, const char *descr) { if (!BPy_BMElem_Check(value) || !(value->ele->head.htype & htype)) @@ -107,10 +108,11 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char * \param htype_bmo The type(s) supported by the target slot. * \param descr Description text. */ -static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, - const char htype_py, const char htype_bmo, - /* for error messages */ - const char *opname, const char *slot_name, const char *descr) +static int bpy_slot_from_py_elemseq_check( + BPy_BMGeneric *value, BMesh *bm, + const char htype_py, const char htype_bmo, + /* for error messages */ + const char *opname, const char *slot_name, const char *descr) { if (value->bm == NULL) { PyErr_Format(PyExc_TypeError, @@ -142,9 +144,10 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, /** * Use for giving py args to an operator. */ -static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, - /* the are just for exception messages */ - const char *opname, const char *slot_name) +static int bpy_slot_from_py( + BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, + /* the are just for exception messages */ + const char *opname, const char *slot_name) { switch (slot->slot_type) { case BMO_OP_SLOT_BOOL: @@ -507,7 +510,7 @@ static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObjec return -1; } } - /* fall-through */ + break; } default: /* TODO --- many others */ @@ -542,20 +545,20 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot) item = PyFloat_FromDouble((double)BMO_SLOT_AS_FLOAT(slot)); break; case BMO_OP_SLOT_MAT: - item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, Py_NEW, NULL); + item = Matrix_CreatePyObject((float *)BMO_SLOT_AS_MATRIX(slot), 4, 4, NULL); break; case BMO_OP_SLOT_VEC: - item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, Py_NEW, NULL); + item = Vector_CreatePyObject(BMO_SLOT_AS_VECTOR(slot), slot->len, NULL); break; case BMO_OP_SLOT_PTR: BLI_assert(0); /* currently we don't have any pointer return values in use */ - item = (Py_INCREF(Py_None), Py_None); + item = Py_INCREF_RET(Py_None); break; case BMO_OP_SLOT_ELEMENT_BUF: { if (slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) { BMHeader *ele = BMO_slot_buffer_get_single(slot); - item = ele ? BPy_BMElem_CreatePyObject(bm, ele) : (Py_INCREF(Py_None), Py_None); + item = ele ? BPy_BMElem_CreatePyObject(bm, ele) : Py_INCREF_RET(Py_None); } else { const int size = slot->len; @@ -666,7 +669,7 @@ static PyObject *bpy_slot_to_py(BMesh *bm, BMOpSlot *slot) } case BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL: /* can't convert from these */ - item = (Py_INCREF(Py_None), Py_None); + item = Py_INCREF_RET(Py_None); break; } break; @@ -745,7 +748,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) ret = NULL; /* exception raised above */ } else if (bmop.slots_out[0].slot_name == NULL) { - ret = (Py_INCREF(Py_None), Py_None); + ret = Py_INCREF_RET(Py_None); } else { /* build return value */ @@ -761,7 +764,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) /* this function doesn't throw exceptions */ item = bpy_slot_to_py(bm, slot); if (item == NULL) { - item = (Py_INCREF(Py_None), Py_None); + item = Py_INCREF_RET(Py_None); } #if 1 |