Base: Use explicit pointer syntax for freecad_cast (#20694)

* Base: Use explicit pointer syntax for freecad_cast

This aligns our custom cast with other casts

* All: Use explicit pointer syntax for freecad_cast
This commit is contained in:
Kacper Donat
2025-04-11 16:11:33 +02:00
committed by GitHub
parent 581fa12e45
commit b300c80b90
73 changed files with 305 additions and 304 deletions

View File

@@ -344,16 +344,16 @@ bool Sheet::exportToFile(const std::string& filename,
std::stringstream field;
if (auto p = freecad_cast<PropertyQuantity>(prop)) {
if (auto p = freecad_cast<PropertyQuantity*>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_cast<PropertyFloat>(prop)) {
else if (auto p = freecad_cast<PropertyFloat*>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_cast<PropertyInteger>(prop)) {
else if (auto p = freecad_cast<PropertyInteger*>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_cast<PropertyString>(prop)) {
else if (auto p = freecad_cast<PropertyString*>(prop)) {
field << p->getValue();
}
else {
@@ -593,7 +593,7 @@ Property* Sheet::setFloatProperty(CellAddress key, double value)
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
floatProp = freecad_cast<PropertyFloat>(
floatProp = freecad_cast<PropertyFloat*>(
addDynamicProperty("App::PropertyFloat",
name.c_str(),
nullptr,
@@ -621,7 +621,7 @@ Property* Sheet::setIntegerProperty(CellAddress key, long value)
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
intProp = freecad_cast<PropertyInteger>(
intProp = freecad_cast<PropertyInteger*>(
addDynamicProperty("App::PropertyInteger",
name.c_str(),
nullptr,
@@ -666,7 +666,7 @@ Property* Sheet::setQuantityProperty(CellAddress key, double value, const Base::
nullptr,
nullptr,
Prop_ReadOnly | Prop_Hidden | Prop_NoPersist);
quantityProp = freecad_cast<PropertySpreadsheetQuantity>(p);
quantityProp = freecad_cast<PropertySpreadsheetQuantity*>(p);
}
else {
quantityProp = static_cast<PropertySpreadsheetQuantity*>(prop);
@@ -695,14 +695,14 @@ Property* Sheet::setStringProperty(CellAddress key, const std::string& value)
{
std::string name = key.toString(CellAddress::Cell::ShowRowColumn);
Property* prop = props.getDynamicPropertyByName(name.c_str());
PropertyString* stringProp = freecad_cast<PropertyString>(prop);
PropertyString* stringProp = freecad_cast<PropertyString*>(prop);
if (!stringProp) {
if (prop) {
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
stringProp = freecad_cast<PropertyString>(
stringProp = freecad_cast<PropertyString*>(
addDynamicProperty("App::PropertyString",
name.c_str(),
nullptr,
@@ -720,14 +720,14 @@ Property* Sheet::setObjectProperty(CellAddress key, Py::Object object)
{
std::string name = key.toString(CellAddress::Cell::ShowRowColumn);
Property* prop = props.getDynamicPropertyByName(name.c_str());
PropertyPythonObject* pyProp = freecad_cast<PropertyPythonObject>(prop);
PropertyPythonObject* pyProp = freecad_cast<PropertyPythonObject*>(prop);
if (!pyProp) {
if (prop) {
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
pyProp = freecad_cast<PropertyPythonObject>(
pyProp = freecad_cast<PropertyPythonObject*>(
addDynamicProperty("App::PropertyPythonObject",
name.c_str(),
nullptr,
@@ -794,10 +794,10 @@ void Sheet::updateProperty(CellAddress key)
/* Eval returns either NumberExpression or StringExpression, or
* PyObjectExpression objects */
auto number = freecad_cast<NumberExpression>(output.get());
auto number = freecad_cast<NumberExpression*>(output.get());
if (number) {
long l;
auto constant = freecad_cast<ConstantExpression>(output.get());
auto constant = freecad_cast<ConstantExpression*>(output.get());
if (constant && !constant->isNumber()) {
Base::PyGILStateLocker lock;
setObjectProperty(key, constant->getPyValue());
@@ -813,13 +813,13 @@ void Sheet::updateProperty(CellAddress key)
}
}
else {
auto str_expr = freecad_cast<StringExpression>(output.get());
auto str_expr = freecad_cast<StringExpression*>(output.get());
if (str_expr) {
setStringProperty(key, str_expr->getText().c_str());
}
else {
Base::PyGILStateLocker lock;
auto py_expr = freecad_cast<PyObjectExpression>(output.get());
auto py_expr = freecad_cast<PyObjectExpression*>(output.get());
if (py_expr) {
setObjectProperty(key, py_expr->getPyValue());
}