diff --git a/doc/changelog.dox b/doc/changelog.dox index 4c081cd31..81508c735 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -431,6 +431,15 @@ See also: @relativeref{Timeline,previousFrameTime()} and @relativeref{Timeline,previousFrameDuration()} (see [mosra/magnum#604](https://github.com/mosra/magnum/pull/604)) +- Added @ref MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE, + @ref MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE, + @ref MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE, + @ref MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE, + @ref MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE, + @ref MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE and + @ref MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE defines with + plugin interface strings to avoid having to update them by hand in every + plugin every time the interface version is bumped after an ABI break @subsubsection changelog-latest-changes-animation Animation library diff --git a/doc/snippets/MagnumAudio.cpp b/doc/snippets/MagnumAudio.cpp index 097fea0c8..cacfea598 100644 --- a/doc/snippets/MagnumAudio.cpp +++ b/doc/snippets/MagnumAudio.cpp @@ -23,11 +23,38 @@ DEALINGS IN THE SOFTWARE. */ +/* In order to have the CORRADE_PLUGIN_REGISTER() macro not a no-op. Doesn't + affect anything else. */ +#define CORRADE_STATIC_PLUGIN + +#include + +#include "Magnum/Audio/AbstractImporter.h" #include "Magnum/Audio/Context.h" #include "Magnum/Audio/Extensions.h" using namespace Magnum; +namespace MyNamespace { + +struct MyAudioImporter: Audio::AbstractImporter { + explicit MyAudioImporter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin): Audio::AbstractImporter{manager, plugin} {} + + Audio::ImporterFeatures doFeatures() const override { return {}; } + bool doIsOpened() const override { return false; } + void doClose() override {} + Audio::BufferFormat doFormat() const override { return {}; } + UnsignedInt doFrequency() const override { return {}; } + Containers::Array doData() override { return {}; } +}; + +} + +/* [MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyAudioImporter, MyNamespace::MyAudioImporter, + MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE) +/* [MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE] */ + int main() { { diff --git a/doc/snippets/MagnumShaderTools.cpp b/doc/snippets/MagnumShaderTools.cpp index da4bdca18..843993b03 100644 --- a/doc/snippets/MagnumShaderTools.cpp +++ b/doc/snippets/MagnumShaderTools.cpp @@ -23,6 +23,10 @@ DEALINGS IN THE SOFTWARE. */ +/* In order to have the CORRADE_PLUGIN_REGISTER() macro not a no-op. Doesn't + affect anything else. */ +#define CORRADE_STATIC_PLUGIN + #include /** @todo drop when file callbacks are -free */ #include #include @@ -41,6 +45,23 @@ using namespace Magnum; +namespace MyNamespace { + +struct MyShaderConverter: ShaderTools::AbstractConverter { + explicit MyShaderConverter(PluginManager::AbstractManager& manager, Containers::StringView plugin): ShaderTools::AbstractConverter{manager, plugin} {} + + ShaderTools::ConverterFeatures doFeatures() const override { return {}; } + void doSetInputFormat(ShaderTools::Format, Containers::StringView) override {} + void doSetOutputFormat(ShaderTools::Format, Containers::StringView) override {} +}; + +} + +/* [MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyShaderConverter, MyNamespace::MyShaderConverter, + MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE) +/* [MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE] */ + int main() { { /* [AbstractConverter-usage-validation] */ diff --git a/doc/snippets/MagnumText.cpp b/doc/snippets/MagnumText.cpp index 5901d9a4c..c0059a124 100644 --- a/doc/snippets/MagnumText.cpp +++ b/doc/snippets/MagnumText.cpp @@ -23,6 +23,10 @@ DEALINGS IN THE SOFTWARE. */ +/* In order to have the CORRADE_PLUGIN_REGISTER() macro not a no-op. Doesn't + affect anything else. */ +#define CORRADE_STATIC_PLUGIN + #include #include #include @@ -36,6 +40,7 @@ #include "Magnum/Math/Matrix3.h" #include "Magnum/Shaders/VectorGL.h" #include "Magnum/Text/AbstractFont.h" +#include "Magnum/Text/AbstractFontConverter.h" #include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Text/Renderer.h" @@ -44,6 +49,36 @@ using namespace Magnum; using namespace Magnum::Math::Literals; +namespace MyNamespace { + +struct MyFont: Text::AbstractFont { + explicit MyFont(PluginManager::AbstractManager& manager, Containers::StringView plugin): Text::AbstractFont{manager, plugin} {} + + Text::FontFeatures doFeatures() const override { return {}; } + bool doIsOpened() const override { return false; } + void doClose() override {} + UnsignedInt doGlyphId(char32_t) override { return {}; } + Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } + Containers::Pointer doLayout(const Text::AbstractGlyphCache&, Float, const std::string&) override { return {}; } +}; +struct MyFontConverter: Text::AbstractFontConverter { + explicit MyFontConverter(PluginManager::AbstractManager& manager, Containers::StringView plugin): Text::AbstractFontConverter{manager, plugin} {} + + Text::FontConverterFeatures doFeatures() const override { return {}; } +}; + +} + +/* [MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyFont, MyNamespace::MyFont, + MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE) +/* [MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE] */ + +/* [MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyFontConverter, MyNamespace::MyFontConverter, + MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE) +/* [MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE] */ + int main() { { diff --git a/doc/snippets/MagnumTrade.cpp b/doc/snippets/MagnumTrade.cpp index dc05e9509..2c0ec70a7 100644 --- a/doc/snippets/MagnumTrade.cpp +++ b/doc/snippets/MagnumTrade.cpp @@ -23,6 +23,10 @@ DEALINGS IN THE SOFTWARE. */ +/* In order to have the CORRADE_PLUGIN_REGISTER() macro not a no-op. Doesn't + affect anything else. */ +#define CORRADE_STATIC_PLUGIN + #include #include #include @@ -89,6 +93,43 @@ using namespace Magnum; using namespace Magnum::Math::Literals; +namespace MyNamespace { + +struct MyImporter: Trade::AbstractImporter { + explicit MyImporter(PluginManager::AbstractManager& manager, Containers::StringView plugin): Trade::AbstractImporter{manager, plugin} {} + + Trade::ImporterFeatures doFeatures() const override { return {}; } + bool doIsOpened() const override { return false; } + void doClose() override {} +}; +struct MyImageConverter: Trade::AbstractImageConverter { + explicit MyImageConverter(PluginManager::AbstractManager& manager, Containers::StringView plugin): Trade::AbstractImageConverter{manager, plugin} {} + + Trade::ImageConverterFeatures doFeatures() const override { return {}; } +}; +struct MySceneConverter: Trade::AbstractSceneConverter { + explicit MySceneConverter(PluginManager::AbstractManager& manager, Containers::StringView plugin): Trade::AbstractSceneConverter{manager, plugin} {} + + Trade::SceneConverterFeatures doFeatures() const override { return {}; } +}; + +} + +/* [MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyImporter, MyNamespace::MyImporter, + MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE) +/* [MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE] */ + +/* [MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MyImageConverter, MyNamespace::MyImageConverter, + MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE) +/* [MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE] */ + +/* [MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE] */ +CORRADE_PLUGIN_REGISTER(MySceneConverter, MyNamespace::MySceneConverter, + MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE) +/* [MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE] */ + int main() { { diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index ab7ffd87a..5d2f2091c 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -51,11 +51,7 @@ namespace Magnum { namespace Audio { using namespace Containers::Literals; Containers::StringView AbstractImporter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Audio.AbstractImporter/0.1"_s -/* [interface] */ - ; + return MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 919e7f1d3..2c4aba5c7 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -124,7 +124,9 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi /** * @brief Plugin interface * - * @snippet Magnum/Audio/AbstractImporter.cpp interface + * @snippet Magnum/Audio/AbstractImporter.h interface + * + * @see @ref MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -236,6 +238,27 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi virtual Containers::Array doData() = 0; }; +/** +@brief Audio importer plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Audio,AbstractImporter::pluginInterface()}, meant to be +used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumAudio.cpp MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_AUDIO_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Audio.AbstractImporter/0.1" +/* [interface] */ + }} #endif diff --git a/src/Magnum/ShaderTools/AbstractConverter.cpp b/src/Magnum/ShaderTools/AbstractConverter.cpp index dec8ac9fd..dc78f5972 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.cpp +++ b/src/Magnum/ShaderTools/AbstractConverter.cpp @@ -52,11 +52,7 @@ namespace Magnum { namespace ShaderTools { using namespace Containers::Literals; Containers::StringView AbstractConverter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.ShaderTools.AbstractConverter/0.1.1"_s -/* [interface] */ - ; + return MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/ShaderTools/AbstractConverter.h b/src/Magnum/ShaderTools/AbstractConverter.h index d1335591e..0b9c24358 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.h +++ b/src/Magnum/ShaderTools/AbstractConverter.h @@ -490,7 +490,9 @@ class MAGNUM_SHADERTOOLS_EXPORT AbstractConverter: public PluginManager::Abstrac /** * @brief Plugin interface * - * @snippet Magnum/ShaderTools/AbstractConverter.cpp interface + * @snippet Magnum/ShaderTools/AbstractConverter.h interface + * + * @see @ref MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -1186,6 +1188,27 @@ class MAGNUM_SHADERTOOLS_EXPORT AbstractConverter: public PluginManager::Abstrac } _inputFileCallbackTemplate{nullptr, nullptr}; }; +/** +@brief Shader converter plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::ShaderTools,AbstractConverter::pluginInterface()}, meant +to be used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumShaderTools.cpp MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_SHADERTOOLS_ABSTRACTCONVERTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.ShaderTools.AbstractConverter/0.1.1" +/* [interface] */ + #ifndef DOXYGEN_GENERATING_OUTPUT template void AbstractConverter::setInputFileCallback(Callback callback, T& userData) { /* Don't try to wrap a null function pointer. Need to cast first because diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index a926aed6e..00e21e5fa 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -54,11 +54,7 @@ namespace Magnum { namespace Text { using namespace Containers::Literals; Containers::StringView AbstractFont::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Text.AbstractFont/0.3"_s -/* [interface] */ - ; + return MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index 90dadf437..1a7d4080a 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -185,7 +185,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** * @brief Plugin interface * - * @snippet Magnum/Text/AbstractFont.cpp interface + * @snippet Magnum/Text/AbstractFont.h interface + * + * @see @ref MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -634,6 +636,27 @@ class MAGNUM_TEXT_EXPORT AbstractLayouter { UnsignedInt _glyphCount; }; +/** +@brief Font plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Text,AbstractFont::pluginInterface()}, meant to be used +inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the interface +string by hand every time the version gets bumped: + +@snippet MagnumText.cpp MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_TEXT_ABSTRACTFONT_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Text.AbstractFont/0.3" +/* [interface] */ + #ifndef DOXYGEN_GENERATING_OUTPUT template void AbstractFont::setFileCallback(Callback callback, T& userData) { /* Don't try to wrap a null function pointer. Need to cast first because diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 89a8f30ce..207f35c62 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -70,11 +70,7 @@ std::u32string uniqueUnicode(const std::string& characters) } Containers::StringView AbstractFontConverter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Text.AbstractFontConverter/0.2"_s -/* [interface] */ - ; + return MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index 50d5f8190..3f3417372 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -176,7 +176,9 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl /** * @brief Plugin interface * - * @snippet Magnum/Text/AbstractFontConverter.cpp interface + * @snippet Magnum/Text/AbstractFontConverter.h interface + * + * @see @ref MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -418,6 +420,27 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl virtual Containers::Pointer doImportGlyphCacheFromFile(const std::string& filename) const; }; +/** +@brief Font converter plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Text,AbstractFontConverter::pluginInterface()}, meant to +be used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumText.cpp MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_TEXT_ABSTRACTFONTCONVERTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Text.AbstractFontConverter/0.2" +/* [interface] */ + }} #endif diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 2bad84d74..af3b83aa9 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -54,11 +54,7 @@ namespace Magnum { namespace Trade { using namespace Containers::Literals; Containers::StringView AbstractImageConverter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Trade.AbstractImageConverter/0.3.3"_s -/* [interface] */ - ; + return MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index fc819399a..3fffafad4 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -624,7 +624,9 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract /** * @brief Plugin interface * - * @snippet Magnum/Trade/AbstractImageConverter.cpp interface + * @snippet Magnum/Trade/AbstractImageConverter.h interface + * + * @see @ref MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -1928,6 +1930,27 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract ImageConverterFlags _flags; }; +/** +@brief Image converter plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Trade,AbstractImageConverter::pluginInterface()}, meant to +be used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumTrade.cpp MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_TRADE_ABSTRACTIMAGECONVERTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Trade.AbstractImageConverter/0.3.3" +/* [interface] */ + }} #endif diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 4b3580420..336933515 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -81,11 +81,7 @@ namespace Magnum { namespace Trade { using namespace Containers::Literals; Containers::StringView AbstractImporter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Trade.AbstractImporter/0.5.1"_s -/* [interface] */ - ; + return MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 129b6b7a9..99fe9d638 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -453,7 +453,9 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi /** * @brief Plugin interface * - * @snippet Magnum/Trade/AbstractImporter.cpp interface + * @snippet Magnum/Trade/AbstractImporter.h interface + * + * @see @ref MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -2605,6 +2607,27 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi #endif }; +/** +@brief Importer plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Trade,AbstractImporter::pluginInterface()}, meant to be +used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumTrade.cpp MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_TRADE_ABSTRACTIMPORTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Trade.AbstractImporter/0.5.1" +/* [interface] */ + #ifndef DOXYGEN_GENERATING_OUTPUT template void AbstractImporter::setFileCallback(Callback callback, T& userData) { /* Don't try to wrap a null function pointer. Need to cast first because diff --git a/src/Magnum/Trade/AbstractSceneConverter.cpp b/src/Magnum/Trade/AbstractSceneConverter.cpp index 4aa72f880..f331fbb43 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.cpp +++ b/src/Magnum/Trade/AbstractSceneConverter.cpp @@ -207,11 +207,7 @@ struct AbstractSceneConverter::State { }; Containers::StringView AbstractSceneConverter::pluginInterface() { - return -/* [interface] */ -"cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.1"_s -/* [interface] */ - ; + return MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE ""_s; } #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT diff --git a/src/Magnum/Trade/AbstractSceneConverter.h b/src/Magnum/Trade/AbstractSceneConverter.h index d7e2bb61c..a0db79a6e 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.h +++ b/src/Magnum/Trade/AbstractSceneConverter.h @@ -805,7 +805,9 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract /** * @brief Plugin interface * - * @snippet Magnum/Trade/AbstractSceneConverter.cpp interface + * @snippet Magnum/Trade/AbstractSceneConverter.h interface + * + * @see @ref MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE */ static Containers::StringView pluginInterface(); @@ -2410,6 +2412,27 @@ class MAGNUM_TRADE_EXPORT AbstractSceneConverter: public PluginManager::Abstract Containers::Pointer _state; }; +/** +@brief Scene converter plugin interface +@m_since_latest + +Same string as returned by +@relativeref{Magnum::Trade,AbstractSceneConverter::pluginInterface()}, meant to +be used inside @ref CORRADE_PLUGIN_REGISTER() to avoid having to update the +interface string by hand every time the version gets bumped: + +@snippet MagnumTrade.cpp MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE + +The interface string version gets increased on every ABI break to prevent +silent crashes and memory corruption. Plugins built against the previous +version will then fail to load, a subsequent rebuild will make them pick up the +updated interface string. +*/ +/* Silly indentation to make the string appear in pluginInterface() docs */ +#define MAGNUM_TRADE_ABSTRACTSCENECONVERTER_PLUGIN_INTERFACE /* [interface] */ \ +"cz.mosra.magnum.Trade.AbstractSceneConverter/0.2.1" +/* [interface] */ + }} #endif