[Bf-blender-cvs] [9906e5313b8] functions: remove usage of lazy init macro

Jacques Lucke noreply at git.blender.org
Thu Feb 13 18:59:01 CET 2020


Commit: 9906e5313b8dd933505954a1702f7a39695ad37c
Author: Jacques Lucke
Date:   Thu Feb 13 18:21:15 2020 +0100
Branches: functions
https://developer.blender.org/rB9906e5313b8dd933505954a1702f7a39695ad37c

remove usage of lazy init macro

===================================================================

M	source/blender/blenlib/BLI_lazy_init_cxx.h
M	source/blender/functions/intern/initialize.cc
M	source/blender/functions/intern/node_tree_multi_function_network/mappings.cc
M	source/blender/functions/intern/node_tree_multi_function_network/mappings.h

===================================================================

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



More information about the Bf-blender-cvs mailing list