Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/mobase/wrappers/basic_classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <uibase/iexecutable.h>
#include <uibase/iexecutableslist.h>
#include <uibase/iinstallationmanager.h>
#include <uibase/iinstance.h>
#include <uibase/iinstancemanager.h>
#include <uibase/imodinterface.h>
#include <uibase/imodrepositorybridge.h>
#include <uibase/imoinfo.h>
Expand Down Expand Up @@ -644,6 +646,8 @@ namespace mo2::python {

.def("virtualFileTree", &IOrganizer::virtualFileTree)

.def("instanceManager", &IOrganizer::instanceManager,
py::return_value_policy::reference)
.def("downloadManager", &IOrganizer::downloadManager,
py::return_value_policy::reference)
.def("pluginList", &IOrganizer::pluginList,
Expand Down Expand Up @@ -799,6 +803,22 @@ namespace mo2::python {
.def_static("getPluginDataPath", &IOrganizer::getPluginDataPath);
}

void add_iinstance_manager_classes(py::module_ m)
{
py::class_<IInstance, std::shared_ptr<IInstance>>(m, "IInstance")
.def("displayName", &IInstance::displayName)
.def("gameName", &IInstance::gameName)
.def("gameDirectory", &IInstance::gameDirectory)
.def("isPortable", &IInstance::isPortable);

py::class_<IInstanceManager>(m, "IInstanceManager")
.def("currentInstance", &IInstanceManager::currentInstance,
py::return_value_policy::reference)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the return value policy on currentInstance() and getGlobalInstance() are needed (or even valid?) since IInstance uses shared_ptr.

.def("globalInstancePaths", &IInstanceManager::globalInstancePaths)
.def("getGlobalInstance", &IInstanceManager::getGlobalInstance,
py::return_value_policy::reference);
}

void add_idownload_manager_classes(py::module_ m)
{
py::class_<IDownloadManager>(m, "IDownloadManager")
Expand Down Expand Up @@ -925,6 +945,7 @@ namespace mo2::python {

add_ipluginlist_classes(m);
add_imodlist_classes(m);
add_iinstance_manager_classes(m);
add_idownload_manager_classes(m);
add_iinstallation_manager_classes(m);
add_iorganizer_classes(m);
Expand Down
1 change: 1 addition & 0 deletions tests/mocks/MockOrganizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MockOrganizer : public IOrganizer {
MOCK_METHOD(QStringList, getFileOrigins, (const QString &fileName) ,(const, override));
MOCK_METHOD(QList<FileInfo>, findFileInfos, (const QString &path, const std::function<bool(const FileInfo&)> &filter), (const, override));
MOCK_METHOD(std::shared_ptr<const IFileTree>, virtualFileTree, (), (const, override));
MOCK_METHOD(MOBase::IInstanceManager*, instanceManager, (), (const, override));
MOCK_METHOD(MOBase::IDownloadManager*, downloadManager, (), (const, override));
MOCK_METHOD(MOBase::IPluginList*, pluginList, (), (const, override));
MOCK_METHOD(MOBase::IModList*, modList, (), (const, override));
Expand Down