diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-26 16:26:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-26 16:26:11 +0400 |
commit | e17fd46c71e0401fefecf22fa8975fc5826d8fe9 (patch) | |
tree | 7c8afe24927c1dfdb5cf14a8deeb61691e1ec0c3 /source/blender/python/intern/bpy_rna_array.c | |
parent | f48fb385ea8dc6b12e12a6ec46a0c0b55d2dfcc4 (diff) |
formatting edits only to use more consisted style
Diffstat (limited to 'source/blender/python/intern/bpy_rna_array.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna_array.c | 267 |
1 files changed, 136 insertions, 131 deletions
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index 2a4c004d84c..a74d0417ca2 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -55,14 +55,14 @@ typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *) */ /* - arr[2]= x + arr[2] = x py_to_array_index(arraydim=0, arrayoffset=0, index=2) validate_array(lvalue_dim=0) ... make real index ... */ -/* arr[3]=x, self->arraydim is 0, lvalue_dim is 1 */ +/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */ /* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[], ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix) @@ -72,59 +72,62 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[] /* not the last dimension */ if (dim + 1 < totdim) { /* check that a sequence contains dimsize[dim] items */ - const Py_ssize_t seq_size= PySequence_Size(seq); + const Py_ssize_t seq_size = PySequence_Size(seq); if (seq_size == -1) { PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'", error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name); return -1; } - for (i= 0; i < seq_size; i++) { + for (i = 0; i < seq_size; i++) { PyObject *item; - int ok= 1; - item= PySequence_GetItem(seq, i); + int ok = 1; + item = PySequence_GetItem(seq, i); if (item == NULL) { PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d", error_prefix, Py_TYPE(seq)->tp_name, i); - ok= 0; + ok = 0; } else if (!PySequence_Check(item)) { /* BLI_snprintf(error_str, error_str_size, "expected a sequence of %s", item_type_str); */ PyErr_Format(PyExc_TypeError, "%s expected a sequence of %s, not %s", error_prefix, item_type_str, Py_TYPE(item)->tp_name); - ok= 0; + ok = 0; } /* arr[3][4][5] - dimsize[1]=4 - dimsize[2]=5 - - dim=0 */ + * dimsize[1] = 4 + * dimsize[2] = 5 + * + * dim = 0 */ else if (PySequence_Size(item) != dimsize[dim + 1]) { - /* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)dimsize[dim + 1]); */ + /* BLI_snprintf(error_str, error_str_size, + "sequences of dimension %d should contain %d items", + (int)dim + 1, (int)dimsize[dim + 1]); */ PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)dimsize[dim + 1]); - ok= 0; + ok = 0; } else if (validate_array_type(item, dim + 1, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) { - ok= 0; + ok = 0; } Py_XDECREF(item); - if (!ok) + if (!ok) { return -1; + } } } else { /* check that items are of correct type */ - const int seq_size= PySequence_Size(seq); + const int seq_size = PySequence_Size(seq); if (seq_size == -1) { PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'", error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name); return -1; } - for (i= 0; i < seq_size; i++) { - PyObject *item= PySequence_GetItem(seq, i); + for (i = 0; i < seq_size; i++) { + PyObject *item = PySequence_GetItem(seq, i); if (item == NULL) { PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d", @@ -150,32 +153,32 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[] /* Returns the number of items in a single- or multi-dimensional sequence. */ static int count_items(PyObject *seq, int dim) { - int totitem= 0; + int totitem = 0; if (dim > 1) { - const Py_ssize_t seq_size= PySequence_Size(seq); + const Py_ssize_t seq_size = PySequence_Size(seq); Py_ssize_t i; - for (i= 0; i < seq_size; i++) { - PyObject *item= PySequence_GetItem(seq, i); + for (i = 0; i < seq_size; i++) { + PyObject *item = PySequence_GetItem(seq, i); if (item) { - const int tot= count_items(item, dim - 1); + const int tot = count_items(item, dim - 1); Py_DECREF(item); if (tot != -1) { totitem += tot; } else { - totitem= -1; + totitem = -1; break; } } else { - totitem= -1; + totitem = -1; break; } } } else { - totitem= PySequence_Size(seq); + totitem = PySequence_Size(seq); } return totitem; @@ -188,8 +191,8 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA int dimsize[MAX_ARRAY_DIMENSION]; int tot, totdim, len; - totdim= RNA_property_array_dimension(ptr, prop, dimsize); - tot= count_items(rvalue, totdim - lvalue_dim); + totdim = RNA_property_array_dimension(ptr, prop, dimsize); + tot = count_items(rvalue, totdim - lvalue_dim); if (tot == -1) { PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, error validating the sequence length", @@ -201,45 +204,47 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA #if 0 /* length is flexible */ if (!RNA_property_dynamic_array_set_length(ptr, prop, tot)) { - /* BLI_snprintf(error_str, error_str_size, "%s.%s: array length cannot be changed to %d", RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */ + /* BLI_snprintf(error_str, error_str_size, + "%s.%s: array length cannot be changed to %d", + RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */ PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); return -1; } #else - *totitem= tot; + *totitem = tot; return 0; #endif } - len= tot; + len = tot; } else { /* length is a constraint */ if (!lvalue_dim) { - len= RNA_property_array_length(ptr, prop); + len = RNA_property_array_length(ptr, prop); } /* array item assignment */ else { int i; - len= 1; + len = 1; /* arr[3][4][5] - arr[2]= x - dimsize={4, 5} - dimsize[1]= 4 - dimsize[2]= 5 - lvalue_dim=0, totdim=3 + arr[2] = x + dimsize = {4, 5} + dimsize[1] = 4 + dimsize[2] = 5 + lvalue_dim = 0, totdim = 3 - arr[2][3]= x - lvalue_dim=1 + arr[2][3] = x + lvalue_dim = 1 - arr[2][3][4]= x - lvalue_dim=2 */ - for (i= lvalue_dim; i < totdim; i++) + arr[2][3][4] = x + lvalue_dim = 2 */ + for (i = lvalue_dim; i < totdim; i++) len *= dimsize[i]; } @@ -251,7 +256,7 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA } } - *totitem= len; + *totitem = len; return 0; } @@ -261,7 +266,7 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, const char *error_prefix) { int dimsize[MAX_ARRAY_DIMENSION]; - int totdim= RNA_property_array_dimension(ptr, prop, dimsize); + int totdim = RNA_property_array_dimension(ptr, prop, dimsize); /* validate type first because length validation may modify property array length */ @@ -269,7 +274,7 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, #ifdef USE_MATHUTILS if (lvalue_dim == 0) { /* only valid for first level array */ if (MatrixObject_Check(rvalue)) { - MatrixObject *pymat= (MatrixObject *)rvalue; + MatrixObject *pymat = (MatrixObject *)rvalue; if (BaseMath_ReadCallback(pymat) == -1) return -1; @@ -292,7 +297,7 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, return -1; } else { - *totitem= dimsize[0] * dimsize[1]; + *totitem = dimsize[0] * dimsize[1]; return 0; } } @@ -317,7 +322,7 @@ static char *copy_value_single(PyObject *item, PointerRNA *ptr, PropertyRNA *pro convert_item(item, value); rna_set_index(ptr, prop, *index, value); - *index= *index + 1; + *index = *index + 1; } else { convert_item(item, data); @@ -331,8 +336,8 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int dim, char *data, unsigned int item_size, int *index, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index) { - int totdim= RNA_property_array_dimension(ptr, prop, NULL); - const Py_ssize_t seq_size= PySequence_Size(seq); + int totdim = RNA_property_array_dimension(ptr, prop, NULL); + const Py_ssize_t seq_size = PySequence_Size(seq); Py_ssize_t i; /* Regarding PySequence_GetItem() failing. @@ -352,8 +357,8 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, #ifdef USE_MATHUTILS if (dim == 0) { if (MatrixObject_Check(seq)) { - MatrixObject *pymat= (MatrixObject *)seq; - size_t allocsize= pymat->num_col * pymat->num_row * sizeof(float); + MatrixObject *pymat = (MatrixObject *)seq; + size_t allocsize = pymat->num_col * pymat->num_row * sizeof(float); /* read callback already done by validate */ /* since this is the first iteration we can assume data is allocated */ @@ -368,14 +373,14 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, #endif /* USE_MATHUTILS */ - for (i= 0; i < seq_size; i++) { - PyObject *item= PySequence_GetItem(seq, i); + for (i = 0; i < seq_size; i++) { + PyObject *item = PySequence_GetItem(seq, i); if (item) { if (dim + 1 < totdim) { - data= copy_values(item, ptr, prop, dim + 1, data, item_size, index, convert_item, rna_set_index); + data = copy_values(item, ptr, prop, dim + 1, data, item_size, index, convert_item, rna_set_index); } else { - data= copy_value_single(item, ptr, prop, data, item_size, index, convert_item, rna_set_index); + data = copy_value_single(item, ptr, prop, data, item_size, index, convert_item, rna_set_index); } Py_DECREF(item); @@ -396,9 +401,9 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, { /*int totdim, dim_size[MAX_ARRAY_DIMENSION];*/ int totitem; - char *data= NULL; + char *data = NULL; - /*totdim= RNA_property_array_dimension(ptr, prop, dim_size);*/ /*UNUSED*/ + /*totdim = RNA_property_array_dimension(ptr, prop, dim_size);*/ /*UNUSED*/ if (validate_array(seq, ptr, prop, 0, check_item_type, item_type_str, &totitem, error_prefix) == -1) { return -1; @@ -408,30 +413,30 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, /* note: this code is confusing */ if (param_data && RNA_property_flag(prop) & PROP_DYNAMIC) { /* not freeing allocated mem, RNA_parameter_list_free() will do this */ - ParameterDynAlloc *param_alloc= (ParameterDynAlloc *)param_data; - param_alloc->array_tot= (int)totitem; - param_alloc->array= MEM_callocN(item_size * totitem, "py_to_array dyn"); /* freeing param list will free */ + ParameterDynAlloc *param_alloc = (ParameterDynAlloc *)param_data; + param_alloc->array_tot = (int)totitem; + param_alloc->array = MEM_callocN(item_size * totitem, "py_to_array dyn"); /* freeing param list will free */ - data= param_alloc->array; + data = param_alloc->array; } else if (param_data) { - data= param_data; + data = param_data; } else { - data= PyMem_MALLOC(item_size * totitem); + data = PyMem_MALLOC(item_size * totitem); } /* will only fail in very rare cases since we already validated the * python data, the check here is mainly for completeness. */ if (copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) { - if (param_data==NULL) { + if (param_data == NULL) { /* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */ rna_set_array(ptr, prop, data); PyMem_FREE(data); } } else { - if (param_data==NULL) { + if (param_data == NULL) { PyMem_FREE(data); } @@ -452,21 +457,21 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, int totdim, dimsize[MAX_ARRAY_DIMENSION]; int totitem, i; - totdim= RNA_property_array_dimension(ptr, prop, dimsize); + totdim = RNA_property_array_dimension(ptr, prop, dimsize); /* convert index */ /* arr[3][4][5] - arr[2]= x - lvalue_dim=0, index= 0 + 2 * 4 * 5 + arr[2] = x + lvalue_dim = 0, index = 0 + 2 * 4 * 5 - arr[2][3]= x - lvalue_dim=1, index= 40 + 3 * 5 */ + arr[2][3] = x + lvalue_dim = 1, index = 40 + 3 * 5 */ lvalue_dim++; - for (i= lvalue_dim; i < totdim; i++) + for (i = lvalue_dim; i < totdim; i++) index *= dimsize[i]; index += arrayoffset; @@ -495,17 +500,17 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, static void py_to_float(PyObject *py, char *data) { - *(float*)data= (float)PyFloat_AsDouble(py); + *(float *)data = (float)PyFloat_AsDouble(py); } static void py_to_int(PyObject *py, char *data) { - *(int*)data= (int)PyLong_AsSsize_t(py); + *(int *)data = (int)PyLong_AsSsize_t(py); } static void py_to_bool(PyObject *py, char *data) { - *(int*)data= (int)PyObject_IsTrue(py); + *(int *)data = (int)PyObject_IsTrue(py); } static int py_float_check(PyObject *py) @@ -527,17 +532,17 @@ static int py_bool_check(PyObject *py) static void float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value) { - RNA_property_float_set_index(ptr, prop, index, *(float*)value); + RNA_property_float_set_index(ptr, prop, index, *(float *)value); } static void int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value) { - RNA_property_int_set_index(ptr, prop, index, *(int*)value); + RNA_property_int_set_index(ptr, prop, index, *(int *)value); } static void bool_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value) { - RNA_property_boolean_set_index(ptr, prop, index, *(int*)value); + RNA_property_boolean_set_index(ptr, prop, index, *(int *)value); } int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, @@ -546,20 +551,20 @@ int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, int ret; switch (RNA_property_type(prop)) { case PROP_FLOAT: - ret= py_to_array(py, ptr, prop, param_data, py_float_check, "float", sizeof(float), + ret = py_to_array(py, ptr, prop, param_data, py_float_check, "float", sizeof(float), py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix); break; case PROP_INT: - ret= py_to_array(py, ptr, prop, param_data, py_int_check, "int", sizeof(int), + ret = py_to_array(py, ptr, prop, param_data, py_int_check, "int", sizeof(int), py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix); break; case PROP_BOOLEAN: - ret= py_to_array(py, ptr, prop, param_data, py_bool_check, "boolean", sizeof(int), + ret = py_to_array(py, ptr, prop, param_data, py_bool_check, "boolean", sizeof(int), py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix); break; default: PyErr_SetString(PyExc_TypeError, "not an array type"); - ret= -1; + ret = -1; } return ret; @@ -571,20 +576,20 @@ int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, in int ret; switch (RNA_property_type(prop)) { case PROP_FLOAT: - ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, + ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_float_check, "float", py_to_float, float_set_index, error_prefix); break; case PROP_INT: - ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, + ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_int_check, "int", py_to_int, int_set_index, error_prefix); break; case PROP_BOOLEAN: - ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, + ret = py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_bool_check, "boolean", py_to_bool, bool_set_index, error_prefix); break; default: PyErr_SetString(PyExc_TypeError, "not an array type"); - ret= -1; + ret = -1; } return ret; @@ -596,17 +601,17 @@ PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index) switch (RNA_property_type(prop)) { case PROP_FLOAT: - item= PyFloat_FromDouble(RNA_property_float_get_index(ptr, prop, index)); + item = PyFloat_FromDouble(RNA_property_float_get_index(ptr, prop, index)); break; case PROP_BOOLEAN: - item= PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index)); + item = PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index)); break; case PROP_INT: - item= PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index)); + item = PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index)); break; default: PyErr_SetString(PyExc_TypeError, "not an array type"); - item= NULL; + item = NULL; } return item; @@ -619,20 +624,20 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop { PyObject *tuple; int i, len; - int totdim= RNA_property_array_dimension(ptr, prop, NULL); + int totdim = RNA_property_array_dimension(ptr, prop, NULL); - len= RNA_property_multi_array_length(ptr, prop, dim); + len = RNA_property_multi_array_length(ptr, prop, dim); - tuple= PyTuple_New(len); + tuple = PyTuple_New(len); - for (i= 0; i < len; i++) { + for (i = 0; i < len; i++) { PyObject *item; if (dim + 1 < totdim) - item= pyrna_py_from_array_internal(ptr, prop, dim + 1, index); + item = pyrna_py_from_array_internal(ptr, prop, dim + 1, index); else { - item= pyrna_array_index(ptr, prop, *index); - *index= *index + 1; + item = pyrna_array_index(ptr, prop, *index); + *index = *index + 1; } if (!item) { @@ -650,13 +655,13 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index) { int totdim, arraydim, arrayoffset, dimsize[MAX_ARRAY_DIMENSION], i, len; - BPy_PropertyArrayRNA *ret= NULL; + BPy_PropertyArrayRNA *ret = NULL; - arraydim= self ? self->arraydim : 0; - arrayoffset= self ? self->arrayoffset : 0; + arraydim = self ? self->arraydim : 0; + arrayoffset = self ? self->arrayoffset : 0; /* just in case check */ - len= RNA_property_multi_array_length(ptr, prop, arraydim); + len = RNA_property_multi_array_length(ptr, prop, arraydim); if (index >= len || index < 0) { /* this shouldn't happen because higher level funcs must check for invalid index */ if (G.f & G_DEBUG) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len); @@ -665,38 +670,38 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, return NULL; } - totdim= RNA_property_array_dimension(ptr, prop, dimsize); + totdim = RNA_property_array_dimension(ptr, prop, dimsize); if (arraydim + 1 < totdim) { - ret= (BPy_PropertyArrayRNA*)pyrna_prop_CreatePyObject(ptr, prop); - ret->arraydim= arraydim + 1; + ret = (BPy_PropertyArrayRNA *)pyrna_prop_CreatePyObject(ptr, prop); + ret->arraydim = arraydim + 1; /* arr[3][4][5] - x= arr[2] - index= 0 + 2 * 4 * 5 + x = arr[2] + index = 0 + 2 * 4 * 5 - x= arr[2][3] - index= offset + 3 * 5 */ + 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; + ret->arrayoffset = arrayoffset + index; } else { - index= arrayoffset + index; - ret= (BPy_PropertyArrayRNA *)pyrna_array_index(ptr, prop, index); + index = arrayoffset + index; + ret = (BPy_PropertyArrayRNA *)pyrna_array_index(ptr, prop, index); } - return (PyObject*)ret; + return (PyObject *)ret; } PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop) { PyObject *ret; - ret= pyrna_math_object_from_array(ptr, prop); + ret = pyrna_math_object_from_array(ptr, prop); /* is this a maths object? */ if (ret) return ret; @@ -707,11 +712,11 @@ PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop) /* TODO, multi-dimensional arrays */ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) { - int len= RNA_property_array_length(ptr, prop); + int len = RNA_property_array_length(ptr, prop); 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) { @@ -719,13 +724,13 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) return -1; } - type= RNA_property_type(prop); + type = RNA_property_type(prop); switch (type) { case PROP_FLOAT: { - float value_f= PyFloat_AsDouble(value); - if (value_f==-1 && PyErr_Occurred()) { + float value_f = PyFloat_AsDouble(value); + if (value_f == -1 && PyErr_Occurred()) { PyErr_Clear(); return 0; } @@ -734,15 +739,15 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) float *tmp_arr; if (len * sizeof(float) > sizeof(tmp)) { - tmp_arr= PyMem_MALLOC(len * sizeof(float)); + tmp_arr = PyMem_MALLOC(len * sizeof(float)); } else { - tmp_arr= tmp; + tmp_arr = tmp; } RNA_property_float_get_array(ptr, prop, tmp_arr); - for (i=0; i<len; i++) { + for (i = 0; i < len; i++) { if (tmp_arr[i] == value_f) { break; } @@ -751,15 +756,15 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) if (tmp_arr != tmp) PyMem_FREE(tmp_arr); - return i<len ? 1 : 0; + return i < len ? 1 : 0; } break; } case PROP_BOOLEAN: case PROP_INT: { - int value_i= PyLong_AsSsize_t(value); - if (value_i==-1 && PyErr_Occurred()) { + int value_i = PyLong_AsSsize_t(value); + if (value_i == -1 && PyErr_Occurred()) { PyErr_Clear(); return 0; } @@ -768,18 +773,18 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) int *tmp_arr; if (len * sizeof(int) > sizeof(tmp)) { - tmp_arr= PyMem_MALLOC(len * sizeof(int)); + tmp_arr = PyMem_MALLOC(len * sizeof(int)); } else { - tmp_arr= tmp; + tmp_arr = tmp; } - if (type==PROP_BOOLEAN) + if (type == PROP_BOOLEAN) RNA_property_boolean_get_array(ptr, prop, tmp_arr); else RNA_property_int_get_array(ptr, prop, tmp_arr); - for (i=0; i<len; i++) { + for (i = 0; i < len; i++) { if (tmp_arr[i] == value_i) { break; } @@ -788,7 +793,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) if (tmp_arr != tmp) PyMem_FREE(tmp_arr); - return i<len ? 1 : 0; + return i < len ? 1 : 0; } break; } |