diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 106 |
1 files changed, 41 insertions, 65 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a631fe4fc26..70fafaf8111 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -425,9 +425,7 @@ static int rna_ensure_property_array_length(PointerRNA *ptr, PropertyRNA *prop) if (idprop->type == IDP_ARRAY) { return idprop->len; } - else { - return 0; - } + return 0; } static bool rna_ensure_property_array_check(PropertyRNA *prop) @@ -1268,7 +1266,7 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index) PROP_COORDS)) { return vectoritem[index]; } - else if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { + if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { return coloritem[index]; } @@ -1533,9 +1531,7 @@ int RNA_property_float_clamp(PointerRNA *ptr, PropertyRNA *prop, float *value) *value = max; return 1; } - else { - return 0; - } + return 0; } int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value) @@ -1552,9 +1548,7 @@ int RNA_property_int_clamp(PointerRNA *ptr, PropertyRNA *prop, int *value) *value = max; return 1; } - else { - return 0; - } + return 0; } /* this is the max length including \0 terminator. @@ -1668,7 +1662,7 @@ void RNA_property_enum_items(bContext *C, #ifdef WITH_INTERNATIONAL static void property_enum_translate(PropertyRNA *prop, EnumPropertyItem **r_item, - int *r_totitem, + const int *totitem, bool *r_free) { if (!(prop->flag & PROP_ENUM_NO_TRANSLATE)) { @@ -1690,8 +1684,8 @@ static void property_enum_translate(PropertyRNA *prop, const EnumPropertyItem *item = *r_item; int tot; - if (r_totitem) { - tot = *r_totitem; + if (totitem) { + tot = *totitem; } else { /* count */ @@ -2614,12 +2608,10 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop) if (iprop->get) { return iprop->get(ptr); } - else if (iprop->get_ex) { + if (iprop->get_ex) { return iprop->get_ex(ptr, prop); } - else { - return iprop->defaultvalue; - } + return iprop->defaultvalue; } void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value) @@ -2950,15 +2942,13 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop) } return (float)IDP_Double(idprop); } - else if (fprop->get) { + if (fprop->get) { return fprop->get(ptr); } - else if (fprop->get_ex) { + if (fprop->get_ex) { return fprop->get_ex(ptr, prop); } - else { - return fprop->defaultvalue; - } + return fprop->defaultvalue; } void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value) @@ -3389,15 +3379,13 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop) #endif return idprop->len - 1; } - else if (sprop->length) { + if (sprop->length) { return sprop->length(ptr); } - else if (sprop->length_ex) { + if (sprop->length_ex) { return sprop->length_ex(ptr, prop); } - else { - return strlen(sprop->defaultvalue); - } + return strlen(sprop->defaultvalue); } void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value) @@ -3555,12 +3543,10 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop) if (eprop->get) { return eprop->get(ptr); } - else if (eprop->get_ex) { + if (eprop->get_ex) { return eprop->get_ex(ptr, prop); } - else { - return eprop->defaultvalue; - } + return eprop->defaultvalue; } void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value) @@ -3671,18 +3657,16 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) } return rna_pointer_inherit_refine(ptr, pprop->type, idprop); } - else if (pprop->get) { + if (pprop->get) { return pprop->get(ptr); } - else if (prop->flag & PROP_IDPROPERTY) { + if (prop->flag & PROP_IDPROPERTY) { /* XXX temporary hack to add it automatically, reading should * never do any write ops, to ensure thread safety etc .. */ RNA_property_pointer_add(ptr, prop); return RNA_property_pointer_get(ptr, prop); } - else { - return PointerRNA_NULL; - } + return PointerRNA_NULL; } void RNA_property_pointer_set(PointerRNA *ptr, @@ -3924,18 +3908,16 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) if (cprop->length) { return cprop->length(ptr); } - else { - CollectionPropertyIterator iter; - int length = 0; - - RNA_property_collection_begin(ptr, prop, &iter); - for (; iter.valid; RNA_property_collection_next(&iter)) { - length++; - } - RNA_property_collection_end(&iter); + CollectionPropertyIterator iter; + int length = 0; - return length; + RNA_property_collection_begin(ptr, prop, &iter); + for (; iter.valid; RNA_property_collection_next(&iter)) { + length++; } + RNA_property_collection_end(&iter); + + return length; } /* This helper checks whether given collection property itself is editable (we only currently @@ -5775,21 +5757,19 @@ static char *rna_idp_path(PointerRNA *ptr, 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; - } + 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; } } } @@ -6788,9 +6768,7 @@ static char *rna_pointer_as_string__bldata(Main *bmain, PointerRNA *ptr) if (RNA_struct_is_ID(ptr->type)) { return RNA_path_full_ID_py(bmain, ptr->owner_id); } - else { - return RNA_path_full_struct_py(bmain, ptr); - } + return RNA_path_full_struct_py(bmain, ptr); } char *RNA_pointer_as_string(bContext *C, @@ -6805,9 +6783,7 @@ char *RNA_pointer_as_string(bContext *C, if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) { return RNA_pointer_as_string_id(C, ptr_prop); } - else { - return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop); - } + return rna_pointer_as_string__bldata(CTX_data_main(C), ptr_prop); } /* context can be NULL */ |