From 10e2b771214af6d0e5589f267c6b1f10bfaea5f9 Mon Sep 17 00:00:00 2001 From: Ankit Meel Date: Tue, 20 Oct 2020 22:23:59 +0530 Subject: Cleanup: makesrna, Clang-tidy else-after-return-fixes. It got left out of {rBc04088fed1b8faea6b2928bb5e09ab3}. No functional change. --- source/blender/makesrna/intern/makesrna.c | 24 +- source/blender/makesrna/intern/rna_access.c | 486 ++++++++------------- .../makesrna/intern/rna_access_compare_override.c | 10 +- source/blender/makesrna/intern/rna_define.c | 12 +- 4 files changed, 210 insertions(+), 322 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index fa589597111..bd762bd5357 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -239,10 +239,8 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[]) if (cmp) { REN_IF_DIFF; } - else { - remove(tmpfile); - return 0; - } + remove(tmpfile); + return 0; #undef REN_IF_DIFF } @@ -254,7 +252,7 @@ static const char *rna_safe_id(const char *id) if (STREQ(id, "default")) { return "default_value"; } - else if (STREQ(id, "operator")) { + if (STREQ(id, "operator")) { return "operator_value"; } else if (STREQ(id, "new")) { @@ -286,14 +284,14 @@ static int cmp_property(const void *a, const void *b) if (STREQ(propa->identifier, "rna_type")) { return -1; } - else if (STREQ(propb->identifier, "rna_type")) { + if (STREQ(propb->identifier, "rna_type")) { return 1; } if (STREQ(propa->identifier, "name")) { return -1; } - else if (STREQ(propb->identifier, "name")) { + if (STREQ(propb->identifier, "name")) { return 1; } @@ -551,9 +549,7 @@ static const char *rna_parameter_type_name(PropertyRNA *parm) if (parm->flag_parameter & PARM_RNAPTR) { return "PointerRNA"; } - else { - return rna_find_dna_type((const char *)pparm->type); - } + return rna_find_dna_type((const char *)pparm->type); } case PROP_COLLECTION: { return "CollectionListBase"; @@ -2270,9 +2266,7 @@ static const char *rna_parameter_type_cpp_name(PropertyRNA *prop) return (const char *)pprop->type; } - else { - return rna_parameter_type_name(prop); - } + return rna_parameter_type_name(prop); } static void rna_def_struct_function_prototype_cpp(FILE *f, @@ -3206,9 +3200,7 @@ static const char *rna_property_subtypename(PropertySubType type) if (RNA_SUBTYPE_UNIT(type)) { return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type)); } - else { - return "PROP_SUBTYPE_UNKNOWN"; - } + return "PROP_SUBTYPE_UNKNOWN"; } } } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 15a4a4e740e..a631fe4fc26 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -132,9 +132,7 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr) if (type == idtype) { break; } - else { - idtype = type; - } + idtype = type; } } @@ -166,9 +164,7 @@ void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr) if (rtype == r_ptr->type) { break; } - else { - r_ptr->type = rtype; - } + r_ptr->type = rtype; } } } @@ -209,15 +205,11 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da if (type == result.type) { break; } - else { - result.type = type; - } + result.type = type; } return result; } - else { - return PointerRNA_NULL; - } + return PointerRNA_NULL; } void RNA_pointer_recast(PointerRNA *ptr, PointerRNA *r_ptr) @@ -399,14 +391,12 @@ IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name) if (group->type == IDP_GROUP) { return IDP_GetPropertyFromGroup(group, name); } - else { - /* Not sure why that happens sometimes, with nested properties... */ - /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */ + /* Not sure why that happens sometimes, with nested properties... */ + /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */ #if 0 printf( "Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type); #endif - } } return NULL; @@ -430,15 +420,13 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop) int arraylen[RNA_MAX_ARRAY_DIMENSION]; return (prop->getlength && ptr->data) ? prop->getlength(ptr, arraylen) : prop->totarraylength; } - else { - IDProperty *idprop = (IDProperty *)prop; + IDProperty *idprop = (IDProperty *)prop; - if (idprop->type == IDP_ARRAY) { - return idprop->len; - } - else { - return 0; - } + if (idprop->type == IDP_ARRAY) { + return idprop->len; + } + else { + return 0; } } @@ -447,11 +435,9 @@ static bool rna_ensure_property_array_check(PropertyRNA *prop) if (prop->magic == RNA_MAGIC) { return (prop->getlength || prop->totarraylength); } - else { - IDProperty *idprop = (IDProperty *)prop; + IDProperty *idprop = (IDProperty *)prop; - return (idprop->type == IDP_ARRAY); - } + return (idprop->type == IDP_ARRAY); } static void rna_ensure_property_multi_array_length(PointerRNA *ptr, @@ -675,9 +661,7 @@ PropertyRNA *rna_ensure_property(PropertyRNA *prop) if (idprop->type == IDP_ARRAY) { return arraytypemap[(int)(idprop->subtype)]; } - else { - return typemap[(int)(idprop->type)]; - } + return typemap[(int)(idprop->type)]; } } @@ -686,9 +670,7 @@ static const char *rna_ensure_property_identifier(const PropertyRNA *prop) if (prop->magic == RNA_MAGIC) { return prop->identifier; } - else { - return ((const IDProperty *)prop)->name; - } + return ((const IDProperty *)prop)->name; } static const char *rna_ensure_property_description(const PropertyRNA *prop) @@ -758,9 +740,7 @@ int RNA_struct_ui_icon(const StructRNA *type) if (type) { return type->icon; } - else { - return ICON_DOT; - } + return ICON_DOT; } const char *RNA_struct_ui_description(const StructRNA *type) @@ -1107,9 +1087,7 @@ bool RNA_struct_available_or_report(ReportList *reports, const char *identifier) MEM_freeN(result); return false; } - else { - return true; - } + return true; } bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, @@ -1279,15 +1257,15 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index) if ((index < 4) && ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) { return quatitem[index]; } - else if ((index < 4) && ELEM(subtype, - PROP_TRANSLATION, - PROP_DIRECTION, - PROP_XYZ, - PROP_XYZ_LENGTH, - PROP_EULER, - PROP_VELOCITY, - PROP_ACCELERATION, - PROP_COORDS)) { + if ((index < 4) && ELEM(subtype, + PROP_TRANSLATION, + PROP_DIRECTION, + PROP_XYZ, + PROP_XYZ_LENGTH, + PROP_EULER, + PROP_VELOCITY, + PROP_ACCELERATION, + PROP_COORDS)) { return vectoritem[index]; } else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { @@ -1551,7 +1529,7 @@ int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value) *value = min; return -1; } - else if (*value > max) { + if (*value > max) { *value = max; return 1; } @@ -1570,7 +1548,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value) *value = min; return -1; } - else if (*value > max) { + if (*value > max) { *value = max; return 1; } @@ -1597,7 +1575,7 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop) if (pprop->typef) { return pprop->typef(ptr); } - else if (pprop->type) { + if (pprop->type) { return pprop->type; } } @@ -1624,9 +1602,7 @@ bool RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *v if (rna_idproperty_check(&prop, ptr)) { return ((PropPointerPollFuncPy)pprop->poll)(ptr, *value, prop); } - else { - return pprop->poll(ptr, *value); - } + return pprop->poll(ptr, *value); } return 1; @@ -1859,9 +1835,7 @@ bool RNA_enum_identifier(const EnumPropertyItem *item, const int value, const ch *r_identifier = item[i].identifier; return true; } - else { - return false; - } + return false; } int RNA_enum_bitflag_identifiers(const EnumPropertyItem *item, @@ -1885,9 +1859,7 @@ bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r *r_name = item[i].name; return true; } - else { - return false; - } + return false; } bool RNA_enum_description(const EnumPropertyItem *item, @@ -1899,9 +1871,7 @@ bool RNA_enum_description(const EnumPropertyItem *item, *r_description = item[i].description; return true; } - else { - return false; - } + return false; } int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier) @@ -2620,16 +2590,14 @@ bool RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop, RNA_property_boolean_get_default_array(ptr, prop, tmp); return tmp[index]; } - else { - bool *tmparray, value; + bool *tmparray, value; - tmparray = MEM_mallocN(sizeof(bool) * len, __func__); - RNA_property_boolean_get_default_array(ptr, prop, tmparray); - value = tmparray[index]; - MEM_freeN(tmparray); + tmparray = MEM_mallocN(sizeof(bool) * len, __func__); + RNA_property_boolean_get_default_array(ptr, prop, tmparray); + value = tmparray[index]; + MEM_freeN(tmparray); - return value; - } + return value; } int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop) @@ -2643,7 +2611,7 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop) if ((idprop = rna_idproperty_check(&prop, ptr))) { return IDP_Int(idprop); } - else if (iprop->get) { + if (iprop->get) { return iprop->get(ptr); } else if (iprop->get_ex) { @@ -2800,16 +2768,14 @@ int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) RNA_property_int_get_array(ptr, prop, tmp); return tmp[index]; } - else { - int *tmparray, value; + int *tmparray, value; - tmparray = MEM_mallocN(sizeof(int) * len, __func__); - RNA_property_int_get_array(ptr, prop, tmparray); - value = tmparray[index]; - MEM_freeN(tmparray); + tmparray = MEM_mallocN(sizeof(int) * len, __func__); + RNA_property_int_get_array(ptr, prop, tmparray); + value = tmparray[index]; + MEM_freeN(tmparray); - return value; - } + return value; } void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values) @@ -2912,9 +2878,7 @@ bool RNA_property_int_set_default(PointerRNA *ptr, PropertyRNA *prop, int value) }; return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, &val); } - else { - return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, NULL); - } + return rna_idproperty_ui_set_default(ptr, prop, IDP_INT, NULL); } void RNA_property_int_get_default_array(PointerRNA *ptr, PropertyRNA *prop, int *values) @@ -2962,16 +2926,14 @@ int RNA_property_int_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int i RNA_property_int_get_default_array(ptr, prop, tmp); return tmp[index]; } - else { - int *tmparray, value; + int *tmparray, value; - tmparray = MEM_mallocN(sizeof(int) * len, __func__); - RNA_property_int_get_default_array(ptr, prop, tmparray); - value = tmparray[index]; - MEM_freeN(tmparray); + tmparray = MEM_mallocN(sizeof(int) * len, __func__); + RNA_property_int_get_default_array(ptr, prop, tmparray); + value = tmparray[index]; + MEM_freeN(tmparray); - return value; - } + return value; } float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop) @@ -2986,9 +2948,7 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop) if (idprop->type == IDP_FLOAT) { return IDP_Float(idprop); } - else { - return (float)IDP_Double(idprop); - } + return (float)IDP_Double(idprop); } else if (fprop->get) { return fprop->get(ptr); @@ -3159,16 +3119,14 @@ float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index RNA_property_float_get_array(ptr, prop, tmp); return tmp[index]; } - else { - float *tmparray, value; + float *tmparray, value; - tmparray = MEM_mallocN(sizeof(float) * len, __func__); - RNA_property_float_get_array(ptr, prop, tmparray); - value = tmparray[index]; - MEM_freeN(tmparray); + tmparray = MEM_mallocN(sizeof(float) * len, __func__); + RNA_property_float_get_array(ptr, prop, tmparray); + value = tmparray[index]; + MEM_freeN(tmparray); - return value; - } + return value; } void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values) @@ -3285,9 +3243,7 @@ bool RNA_property_float_set_default(PointerRNA *ptr, PropertyRNA *prop, float va }; return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, &val); } - else { - return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, NULL); - } + return rna_idproperty_ui_set_default(ptr, prop, IDP_DOUBLE, NULL); } void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, float *values) @@ -3341,16 +3297,14 @@ float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, i RNA_property_float_get_default_array(ptr, prop, tmp); return tmp[index]; } - else { - float *tmparray, value; + float *tmparray, value; - tmparray = MEM_mallocN(sizeof(float) * len, __func__); - RNA_property_float_get_default_array(ptr, prop, tmparray); - value = tmparray[index]; - MEM_freeN(tmparray); + tmparray = MEM_mallocN(sizeof(float) * len, __func__); + RNA_property_float_get_default_array(ptr, prop, tmparray); + value = tmparray[index]; + MEM_freeN(tmparray); - return value; - } + return value; } void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value) @@ -3429,13 +3383,11 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop) if (idprop->subtype == IDP_STRING_SUB_BYTE) { return idprop->len; } - else { #ifndef NDEBUG - /* these _must_ stay in sync */ - BLI_assert(strlen(IDP_String(idprop)) == idprop->len - 1); + /* these _must_ stay in sync */ + BLI_assert(strlen(IDP_String(idprop)) == idprop->len - 1); #endif - return idprop->len - 1; - } + return idprop->len - 1; } else if (sprop->length) { return sprop->length(ptr); @@ -3600,7 +3552,7 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop) if ((idprop = rna_idproperty_check(&prop, ptr))) { return IDP_Int(idprop); } - else if (eprop->get) { + if (eprop->get) { return eprop->get(ptr); } else if (eprop->get_ex) { @@ -3717,9 +3669,7 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) if (pprop->typef) { return rna_pointer_inherit_refine(ptr, pprop->typef(ptr), idprop); } - else { - return rna_pointer_inherit_refine(ptr, pprop->type, idprop); - } + return rna_pointer_inherit_refine(ptr, pprop->type, idprop); } else if (pprop->get) { return pprop->get(ptr); @@ -3971,7 +3921,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) if ((idprop = rna_idproperty_check(&prop, ptr))) { return idprop->len; } - else if (cprop->length) { + if (cprop->length) { return cprop->length(ptr); } else { @@ -4146,7 +4096,7 @@ bool RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) return true; } - else if (prop->flag & PROP_IDPROPERTY) { + if (prop->flag & PROP_IDPROPERTY) { return true; } @@ -4210,7 +4160,7 @@ bool RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, i return true; } - else if (prop->flag & PROP_IDPROPERTY) { + if (prop->flag & PROP_IDPROPERTY) { return true; } @@ -4269,9 +4219,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi if (iter.valid) { return index; } - else { - return -1; - } + return -1; } int RNA_property_collection_lookup_int(PointerRNA *ptr, @@ -4287,26 +4235,24 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr, /* we have a callback defined, use it */ return cprop->lookupint(ptr, key, r_ptr); } - else { - /* no callback defined, just iterate and find the nth item */ - CollectionPropertyIterator iter; - int i; - - RNA_property_collection_begin(ptr, prop, &iter); - for (i = 0; iter.valid; RNA_property_collection_next(&iter), i++) { - if (i == key) { - *r_ptr = iter.ptr; - break; - } - } - RNA_property_collection_end(&iter); + /* no callback defined, just iterate and find the nth item */ + CollectionPropertyIterator iter; + int i; - if (!iter.valid) { - memset(r_ptr, 0, sizeof(*r_ptr)); + RNA_property_collection_begin(ptr, prop, &iter); + for (i = 0; iter.valid; RNA_property_collection_next(&iter), i++) { + if (i == key) { + *r_ptr = iter.ptr; + break; } + } + RNA_property_collection_end(&iter); - return iter.valid; + if (!iter.valid) { + memset(r_ptr, 0, sizeof(*r_ptr)); } + + return iter.valid; } int RNA_property_collection_lookup_string_index( @@ -4320,49 +4266,47 @@ int RNA_property_collection_lookup_string_index( /* we have a callback defined, use it */ return cprop->lookupstring(ptr, key, r_ptr); } - else { - /* no callback defined, compare with name properties if they exist */ - CollectionPropertyIterator iter; - PropertyRNA *nameprop; - char name[256], *nameptr; - int found = 0; - int keylen = strlen(key); - int namelen; - int index = 0; - - RNA_property_collection_begin(ptr, prop, &iter); - for (; iter.valid; RNA_property_collection_next(&iter), index++) { - if (iter.ptr.data && iter.ptr.type->nameproperty) { - nameprop = iter.ptr.type->nameproperty; + /* no callback defined, compare with name properties if they exist */ + CollectionPropertyIterator iter; + PropertyRNA *nameprop; + char name[256], *nameptr; + int found = 0; + int keylen = strlen(key); + int namelen; + int index = 0; - nameptr = RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen); + RNA_property_collection_begin(ptr, prop, &iter); + for (; iter.valid; RNA_property_collection_next(&iter), index++) { + if (iter.ptr.data && iter.ptr.type->nameproperty) { + nameprop = iter.ptr.type->nameproperty; - if ((keylen == namelen) && STREQ(nameptr, key)) { - *r_ptr = iter.ptr; - found = 1; - } + nameptr = RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen); - if ((char *)&name != nameptr) { - MEM_freeN(nameptr); - } + if ((keylen == namelen) && STREQ(nameptr, key)) { + *r_ptr = iter.ptr; + found = 1; + } - if (found) { - break; - } + if ((char *)&name != nameptr) { + MEM_freeN(nameptr); } - } - RNA_property_collection_end(&iter); - if (!iter.valid) { - memset(r_ptr, 0, sizeof(*r_ptr)); - *r_index = -1; - } - else { - *r_index = index; + if (found) { + break; + } } + } + RNA_property_collection_end(&iter); - return iter.valid; + if (!iter.valid) { + memset(r_ptr, 0, sizeof(*r_ptr)); + *r_index = -1; + } + else { + *r_index = index; } + + return iter.valid; } int RNA_property_collection_lookup_string(PointerRNA *ptr, @@ -5240,7 +5184,7 @@ static bool rna_path_parse_array_index(const char **path, return false; } /* check for "" to see if it is a string */ - else if (rna_token_strip_quotes(token)) { + if (rna_token_strip_quotes(token)) { temp_index = RNA_property_array_item_index(prop, *(token + 1)); } else { @@ -5809,44 +5753,42 @@ static char *rna_idp_path(PointerRNA *ptr, path = rna_idp_path_create(&link); break; } - else { - if (iter->type == IDP_GROUP) { - /* ensure this is RNA */ - PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name); - if (prop && prop->type == PROP_POINTER) { - PointerRNA child_ptr = RNA_property_pointer_get(ptr, prop); - link.name = iter->name; - link.index = -1; - if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) { - break; - } + if (iter->type == IDP_GROUP) { + /* ensure this is RNA */ + PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name); + if (prop && prop->type == PROP_POINTER) { + PointerRNA child_ptr = RNA_property_pointer_get(ptr, prop); + link.name = iter->name; + link.index = -1; + if ((path = rna_idp_path(&child_ptr, iter, needle, &link))) { + break; } } - else if (iter->type == IDP_IDPARRAY) { - PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name); - if (prop && prop->type == PROP_COLLECTION) { - IDProperty *array = IDP_IDPArray(iter); - if (needle >= array && needle < (iter->len + array)) { /* found! */ - link.name = iter->name; - link.index = (int)(needle - array); - path = rna_idp_path_create(&link); - break; - } - else { - int j; - link.name = iter->name; - for (j = 0; j < iter->len; j++, array++) { - PointerRNA child_ptr; - if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) { - link.index = j; - if ((path = rna_idp_path(&child_ptr, array, needle, &link))) { - break; - } + } + else if (iter->type == IDP_IDPARRAY) { + PropertyRNA *prop = RNA_struct_find_property(ptr, iter->name); + if (prop && prop->type == PROP_COLLECTION) { + IDProperty *array = IDP_IDPArray(iter); + if (needle >= array && needle < (iter->len + array)) { /* found! */ + link.name = iter->name; + link.index = (int)(needle - array); + path = rna_idp_path_create(&link); + break; + } + else { + int j; + link.name = iter->name; + for (j = 0; j < iter->len; j++, array++) { + PointerRNA child_ptr; + if (RNA_property_collection_lookup_int(ptr, prop, j, &child_ptr)) { + link.index = j; + if ((path = rna_idp_path(&child_ptr, array, needle, &link))) { + break; } } - if (path) { - break; - } + } + if (path) { + break; } } } @@ -5870,9 +5812,7 @@ char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle) if (haystack) { /* can fail when called on bones */ return rna_idp_path(ptr, haystack, needle, NULL); } - else { - return NULL; - } + return NULL; } static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr) @@ -5954,9 +5894,7 @@ static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_re MEM_freeN(path); return new_path; } - else { - return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL; - } + return prefix[0] != '\0' ? BLI_strdup(prefix) : NULL; } char *RNA_path_from_ID_to_struct(PointerRNA *ptr) @@ -6351,10 +6289,8 @@ bool RNA_boolean_get(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_boolean_get(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value) @@ -6400,10 +6336,8 @@ int RNA_int_get(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_int_get(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } void RNA_int_set(PointerRNA *ptr, const char *name, int value) @@ -6449,10 +6383,8 @@ float RNA_float_get(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_float_get(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } void RNA_float_set(PointerRNA *ptr, const char *name, float value) @@ -6498,10 +6430,8 @@ int RNA_enum_get(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_enum_get(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } void RNA_enum_set(PointerRNA *ptr, const char *name, int value) @@ -6561,10 +6491,8 @@ bool RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const cha printf("%s: %s.%s item %s not found.\n", __func__, ptr->type->identifier, name, enumname); return false; } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return false; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return false; } bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value) @@ -6574,9 +6502,7 @@ bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier *r_value = item[i].value; return true; } - else { - return false; - } + return false; } bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **r_identifier) @@ -6586,9 +6512,7 @@ bool RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char *r_identifier = item[i].identifier; return true; } - else { - return false; - } + return false; } bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_icon) @@ -6598,9 +6522,7 @@ bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_ic *r_icon = item[i].icon; return true; } - else { - return false; - } + return false; } bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name) @@ -6610,9 +6532,7 @@ bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const cha *r_name = item[i].name; return true; } - else { - return false; - } + return false; } void RNA_string_get(PointerRNA *ptr, const char *name, char *value) @@ -6636,10 +6556,8 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in /* TODO, pass length */ return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return NULL; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return NULL; } int RNA_string_length(PointerRNA *ptr, const char *name) @@ -6649,10 +6567,8 @@ int RNA_string_length(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_string_length(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } void RNA_string_set(PointerRNA *ptr, const char *name, const char *value) @@ -6674,11 +6590,9 @@ PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_pointer_get(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return PointerRNA_NULL; - } + return PointerRNA_NULL; } void RNA_pointer_set(PointerRNA *ptr, const char *name, PointerRNA ptr_value) @@ -6748,10 +6662,8 @@ int RNA_collection_length(PointerRNA *ptr, const char *name) if (prop) { return RNA_property_collection_length(ptr, prop); } - else { - printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); - return 0; - } + printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); + return 0; } bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost) @@ -6761,9 +6673,7 @@ bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost) IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); return ((idprop != NULL) && (use_ghost == false || !(idprop->flag & IDP_FLAG_GHOST))); } - else { - return true; - } + return true; } bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) @@ -6773,9 +6683,7 @@ bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); return ((idprop != NULL) && !(idprop->flag & IDP_FLAG_GHOST)); } - else { - return true; - } + return true; } void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop) @@ -6793,11 +6701,9 @@ bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool if (prop) { return RNA_property_is_set_ex(ptr, prop, use_ghost); } - else { - /* python raises an error */ - /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ - return 0; - } + /* python raises an error */ + /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + return 0; } bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier) @@ -6807,11 +6713,9 @@ bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier) if (prop) { return RNA_property_is_set(ptr, prop); } - else { - /* python raises an error */ - /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ - return 0; - } + /* python raises an error */ + /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + return 0; } void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier) @@ -6835,9 +6739,7 @@ bool RNA_property_is_unlink(PropertyRNA *prop) if (RNA_property_type(prop) == PROP_STRING) { return (flag & PROP_NEVER_UNLINK) == 0; } - else { - return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0; - } + return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0; } /* string representation of a property, python @@ -6883,7 +6785,7 @@ static char *rna_pointer_as_string__bldata(Main *bmain, PointerRNA *ptr) if (ptr->type == NULL || ptr->owner_id == NULL) { return BLI_strdup("None"); } - else if (RNA_struct_is_ID(ptr->type)) { + if (RNA_struct_is_ID(ptr->type)) { return RNA_path_full_ID_py(bmain, ptr->owner_id); } else { @@ -6900,7 +6802,7 @@ char *RNA_pointer_as_string(bContext *C, if (ptr_prop->data == NULL) { return BLI_strdup("None"); } - else if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) { + if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) { return RNA_pointer_as_string_id(C, ptr_prop); } else { @@ -7970,7 +7872,7 @@ int RNA_function_call_direct_va(bContext *C, retdata = iter.data; continue; } - else if (flag_parameter & PARM_OUTPUT) { + if (flag_parameter & PARM_OUTPUT) { continue; } @@ -8307,9 +8209,7 @@ bool RNA_path_resolved_create(PointerRNA *ptr, return true; } - else { - return false; - } + return false; } static char rna_struct_state_owner[64]; diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 202864a7d82..6a90d140cce 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -80,11 +80,9 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop) return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY); } - else { - /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */ - IDProperty *idprop = (IDProperty *)prop; - return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0; - } + /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */ + IDProperty *idprop = (IDProperty *)prop; + return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0; } /* Should only be used for custom properties */ @@ -208,7 +206,7 @@ bool RNA_struct_equals(Main *bmain, PointerRNA *ptr_a, PointerRNA *ptr_b, eRNACo if (ptr_a == NULL && ptr_b == NULL) { return true; } - else if (ptr_a == NULL || ptr_b == NULL) { + if (ptr_a == NULL || ptr_b == NULL) { return false; } else if (ptr_a->type != ptr_b->type) { diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 875c5398488..8eb964b8c17 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -500,7 +500,7 @@ static int rna_find_sdna_member(SDNA *sdna, return 1; } - else if (cmp == 2) { + if (cmp == 2) { smember->type = ""; smember->name = dnaname; smember->offset = *offset; @@ -1885,7 +1885,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item DefRNA.error = true; break; } - else if (item[i].value == eprop->defaultvalue) { + if (item[i].value == eprop->defaultvalue) { defaultfound = 1; } } @@ -2182,7 +2182,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, if (DefRNA.silent) { return NULL; } - else if (!DefRNA.verify) { + if (!DefRNA.verify) { /* some basic values to survive even with sdna info */ dp->dnastructname = structname; dp->dnaname = propname; @@ -4269,7 +4269,7 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret) ret->identifier); return; } - else if (ret->arraydimension) { + if (ret->arraydimension) { CLOG_ERROR(&LOG, "\"%s.%s\", arrays are not allowed as strict returns, " "use RNA_def_function_output instead.", @@ -4357,9 +4357,7 @@ int rna_parameter_size(PropertyRNA *parm) if (parm->flag & PROP_THICK_WRAP) { return sizeof(PointerRNA); } - else { - return sizeof(PointerRNA *); - } + return sizeof(PointerRNA *); } else { return sizeof(void *); -- cgit v1.2.3