From 2252bc6a5527cd7360d1ccfe7a2d1bc640a8dfa6 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 18 Mar 2022 10:57:45 +0100 Subject: BLI: move CPPType to blenlib For more detail about `CPPType`, see `BLI_cpp_type.hh` and D14367. Differential Revision: https://developer.blender.org/D14367 --- source/blender/blenkernel/BKE_attribute_access.hh | 4 +--- source/blender/blenkernel/BKE_attribute_math.hh | 7 ++----- source/blender/blenkernel/BKE_geometry_set.hh | 6 +++--- source/blender/blenkernel/BKE_mesh_sample.hh | 1 - source/blender/blenkernel/BKE_node.h | 4 ++-- source/blender/blenkernel/BKE_type_conversions.hh | 2 -- source/blender/blenkernel/intern/attribute_access.cc | 12 ++++++------ .../blenkernel/intern/geometry_component_instances.cc | 4 ++-- 8 files changed, 16 insertions(+), 24 deletions(-) (limited to 'source/blender/blenkernel') 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 -#include "FN_cpp_type.hh" #include "FN_generic_span.hh" #include "FN_generic_virtual_array.hh" @@ -166,7 +165,6 @@ using AttributeForeachCallback = blender::FunctionRef blender::VArray get_for_read(const AttributeIDRef &attribute_id, const T &default_value) const { - const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get(); + const blender::CPPType &cpp_type = blender::CPPType::get(); 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(); 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 -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()) { 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(); + const blender::CPPType &cpp_type = blender::CPPType::get(); 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(); @@ -240,7 +240,7 @@ class GeometryComponent { const AttributeDomain domain, const T default_value) { - const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get(); + const blender::CPPType &cpp_type = blender::CPPType::get(); 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 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(); + const blender::CPPType &cpp_type = blender::CPPType::get(); 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()) { return CD_PROP_FLOAT; @@ -1102,7 +1102,7 @@ std::optional 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 -- cgit v1.2.3