App: Use std::numeric_limits and std::numbers instead of defines
This commit is contained in:
@@ -130,7 +130,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer* _owner,
|
||||
}
|
||||
if (!property.empty()) {
|
||||
addComponent(SimpleComponent(property));
|
||||
if (index != INT_MAX) {
|
||||
if (index != std::numeric_limits<int>::max()) {
|
||||
addComponent(ArrayComponent(index));
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ ObjectIdentifier::ObjectIdentifier(const Property& prop, int index)
|
||||
setDocumentObjectName(docObj);
|
||||
|
||||
addComponent(SimpleComponent(String(prop.getName())));
|
||||
if (index != INT_MAX) {
|
||||
if (index != std::numeric_limits<int>::max()) {
|
||||
addComponent(ArrayComponent(index));
|
||||
}
|
||||
}
|
||||
@@ -703,8 +703,9 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object& pyobj) const
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
PyObject* r = PyObject_GetItem(pyobj.ptr(), slice.ptr());
|
||||
@@ -742,8 +743,9 @@ void ObjectIdentifier::Component::set(Py::Object& pyobj, const Py::Object& value
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
if (PyObject_SetItem(pyobj.ptr(), slice.ptr(), value.ptr()) < 0) {
|
||||
@@ -770,8 +772,9 @@ void ObjectIdentifier::Component::del(Py::Object& pyobj) const
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
if (PyObject_DelItem(pyobj.ptr(), slice.ptr()) < 0) {
|
||||
@@ -897,11 +900,11 @@ void ObjectIdentifier::Component::toString(std::ostream& ss, bool toPython) cons
|
||||
break;
|
||||
case Component::RANGE:
|
||||
ss << '[';
|
||||
if (begin != INT_MAX) {
|
||||
if (begin != std::numeric_limits<int>::max()) {
|
||||
ss << begin;
|
||||
}
|
||||
ss << ':';
|
||||
if (end != INT_MAX) {
|
||||
if (end != std::numeric_limits<int>::max()) {
|
||||
ss << end;
|
||||
}
|
||||
if (step != 1) {
|
||||
|
||||
Reference in New Issue
Block a user