Cleanup: style, use braces for the Python API

This commit is contained in:
Campbell Barton
2019-03-30 06:12:48 +11:00
parent 18d06e8d21
commit 25ec4b437f
39 changed files with 1689 additions and 800 deletions

View File

@@ -276,8 +276,9 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
*
* arr[2][3][4] = x
* lvalue_dim = 2 */
for (i = lvalue_dim; i < totdim; i++)
for (i = lvalue_dim; i < totdim; i++) {
len *= dimsize[i];
}
}
if (tot != len) {
@@ -308,8 +309,9 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop,
if (MatrixObject_Check(rvalue)) {
MatrixObject *pymat = (MatrixObject *)rvalue;
if (BaseMath_ReadCallback(pymat) == -1)
if (BaseMath_ReadCallback(pymat) == -1) {
return -1;
}
if (RNA_property_type(prop) != PROP_FLOAT) {
PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, matrix assign to non float array",
@@ -512,8 +514,9 @@ static int py_to_array_index(
lvalue_dim++;
for (i = lvalue_dim; i < totdim; i++)
for (i = lvalue_dim; i < totdim; i++) {
index *= dimsize[i];
}
index += arrayoffset;
@@ -751,8 +754,9 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
for (i = 0; i < len; i++) {
PyObject *item;
if (dim + 1 < totdim)
if (dim + 1 < totdim) {
item = pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
}
else {
item = pyrna_array_index(ptr, prop, *index);
*index = *index + 1;
@@ -802,8 +806,9 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
* x = arr[2][3]
* index = offset + 3 * 5 */
for (i = arraydim + 1; i < totdim; i++)
for (i = arraydim + 1; i < totdim; i++) {
index *= dimsize[i];
}
ret->arrayoffset = arrayoffset + index;
}
@@ -822,7 +827,9 @@ PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret = pyrna_math_object_from_array(ptr, prop);
/* is this a maths object? */
if (ret) return ret;
if (ret) {
return ret;
}
return pyrna_prop_CreatePyObject(ptr, prop);
}
@@ -834,8 +841,10 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
int type;
int i;
if (len == 0) /* possible with dynamic arrays */
if (len == 0) {
/* possible with dynamic arrays */
return 0;
}
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet");
@@ -871,8 +880,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}
@@ -904,8 +914,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}
@@ -937,8 +948,9 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
if (tmp_arr != tmp)
if (tmp_arr != tmp) {
PyMem_FREE(tmp_arr);
}
return i < len ? 1 : 0;
}