diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 09:03:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-04 09:43:57 +0300 |
commit | 8106a6b75d45cc7472fd92f3b045697e30be8c73 (patch) | |
tree | 3b81857d4df29ce8bcc8d0043045aa6c713e4a78 /source/blender/python/bmesh | |
parent | c41431f1e9e75a424717b4080434b940c2685c20 (diff) |
mathutils: refactor instantiation
remove 'type' argument, very few mathutils objects are wrapped,
add new function for creating wrapped objects.
also fixes unlikely memory leak if the data-array can't be allocated.
Diffstat (limited to 'source/blender/python/bmesh')
4 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index ec6810fe49a..e8ef4c58895 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -540,10 +540,10 @@ 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 */ diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 8c13a66bea0..d3f4bfcacda 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -342,7 +342,7 @@ PyDoc_STRVAR(bpy_bmvert_co_doc, static PyObject *bpy_bmvert_co_get(BPy_BMVert *self) { BPY_BM_CHECK_OBJ(self); - return Vector_CreatePyObject(self->v->co, 3, Py_WRAP, NULL); + return Vector_CreatePyObject_wrap(self->v->co, 3, NULL); } static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value) @@ -364,7 +364,7 @@ PyDoc_STRVAR(bpy_bmvert_normal_doc, static PyObject *bpy_bmvert_normal_get(BPy_BMVert *self) { BPY_BM_CHECK_OBJ(self); - return Vector_CreatePyObject(self->v->no, 3, Py_WRAP, NULL); + return Vector_CreatePyObject_wrap(self->v->no, 3, NULL); } static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value) @@ -468,7 +468,7 @@ PyDoc_STRVAR(bpy_bmface_normal_doc, static PyObject *bpy_bmface_normal_get(BPy_BMFace *self) { BPY_BM_CHECK_OBJ(self); - return Vector_CreatePyObject(self->f->no, 3, Py_WRAP, NULL); + return Vector_CreatePyObject_wrap(self->f->no, 3, NULL); } static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value) @@ -1530,7 +1530,7 @@ static PyObject *bpy_bmedge_calc_tangent(BPy_BMEdge *self, PyObject *args) BPY_BM_CHECK_OBJ(py_loop); /* no need to check if they are from the same mesh or even connected */ BM_edge_calc_face_tangent(self->e, py_loop->l, vec); - return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(vec, 3, NULL); } } @@ -1711,7 +1711,7 @@ static PyObject *bpy_bmface_calc_center_mean(BPy_BMFace *self) BPY_BM_CHECK_OBJ(self); BM_face_calc_center_mean(self->f, cent); - return Vector_CreatePyObject(cent, 3, Py_NEW, NULL); + return Vector_CreatePyObject(cent, 3, NULL); } PyDoc_STRVAR(bpy_bmface_calc_center_mean_weighted_doc, @@ -1728,7 +1728,7 @@ static PyObject *bpy_bmface_calc_center_mean_weighted(BPy_BMFace *self) BPY_BM_CHECK_OBJ(self); BM_face_calc_center_mean_weighted(self->f, cent); - return Vector_CreatePyObject(cent, 3, Py_NEW, NULL); + return Vector_CreatePyObject(cent, 3, NULL); } PyDoc_STRVAR(bpy_bmface_calc_center_bounds_doc, @@ -1745,7 +1745,7 @@ static PyObject *bpy_bmface_calc_center_bounds(BPy_BMFace *self) BPY_BM_CHECK_OBJ(self); BM_face_calc_center_bounds(self->f, cent); - return Vector_CreatePyObject(cent, 3, Py_NEW, NULL); + return Vector_CreatePyObject(cent, 3, NULL); } @@ -1849,7 +1849,7 @@ static PyObject *bpy_bmloop_calc_normal(BPy_BMLoop *self) float vec[3]; BPY_BM_CHECK_OBJ(self); BM_loop_calc_face_normal(self->l, vec); - return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(vec, 3, NULL); } PyDoc_STRVAR(bpy_bmloop_calc_tangent_doc, @@ -1866,7 +1866,7 @@ static PyObject *bpy_bmloop_calc_tangent(BPy_BMLoop *self) float vec[3]; BPY_BM_CHECK_OBJ(self); BM_loop_calc_face_tangent(self->l, vec); - return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); + return Vector_CreatePyObject(vec, 3, NULL); } /* Vert Seq diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 6ecb01a8528..3c1502dc72b 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -1014,7 +1014,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer) } case CD_SHAPEKEY: { - ret = Vector_CreatePyObject((float *)value, 3, Py_WRAP, NULL); + ret = Vector_CreatePyObject_wrap((float *)value, 3, NULL); break; } case CD_BWEIGHT: diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index 4fa5d0f755c..df0c39fd3b3 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -150,7 +150,7 @@ PyDoc_STRVAR(bpy_bmloopuv_uv_doc, ); static PyObject *bpy_bmloopuv_uv_get(BPy_BMLoopUV *self, void *UNUSED(closure)) { - return Vector_CreatePyObject(self->data->uv, 2, Py_WRAP, NULL); + return Vector_CreatePyObject_wrap(self->data->uv, 2, NULL); } static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED(closure)) @@ -263,7 +263,7 @@ PyDoc_STRVAR(bpy_bmvertskin_radius_doc, ); static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure)) { - return Vector_CreatePyObject(self->data->radius, 2, Py_WRAP, NULL); + return Vector_CreatePyObject_wrap(self->data->radius, 2, NULL); } static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure)) |