Code cleanup: use booleans where appropriate

This commit is contained in:
2014-01-28 03:52:21 +11:00
parent 60287e23b5
commit a5c35fb27f
66 changed files with 248 additions and 233 deletions

View File

@@ -197,7 +197,7 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
PyObject *args;
PyObject *self;
PyObject *ret;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);
@@ -248,7 +248,7 @@ static int bpy_prop_boolean_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int value;
BLI_assert(py_data != NULL);
@@ -306,7 +306,7 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);
@@ -360,7 +360,7 @@ static void bpy_prop_boolean_array_get_cb(struct PointerRNA *ptr, struct Propert
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int i, len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -422,7 +422,7 @@ static void bpy_prop_boolean_array_set_cb(struct PointerRNA *ptr, struct Propert
PyObject *py_values;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -482,7 +482,7 @@ static int bpy_prop_int_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop)
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int value;
BLI_assert(py_data != NULL);
@@ -540,7 +540,7 @@ static void bpy_prop_int_set_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);
@@ -594,7 +594,7 @@ static void bpy_prop_int_array_get_cb(struct PointerRNA *ptr, struct PropertyRNA
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int i, len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -656,7 +656,7 @@ static void bpy_prop_int_array_set_cb(struct PointerRNA *ptr, struct PropertyRNA
PyObject *py_values;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -716,7 +716,7 @@ static float bpy_prop_float_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
float value;
BLI_assert(py_data != NULL);
@@ -774,7 +774,7 @@ static void bpy_prop_float_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pr
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);
@@ -828,7 +828,7 @@ static void bpy_prop_float_array_get_cb(struct PointerRNA *ptr, struct PropertyR
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int i, len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -890,7 +890,7 @@ static void bpy_prop_float_array_set_cb(struct PointerRNA *ptr, struct PropertyR
PyObject *py_values;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int len = RNA_property_array_length(ptr, prop);
BLI_assert(py_data != NULL);
@@ -950,7 +950,7 @@ static void bpy_prop_string_get_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);
@@ -1009,7 +1009,7 @@ static int bpy_prop_string_length_cb(struct PointerRNA *ptr, struct PropertyRNA
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int length;
BLI_assert(py_data != NULL);
@@ -1071,7 +1071,7 @@ static void bpy_prop_string_set_cb(struct PointerRNA *ptr, struct PropertyRNA *p
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
PyObject *py_value;
BLI_assert(py_data != NULL);
@@ -1132,7 +1132,7 @@ static int bpy_prop_enum_get_cb(struct PointerRNA *ptr, struct PropertyRNA *prop
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
int value;
BLI_assert(py_data != NULL);
@@ -1190,7 +1190,7 @@ static void bpy_prop_enum_set_cb(struct PointerRNA *ptr, struct PropertyRNA *pro
PyObject *ret;
PyGILState_STATE gilstate;
bool use_gil;
const int is_write_ok = pyrna_write_check();
const bool is_write_ok = pyrna_write_check();
BLI_assert(py_data != NULL);

View File

@@ -606,7 +606,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
#ifdef USE_MATHUTILS
int subtype, totdim;
int len;
int is_thick;
bool is_thick;
const int flag = RNA_property_flag(prop);
/* disallow dynamic sized arrays to be wrapped since the size could change
@@ -617,7 +617,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
len = RNA_property_array_length(ptr, prop);
subtype = RNA_property_subtype(prop);
totdim = RNA_property_array_dimension(ptr, prop, NULL);
is_thick = (flag & PROP_THICK_WRAP);
is_thick = (flag & PROP_THICK_WRAP) != 0;
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
if (!is_thick)
@@ -3640,7 +3640,7 @@ static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
#endif
/* --------------- setattr------------------------------------------- */
static int pyrna_is_deferred_prop(const PyObject *value)
static bool pyrna_is_deferred_prop(const PyObject *value)
{
return PyTuple_CheckExact(value) &&
PyTuple_GET_SIZE(value) == 2 &&
@@ -3682,7 +3682,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
{
StructRNA *srna = srna_from_self(cls, "StructRNA.__setattr__");
const int is_deferred_prop = (value && pyrna_is_deferred_prop(value));
const bool is_deferred_prop = (value && pyrna_is_deferred_prop(value));
const char *attr_str = _PyUnicode_AsString(attr);
if (srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, attr_str))) {
@@ -6901,7 +6901,7 @@ static int rna_function_arg_count(FunctionRNA *func, int *min_count)
PropertyRNA *parm;
Link *link;
int flag = RNA_function_flag(func);
int is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
int count = is_staticmethod ? 0 : 1;
bool done_min_count = false;
@@ -6934,7 +6934,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
PyObject *py_class = (PyObject *)py_data;
PyObject *base_class = RNA_struct_py_type_get(srna);
PyObject *item;
int i, flag, is_staticmethod, arg_count, func_arg_count, func_arg_min_count = 0;
int i, flag, arg_count, func_arg_count, func_arg_min_count = 0;
bool is_staticmethod;
const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */
if (srna_base) {
@@ -7119,10 +7120,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
PyGILState_STATE gilstate;
#ifdef USE_PEDANTIC_WRITE
const int is_operator = RNA_struct_is_a(ptr->type, &RNA_Operator);
const bool is_operator = RNA_struct_is_a(ptr->type, &RNA_Operator);
// const char *func_id = RNA_function_identifier(func); /* UNUSED */
/* testing, for correctness, not operator and not draw function */
const short is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
#endif
py_class = RNA_struct_py_type_get(ptr->type);

View File

@@ -58,7 +58,7 @@ static int pyrna_struct_anim_args_parse(
PointerRNA *ptr, const char *error_prefix, const char *path,
const char **path_full, int *index)
{
const int is_idbase = RNA_struct_is_ID(ptr->type);
const bool is_idbase = RNA_struct_is_ID(ptr->type);
PropertyRNA *prop;
PointerRNA r_ptr;