All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
ef997f2259
commit
9fe130cd73
@@ -41,9 +41,10 @@ void DocumentObserverPython::addObserver(const Py::Object& obj)
|
||||
|
||||
void DocumentObserverPython::removeObserver(const Py::Object& obj)
|
||||
{
|
||||
DocumentObserverPython* obs=nullptr;
|
||||
for (std::vector<DocumentObserverPython*>::iterator it =
|
||||
_instances.begin(); it != _instances.end(); ++it) {
|
||||
DocumentObserverPython* obs = nullptr;
|
||||
for (std::vector<DocumentObserverPython*>::iterator it = _instances.begin();
|
||||
it != _instances.end();
|
||||
++it) {
|
||||
if ((*it)->inst == obj) {
|
||||
obs = *it;
|
||||
_instances.erase(it);
|
||||
@@ -54,24 +55,27 @@ void DocumentObserverPython::removeObserver(const Py::Object& obj)
|
||||
delete obs;
|
||||
}
|
||||
|
||||
DocumentObserverPython::DocumentObserverPython(const Py::Object& obj) : inst(obj)
|
||||
DocumentObserverPython::DocumentObserverPython(const Py::Object& obj)
|
||||
: inst(obj)
|
||||
{
|
||||
//NOLINTBEGIN
|
||||
#define FC_PY_ELEMENT_ARG1(_name1, _name2) do {\
|
||||
FC_PY_GetCallable(obj.ptr(), "slot" #_name1, py##_name1.py);\
|
||||
if (!py##_name1.py.isNone())\
|
||||
py##_name1.slot = Application::Instance->signal##_name2.connect(\
|
||||
std::bind(&DocumentObserverPython::slot##_name1, this, sp::_1));\
|
||||
}\
|
||||
while(0);
|
||||
// NOLINTBEGIN
|
||||
#define FC_PY_ELEMENT_ARG1(_name1, _name2) \
|
||||
do { \
|
||||
FC_PY_GetCallable(obj.ptr(), "slot" #_name1, py##_name1.py); \
|
||||
if (!py##_name1.py.isNone()) \
|
||||
py##_name1.slot = Application::Instance->signal##_name2.connect( \
|
||||
std::bind(&DocumentObserverPython::slot##_name1, this, sp::_1) \
|
||||
); \
|
||||
} while (0);
|
||||
|
||||
#define FC_PY_ELEMENT_ARG2(_name1, _name2) do {\
|
||||
FC_PY_GetCallable(obj.ptr(), "slot" #_name1, py##_name1.py);\
|
||||
if (!py##_name1.py.isNone())\
|
||||
py##_name1.slot = Application::Instance->signal##_name2.connect(\
|
||||
std::bind(&DocumentObserverPython::slot##_name1, this, sp::_1, sp::_2));\
|
||||
}\
|
||||
while(0);
|
||||
#define FC_PY_ELEMENT_ARG2(_name1, _name2) \
|
||||
do { \
|
||||
FC_PY_GetCallable(obj.ptr(), "slot" #_name1, py##_name1.py); \
|
||||
if (!py##_name1.py.isNone()) \
|
||||
py##_name1.slot = Application::Instance->signal##_name2.connect( \
|
||||
std::bind(&DocumentObserverPython::slot##_name1, this, sp::_1, sp::_2) \
|
||||
); \
|
||||
} while (0);
|
||||
|
||||
FC_PY_ELEMENT_ARG1(CreatedDocument, NewDocument)
|
||||
FC_PY_ELEMENT_ARG1(DeletedDocument, DeleteDocument)
|
||||
@@ -84,7 +88,7 @@ DocumentObserverPython::DocumentObserverPython(const Py::Object& obj) : inst(obj
|
||||
FC_PY_ELEMENT_ARG2(ChangedObject, ChangedObject)
|
||||
FC_PY_ELEMENT_ARG1(InEdit, InEdit)
|
||||
FC_PY_ELEMENT_ARG1(ResetEdit, ResetEdit)
|
||||
//NOLINTEND
|
||||
// NOLINTEND
|
||||
}
|
||||
|
||||
DocumentObserverPython::~DocumentObserverPython() = default;
|
||||
@@ -95,10 +99,10 @@ void DocumentObserverPython::slotCreatedDocument(const Gui::Document& Doc)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::Document&>(Doc).getPyObject()));
|
||||
Base::pyCall(pyCreatedDocument.ptr(),args.ptr());
|
||||
Base::pyCall(pyCreatedDocument.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -109,10 +113,10 @@ void DocumentObserverPython::slotDeletedDocument(const Gui::Document& Doc)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::Document&>(Doc).getPyObject()));
|
||||
Base::pyCall(pyDeletedDocument.ptr(),args.ptr());
|
||||
Base::pyCall(pyDeletedDocument.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -123,10 +127,10 @@ void DocumentObserverPython::slotRelabelDocument(const Gui::Document& Doc)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::Document&>(Doc).getPyObject()));
|
||||
Base::pyCall(pyRelabelDocument.ptr(),args.ptr());
|
||||
Base::pyCall(pyRelabelDocument.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -137,10 +141,10 @@ void DocumentObserverPython::slotRenameDocument(const Gui::Document& Doc)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::Document&>(Doc).getPyObject()));
|
||||
Base::pyCall(pyRenameDocument.ptr(),args.ptr());
|
||||
Base::pyCall(pyRenameDocument.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -151,10 +155,10 @@ void DocumentObserverPython::slotActivateDocument(const Gui::Document& Doc)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::Document&>(Doc).getPyObject()));
|
||||
Base::pyCall(pyActivateDocument.ptr(),args.ptr());
|
||||
Base::pyCall(pyActivateDocument.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -165,10 +169,10 @@ void DocumentObserverPython::slotCreatedObject(const Gui::ViewProvider& Obj)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::ViewProvider&>(Obj).getPyObject()));
|
||||
Base::pyCall(pyCreatedObject.ptr(),args.ptr());
|
||||
Base::pyCall(pyCreatedObject.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -179,16 +183,18 @@ void DocumentObserverPython::slotDeletedObject(const Gui::ViewProvider& Obj)
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::ViewProvider&>(Obj).getPyObject()));
|
||||
Base::pyCall(pyDeletedObject.ptr(),args.ptr());
|
||||
Base::pyCall(pyDeletedObject.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentObserverPython::slotBeforeChangeObject(const Gui::ViewProvider& Obj,
|
||||
const App::Property& Prop)
|
||||
void DocumentObserverPython::slotBeforeChangeObject(
|
||||
const Gui::ViewProvider& Obj,
|
||||
const App::Property& Prop
|
||||
)
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
try {
|
||||
@@ -199,17 +205,16 @@ void DocumentObserverPython::slotBeforeChangeObject(const Gui::ViewProvider& Obj
|
||||
const char* prop_name = Obj.getPropertyName(&Prop);
|
||||
if (prop_name) {
|
||||
args.setItem(1, Py::String(prop_name));
|
||||
Base::pyCall(pyBeforeChangeObject.ptr(),args.ptr());
|
||||
Base::pyCall(pyBeforeChangeObject.ptr(), args.ptr());
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentObserverPython::slotChangedObject(const Gui::ViewProvider& Obj,
|
||||
const App::Property& Prop)
|
||||
void DocumentObserverPython::slotChangedObject(const Gui::ViewProvider& Obj, const App::Property& Prop)
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
try {
|
||||
@@ -220,11 +225,11 @@ void DocumentObserverPython::slotChangedObject(const Gui::ViewProvider& Obj,
|
||||
const char* prop_name = Obj.getPropertyName(&Prop);
|
||||
if (prop_name) {
|
||||
args.setItem(1, Py::String(prop_name));
|
||||
Base::pyCall(pyChangedObject.ptr(),args.ptr());
|
||||
Base::pyCall(pyChangedObject.ptr(), args.ptr());
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -235,10 +240,10 @@ void DocumentObserverPython::slotInEdit(const Gui::ViewProviderDocumentObject& O
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::ViewProviderDocumentObject&>(Obj).getPyObject()));
|
||||
Base::pyCall(pyInEdit.ptr(),args.ptr());
|
||||
Base::pyCall(pyInEdit.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
@@ -249,10 +254,10 @@ void DocumentObserverPython::slotResetEdit(const Gui::ViewProviderDocumentObject
|
||||
try {
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, Py::asObject(const_cast<Gui::ViewProviderDocumentObject&>(Obj).getPyObject()));
|
||||
Base::pyCall(pyResetEdit.ptr(),args.ptr());
|
||||
Base::pyCall(pyResetEdit.ptr(), args.ptr());
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.reportException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user