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:
authorJacques Lucke <jacques@blender.org>2020-07-20 13:16:20 +0300
committerJacques Lucke <jacques@blender.org>2020-07-20 13:16:20 +0300
commit8cbbdedaf4dfec9e320e7e2be58b75d256950df1 (patch)
tree496b9620e11ac44e515b0bb4ca52c05834d557f9 /source/blender/functions/FN_attributes_ref.hh
parent686ab4c9401a90b22fb17e46c992eb513fe4f693 (diff)
Refactor: Update integer type usage
This updates the usage of integer types in code I wrote according to our new style guides. Major changes: * Use signed instead of unsigned integers in many places. * C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`). * Hash values for C++ containers are 64 bit wide now (instead of 32 bit). I do hope that I broke no builds, but it is quite likely that some compiler reports slightly different errors. Please let me know when there are any errors. If the fix is small, feel free to commit it yourself. I compiled successfully on linux with gcc and on windows.
Diffstat (limited to 'source/blender/functions/FN_attributes_ref.hh')
-rw-r--r--source/blender/functions/FN_attributes_ref.hh52
1 files changed, 26 insertions, 26 deletions
diff --git a/source/blender/functions/FN_attributes_ref.hh b/source/blender/functions/FN_attributes_ref.hh
index cf5ef2af8a6..2af35317827 100644
--- a/source/blender/functions/FN_attributes_ref.hh
+++ b/source/blender/functions/FN_attributes_ref.hh
@@ -65,7 +65,7 @@ class AttributesInfoBuilder : NonCopyable, NonMovable {
class AttributesInfo : NonCopyable, NonMovable {
private:
LinearAllocator<> allocator_;
- Map<StringRefNull, uint> index_by_name_;
+ Map<StringRefNull, int> index_by_name_;
Vector<StringRefNull> name_by_index_;
Vector<const CPPType *> type_by_index_;
Vector<void *> defaults_;
@@ -75,7 +75,7 @@ class AttributesInfo : NonCopyable, NonMovable {
AttributesInfo(const AttributesInfoBuilder &builder);
~AttributesInfo();
- uint size() const
+ int size() const
{
return name_by_index_.size();
}
@@ -85,17 +85,17 @@ class AttributesInfo : NonCopyable, NonMovable {
return name_by_index_.index_range();
}
- StringRefNull name_of(uint index) const
+ StringRefNull name_of(int index) const
{
return name_by_index_[index];
}
- uint index_of(StringRef name) const
+ int index_of(StringRef name) const
{
return index_by_name_.lookup_as(name);
}
- const void *default_of(uint index) const
+ const void *default_of(int index) const
{
return defaults_[index];
}
@@ -105,7 +105,7 @@ class AttributesInfo : NonCopyable, NonMovable {
return this->default_of(this->index_of(name));
}
- template<typename T> const T &default_of(uint index) const
+ template<typename T> const T &default_of(int index) const
{
BLI_assert(type_by_index_[index]->is<T>());
return *(T *)defaults_[index];
@@ -116,7 +116,7 @@ class AttributesInfo : NonCopyable, NonMovable {
return this->default_of<T>(this->index_of(name));
}
- const CPPType &type_of(uint index) const
+ const CPPType &type_of(int index) const
{
return *type_by_index_[index];
}
@@ -133,7 +133,7 @@ class AttributesInfo : NonCopyable, NonMovable {
int try_index_of(StringRef name) const
{
- return (int)index_by_name_.lookup_default_as(name, -1);
+ return index_by_name_.lookup_default_as(name, -1);
}
int try_index_of(StringRef name, const CPPType &type) const
@@ -142,7 +142,7 @@ class AttributesInfo : NonCopyable, NonMovable {
if (index == -1) {
return -1;
}
- else if (this->type_of((uint)index) == type) {
+ else if (this->type_of(index) == type) {
return index;
}
else {
@@ -164,7 +164,7 @@ class MutableAttributesRef {
friend class AttributesRef;
public:
- MutableAttributesRef(const AttributesInfo &info, Span<void *> buffers, uint size)
+ MutableAttributesRef(const AttributesInfo &info, Span<void *> buffers, int64_t size)
: MutableAttributesRef(info, buffers, IndexRange(size))
{
}
@@ -174,7 +174,7 @@ class MutableAttributesRef {
{
}
- uint size() const
+ int64_t size() const
{
return range_.size();
}
@@ -184,7 +184,7 @@ class MutableAttributesRef {
return *info_;
}
- GMutableSpan get(uint index) const
+ GMutableSpan get(int index) const
{
const CPPType &type = info_->type_of(index);
void *ptr = POINTER_OFFSET(buffers_[index], type.size() * range_.start());
@@ -196,7 +196,7 @@ class MutableAttributesRef {
return this->get(info_->index_of(name));
}
- template<typename T> MutableSpan<T> get(uint index) const
+ template<typename T> MutableSpan<T> get(int index) const
{
BLI_assert(info_->type_of(index).is<T>());
return MutableSpan<T>((T *)buffers_[index] + range_.start(), range_.size());
@@ -214,7 +214,7 @@ class MutableAttributesRef {
return {};
}
else {
- return this->get((uint)index);
+ return this->get(index);
}
}
@@ -224,8 +224,8 @@ class MutableAttributesRef {
if (index == -1) {
return {};
}
- else if (info_->type_of((uint)index).is<T>()) {
- return this->get<T>((uint)index);
+ else if (info_->type_of(index).is<T>()) {
+ return this->get<T>(index);
}
else {
return {};
@@ -237,7 +237,7 @@ class MutableAttributesRef {
return this->slice(range.start(), range.size());
}
- MutableAttributesRef slice(uint start, uint size) const
+ MutableAttributesRef slice(int64_t start, int64_t size) const
{
return MutableAttributesRef(*info_, buffers_, range_.slice(start, size));
}
@@ -250,7 +250,7 @@ class AttributesRef {
IndexRange range_;
public:
- AttributesRef(const AttributesInfo &info, Span<const void *> buffers, uint size)
+ AttributesRef(const AttributesInfo &info, Span<const void *> buffers, int64_t size)
: AttributesRef(info, buffers, IndexRange(size))
{
}
@@ -265,7 +265,7 @@ class AttributesRef {
{
}
- uint size() const
+ int64_t size() const
{
return range_.size();
}
@@ -275,7 +275,7 @@ class AttributesRef {
return *info_;
}
- GSpan get(uint index) const
+ GSpan get(int index) const
{
const CPPType &type = info_->type_of(index);
const void *ptr = POINTER_OFFSET(buffers_[index], type.size() * range_.start());
@@ -287,7 +287,7 @@ class AttributesRef {
return this->get(info_->index_of(name));
}
- template<typename T> Span<T> get(uint index) const
+ template<typename T> Span<T> get(int index) const
{
BLI_assert(info_->type_of(index).is<T>());
return Span<T>((T *)buffers_[index] + range_.start(), range_.size());
@@ -300,12 +300,12 @@ class AttributesRef {
std::optional<GSpan> try_get(StringRef name, const CPPType &type) const
{
- int index = info_->try_index_of(name, type);
+ int64_t index = info_->try_index_of(name, type);
if (index == -1) {
return {};
}
else {
- return this->get((uint)index);
+ return this->get(index);
}
}
@@ -315,8 +315,8 @@ class AttributesRef {
if (index == -1) {
return {};
}
- else if (info_->type_of((uint)index).is<T>()) {
- return this->get<T>((uint)index);
+ else if (info_->type_of(index).is<T>()) {
+ return this->get<T>(index);
}
else {
return {};
@@ -328,7 +328,7 @@ class AttributesRef {
return this->slice(range.start(), range.size());
}
- AttributesRef slice(uint start, uint size) const
+ AttributesRef slice(int64_t start, int64_t size) const
{
return AttributesRef(*info_, buffers_, range_.slice(start, size));
}