Browse Source

python: expose pluginmanager.AbstractManager.register_external_manager().

And *now* it's possible to use scene converter plugins.
next
Vladimír Vondruš 3 years ago
parent
commit
e2642033b3
  1. 5
      doc/python/pages/changelog.rst
  2. 3
      src/python/corrade/pluginmanager.cpp
  3. 13
      src/python/magnum/test/test_trade.py

5
doc/python/pages/changelog.rst

@ -127,8 +127,9 @@ Changelog
- Exposed the :ref:`text` library
- Exposed the minimal interface of :ref:`utility.ConfigurationGroup` and
:ref:`utility.Configuration`
- Exposed :ref:`pluginmanager.AbstractManager.set_preferred_plugins()`, the
base :ref:`pluginmanager.AbstractPlugin` class and
- Exposed :ref:`pluginmanager.AbstractManager.set_preferred_plugins()`,
:ref:`pluginmanager.AbstractManager.register_external_manager()`, the base
:ref:`pluginmanager.AbstractPlugin` class and
:ref:`pluginmanager.PluginMetadata`
- Fixed issues with an in-source build (see :gh:`mosra/magnum-bindings#13`)
- All CMake build options are now prefixed with ``MAGNUM_``. For backwards

3
src/python/corrade/pluginmanager.cpp

@ -144,7 +144,8 @@ void pluginmanager(py::module_& m) {
}
return state;
}, "Unload a plugin", py::arg("plugin"));
}, "Unload a plugin", py::arg("plugin"))
.def("register_external_manager", &PluginManager::AbstractManager::registerExternalManager, "Register an external manager for resolving inter-manager dependencies", py::arg("manager"), py::keep_alive<1, 2>());
py::class_<PluginManager::AbstractPlugin, PluginManager::PyPluginHolder<PluginManager::AbstractPlugin>>{m, "AbstractPlugin", "Base class for plugin interfaces"}
/* Plugin interface string, search paths, suffix, metadata file suffix

13
src/python/magnum/test/test_trade.py

@ -1047,6 +1047,19 @@ class Importer(unittest.TestCase):
with self.assertRaises(KeyError):
manager.set_preferred_plugins('ApngImporter', [])
def test_register_external_manager(self):
# This scenario is stupid in practice, but want to test it on the
# Importer API for consistency
converter_manager = trade.ImageConverterManager()
converter_manager_refcount = sys.getrefcount(converter_manager)
manager = trade.ImporterManager()
manager.register_external_manager(converter_manager)
self.assertEqual(sys.getrefcount(converter_manager), converter_manager_refcount + 1)
del manager
self.assertEqual(sys.getrefcount(converter_manager), converter_manager_refcount)
def test_metadata(self):
manager = trade.ImporterManager()
manager.set_preferred_plugins('PngImporter', ['StbImageImporter'])

Loading…
Cancel
Save