From 1972dfe5a3a2f307804c166c1619e71fefc27283 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Fri, 24 Jun 2022 16:31:56 -0300 Subject: [PATCH] Base: Replace C cast --- src/Base/Interpreter.cpp | 2 +- src/Base/PyObjectBase.cpp | 2 +- src/Base/Rotation.cpp | 2 +- src/Base/Vector3D.cpp | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index cfd600298a..849540a6ac 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -48,7 +48,7 @@ PyException::PyException(const Py::Object &obj) { // WARNING: we are assuming that python type object will never be // destroyed, so we don't keep reference here to save book-keeping in // our copy constructor and destructor - _exceptionType = (PyObject*)obj.ptr()->ob_type; + _exceptionType = reinterpret_cast(obj.ptr()->ob_type); _errorType = obj.ptr()->ob_type->tp_name; } diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index ca10b95232..1859c2a9a0 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -393,7 +393,7 @@ PyObject *PyObjectBase::_getattr(const char *attr) // Note: We must return the type object here, // so that our own types feel as really Python objects Py_INCREF(Py_TYPE(this)); - return (PyObject *)(Py_TYPE(this)); + return reinterpret_cast(Py_TYPE(this)); } else if (streq(attr, "__members__")) { // Use __dict__ instead as __members__ is deprecated diff --git a/src/Base/Rotation.cpp b/src/Base/Rotation.cpp index a53e156284..550c3519bc 100644 --- a/src/Base/Rotation.cpp +++ b/src/Base/Rotation.cpp @@ -921,7 +921,7 @@ Rotation::EulerSequence Rotation::eulerSequenceFromName(const char *name) if (name) { for (unsigned i=0; i(i+1); } } return Invalid; diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index 31f8da5894..810f1e1813 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -247,14 +247,14 @@ _Precision Vector3<_Precision>::DistanceToPlane (const Vector3<_Precision> &rclB template _Precision Vector3<_Precision>::Length () const { - return (_Precision)sqrt ((x * x) + (y * y) + (z * z)); + return static_cast<_Precision>(sqrt ((x * x) + (y * y) + (z * z))); } template _Precision Vector3<_Precision>::DistanceToLine (const Vector3<_Precision> &rclBase, const Vector3<_Precision> &rclDirect) const { - return (_Precision) fabs((rclDirect % Vector3(*this - rclBase)).Length() / rclDirect.Length()); + return static_cast<_Precision>(fabs((rclDirect % Vector3(*this - rclBase)).Length() / rclDirect.Length())); } template @@ -360,8 +360,8 @@ void Vector3<_Precision>::RotateX (_Precision f) Vector3 cPt (*this); _Precision fsin, fcos; - fsin = (_Precision)sin (f); - fcos = (_Precision)cos (f); + fsin = static_cast<_Precision>(sin(f)); + fcos = static_cast<_Precision>(cos(f)); y = (cPt.y * fcos) - (cPt.z * fsin); z = (cPt.y * fsin) + (cPt.z * fcos); } @@ -372,8 +372,8 @@ void Vector3<_Precision>::RotateY (_Precision f) Vector3 cPt (*this); _Precision fsin, fcos; - fsin = (_Precision)sin (f); - fcos = (_Precision)cos (f); + fsin = static_cast<_Precision>(sin(f)); + fcos = static_cast<_Precision>(cos(f)); x = (cPt.z * fsin) + (cPt.x * fcos); z = (cPt.z * fcos) - (cPt.x * fsin); } @@ -384,8 +384,8 @@ void Vector3<_Precision>::RotateZ (_Precision f) Vector3 cPt (*this); _Precision fsin, fcos; - fsin = (_Precision)sin (f); - fcos = (_Precision)cos (f); + fsin = static_cast<_Precision>(sin(f)); + fcos = static_cast<_Precision>(cos(f)); x = (cPt.x * fcos) - (cPt.y * fsin); y = (cPt.x * fsin) + (cPt.y * fcos); } @@ -394,7 +394,7 @@ template Vector3<_Precision> & Vector3<_Precision>::Normalize () { _Precision fLen = Length (); - if (fLen != (_Precision)0.0 && fLen != (_Precision)1.0) { + if (fLen != static_cast<_Precision>(0.0) && fLen != static_cast<_Precision>(1.0)) { x /= fLen; y /= fLen; z /= fLen;