Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-02-18 23:08:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-02-18 23:08:10 +0300
commitbbc7dc169dc365889bad3f3aed7b868efb432710 (patch)
tree9f5b32383083fdab395ffac6064415fb1661d323 /source/blender/makesrna/intern/rna_access.c
parent86e04c4ca902e8c9752e708225f262cd0283f8b4 (diff)
RNA: assert when non 0/1 values used as bool
Prepare for using 'bool' type.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 48514745426..10b5112f29f 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1826,18 +1826,23 @@ int RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
IDProperty *idprop;
+ int value;
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) == false);
if ((idprop = rna_idproperty_check(&prop, ptr)))
- return IDP_Int(idprop);
+ value = IDP_Int(idprop);
else if (bprop->get)
- return bprop->get(ptr);
+ value = bprop->get(ptr);
else if (bprop->get_ex)
- return bprop->get_ex(ptr, prop);
+ value = bprop->get_ex(ptr, prop);
else
- return bprop->defaultvalue;
+ value = bprop->defaultvalue;
+
+ BLI_assert(ELEM(value, false, true));
+
+ return value;
}
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value)
@@ -1847,6 +1852,7 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value)
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) == false);
+ BLI_assert(ELEM(value, false, true));
/* just in case other values are passed */
if (value) value = 1;
@@ -1903,6 +1909,7 @@ int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index
{
int tmp[RNA_MAX_ARRAY_LENGTH];
int len = rna_ensure_property_array_length(ptr, prop);
+ int value;
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) != false);
@@ -1911,18 +1918,20 @@ int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index
if (len <= RNA_MAX_ARRAY_LENGTH) {
RNA_property_boolean_get_array(ptr, prop, tmp);
- return tmp[index];
+ value = tmp[index];
}
else {
- int *tmparray, value;
+ int *tmparray;
tmparray = MEM_callocN(sizeof(int) * len, __func__);
RNA_property_boolean_get_array(ptr, prop, tmparray);
value = tmparray[index];
MEM_freeN(tmparray);
-
- return value;
}
+
+ BLI_assert(ELEM(value, false, true));
+
+ return value;
}
void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
@@ -1972,6 +1981,7 @@ void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int inde
BLI_assert(RNA_property_array_check(prop) != false);
BLI_assert(index >= 0);
BLI_assert(index < len);
+ BLI_assert(ELEM(value, false, true));
if (len <= RNA_MAX_ARRAY_LENGTH) {
RNA_property_boolean_get_array(ptr, prop, tmp);
@@ -1995,6 +2005,7 @@ int RNA_property_boolean_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN);
BLI_assert(RNA_property_array_check(prop) == false);
+ BLI_assert(ELEM(bprop->defaultvalue, false, true));
return bprop->defaultvalue;
}