From 8cbbdedaf4dfec9e320e7e2be58b75d256950df1 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 20 Jul 2020 12:16:20 +0200 Subject: 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. --- source/blender/functions/FN_multi_function_builder.hh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/blender/functions/FN_multi_function_builder.hh') diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index c2c95f7c355..95e216558e7 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -59,7 +59,7 @@ template class CustomMF_SI_SO : public MultiFunctio template static FunctionT create_function(ElementFuncT element_fn) { return [=](IndexMask mask, VSpan in1, MutableSpan out1) { - mask.foreach_index([&](uint i) { new ((void *)&out1[i]) Out1(element_fn(in1[i])); }); + mask.foreach_index([&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i])); }); }; } @@ -101,7 +101,7 @@ class CustomMF_SI_SI_SO : public MultiFunction { template static FunctionT create_function(ElementFuncT element_fn) { return [=](IndexMask mask, VSpan in1, VSpan in2, MutableSpan out1) { - mask.foreach_index([&](uint i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i])); }); + mask.foreach_index([&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i])); }); }; } @@ -152,7 +152,7 @@ class CustomMF_SI_SI_SI_SO : public MultiFunction { VSpan in3, MutableSpan out1) { mask.foreach_index( - [&](uint i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i], in3[i])); }); + [&](int i) { new ((void *)&out1[i]) Out1(element_fn(in1[i], in2[i], in3[i])); }); }; } @@ -191,7 +191,7 @@ template class CustomMF_SM : public MultiFunction { template static FunctionT create_function(ElementFuncT element_fn) { return [=](IndexMask mask, MutableSpan mut1) { - mask.foreach_index([&](uint i) { element_fn(mut1[i]); }); + mask.foreach_index([&](int i) { element_fn(mut1[i]); }); }; } @@ -220,7 +220,7 @@ template class CustomMF_Convert : public MultiFuncti VSpan inputs = params.readonly_single_input(0); MutableSpan outputs = params.uninitialized_single_output(1); - for (uint i : mask) { + for (int64_t i : mask) { new ((void *)&outputs[i]) To(inputs[i]); } } @@ -240,7 +240,7 @@ class CustomMF_GenericConstant : public MultiFunction { public: CustomMF_GenericConstant(const CPPType &type, const void *value); void call(IndexMask mask, MFParams params, MFContext context) const override; - uint32_t hash() const override; + uint64_t hash() const override; bool equals(const MultiFunction &other) const override; }; @@ -276,10 +276,10 @@ template class CustomMF_Constant : public MultiFunction { void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override { MutableSpan output = params.uninitialized_single_output(0); - mask.foreach_index([&](uint i) { new (&output[i]) T(value_); }); + mask.foreach_index([&](int i) { new (&output[i]) T(value_); }); } - uint32_t hash() const override + uint64_t hash() const override { return DefaultHash{}(value_); } @@ -304,7 +304,7 @@ template class CustomMF_Constant : public MultiFunction { class CustomMF_DefaultOutput : public MultiFunction { private: - uint output_amount_; + int output_amount_; public: CustomMF_DefaultOutput(StringRef name, -- cgit v1.2.3