diff options
author | Jacques Lucke <jacques@blender.org> | 2020-02-13 20:21:15 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-02-13 20:21:15 +0300 |
commit | 9906e5313b8dd933505954a1702f7a39695ad37c (patch) | |
tree | fe9754fe5f10ddbdf303cfdf7771aa834d144ee3 | |
parent | 2e1d18600f39b6227799d5ffaa377bb9f7f51a68 (diff) |
remove usage of lazy init macro
4 files changed, 19 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_lazy_init_cxx.h b/source/blender/blenlib/BLI_lazy_init_cxx.h index 277637520c0..984e29cc1cb 100644 --- a/source/blender/blenlib/BLI_lazy_init_cxx.h +++ b/source/blender/blenlib/BLI_lazy_init_cxx.h @@ -62,18 +62,3 @@ void lazy_init_register(std::function<void()> free_func, const char *name); #define BLI_LAZY_INIT_STATIC(type, func_name) \ static type &func_name(void); \ BLI_LAZY_INIT(type, func_name) - -#define BLI_LAZY_INIT_REF(TYPE, NAME) \ - static std::unique_ptr<TYPE> NAME##_impl(void); \ - static TYPE *NAME##_builder(void) \ - { \ - static std::unique_ptr<TYPE> value = NAME##_impl(); \ - BLI::lazy_init_register([]() { delete value.release(); }, #NAME); \ - return value.get(); \ - } \ - TYPE &NAME(void) \ - { \ - static TYPE &value = *NAME##_builder(); \ - return value; \ - } \ - std::unique_ptr<TYPE> NAME##_impl(void) diff --git a/source/blender/functions/intern/initialize.cc b/source/blender/functions/intern/initialize.cc index 61f3214c4b2..962998e6796 100644 --- a/source/blender/functions/intern/initialize.cc +++ b/source/blender/functions/intern/initialize.cc @@ -1,12 +1,15 @@ #include "FN_initialize.h" #include "cpp_types.h" +#include "node_tree_multi_function_network/mappings.h" void FN_initialize(void) { FN::init_cpp_types(); + FN::MFGeneration::init_function_tree_mf_mappings(); } void FN_exit(void) { + FN::MFGeneration::free_function_tree_mf_mappings(); FN::free_cpp_types(); } diff --git a/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc b/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc index b79a0dc8240..139f981c376 100644 --- a/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc +++ b/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc @@ -8,12 +8,23 @@ namespace FN { namespace MFGeneration { -BLI_LAZY_INIT_REF(const FunctionTreeMFMappings, get_function_tree_multi_function_mappings) +static FunctionTreeMFMappings *mappings; + +void init_function_tree_mf_mappings() { - auto mappings = BLI::make_unique<FunctionTreeMFMappings>(); + mappings = new FunctionTreeMFMappings(); add_function_tree_socket_mapping_info(*mappings); add_function_tree_node_mapping_info(*mappings); - return mappings; +} + +void free_function_tree_mf_mappings() +{ + delete mappings; +} + +const FunctionTreeMFMappings &get_function_tree_multi_function_mappings() +{ + return *mappings; } } // namespace MFGeneration diff --git a/source/blender/functions/intern/node_tree_multi_function_network/mappings.h b/source/blender/functions/intern/node_tree_multi_function_network/mappings.h index 963e503a80f..1eaec2a467d 100644 --- a/source/blender/functions/intern/node_tree_multi_function_network/mappings.h +++ b/source/blender/functions/intern/node_tree_multi_function_network/mappings.h @@ -34,6 +34,8 @@ struct FunctionTreeMFMappings { void add_function_tree_socket_mapping_info(FunctionTreeMFMappings &mappings); void add_function_tree_node_mapping_info(FunctionTreeMFMappings &mappings); +void init_function_tree_mf_mappings(); +void free_function_tree_mf_mappings(); const FunctionTreeMFMappings &get_function_tree_multi_function_mappings(); } // namespace MFGeneration |