From d4f515ade1f13d3a59e62d409e1e87235ad83911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Thu, 28 Apr 2022 21:38:12 +0200 Subject: [PATCH] Rename runner -> runner-boost. --- src/{runner => runner-boost}/CMakeLists.txt | 0 src/{runner => runner-boost}/converters.h | 0 src/{runner => runner-boost}/error.cpp | 96 +- src/{runner => runner-boost}/error.h | 246 ++--- .../gamefeatureswrappers.cpp | 0 .../gamefeatureswrappers.h | 0 src/{runner => runner-boost}/gilock.cpp | 24 +- src/{runner => runner-boost}/gilock.h | 36 +- .../proxypluginwrappers.cpp | 946 +++++++++--------- .../proxypluginwrappers.h | 536 +++++----- src/{runner => runner-boost}/pylogger.cpp | 0 src/{runner => runner-boost}/pylogger.h | 0 src/{runner => runner-boost}/pythonrunner.cpp | 0 src/{runner => runner-boost}/pythonrunner.h | 66 +- src/{runner => runner-boost}/pythonutils.cpp | 0 src/{runner => runner-boost}/pythonutils.h | 0 .../pythonwrapperutilities.h | 0 .../shared_ptr_converter.h | 0 src/{runner => runner-boost}/sipapiaccess.cpp | 0 src/{runner => runner-boost}/sipapiaccess.h | 0 src/{runner => runner-boost}/tuple_helper.h | 0 src/{runner => runner-boost}/uibasewrappers.h | 0 src/{runner => runner-boost}/variant_helper.h | 0 src/{runner => runner-boost}/widgets.cpp | 0 src/{runner => runner-boost}/widgets.h | 0 25 files changed, 975 insertions(+), 975 deletions(-) rename src/{runner => runner-boost}/CMakeLists.txt (100%) rename src/{runner => runner-boost}/converters.h (100%) rename src/{runner => runner-boost}/error.cpp (95%) rename src/{runner => runner-boost}/error.h (95%) rename src/{runner => runner-boost}/gamefeatureswrappers.cpp (100%) rename src/{runner => runner-boost}/gamefeatureswrappers.h (100%) rename src/{runner => runner-boost}/gilock.cpp (92%) rename src/{runner => runner-boost}/gilock.h (92%) rename src/{runner => runner-boost}/proxypluginwrappers.cpp (97%) rename src/{runner => runner-boost}/proxypluginwrappers.h (97%) rename src/{runner => runner-boost}/pylogger.cpp (100%) rename src/{runner => runner-boost}/pylogger.h (100%) rename src/{runner => runner-boost}/pythonrunner.cpp (100%) rename src/{runner => runner-boost}/pythonrunner.h (94%) rename src/{runner => runner-boost}/pythonutils.cpp (100%) rename src/{runner => runner-boost}/pythonutils.h (100%) rename src/{runner => runner-boost}/pythonwrapperutilities.h (100%) rename src/{runner => runner-boost}/shared_ptr_converter.h (100%) rename src/{runner => runner-boost}/sipapiaccess.cpp (100%) rename src/{runner => runner-boost}/sipapiaccess.h (100%) rename src/{runner => runner-boost}/tuple_helper.h (100%) rename src/{runner => runner-boost}/uibasewrappers.h (100%) rename src/{runner => runner-boost}/variant_helper.h (100%) rename src/{runner => runner-boost}/widgets.cpp (100%) rename src/{runner => runner-boost}/widgets.h (100%) diff --git a/src/runner/CMakeLists.txt b/src/runner-boost/CMakeLists.txt similarity index 100% rename from src/runner/CMakeLists.txt rename to src/runner-boost/CMakeLists.txt diff --git a/src/runner/converters.h b/src/runner-boost/converters.h similarity index 100% rename from src/runner/converters.h rename to src/runner-boost/converters.h diff --git a/src/runner/error.cpp b/src/runner-boost/error.cpp similarity index 95% rename from src/runner/error.cpp rename to src/runner-boost/error.cpp index 7ef6700..2be1906 100644 --- a/src/runner/error.cpp +++ b/src/runner-boost/error.cpp @@ -1,48 +1,48 @@ -#ifndef Q_MOC_RUN -#include -#endif -#include -#include -#include "error.h" - -using namespace MOBase; -namespace bpy = boost::python; - -ErrWrapper & ErrWrapper::instance() -{ - static ErrWrapper err; - return err; -} - -void ErrWrapper::write(const char * message) -{ - buffer << message; - if (buffer.tellp() != 0 && buffer.str().back() == '\n') - { - // actually put the string in a variable so it doesn't get destroyed as soon as we get a pointer to its data - std::string string = buffer.str().substr(0, buffer.str().length() - 1); - qCritical().nospace().noquote() << string.c_str(); - buffer = std::stringstream(); - } - - if (recordingExceptionMessage) - { - lastException << message; - } -} - -void ErrWrapper::startRecordingExceptionMessage() -{ - recordingExceptionMessage = true; - lastException = std::stringstream(); -} - -void ErrWrapper::stopRecordingExceptionMessage() -{ - recordingExceptionMessage = false; -} - -QString ErrWrapper::getLastExceptionMessage() -{ - return QString::fromStdString(lastException.str()); -} +#ifndef Q_MOC_RUN +#include +#endif +#include +#include +#include "error.h" + +using namespace MOBase; +namespace bpy = boost::python; + +ErrWrapper & ErrWrapper::instance() +{ + static ErrWrapper err; + return err; +} + +void ErrWrapper::write(const char * message) +{ + buffer << message; + if (buffer.tellp() != 0 && buffer.str().back() == '\n') + { + // actually put the string in a variable so it doesn't get destroyed as soon as we get a pointer to its data + std::string string = buffer.str().substr(0, buffer.str().length() - 1); + qCritical().nospace().noquote() << string.c_str(); + buffer = std::stringstream(); + } + + if (recordingExceptionMessage) + { + lastException << message; + } +} + +void ErrWrapper::startRecordingExceptionMessage() +{ + recordingExceptionMessage = true; + lastException = std::stringstream(); +} + +void ErrWrapper::stopRecordingExceptionMessage() +{ + recordingExceptionMessage = false; +} + +QString ErrWrapper::getLastExceptionMessage() +{ + return QString::fromStdString(lastException.str()); +} diff --git a/src/runner/error.h b/src/runner-boost/error.h similarity index 95% rename from src/runner/error.h rename to src/runner-boost/error.h index b44bd5b..89d0036 100644 --- a/src/runner/error.h +++ b/src/runner-boost/error.h @@ -1,123 +1,123 @@ -#ifndef ERROR_H -#define ERROR_H - -#include - -#include - -#include -#include - -struct ErrWrapper -{ - static ErrWrapper& instance(); - - void write(const char* message); - - void startRecordingExceptionMessage(); - - void stopRecordingExceptionMessage(); - - QString getLastExceptionMessage(); - - std::stringstream buffer; - bool recordingExceptionMessage; - std::stringstream lastException; -}; - -namespace pyexcept { - - /** - * @brief Exception to throw when a python implementation does not implement - * a pure virtual function. - */ - class MissingImplementation : public MOBase::Exception { - public: - MissingImplementation(std::string const& className, std::string const& methodName) : - Exception(QString::fromStdString( - fmt::format("Python class implementing \"{}\" has no implementation of method \"{}\".", - className, methodName))) { } - - }; - - /** - * @brief Exception to throw when a python error occurs. - */ - class PythonError : public MOBase::Exception { - public: - - /** - * @brief Create a new PythonError, fetching the error message from python. If the message - * cannot be retrieved, `defaultErrorMessage()` is used instead. - */ - PythonError() : Exception(getPythonErrorMessage()) { } - - /** - * @brief Create a new PythonError with the given message. - * - * @param message Message for the exception. - */ - PythonError(QString message) : Exception(message) { } - - protected: - - /** - * - */ - static QString defaultErrorMessage() { - return QObject::tr("An unexpected C++ exception was thrown in python code."); - } - - /** - * - */ - static QString getPythonErrorMessage() { - if (PyErr_Occurred()) { - ErrWrapper& errWrapper = ErrWrapper::instance(); - - errWrapper.startRecordingExceptionMessage(); - PyErr_Print(); - errWrapper.stopRecordingExceptionMessage(); - - return errWrapper.getLastExceptionMessage(); - } - else { - return defaultErrorMessage(); - } - } - }; - - /** - * @brief Exception to throw when an unknown error occured. This is typically thrown - * from a catch(...) block. - */ - class UnknownException : public MOBase::Exception { - public: - - /** - * @brief Create a new UnknownException with the default message. - * - * @see defaultErrorMessage - */ - UnknownException() : Exception(defaultErrorMessage()) { } - - /** - * @brief Create a new UnknownException with the given message. - * - * @param message Message for the exception. - */ - UnknownException(QString message) : Exception(message) { } - - protected: - - /** - * - */ - static QString defaultErrorMessage() { - return QObject::tr("An unknown exception was thrown in python code."); - } - }; - -} - -#endif // ERROR_H +#ifndef ERROR_H +#define ERROR_H + +#include + +#include + +#include +#include + +struct ErrWrapper +{ + static ErrWrapper& instance(); + + void write(const char* message); + + void startRecordingExceptionMessage(); + + void stopRecordingExceptionMessage(); + + QString getLastExceptionMessage(); + + std::stringstream buffer; + bool recordingExceptionMessage; + std::stringstream lastException; +}; + +namespace pyexcept { + + /** + * @brief Exception to throw when a python implementation does not implement + * a pure virtual function. + */ + class MissingImplementation : public MOBase::Exception { + public: + MissingImplementation(std::string const& className, std::string const& methodName) : + Exception(QString::fromStdString( + fmt::format("Python class implementing \"{}\" has no implementation of method \"{}\".", + className, methodName))) { } + + }; + + /** + * @brief Exception to throw when a python error occurs. + */ + class PythonError : public MOBase::Exception { + public: + + /** + * @brief Create a new PythonError, fetching the error message from python. If the message + * cannot be retrieved, `defaultErrorMessage()` is used instead. + */ + PythonError() : Exception(getPythonErrorMessage()) { } + + /** + * @brief Create a new PythonError with the given message. + * + * @param message Message for the exception. + */ + PythonError(QString message) : Exception(message) { } + + protected: + + /** + * + */ + static QString defaultErrorMessage() { + return QObject::tr("An unexpected C++ exception was thrown in python code."); + } + + /** + * + */ + static QString getPythonErrorMessage() { + if (PyErr_Occurred()) { + ErrWrapper& errWrapper = ErrWrapper::instance(); + + errWrapper.startRecordingExceptionMessage(); + PyErr_Print(); + errWrapper.stopRecordingExceptionMessage(); + + return errWrapper.getLastExceptionMessage(); + } + else { + return defaultErrorMessage(); + } + } + }; + + /** + * @brief Exception to throw when an unknown error occured. This is typically thrown + * from a catch(...) block. + */ + class UnknownException : public MOBase::Exception { + public: + + /** + * @brief Create a new UnknownException with the default message. + * + * @see defaultErrorMessage + */ + UnknownException() : Exception(defaultErrorMessage()) { } + + /** + * @brief Create a new UnknownException with the given message. + * + * @param message Message for the exception. + */ + UnknownException(QString message) : Exception(message) { } + + protected: + + /** + * + */ + static QString defaultErrorMessage() { + return QObject::tr("An unknown exception was thrown in python code."); + } + }; + +} + +#endif // ERROR_H diff --git a/src/runner/gamefeatureswrappers.cpp b/src/runner-boost/gamefeatureswrappers.cpp similarity index 100% rename from src/runner/gamefeatureswrappers.cpp rename to src/runner-boost/gamefeatureswrappers.cpp diff --git a/src/runner/gamefeatureswrappers.h b/src/runner-boost/gamefeatureswrappers.h similarity index 100% rename from src/runner/gamefeatureswrappers.h rename to src/runner-boost/gamefeatureswrappers.h diff --git a/src/runner/gilock.cpp b/src/runner-boost/gilock.cpp similarity index 92% rename from src/runner/gilock.cpp rename to src/runner-boost/gilock.cpp index fb63387..8543935 100644 --- a/src/runner/gilock.cpp +++ b/src/runner-boost/gilock.cpp @@ -1,12 +1,12 @@ -#include "gilock.h" - -GILock::GILock() -{ - m_State = PyGILState_Ensure(); -} - -GILock::~GILock() -{ - PyErr_Clear(); - PyGILState_Release(m_State); -} +#include "gilock.h" + +GILock::GILock() +{ + m_State = PyGILState_Ensure(); +} + +GILock::~GILock() +{ + PyErr_Clear(); + PyGILState_Release(m_State); +} diff --git a/src/runner/gilock.h b/src/runner-boost/gilock.h similarity index 92% rename from src/runner/gilock.h rename to src/runner-boost/gilock.h index 560e29a..c2425a6 100644 --- a/src/runner/gilock.h +++ b/src/runner-boost/gilock.h @@ -1,18 +1,18 @@ -#ifndef GILOCK_H -#define GILOCK_H - - -#ifndef Q_MOC_RUN -#include -#endif // Q_MOC_RUN - -class GILock { -public: - GILock(); - ~GILock(); -private: - PyGILState_STATE m_State; -}; - - -#endif // GILOCK_H +#ifndef GILOCK_H +#define GILOCK_H + + +#ifndef Q_MOC_RUN +#include +#endif // Q_MOC_RUN + +class GILock { +public: + GILock(); + ~GILock(); +private: + PyGILState_STATE m_State; +}; + + +#endif // GILOCK_H diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner-boost/proxypluginwrappers.cpp similarity index 97% rename from src/runner/proxypluginwrappers.cpp rename to src/runner-boost/proxypluginwrappers.cpp index 52f1c3b..bb64065 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner-boost/proxypluginwrappers.cpp @@ -1,473 +1,473 @@ -#include "proxypluginwrappers.h" - -#include "gilock.h" -#include -#include - -#include "shared_ptr_converter.h" -#include "pythonwrapperutilities.h" -#include "uibasewrappers.h" - -#include -#include - -namespace boost -{ - // See bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624 -#if (_MSC_VER == 1900) - template<> const volatile MOBase::IOrganizer* get_pointer(const volatile MOBase::IOrganizer* p) { return p; } - template<> const volatile MOBase::IModInterface* get_pointer(const volatile MOBase::IModInterface* p) { return p; } - template<> const volatile MOBase::IPluginGame* get_pointer(const volatile MOBase::IPluginGame* p) { return p; } - template<> const volatile MOBase::IProfile* get_pointer(const volatile MOBase::IProfile* p) { return p; } - template<> const volatile MOBase::IModList* get_pointer(const volatile MOBase::IModList* p) { return p; } - template<> const volatile MOBase::IPluginList* get_pointer(const volatile MOBase::IPluginList* p) { return p; } - template<> const volatile MOBase::IDownloadManager* get_pointer(const volatile MOBase::IDownloadManager* p) { return p; } - template<> const volatile MOBase::IModRepositoryBridge* get_pointer(const volatile MOBase::IModRepositoryBridge* p) { return p; } -#endif -} - -using namespace MOBase; - -// See COMMON_I_PLUGIN_WRAPPER_DECLARATIONS__IMPL in proxypluginwrappers.h for explanation on -// the "include_requirements". -#define COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(class_name, include_requirements) \ -bool class_name::init(MOBase::IOrganizer *moInfo) \ -{ \ - return basicWrapperFunctionImplementation(this, "init", boost::python::ptr(moInfo)); \ -} \ - \ -QString class_name::name() const \ -{ \ - return basicWrapperFunctionImplementation(this, "name"); \ -} \ - \ -QString class_name::localizedName() const \ -{ \ - return basicWrapperFunctionImplementationWithDefault(this, &class_name::localizedName_Default, "localizedName"); \ -} \ - \ -QString class_name::master() const \ -{ \ - return basicWrapperFunctionImplementationWithDefault(this, &class_name::master_Default, "master"); \ -} \ - \ -QString class_name::author() const \ -{ \ - return basicWrapperFunctionImplementation(this, "author"); \ -} \ - \ -QString class_name::description() const \ -{ \ - return basicWrapperFunctionImplementation(this, "description"); \ -} \ - \ -MOBase::VersionInfo class_name::version() const \ -{ \ - return basicWrapperFunctionImplementation(this, "version"); \ -} \ - \ -QList class_name::settings() const \ -{ \ - return basicWrapperFunctionImplementation>(this, "settings"); \ -} \ -QString class_name::localizedName_Default() const { return IPlugin::localizedName(); } \ -QString class_name::master_Default() const { return IPlugin::master(); } \ -BOOST_PP_EXPR_IF(include_requirements, \ - std::vector> class_name::requirements() const { \ - return basicWrapperFunctionImplementationWithDefault>>( \ - this, &class_name::requirements_Default, "requirements"); \ - } \ - std::vector> class_name::requirements_Default() const { return IPlugin::requirements(); } \ - bool class_name::enabledByDefault() const \ - { \ - return basicWrapperFunctionImplementationWithDefault(this, &class_name::enabledByDefault_Default, "enabledByDefault"); \ - } \ - bool class_name::enabledByDefault_Default() const { return IPlugin::enabledByDefault(); }) - -#define COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(class_name) COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(class_name, 1) - -/// end COMMON_I_PLUGIN_WRAPPER_DEFINITIONS -///////////////////////////// -/// IPlugin Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginWrapper) -/// end IPlugin Wrapper -///////////////////////////////////// -/// IPluginDiagnose Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginDiagnoseWrapper) - -std::vector IPluginDiagnoseWrapper::activeProblems() const -{ - return basicWrapperFunctionImplementation>(this, "activeProblems"); -} - -QString IPluginDiagnoseWrapper::shortDescription(unsigned int key) const -{ - return basicWrapperFunctionImplementation(this, "shortDescription", key); -} - -QString IPluginDiagnoseWrapper::fullDescription(unsigned int key) const -{ - return basicWrapperFunctionImplementation(this, "fullDescription", key); -} - -bool IPluginDiagnoseWrapper::hasGuidedFix(unsigned int key) const -{ - return basicWrapperFunctionImplementation(this, "hasGuidedFix", key); -} - -void IPluginDiagnoseWrapper::startGuidedFix(unsigned int key) const -{ - basicWrapperFunctionImplementation(this, "startGuidedFix", key); -} - -/// end IPluginDiagnose Wrapper -///////////////////////////////////// -/// IPluginFileMapper Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginFileMapperWrapper) - -MappingType IPluginFileMapperWrapper::mappings() const -{ - return basicWrapperFunctionImplementation(this, "mappings"); -} -/// end IPluginFileMapper Wrapper -///////////////////////////////////// -/// IPluginGame Wrapper - -void IPluginGameWrapper::detectGame() -{ - return basicWrapperFunctionImplementation(this, "detectGame"); -} - -QString IPluginGameWrapper::gameName() const -{ - return basicWrapperFunctionImplementation(this, "gameName"); -} - -void IPluginGameWrapper::initializeProfile(const QDir & directory, ProfileSettings settings) const -{ - basicWrapperFunctionImplementation(this, "initializeProfile", directory, settings); -} - -std::vector> IPluginGameWrapper::listSaves(QDir folder) const -{ - // Why do I not need to hold python references here? Is it because those are wrapped - // in shared_ptr? - return basicWrapperFunctionImplementation>>(this, "listSaves", folder); -} - -bool IPluginGameWrapper::isInstalled() const -{ - return basicWrapperFunctionImplementation(this, "isInstalled"); -} - -QIcon IPluginGameWrapper::gameIcon() const -{ - return basicWrapperFunctionImplementation(this, "gameIcon"); -} - -QDir IPluginGameWrapper::gameDirectory() const -{ - return basicWrapperFunctionImplementation(this, "gameDirectory"); -} - -QDir IPluginGameWrapper::dataDirectory() const -{ - return basicWrapperFunctionImplementation(this, "dataDirectory"); -} - -void IPluginGameWrapper::setGamePath(const QString & path) -{ - basicWrapperFunctionImplementation(this, "setGamePath", path); -} - -QDir IPluginGameWrapper::documentsDirectory() const -{ - return basicWrapperFunctionImplementation(this, "documentsDirectory"); -} - -QDir IPluginGameWrapper::savesDirectory() const -{ - return basicWrapperFunctionImplementation(this, "savesDirectory"); -} - -QList IPluginGameWrapper::executables() const -{ - return basicWrapperFunctionImplementation>(this, "executables"); -} - -QList IPluginGameWrapper::executableForcedLoads() const -{ - return basicWrapperFunctionImplementation>(this, "executableForcedLoads"); -} - -QString IPluginGameWrapper::steamAPPId() const -{ - return basicWrapperFunctionImplementation(this, "steamAPPId"); -} - -QStringList IPluginGameWrapper::primaryPlugins() const -{ - return basicWrapperFunctionImplementation(this, "primaryPlugins"); -} - -QStringList IPluginGameWrapper::gameVariants() const -{ - return basicWrapperFunctionImplementation(this, "gameVariants"); -} - -void IPluginGameWrapper::setGameVariant(const QString & variant) -{ - basicWrapperFunctionImplementation(this, "setGameVariant", variant); -} - -QString IPluginGameWrapper::binaryName() const -{ - return basicWrapperFunctionImplementation(this, "binaryName"); -} - -QString IPluginGameWrapper::gameShortName() const -{ - return basicWrapperFunctionImplementation(this, "gameShortName"); -} - -QStringList IPluginGameWrapper::primarySources() const -{ - return basicWrapperFunctionImplementation(this, "primarySources"); -} - -QStringList IPluginGameWrapper::validShortNames() const -{ - return basicWrapperFunctionImplementation(this, "validShortNames"); -} - -QString IPluginGameWrapper::gameNexusName() const -{ - return basicWrapperFunctionImplementation(this, "gameNexusName"); -} - -QStringList IPluginGameWrapper::iniFiles() const -{ - return basicWrapperFunctionImplementation(this, "iniFiles"); -} - -QStringList IPluginGameWrapper::DLCPlugins() const -{ - return basicWrapperFunctionImplementation(this, "DLCPlugins"); -} - -QStringList IPluginGameWrapper::CCPlugins() const -{ - return basicWrapperFunctionImplementation(this, "CCPlugins"); -} - -IPluginGame::LoadOrderMechanism IPluginGameWrapper::loadOrderMechanism() const -{ - return basicWrapperFunctionImplementation(this, "loadOrderMechanism"); -} - -IPluginGame::SortMechanism IPluginGameWrapper::sortMechanism() const -{ - return basicWrapperFunctionImplementation(this, "sortMechanism"); -} - -int IPluginGameWrapper::nexusModOrganizerID() const -{ - return basicWrapperFunctionImplementation(this, "nexusModOrganizerID"); -} - -int IPluginGameWrapper::nexusGameID() const -{ - return basicWrapperFunctionImplementation(this, "nexusGameID"); -} - -bool IPluginGameWrapper::looksValid(QDir const & dir) const -{ - return basicWrapperFunctionImplementation(this, "looksValid", dir); -} - -QString IPluginGameWrapper::gameVersion() const -{ - return basicWrapperFunctionImplementation(this, "gameVersion"); -} - -QString IPluginGameWrapper::getLauncherName() const -{ - return basicWrapperFunctionImplementation(this, "getLauncherName"); -} - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(IPluginGameWrapper, 0) - -std::map IPluginGameWrapper::featureList() const -{ - return basicWrapperFunctionImplementation>(this, "_featureList"); -} -/// end IPluginGame Wrapper -///////////////////////////////////// -/// IPluginInstaller macro - -#define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(class_name) \ -unsigned int class_name::priority() const { return basicWrapperFunctionImplementation(this, "priority"); } \ -bool class_name::isManualInstaller() const { return basicWrapperFunctionImplementation(this, "isManualInstaller"); } \ -void class_name::onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ - basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationStart_Default, "onInstallationStart", archive, reinstallation, boost::python::ptr(currentMod)); } \ -void class_name::onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) { \ - basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationEnd_Default, "onInstallationEnd", result, boost::python::ptr(newMod)); } \ -bool class_name::isArchiveSupported(std::shared_ptr tree) const { return basicWrapperFunctionImplementation(this, "isArchiveSupported", tree); } - -/// end IPluginInstaller macro -///////////////////////////////////// -/// IPluginInstaller Wrapper - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginInstallerSimpleWrapper) -COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(IPluginInstallerSimpleWrapper) - -IPluginInstaller::EInstallResult IPluginInstallerSimpleWrapper::install( - GuessedValue& modName, std::shared_ptr& tree, - QString& version, int& nexusID) -{ - namespace bpy = boost::python; - - using return_type = std::variant< - IPluginInstaller::EInstallResult, - std::shared_ptr, - std::tuple, QString, int>>; - auto ret = basicWrapperFunctionImplementation(this, "install", boost::ref(modName), tree, version, nexusID); - - auto result = std::visit([&](auto const& t) { - using type = std::decay_t; - if constexpr (std::is_same_v) { - return t; - } - else if constexpr (std::is_same_v>) { - tree = t; - return IPluginInstaller::RESULT_SUCCESS; - } - else if constexpr (std::is_same_v, QString, int>>) { - tree = std::get<1>(t); - version = std::get<2>(t); - nexusID = std::get<3>(t); - return std::get<0>(t); - } - }, ret); - - tree = utils::clean_shared_ptr(tree); - return result; -} - -/// end IPluginInstallerSimple Wrapper -///////////////////////////////////// -/// IPluginInstallerCustom Wrapper -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginInstallerCustomWrapper) -COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(IPluginInstallerCustomWrapper) - -bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const -{ - return basicWrapperFunctionImplementation(this, "isArchiveSupported", archiveName); -} - -std::set IPluginInstallerCustomWrapper::supportedExtensions() const -{ - return basicWrapperFunctionImplementation>(this, "supportedExtensions"); -} - -IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install( - GuessedValue &modName, QString gameName, const QString &archiveName, const QString &version, int modID) -{ - // Note: This requires far more less trouble than the "Simple" installer version since 1) there is no tree - // and 2) there version and modId cannot be modified: - return basicWrapperFunctionImplementation( - this, "install", boost::ref(modName), gameName, archiveName, version, modID); -} - -/// end IPluginInstallerCustom Wrapper -///////////////////////////// -/// IPluginModPage Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginModPageWrapper) - -QString IPluginModPageWrapper::displayName() const -{ - return basicWrapperFunctionImplementation(this, "displayName"); -} - -QIcon IPluginModPageWrapper::icon() const -{ - return basicWrapperFunctionImplementation(this, "icon"); -} - -QUrl IPluginModPageWrapper::pageURL() const -{ - return basicWrapperFunctionImplementation(this, "pageURL"); -} - -bool IPluginModPageWrapper::useIntegratedBrowser() const -{ - return basicWrapperFunctionImplementation(this, "useIntegratedBrowser"); -} - -bool IPluginModPageWrapper::handlesDownload(const QUrl & pageURL, const QUrl & downloadURL, MOBase::ModRepositoryFileInfo & fileInfo) const -{ - return basicWrapperFunctionImplementation(this, "handlesDownload", pageURL, downloadURL, fileInfo); -} - -void IPluginModPageWrapper::setParentWidget(QWidget * widget) -{ - basicWrapperFunctionImplementationWithDefault(this, &IPluginModPageWrapper::setParentWidget_Default, "setParentWidget", widget); -} -/// end IPluginModPage Wrapper -///////////////////////////// -/// IPluginPreview Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginPreviewWrapper) - -std::set IPluginPreviewWrapper::supportedExtensions() const -{ - return basicWrapperFunctionImplementation>(this, "supportedExtensions"); -} - -QWidget *IPluginPreviewWrapper::genFilePreview(const QString &fileName, const QSize &maxSize) const -{ - // We need responsibility for deleting the QWidget to be transferred to C++: - return wrapperFunctionImplementationWithApiTransfer(this, "genFilePreview", fileName, maxSize); -} -/// end IPluginPreview Wrapper -///////////////////////////// -/// IPluginTool Wrapper - - -COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginToolWrapper) - -QString IPluginToolWrapper::displayName() const -{ - return basicWrapperFunctionImplementation(this, "displayName"); -} - -QString IPluginToolWrapper::tooltip() const -{ - return basicWrapperFunctionImplementation(this, "tooltip"); -} - -QIcon IPluginToolWrapper::icon() const -{ - return basicWrapperFunctionImplementation(this, "icon"); -} - -void IPluginToolWrapper::setParentWidget(QWidget *parent) -{ - basicWrapperFunctionImplementationWithDefault(this, &IPluginToolWrapper::setParentWidget_Default, "setParentWidget", parent); -} - -void IPluginToolWrapper::display() const -{ - basicWrapperFunctionImplementation(this, "display"); -} - -/// end IPluginTool Wrapper +#include "proxypluginwrappers.h" + +#include "gilock.h" +#include +#include + +#include "shared_ptr_converter.h" +#include "pythonwrapperutilities.h" +#include "uibasewrappers.h" + +#include +#include + +namespace boost +{ + // See bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624 +#if (_MSC_VER == 1900) + template<> const volatile MOBase::IOrganizer* get_pointer(const volatile MOBase::IOrganizer* p) { return p; } + template<> const volatile MOBase::IModInterface* get_pointer(const volatile MOBase::IModInterface* p) { return p; } + template<> const volatile MOBase::IPluginGame* get_pointer(const volatile MOBase::IPluginGame* p) { return p; } + template<> const volatile MOBase::IProfile* get_pointer(const volatile MOBase::IProfile* p) { return p; } + template<> const volatile MOBase::IModList* get_pointer(const volatile MOBase::IModList* p) { return p; } + template<> const volatile MOBase::IPluginList* get_pointer(const volatile MOBase::IPluginList* p) { return p; } + template<> const volatile MOBase::IDownloadManager* get_pointer(const volatile MOBase::IDownloadManager* p) { return p; } + template<> const volatile MOBase::IModRepositoryBridge* get_pointer(const volatile MOBase::IModRepositoryBridge* p) { return p; } +#endif +} + +using namespace MOBase; + +// See COMMON_I_PLUGIN_WRAPPER_DECLARATIONS__IMPL in proxypluginwrappers.h for explanation on +// the "include_requirements". +#define COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(class_name, include_requirements) \ +bool class_name::init(MOBase::IOrganizer *moInfo) \ +{ \ + return basicWrapperFunctionImplementation(this, "init", boost::python::ptr(moInfo)); \ +} \ + \ +QString class_name::name() const \ +{ \ + return basicWrapperFunctionImplementation(this, "name"); \ +} \ + \ +QString class_name::localizedName() const \ +{ \ + return basicWrapperFunctionImplementationWithDefault(this, &class_name::localizedName_Default, "localizedName"); \ +} \ + \ +QString class_name::master() const \ +{ \ + return basicWrapperFunctionImplementationWithDefault(this, &class_name::master_Default, "master"); \ +} \ + \ +QString class_name::author() const \ +{ \ + return basicWrapperFunctionImplementation(this, "author"); \ +} \ + \ +QString class_name::description() const \ +{ \ + return basicWrapperFunctionImplementation(this, "description"); \ +} \ + \ +MOBase::VersionInfo class_name::version() const \ +{ \ + return basicWrapperFunctionImplementation(this, "version"); \ +} \ + \ +QList class_name::settings() const \ +{ \ + return basicWrapperFunctionImplementation>(this, "settings"); \ +} \ +QString class_name::localizedName_Default() const { return IPlugin::localizedName(); } \ +QString class_name::master_Default() const { return IPlugin::master(); } \ +BOOST_PP_EXPR_IF(include_requirements, \ + std::vector> class_name::requirements() const { \ + return basicWrapperFunctionImplementationWithDefault>>( \ + this, &class_name::requirements_Default, "requirements"); \ + } \ + std::vector> class_name::requirements_Default() const { return IPlugin::requirements(); } \ + bool class_name::enabledByDefault() const \ + { \ + return basicWrapperFunctionImplementationWithDefault(this, &class_name::enabledByDefault_Default, "enabledByDefault"); \ + } \ + bool class_name::enabledByDefault_Default() const { return IPlugin::enabledByDefault(); }) + +#define COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(class_name) COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(class_name, 1) + +/// end COMMON_I_PLUGIN_WRAPPER_DEFINITIONS +///////////////////////////// +/// IPlugin Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginWrapper) +/// end IPlugin Wrapper +///////////////////////////////////// +/// IPluginDiagnose Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginDiagnoseWrapper) + +std::vector IPluginDiagnoseWrapper::activeProblems() const +{ + return basicWrapperFunctionImplementation>(this, "activeProblems"); +} + +QString IPluginDiagnoseWrapper::shortDescription(unsigned int key) const +{ + return basicWrapperFunctionImplementation(this, "shortDescription", key); +} + +QString IPluginDiagnoseWrapper::fullDescription(unsigned int key) const +{ + return basicWrapperFunctionImplementation(this, "fullDescription", key); +} + +bool IPluginDiagnoseWrapper::hasGuidedFix(unsigned int key) const +{ + return basicWrapperFunctionImplementation(this, "hasGuidedFix", key); +} + +void IPluginDiagnoseWrapper::startGuidedFix(unsigned int key) const +{ + basicWrapperFunctionImplementation(this, "startGuidedFix", key); +} + +/// end IPluginDiagnose Wrapper +///////////////////////////////////// +/// IPluginFileMapper Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginFileMapperWrapper) + +MappingType IPluginFileMapperWrapper::mappings() const +{ + return basicWrapperFunctionImplementation(this, "mappings"); +} +/// end IPluginFileMapper Wrapper +///////////////////////////////////// +/// IPluginGame Wrapper + +void IPluginGameWrapper::detectGame() +{ + return basicWrapperFunctionImplementation(this, "detectGame"); +} + +QString IPluginGameWrapper::gameName() const +{ + return basicWrapperFunctionImplementation(this, "gameName"); +} + +void IPluginGameWrapper::initializeProfile(const QDir & directory, ProfileSettings settings) const +{ + basicWrapperFunctionImplementation(this, "initializeProfile", directory, settings); +} + +std::vector> IPluginGameWrapper::listSaves(QDir folder) const +{ + // Why do I not need to hold python references here? Is it because those are wrapped + // in shared_ptr? + return basicWrapperFunctionImplementation>>(this, "listSaves", folder); +} + +bool IPluginGameWrapper::isInstalled() const +{ + return basicWrapperFunctionImplementation(this, "isInstalled"); +} + +QIcon IPluginGameWrapper::gameIcon() const +{ + return basicWrapperFunctionImplementation(this, "gameIcon"); +} + +QDir IPluginGameWrapper::gameDirectory() const +{ + return basicWrapperFunctionImplementation(this, "gameDirectory"); +} + +QDir IPluginGameWrapper::dataDirectory() const +{ + return basicWrapperFunctionImplementation(this, "dataDirectory"); +} + +void IPluginGameWrapper::setGamePath(const QString & path) +{ + basicWrapperFunctionImplementation(this, "setGamePath", path); +} + +QDir IPluginGameWrapper::documentsDirectory() const +{ + return basicWrapperFunctionImplementation(this, "documentsDirectory"); +} + +QDir IPluginGameWrapper::savesDirectory() const +{ + return basicWrapperFunctionImplementation(this, "savesDirectory"); +} + +QList IPluginGameWrapper::executables() const +{ + return basicWrapperFunctionImplementation>(this, "executables"); +} + +QList IPluginGameWrapper::executableForcedLoads() const +{ + return basicWrapperFunctionImplementation>(this, "executableForcedLoads"); +} + +QString IPluginGameWrapper::steamAPPId() const +{ + return basicWrapperFunctionImplementation(this, "steamAPPId"); +} + +QStringList IPluginGameWrapper::primaryPlugins() const +{ + return basicWrapperFunctionImplementation(this, "primaryPlugins"); +} + +QStringList IPluginGameWrapper::gameVariants() const +{ + return basicWrapperFunctionImplementation(this, "gameVariants"); +} + +void IPluginGameWrapper::setGameVariant(const QString & variant) +{ + basicWrapperFunctionImplementation(this, "setGameVariant", variant); +} + +QString IPluginGameWrapper::binaryName() const +{ + return basicWrapperFunctionImplementation(this, "binaryName"); +} + +QString IPluginGameWrapper::gameShortName() const +{ + return basicWrapperFunctionImplementation(this, "gameShortName"); +} + +QStringList IPluginGameWrapper::primarySources() const +{ + return basicWrapperFunctionImplementation(this, "primarySources"); +} + +QStringList IPluginGameWrapper::validShortNames() const +{ + return basicWrapperFunctionImplementation(this, "validShortNames"); +} + +QString IPluginGameWrapper::gameNexusName() const +{ + return basicWrapperFunctionImplementation(this, "gameNexusName"); +} + +QStringList IPluginGameWrapper::iniFiles() const +{ + return basicWrapperFunctionImplementation(this, "iniFiles"); +} + +QStringList IPluginGameWrapper::DLCPlugins() const +{ + return basicWrapperFunctionImplementation(this, "DLCPlugins"); +} + +QStringList IPluginGameWrapper::CCPlugins() const +{ + return basicWrapperFunctionImplementation(this, "CCPlugins"); +} + +IPluginGame::LoadOrderMechanism IPluginGameWrapper::loadOrderMechanism() const +{ + return basicWrapperFunctionImplementation(this, "loadOrderMechanism"); +} + +IPluginGame::SortMechanism IPluginGameWrapper::sortMechanism() const +{ + return basicWrapperFunctionImplementation(this, "sortMechanism"); +} + +int IPluginGameWrapper::nexusModOrganizerID() const +{ + return basicWrapperFunctionImplementation(this, "nexusModOrganizerID"); +} + +int IPluginGameWrapper::nexusGameID() const +{ + return basicWrapperFunctionImplementation(this, "nexusGameID"); +} + +bool IPluginGameWrapper::looksValid(QDir const & dir) const +{ + return basicWrapperFunctionImplementation(this, "looksValid", dir); +} + +QString IPluginGameWrapper::gameVersion() const +{ + return basicWrapperFunctionImplementation(this, "gameVersion"); +} + +QString IPluginGameWrapper::getLauncherName() const +{ + return basicWrapperFunctionImplementation(this, "getLauncherName"); +} + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS_IMPL(IPluginGameWrapper, 0) + +std::map IPluginGameWrapper::featureList() const +{ + return basicWrapperFunctionImplementation>(this, "_featureList"); +} +/// end IPluginGame Wrapper +///////////////////////////////////// +/// IPluginInstaller macro + +#define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(class_name) \ +unsigned int class_name::priority() const { return basicWrapperFunctionImplementation(this, "priority"); } \ +bool class_name::isManualInstaller() const { return basicWrapperFunctionImplementation(this, "isManualInstaller"); } \ +void class_name::onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ + basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationStart_Default, "onInstallationStart", archive, reinstallation, boost::python::ptr(currentMod)); } \ +void class_name::onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) { \ + basicWrapperFunctionImplementationWithDefault(this, &class_name::onInstallationEnd_Default, "onInstallationEnd", result, boost::python::ptr(newMod)); } \ +bool class_name::isArchiveSupported(std::shared_ptr tree) const { return basicWrapperFunctionImplementation(this, "isArchiveSupported", tree); } + +/// end IPluginInstaller macro +///////////////////////////////////// +/// IPluginInstaller Wrapper + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginInstallerSimpleWrapper) +COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(IPluginInstallerSimpleWrapper) + +IPluginInstaller::EInstallResult IPluginInstallerSimpleWrapper::install( + GuessedValue& modName, std::shared_ptr& tree, + QString& version, int& nexusID) +{ + namespace bpy = boost::python; + + using return_type = std::variant< + IPluginInstaller::EInstallResult, + std::shared_ptr, + std::tuple, QString, int>>; + auto ret = basicWrapperFunctionImplementation(this, "install", boost::ref(modName), tree, version, nexusID); + + auto result = std::visit([&](auto const& t) { + using type = std::decay_t; + if constexpr (std::is_same_v) { + return t; + } + else if constexpr (std::is_same_v>) { + tree = t; + return IPluginInstaller::RESULT_SUCCESS; + } + else if constexpr (std::is_same_v, QString, int>>) { + tree = std::get<1>(t); + version = std::get<2>(t); + nexusID = std::get<3>(t); + return std::get<0>(t); + } + }, ret); + + tree = utils::clean_shared_ptr(tree); + return result; +} + +/// end IPluginInstallerSimple Wrapper +///////////////////////////////////// +/// IPluginInstallerCustom Wrapper +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginInstallerCustomWrapper) +COMMON_I_PLUGIN_INSTALLER_WRAPPER_DEFINITIONS(IPluginInstallerCustomWrapper) + +bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const +{ + return basicWrapperFunctionImplementation(this, "isArchiveSupported", archiveName); +} + +std::set IPluginInstallerCustomWrapper::supportedExtensions() const +{ + return basicWrapperFunctionImplementation>(this, "supportedExtensions"); +} + +IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install( + GuessedValue &modName, QString gameName, const QString &archiveName, const QString &version, int modID) +{ + // Note: This requires far more less trouble than the "Simple" installer version since 1) there is no tree + // and 2) there version and modId cannot be modified: + return basicWrapperFunctionImplementation( + this, "install", boost::ref(modName), gameName, archiveName, version, modID); +} + +/// end IPluginInstallerCustom Wrapper +///////////////////////////// +/// IPluginModPage Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginModPageWrapper) + +QString IPluginModPageWrapper::displayName() const +{ + return basicWrapperFunctionImplementation(this, "displayName"); +} + +QIcon IPluginModPageWrapper::icon() const +{ + return basicWrapperFunctionImplementation(this, "icon"); +} + +QUrl IPluginModPageWrapper::pageURL() const +{ + return basicWrapperFunctionImplementation(this, "pageURL"); +} + +bool IPluginModPageWrapper::useIntegratedBrowser() const +{ + return basicWrapperFunctionImplementation(this, "useIntegratedBrowser"); +} + +bool IPluginModPageWrapper::handlesDownload(const QUrl & pageURL, const QUrl & downloadURL, MOBase::ModRepositoryFileInfo & fileInfo) const +{ + return basicWrapperFunctionImplementation(this, "handlesDownload", pageURL, downloadURL, fileInfo); +} + +void IPluginModPageWrapper::setParentWidget(QWidget * widget) +{ + basicWrapperFunctionImplementationWithDefault(this, &IPluginModPageWrapper::setParentWidget_Default, "setParentWidget", widget); +} +/// end IPluginModPage Wrapper +///////////////////////////// +/// IPluginPreview Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginPreviewWrapper) + +std::set IPluginPreviewWrapper::supportedExtensions() const +{ + return basicWrapperFunctionImplementation>(this, "supportedExtensions"); +} + +QWidget *IPluginPreviewWrapper::genFilePreview(const QString &fileName, const QSize &maxSize) const +{ + // We need responsibility for deleting the QWidget to be transferred to C++: + return wrapperFunctionImplementationWithApiTransfer(this, "genFilePreview", fileName, maxSize); +} +/// end IPluginPreview Wrapper +///////////////////////////// +/// IPluginTool Wrapper + + +COMMON_I_PLUGIN_WRAPPER_DEFINITIONS(IPluginToolWrapper) + +QString IPluginToolWrapper::displayName() const +{ + return basicWrapperFunctionImplementation(this, "displayName"); +} + +QString IPluginToolWrapper::tooltip() const +{ + return basicWrapperFunctionImplementation(this, "tooltip"); +} + +QIcon IPluginToolWrapper::icon() const +{ + return basicWrapperFunctionImplementation(this, "icon"); +} + +void IPluginToolWrapper::setParentWidget(QWidget *parent) +{ + basicWrapperFunctionImplementationWithDefault(this, &IPluginToolWrapper::setParentWidget_Default, "setParentWidget", parent); +} + +void IPluginToolWrapper::display() const +{ + basicWrapperFunctionImplementation(this, "display"); +} + +/// end IPluginTool Wrapper diff --git a/src/runner/proxypluginwrappers.h b/src/runner-boost/proxypluginwrappers.h similarity index 97% rename from src/runner/proxypluginwrappers.h rename to src/runner-boost/proxypluginwrappers.h index ccf18b7..524adde 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner-boost/proxypluginwrappers.h @@ -1,268 +1,268 @@ -#ifndef PROXYPLUGINWRAPPERS_H -#define PROXYPLUGINWRAPPERS_H - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef Q_MOC_RUN -#include -#include -#endif - -// The wrapper for IPluginGame cannot override requirements or enabledByDefault since they're final, -// so we need to be able to exclude the declarations. -#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(include_requirements) \ -public: \ -virtual bool init(MOBase::IOrganizer *moInfo) override; \ -virtual QString name() const override; \ -virtual QString localizedName() const override; \ -virtual QString master() const override; \ -virtual QString author() const override; \ -virtual QString description() const override; \ -virtual MOBase::VersionInfo version() const override; \ -virtual QList settings() const override; \ -QString localizedName_Default() const; \ -QString master_Default() const; \ -BOOST_PP_EXPR_IF(include_requirements, \ - virtual std::vector> requirements() const override; \ - std::vector> requirements_Default() const; \ - virtual bool enabledByDefault() const override; \ - bool enabledByDefault_Default() const;) - -#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(1) - -// Even though the base interface is not a QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. -// QObject must be the first base class because moc assumes the first base class is a QObject -class IPluginWrapper : public QObject, public MOBase::IPlugin, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -public: - static constexpr const char* className = "IPluginWrapper"; - using boost::python::wrapper::get_override; -}; - - -// Even though the base interface is not an IPlugin or QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. -// QObject must be the first base class because moc assumes the first base class is a QObject -class IPluginDiagnoseWrapper : public QObject, public MOBase::IPluginDiagnose, public MOBase::IPlugin, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginDiagnose) - -public: - static constexpr const char* className = "IPluginDiagnoseWrapper"; - using boost::python::wrapper::get_override; - - // Bring in public scope: - using IPluginDiagnose::invalidate; - - virtual std::vector activeProblems() const override; - virtual QString shortDescription(unsigned int key) const override; - virtual QString fullDescription(unsigned int key) const override; - virtual bool hasGuidedFix(unsigned int key) const override; - virtual void startGuidedFix(unsigned int key) const override; - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -}; - - -// Even though the base interface is not an IPlugin or QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. -// QObject must be the first base class because moc assumes the first base class is a QObject -class IPluginFileMapperWrapper : public QObject, public MOBase::IPluginFileMapper, public MOBase::IPlugin, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginFileMapper) - -public: - static constexpr const char* className = "IPluginFileMapperWrapper"; - using boost::python::wrapper::get_override; - - virtual MappingType mappings() const override; - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -}; - - -class IPluginGameWrapper : public MOBase::IPluginGame, public boost::python::wrapper { - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginGame) - -public: - static constexpr const char* className = "IPluginGameWrapper"; - using boost::python::wrapper::get_override; - - virtual void detectGame() override; - virtual QString gameName() const override; - virtual void initializeProfile(const QDir &directory, ProfileSettings settings) const override; - virtual std::vector> listSaves(QDir folder) const override; - virtual bool isInstalled() const override; - virtual QIcon gameIcon() const override; - virtual QDir gameDirectory() const override; - virtual QDir dataDirectory() const override; - virtual void setGamePath(const QString &path) override; - virtual QDir documentsDirectory() const override; - virtual QDir savesDirectory() const override; - virtual QList executables() const override; - virtual QList executableForcedLoads() const override; - virtual QString steamAPPId() const override; - virtual QStringList primaryPlugins() const override; - virtual QStringList gameVariants() const override; - virtual void setGameVariant(const QString &variant) override; - virtual QString binaryName() const override; - virtual QString gameShortName() const override; - virtual QStringList primarySources() const override; - virtual QStringList validShortNames() const override; - virtual QString gameNexusName() const override; - virtual QStringList iniFiles() const override; - virtual QStringList DLCPlugins() const override; - virtual QStringList CCPlugins() const override; - virtual LoadOrderMechanism loadOrderMechanism() const override; - virtual SortMechanism sortMechanism() const override; - virtual int nexusModOrganizerID() const override; - virtual int nexusGameID() const override; - virtual bool looksValid(QDir const &dir) const override; - virtual QString gameVersion() const override; - virtual QString getLauncherName() const override; - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(0) - -protected: - // Apparently, Python developers interpret an underscore in a function name as it being protected - virtual std::map featureList() const override; - - // Thankfully, the default implementation of the templated 'T *feature()' function should allow us to get away without overriding it. -}; - - -#define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS public: \ -using IPluginInstaller::parentWidget; \ -using IPluginInstaller::manager; \ -virtual unsigned int priority() const override; \ -virtual bool isManualInstaller() const override; \ -virtual void onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) override; \ -void onInstallationStart_Default(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ - return IPluginInstaller::onInstallationStart(archive, reinstallation, currentMod); } \ -virtual void onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) override; \ -void onInstallationEnd_Default(EInstallResult result, MOBase::IModInterface* newMod) { \ - return IPluginInstaller::onInstallationEnd(result, newMod); } \ -virtual bool isArchiveSupported(std::shared_ptr tree) const override; - - -class IPluginInstallerSimpleWrapper : public MOBase::IPluginInstallerSimple, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS - COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS - -public: - static constexpr const char* className = "IPluginInstallerSimpleWrapper"; - using boost::python::wrapper::get_override; - - virtual EInstallResult install(MOBase::GuessedValue& modName, std::shared_ptr& tree, - QString& version, int& nexusID) override; -}; - -class IPluginInstallerCustomWrapper : public MOBase::IPluginInstallerCustom, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS - - COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS - -public: - static constexpr const char* className = "IPluginInstallerCustomWrapper"; - using boost::python::wrapper::get_override; - - virtual bool isArchiveSupported(const QString &archiveName) const override; - virtual std::set supportedExtensions() const override; - virtual EInstallResult install(MOBase::GuessedValue &modName, QString gameName, const QString &archiveName, - const QString &version, int modID) override; -}; - - -class IPluginModPageWrapper : public MOBase::IPluginModPage, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginModPage) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -public: - static constexpr const char* className = "IPluginModPageWrapper"; - using boost::python::wrapper::get_override; - - // Bring in public scope: - using IPluginModPage::parentWidget; - - virtual QString displayName() const override; - virtual QIcon icon() const override; - virtual QUrl pageURL() const override; - virtual bool useIntegratedBrowser() const override; - virtual bool handlesDownload(const QUrl &pageURL, const QUrl &downloadURL, MOBase::ModRepositoryFileInfo &fileInfo) const override; - virtual void setParentWidget(QWidget *widget) override; - - void setParentWidget_Default(QWidget* parent) { - IPluginModPage::setParentWidget(parent); - } -}; - - -class IPluginPreviewWrapper : public MOBase::IPluginPreview, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -public: - static constexpr const char* className = "IPluginPreviewWrapper"; - using boost::python::wrapper::get_override; - - virtual std::set supportedExtensions() const override; - virtual QWidget *genFilePreview(const QString &fileName, const QSize &maxSize) const override; -}; - - -class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper -{ - Q_OBJECT - Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool) - - COMMON_I_PLUGIN_WRAPPER_DECLARATIONS -public: - static constexpr const char* className = "IPluginToolWrapper"; - using boost::python::wrapper::get_override; - - // Bring in public scope: - using IPluginTool::parentWidget; - - virtual QString displayName() const override; - virtual QString tooltip() const override; - virtual QIcon icon() const override; - virtual void setParentWidget(QWidget *parent) override; - - void setParentWidget_Default(QWidget* parent) { - IPluginTool::setParentWidget(parent); - } - -public Q_SLOTS: - virtual void display() const override; -}; - - - - -#endif // PROXYPLUGINWRAPPERS_H +#ifndef PROXYPLUGINWRAPPERS_H +#define PROXYPLUGINWRAPPERS_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef Q_MOC_RUN +#include +#include +#endif + +// The wrapper for IPluginGame cannot override requirements or enabledByDefault since they're final, +// so we need to be able to exclude the declarations. +#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(include_requirements) \ +public: \ +virtual bool init(MOBase::IOrganizer *moInfo) override; \ +virtual QString name() const override; \ +virtual QString localizedName() const override; \ +virtual QString master() const override; \ +virtual QString author() const override; \ +virtual QString description() const override; \ +virtual MOBase::VersionInfo version() const override; \ +virtual QList settings() const override; \ +QString localizedName_Default() const; \ +QString master_Default() const; \ +BOOST_PP_EXPR_IF(include_requirements, \ + virtual std::vector> requirements() const override; \ + std::vector> requirements_Default() const; \ + virtual bool enabledByDefault() const override; \ + bool enabledByDefault_Default() const;) + +#define COMMON_I_PLUGIN_WRAPPER_DECLARATIONS COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(1) + +// Even though the base interface is not a QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. +// QObject must be the first base class because moc assumes the first base class is a QObject +class IPluginWrapper : public QObject, public MOBase::IPlugin, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +public: + static constexpr const char* className = "IPluginWrapper"; + using boost::python::wrapper::get_override; +}; + + +// Even though the base interface is not an IPlugin or QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. +// QObject must be the first base class because moc assumes the first base class is a QObject +class IPluginDiagnoseWrapper : public QObject, public MOBase::IPluginDiagnose, public MOBase::IPlugin, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginDiagnose) + +public: + static constexpr const char* className = "IPluginDiagnoseWrapper"; + using boost::python::wrapper::get_override; + + // Bring in public scope: + using IPluginDiagnose::invalidate; + + virtual std::vector activeProblems() const override; + virtual QString shortDescription(unsigned int key) const override; + virtual QString fullDescription(unsigned int key) const override; + virtual bool hasGuidedFix(unsigned int key) const override; + virtual void startGuidedFix(unsigned int key) const override; + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +}; + + +// Even though the base interface is not an IPlugin or QObject, this has to be because we have no way to pass Mod Organizer a plugin that implements multiple interfaces. +// QObject must be the first base class because moc assumes the first base class is a QObject +class IPluginFileMapperWrapper : public QObject, public MOBase::IPluginFileMapper, public MOBase::IPlugin, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginFileMapper) + +public: + static constexpr const char* className = "IPluginFileMapperWrapper"; + using boost::python::wrapper::get_override; + + virtual MappingType mappings() const override; + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +}; + + +class IPluginGameWrapper : public MOBase::IPluginGame, public boost::python::wrapper { + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginGame) + +public: + static constexpr const char* className = "IPluginGameWrapper"; + using boost::python::wrapper::get_override; + + virtual void detectGame() override; + virtual QString gameName() const override; + virtual void initializeProfile(const QDir &directory, ProfileSettings settings) const override; + virtual std::vector> listSaves(QDir folder) const override; + virtual bool isInstalled() const override; + virtual QIcon gameIcon() const override; + virtual QDir gameDirectory() const override; + virtual QDir dataDirectory() const override; + virtual void setGamePath(const QString &path) override; + virtual QDir documentsDirectory() const override; + virtual QDir savesDirectory() const override; + virtual QList executables() const override; + virtual QList executableForcedLoads() const override; + virtual QString steamAPPId() const override; + virtual QStringList primaryPlugins() const override; + virtual QStringList gameVariants() const override; + virtual void setGameVariant(const QString &variant) override; + virtual QString binaryName() const override; + virtual QString gameShortName() const override; + virtual QStringList primarySources() const override; + virtual QStringList validShortNames() const override; + virtual QString gameNexusName() const override; + virtual QStringList iniFiles() const override; + virtual QStringList DLCPlugins() const override; + virtual QStringList CCPlugins() const override; + virtual LoadOrderMechanism loadOrderMechanism() const override; + virtual SortMechanism sortMechanism() const override; + virtual int nexusModOrganizerID() const override; + virtual int nexusGameID() const override; + virtual bool looksValid(QDir const &dir) const override; + virtual QString gameVersion() const override; + virtual QString getLauncherName() const override; + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS_IMPL(0) + +protected: + // Apparently, Python developers interpret an underscore in a function name as it being protected + virtual std::map featureList() const override; + + // Thankfully, the default implementation of the templated 'T *feature()' function should allow us to get away without overriding it. +}; + + +#define COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS public: \ +using IPluginInstaller::parentWidget; \ +using IPluginInstaller::manager; \ +virtual unsigned int priority() const override; \ +virtual bool isManualInstaller() const override; \ +virtual void onInstallationStart(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) override; \ +void onInstallationStart_Default(QString const& archive, bool reinstallation, MOBase::IModInterface* currentMod) { \ + return IPluginInstaller::onInstallationStart(archive, reinstallation, currentMod); } \ +virtual void onInstallationEnd(EInstallResult result, MOBase::IModInterface* newMod) override; \ +void onInstallationEnd_Default(EInstallResult result, MOBase::IModInterface* newMod) { \ + return IPluginInstaller::onInstallationEnd(result, newMod); } \ +virtual bool isArchiveSupported(std::shared_ptr tree) const override; + + +class IPluginInstallerSimpleWrapper : public MOBase::IPluginInstallerSimple, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerSimple) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS + COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS + +public: + static constexpr const char* className = "IPluginInstallerSimpleWrapper"; + using boost::python::wrapper::get_override; + + virtual EInstallResult install(MOBase::GuessedValue& modName, std::shared_ptr& tree, + QString& version, int& nexusID) override; +}; + +class IPluginInstallerCustomWrapper : public MOBase::IPluginInstallerCustom, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS + + COMMON_I_PLUGIN_INSTALLER_WRAPPER_DECLARATIONS + +public: + static constexpr const char* className = "IPluginInstallerCustomWrapper"; + using boost::python::wrapper::get_override; + + virtual bool isArchiveSupported(const QString &archiveName) const override; + virtual std::set supportedExtensions() const override; + virtual EInstallResult install(MOBase::GuessedValue &modName, QString gameName, const QString &archiveName, + const QString &version, int modID) override; +}; + + +class IPluginModPageWrapper : public MOBase::IPluginModPage, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginModPage) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +public: + static constexpr const char* className = "IPluginModPageWrapper"; + using boost::python::wrapper::get_override; + + // Bring in public scope: + using IPluginModPage::parentWidget; + + virtual QString displayName() const override; + virtual QIcon icon() const override; + virtual QUrl pageURL() const override; + virtual bool useIntegratedBrowser() const override; + virtual bool handlesDownload(const QUrl &pageURL, const QUrl &downloadURL, MOBase::ModRepositoryFileInfo &fileInfo) const override; + virtual void setParentWidget(QWidget *widget) override; + + void setParentWidget_Default(QWidget* parent) { + IPluginModPage::setParentWidget(parent); + } +}; + + +class IPluginPreviewWrapper : public MOBase::IPluginPreview, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +public: + static constexpr const char* className = "IPluginPreviewWrapper"; + using boost::python::wrapper::get_override; + + virtual std::set supportedExtensions() const override; + virtual QWidget *genFilePreview(const QString &fileName, const QSize &maxSize) const override; +}; + + +class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper +{ + Q_OBJECT + Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool) + + COMMON_I_PLUGIN_WRAPPER_DECLARATIONS +public: + static constexpr const char* className = "IPluginToolWrapper"; + using boost::python::wrapper::get_override; + + // Bring in public scope: + using IPluginTool::parentWidget; + + virtual QString displayName() const override; + virtual QString tooltip() const override; + virtual QIcon icon() const override; + virtual void setParentWidget(QWidget *parent) override; + + void setParentWidget_Default(QWidget* parent) { + IPluginTool::setParentWidget(parent); + } + +public Q_SLOTS: + virtual void display() const override; +}; + + + + +#endif // PROXYPLUGINWRAPPERS_H diff --git a/src/runner/pylogger.cpp b/src/runner-boost/pylogger.cpp similarity index 100% rename from src/runner/pylogger.cpp rename to src/runner-boost/pylogger.cpp diff --git a/src/runner/pylogger.h b/src/runner-boost/pylogger.h similarity index 100% rename from src/runner/pylogger.h rename to src/runner-boost/pylogger.h diff --git a/src/runner/pythonrunner.cpp b/src/runner-boost/pythonrunner.cpp similarity index 100% rename from src/runner/pythonrunner.cpp rename to src/runner-boost/pythonrunner.cpp diff --git a/src/runner/pythonrunner.h b/src/runner-boost/pythonrunner.h similarity index 94% rename from src/runner/pythonrunner.h rename to src/runner-boost/pythonrunner.h index ce8cad6..b4f4ed9 100644 --- a/src/runner/pythonrunner.h +++ b/src/runner-boost/pythonrunner.h @@ -1,33 +1,33 @@ -#ifndef PYTHONRUNNER_H -#define PYTHONRUNNER_H - -#include -#include -#include -#include -#include - - -class IPythonRunner { -public: - - virtual QList load(const QString& identifier) = 0; - virtual void unload(const QString& identifier) = 0; - - virtual bool isPythonInitialized() const = 0; - - virtual ~IPythonRunner() { } -}; - - -#ifdef PYTHONRUNNER_LIBRARY -#define PYDLLEXPORT Q_DECL_EXPORT -#else // PYTHONRUNNER_LIBRARY -#define PYDLLEXPORT Q_DECL_IMPORT -#endif // PYTHONRUNNER_LIBRARY - -extern "C" PYDLLEXPORT IPythonRunner *CreatePythonRunner(); - - - -#endif // PYTHONRUNNER_H +#ifndef PYTHONRUNNER_H +#define PYTHONRUNNER_H + +#include +#include +#include +#include +#include + + +class IPythonRunner { +public: + + virtual QList load(const QString& identifier) = 0; + virtual void unload(const QString& identifier) = 0; + + virtual bool isPythonInitialized() const = 0; + + virtual ~IPythonRunner() { } +}; + + +#ifdef PYTHONRUNNER_LIBRARY +#define PYDLLEXPORT Q_DECL_EXPORT +#else // PYTHONRUNNER_LIBRARY +#define PYDLLEXPORT Q_DECL_IMPORT +#endif // PYTHONRUNNER_LIBRARY + +extern "C" PYDLLEXPORT IPythonRunner *CreatePythonRunner(); + + + +#endif // PYTHONRUNNER_H diff --git a/src/runner/pythonutils.cpp b/src/runner-boost/pythonutils.cpp similarity index 100% rename from src/runner/pythonutils.cpp rename to src/runner-boost/pythonutils.cpp diff --git a/src/runner/pythonutils.h b/src/runner-boost/pythonutils.h similarity index 100% rename from src/runner/pythonutils.h rename to src/runner-boost/pythonutils.h diff --git a/src/runner/pythonwrapperutilities.h b/src/runner-boost/pythonwrapperutilities.h similarity index 100% rename from src/runner/pythonwrapperutilities.h rename to src/runner-boost/pythonwrapperutilities.h diff --git a/src/runner/shared_ptr_converter.h b/src/runner-boost/shared_ptr_converter.h similarity index 100% rename from src/runner/shared_ptr_converter.h rename to src/runner-boost/shared_ptr_converter.h diff --git a/src/runner/sipapiaccess.cpp b/src/runner-boost/sipapiaccess.cpp similarity index 100% rename from src/runner/sipapiaccess.cpp rename to src/runner-boost/sipapiaccess.cpp diff --git a/src/runner/sipapiaccess.h b/src/runner-boost/sipapiaccess.h similarity index 100% rename from src/runner/sipapiaccess.h rename to src/runner-boost/sipapiaccess.h diff --git a/src/runner/tuple_helper.h b/src/runner-boost/tuple_helper.h similarity index 100% rename from src/runner/tuple_helper.h rename to src/runner-boost/tuple_helper.h diff --git a/src/runner/uibasewrappers.h b/src/runner-boost/uibasewrappers.h similarity index 100% rename from src/runner/uibasewrappers.h rename to src/runner-boost/uibasewrappers.h diff --git a/src/runner/variant_helper.h b/src/runner-boost/variant_helper.h similarity index 100% rename from src/runner/variant_helper.h rename to src/runner-boost/variant_helper.h diff --git a/src/runner/widgets.cpp b/src/runner-boost/widgets.cpp similarity index 100% rename from src/runner/widgets.cpp rename to src/runner-boost/widgets.cpp diff --git a/src/runner/widgets.h b/src/runner-boost/widgets.h similarity index 100% rename from src/runner/widgets.h rename to src/runner-boost/widgets.h