diff options
Diffstat (limited to 'source/blender/functions/FN_spans.hh')
-rw-r--r-- | source/blender/functions/FN_spans.hh | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/source/blender/functions/FN_spans.hh b/source/blender/functions/FN_spans.hh index b4607527fb5..0bb5ea7938d 100644 --- a/source/blender/functions/FN_spans.hh +++ b/source/blender/functions/FN_spans.hh @@ -51,13 +51,13 @@ namespace fn { */ class GSpan { private: - const CPPType *m_type; - const void *m_buffer; - uint m_size; + const CPPType *type_; + const void *buffer_; + uint size_; public: GSpan(const CPPType &type, const void *buffer, uint size) - : m_type(&type), m_buffer(buffer), m_size(size) + : type_(&type), buffer_(buffer), size_(size) { BLI_assert(buffer != nullptr || size == 0); BLI_assert(type.pointer_has_valid_alignment(buffer)); @@ -74,34 +74,34 @@ class GSpan { const CPPType &type() const { - return *m_type; + return *type_; } bool is_empty() const { - return m_size == 0; + return size_ == 0; } uint size() const { - return m_size; + return size_; } const void *buffer() const { - return m_buffer; + return buffer_; } const void *operator[](uint index) const { - BLI_assert(index < m_size); - return POINTER_OFFSET(m_buffer, m_type->size() * index); + BLI_assert(index < size_); + return POINTER_OFFSET(buffer_, type_->size() * index); } template<typename T> Span<T> typed() const { - BLI_assert(m_type->is<T>()); - return Span<T>((const T *)m_buffer, m_size); + BLI_assert(type_->is<T>()); + return Span<T>((const T *)buffer_, size_); } }; @@ -111,13 +111,13 @@ class GSpan { */ class GMutableSpan { private: - const CPPType *m_type; - void *m_buffer; - uint m_size; + const CPPType *type_; + void *buffer_; + uint size_; public: GMutableSpan(const CPPType &type, void *buffer, uint size) - : m_type(&type), m_buffer(buffer), m_size(size) + : type_(&type), buffer_(buffer), size_(size) { BLI_assert(buffer != nullptr || size == 0); BLI_assert(type.pointer_has_valid_alignment(buffer)); @@ -135,39 +135,39 @@ class GMutableSpan { operator GSpan() const { - return GSpan(*m_type, m_buffer, m_size); + return GSpan(*type_, buffer_, size_); } const CPPType &type() const { - return *m_type; + return *type_; } bool is_empty() const { - return m_size == 0; + return size_ == 0; } uint size() const { - return m_size; + return size_; } void *buffer() { - return m_buffer; + return buffer_; } void *operator[](uint index) { - BLI_assert(index < m_size); - return POINTER_OFFSET(m_buffer, m_type->size() * index); + BLI_assert(index < size_); + return POINTER_OFFSET(buffer_, type_->size() * index); } template<typename T> MutableSpan<T> typed() { - BLI_assert(m_type->is<T>()); - return MutableSpan<T>((T *)m_buffer, m_size); + BLI_assert(type_->is<T>()); + return MutableSpan<T>((T *)buffer_, size_); } }; @@ -179,8 +179,8 @@ enum class VSpanCategory { template<typename T> struct VSpanBase { protected: - uint m_virtual_size; - VSpanCategory m_category; + uint virtual_size_; + VSpanCategory category_; union { struct { const T *data; @@ -191,18 +191,18 @@ template<typename T> struct VSpanBase { struct { const T *const *data; } full_pointer_array; - } m_data; + } data_; public: bool is_single_element() const { - switch (m_category) { + switch (category_) { case VSpanCategory::Single: return true; case VSpanCategory::FullArray: - return m_virtual_size == 1; + return virtual_size_ == 1; case VSpanCategory::FullPointerArray: - return m_virtual_size == 1; + return virtual_size_ == 1; } BLI_assert(false); return false; @@ -210,12 +210,12 @@ template<typename T> struct VSpanBase { bool is_empty() const { - return this->m_virtual_size == 0; + return this->virtual_size_ == 0; } uint size() const { - return this->m_virtual_size; + return this->virtual_size_; } }; @@ -237,16 +237,16 @@ template<typename T> class VSpan : public VSpanBase<T> { public: VSpan() { - this->m_virtual_size = 0; - this->m_category = VSpanCategory::FullArray; - this->m_data.full_array.data = nullptr; + this->virtual_size_ = 0; + this->category_ = VSpanCategory::FullArray; + this->data_.full_array.data = nullptr; } VSpan(Span<T> values) { - this->m_virtual_size = values.size(); - this->m_category = VSpanCategory::FullArray; - this->m_data.full_array.data = values.begin(); + this->virtual_size_ = values.size(); + this->category_ = VSpanCategory::FullArray; + this->data_.full_array.data = values.begin(); } VSpan(MutableSpan<T> values) : VSpan(Span<T>(values)) @@ -255,33 +255,33 @@ template<typename T> class VSpan : public VSpanBase<T> { VSpan(Span<const T *> values) { - this->m_virtual_size = values.size(); - this->m_category = VSpanCategory::FullPointerArray; - this->m_data.full_pointer_array.data = values.begin(); + this->virtual_size_ = values.size(); + this->category_ = VSpanCategory::FullPointerArray; + this->data_.full_pointer_array.data = values.begin(); } static VSpan FromSingle(const T *value, uint virtual_size) { VSpan ref; - ref.m_virtual_size = virtual_size; - ref.m_category = VSpanCategory::Single; - ref.m_data.single.data = value; + ref.virtual_size_ = virtual_size; + ref.category_ = VSpanCategory::Single; + ref.data_.single.data = value; return ref; } const T &operator[](uint index) const { - BLI_assert(index < this->m_virtual_size); - switch (this->m_category) { + BLI_assert(index < this->virtual_size_); + switch (this->category_) { case VSpanCategory::Single: - return *this->m_data.single.data; + return *this->data_.single.data; case VSpanCategory::FullArray: - return this->m_data.full_array.data[index]; + return this->data_.full_array.data[index]; case VSpanCategory::FullPointerArray: - return *this->m_data.full_pointer_array.data[index]; + return *this->data_.full_pointer_array.data[index]; } BLI_assert(false); - return *this->m_data.single.data; + return *this->data_.single.data; } }; @@ -291,25 +291,25 @@ template<typename T> class VSpan : public VSpanBase<T> { */ class GVSpan : public VSpanBase<void> { private: - const CPPType *m_type; + const CPPType *type_; GVSpan() = default; public: GVSpan(const CPPType &type) { - this->m_type = &type; - this->m_virtual_size = 0; - this->m_category = VSpanCategory::FullArray; - this->m_data.full_array.data = nullptr; + this->type_ = &type; + this->virtual_size_ = 0; + this->category_ = VSpanCategory::FullArray; + this->data_.full_array.data = nullptr; } GVSpan(GSpan values) { - this->m_type = &values.type(); - this->m_virtual_size = values.size(); - this->m_category = VSpanCategory::FullArray; - this->m_data.full_array.data = values.buffer(); + this->type_ = &values.type(); + this->virtual_size_ = values.size(); + this->category_ = VSpanCategory::FullArray; + this->data_.full_array.data = values.buffer(); } GVSpan(GMutableSpan values) : GVSpan(GSpan(values)) @@ -318,7 +318,7 @@ class GVSpan : public VSpanBase<void> { template<typename T> GVSpan(const VSpanBase<T> &values) { - this->m_type = &CPPType::get<T>(); + this->type_ = &CPPType::get<T>(); memcpy(this, &values, sizeof(VSpanBase<void>)); } @@ -333,46 +333,46 @@ class GVSpan : public VSpanBase<void> { static GVSpan FromSingle(const CPPType &type, const void *value, uint virtual_size) { GVSpan ref; - ref.m_type = &type; - ref.m_virtual_size = virtual_size; - ref.m_category = VSpanCategory::Single; - ref.m_data.single.data = value; + ref.type_ = &type; + ref.virtual_size_ = virtual_size; + ref.category_ = VSpanCategory::Single; + ref.data_.single.data = value; return ref; } static GVSpan FromFullPointerArray(const CPPType &type, const void *const *values, uint size) { GVSpan ref; - ref.m_type = &type; - ref.m_virtual_size = size; - ref.m_category = VSpanCategory::FullPointerArray; - ref.m_data.full_pointer_array.data = values; + ref.type_ = &type; + ref.virtual_size_ = size; + ref.category_ = VSpanCategory::FullPointerArray; + ref.data_.full_pointer_array.data = values; return ref; } const CPPType &type() const { - return *this->m_type; + return *this->type_; } const void *operator[](uint index) const { - BLI_assert(index < this->m_virtual_size); - switch (this->m_category) { + BLI_assert(index < this->virtual_size_); + switch (this->category_) { case VSpanCategory::Single: - return this->m_data.single.data; + return this->data_.single.data; case VSpanCategory::FullArray: - return POINTER_OFFSET(this->m_data.full_array.data, index * m_type->size()); + return POINTER_OFFSET(this->data_.full_array.data, index * type_->size()); case VSpanCategory::FullPointerArray: - return this->m_data.full_pointer_array.data[index]; + return this->data_.full_pointer_array.data[index]; } BLI_assert(false); - return this->m_data.single.data; + return this->data_.single.data; } template<typename T> VSpan<T> typed() const { - BLI_assert(m_type->is<T>()); + BLI_assert(type_->is<T>()); return VSpan<T>(*this); } @@ -384,16 +384,16 @@ class GVSpan : public VSpanBase<void> { void materialize_to_uninitialized(void *dst) const { - this->materialize_to_uninitialized(IndexRange(m_virtual_size), dst); + this->materialize_to_uninitialized(IndexRange(virtual_size_), dst); } void materialize_to_uninitialized(IndexMask mask, void *dst) const { BLI_assert(this->size() >= mask.min_array_size()); - uint element_size = m_type->size(); + uint element_size = type_->size(); for (uint i : mask) { - m_type->copy_to_uninitialized((*this)[i], POINTER_OFFSET(dst, element_size * i)); + type_->copy_to_uninitialized((*this)[i], POINTER_OFFSET(dst, element_size * i)); } } }; |