From de5fde0f284b39f0d236577390c850c6c3686eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 11 Nov 2020 16:14:28 +0100 Subject: [PATCH] Cleaner IPluginRequirement. --- src/runner/pythonrunner.cpp | 18 ++++++++++++++---- src/runner/uibasewrappers.h | 5 ++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 09b5db9..eafbb9d 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -263,10 +263,20 @@ BOOST_PYTHON_MODULE(mobase) ; // Plugin requirements: - bpy::class_, IPluginRequirement*, boost::noncopyable>("IPluginRequirement", bpy::no_init) - .def("problems", &IPluginRequirement::problems) - .def("description", &IPluginRequirement::description) - ; + auto iPluginRequirementClass = bpy::class_< + IPluginRequirementWrapper, bpy::bases<>, IPluginRequirement*, boost::noncopyable>("IPluginRequirement", bpy::no_init); + { + bpy::scope scope = iPluginRequirementClass; + + bpy::class_("Problem", + bpy::init((bpy::arg("short_description"), bpy::arg("long_description") = ""))) + .def("shortDescription", &IPluginRequirement::Problem::shortDescription) + .def("longDescription", &IPluginRequirement::Problem::longDescription); + + iPluginRequirementClass + .def("check", &IPluginRequirement::check) + ; + } bpy::class_("PluginRequirementFactory") // pluginDependency diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index e572e34..a0470de 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -29,9 +29,8 @@ public: static constexpr const char* className = "IPluginRequirement"; using boost::python::wrapper::get_override; - virtual std::vector problems(MOBase::IOrganizer *o) const override { - return basicWrapperFunctionImplementation>(this, "problems", boost::python::ptr(o)); }; - virtual QString description(unsigned int id) const override { return basicWrapperFunctionImplementation(this, "getCreationTime", id); }; + virtual std::optional check(MOBase::IOrganizer *o) const override { + return basicWrapperFunctionImplementation>(this, "check", boost::python::ptr(o)); }; }; // This needs to be extendable in Python, so actually needs a wrapper: