Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/functions/FN_array_spans.hh')
-rw-r--r--source/blender/functions/FN_array_spans.hh29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/functions/FN_array_spans.hh b/source/blender/functions/FN_array_spans.hh
index 3f71b36c49c..976b9a44d3e 100644
--- a/source/blender/functions/FN_array_spans.hh
+++ b/source/blender/functions/FN_array_spans.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FN_ARRAY_SPANS_HH__
-#define __FN_ARRAY_SPANS_HH__
+#pragma once
/** \file
* \ingroup fn
@@ -39,17 +38,17 @@ enum class VArraySpanCategory {
template<typename T> class VArraySpanBase {
protected:
- uint virtual_size_;
+ int64_t virtual_size_;
VArraySpanCategory category_;
union {
struct {
const T *start;
- uint size;
+ int64_t size;
} single_array;
struct {
const T *const *starts;
- const uint *sizes;
+ const int64_t *sizes;
} starts_and_sizes;
} data_;
@@ -71,7 +70,7 @@ template<typename T> class VArraySpanBase {
return this->virtual_size_ == 0;
}
- uint size() const
+ int64_t size() const
{
return this->virtual_size_;
}
@@ -99,15 +98,16 @@ template<typename T> class VArraySpan : public VArraySpanBase<T> {
this->data_.starts_and_sizes.sizes = nullptr;
}
- VArraySpan(Span<T> span, uint virtual_size)
+ VArraySpan(Span<T> span, int64_t virtual_size)
{
+ BLI_assert(virtual_size >= 0);
this->virtual_size_ = virtual_size;
this->category_ = VArraySpanCategory::SingleArray;
this->data_.single_array.start = span.data();
this->data_.single_array.size = span.size();
}
- VArraySpan(Span<const T *> starts, Span<uint> sizes)
+ VArraySpan(Span<const T *> starts, Span<int64_t> sizes)
{
BLI_assert(starts.size() == sizes.size());
this->virtual_size_ = starts.size();
@@ -116,8 +116,9 @@ template<typename T> class VArraySpan : public VArraySpanBase<T> {
this->data_.starts_and_sizes.sizes = sizes.begin();
}
- VSpan<T> operator[](uint index) const
+ VSpan<T> operator[](int64_t index) const
{
+ BLI_assert(index >= 0);
BLI_assert(index < this->virtual_size_);
switch (this->category_) {
case VArraySpanCategory::SingleArray:
@@ -151,16 +152,16 @@ class GVArraySpan : public VArraySpanBase<void> {
this->data_.starts_and_sizes.sizes = nullptr;
}
- GVArraySpan(GSpan array, uint virtual_size)
+ GVArraySpan(GSpan array, int64_t virtual_size)
{
this->type_ = &array.type();
this->virtual_size_ = virtual_size;
this->category_ = VArraySpanCategory::SingleArray;
- this->data_.single_array.start = array.buffer();
+ this->data_.single_array.start = array.data();
this->data_.single_array.size = array.size();
}
- GVArraySpan(const CPPType &type, Span<const void *> starts, Span<uint> sizes)
+ GVArraySpan(const CPPType &type, Span<const void *> starts, Span<int64_t> sizes)
{
BLI_assert(starts.size() == sizes.size());
this->type_ = &type;
@@ -187,7 +188,7 @@ class GVArraySpan : public VArraySpanBase<void> {
return VArraySpan<T>(*this);
}
- GVSpan operator[](uint index) const
+ GVSpan operator[](int64_t index) const
{
BLI_assert(index < virtual_size_);
switch (category_) {
@@ -203,5 +204,3 @@ class GVArraySpan : public VArraySpanBase<void> {
};
} // namespace blender::fn
-
-#endif /* __FN_ARRAY_SPANS_HH__ */