[Bf-blender-cvs] [25ec4b437fe] master: Cleanup: style, use braces for the Python API

Campbell Barton noreply at git.blender.org
Fri Mar 29 21:21:20 CET 2019


Commit: 25ec4b437fe927205a810470cdc23efd7282c85b
Author: Campbell Barton
Date:   Sat Mar 30 06:12:48 2019 +1100
Branches: master
https://developer.blender.org/rB25ec4b437fe927205a810470cdc23efd7282c85b

Cleanup: style, use braces for the Python API

===================================================================

M	source/blender/python/bmesh/bmesh_py_ops.c
M	source/blender/python/bmesh/bmesh_py_types.c
M	source/blender/python/bmesh/bmesh_py_types_customdata.c
M	source/blender/python/bmesh/bmesh_py_types_meshdata.c
M	source/blender/python/bmesh/bmesh_py_types_select.c
M	source/blender/python/generic/bgl.c
M	source/blender/python/generic/blf_py_api.c
M	source/blender/python/generic/bpy_internal_import.c
M	source/blender/python/generic/idprop_py_api.c
M	source/blender/python/generic/py_capi_utils.c
M	source/blender/python/gpu/gpu_py_offscreen.c
M	source/blender/python/gpu/gpu_py_types.c
M	source/blender/python/intern/bpy.c
M	source/blender/python/intern/bpy_app.c
M	source/blender/python/intern/bpy_app_handlers.c
M	source/blender/python/intern/bpy_app_translations.c
M	source/blender/python/intern/bpy_capi_utils.c
M	source/blender/python/intern/bpy_driver.c
M	source/blender/python/intern/bpy_interface.c
M	source/blender/python/intern/bpy_library_load.c
M	source/blender/python/intern/bpy_operator.c
M	source/blender/python/intern/bpy_operator_wrap.c
M	source/blender/python/intern/bpy_props.c
M	source/blender/python/intern/bpy_rna.c
M	source/blender/python/intern/bpy_rna_anim.c
M	source/blender/python/intern/bpy_rna_array.c
M	source/blender/python/intern/bpy_rna_callback.c
M	source/blender/python/intern/bpy_traceback.c
M	source/blender/python/mathutils/mathutils.c
M	source/blender/python/mathutils/mathutils_Color.c
M	source/blender/python/mathutils/mathutils_Euler.c
M	source/blender/python/mathutils/mathutils_Matrix.c
M	source/blender/python/mathutils/mathutils_Quaternion.c
M	source/blender/python/mathutils/mathutils_Vector.c
M	source/blender/python/mathutils/mathutils_bvhtree.c
M	source/blender/python/mathutils/mathutils_geometry.c
M	source/blender/python/mathutils/mathutils_interpolate.c
M	source/blender/python/mathutils/mathutils_kdtree.c
M	source/blender/python/mathutils/mathutils_noise.c

===================================================================

diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index fbd79f28ec7..f35bfb730ad 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -351,11 +351,13 @@ PyObject *BPyInit_bmesh_ops(void)
 {
 	PyObject *submodule;
 
-	if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0)
+	if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0) {
 		return NULL;
+	}
 
-	if (PyType_Ready(&bmesh_op_Type) < 0)
+	if (PyType_Ready(&bmesh_op_Type) < 0) {
 		return NULL;
+	}
 
 	submodule = PyObject_New(PyObject, &bmesh_ops_fakemod_Type);
 
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 1addd9b84f7..366f0b4b3f7 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1445,8 +1445,9 @@ static PyObject *bpy_bmvert_calc_edge_angle(BPy_BMVert *self, PyObject *args)
 
 	BPY_BM_CHECK_OBJ(self);
 
-	if (!PyArg_ParseTuple(args, "|O:calc_edge_angle", &fallback))
+	if (!PyArg_ParseTuple(args, "|O:calc_edge_angle", &fallback)) {
 		return NULL;
+	}
 
 	angle = BM_vert_calc_edge_angle_ex(self->v, angle_invalid);
 
@@ -1530,8 +1531,9 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self, PyObject *args)
 
 	BPY_BM_CHECK_OBJ(self);
 
-	if (!PyArg_ParseTuple(args, "|O:calc_face_angle", &fallback))
+	if (!PyArg_ParseTuple(args, "|O:calc_face_angle", &fallback)) {
 		return NULL;
+	}
 
 	angle = BM_edge_calc_face_angle_ex(self->e, angle_invalid);
 
@@ -1569,8 +1571,9 @@ static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self, PyObject *a
 
 	BPY_BM_CHECK_OBJ(self);
 
-	if (!PyArg_ParseTuple(args, "|O:calc_face_angle_signed", &fallback))
+	if (!PyArg_ParseTuple(args, "|O:calc_face_angle_signed", &fallback)) {
 		return NULL;
+	}
 
 	angle = BM_edge_calc_face_angle_signed_ex(self->e, angle_invalid);
 
@@ -2161,7 +2164,9 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
 		ret = BPy_BMEdge_CreatePyObject(bm, e);
 
 cleanup:
-		if (vert_array) PyMem_FREE(vert_array);
+		if (vert_array) {
+			PyMem_FREE(vert_array);
+		}
 		return ret;
 	}
 }
@@ -2239,7 +2244,9 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
 
 		/* pass through */
 cleanup:
-		if (vert_array) PyMem_FREE(vert_array);
+		if (vert_array) {
+			PyMem_FREE(vert_array);
+		}
 		return ret;
 	}
 }
@@ -2535,9 +2542,15 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v, const
 	const int *index1 = (int *)index1_v;
 	const int *index2 = (int *)index2_v;
 
-	if      (keys[*index1] < keys[*index2]) return -1;
-	else if (keys[*index1] > keys[*index2]) return 1;
-	else                                    return 0;
+	if (keys[*index1] < keys[*index2]) {
+		return -1;
+	}
+	else if (keys[*index1] > keys[*index2]) {
+		return 1;
+	}
+	else {
+		return 0;
+	}
 }
 
 static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v, const void *index2_v, void *keys_v)
@@ -2646,10 +2659,12 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec
 	range_vn_i(elem_idx, n_elem, 0);
 
 	/* Sort the index array according to the order of the 'keys' array */
-	if (do_reverse)
+	if (do_reverse) {
 		elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_descending;
-	else
+	}
+	else {
 		elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_ascending;
+	}
 
 	BLI_qsort_r(elem_idx, n_elem, sizeof(*elem_idx), elem_idx_compare_by_keys, keys);
 
@@ -2920,7 +2935,10 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, int keynum)
 {
 	BPY_BM_CHECK_OBJ(self);
 
-	if (keynum < 0) keynum += bpy_bmelemseq_length(self); /* only get length on negative value, may loop entire seq */
+	if (keynum < 0) {
+		/* only get length on negative value, may loop entire seq */
+		keynum += bpy_bmelemseq_length(self);
+	}
 	if (keynum >= 0) {
 		if (self->itype <= BM_FACES_OF_MESH) {
 			if ((self->bm->elem_table_dirty & bm_iter_itype_htype_map[self->itype]) == 0) {
@@ -3014,8 +3032,9 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
 	/* don't need error check here */
 	if (PyIndex_Check(key)) {
 		Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
-		if (i == -1 && PyErr_Occurred())
+		if (i == -1 && PyErr_Occurred()) {
 			return NULL;
+		}
 		return bpy_bmelemseq_subscript_int(self, i);
 	}
 	else if (PySlice_Check(key)) {
@@ -3037,14 +3056,22 @@ static PyObject *bpy_bmelemseq_subscript(BPy_BMElemSeq *self, PyObject *key)
 			Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
 
 			/* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
-			if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
-			if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop))    return NULL;
+			if (key_slice->start != Py_None && !_PyEval_SliceIndex(key_slice->start, &start)) {
+				return NULL;
+			}
+			if (key_slice->stop != Py_None && !_PyEval_SliceIndex(key_slice->stop, &stop)) {
+				return NULL;
+			}
 
 			if (start < 0 || stop < 0) {
 				/* only get the length for negative values */
 				Py_ssize_t len = bpy_bmelemseq_length(self);
-				if (start < 0) start += len;
-				if (stop  < 0) stop  += len;
+				if (start < 0) {
+					start += len;
+				}
+				if (stop  < 0) {
+					stop  += len;
+				}
 			}
 
 			if (stop - start <= 0) {
@@ -3162,10 +3189,18 @@ static void bpy_bmesh_dealloc(BPy_BMesh *self)
 	if (bm) {
 		bm_dealloc_editmode_warn(self);
 
-		if (CustomData_has_layer(&bm->vdata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
-		if (CustomData_has_layer(&bm->edata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->edata, CD_BM_ELEM_PYPTR);
-		if (CustomData_has_layer(&bm->pdata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
-		if (CustomData_has_layer(&bm->ldata, CD_BM_ELEM_PYPTR)) BM_data_layer_free(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
+		if (CustomData_has_layer(&bm->vdata, CD_BM_ELEM_PYPTR)) {
+			BM_data_layer_free(bm, &bm->vdata, CD_BM_ELEM_PYPTR);
+		}
+		if (CustomData_has_layer(&bm->edata, CD_BM_ELEM_PYPTR)) {
+			BM_data_layer_free(bm, &bm->edata, CD_BM_ELEM_PYPTR);
+		}
+		if (CustomData_has_layer(&bm->pdata, CD_BM_ELEM_PYPTR)) {
+			BM_data_layer_free(bm, &bm->pdata, CD_BM_ELEM_PYPTR);
+		}
+		if (CustomData_has_layer(&bm->ldata, CD_BM_ELEM_PYPTR)) {
+			BM_data_layer_free(bm, &bm->ldata, CD_BM_ELEM_PYPTR);
+		}
 
 		bm->py_handle = NULL;
 
@@ -3182,8 +3217,9 @@ static void bpy_bmvert_dealloc(BPy_BMElem *self)
 	BMesh *bm = self->bm;
 	if (bm) {
 		void **ptr = CustomData_bmesh_get(&bm->vdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
-		if (ptr)
+		if (ptr) {
 			*ptr = NULL;
+		}
 	}
 	PyObject_DEL(self);
 }
@@ -3193,8 +3229,9 @@ static void bpy_bmedge_dealloc(BPy_BMElem *self)
 	BMesh *bm = self->bm;
 	if (bm) {
 		void **ptr = CustomData_bmesh_get(&bm->edata, self->ele->head.data, CD_BM_ELEM_PYPTR);
-		if (ptr)
+		if (ptr) {
 			*ptr = NULL;
+		}
 	}
 	PyObject_DEL(self);
 }
@@ -3204,8 +3241,9 @@ static void bpy_bmface_dealloc(BPy_BMElem *self)
 	BMesh *bm = self->bm;
 	if (bm) {
 		void **ptr = CustomData_bmesh_get(&bm->pdata, self->ele->head.data, CD_BM_ELEM_PYPTR);
-		if (ptr)
+		if (ptr) {
 			*ptr = NULL;
+		}
 	}
 	PyObject_DEL(self);
 }
@@ -3215,8 +3253,9 @@ static void bpy_bmloop_dealloc(BPy_BMElem *self)
 	BMesh *bm = self->bm;
 	if (bm) {
 		void **ptr = CustomData_bmesh_get(&bm->ldata, self->ele->head.data, CD_BM_ELEM_PYPTR);
-		if (ptr)
+		if (ptr) {
 			*ptr = NULL;
+		}
 	}
 	PyObject_DEL(self);
 }
@@ -3938,7 +3977,9 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
 	}
 
 	*r_size = seq_len;
-	if (r_bm) *r_bm = bm;
+	if (r_bm) {
+		*r_bm = bm;
+	}
 	return alloc;
 
 err_cleanup:
@@ -4042,10 +4083,10 @@ char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
 {
 	/* zero to ensure string is always NULL terminated */
 	char *ret_ptr = ret;
-	if (htype & BM_VERT) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMVert_Type.tp_name);
-	if (htype & BM_EDGE) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMEdge_Type.tp_name);
-	if (htype & BM_FACE) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMFace_Type.tp_name);
-	if (htype & BM_LOOP) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMLoop_Type.tp_name);
+	if (htype & BM_VERT) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMVert_Type.tp_name); }
+	if (htype & BM_EDGE) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMEdge_Type.tp_name); }
+	if (htype & BM_FACE) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMFace_Type.tp_name); }
+	if (htype & BM_LOOP) { ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMLoop_Type.tp_name); }
 	ret[0]   = '(';
 	*ret_ptr++ = ')';
 	*ret_ptr   = '\0';
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index c161b974eff..abe146f2581 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -615,7 +615,9 @@ static PyObject *bpy_bmlayercollection_subscript_int(BPy_BMLayerCollection *self
 
 	len = bpy_bmlayercollection_length(self);
 
-	if (keynum < 0) keynum += len;
+	if (keynum < 0) {
+		keynum += len;
+	}
 	if (keynum >= 0) {
 		if (keynum < len) {
 			return BPy_BMLayerItem_CreatePyObject(self->bm, self->htype, self->type, keynum);
@@ -636,8 +638,12 @@ static PyObject *bpy_bmlayercollection_subscript_slice(BPy_BMLayerCollection *se
 
 	BPY_BM_CHECK_OBJ(self);
 
-	if (start >= len) start = len - 1;
-	if (stop  >= len) stop  = len - 1;
+	if (start >= len) {
+		start = len - 1;
+	}
+	if (stop  >= len) {
+		stop  = len - 1;
+	}
 
 	tuple = PyTuple_New(stop - start);
 
@@ -656,8 +662,9 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
 	}
 	else if (PyIndex_Check(key)) {
 		Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
-		if (i == -1 && PyErr_Occurred())
+		if (i == -1 && PyErr_Occurred()) {
 			return NULL;
+		}
 		return bpy_bmlayercollection_subscript_int(self, i);
 	}
 	else if (PySlice_Check(key)) {
@@ -679,14 +686,22 @@ static PyObject *bpy_bmlayercollection_subscript(BPy_BMLayerCollection *self, Py
 			P

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list