App: Apply clang format (part 2)
This commit is contained in:
@@ -38,8 +38,8 @@
|
||||
#include "Range.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( disable : 4700 )
|
||||
#pragma warning( disable : 4723 )
|
||||
#pragma warning(disable : 4700)
|
||||
#pragma warning(disable : 4723)
|
||||
#endif
|
||||
|
||||
using namespace App;
|
||||
@@ -47,73 +47,106 @@ using namespace App;
|
||||
|
||||
PROPERTY_SOURCE(App::FeatureTest, App::DocumentObject)
|
||||
|
||||
const char* enums[]= {"Zero","One","Two","Three","Four",nullptr};
|
||||
const PropertyIntegerConstraint::Constraints intPercent = {0,100,1};
|
||||
const PropertyFloatConstraint::Constraints floatPercent = {0.0,100.0,1.0};
|
||||
const char* enums[] = {"Zero", "One", "Two", "Three", "Four", nullptr};
|
||||
const PropertyIntegerConstraint::Constraints intPercent = {0, 100, 1};
|
||||
const PropertyFloatConstraint::Constraints floatPercent = {0.0, 100.0, 1.0};
|
||||
|
||||
|
||||
FeatureTest::FeatureTest()
|
||||
{
|
||||
ADD_PROPERTY(Integer,(4711) );
|
||||
ADD_PROPERTY(Float ,(47.11f) );
|
||||
ADD_PROPERTY(Bool ,(true) );
|
||||
ADD_PROPERTY(BoolList,(false));
|
||||
ADD_PROPERTY(String ,("4711"));
|
||||
ADD_PROPERTY(Path ,("c:\\temp"));
|
||||
ADD_PROPERTY(StringList ,("4711"));
|
||||
// clang-format off
|
||||
ADD_PROPERTY(Integer, (4711));
|
||||
ADD_PROPERTY(Float, (47.11f));
|
||||
ADD_PROPERTY(Bool, (true));
|
||||
ADD_PROPERTY(BoolList, (false));
|
||||
ADD_PROPERTY(String, ("4711"));
|
||||
ADD_PROPERTY(Path, ("c:\\temp"));
|
||||
ADD_PROPERTY(StringList, ("4711"));
|
||||
|
||||
ADD_PROPERTY(Enum ,(4));
|
||||
Enum.setEnums(enums);
|
||||
ADD_PROPERTY(ConstraintInt ,(5));
|
||||
ConstraintInt.setConstraints(&intPercent);
|
||||
ADD_PROPERTY(ConstraintFloat ,(5.0));
|
||||
ConstraintFloat.setConstraints(&floatPercent);
|
||||
ADD_PROPERTY(Enum, (4));
|
||||
Enum.setEnums(enums);
|
||||
ADD_PROPERTY(ConstraintInt, (5));
|
||||
ConstraintInt.setConstraints(&intPercent);
|
||||
ADD_PROPERTY(ConstraintFloat, (5.0));
|
||||
ConstraintFloat.setConstraints(&floatPercent);
|
||||
|
||||
App::Color c;
|
||||
App::Material mat(App::Material::GOLD);
|
||||
ADD_PROPERTY(Colour ,(c) );
|
||||
ADD_PROPERTY(ColourList ,(c) );
|
||||
ADD_PROPERTY(Material ,(mat));
|
||||
ADD_PROPERTY(MaterialList,(mat));
|
||||
App::Color c;
|
||||
App::Material mat(App::Material::GOLD);
|
||||
ADD_PROPERTY(Colour, (c));
|
||||
ADD_PROPERTY(ColourList, (c));
|
||||
ADD_PROPERTY(Material, (mat));
|
||||
ADD_PROPERTY(MaterialList, (mat));
|
||||
|
||||
ADD_PROPERTY(Distance,(47.11f) );
|
||||
ADD_PROPERTY(Angle ,(3.0f) );
|
||||
ADD_PROPERTY(Distance, (47.11f));
|
||||
ADD_PROPERTY(Angle, (3.0f));
|
||||
|
||||
ADD_PROPERTY(IntegerList,(4711) );
|
||||
ADD_PROPERTY(FloatList ,(47.11f) );
|
||||
ADD_PROPERTY(IntegerList, (4711));
|
||||
ADD_PROPERTY(FloatList, (47.11f));
|
||||
|
||||
ADD_PROPERTY(Link ,(nullptr));
|
||||
ADD_PROPERTY(LinkSub ,(nullptr));
|
||||
ADD_PROPERTY(LinkList ,(nullptr));
|
||||
ADD_PROPERTY(LinkSubList,(nullptr));
|
||||
ADD_PROPERTY(Link, (nullptr));
|
||||
ADD_PROPERTY(LinkSub, (nullptr));
|
||||
ADD_PROPERTY(LinkList, (nullptr));
|
||||
ADD_PROPERTY(LinkSubList, (nullptr));
|
||||
|
||||
ADD_PROPERTY(Vector ,(1.0,2.0,3.0));
|
||||
ADD_PROPERTY(VectorList,(3.0,2.0,1.0));
|
||||
ADD_PROPERTY(Matrix ,(Base::Matrix4D(1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0)));
|
||||
ADD_PROPERTY(Placement ,(Base::Placement()));
|
||||
ADD_PROPERTY(Vector, (1.0, 2.0, 3.0));
|
||||
ADD_PROPERTY(VectorList, (3.0, 2.0, 1.0));
|
||||
ADD_PROPERTY(Matrix,
|
||||
(Base::Matrix4D( 1.0, 2.0, 3.0, 4.0,
|
||||
5.0, 6.0, 7.0, 8.0,
|
||||
9.0, 10.0, 11.0, 12.0,
|
||||
13.0, 14.0, 15.0, 16.0)));
|
||||
ADD_PROPERTY(Placement, (Base::Placement()));
|
||||
|
||||
// properties for recompute testing
|
||||
static const char* group = "Feature Test";
|
||||
ADD_PROPERTY_TYPE(Source1 ,(nullptr),group,Prop_None,"Source for testing links");
|
||||
ADD_PROPERTY_TYPE(Source2 ,(nullptr),group,Prop_None,"Source for testing links");
|
||||
ADD_PROPERTY_TYPE(SourceN ,(nullptr),group,Prop_None,"Source for testing links");
|
||||
ADD_PROPERTY_TYPE(ExecResult ,("empty"),group,Prop_None,"Result of the execution");
|
||||
ADD_PROPERTY_TYPE(ExceptionType ,(0),group,Prop_None,"The type of exception the execution method throws");
|
||||
ADD_PROPERTY_TYPE(ExecCount ,(0),group,Prop_None,"Number of executions");
|
||||
// properties for recompute testing
|
||||
static const char* group = "Feature Test";
|
||||
ADD_PROPERTY_TYPE(Source1, (nullptr), group, Prop_None, "Source for testing links");
|
||||
ADD_PROPERTY_TYPE(Source2, (nullptr), group, Prop_None, "Source for testing links");
|
||||
ADD_PROPERTY_TYPE(SourceN, (nullptr), group, Prop_None, "Source for testing links");
|
||||
ADD_PROPERTY_TYPE(ExecResult, ("empty"), group, Prop_None, "Result of the execution");
|
||||
ADD_PROPERTY_TYPE(ExceptionType,
|
||||
(0),
|
||||
group,
|
||||
Prop_None,
|
||||
"The type of exception the execution method throws");
|
||||
ADD_PROPERTY_TYPE(ExecCount, (0), group, Prop_None, "Number of executions");
|
||||
|
||||
// properties with types
|
||||
ADD_PROPERTY_TYPE(TypeHidden ,(4711),group,Prop_Hidden,"An example property which has the type 'Hidden'" );
|
||||
ADD_PROPERTY_TYPE(TypeReadOnly,(4711),group,Prop_ReadOnly ,"An example property which has the type 'ReadOnly'" );
|
||||
ADD_PROPERTY_TYPE(TypeOutput ,(4711),group,Prop_Output ,"An example property which has the type 'Output'" );
|
||||
ADD_PROPERTY_TYPE(TypeTransient,(4711),group,Prop_Transient ,"An example property which has the type 'Transient'" );
|
||||
ADD_PROPERTY_TYPE(TypeNoRecompute,(4711),group,Prop_NoRecompute,"An example property which has the type 'NoRecompute'");
|
||||
ADD_PROPERTY_TYPE(TypeAll ,(4711),group,(App::PropertyType) (Prop_Output|Prop_ReadOnly |Prop_Hidden ),
|
||||
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
|
||||
// properties with types
|
||||
ADD_PROPERTY_TYPE(TypeHidden,
|
||||
(4711),
|
||||
group,
|
||||
Prop_Hidden,
|
||||
"An example property which has the type 'Hidden'");
|
||||
ADD_PROPERTY_TYPE(TypeReadOnly,
|
||||
(4711),
|
||||
group,
|
||||
Prop_ReadOnly,
|
||||
"An example property which has the type 'ReadOnly'");
|
||||
ADD_PROPERTY_TYPE(TypeOutput,
|
||||
(4711),
|
||||
group,
|
||||
Prop_Output,
|
||||
"An example property which has the type 'Output'");
|
||||
ADD_PROPERTY_TYPE(TypeTransient,
|
||||
(4711),
|
||||
group,
|
||||
Prop_Transient,
|
||||
"An example property which has the type 'Transient'");
|
||||
ADD_PROPERTY_TYPE(TypeNoRecompute,
|
||||
(4711),
|
||||
group,
|
||||
Prop_NoRecompute,
|
||||
"An example property which has the type 'NoRecompute'");
|
||||
ADD_PROPERTY_TYPE(TypeAll,
|
||||
(4711),
|
||||
group,
|
||||
(App::PropertyType)(Prop_Output | Prop_ReadOnly | Prop_Hidden),
|
||||
"An example property which has the types 'Output', 'ReadOnly' and 'Hidden'");
|
||||
|
||||
ADD_PROPERTY(QuantityLength,(1.0));
|
||||
QuantityLength.setUnit(Base::Unit::Length);
|
||||
ADD_PROPERTY(QuantityOther,(5.0));
|
||||
QuantityOther.setUnit(Base::Unit(-3,1));
|
||||
ADD_PROPERTY(QuantityLength, (1.0));
|
||||
QuantityLength.setUnit(Base::Unit::Length);
|
||||
ADD_PROPERTY(QuantityOther, (5.0));
|
||||
QuantityOther.setUnit(Base::Unit(-3, 1));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
FeatureTest::~FeatureTest() = default;
|
||||
@@ -123,7 +156,7 @@ short FeatureTest::mustExecute() const
|
||||
return DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTest::execute()
|
||||
DocumentObjectExecReturn* FeatureTest::execute()
|
||||
{
|
||||
// Enum handling
|
||||
Enumeration enumObj1 = Enum.getEnum();
|
||||
@@ -159,19 +192,27 @@ DocumentObjectExecReturn *FeatureTest::execute()
|
||||
enumObj6.setEnums(list);
|
||||
enumObj6.setValue(list.back());
|
||||
|
||||
int *i=nullptr,j;
|
||||
int *i = nullptr, j;
|
||||
float f;
|
||||
void *s;
|
||||
void* s;
|
||||
std::string t;
|
||||
|
||||
// Code analyzers may complain about some errors. This can be ignored
|
||||
// because this is done on purpose to test the error handling mechanism
|
||||
switch(ExceptionType.getValue())
|
||||
{
|
||||
case 0: break;
|
||||
case 1: throw std::runtime_error("Test Exception");
|
||||
case 2: throw Base::RuntimeError("FeatureTestException::execute(): Testexception");
|
||||
default: (void)i; (void)j; (void)f; (void)s; (void)t; break;
|
||||
switch (ExceptionType.getValue()) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
throw std::runtime_error("Test Exception");
|
||||
case 2:
|
||||
throw Base::RuntimeError("FeatureTestException::execute(): Testexception");
|
||||
default:
|
||||
(void)i;
|
||||
(void)j;
|
||||
(void)f;
|
||||
(void)s;
|
||||
(void)t;
|
||||
break;
|
||||
}
|
||||
|
||||
ExecCount.setValue(ExecCount.getValue() + 1);
|
||||
@@ -188,12 +229,12 @@ PROPERTY_SOURCE(App::FeatureTestException, App::FeatureTest)
|
||||
|
||||
FeatureTestException::FeatureTestException()
|
||||
{
|
||||
ADD_PROPERTY(ExceptionType,(Base::Exception::getClassTypeId().getKey()) );
|
||||
ADD_PROPERTY(ExceptionType, (Base::Exception::getClassTypeId().getKey()));
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestException::execute()
|
||||
DocumentObjectExecReturn* FeatureTestException::execute()
|
||||
{
|
||||
//ExceptionType;
|
||||
// ExceptionType;
|
||||
throw Base::RuntimeError("FeatureTestException::execute(): Testexception ;-)");
|
||||
|
||||
return nullptr;
|
||||
@@ -211,7 +252,7 @@ FeatureTestColumn::FeatureTestColumn()
|
||||
ADD_PROPERTY_TYPE(Value, (0L), "Test", App::Prop_Output, "");
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestColumn::execute()
|
||||
DocumentObjectExecReturn* FeatureTestColumn::execute()
|
||||
{
|
||||
Value.setValue(decodeColumn(Column.getStrValue(), Silent.getValue()));
|
||||
return nullptr;
|
||||
@@ -229,7 +270,7 @@ FeatureTestRow::FeatureTestRow()
|
||||
ADD_PROPERTY_TYPE(Value, (0L), "Test", App::Prop_Output, "");
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestRow::execute()
|
||||
DocumentObjectExecReturn* FeatureTestRow::execute()
|
||||
{
|
||||
Value.setValue(decodeRow(Row.getStrValue(), Silent.getValue()));
|
||||
return nullptr;
|
||||
@@ -246,7 +287,7 @@ FeatureTestAbsAddress::FeatureTestAbsAddress()
|
||||
ADD_PROPERTY_TYPE(Valid, (false), "Test", PropertyType(Prop_Output | Prop_ReadOnly), "");
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestAbsAddress::execute()
|
||||
DocumentObjectExecReturn* FeatureTestAbsAddress::execute()
|
||||
{
|
||||
CellAddress address;
|
||||
Valid.setValue(address.parseAbsoluteAddress(Address.getValue()));
|
||||
@@ -266,7 +307,7 @@ FeatureTestPlacement::FeatureTestPlacement()
|
||||
ADD_PROPERTY_TYPE(MultRight, (Base::Placement()), "Test", Prop_Output, "");
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestPlacement::execute()
|
||||
DocumentObjectExecReturn* FeatureTestPlacement::execute()
|
||||
{
|
||||
Base::Placement p1 = Input1.getValue();
|
||||
Base::Placement q1 = Input1.getValue();
|
||||
@@ -295,8 +336,9 @@ FeatureTestAttribute::~FeatureTestAttribute()
|
||||
#if PYCXX_VERSION_MAJOR >= 7
|
||||
Py::ifPyErrorThrowCxxException();
|
||||
#else
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
throw Py::RuntimeError();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Py::RuntimeError& e) {
|
||||
@@ -308,7 +350,7 @@ FeatureTestAttribute::~FeatureTestAttribute()
|
||||
}
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn *FeatureTestAttribute::execute()
|
||||
DocumentObjectExecReturn* FeatureTestAttribute::execute()
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
try {
|
||||
@@ -316,8 +358,9 @@ DocumentObjectExecReturn *FeatureTestAttribute::execute()
|
||||
#if PYCXX_VERSION_MAJOR >= 7
|
||||
Py::ifPyErrorThrowCxxException();
|
||||
#else
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
throw Py::AttributeError();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Py::AttributeError& e) {
|
||||
|
||||
Reference in New Issue
Block a user