App: Replace C cast

This commit is contained in:
marioalexis
2022-05-19 11:11:00 -03:00
committed by Chris Hennes
parent 78cc184d50
commit 9ccb9eecb2
8 changed files with 17 additions and 17 deletions

View File

@@ -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<Base::PyObjectBase*>(PythonObject.ptr());
// Call before decrementing the reference counter, otherwise a heap error can occur
obj->setInvalid();
}

View File

@@ -761,7 +761,7 @@ PyObject *DocumentObjectPy::resolveSubElement(PyObject *args)
PY_TRY {
std::pair<std::string,std::string> elementName;
auto obj = GeoFeature::resolveElement(getDocumentObjectPtr(), subname,elementName,
Base::asBoolean(append), (GeoFeature::ElementNameType)type);
Base::asBoolean(append), static_cast<GeoFeature::ElementNameType>(type));
Py::Tuple ret(3);
ret.setItem(0,obj?Py::Object(obj->getPyObject(),true):Py::None());
ret.setItem(1,Py::String(elementName.first));

View File

@@ -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<Expression*>(nullptr))
#define TYPE_THROW(_msg) __EXPR_THROW(Base::TypeError,_msg, (Expression*)0)
#define TYPE_THROW(_msg) __EXPR_THROW(Base::TypeError,_msg, static_cast<Expression*>(nullptr))
#define PARSER_THROW(_msg) __EXPR_THROW(Base::ParserError,_msg, (Expression*)0)
#define PARSER_THROW(_msg) __EXPR_THROW(Base::ParserError,_msg, static_cast<Expression*>(nullptr))
#define PY_THROW(_msg) __EXPR_THROW(Py::RuntimeError,_msg, (Expression*)0)
#define PY_THROW(_msg) __EXPR_THROW(Py::RuntimeError,_msg, static_cast<Expression*>(nullptr))
static inline std::ostream &operator<<(std::ostream &os, const App::Expression *expr) {
if(expr) {

View File

@@ -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<Base::PyObjectBase*>(ExtensionPythonObject.ptr());
// Call before decrementing the reference counter, otherwise a heap error can occur
obj->setInvalid();
}

View File

@@ -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<Property *>(Spec->Offset + offsetBase.getOffset());
else
return nullptr;
}
@@ -574,7 +574,7 @@ void PropertyData::getPropertyMap(OffsetBase offsetBase,std::map<std::string,Pro
{
merge();
for(auto &spec : propertyData.get<0>())
Map[spec.Name] = (Property *) (spec.Offset + offsetBase.getOffset());
Map[spec.Name] = reinterpret_cast<Property *>(spec.Offset + offsetBase.getOffset());
}
void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector<Property*> &List) const
@@ -583,7 +583,7 @@ void PropertyData::getPropertyList(OffsetBase offsetBase,std::vector<Property*>
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<Property *>(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<Property *>(spec.Offset + offsetBase.getOffset());
List.emplace_back(prop->getName(),prop);
}
}

View File

@@ -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<std::string>(Py::String(item));
if(v.size()>1 && v[0] == '-') {
value = false;
v = v.substr(1);

View File

@@ -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<Base::MatrixPy*>(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<Base::MatrixPy*>(value);
Base::Matrix4D mat = pcObject->value();
Base::Placement p;
p.fromMatrix(mat);

View File

@@ -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<DocumentObjectPy*>(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<DocumentObjectPy*>(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<DocumentObjectPy*>(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()) {