diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index 4e4853a..6528458 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -25,58 +25,62 @@ using namespace MOBase; catch (...) { throw MyException("An unknown exception was thrown in python code"); } +#define COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(class_name) \ +bool class_name::init(MOBase::IOrganizer *moInfo) \ +{ \ + try { \ + return this->get_override("init")(boost::python::ptr(moInfo)); \ + } PYCATCH; \ +} \ + \ +QString class_name::name() const \ +{ \ + try { \ + return this->get_override("name")().as(); \ + } PYCATCH; \ +} \ + \ +QString class_name::author() const \ +{ \ + try { \ + return this->get_override("author")().as(); \ + } PYCATCH; \ +} \ + \ +QString class_name::description() const \ +{ \ + try { \ + return this->get_override("description")().as(); \ + } PYCATCH; \ +} \ + \ +MOBase::VersionInfo class_name::version() const \ +{ \ + try { \ + return this->get_override("version")().as(); \ + } PYCATCH; \ +} \ + \ +bool class_name::isActive() const \ +{ \ + try { \ + return this->get_override("isActive")().as(); \ + } PYCATCH; \ +} \ + \ +QList class_name::settings() const \ +{ \ + try { \ + return this->get_override("settings")().as>(); \ + } PYCATCH; \ +} + +/// end COMMON_I_PLUGIN_WRAPPER_DEFINITIONS ///////////////////////////// /// IPlugin Wrapper -bool IPluginWrapper::init(MOBase::IOrganizer *moInfo) -{ - try { - return this->get_override("init")(boost::python::ptr(moInfo)); - } PYCATCH; -} - -QString IPluginWrapper::name() const -{ - try { - return this->get_override("name")().as(); - } PYCATCH; -} - -QString IPluginWrapper::author() const -{ - try { - return this->get_override("author")().as(); - } PYCATCH; -} - -QString IPluginWrapper::description() const -{ - try { - return this->get_override("description")().as(); - } PYCATCH; -} - -MOBase::VersionInfo IPluginWrapper::version() const -{ - try { - return this->get_override("version")().as(); - } PYCATCH; -} - -bool IPluginWrapper::isActive() const -{ - try { - return this->get_override("isActive")().as(); - } PYCATCH; -} - -QList IPluginWrapper::settings() const -{ - try { - return this->get_override("settings")().as>(); - } PYCATCH; -} +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginWrapper) /// end IPlugin Wrapper ///////////////////////////////////// /// IPluginGame Wrapper @@ -292,54 +296,7 @@ QString IPluginGameWrapper::getLauncherName() const } PYCATCH; } -bool IPluginGameWrapper::init(MOBase::IOrganizer * moInfo) -{ - try { - return this->get_override("init")(boost::python::ptr(moInfo)); - } PYCATCH; -} - -QString IPluginGameWrapper::name() const -{ - try { - return this->get_override("name")(); - } PYCATCH; -} - -QString IPluginGameWrapper::author() const -{ - try { - return this->get_override("author")(); - } PYCATCH; -} - -QString IPluginGameWrapper::description() const -{ - try { - return this->get_override("description")(); - } PYCATCH; -} - -MOBase::VersionInfo IPluginGameWrapper::version() const -{ - try { - return this->get_override("version")(); - } PYCATCH; -} - -bool IPluginGameWrapper::isActive() const -{ - try { - return this->get_override("isActive")(); - } PYCATCH; -} - -QList IPluginGameWrapper::settings() const -{ - try { - return this->get_override("settings")(); - } PYCATCH; -} +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginGameWrapper) std::map IPluginGameWrapper::featureList() const { @@ -353,54 +310,7 @@ std::map IPluginGameWrapper::featureList() const /// IPluginInstallerCustom Wrapper -bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo) -{ - try { - return this->get_override("init")(boost::python::ptr(moInfo)); - } PYCATCH; -} - -QString IPluginInstallerCustomWrapper::name() const -{ - try { - return this->get_override("name")().as(); - } PYCATCH; -} - -QString IPluginInstallerCustomWrapper::author() const -{ - try { - return this->get_override("author")().as(); - } PYCATCH; -} - -QString IPluginInstallerCustomWrapper::description() const -{ - try { - return this->get_override("description")().as(); - } PYCATCH; -} - -MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const -{ - try { - return this->get_override("version")(); - } PYCATCH; -} - -bool IPluginInstallerCustomWrapper::isActive() const -{ - try { - return this->get_override("isActive")(); - } PYCATCH; -} - -QList IPluginInstallerCustomWrapper::settings() const -{ - try { - return this->get_override("settings")().as>(); - } PYCATCH; -} +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginInstallerCustomWrapper) unsigned int IPluginInstallerCustomWrapper::priority() const { @@ -459,54 +369,7 @@ void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent) /// IPluginTool Wrapper -bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo) -{ - try { - return this->get_override("init")(boost::python::ptr(moInfo)); - } PYCATCH; -} - -QString IPluginToolWrapper::name() const -{ - try { - return this->get_override("name")().as(); - } PYCATCH; -} - -QString IPluginToolWrapper::author() const -{ - try { - return this->get_override("author")().as(); - } PYCATCH; -} - -QString IPluginToolWrapper::description() const -{ - try { - return this->get_override("description")().as(); - } PYCATCH; -} - -MOBase::VersionInfo IPluginToolWrapper::version() const -{ - try { - return this->get_override("version")().as(); - } PYCATCH; -} - -bool IPluginToolWrapper::isActive() const -{ - try { - return this->get_override("isActive")().as(); - } PYCATCH; -} - -QList IPluginToolWrapper::settings() const -{ - try { - return this->get_override("settings")().as>(); - } PYCATCH; -} +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginToolWrapper) QString IPluginToolWrapper::displayName() const { diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 01677e3..1060c12 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -12,18 +12,21 @@ #endif +#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS public: \ +virtual bool init(MOBase::IOrganizer *moInfo) override; \ +virtual QString name() const override; \ +virtual QString author() const override; \ +virtual QString description() const override; \ +virtual MOBase::VersionInfo version() const override; \ +virtual bool isActive() const override; \ +virtual QList settings() const override; + + class IPluginWrapper : public MOBase::IPlugin, public boost::python::wrapper { Q_INTERFACES(MOBase::IPlugin) -public: - virtual bool init(MOBase::IOrganizer *moInfo); - virtual QString name() const; - virtual QString author() const; - virtual QString description() const; - virtual MOBase::VersionInfo version() const; - virtual bool isActive() const; - virtual QList settings() const; + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS }; @@ -63,14 +66,7 @@ public: virtual QString gameVersion() const override; virtual QString getLauncherName() const override; - //Plugin interface. Could this bit be implemented just once? - virtual bool init(MOBase::IOrganizer *moInfo) override; - virtual QString name() const override; - virtual QString author() const override; - virtual QString description() const override; - virtual MOBase::VersionInfo version() const override; - virtual bool isActive() const override; - virtual QList settings() const override; + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS protected: @@ -86,15 +82,8 @@ class IPluginInstallerCustomWrapper : public MOBase::IPluginInstallerCustom, pub Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom) + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS public: - virtual bool init(MOBase::IOrganizer *moInfo); - virtual QString name() const; - virtual QString author() const; - virtual QString description() const; - virtual MOBase::VersionInfo version() const; - virtual bool isActive() const; - virtual QList settings() const; - virtual unsigned int priority() const; virtual bool isManualInstaller() const; virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const; @@ -112,15 +101,8 @@ class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrap Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool) + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS public: - virtual bool init(MOBase::IOrganizer *moInfo); - virtual QString name() const; - virtual QString author() const; - virtual QString description() const; - virtual MOBase::VersionInfo version() const; - virtual bool isActive() const; - virtual QList settings() const; - virtual QString displayName() const; virtual QString tooltip() const; virtual QIcon icon() const;