[Bf-blender-cvs] [7921c6cb7e3] functions: store types in global variables

Jacques Lucke noreply at git.blender.org
Wed Aug 14 15:34:48 CEST 2019


Commit: 7921c6cb7e3bcda06918c984780773670ce760ce
Author: Jacques Lucke
Date:   Wed Aug 14 14:39:39 2019 +0200
Branches: functions
https://developer.blender.org/rB7921c6cb7e3bcda06918c984780773670ce760ce

store types in global variables

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

M	source/blender/functions/CMakeLists.txt
M	source/blender/functions/FN_types.hpp
M	source/blender/functions/frontends/data_flow_nodes/mappings/socket_loaders.cpp
M	source/blender/functions/frontends/data_flow_nodes/mappings/type_mappings.cpp
M	source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
M	source/blender/functions/functions/color.cpp
M	source/blender/functions/functions/comparisons.cpp
M	source/blender/functions/functions/constants.cpp
M	source/blender/functions/functions/lists.cpp
M	source/blender/functions/functions/object_input.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/switch.cpp
M	source/blender/functions/functions/vectors.cpp
M	source/blender/functions/initialize.cpp
M	source/blender/functions/types/boolean.cpp
M	source/blender/functions/types/boolean.hpp
M	source/blender/functions/types/external.cpp
M	source/blender/functions/types/external.hpp
A	source/blender/functions/types/initialization.cpp
A	source/blender/functions/types/initialization.hpp
M	source/blender/functions/types/lists.cpp
M	source/blender/functions/types/lists.hpp
M	source/blender/functions/types/numeric.cpp
M	source/blender/functions/types/numeric.hpp
M	source/blender/functions/types/types-c.cpp
M	source/blender/functions/types/types-c.h
M	source/blender/simulations/bparticles/emitters.cpp
M	source/blender/simulations/bparticles/inserters.cpp

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

diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 842a0388716..1142db625d1 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -100,6 +100,8 @@ set(SRC
   backends/llvm/context_pool.hpp
   backends/llvm/context_pool.cpp
 
+  types/initialization.hpp
+  types/initialization.cpp
   types/lists.hpp
   types/lists.cpp
   types/numeric.hpp
diff --git a/source/blender/functions/FN_types.hpp b/source/blender/functions/FN_types.hpp
index 39c99ef598d..f9e5229c7b0 100644
--- a/source/blender/functions/FN_types.hpp
+++ b/source/blender/functions/FN_types.hpp
@@ -5,3 +5,4 @@
 #include "types/numeric.hpp"
 #include "types/boolean.hpp"
 #include "types/external.hpp"
+#include "types/initialization.hpp"
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings/socket_loaders.cpp b/source/blender/functions/frontends/data_flow_nodes/mappings/socket_loaders.cpp
index 61c2a71195b..30b6bf0c80b 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings/socket_loaders.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings/socket_loaders.cpp
@@ -52,7 +52,7 @@ static void LOAD_color(PointerRNA *rna, Tuple &tuple, uint index)
 
 static SocketLoader GET_empty_list_loader(Type *type)
 {
-  return [&type](PointerRNA *UNUSED(rna), Tuple &tuple, uint index) {
+  return [type](PointerRNA *UNUSED(rna), Tuple &tuple, uint index) {
     auto list = SharedList::New(type);
     tuple.move_in(index, list);
   };
@@ -60,17 +60,17 @@ static SocketLoader GET_empty_list_loader(Type *type)
 
 void REGISTER_socket_loaders(std::unique_ptr<SocketLoaders> &loaders)
 {
-  loaders->register_loader("Boolean List", GET_empty_list_loader(GET_TYPE_bool()));
+  loaders->register_loader("Boolean List", GET_empty_list_loader(TYPE_bool));
   loaders->register_loader("Boolean", LOAD_boolean);
-  loaders->register_loader("Color List", GET_empty_list_loader(GET_TYPE_rgba_f()));
+  loaders->register_loader("Color List", GET_empty_list_loader(TYPE_rgba_f));
   loaders->register_loader("Color", LOAD_color);
-  loaders->register_loader("Float List", GET_empty_list_loader(GET_TYPE_float()));
+  loaders->register_loader("Float List", GET_empty_list_loader(TYPE_float));
   loaders->register_loader("Float", LOAD_float);
-  loaders->register_loader("Integer List", GET_empty_list_loader(GET_TYPE_int32()));
+  loaders->register_loader("Integer List", GET_empty_list_loader(TYPE_int32));
   loaders->register_loader("Integer", LOAD_integer);
-  loaders->register_loader("Object List", GET_empty_list_loader(GET_TYPE_object()));
+  loaders->register_loader("Object List", GET_empty_list_loader(TYPE_object));
   loaders->register_loader("Object", LOAD_object);
-  loaders->register_loader("Vector List", GET_empty_list_loader(GET_TYPE_float3()));
+  loaders->register_loader("Vector List", GET_empty_list_loader(TYPE_float3));
   loaders->register_loader("Vector", LOAD_vector);
 }
 
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings/type_mappings.cpp b/source/blender/functions/frontends/data_flow_nodes/mappings/type_mappings.cpp
index 41c84cb6d32..caa474448e0 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings/type_mappings.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings/type_mappings.cpp
@@ -8,8 +8,8 @@ namespace DataFlowNodes {
 
 void REGISTER_type_mappings(std::unique_ptr<TypeMappings> &type_mappings)
 {
-#define ADD_TYPE(idname, name, func_suffix) \
-  type_mappings->register_type(idname, name, Types::GET_TYPE_##func_suffix())
+#define ADD_TYPE(idname, name, cpp_name) \
+  type_mappings->register_type(idname, name, Types::TYPE_##cpp_name)
 
   ADD_TYPE("fn_BooleanListSocket", "Boolean List", bool_list);
   ADD_TYPE("fn_BooleanSocket", "Boolean", bool);
diff --git a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
index 24f56b34f97..947c911763a 100644
--- a/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/unlinked_input_inserters.cpp
@@ -129,9 +129,9 @@ class ConstantOutputGen : public LLVMBuildIRBody {
                 const BuildIRSettings &UNUSED(settings)) const override
   {
     TupleMeta &meta = m_tuple->meta();
-    Type *float_type = Types::GET_TYPE_float();
-    Type *int32_type = Types::GET_TYPE_int32();
-    Type *float3_type = Types::GET_TYPE_float3();
+    Type *float_type = Types::TYPE_float;
+    Type *int32_type = Types::TYPE_int32;
+    Type *float3_type = Types::TYPE_float3;
 
     for (uint i = 0; i < m_tuple->size(); i++) {
       Type *type = meta.types()[i];
diff --git a/source/blender/functions/functions/color.cpp b/source/blender/functions/functions/color.cpp
index 46ba2dfdfee..e5edcbac092 100644
--- a/source/blender/functions/functions/color.cpp
+++ b/source/blender/functions/functions/color.cpp
@@ -23,11 +23,11 @@ class SeparateColor : public TupleCallBody {
 BLI_LAZY_INIT(SharedFunction, GET_FN_separate_color)
 {
   FunctionBuilder fn_builder;
-  fn_builder.add_input("Color", GET_TYPE_rgba_f());
-  fn_builder.add_output("Red", GET_TYPE_float());
-  fn_builder.add_output("Green", GET_TYPE_float());
-  fn_builder.add_output("Blue", GET_TYPE_float());
-  fn_builder.add_output("Alpha", GET_TYPE_float());
+  fn_builder.add_input("Color", TYPE_rgba_f);
+  fn_builder.add_output("Red", TYPE_float);
+  fn_builder.add_output("Green", TYPE_float);
+  fn_builder.add_output("Blue", TYPE_float);
+  fn_builder.add_output("Alpha", TYPE_float);
 
   auto fn = fn_builder.build("Separate Color");
   fn->add_body<SeparateColor>();
@@ -49,11 +49,11 @@ class CombineColor : public TupleCallBody {
 BLI_LAZY_INIT(SharedFunction, GET_FN_combine_color)
 {
   FunctionBuilder fn_builder;
-  fn_builder.add_input("Red", GET_TYPE_float());
-  fn_builder.add_input("Green", GET_TYPE_float());
-  fn_builder.add_input("Blue", GET_TYPE_float());
-  fn_builder.add_input("Alpha", GET_TYPE_float());
-  fn_builder.add_output("Color", GET_TYPE_rgba_f());
+  fn_builder.add_input("Red", TYPE_float);
+  fn_builder.add_input("Green", TYPE_float);
+  fn_builder.add_input("Blue", TYPE_float);
+  fn_builder.add_input("Alpha", TYPE_float);
+  fn_builder.add_output("Color", TYPE_rgba_f);
 
   auto fn = fn_builder.build("Combine Color");
   fn->add_body<CombineColor>();
diff --git a/source/blender/functions/functions/comparisons.cpp b/source/blender/functions/functions/comparisons.cpp
index b9bf5396a6c..cd3402cd8b1 100644
--- a/source/blender/functions/functions/comparisons.cpp
+++ b/source/blender/functions/functions/comparisons.cpp
@@ -22,9 +22,9 @@ template<typename T> class LessThan : public TupleCallBody {
 BLI_LAZY_INIT(SharedFunction, GET_FN_less_than_float)
 {
   FunctionBuilder builder;
-  builder.add_input("A", GET_TYPE_float());
-  builder.add_input("B", GET_TYPE_float());
-  builder.add_output("A < B", GET_TYPE_bool());
+  builder.add_input("A", TYPE_float);
+  builder.add_input("B", TYPE_float);
+  builder.add_output("A < B", TYPE_bool);
 
   auto fn = builder.build("Less Than (float)");
   fn->add_body<LessThan<float>>();
@@ -34,9 +34,9 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_less_than_float)
 BLI_LAZY_INIT(SharedFunction, GET_FN_less_than_int32)
 {
   FunctionBuilder builder;
-  builder.add_input("A", GET_TYPE_int32());
-  builder.add_input("B", GET_TYPE_int32());
-  builder.add_output("A < B", GET_TYPE_bool());
+  builder.add_input("A", TYPE_int32);
+  builder.add_input("B", TYPE_int32);
+  builder.add_output("A < B", TYPE_bool);
 
   auto fn = builder.build("Less Than (int32)");
   fn->add_body<LessThan<int32_t>>();
diff --git a/source/blender/functions/functions/constants.cpp b/source/blender/functions/functions/constants.cpp
index 0a7dc84851b..5ef8f6cd112 100644
--- a/source/blender/functions/functions/constants.cpp
+++ b/source/blender/functions/functions/constants.cpp
@@ -82,7 +82,7 @@ class ConstBoolGen : public LLVMBuildIRBody {
 static SharedFunction get_output_int32_function(int32_t value)
 {
   FunctionBuilder builder;
-  builder.add_output("Value", GET_TYPE_int32());
+  builder.add_output("Value", TYPE_int32);
   auto fn = builder.build("Build Value: " + std::to_string(value));
   fn->add_body<ConstValue<int32_t>>(value);
   fn->add_body<ConstInt32Gen>(value);
@@ -102,7 +102,7 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_output_int32_1)
 static SharedFunction get_output_float_function(float value)
 {
   FunctionBuilder builder;
-  builder.add_output("Value", GET_TYPE_float());
+  builder.add_output("Value", TYPE_float);
   auto fn = builder.build("Build Value: " + std::to_string(value));
   fn->add_body<ConstValue<float>>(value);
   fn->add_body<ConstFloatGen>(value);
@@ -122,7 +122,7 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_output_float_1)
 static SharedFunction get_output_bool_function(bool value)
 {
   FunctionBuilder builder;
-  builder.add_output("Value", GET_TYPE_bool());
+  builder.add_output("Value", TYPE_bool);
   auto fn = builder.build("Build Value");
   fn->add_body<ConstValue<bool>>(value);
   fn->add_body<ConstBoolGen>(value);
@@ -165,7 +165,7 @@ template<uint N> class ConstFloatArrayGen : public LLVMBuildIRBody {
 static SharedFunction get_output_float3_function(float3 vector)
 {
   FunctionBuilder builder;
-  auto &float3_type = GET_TYPE_float3();
+  auto &float3_type = TYPE_float3;
   builder.add_output("Vector", float3_type);
   auto fn = builder.build("Build Vector");
   fn->add_body<ConstValue<float3>>(vector);
@@ -186,7 +186,7 @@ BLI_LAZY_INIT(SharedFunction, GET_FN_output_float3_1)
 static SharedFunction get_output_rgba_f_function(rgba_f color)
 {
   FunctionBuilder builder;
-  auto &rgba_f_type = GET_TYPE_rgba_f();
+  auto &rgba_f_type = TYPE_rgba_f;
   builder.add_output("RGBA Float", rgba_f_type);
   auto fn = builder.build("Build Color");
   fn->add_body<ConstValue<rgba_f>>(color);
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index b9d949bbbaa..2ca41fd0a0d 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/fu

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list