diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index 88a09972ea..a9af86bb32 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -90,7 +90,7 @@ DocumentObject::~DocumentObject() // not to dec'ref the Python object any more. // But we must still invalidate the Python object because it need not to be // destructed right now because the interpreter can own several references to it. - Base::PyObjectBase* obj = (Base::PyObjectBase*)PythonObject.ptr(); + Base::PyObjectBase* obj = static_cast(PythonObject.ptr()); // Call before decrementing the reference counter, otherwise a heap error can occur obj->setInvalid(); } diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 5e160296ad..415c38d037 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -761,7 +761,7 @@ PyObject *DocumentObjectPy::resolveSubElement(PyObject *args) PY_TRY { std::pair elementName; auto obj = GeoFeature::resolveElement(getDocumentObjectPtr(), subname,elementName, - Base::asBoolean(append), (GeoFeature::ElementNameType)type); + Base::asBoolean(append), static_cast(type)); Py::Tuple ret(3); ret.setItem(0,obj?Py::Object(obj->getPyObject(),true):Py::None()); ret.setItem(1,Py::String(elementName.first)); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index ef790dbc0f..9c7fe6bf8c 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -110,13 +110,13 @@ FC_LOG_LEVEL_INIT("Expression", true, true) #define EXPR_THROW(_msg) _EXPR_THROW(_msg,this) -#define RUNTIME_THROW(_msg) __EXPR_THROW(Base::RuntimeError,_msg, (Expression*)0) +#define RUNTIME_THROW(_msg) __EXPR_THROW(Base::RuntimeError,_msg, static_cast(nullptr)) -#define TYPE_THROW(_msg) __EXPR_THROW(Base::TypeError,_msg, (Expression*)0) +#define TYPE_THROW(_msg) __EXPR_THROW(Base::TypeError,_msg, static_cast(nullptr)) -#define PARSER_THROW(_msg) __EXPR_THROW(Base::ParserError,_msg, (Expression*)0) +#define PARSER_THROW(_msg) __EXPR_THROW(Base::ParserError,_msg, static_cast(nullptr)) -#define PY_THROW(_msg) __EXPR_THROW(Py::RuntimeError,_msg, (Expression*)0) +#define PY_THROW(_msg) __EXPR_THROW(Py::RuntimeError,_msg, static_cast(nullptr)) static inline std::ostream &operator<<(std::ostream &os, const App::Expression *expr) { if(expr) { diff --git a/src/App/Extension.cpp b/src/App/Extension.cpp index fdbbe695e9..9c38fbfd98 100644 --- a/src/App/Extension.cpp +++ b/src/App/Extension.cpp @@ -65,7 +65,7 @@ Extension::~Extension() // not to dec'ref the Python object any more. // But we must still invalidate the Python object because it need not to be // destructed right now because the interpreter can own several references to it. - Base::PyObjectBase* obj = (Base::PyObjectBase*)ExtensionPythonObject.ptr(); + Base::PyObjectBase* obj = static_cast(ExtensionPythonObject.ptr()); // Call before decrementing the reference counter, otherwise a heap error can occur obj->setInvalid(); } diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index d12c89c3bf..3e3416e637 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -565,7 +565,7 @@ Property *PropertyData::getPropertyByName(OffsetBase offsetBase,const char* name const PropertyData::PropertySpec* Spec = findProperty(offsetBase,name); if(Spec) - return (Property *) (Spec->Offset + offsetBase.getOffset()); + return reinterpret_cast(Spec->Offset + offsetBase.getOffset()); else return nullptr; } @@ -574,7 +574,7 @@ void PropertyData::getPropertyMap(OffsetBase offsetBase,std::map()) - Map[spec.Name] = (Property *) (spec.Offset + offsetBase.getOffset()); + Map[spec.Name] = reinterpret_cast(spec.Offset + offsetBase.getOffset()); } void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector &List) const @@ -583,7 +583,7 @@ void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector size_t base = List.size(); List.reserve(base+propertyData.size()); for (auto &spec : propertyData.get<0>()) - List.push_back((Property *) (spec.Offset + offsetBase.getOffset())); + List.push_back(reinterpret_cast(spec.Offset + offsetBase.getOffset())); } void PropertyData::getPropertyNamedList(OffsetBase offsetBase, @@ -593,7 +593,7 @@ void PropertyData::getPropertyNamedList(OffsetBase offsetBase, size_t base = List.size(); List.reserve(base+propertyData.size()); for (auto &spec : propertyData.get<0>()) { - auto prop = (Property *) (spec.Offset + offsetBase.getOffset()); + auto prop = reinterpret_cast(spec.Offset + offsetBase.getOffset()); List.emplace_back(prop->getName(),prop); } } diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 4aa2304d42..98a8f69fa4 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -247,7 +247,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args) bool value = true; if (item.isString()) { const auto &statusMap = getStatusMap(); - auto v = (std::string)Py::String(item); + auto v = static_cast(Py::String(item)); if(v.size()>1 && v[0] == '-') { value = false; v = v.substr(1); diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 2eef5db185..8c2377b293 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -405,7 +405,7 @@ PyObject *PropertyMatrix::getPyObject() void PropertyMatrix::setPyObject(PyObject *value) { if (PyObject_TypeCheck(value, &(Base::MatrixPy::Type))) { - Base::MatrixPy *pcObject = (Base::MatrixPy*)value; + Base::MatrixPy *pcObject = static_cast(value); setValue( pcObject->value() ); } else if (PyTuple_Check(value)&&PyTuple_Size(value)==16) { @@ -630,7 +630,7 @@ PyObject *PropertyPlacement::getPyObject() void PropertyPlacement::setPyObject(PyObject *value) { if (PyObject_TypeCheck(value, &(Base::MatrixPy::Type))) { - Base::MatrixPy *pcObject = (Base::MatrixPy*)value; + Base::MatrixPy *pcObject = static_cast(value); Base::Matrix4D mat = pcObject->value(); Base::Placement p; p.fromMatrix(mat); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index c0ae427953..2ef7b080ef 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -461,7 +461,7 @@ PyObject *PropertyLink::getPyObject() void PropertyLink::setPyObject(PyObject *value) { if (PyObject_TypeCheck(value, &(DocumentObjectPy::Type))) { - DocumentObjectPy *pcObject = (DocumentObjectPy*)value; + DocumentObjectPy *pcObject = static_cast(value); setValue(pcObject->getDocumentObjectPtr()); } else if (Py_None == value) { @@ -1025,7 +1025,7 @@ PyObject *PropertyLinkSub::getPyObject() void PropertyLinkSub::setPyObject(PyObject *value) { if (PyObject_TypeCheck(value, &(DocumentObjectPy::Type))) { - DocumentObjectPy *pcObject = (DocumentObjectPy*)value; + DocumentObjectPy *pcObject = static_cast(value); setValue(pcObject->getDocumentObjectPtr()); } else if (PyTuple_Check(value) || PyList_Check(value)) { @@ -1035,7 +1035,7 @@ void PropertyLinkSub::setPyObject(PyObject *value) else if(seq.size()!=2) throw Base::ValueError("Expect input sequence of size 2"); else if (PyObject_TypeCheck(seq[0].ptr(), &(DocumentObjectPy::Type))) { - DocumentObjectPy *pcObj = (DocumentObjectPy*)seq[0].ptr(); + DocumentObjectPy *pcObj = static_cast(seq[0].ptr()); static const char *errMsg = "type of second element in tuple must be str or sequence of str"; PropertyString propString; if (seq[1].isString()) {