Cleanup: Replace MIN/MAX macros with C++ functions
Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2 just for C code that hasn't been moved to C++ yet. Pull Request: https://projects.blender.org/blender/blender/pulls/117384
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
* \ingroup pymathutils
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "mathutils.h"
|
||||
@@ -431,7 +433,7 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end)
|
||||
end = (COLOR_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, COLOR_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
tuple = PyTuple_New(end - begin);
|
||||
for (count = begin; count < end; count++) {
|
||||
@@ -456,7 +458,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq)
|
||||
end = (COLOR_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, COLOR_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) ==
|
||||
-1)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup pymathutils
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "mathutils.h"
|
||||
@@ -517,7 +519,7 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end)
|
||||
end = (EULER_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, EULER_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
tuple = PyTuple_New(end - begin);
|
||||
for (count = begin; count < end; count++) {
|
||||
@@ -542,7 +544,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq)
|
||||
end = (EULER_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, EULER_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) ==
|
||||
-1)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup pymathutils
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "mathutils.h"
|
||||
@@ -2508,7 +2510,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end)
|
||||
|
||||
CLAMP(begin, 0, self->row_num);
|
||||
CLAMP(end, 0, self->row_num);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
tuple = PyTuple_New(end - begin);
|
||||
for (count = begin; count < end; count++) {
|
||||
@@ -2532,7 +2534,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
|
||||
|
||||
CLAMP(begin, 0, self->row_num);
|
||||
CLAMP(end, 0, self->row_num);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
/* non list/tuple cases */
|
||||
if (!(value_fast = PySequence_Fast(value, "matrix[begin:end] = value"))) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup pymathutils
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "mathutils.h"
|
||||
@@ -969,7 +971,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end)
|
||||
end = (QUAT_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, QUAT_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
tuple = PyTuple_New(end - begin);
|
||||
for (count = begin; count < end; count++) {
|
||||
@@ -994,7 +996,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb
|
||||
end = (QUAT_SIZE + 1) + end;
|
||||
}
|
||||
CLAMP(end, 0, QUAT_SIZE);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
if ((size = mathutils_array_parse(
|
||||
quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* \ingroup pymathutils
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "mathutils.h"
|
||||
@@ -1782,7 +1784,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end)
|
||||
end = self->vec_num + end + 1;
|
||||
}
|
||||
CLAMP(end, 0, self->vec_num);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
tuple = PyTuple_New(end - begin);
|
||||
for (count = begin; count < end; count++) {
|
||||
@@ -1804,7 +1806,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se
|
||||
|
||||
CLAMP(begin, 0, self->vec_num);
|
||||
CLAMP(end, 0, self->vec_num);
|
||||
begin = MIN2(begin, end);
|
||||
begin = std::min(begin, end);
|
||||
|
||||
vec_num = (end - begin);
|
||||
if (mathutils_array_parse_alloc(&vec, vec_num, seq, "vector[begin:end] = [...]") == -1) {
|
||||
|
||||
Reference in New Issue
Block a user