From 22158162efb6fb6b6d9af51c7be652fa9248155b Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 7 Jul 2020 19:34:35 +0200 Subject: Functions: add generic functions that output constants --- .../blender/functions/FN_multi_function_builder.hh | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source/blender/functions/FN_multi_function_builder.hh') diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index abc1e5d0723..98f263a75fa 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -225,6 +225,33 @@ template class CustomMF_Constant : public MultiFunction { } }; +/** + * A multi-function that outputs the same value every time. The value is not owned by an instance + * of this function. The caller is responsible for destructing and freeing the value. + */ +class CustomMF_GenericConstant : public MultiFunction { + private: + const CPPType &type_; + const void *value_; + + public: + CustomMF_GenericConstant(const CPPType &type, const void *value); + void call(IndexMask mask, MFParams params, MFContext context) const override; +}; + +/** + * A multi-function that outputs the same array every time. The array is not owned by in instance + * of this function. The caller is responsible for destructing and freeing the values. + */ +class CustomMF_GenericConstantArray : public MultiFunction { + private: + GSpan array_; + + public: + CustomMF_GenericConstantArray(GSpan array); + void call(IndexMask mask, MFParams params, MFContext context) const override; +}; + } // namespace blender::fn #endif /* __FN_MULTI_FUNCTION_BUILDER_HH__ */ -- cgit v1.2.3