[Bf-blender-cvs] [2252bc6a552] master: BLI: move CPPType to blenlib

Jacques Lucke noreply at git.blender.org
Fri Mar 18 10:58:08 CET 2022


Commit: 2252bc6a5527cd7360d1ccfe7a2d1bc640a8dfa6
Author: Jacques Lucke
Date:   Fri Mar 18 10:57:45 2022 +0100
Branches: master
https://developer.blender.org/rB2252bc6a5527cd7360d1ccfe7a2d1bc640a8dfa6

BLI: move CPPType to blenlib

For more detail about `CPPType`, see `BLI_cpp_type.hh` and D14367.

Differential Revision: https://developer.blender.org/D14367

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

M	source/blender/blenkernel/BKE_attribute_access.hh
M	source/blender/blenkernel/BKE_attribute_math.hh
M	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/BKE_mesh_sample.hh
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/BKE_type_conversions.hh
M	source/blender/blenkernel/intern/attribute_access.cc
M	source/blender/blenkernel/intern/geometry_component_instances.cc
R088	source/blender/functions/FN_cpp_type.hh	source/blender/blenlib/BLI_cpp_type.hh
R094	source/blender/functions/FN_cpp_type_make.hh	source/blender/blenlib/BLI_cpp_type_make.hh
M	source/blender/blenlib/CMakeLists.txt
A	source/blender/blenlib/intern/cpp_type.cc
R097	source/blender/functions/tests/FN_cpp_type_test.cc	source/blender/blenlib/tests/BLI_cpp_type_test.cc
M	source/blender/editors/geometry/geometry_attributes.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_column.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_column_values.hh
M	source/blender/functions/CMakeLists.txt
M	source/blender/functions/FN_field.hh
M	source/blender/functions/FN_field_cpp_type.hh
M	source/blender/functions/FN_generic_array.hh
M	source/blender/functions/FN_generic_pointer.hh
M	source/blender/functions/FN_generic_span.hh
M	source/blender/functions/FN_multi_function.hh
M	source/blender/functions/FN_multi_function_data_type.hh
M	source/blender/functions/intern/cpp_types.cc
M	source/blender/functions/tests/FN_field_test.cc
M	source/blender/geometry/intern/realize_instances.cc
M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/modifiers/intern/MOD_nodes_evaluator.cc
M	source/blender/nodes/NOD_geometry_exec.hh
M	source/blender/nodes/NOD_geometry_nodes_eval_log.hh
M	source/blender/nodes/geometry/node_geometry_exec.cc
M	source/blender/nodes/intern/geometry_nodes_eval_log.cc
M	source/blender/nodes/intern/node_socket.cc

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

diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index 500f386dcc0..e36163878a5 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -4,7 +4,6 @@
 
 #include <mutex>
 
-#include "FN_cpp_type.hh"
 #include "FN_generic_span.hh"
 #include "FN_generic_virtual_array.hh"
 
@@ -166,7 +165,6 @@ using AttributeForeachCallback = blender::FunctionRef<bool(
 
 namespace blender::bke {
 
-using fn::CPPType;
 using fn::GVArray;
 using fn::GVMutableArray;
 
@@ -390,7 +388,7 @@ class CustomDataAttributes {
   template<typename T>
   blender::VArray<T> get_for_read(const AttributeIDRef &attribute_id, const T &default_value) const
   {
-    const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>();
+    const blender::CPPType &cpp_type = blender::CPPType::get<T>();
     const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type);
     GVArray varray = this->get_for_read(attribute_id, type, &default_value);
     return varray.typed<T>();
diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh
index 42bff89922b..9e97979fde9 100644
--- a/source/blender/blenkernel/BKE_attribute_math.hh
+++ b/source/blender/blenkernel/BKE_attribute_math.hh
@@ -4,17 +4,14 @@
 
 #include "BLI_array.hh"
 #include "BLI_color.hh"
+#include "BLI_cpp_type.hh"
 #include "BLI_math_vector.h"
 #include "BLI_math_vector.hh"
 
 #include "DNA_customdata_types.h"
 
-#include "FN_cpp_type.hh"
-
 namespace blender::attribute_math {
 
-using fn::CPPType;
-
 /**
  * Utility function that simplifies calling a templated function based on a custom data type.
  */
@@ -50,7 +47,7 @@ inline void convert_to_static_type(const CustomDataType data_type, const Func &f
 }
 
 template<typename Func>
-inline void convert_to_static_type(const fn::CPPType &cpp_type, const Func &func)
+inline void convert_to_static_type(const CPPType &cpp_type, const Func &func)
 {
   if (cpp_type.is<float>()) {
     func(float());
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 0e121068cbc..372922a24d2 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -212,7 +212,7 @@ class GeometryComponent {
                                             const AttributeDomain domain,
                                             const T &default_value) const
   {
-    const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>();
+    const blender::CPPType &cpp_type = blender::CPPType::get<T>();
     const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type);
     return this->attribute_get_for_read(attribute_id, domain, type, &default_value)
         .template typed<T>();
@@ -240,7 +240,7 @@ class GeometryComponent {
       const AttributeDomain domain,
       const T default_value)
   {
-    const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>();
+    const blender::CPPType &cpp_type = blender::CPPType::get<T>();
     const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type);
     return this->attribute_try_get_for_output(attribute_id, domain, data_type, &default_value);
   }
@@ -260,7 +260,7 @@ class GeometryComponent {
   blender::bke::OutputAttribute_Typed<T> attribute_try_get_for_output_only(
       const blender::bke::AttributeIDRef &attribute_id, const AttributeDomain domain)
   {
-    const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>();
+    const blender::CPPType &cpp_type = blender::CPPType::get<T>();
     const CustomDataType data_type = blender::bke::cpp_type_to_custom_data_type(cpp_type);
     return this->attribute_try_get_for_output_only(attribute_id, domain, data_type);
   }
diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh
index 9fe5bd3c531..a51dc7eef2f 100644
--- a/source/blender/blenkernel/BKE_mesh_sample.hh
+++ b/source/blender/blenkernel/BKE_mesh_sample.hh
@@ -21,7 +21,6 @@ class OutputAttribute;
 
 namespace blender::bke::mesh_surface_sample {
 
-using fn::CPPType;
 using fn::GMutableSpan;
 using fn::GSpan;
 using fn::GVArray;
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 3e964b038c4..fa199300780 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -99,6 +99,7 @@ typedef struct bNodeSocketTemplate {
  * However, achieving this requires quite a few changes currently. */
 #ifdef __cplusplus
 namespace blender {
+class CPPType;
 namespace nodes {
 class NodeMultiFunctionBuilder;
 class GeoNodeExecParams;
@@ -106,12 +107,11 @@ class NodeDeclarationBuilder;
 class GatherLinkSearchOpParams;
 }  // namespace nodes
 namespace fn {
-class CPPType;
 class MFDataType;
 }  // namespace fn
 }  // namespace blender
 
-using CPPTypeHandle = blender::fn::CPPType;
+using CPPTypeHandle = blender::CPPType;
 using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder);
 using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params);
 using NodeDeclareFunction = void (*)(blender::nodes::NodeDeclarationBuilder &builder);
diff --git a/source/blender/blenkernel/BKE_type_conversions.hh b/source/blender/blenkernel/BKE_type_conversions.hh
index e66982aa04c..8d3b2730a9c 100644
--- a/source/blender/blenkernel/BKE_type_conversions.hh
+++ b/source/blender/blenkernel/BKE_type_conversions.hh
@@ -6,8 +6,6 @@
 
 namespace blender::bke {
 
-using fn::CPPType;
-
 struct ConversionFunctions {
   const fn::MultiFunction *multi_function;
   void (*convert_single_to_initialized)(const void *src, void *dst);
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 2f07ee55d79..f79e8ee7653 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -54,7 +54,7 @@ std::ostream &operator<<(std::ostream &stream, const AttributeIDRef &attribute_i
   return stream;
 }
 
-const blender::fn::CPPType *custom_data_type_to_cpp_type(const CustomDataType type)
+const blender::CPPType *custom_data_type_to_cpp_type(const CustomDataType type)
 {
   switch (type) {
     case CD_PROP_FLOAT:
@@ -77,7 +77,7 @@ const blender::fn::CPPType *custom_data_type_to_cpp_type(const CustomDataType ty
   return nullptr;
 }
 
-CustomDataType cpp_type_to_custom_data_type(const blender::fn::CPPType &type)
+CustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type)
 {
   if (type.is<float>()) {
     return CD_PROP_FLOAT;
@@ -1102,7 +1102,7 @@ std::optional<AttributeMetaData> GeometryComponent::attribute_get_meta_data(
 }
 
 static blender::fn::GVArray try_adapt_data_type(blender::fn::GVArray varray,
-                                                const blender::fn::CPPType &to_type)
+                                                const blender::CPPType &to_type)
 {
   const blender::bke::DataTypeConversions &conversions =
       blender::bke::get_implicit_type_conversions();
@@ -1127,7 +1127,7 @@ blender::fn::GVArray GeometryComponent::attribute_try_get_for_read(
     }
   }
 
-  const blender::fn::CPPType *cpp_type = blender::bke::custom_data_type_to_cpp_type(data_type);
+  const blender::CPPType *cpp_type = blender::bke::custom_data_type_to_cpp_type(data_type);
   BLI_assert(cpp_type != nullptr);
   if (varray.type() != *cpp_type) {
     varray = try_adapt_data_type(std::move(varray), *cpp_type);
@@ -1165,7 +1165,7 @@ blender::bke::ReadAttributeLookup GeometryComponent::attribute_try_get_for_read(
   if (!attribute) {
     return {};
   }
-  const blender::fn::CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type);
+  const blender::CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type);
   BLI_assert(type != nullptr);
   if (attribute.varray.type() == *type) {
     return attribute;
@@ -1184,7 +1184,7 @@ blender::fn::GVArray GeometryComponent::attribute_get_for_read(const AttributeID
   if (varray) {
     return varray;
   }
-  const blender::fn::CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type);
+  const blender::CPPType *type = blender::bke::custom_data_type_to_cpp_type(data_type);
   if (default_value == nullptr) {
     default_value = type->default_value();
   }
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc
index 0cb2b0e812b..75384b5c420 100644
--- a/source/blender/blenkernel/intern/geometry_component_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_component_instances.cc
@@ -20,7 +20,7 @@
 
 #include "attribute_access_intern.hh"
 
-#include "FN_cpp_type_make.hh"
+#include "BLI_cpp_type_make.hh"
 
 using blender::float4x4;
 using blender::IndexMask;
@@ -31,7 +31,7 @@ using blender::Span;
 using blender::VectorSet;
 using blender::fn::GSpan;
 
-MAKE_CPP_TYPE(InstanceReference, InstanceReference, CPPTypeFlags::None)
+BLI_CPP_TYPE_MAKE(InstanceReference, InstanceReference, CPPTypeFlags::None)
 
 /* -------------------------------------------------------------------- */
 /** \name Geometry Component Implementation
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh
similarity index 88%
rename from source/blender/functions/FN_cpp_type.hh
rename to source/blender/blenlib/BLI_cpp_type.hh
index 420e2a8d9a9..ae6a87b4b68 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/blenlib/BLI_cpp_type.hh
@@ -3,28 +3,46 @@
 #pragma once
 
 /** \file
- * \ingroup fn
+ * \ingroup bli
  *
- * The `CPPType` class is the core of a runtime-type-system. It allows working with arbitrary C++
- * types in a generic way. An instance of `CPPType` wraps exactly one type like `int` or
- * `std::string`.
+ * The `CPPType` class allows working with arbitrary C++ types in a generic way. An instance of
+ * #CPPType wraps exactly one type like `int` or `std::string`.
+ *
+ * With #CPPType one can write generic data structures a

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list