diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-27 16:25:35 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-27 16:25:35 +0300 |
commit | 2bf84b941081b4ac6a93ef2b617e85fcf3a11fac (patch) | |
tree | 924575080f897ba7bece550a49b542816ab88960 | |
parent | b4956ad6e0e97a96a102e746665dd191a177dd7d (diff) |
improve naming
18 files changed, 157 insertions, 161 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 8bbb3014dac..aa0af294bc3 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -1197,7 +1197,7 @@ static blender::bke::OutputAttribute create_output_attribute( cpp_type->size() * domain_size, cpp_type->alignment(), __func__); if (ignore_old_values) { /* This does nothing for trivially constructible types, but is necessary for correctness. */ - cpp_type->construct_default_n(data, domain); + cpp_type->default_construct_n(data, domain); } else { /* Fill the temporary array with values from the existing attribute. */ diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 8cf08d05d9d..88fcb18d3d2 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -535,7 +535,7 @@ static void join_attributes(Span<GeometryInstanceGroup> set_groups, const void *src_buffer = src_span.data(); for (const int UNUSED(i) : set_group.transforms.index_range()) { void *dst_buffer = dst_span[offset]; - cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size); + cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size); offset += domain_size; } } diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 1782000785d..60b51266138 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -35,11 +35,11 @@ * * A CPPType instance comes with many methods that allow dealing with types in a generic way. Most * methods come in three variants. Using the construct-default methods as example: - * - construct_default(void *ptr): + * - default_construct(void *ptr): * Constructs a single instance of that type at the given pointer. - * - construct_default_n(void *ptr, int64_t n): + * - default_construct_n(void *ptr, int64_t n): * Constructs n instances of that type in an array that starts at the given pointer. - * - construct_default_indices(void *ptr, IndexMask mask): + * - default_construct_indices(void *ptr, IndexMask mask): * Constructs multiple instances of that type in an array that starts at the given pointer. * Only the indices referenced by `mask` will by constructed. * @@ -58,7 +58,7 @@ * used now with explicit function pointers to work better. Here are some reasons: * - If CPPType would be inherited once for every used C++ type, we would get a lot of classes * that would only be instanced once each. - * - Methods like `construct_default` that operate on a single instance have to be fast. Even this + * - Methods like `default_construct` that operate on a single instance have to be fast. Even this * one necessary indirection using function pointers adds a lot of overhead. If all methods were * virtual, there would be a second level of indirection that increases the overhead even more. * - If it becomes necessary, we could pass the function pointers to C functions more easily than @@ -80,35 +80,35 @@ struct CPPTypeMembers { bool is_trivially_destructible = false; bool has_special_member_functions = false; - void (*construct_default)(void *ptr) = nullptr; - void (*construct_default_indices)(void *ptr, IndexMask mask) = nullptr; + void (*default_construct)(void *ptr) = nullptr; + void (*default_construct_indices)(void *ptr, IndexMask mask) = nullptr; void (*destruct)(void *ptr) = nullptr; void (*destruct_indices)(void *ptr, IndexMask mask) = nullptr; - void (*copy_to_initialized)(const void *src, void *dst) = nullptr; - void (*copy_to_initialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; + void (*copy_assign)(const void *src, void *dst) = nullptr; + void (*copy_assign_indices)(const void *src, void *dst, IndexMask mask) = nullptr; - void (*copy_to_uninitialized)(const void *src, void *dst) = nullptr; - void (*copy_to_uninitialized_indices)(const void *src, void *dst, IndexMask mask) = nullptr; + void (*copy_construct)(const void *src, void *dst) = nullptr; + void (*copy_construct_indices)(const void *src, void *dst, IndexMask mask) = nullptr; - void (*move_to_initialized)(void *src, void *dst) = nullptr; - void (*move_to_initialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; + void (*move_assign)(void *src, void *dst) = nullptr; + void (*move_assign_indices)(void *src, void *dst, IndexMask mask) = nullptr; - void (*move_to_uninitialized)(void *src, void *dst) = nullptr; - void (*move_to_uninitialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; + void (*move_construct)(void *src, void *dst) = nullptr; + void (*move_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr; - void (*relocate_to_initialized)(void *src, void *dst) = nullptr; - void (*relocate_to_initialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; + void (*relocate_assign)(void *src, void *dst) = nullptr; + void (*relocate_assign_indices)(void *src, void *dst, IndexMask mask) = nullptr; - void (*relocate_to_uninitialized)(void *src, void *dst) = nullptr; - void (*relocate_to_uninitialized_indices)(void *src, void *dst, IndexMask mask) = nullptr; + void (*relocate_construct)(void *src, void *dst) = nullptr; + void (*relocate_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr; - void (*fill_initialized)(const void *value, void *dst, int64_t n) = nullptr; - void (*fill_initialized_indices)(const void *value, void *dst, IndexMask mask) = nullptr; + void (*fill_assign)(const void *value, void *dst, int64_t n) = nullptr; + void (*fill_assign_indices)(const void *value, void *dst, IndexMask mask) = nullptr; - void (*fill_uninitialized)(const void *value, void *dst, int64_t n) = nullptr; - void (*fill_uninitialized_indices)(const void *value, void *dst, IndexMask mask) = nullptr; + void (*fill_construct)(const void *value, void *dst, int64_t n) = nullptr; + void (*fill_construct_indices)(const void *value, void *dst, IndexMask mask) = nullptr; void (*debug_print)(const void *value, std::stringstream &ss) = nullptr; bool (*is_equal)(const void *a, const void *b) = nullptr; @@ -127,9 +127,9 @@ class CPPType : NonCopyable, NonMovable { { BLI_assert(is_power_of_2_i(m_.alignment)); m_.alignment_mask = (uintptr_t)members.alignment - (uintptr_t)1; - m_.has_special_member_functions = (m_.construct_default && m_.copy_to_uninitialized && - m_.copy_to_initialized && m_.move_to_uninitialized && - m_.move_to_initialized && m_.destruct); + m_.has_special_member_functions = (m_.default_construct && m_.copy_construct && + m_.copy_assign && m_.move_construct && m_.move_assign && + m_.destruct); } /** @@ -198,17 +198,17 @@ class CPPType : NonCopyable, NonMovable { bool is_default_constructible() const { - return m_.construct_default != nullptr; + return m_.default_construct != nullptr; } bool is_copy_constructible() const { - return m_.copy_to_initialized != nullptr; + return m_.copy_assign != nullptr; } bool is_move_constructible() const { - return m_.move_to_initialized != nullptr; + return m_.move_assign != nullptr; } bool is_destructible() const @@ -218,12 +218,12 @@ class CPPType : NonCopyable, NonMovable { bool is_copy_assignable() const { - return m_.copy_to_initialized != nullptr; + return m_.copy_assign != nullptr; } bool is_move_assignable() const { - return m_.copy_to_uninitialized != nullptr; + return m_.copy_construct != nullptr; } /** @@ -261,23 +261,23 @@ class CPPType : NonCopyable, NonMovable { * C++ equivalent: * new (ptr) T; */ - void construct_default(void *ptr) const + void default_construct(void *ptr) const { BLI_assert(this->pointer_can_point_to_instance(ptr)); - m_.construct_default(ptr); + m_.default_construct(ptr); } - void construct_default_n(void *ptr, int64_t n) const + void default_construct_n(void *ptr, int64_t n) const { - this->construct_default_indices(ptr, IndexMask(n)); + this->default_construct_indices(ptr, IndexMask(n)); } - void construct_default_indices(void *ptr, IndexMask mask) const + void default_construct_indices(void *ptr, IndexMask mask) const { BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(ptr)); - m_.construct_default_indices(ptr, mask); + m_.default_construct_indices(ptr, mask); } /** @@ -313,27 +313,27 @@ class CPPType : NonCopyable, NonMovable { * C++ equivalent: * dst = src; */ - void copy_to_initialized(const void *src, void *dst) const + void copy_assign(const void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.copy_to_initialized(src, dst); + m_.copy_assign(src, dst); } - void copy_to_initialized_n(const void *src, void *dst, int64_t n) const + void copy_assign_n(const void *src, void *dst, int64_t n) const { - this->copy_to_initialized_indices(src, dst, IndexMask(n)); + this->copy_assign_indices(src, dst, IndexMask(n)); } - void copy_to_initialized_indices(const void *src, void *dst, IndexMask mask) const + void copy_assign_indices(const void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.copy_to_initialized_indices(src, dst, mask); + m_.copy_assign_indices(src, dst, mask); } /** @@ -344,27 +344,27 @@ class CPPType : NonCopyable, NonMovable { * C++ equivalent: * new (dst) T(src); */ - void copy_to_uninitialized(const void *src, void *dst) const + void copy_construct(const void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.copy_to_uninitialized(src, dst); + m_.copy_construct(src, dst); } - void copy_to_uninitialized_n(const void *src, void *dst, int64_t n) const + void copy_construct_n(const void *src, void *dst, int64_t n) const { - this->copy_to_uninitialized_indices(src, dst, IndexMask(n)); + this->copy_construct_indices(src, dst, IndexMask(n)); } - void copy_to_uninitialized_indices(const void *src, void *dst, IndexMask mask) const + void copy_construct_indices(const void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.copy_to_uninitialized_indices(src, dst, mask); + m_.copy_construct_indices(src, dst, mask); } /** @@ -375,27 +375,27 @@ class CPPType : NonCopyable, NonMovable { * C++ equivalent: * dst = std::move(src); */ - void move_to_initialized(void *src, void *dst) const + void move_assign(void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.move_to_initialized(src, dst); + m_.move_assign(src, dst); } - void move_to_initialized_n(void *src, void *dst, int64_t n) const + void move_assign_n(void *src, void *dst, int64_t n) const { - this->move_to_initialized_indices(src, dst, IndexMask(n)); + this->move_assign_indices(src, dst, IndexMask(n)); } - void move_to_initialized_indices(void *src, void *dst, IndexMask mask) const + void move_assign_indices(void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.move_to_initialized_indices(src, dst, mask); + m_.move_assign_indices(src, dst, mask); } /** @@ -406,27 +406,27 @@ class CPPType : NonCopyable, NonMovable { * C++ equivalent: * new (dst) T(std::move(src)); */ - void move_to_uninitialized(void *src, void *dst) const + void move_construct(void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.move_to_uninitialized(src, dst); + m_.move_construct(src, dst); } - void move_to_uninitialized_n(void *src, void *dst, int64_t n) const + void move_construct_n(void *src, void *dst, int64_t n) const { - this->move_to_uninitialized_indices(src, dst, IndexMask(n)); + this->move_construct_indices(src, dst, IndexMask(n)); } - void move_to_uninitialized_indices(void *src, void *dst, IndexMask mask) const + void move_construct_indices(void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.move_to_uninitialized_indices(src, dst, mask); + m_.move_construct_indices(src, dst, mask); } /** @@ -437,27 +437,27 @@ class CPPType : NonCopyable, NonMovable { * dst = std::move(src); * src->~T(); */ - void relocate_to_initialized(void *src, void *dst) const + void relocate_assign(void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.relocate_to_initialized(src, dst); + m_.relocate_assign(src, dst); } - void relocate_to_initialized_n(void *src, void *dst, int64_t n) const + void relocate_assign_n(void *src, void *dst, int64_t n) const { - this->relocate_to_initialized_indices(src, dst, IndexMask(n)); + this->relocate_assign_indices(src, dst, IndexMask(n)); } - void relocate_to_initialized_indices(void *src, void *dst, IndexMask mask) const + void relocate_assign_indices(void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.relocate_to_initialized_indices(src, dst, mask); + m_.relocate_assign_indices(src, dst, mask); } /** @@ -468,27 +468,27 @@ class CPPType : NonCopyable, NonMovable { * new (dst) T(std::move(src)) * src->~T(); */ - void relocate_to_uninitialized(void *src, void *dst) const + void relocate_construct(void *src, void *dst) const { BLI_assert(src != dst); BLI_assert(this->pointer_can_point_to_instance(src)); BLI_assert(this->pointer_can_point_to_instance(dst)); - m_.relocate_to_uninitialized(src, dst); + m_.relocate_construct(src, dst); } - void relocate_to_uninitialized_n(void *src, void *dst, int64_t n) const + void relocate_construct_n(void *src, void *dst, int64_t n) const { - this->relocate_to_uninitialized_indices(src, dst, IndexMask(n)); + this->relocate_construct_indices(src, dst, IndexMask(n)); } - void relocate_to_uninitialized_indices(void *src, void *dst, IndexMask mask) const + void relocate_construct_indices(void *src, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || src != dst); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(src)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.relocate_to_uninitialized_indices(src, dst, mask); + m_.relocate_construct_indices(src, dst, mask); } /** @@ -496,20 +496,20 @@ class CPPType : NonCopyable, NonMovable { * * Other instances of the same type should live in the array before this method is called. */ - void fill_initialized(const void *value, void *dst, int64_t n) const + void fill_assign(const void *value, void *dst, int64_t n) const { BLI_assert(n == 0 || this->pointer_can_point_to_instance(value)); BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - m_.fill_initialized(value, dst, n); + m_.fill_assign(value, dst, n); } - void fill_initialized_indices(const void *value, void *dst, IndexMask mask) const + void fill_assign_indices(const void *value, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(value)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.fill_initialized_indices(value, dst, mask); + m_.fill_assign_indices(value, dst, mask); } /** @@ -517,20 +517,20 @@ class CPPType : NonCopyable, NonMovable { * * The array should be uninitialized before this method is called. */ - void fill_uninitialized(const void *value, void *dst, int64_t n) const + void fill_construct(const void *value, void *dst, int64_t n) const { BLI_assert(n == 0 || this->pointer_can_point_to_instance(value)); BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst)); - m_.fill_uninitialized(value, dst, n); + m_.fill_construct(value, dst, n); } - void fill_uninitialized_indices(const void *value, void *dst, IndexMask mask) const + void fill_construct_indices(const void *value, void *dst, IndexMask mask) const { BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(value)); BLI_assert(mask.size() == 0 || this->pointer_can_point_to_instance(dst)); - m_.fill_uninitialized_indices(value, dst, mask); + m_.fill_construct_indices(value, dst, mask); } void debug_print(const void *value, std::stringstream &ss) const diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh index 81fb09d0731..8a12b32b805 100644 --- a/source/blender/functions/FN_cpp_type_make.hh +++ b/source/blender/functions/FN_cpp_type_make.hh @@ -24,11 +24,11 @@ namespace blender::fn::cpp_type_util { -template<typename T> void construct_default_cb(void *ptr) +template<typename T> void default_construct_cb(void *ptr) { new (ptr) T; } -template<typename T> void construct_default_indices_cb(void *ptr, IndexMask mask) +template<typename T> void default_construct_indices_cb(void *ptr, IndexMask mask) { mask.foreach_index([&](int64_t i) { new (static_cast<T *>(ptr) + i) T; }); } @@ -43,12 +43,11 @@ template<typename T> void destruct_indices_cb(void *ptr, IndexMask mask) mask.foreach_index([&](int64_t i) { ptr_[i].~T(); }); } -template<typename T> void copy_to_initialized_cb(const void *src, void *dst) +template<typename T> void copy_assign_cb(const void *src, void *dst) { *static_cast<T *>(dst) = *static_cast<const T *>(src); } -template<typename T> -void copy_to_initialized_indices_cb(const void *src, void *dst, IndexMask mask) +template<typename T> void copy_assign_indices_cb(const void *src, void *dst, IndexMask mask) { const T *src_ = static_cast<const T *>(src); T *dst_ = static_cast<T *>(dst); @@ -56,12 +55,11 @@ void copy_to_initialized_indices_cb(const void *src, void *dst, IndexMask mask) mask.foreach_index([&](int64_t i) { dst_[i] = src_[i]; }); } -template<typename T> void copy_to_uninitialized_cb(const void *src, void *dst) +template<typename T> void copy_construct_cb(const void *src, void *dst) { blender::uninitialized_copy_n(static_cast<const T *>(src), 1, static_cast<T *>(dst)); } -template<typename T> -void copy_to_uninitialized_indices_cb(const void *src, void *dst, IndexMask mask) +template<typename T> void copy_construct_indices_cb(const void *src, void *dst, IndexMask mask) { const T *src_ = static_cast<const T *>(src); T *dst_ = static_cast<T *>(dst); @@ -69,11 +67,11 @@ void copy_to_uninitialized_indices_cb(const void *src, void *dst, IndexMask mask mask.foreach_index([&](int64_t i) { new (dst_ + i) T(src_[i]); }); } -template<typename T> void move_to_initialized_cb(void *src, void *dst) +template<typename T> void move_assign_cb(void *src, void *dst) { blender::initialized_move_n(static_cast<T *>(src), 1, static_cast<T *>(dst)); } -template<typename T> void move_to_initialized_indices_cb(void *src, void *dst, IndexMask mask) +template<typename T> void move_assign_indices_cb(void *src, void *dst, IndexMask mask) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -81,11 +79,11 @@ template<typename T> void move_to_initialized_indices_cb(void *src, void *dst, I mask.foreach_index([&](int64_t i) { dst_[i] = std::move(src_[i]); }); } -template<typename T> void move_to_uninitialized_cb(void *src, void *dst) +template<typename T> void move_construct_cb(void *src, void *dst) { blender::uninitialized_move_n(static_cast<T *>(src), 1, static_cast<T *>(dst)); } -template<typename T> void move_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask) +template<typename T> void move_construct_indices_cb(void *src, void *dst, IndexMask mask) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -93,7 +91,7 @@ template<typename T> void move_to_uninitialized_indices_cb(void *src, void *dst, mask.foreach_index([&](int64_t i) { new (dst_ + i) T(std::move(src_[i])); }); } -template<typename T> void relocate_to_initialized_cb(void *src, void *dst) +template<typename T> void relocate_assign_cb(void *src, void *dst) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -101,7 +99,7 @@ template<typename T> void relocate_to_initialized_cb(void *src, void *dst) *dst_ = std::move(*src_); src_->~T(); } -template<typename T> void relocate_to_initialized_indices_cb(void *src, void *dst, IndexMask mask) +template<typename T> void relocate_assign_indices_cb(void *src, void *dst, IndexMask mask) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -112,7 +110,7 @@ template<typename T> void relocate_to_initialized_indices_cb(void *src, void *ds }); } -template<typename T> void relocate_to_uninitialized_cb(void *src, void *dst) +template<typename T> void relocate_construct_cb(void *src, void *dst) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -120,8 +118,7 @@ template<typename T> void relocate_to_uninitialized_cb(void *src, void *dst) new (dst_) T(std::move(*src_)); src_->~T(); } -template<typename T> -void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask) +template<typename T> void relocate_construct_indices_cb(void *src, void *dst, IndexMask mask) { T *src_ = static_cast<T *>(src); T *dst_ = static_cast<T *>(dst); @@ -132,7 +129,7 @@ void relocate_to_uninitialized_indices_cb(void *src, void *dst, IndexMask mask) }); } -template<typename T> void fill_initialized_cb(const void *value, void *dst, int64_t n) +template<typename T> void fill_assign_cb(const void *value, void *dst, int64_t n) { const T &value_ = *static_cast<const T *>(value); T *dst_ = static_cast<T *>(dst); @@ -141,7 +138,7 @@ template<typename T> void fill_initialized_cb(const void *value, void *dst, int6 dst_[i] = value_; } } -template<typename T> void fill_initialized_indices_cb(const void *value, void *dst, IndexMask mask) +template<typename T> void fill_assign_indices_cb(const void *value, void *dst, IndexMask mask) { const T &value_ = *static_cast<const T *>(value); T *dst_ = static_cast<T *>(dst); @@ -149,7 +146,7 @@ template<typename T> void fill_initialized_indices_cb(const void *value, void *d mask.foreach_index([&](int64_t i) { dst_[i] = value_; }); } -template<typename T> void fill_uninitialized_cb(const void *value, void *dst, int64_t n) +template<typename T> void fill_construct_cb(const void *value, void *dst, int64_t n) { const T &value_ = *static_cast<const T *>(value); T *dst_ = static_cast<T *>(dst); @@ -158,8 +155,7 @@ template<typename T> void fill_uninitialized_cb(const void *value, void *dst, in new (dst_ + i) T(value_); } } -template<typename T> -void fill_uninitialized_indices_cb(const void *value, void *dst, IndexMask mask) +template<typename T> void fill_construct_indices_cb(const void *value, void *dst, IndexMask mask) { const T &value_ = *static_cast<const T *>(value); T *dst_ = static_cast<T *>(dst); @@ -203,46 +199,46 @@ template<typename T> inline std::unique_ptr<const CPPType> create_cpp_type(Strin m.default_value = (void *)&default_value; m.is_trivially_destructible = std::is_trivially_destructible_v<T>; if constexpr (std::is_default_constructible_v<T>) { - m.construct_default = construct_default_cb<T>; - m.construct_default_indices = construct_default_indices_cb<T>; + m.default_construct = default_construct_cb<T>; + m.default_construct_indices = default_construct_indices_cb<T>; } if constexpr (std::is_destructible_v<T>) { m.destruct = destruct_cb<T>; m.destruct_indices = destruct_indices_cb<T>; } if constexpr (std::is_copy_assignable_v<T>) { - m.copy_to_initialized = copy_to_initialized_cb<T>; - m.copy_to_initialized_indices = copy_to_initialized_indices_cb<T>; + m.copy_assign = copy_assign_cb<T>; + m.copy_assign_indices = copy_assign_indices_cb<T>; } if constexpr (std::is_copy_constructible_v<T>) { - m.copy_to_uninitialized = copy_to_uninitialized_cb<T>; - m.copy_to_uninitialized_indices = copy_to_uninitialized_indices_cb<T>; + m.copy_construct = copy_construct_cb<T>; + m.copy_construct_indices = copy_construct_indices_cb<T>; } if constexpr (std::is_move_assignable_v<T>) { - m.move_to_initialized = move_to_initialized_cb<T>; - m.move_to_initialized_indices = move_to_initialized_indices_cb<T>; + m.move_assign = move_assign_cb<T>; + m.move_assign_indices = move_assign_indices_cb<T>; } if constexpr (std::is_move_constructible_v<T>) { - m.move_to_uninitialized = move_to_uninitialized_cb<T>; - m.move_to_uninitialized_indices = move_to_uninitialized_indices_cb<T>; + m.move_construct = move_construct_cb<T>; + m.move_construct_indices = move_construct_indices_cb<T>; } if constexpr (std::is_destructible_v<T>) { if constexpr (std::is_move_assignable_v<T>) { - m.relocate_to_initialized = relocate_to_initialized_cb<T>; - m.relocate_to_initialized_indices = relocate_to_initialized_indices_cb<T>; + m.relocate_assign = relocate_assign_cb<T>; + m.relocate_assign_indices = relocate_assign_indices_cb<T>; } if constexpr (std::is_move_constructible_v<T>) { - m.relocate_to_uninitialized = relocate_to_uninitialized_cb<T>; - m.relocate_to_uninitialized_indices = relocate_to_uninitialized_indices_cb<T>; + m.relocate_construct = relocate_construct_cb<T>; + m.relocate_construct_indices = relocate_construct_indices_cb<T>; } } if constexpr (std::is_copy_assignable_v<T>) { - m.fill_initialized = fill_initialized_cb<T>; - m.fill_initialized_indices = fill_initialized_indices_cb<T>; + m.fill_assign = fill_assign_cb<T>; + m.fill_assign_indices = fill_assign_indices_cb<T>; } if constexpr (std::is_copy_constructible_v<T>) { - m.fill_uninitialized = fill_uninitialized_cb<T>; - m.fill_uninitialized_indices = fill_uninitialized_indices_cb<T>; + m.fill_construct = fill_construct_cb<T>; + m.fill_construct_indices = fill_construct_indices_cb<T>; } m.debug_print = debug_print_cb<T>; m.is_equal = is_equal_cb<T>; diff --git a/source/blender/functions/FN_generic_pointer.hh b/source/blender/functions/FN_generic_pointer.hh index f88ff09f916..c65c42f26c9 100644 --- a/source/blender/functions/FN_generic_pointer.hh +++ b/source/blender/functions/FN_generic_pointer.hh @@ -70,7 +70,7 @@ class GMutablePointer { { BLI_assert(this->is_type<T>()); T value; - type_->relocate_to_initialized(data_, &value); + type_->relocate_assign(data_, &value); data_ = nullptr; type_ = nullptr; return value; diff --git a/source/blender/functions/FN_generic_value_map.hh b/source/blender/functions/FN_generic_value_map.hh index 4e7fe298874..33b827bf073 100644 --- a/source/blender/functions/FN_generic_value_map.hh +++ b/source/blender/functions/FN_generic_value_map.hh @@ -60,7 +60,7 @@ template<typename Key> class GValueMap { { const CPPType &type = *value.type(); void *buffer = allocator_.allocate(type.size(), type.alignment()); - type.move_to_uninitialized(value.get(), buffer); + type.move_construct(value.get(), buffer); values_.add_new_as(std::forward<ForwardKey>(key), GMutablePointer{type, buffer}); } @@ -70,7 +70,7 @@ template<typename Key> class GValueMap { { const CPPType &type = *value.type(); void *buffer = allocator_.allocate(type.size(), type.alignment()); - type.copy_to_uninitialized(value.get(), buffer); + type.copy_construct(value.get(), buffer); values_.add_new_as(std::forward<ForwardKey>(key), GMutablePointer{type, buffer}); } @@ -105,7 +105,7 @@ template<typename Key> class GValueMap { const CPPType &type = *value.type(); BLI_assert(type.is<T>()); T return_value; - type.relocate_to_initialized(value.get(), &return_value); + type.relocate_assign(value.get(), &return_value); return return_value; } diff --git a/source/blender/functions/FN_generic_vector_array.hh b/source/blender/functions/FN_generic_vector_array.hh index b02ed471875..eeba0c9dba2 100644 --- a/source/blender/functions/FN_generic_vector_array.hh +++ b/source/blender/functions/FN_generic_vector_array.hh @@ -154,7 +154,7 @@ class GVVectorArray_For_GVectorArray : public GVVectorArray { const int64_t index_in_vector, void *r_value) const override { - type_->copy_to_initialized(vector_array_[index][index_in_vector], r_value); + type_->copy_assign(vector_array_[index][index_in_vector], r_value); } }; diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh index 27c7a13029c..40dc585b39b 100644 --- a/source/blender/functions/FN_generic_virtual_array.hh +++ b/source/blender/functions/FN_generic_virtual_array.hh @@ -131,7 +131,7 @@ class GVArray { /* Same as `get_internal_single`, but `r_value` points to initialized memory. */ void get_single_to_uninitialized(void *r_value) const { - type_->construct_default(r_value); + type_->default_construct(r_value); this->get_internal_single(r_value); } diff --git a/source/blender/functions/intern/generic_vector_array.cc b/source/blender/functions/intern/generic_vector_array.cc index 3335b07e559..9556d24218e 100644 --- a/source/blender/functions/intern/generic_vector_array.cc +++ b/source/blender/functions/intern/generic_vector_array.cc @@ -43,7 +43,7 @@ void GVectorArray::append(const int64_t index, const void *value) } void *dst = POINTER_OFFSET(item.start, element_size_ * item.length); - type_.copy_to_uninitialized(value, dst); + type_.copy_construct(value, dst); item.length++; } @@ -95,7 +95,7 @@ void GVectorArray::realloc_to_at_least(Item &item, int64_t min_capacity) const int64_t new_capacity = std::max(min_capacity, item.length * 2); void *new_buffer = allocator_.allocate(element_size_ * new_capacity, type_.alignment()); - type_.relocate_to_initialized_n(item.start, new_buffer, item.length); + type_.relocate_assign_n(item.start, new_buffer, item.length); item.start = new_buffer; item.capacity = new_capacity; diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc index 87dae06ccdc..b25daf40568 100644 --- a/source/blender/functions/intern/generic_virtual_array.cc +++ b/source/blender/functions/intern/generic_virtual_array.cc @@ -149,7 +149,7 @@ GVArrayPtr GVArray::shallow_copy() const void GVMutableArray::set_by_copy_impl(const int64_t index, const void *value) { BUFFER_FOR_CPP_TYPE_VALUE(*type_, buffer); - type_->copy_to_uninitialized(value, buffer); + type_->copy_construct(value, buffer); this->set_by_move_impl(index, buffer); type_->destruct(buffer); } @@ -164,7 +164,7 @@ void GVMutableArray::set_all_impl(const void *src) { if (this->is_span()) { const GMutableSpan span = this->get_internal_span(); - type_->copy_to_initialized_n(src, span.data(), size_); + type_->copy_assign_n(src, span.data(), size_); } else { for (int64_t i : IndexRange(size_)) { @@ -182,7 +182,7 @@ void GVMutableArray::fill(const void *value) { if (this->is_span()) { const GMutableSpan span = this->get_internal_span(); - type_->fill_initialized(value, span.data(), size_); + type_->fill_assign(value, span.data(), size_); } else { for (int64_t i : IndexRange(size_)) { @@ -197,12 +197,12 @@ void GVMutableArray::fill(const void *value) void GVArray_For_GSpan::get_impl(const int64_t index, void *r_value) const { - type_->copy_to_initialized(POINTER_OFFSET(data_, element_size_ * index), r_value); + type_->copy_assign(POINTER_OFFSET(data_, element_size_ * index), r_value); } void GVArray_For_GSpan::get_to_uninitialized_impl(const int64_t index, void *r_value) const { - type_->copy_to_uninitialized(POINTER_OFFSET(data_, element_size_ * index), r_value); + type_->copy_construct(POINTER_OFFSET(data_, element_size_ * index), r_value); } bool GVArray_For_GSpan::is_span_impl() const @@ -221,28 +221,28 @@ GSpan GVArray_For_GSpan::get_internal_span_impl() const void GVMutableArray_For_GMutableSpan::get_impl(const int64_t index, void *r_value) const { - type_->copy_to_initialized(POINTER_OFFSET(data_, element_size_ * index), r_value); + type_->copy_assign(POINTER_OFFSET(data_, element_size_ * index), r_value); } void GVMutableArray_For_GMutableSpan::get_to_uninitialized_impl(const int64_t index, void *r_value) const { - type_->copy_to_uninitialized(POINTER_OFFSET(data_, element_size_ * index), r_value); + type_->copy_construct(POINTER_OFFSET(data_, element_size_ * index), r_value); } void GVMutableArray_For_GMutableSpan::set_by_copy_impl(const int64_t index, const void *value) { - type_->copy_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index)); + type_->copy_assign(value, POINTER_OFFSET(data_, element_size_ * index)); } void GVMutableArray_For_GMutableSpan::set_by_move_impl(const int64_t index, void *value) { - type_->move_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index)); + type_->move_construct(value, POINTER_OFFSET(data_, element_size_ * index)); } void GVMutableArray_For_GMutableSpan::set_by_relocate_impl(const int64_t index, void *value) { - type_->relocate_to_initialized(value, POINTER_OFFSET(data_, element_size_ * index)); + type_->relocate_assign(value, POINTER_OFFSET(data_, element_size_ * index)); } bool GVMutableArray_For_GMutableSpan::is_span_impl() const @@ -261,13 +261,13 @@ GSpan GVMutableArray_For_GMutableSpan::get_internal_span_impl() const void GVArray_For_SingleValueRef::get_impl(const int64_t UNUSED(index), void *r_value) const { - type_->copy_to_initialized(value_, r_value); + type_->copy_assign(value_, r_value); } void GVArray_For_SingleValueRef::get_to_uninitialized_impl(const int64_t UNUSED(index), void *r_value) const { - type_->copy_to_uninitialized(value_, r_value); + type_->copy_construct(value_, r_value); } bool GVArray_For_SingleValueRef::is_span_impl() const @@ -287,7 +287,7 @@ bool GVArray_For_SingleValueRef::is_single_impl() const void GVArray_For_SingleValueRef::get_internal_single_impl(void *r_value) const { - type_->copy_to_initialized(value_, r_value); + type_->copy_assign(value_, r_value); } /* -------------------------------------------------------------------- @@ -300,7 +300,7 @@ GVArray_For_SingleValue::GVArray_For_SingleValue(const CPPType &type, : GVArray_For_SingleValueRef(type, size) { value_ = MEM_mallocN_aligned(type.size(), type.alignment(), __func__); - type.copy_to_uninitialized(value, (void *)value_); + type.copy_construct(value, (void *)value_); } GVArray_For_SingleValue::~GVArray_For_SingleValue() @@ -351,7 +351,7 @@ GVMutableArray_GSpan::GVMutableArray_GSpan(GVMutableArray &varray, const bool co varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_); } else { - type_->construct_default_n(owned_data_, size_); + type_->default_construct_n(owned_data_, size_); } data_ = owned_data_; } diff --git a/source/blender/functions/intern/generic_virtual_vector_array.cc b/source/blender/functions/intern/generic_virtual_vector_array.cc index aa3d90883c6..6b90ce993ae 100644 --- a/source/blender/functions/intern/generic_virtual_vector_array.cc +++ b/source/blender/functions/intern/generic_virtual_vector_array.cc @@ -26,7 +26,7 @@ void GVArray_For_GVVectorArrayIndex::get_impl(const int64_t index_in_vector, voi void GVArray_For_GVVectorArrayIndex::get_to_uninitialized_impl(const int64_t index_in_vector, void *r_value) const { - type_->construct_default(r_value); + type_->default_construct(r_value); vector_array_.get_vector_element(index_, index_in_vector, r_value); } @@ -56,7 +56,7 @@ void GVVectorArray_For_SingleGSpan::get_vector_element_impl(const int64_t UNUSED const int64_t index_in_vector, void *r_value) const { - type_->copy_to_initialized(span_[index_in_vector], r_value); + type_->copy_assign(span_[index_in_vector], r_value); } bool GVVectorArray_For_SingleGSpan::is_single_vector_impl() const diff --git a/source/blender/functions/intern/multi_function_builder.cc b/source/blender/functions/intern/multi_function_builder.cc index 3567f4f9167..6961935dc0c 100644 --- a/source/blender/functions/intern/multi_function_builder.cc +++ b/source/blender/functions/intern/multi_function_builder.cc @@ -36,7 +36,7 @@ void CustomMF_GenericConstant::call(IndexMask mask, MFContext UNUSED(context)) const { GMutableSpan output = params.uninitialized_single_output(0); - type_.fill_uninitialized_indices(value_, output.data(), mask); + type_.fill_construct_indices(value_, output.data(), mask); } uint64_t CustomMF_GenericConstant::hash() const @@ -117,7 +117,7 @@ void CustomMF_DefaultOutput::call(IndexMask mask, MFParams params, MFContext UNU if (param_type.data_type().is_single()) { GMutableSpan span = params.uninitialized_single_output(param_index); const CPPType &type = span.type(); - type.fill_uninitialized_indices(type.default_value(), span.data(), mask); + type.fill_construct_indices(type.default_value(), span.data(), mask); } } } diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 5daecef1946..d776adeff75 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -714,7 +714,7 @@ static void initialize_group_input(NodesModifierData &nmd, { const SocketPropertyType *property_type = get_socket_property_type(socket); if (property_type == nullptr) { - cpp_type.copy_to_uninitialized(cpp_type.default_value(), r_value); + cpp_type.copy_construct(cpp_type.default_value(), r_value); return; } if (nmd.settings.properties == nullptr) { diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index 448abe6b5fe..8314a443ba6 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -896,7 +896,7 @@ class GeometryNodesEvaluator { OutputState &output_state = node_state.outputs[socket->index()]; output_state.has_been_computed = true; void *buffer = allocator.allocate(type->size(), type->alignment()); - type->copy_to_uninitialized(type->default_value(), buffer); + type->copy_construct(type->default_value(), buffer); this->forward_output({node.context(), socket}, {*type, buffer}); } } @@ -975,7 +975,7 @@ class GeometryNodesEvaluator { /* Move value into memory owned by the outer allocator. */ const CPPType &type = *input_state.type; void *buffer = outer_allocator_.allocate(type.size(), type.alignment()); - type.move_to_uninitialized(value, buffer); + type.move_construct(value, buffer); params_.r_output_values.append({type, buffer}); } @@ -1212,7 +1212,7 @@ class GeometryNodesEvaluator { } else { /* Cannot convert, use default value instead. */ - to_type.copy_to_uninitialized(to_type.default_value(), buffer); + to_type.copy_construct(to_type.default_value(), buffer); } this->add_value_to_input_socket(to_socket, from_socket, {to_type, buffer}); } @@ -1238,7 +1238,7 @@ class GeometryNodesEvaluator { const CPPType &type = *value_to_forward.type(); for (const DInputSocket &to_socket : to_sockets.drop_front(1)) { void *buffer = allocator.allocate(type.size(), type.alignment()); - type.copy_to_uninitialized(value_to_forward.get(), buffer); + type.copy_construct(value_to_forward.get(), buffer); this->add_value_to_input_socket(to_socket, from_socket, {type, buffer}); } /* Forward the original value to one of the targets. */ @@ -1339,7 +1339,7 @@ class GeometryNodesEvaluator { } /* Use a default fallback value when the loaded type is not compatible. */ void *default_buffer = allocator.allocate(required_type.size(), required_type.alignment()); - required_type.copy_to_uninitialized(required_type.default_value(), default_buffer); + required_type.copy_construct(required_type.default_value(), default_buffer); return {required_type, default_buffer}; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc index 7b40456b180..60b5b91db19 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc @@ -130,7 +130,7 @@ static void attribute_convert_calc(GeometryComponent &component, const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(result_type); BLI_assert(cpp_type != nullptr); - cpp_type->copy_to_initialized_n(source_span.data(), result_span.data(), result_span.size()); + cpp_type->copy_assign_n(source_span.data(), result_span.data(), result_span.size()); result_attribute.save(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 2725c625913..1e1533e48cf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -298,7 +298,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component, if (size != 0) { BUFFER_FOR_CPP_TYPE_VALUE(type, buffer); spline_attribute->get(i, buffer); - type.fill_initialized(buffer, result[offset], size); + type.fill_assign(buffer, result[offset], size); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc index bc758b59987..2f6d3ef0d6c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc @@ -208,7 +208,7 @@ static void fill_new_attribute(Span<const GeometryComponent *> src_components, GVArray_GSpan src_span{*read_attribute}; const void *src_buffer = src_span.data(); void *dst_buffer = dst_span[offset]; - cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size); + cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size); offset += domain_size; } @@ -353,7 +353,7 @@ static void ensure_control_point_attribute(const StringRef name, BUFFER_FOR_CPP_TYPE_VALUE(type, buffer); current_curve_attribute->get(spline_index_in_component, buffer); - type.fill_initialized(buffer, new_attribute->data(), new_attribute->size()); + type.fill_assign(buffer, new_attribute->data(), new_attribute->size()); } } @@ -392,7 +392,7 @@ static void ensure_spline_attribute(const StringRef name, GVArray_GSpan src_span{*read_attribute}; const void *src_buffer = src_span.data(); - type.copy_to_initialized_n(src_buffer, result_attribute[offset], size); + type.copy_assign_n(src_buffer, result_attribute[offset], size); offset += size; } diff --git a/source/blender/nodes/intern/type_conversions.cc b/source/blender/nodes/intern/type_conversions.cc index 220e5ea9046..1a71a3418a5 100644 --- a/source/blender/nodes/intern/type_conversions.cc +++ b/source/blender/nodes/intern/type_conversions.cc @@ -231,7 +231,7 @@ void DataTypeConversions::convert_to_uninitialized(const CPPType &from_type, void *to_value) const { if (from_type == to_type) { - from_type.copy_to_uninitialized(from_value, to_value); + from_type.copy_construct(from_value, to_value); return; } |