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:
authorJacques Lucke <mail@jlucke.com>2019-11-19 12:49:34 +0300
committerJacques Lucke <mail@jlucke.com>2019-11-19 12:49:34 +0300
commit3d16a8193f854f501543b93b4a938426a6192e4f (patch)
tree81b453da7bacbeeae66a9ebbdb3f36009c22f4a0 /source/blender/functions
parent1aef4b1298f55482ec48735431c09bf9a95d07f7 (diff)
improved debug error checking
Diffstat (limited to 'source/blender/functions')
-rw-r--r--source/blender/functions/FN_generic_virtual_list_list_ref.h5
-rw-r--r--source/blender/functions/FN_generic_virtual_list_ref.h5
-rw-r--r--source/blender/functions/FN_multi_function.h49
3 files changed, 50 insertions, 9 deletions
diff --git a/source/blender/functions/FN_generic_virtual_list_list_ref.h b/source/blender/functions/FN_generic_virtual_list_list_ref.h
index 54d01bb3fdb..7a309780bb7 100644
--- a/source/blender/functions/FN_generic_virtual_list_list_ref.h
+++ b/source/blender/functions/FN_generic_virtual_list_list_ref.h
@@ -76,6 +76,11 @@ class GenericVirtualListListRef {
return m_virtual_list_size;
}
+ const CPPType &type() const
+ {
+ return *m_type;
+ }
+
GenericVirtualListRef operator[](uint index) const
{
BLI_assert(index < m_virtual_list_size);
diff --git a/source/blender/functions/FN_generic_virtual_list_ref.h b/source/blender/functions/FN_generic_virtual_list_ref.h
index f8543c0a04f..7bb38edc992 100644
--- a/source/blender/functions/FN_generic_virtual_list_ref.h
+++ b/source/blender/functions/FN_generic_virtual_list_ref.h
@@ -128,6 +128,11 @@ class GenericVirtualListRef {
return m_virtual_size;
}
+ const CPPType &type() const
+ {
+ return *m_type;
+ }
+
const void *operator[](uint index) const
{
BLI_assert(index < m_virtual_size);
diff --git a/source/blender/functions/FN_multi_function.h b/source/blender/functions/FN_multi_function.h
index b8eb3a366a1..59fa0be5d04 100644
--- a/source/blender/functions/FN_multi_function.h
+++ b/source/blender/functions/FN_multi_function.h
@@ -217,57 +217,88 @@ class MFParamsBuilder {
template<typename T> void add_readonly_single_input(ArrayRef<T> array)
{
- BLI_assert(array.size() >= m_min_array_size);
- m_virtual_list_refs.append(GenericVirtualListRef::FromFullArray<T>(array));
+ this->add_readonly_single_input(GenericVirtualListRef::FromFullArray<T>(array));
}
template<typename T> void add_readonly_single_input(const T *value)
{
- m_virtual_list_refs.append(
+ this->add_readonly_single_input(
GenericVirtualListRef::FromSingle(CPP_TYPE<T>(), (void *)value, m_min_array_size));
}
void add_readonly_single_input(GenericVirtualListRef list)
{
+ this->assert_current_param_type(MFParamType::ForSingleInput(list.type()));
BLI_assert(list.size() >= m_min_array_size);
m_virtual_list_refs.append(list);
}
void add_readonly_vector_input(GenericVirtualListListRef list)
{
+ this->assert_current_param_type(MFParamType::ForVectorInput(list.type()));
BLI_assert(list.size() >= m_min_array_size);
m_virtual_list_list_refs.append(list);
}
+ template<typename T> void add_single_output(ArrayRef<T> array)
+ {
+ BLI_assert(array.size() >= m_min_array_size);
+ this->add_single_output(GenericMutableArrayRef(array));
+ }
void add_single_output(GenericMutableArrayRef array)
{
+ this->assert_current_param_type(MFParamType::ForSingleOutput(array.type()));
BLI_assert(array.size() >= m_min_array_size);
m_mutable_array_refs.append(array);
}
void add_vector_output(GenericVectorArray &vector_array)
{
+ this->assert_current_param_type(MFParamType::ForVectorOutput(vector_array.type()));
BLI_assert(vector_array.size() >= m_min_array_size);
m_vector_arrays.append(&vector_array);
}
- template<typename T> void add_single_output(ArrayRef<T> array)
- {
- BLI_assert(array.size() >= m_min_array_size);
- m_mutable_array_refs.append(GenericMutableArrayRef(array));
- }
-
void add_mutable_vector(GenericVectorArray &vector_array)
{
+ this->assert_current_param_type(MFParamType::ForVectorMutable(vector_array.type()));
BLI_assert(vector_array.size() >= m_min_array_size);
m_vector_arrays.append(&vector_array);
}
void add_mutable_single(GenericMutableArrayRef array)
{
+ this->assert_current_param_type(MFParamType::ForSingleMutable(array.type()));
BLI_assert(array.size() >= m_min_array_size);
m_mutable_array_refs.append(array);
}
+
+ private:
+ void assert_current_param_type(MFParamType param_type) const
+ {
+ UNUSED_VARS_NDEBUG(param_type);
+#ifdef DEBUG
+ uint param_index = this->current_param_index();
+ MFParamType expected_type = m_signature->param_types()[param_index];
+ BLI_assert(expected_type == param_type);
+#endif
+ }
+
+ void assert_current_param_type(MFParamType::Type type) const
+ {
+ UNUSED_VARS_NDEBUG(type);
+#ifdef DEBUG
+ uint param_index = this->current_param_index();
+ MFParamType::Type expected_type = m_signature->param_types()[param_index].type();
+ BLI_assert(expected_type == type);
+#endif
+ }
+
+ uint current_param_index() const
+ {
+ return m_mutable_array_refs.size() + m_virtual_list_refs.size() +
+ m_virtual_list_list_refs.size() + m_vector_arrays.size();
+ }
};
class MFParams {