diff options
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 82 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 2 |
5 files changed, 53 insertions, 45 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 8f7660d4015..53fa7a3d923 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -6723,23 +6723,27 @@ static void *rna_array_as_string_alloc( int type, int len, PointerRNA *ptr, PropertyRNA *prop, void **r_buf_end) { void *buf_ret = NULL; - if (type == PROP_BOOLEAN) { - bool *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); - RNA_property_boolean_get_array(ptr, prop, buf); - *r_buf_end = buf + len; - } - else if (type == PROP_INT) { - int *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); - RNA_property_int_get_array(ptr, prop, buf); - *r_buf_end = buf + len; - } - else if (type == PROP_FLOAT) { - float *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); - RNA_property_float_get_array(ptr, prop, buf); - *r_buf_end = buf + len; - } - else { - BLI_assert(0); + switch (type) { + case PROP_BOOLEAN: { + bool *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); + RNA_property_boolean_get_array(ptr, prop, buf); + *r_buf_end = buf + len; + break; + } + case PROP_INT: { + int *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); + RNA_property_int_get_array(ptr, prop, buf); + *r_buf_end = buf + len; + break; + } + case PROP_FLOAT: { + float *buf = buf_ret = MEM_mallocN(sizeof(*buf) * len, __func__); + RNA_property_float_get_array(ptr, prop, buf); + *r_buf_end = buf + len; + break; + } + default: + BLI_assert_unreachable(); } return buf_ret; } @@ -6749,29 +6753,33 @@ static void rna_array_as_string_elem(int type, void **buf_p, int len, DynStr *dy /* This will print a comma separated string of the array elements from * buf start to len. We will add a comma if len == 1 to preserve tuples. */ const int end = len - 1; - if (type == PROP_BOOLEAN) { - bool *buf = *buf_p; - for (int i = 0; i < len; i++, buf++) { - BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%s, " : "%s", bool_as_py_string(*buf)); + switch (type) { + case PROP_BOOLEAN: { + bool *buf = *buf_p; + for (int i = 0; i < len; i++, buf++) { + BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%s, " : "%s", bool_as_py_string(*buf)); + } + *buf_p = buf; + break; } - *buf_p = buf; - } - else if (type == PROP_INT) { - int *buf = *buf_p; - for (int i = 0; i < len; i++, buf++) { - BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%d, " : "%d", *buf); + case PROP_INT: { + int *buf = *buf_p; + for (int i = 0; i < len; i++, buf++) { + BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%d, " : "%d", *buf); + } + *buf_p = buf; + break; } - *buf_p = buf; - } - else if (type == PROP_FLOAT) { - float *buf = *buf_p; - for (int i = 0; i < len; i++, buf++) { - BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%g, " : "%g", *buf); + case PROP_FLOAT: { + float *buf = *buf_p; + for (int i = 0; i < len; i++, buf++) { + BLI_dynstr_appendf(dynstr, (i < end || !end) ? "%g, " : "%g", *buf); + } + *buf_p = buf; + break; } - *buf_p = buf; - } - else { - BLI_assert(0); + default: + BLI_assert_unreachable(); } } diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 5974788884e..aea4467c162 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -87,7 +87,7 @@ static ID *rna_property_override_property_real_id_owner(Main *bmain, owner_id = RNA_find_real_ID_and_path(bmain, id, &rna_path_prefix); break; default: - BLI_assert(0); + BLI_assert_unreachable(); } } @@ -354,7 +354,7 @@ static int rna_property_override_diff(Main *bmain, if (is_array_a != is_array_b) { /* Should probably never happen actually... */ - BLI_assert(0); + BLI_assert_unreachable(); return is_array_a ? 1 : -1; } @@ -400,7 +400,7 @@ static int rna_property_override_diff(Main *bmain, rna_path ? rna_path : prop_a->identifier, !prop_a->is_idprop, !prop_b->is_idprop); - BLI_assert(0); + BLI_assert_unreachable(); return 1; } @@ -491,7 +491,7 @@ static bool rna_property_override_operation_store(Main *bmain, op->rna_path, prop_local->magic == RNA_MAGIC, prop_reference->magic == RNA_MAGIC); - BLI_assert(0); + BLI_assert_unreachable(); return changed; } @@ -580,7 +580,7 @@ static bool rna_property_override_operation_apply(Main *bmain, prop_dst->identifier, prop_dst->magic == RNA_MAGIC, prop_src->magic == RNA_MAGIC); - BLI_assert(0); + BLI_assert_unreachable(); return false; } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 8e2b9c1d937..1e950b883ab 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -208,7 +208,7 @@ static int DNA_struct_find_nr_wrapper(const struct SDNA *sdna, const char *struc struct_name = DNA_struct_rename_legacy_hack_static_from_alias(struct_name); #ifdef RNA_RUNTIME /* We may support this at some point but for now we don't. */ - BLI_assert(0); + BLI_assert_unreachable(); #else struct_name = BLI_ghash_lookup_default( g_version_data.struct_map_static_from_alias, struct_name, (void *)struct_name); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index a7d673d3fe1..d540b51a585 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -2655,7 +2655,7 @@ bool rna_property_override_apply_default(Main *bmain, break; } default: - BLI_assert(0); + BLI_assert_unreachable(); return false; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b647a823929..63a68d04a97 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2085,7 +2085,7 @@ static char *rna_TransformOrientationSlot_path(PointerRNA *ptr) } /* Should not happen, but in case, just return default path. */ - BLI_assert(0); + BLI_assert_unreachable(); return BLI_strdup("transform_orientation_slots[0]"); } |