From 7758509bdabbd2ab5e3df71dd582e8ca911fbf22 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 15 Nov 2019 23:53:09 +0100 Subject: [PATCH] fix and suppress some more -Wgnu-zero-variadic-macro-arguments --- src/App/DocumentObserverPython.cpp | 67 ++++++++++++++++++++-------- src/App/DocumentObserverPython.h | 70 +++++++++++++++--------------- src/App/Link.cpp | 11 +++++ 3 files changed, 95 insertions(+), 53 deletions(-) diff --git a/src/App/DocumentObserverPython.cpp b/src/App/DocumentObserverPython.cpp index ccc0b2055a..edaeef5eb0 100644 --- a/src/App/DocumentObserverPython.cpp +++ b/src/App/DocumentObserverPython.cpp @@ -59,29 +59,62 @@ void DocumentObserverPython::removeObserver(const Py::Object& obj) DocumentObserverPython::DocumentObserverPython(const Py::Object& obj) : inst(obj) { -#define signalCreatedDocument signalNewDocument -#define signalCreatedObject signalNewObject -#define signalRecomputedObject signalObjectRecomputed -#define signalRecomputedDocument signalRecomputed -#define signalActivateDocument signalActiveDocument -#define signalDeletedDocument signalDeleteDocument +#define FC_PY_ELEMENT_ARG0(_name1, _name2) do {\ + FC_PY_GetCallable(obj.ptr(), "slot" #_name1, py##_name1.py);\ + if (!py##_name1.py.isNone())\ + py##_name1.slot = App::GetApplication().signal##_name2.connect(\ + boost::bind(&DocumentObserverPython::slot##_name1, this));\ + }\ + while(0); -#undef FC_PY_ELEMENT -#define FC_PY_ELEMENT(_name,...) do{\ - FC_PY_GetCallable(obj.ptr(),"slot" #_name, py##_name);\ - if(!py##_name.isNone())\ - connect##_name = App::GetApplication().signal##_name.connect(\ - boost::bind(&DocumentObserverPython::slot##_name, this, ##__VA_ARGS__));\ - }while(0); - FC_PY_DOC_OBSERVER +#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 = App::GetApplication().signal##_name2.connect(\ + boost::bind(&DocumentObserverPython::slot##_name1, this, _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 = App::GetApplication().signal##_name2.connect(\ + boost::bind(&DocumentObserverPython::slot##_name1, this, _1, _2));\ + }\ + while(0); + + FC_PY_ELEMENT_ARG1(CreatedDocument, NewDocument) + FC_PY_ELEMENT_ARG1(DeletedDocument, DeleteDocument) + FC_PY_ELEMENT_ARG1(RelabelDocument, RelabelDocument) + FC_PY_ELEMENT_ARG1(ActivateDocument, ActiveDocument) + FC_PY_ELEMENT_ARG1(UndoDocument, UndoDocument) + FC_PY_ELEMENT_ARG1(RedoDocument, RedoDocument) + FC_PY_ELEMENT_ARG2(BeforeChangeDocument, BeforeChangeDocument) + FC_PY_ELEMENT_ARG2(ChangedDocument, ChangedDocument) + FC_PY_ELEMENT_ARG1(CreatedObject, NewObject) + FC_PY_ELEMENT_ARG1(DeletedObject, DeletedObject) + FC_PY_ELEMENT_ARG2(BeforeChangeObject, BeforeChangeObject) + FC_PY_ELEMENT_ARG2(ChangedObject, ChangedObject) + FC_PY_ELEMENT_ARG1(RecomputedObject, ObjectRecomputed) + FC_PY_ELEMENT_ARG1(BeforeRecomputeDocument, BeforeRecomputeDocument) + FC_PY_ELEMENT_ARG1(RecomputedDocument, Recomputed) + FC_PY_ELEMENT_ARG2(OpenTransaction, OpenTransaction) + FC_PY_ELEMENT_ARG1(CommitTransaction, CommitTransaction) + FC_PY_ELEMENT_ARG1(AbortTransaction, AbortTransaction) + FC_PY_ELEMENT_ARG0(Undo, Undo) + FC_PY_ELEMENT_ARG0(Redo, Redo) + FC_PY_ELEMENT_ARG1(BeforeCloseTransaction, BeforeCloseTransaction) + FC_PY_ELEMENT_ARG1(CloseTransaction, CloseTransaction) + FC_PY_ELEMENT_ARG2(StartSaveDocument, StartSaveDocument) + FC_PY_ELEMENT_ARG2(FinishSaveDocument, FinishSaveDocument) + FC_PY_ELEMENT_ARG1(AppendDynamicProperty, AppendDynamicProperty) + FC_PY_ELEMENT_ARG1(RemoveDynamicProperty, RemoveDynamicProperty) + FC_PY_ELEMENT_ARG2(ChangePropertyEditor, ChangePropertyEditor) } DocumentObserverPython::~DocumentObserverPython() { -#undef FC_PY_ELEMENT -#define FC_PY_ELEMENT(_name,...) connect##_name.disconnect(); - FC_PY_DOC_OBSERVER } void DocumentObserverPython::slotCreatedDocument(const App::Document& Doc) diff --git a/src/App/DocumentObserverPython.h b/src/App/DocumentObserverPython.h index eecc761fc5..b1d0411d9d 100644 --- a/src/App/DocumentObserverPython.h +++ b/src/App/DocumentObserverPython.h @@ -110,43 +110,41 @@ private: Py::Object inst; static std::vector _instances; - typedef boost::signals2::connection Connection; -//FIXME: ISO C++11 requires at least one argument for the "..." in a variadic macro -#define FC_PY_DOC_OBSERVER \ - FC_PY_ELEMENT(CreatedDocument,_1) \ - FC_PY_ELEMENT(DeletedDocument,_1) \ - FC_PY_ELEMENT(RelabelDocument,_1) \ - FC_PY_ELEMENT(ActivateDocument,_1) \ - FC_PY_ELEMENT(UndoDocument,_1) \ - FC_PY_ELEMENT(RedoDocument,_1) \ - FC_PY_ELEMENT(BeforeChangeDocument,_1,_2) \ - FC_PY_ELEMENT(ChangedDocument,_1,_2) \ - FC_PY_ELEMENT(CreatedObject,_1) \ - FC_PY_ELEMENT(DeletedObject,_1) \ - FC_PY_ELEMENT(BeforeChangeObject,_1,_2) \ - FC_PY_ELEMENT(ChangedObject,_1,_2) \ - FC_PY_ELEMENT(RecomputedObject,_1) \ - FC_PY_ELEMENT(BeforeRecomputeDocument,_1) \ - FC_PY_ELEMENT(RecomputedDocument,_1) \ - FC_PY_ELEMENT(OpenTransaction,_1,_2) \ - FC_PY_ELEMENT(CommitTransaction,_1) \ - FC_PY_ELEMENT(AbortTransaction,_1) \ - FC_PY_ELEMENT(Undo) \ - FC_PY_ELEMENT(Redo) \ - FC_PY_ELEMENT(BeforeCloseTransaction,_1) \ - FC_PY_ELEMENT(CloseTransaction,_1) \ - FC_PY_ELEMENT(StartSaveDocument,_1,_2) \ - FC_PY_ELEMENT(FinishSaveDocument,_1,_2) \ - FC_PY_ELEMENT(AppendDynamicProperty,_1) \ - FC_PY_ELEMENT(RemoveDynamicProperty,_1) \ - FC_PY_ELEMENT(ChangePropertyEditor,_1,_2) + typedef struct { + boost::signals2::scoped_connection slot; + Py::Object py; + PyObject* ptr() { + return py.ptr(); + } + } Connection; -#undef FC_PY_ELEMENT -#define FC_PY_ELEMENT(_name,...) \ - Connection connect##_name;\ - Py::Object py##_name; - - FC_PY_DOC_OBSERVER + Connection pyCreatedDocument; + Connection pyDeletedDocument; + Connection pyRelabelDocument; + Connection pyActivateDocument; + Connection pyUndoDocument; + Connection pyRedoDocument; + Connection pyBeforeChangeDocument; + Connection pyChangedDocument; + Connection pyCreatedObject; + Connection pyDeletedObject; + Connection pyBeforeChangeObject; + Connection pyChangedObject; + Connection pyRecomputedObject; + Connection pyBeforeRecomputeDocument; + Connection pyRecomputedDocument; + Connection pyOpenTransaction; + Connection pyCommitTransaction; + Connection pyAbortTransaction; + Connection pyUndo; + Connection pyRedo; + Connection pyBeforeCloseTransaction; + Connection pyCloseTransaction; + Connection pyStartSaveDocument; + Connection pyFinishSaveDocument; + Connection pyAppendDynamicProperty; + Connection pyRemoveDynamicProperty; + Connection pyChangePropertyEditor; }; } //namespace App diff --git a/src/App/Link.cpp b/src/App/Link.cpp index a8cc8568e8..90acca1b39 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -36,6 +36,12 @@ #include "ComplexGeoData.h" #include "ComplexGeoDataPy.h" +//FIXME: ISO C++11 requires at least one argument for the "..." in a variadic macro +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" +#endif + FC_LOG_LEVEL_INIT("App::Link", true,true) using namespace App; @@ -1488,3 +1494,8 @@ template<> const char* App::LinkGroupPython::getViewProviderName(void) const { } template class AppExport FeaturePythonT; } + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +