diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-29 22:12:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-29 23:14:28 +0300 |
commit | 25ec4b437fe927205a810470cdc23efd7282c85b (patch) | |
tree | 6d7ba2fe73703915b4b94d3f2dab03fb731e9544 /source/blender/python/generic/idprop_py_api.c | |
parent | 18d06e8d21ed8c9a19df4205abcd7ed17eb9af00 (diff) |
Cleanup: style, use braces for the Python API
Diffstat (limited to 'source/blender/python/generic/idprop_py_api.c')
-rw-r--r-- | source/blender/python/generic/idprop_py_api.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 6c5177d4759..f18d02a4405 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -419,11 +419,17 @@ static int idp_array_type_from_formatstr_and_size(const char *typestr, Py_ssize_ char format = PyC_StructFmt_type_from_str(typestr); if (PyC_StructFmt_type_is_float_any(format)) { - if (itemsize == 4) return IDP_FLOAT; - if (itemsize == 8) return IDP_DOUBLE; + if (itemsize == 4) { + return IDP_FLOAT; + } + if (itemsize == 8) { + return IDP_DOUBLE; + } } if (PyC_StructFmt_type_is_int_any(format)) { - if (itemsize == 4) return IDP_INT; + if (itemsize == 4) { + return IDP_INT; + } } return -1; @@ -431,9 +437,15 @@ static int idp_array_type_from_formatstr_and_size(const char *typestr, Py_ssize_ static const char *idp_format_from_array_type(int type) { - if (type == IDP_INT) return "i"; - if (type == IDP_FLOAT) return "f"; - if (type == IDP_DOUBLE) return "d"; + if (type == IDP_INT) { + return "i"; + } + if (type == IDP_FLOAT) { + return "f"; + } + if (type == IDP_DOUBLE) { + return "d"; + } return NULL; } @@ -936,8 +948,9 @@ PyObject *BPy_Wrap_GetKeys(IDProperty *prop) IDProperty *loop; int i; - for (i = 0, loop = prop->data.group.first; loop && (i < prop->len); loop = loop->next, i++) + for (i = 0, loop = prop->data.group.first; loop && (i < prop->len); loop = loop->next, i++) { PyList_SET_ITEM(list, i, PyUnicode_FromString(loop->name)); + } /* if the id prop is corrupt, count the remaining */ for ( ; loop; loop = loop->next, i++) { @@ -1067,7 +1080,9 @@ static PyObject *BPy_IDGroup_update(BPy_IDProperty *self, PyObject *value) else if (PyDict_Check(value)) { while (PyDict_Next(value, &i, &pkey, &pval)) { BPy_IDGroup_Map_SetItem(self, pkey, pval); - if (PyErr_Occurred()) return NULL; + if (PyErr_Occurred()) { + return NULL; + } } } else { @@ -1113,14 +1128,16 @@ static PyObject *BPy_IDGroup_get(BPy_IDProperty *self, PyObject *args) const char *key; PyObject *def = Py_None; - if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) + if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) { return NULL; + } idprop = IDP_GetPropertyFromGroup(self->prop, key); if (idprop) { PyObject *pyobj = BPy_IDGroup_WrapData(self->id, idprop, self->prop); - if (pyobj) + if (pyobj) { return pyobj; + } } Py_INCREF(def); @@ -1376,7 +1393,9 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end) int count; CLAMP(begin, 0, prop->len); - if (end < 0) end = prop->len + end + 1; + if (end < 0) { + end = prop->len + end + 1; + } CLAMP(end, 0, prop->len); begin = MIN2(begin, end); @@ -1446,17 +1465,20 @@ static PyObject *BPy_IDArray_subscript(BPy_IDArray *self, PyObject *item) if (PyIndex_Check(item)) { Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); - if (i == -1 && PyErr_Occurred()) + if (i == -1 && PyErr_Occurred()) { return NULL; - if (i < 0) + } + if (i < 0) { i += self->prop->len; + } return BPy_IDArray_GetItem(self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) { return NULL; + } if (slicelength <= 0) { return PyTuple_New(0); @@ -1481,20 +1503,24 @@ static int BPy_IDArray_ass_subscript(BPy_IDArray *self, PyObject *item, PyObject { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); - if (i == -1 && PyErr_Occurred()) + if (i == -1 && PyErr_Occurred()) { return -1; - if (i < 0) + } + if (i < 0) { i += self->prop->len; + } return BPy_IDArray_SetItem(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) + if (PySlice_GetIndicesEx(item, self->prop->len, &start, &stop, &step, &slicelength) < 0) { return -1; + } - if (step == 1) + if (step == 1) { return BPy_IDArray_ass_slice(self, start, stop, value); + } else { PyErr_SetString(PyExc_TypeError, "slice steps not supported with vectors"); return -1; @@ -1516,9 +1542,9 @@ static PyMappingMethods BPy_IDArray_AsMapping = { static int itemsize_by_idarray_type(int array_type) { - if (array_type == IDP_INT) return sizeof(int); - if (array_type == IDP_FLOAT) return sizeof(float); - if (array_type == IDP_DOUBLE) return sizeof(double); + if (array_type == IDP_INT) { return sizeof(int); } + if (array_type == IDP_FLOAT) { return sizeof(float); } + if (array_type == IDP_DOUBLE) { return sizeof(double); } return -1; /* should never happen */ } |