[Bf-blender-cvs] [15011e0b706] master: Functions: use static string for parameter names

Jacques Lucke noreply at git.blender.org
Sun Nov 21 12:57:41 CET 2021


Commit: 15011e0b7065243d1122e4eef9e5ba823264725e
Author: Jacques Lucke
Date:   Sun Nov 21 12:57:34 2021 +0100
Branches: master
https://developer.blender.org/rB15011e0b7065243d1122e4eef9e5ba823264725e

Functions: use static string for parameter names

The idea behind this change is the same as in
rB6ee2abde82ef121cd6e927995053ac33afdbb438.

A `MultiFunction::debug_parameter_name` method could be
added separately when necessary.

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

M	source/blender/functions/FN_multi_function_signature.hh
M	source/blender/functions/intern/multi_function_procedure_executor.cc

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

diff --git a/source/blender/functions/FN_multi_function_signature.hh b/source/blender/functions/FN_multi_function_signature.hh
index 2ccaa60fed6..3c991bc9c56 100644
--- a/source/blender/functions/FN_multi_function_signature.hh
+++ b/source/blender/functions/FN_multi_function_signature.hh
@@ -38,7 +38,7 @@ struct MFSignature {
    * actually needed.
    */
   const char *function_name;
-  Vector<std::string> param_names;
+  Vector<const char *> param_names;
   Vector<MFParamType> param_types;
   Vector<int> param_data_indices;
   bool depends_on_context = false;
@@ -70,23 +70,23 @@ class MFSignatureBuilder {
 
   /* Input Parameter Types */
 
-  template<typename T> void single_input(StringRef name)
+  template<typename T> void single_input(const char *name)
   {
     this->single_input(name, CPPType::get<T>());
   }
-  void single_input(StringRef name, const CPPType &type)
+  void single_input(const char *name, const CPPType &type)
   {
     this->input(name, MFDataType::ForSingle(type));
   }
-  template<typename T> void vector_input(StringRef name)
+  template<typename T> void vector_input(const char *name)
   {
     this->vector_input(name, CPPType::get<T>());
   }
-  void vector_input(StringRef name, const CPPType &base_type)
+  void vector_input(const char *name, const CPPType &base_type)
   {
     this->input(name, MFDataType::ForVector(base_type));
   }
-  void input(StringRef name, MFDataType data_type)
+  void input(const char *name, MFDataType data_type)
   {
     signature_.param_names.append(name);
     signature_.param_types.append(MFParamType(MFParamType::Input, data_type));
@@ -103,23 +103,23 @@ class MFSignatureBuilder {
 
   /* Output Parameter Types */
 
-  template<typename T> void single_output(StringRef name)
+  template<typename T> void single_output(const char *name)
   {
     this->single_output(name, CPPType::get<T>());
   }
-  void single_output(StringRef name, const CPPType &type)
+  void single_output(const char *name, const CPPType &type)
   {
     this->output(name, MFDataType::ForSingle(type));
   }
-  template<typename T> void vector_output(StringRef name)
+  template<typename T> void vector_output(const char *name)
   {
     this->vector_output(name, CPPType::get<T>());
   }
-  void vector_output(StringRef name, const CPPType &base_type)
+  void vector_output(const char *name, const CPPType &base_type)
   {
     this->output(name, MFDataType::ForVector(base_type));
   }
-  void output(StringRef name, MFDataType data_type)
+  void output(const char *name, MFDataType data_type)
   {
     signature_.param_names.append(name);
     signature_.param_types.append(MFParamType(MFParamType::Output, data_type));
@@ -136,23 +136,23 @@ class MFSignatureBuilder {
 
   /* Mutable Parameter Types */
 
-  template<typename T> void single_mutable(StringRef name)
+  template<typename T> void single_mutable(const char *name)
   {
     this->single_mutable(name, CPPType::get<T>());
   }
-  void single_mutable(StringRef name, const CPPType &type)
+  void single_mutable(const char *name, const CPPType &type)
   {
     this->mutable_(name, MFDataType::ForSingle(type));
   }
-  template<typename T> void vector_mutable(StringRef name)
+  template<typename T> void vector_mutable(const char *name)
   {
     this->vector_mutable(name, CPPType::get<T>());
   }
-  void vector_mutable(StringRef name, const CPPType &base_type)
+  void vector_mutable(const char *name, const CPPType &base_type)
   {
     this->mutable_(name, MFDataType::ForVector(base_type));
   }
-  void mutable_(StringRef name, MFDataType data_type)
+  void mutable_(const char *name, MFDataType data_type)
   {
     signature_.param_names.append(name);
     signature_.param_types.append(MFParamType(MFParamType::Mutable, data_type));
@@ -167,7 +167,7 @@ class MFSignatureBuilder {
     }
   }
 
-  void add(StringRef name, const MFParamType &param_type)
+  void add(const char *name, const MFParamType &param_type)
   {
     switch (param_type.interface_type()) {
       case MFParamType::Input:
diff --git a/source/blender/functions/intern/multi_function_procedure_executor.cc b/source/blender/functions/intern/multi_function_procedure_executor.cc
index 1136b03ed58..06c97fd1173 100644
--- a/source/blender/functions/intern/multi_function_procedure_executor.cc
+++ b/source/blender/functions/intern/multi_function_procedure_executor.cc
@@ -25,7 +25,7 @@ MFProcedureExecutor::MFProcedureExecutor(const MFProcedure &procedure) : procedu
   MFSignatureBuilder signature("Procedure Executor");
 
   for (const ConstMFParameter &param : procedure.params()) {
-    signature.add(param.variable->name(), MFParamType(param.type, param.variable->data_type()));
+    signature.add("Parameter", MFParamType(param.type, param.variable->data_type()));
   }
 
   signature_ = signature.build();



More information about the Bf-blender-cvs mailing list