[Bf-blender-cvs] [6ffab86a4db] functions: simplify naming for lazy init macros

Jacques Lucke noreply at git.blender.org
Wed Jun 5 10:07:19 CEST 2019


Commit: 6ffab86a4dbbc296bd6f2ed5bd4caa853ce7dade
Author: Jacques Lucke
Date:   Wed Jun 5 09:56:25 2019 +0200
Branches: functions
https://developer.blender.org/rB6ffab86a4dbbc296bd6f2ed5bd4caa853ce7dade

simplify naming for lazy init macros

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

M	source/blender/blenlib/BLI_lazy_init.hpp
M	source/blender/blenlib/intern/BLI_lazy_init.cpp
M	source/blender/functions/frontends/data_flow_nodes/inserters.cpp
M	source/blender/functions/functions/auto_vectorization.cpp
M	source/blender/functions/functions/lists.cpp
M	source/blender/functions/functions/random.cpp
M	source/blender/functions/functions/ranges.cpp
M	source/blender/functions/functions/scalar_math.cpp
M	source/blender/functions/functions/simple_conversions.cpp
M	source/blender/functions/functions/vectors.cpp
M	source/blender/functions/types/boolean.cpp
M	source/blender/functions/types/numeric.cpp
M	source/blender/functions/types/numeric_lists.cpp

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

diff --git a/source/blender/blenlib/BLI_lazy_init.hpp b/source/blender/blenlib/BLI_lazy_init.hpp
index f63621d44c1..026f7437001 100644
--- a/source/blender/blenlib/BLI_lazy_init.hpp
+++ b/source/blender/blenlib/BLI_lazy_init.hpp
@@ -10,30 +10,25 @@
 
 namespace BLI {
 
-void register_lazy_init_free_func(std::function<void()> free_func, const char *name);
+void lazy_init_register(std::function<void()> free_func, const char *name);
 
 }  // namespace BLI
 
-#define LAZY_INIT__NO_ARG(final_ret_type, builder_ret_type, func_name) \
-  static builder_ret_type func_name##_impl(void); \
-  static builder_ret_type &func_name##_builder(void) \
+#define BLI_LAZY_INIT(type, func_name) \
+  static type func_name##_impl(void); \
+  static type &func_name##_builder(void) \
   { \
-    static BLI::Optional<builder_ret_type> value = func_name##_impl(); \
-    BLI::register_lazy_init_free_func([]() { value.reset(); }, #func_name); \
+    static BLI::Optional<type> value = func_name##_impl(); \
+    BLI::lazy_init_register([]() { value.reset(); }, #func_name); \
     return value.value(); \
   } \
-  final_ret_type func_name(void) \
+  type &func_name(void) \
   { \
-    static builder_ret_type &value = func_name##_builder(); \
+    static type &value = func_name##_builder(); \
     return value; \
   } \
-  builder_ret_type func_name##_impl(void)
+  type func_name##_impl(void)
 
-#define LAZY_INIT_STATIC__NO_ARG(final_ret_type, builder_ret_type, func_name) \
-  static final_ret_type func_name(void); \
-  LAZY_INIT__NO_ARG(final_ret_type, builder_ret_type, func_name)
-
-#define LAZY_INIT_REF__NO_ARG(type, func_name) LAZY_INIT__NO_ARG(type &, type, func_name)
-
-#define LAZY_INIT_REF_STATIC__NO_ARG(type, func_name) \
-  LAZY_INIT_STATIC__NO_ARG(type &, type, func_name)
+#define BLI_LAZY_INIT_STATIC(type, func_name) \
+  static type &func_name(void); \
+  BLI_LAZY_INIT(type, func_name)
diff --git a/source/blender/blenlib/intern/BLI_lazy_init.cpp b/source/blender/blenlib/intern/BLI_lazy_init.cpp
index 0b0414e31ef..f386f7af363 100644
--- a/source/blender/blenlib/intern/BLI_lazy_init.cpp
+++ b/source/blender/blenlib/intern/BLI_lazy_init.cpp
@@ -30,7 +30,7 @@ void BLI_lazy_init_list_all()
 
 namespace BLI {
 
-void register_lazy_init_free_func(std::function<void()> free_func, const char *name)
+void lazy_init_register(std::function<void()> free_func, const char *name)
 {
   std::lock_guard<std::mutex> lock(store_free_func_mutex);
   free_functions.push({free_func, name});
diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
index f2c54a8c2fa..283fb5dfe1d 100644
--- a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp
@@ -18,7 +18,7 @@ static void initialize_standard_inserters(GraphInserters &inserters)
   register_conversion_inserters(inserters);
 }
 
-LAZY_INIT_REF__NO_ARG(GraphInserters, get_standard_inserters)
+BLI_LAZY_INIT(GraphInserters, get_standard_inserters)
 {
   GraphInserters inserters;
   initialize_standard_inserters(inserters);
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index f06a469c870..c98e60b7b1b 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -482,7 +482,7 @@ struct AutoVectorizationInput {
 
 using VectorizeCacheMap = SmallMap<AutoVectorizationInput, SharedFunction>;
 
-LAZY_INIT_REF_STATIC__NO_ARG(VectorizeCacheMap, get_vectorized_function_cache)
+BLI_LAZY_INIT_STATIC(VectorizeCacheMap, get_vectorized_function_cache)
 {
   return VectorizeCacheMap{};
 }
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index df39f91336f..9141be32ae8 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/functions/functions/lists.cpp
@@ -218,7 +218,7 @@ void insert_list_functions_for_type(ListFunctions &functions,
   functions.m_c_new_allocated.add(base_type, new_list_with_prepared_memory<T>);
 }
 
-LAZY_INIT_REF_STATIC__NO_ARG(ListFunctions, get_list_functions)
+BLI_LAZY_INIT_STATIC(ListFunctions, get_list_functions)
 {
   ListFunctions functions;
   insert_list_functions_for_type<float>(functions, GET_TYPE_float(), GET_TYPE_float_list());
diff --git a/source/blender/functions/functions/random.cpp b/source/blender/functions/functions/random.cpp
index 23e99b895ad..ade07c38310 100644
--- a/source/blender/functions/functions/random.cpp
+++ b/source/blender/functions/functions/random.cpp
@@ -32,7 +32,7 @@ class RandomNumber : public TupleCallBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_random_number)
+BLI_LAZY_INIT(SharedFunction, GET_FN_random_number)
 {
   FunctionBuilder builder;
   builder.add_input("Seed", GET_TYPE_int32());
diff --git a/source/blender/functions/functions/ranges.cpp b/source/blender/functions/functions/ranges.cpp
index 8dcc6721ff2..8dbc3da4894 100644
--- a/source/blender/functions/functions/ranges.cpp
+++ b/source/blender/functions/functions/ranges.cpp
@@ -31,7 +31,7 @@ class FloatRange : public TupleCallBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_float_range)
+BLI_LAZY_INIT(SharedFunction, GET_FN_float_range)
 {
   FunctionBuilder builder;
   builder.add_input("Amount", GET_TYPE_int32());
diff --git a/source/blender/functions/functions/scalar_math.cpp b/source/blender/functions/functions/scalar_math.cpp
index e82209bd90e..880414a417f 100644
--- a/source/blender/functions/functions/scalar_math.cpp
+++ b/source/blender/functions/functions/scalar_math.cpp
@@ -48,7 +48,7 @@ class GenAddFloats : public LLVMBuildIRBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_add_floats)
+BLI_LAZY_INIT(SharedFunction, GET_FN_add_floats)
 {
   auto fn = get_math_function__two_inputs("Add Floats");
   // fn->add_body<AddFloats>();
@@ -75,7 +75,7 @@ class MultiplyFloatsGen : public LLVMBuildIRBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_multiply_floats)
+BLI_LAZY_INIT(SharedFunction, GET_FN_multiply_floats)
 {
   auto fn = get_math_function__two_inputs("Multiply Floats");
   fn->add_body<MultiplyFloats>();
@@ -92,7 +92,7 @@ class MinFloats : public TupleCallBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_min_floats)
+BLI_LAZY_INIT(SharedFunction, GET_FN_min_floats)
 {
   auto fn = get_math_function__two_inputs("Minimum");
   fn->add_body<MinFloats>();
@@ -108,7 +108,7 @@ class MaxFloats : public TupleCallBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_max_floats)
+BLI_LAZY_INIT(SharedFunction, GET_FN_max_floats)
 {
   auto fn = get_math_function__two_inputs("Maximum");
   fn->add_body<MaxFloats>();
@@ -141,7 +141,7 @@ class MapRange : public TupleCallBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_map_range)
+BLI_LAZY_INIT(SharedFunction, GET_FN_map_range)
 {
   FunctionBuilder builder;
   builder.add_input("Value", GET_TYPE_float());
@@ -174,7 +174,7 @@ class SinFloatGen : public LLVMBuildIRBody {
   }
 };
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_sin_float)
+BLI_LAZY_INIT(SharedFunction, GET_FN_sin_float)
 {
   auto fn = get_math_function__one_input("Sin");
   fn->add_body<SinFloat>();
@@ -264,12 +264,12 @@ static SharedFunction get_output_int32_function(int32_t value)
   return fn;
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_int32_0)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_int32_0)
 {
   return get_output_int32_function(0);
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_int32_1)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_int32_1)
 {
   return get_output_int32_function(1);
 }
@@ -284,12 +284,12 @@ static SharedFunction get_output_float_function(float value)
   return fn;
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_float_0)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_float_0)
 {
   return get_output_float_function(0.0f);
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_float_1)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_float_1)
 {
   return get_output_float_function(1.0f);
 }
@@ -304,12 +304,12 @@ static SharedFunction get_output_bool_function(bool value)
   return fn;
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_false)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_false)
 {
   return get_output_bool_function(false);
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_output_true)
+BLI_LAZY_INIT(SharedFunction, GET_FN_output_true)
 {
   return get_output_bool_function(true);
 }
diff --git a/source/blender/functions/functions/simple_conversions.cpp b/source/blender/functions/functions/simple_conversions.cpp
index 780ca76ac4e..25a9e37aa0b 100644
--- a/source/blender/functions/functions/simple_conversions.cpp
+++ b/source/blender/functions/functions/simple_conversions.cpp
@@ -37,64 +37,64 @@ static SharedFunction get_implicit_conversion_function(SharedType &from_type, Sh
 
 /* Individual Element Conversion */
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_bool_to_int32)
+BLI_LAZY_INIT(SharedFunction, GET_FN_bool_to_int32)
 {
   return get_implicit_conversion_function<bool, int32_t>(GET_TYPE_bool(), GET_TYPE_int32());
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_bool_to_float)
+BLI_LAZY_INIT(SharedFunction, GET_FN_bool_to_float)
 {
   return get_implicit_conversion_function<bool, float>(GET_TYPE_bool(), GET_TYPE_float());
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_int32_to_float)
+BLI_LAZY_INIT(SharedFunction, GET_FN_int32_to_float)
 {
   return get_implicit_conversion_function<int32_t, float>(GET_TYPE_int32(), GET_TYPE_float());
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_int32_to_bool)
+BLI_LAZY_INIT(SharedFunction, GET_FN_int32_to_bool)
 {
   return get_implicit_conversion_function<int32_t, bool>(GET_TYPE_int32(), GET_TYPE_bool());
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_float_to_int32)
+BLI_LAZY_INIT(SharedFunction, GET_FN_float_to_int32)
 {
   return get_implicit_conversion_function<float, int32_t>(GET_TYPE_float(), GET_TYPE_int32());
 }
 
-LAZY_INIT_REF__NO_ARG(SharedFunction, GET_FN_float_to_bool)
+BLI_LAZY_INIT(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list