Skip to content

Commit

Permalink
Start adding bindings for extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 11, 2024
1 parent 4c6ed4a commit e85e69a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mobase/mobase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PYBIND11_MODULE(mobase, m)

// exceptions
//
py::register_exception<Exception>(m, "Exception");
py::register_exception<Exception>(m, "MO2Exception");
py::register_exception<InvalidNXMLinkException>(m, "InvalidNXMLinkException");
py::register_exception<IncompatibilityException>(m, "IncompatibilityException");
py::register_exception<InvalidVersionException>(m, "InvalidVersionException");
Expand Down
33 changes: 33 additions & 0 deletions src/mobase/wrappers/basic_classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,38 @@ namespace mo2::python {
py::implicitly_convertible<QString, GuessedValue<QString>>();
}

void add_iextensionlist_classes(py::module_ m)
{
// TODO: add all bindings here

py::class_<IExtension>(m, "IExtension");

py::class_<IExtensionList>(m, "IExtensionList")
.def("installed", &IExtensionList::installed, "identifier"_a)
.def(
"enabled",
py::overload_cast<const QString&>(&IExtensionList::enabled, py::const_),
"identifier"_a)
.def(
"__getitem__",
[](IExtensionList const& self,
std::variant<std::size_t, QString> const& index) {
return std::visit(
[&self](auto&& value) {
if constexpr (std::is_same_v<std::decay_t<decltype(value)>,
std::size_t>) {
return self.at(value);
}
else {
return self.get(value);
}
},
index);
},
"index"_a, py::return_value_policy::reference)
.def("__len__", &IExtensionList::size);
}

void add_ipluginlist_classes(py::module_ m)
{
py::enum_<IPluginList::PluginState>(m, "PluginState", py::arithmetic())
Expand Down Expand Up @@ -887,6 +919,7 @@ namespace mo2::python {
})
.def("absoluteIniFilePath", &IProfile::absoluteIniFilePath, "inifile"_a);

add_iextensionlist_classes(m);
add_ipluginlist_classes(m);
add_imodlist_classes(m);
add_idownload_manager_classes(m);
Expand Down

0 comments on commit e85e69a

Please sign in to comment.