From 0f4a5adb4dc50b1d4de3edaeab23226f79f08435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Nov 2019 17:15:15 +0100 Subject: [PATCH] Trade: deprecate AbstractImporter interfaces for MeshDataXD. For backwards compatibility these will delegate to the new MeshData interfaces for 3D (and nothing for 2D, because so far there were no 2D scene importers). --- doc/changelog.dox | 7 ++ src/Magnum/FileCallback.h | 2 +- src/Magnum/Trade/AbstractImporter.cpp | 45 +++++-- src/Magnum/Trade/AbstractImporter.h | 119 +++++++++++++++--- .../Trade/Test/AbstractImporterTest.cpp | 110 +++++++++++++++- 5 files changed, 254 insertions(+), 29 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 81d97b130..04312abbe 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -378,6 +378,13 @@ See also: @ref GL::Attribute::DataType::Half, @ref GL::DynamicAttribute::DataType::Half and @ref GL::PixelType::Half that are consistent with the @ref Half type used elsewhere. +- @cpp Trade::AbstractImporter::mesh2D() @ce, + @cpp Trade::AbstractImporter::mesh3D() @ce and related APIs are + deprecated in favor of @ref Trade::AbstractImporter::mesh() and the new + @ref Trade::MeshData API. For backwards compatibility, importers + implementing the new API have it exposed through @cpp mesh3D() @ce as well, + returning a subset of @ref Trade::MeshData functionality supported by the + old @cpp Trade::MeshData3D @ce APIs - @cpp Platform::GlfwApplication::Configuration::setCursorMode() @ce and related enum & getter are deprecated in favor of the new extended and more flexible @ref Platform::GlfwApplication::setCursor(). The setting didn't diff --git a/src/Magnum/FileCallback.h b/src/Magnum/FileCallback.h index 3e7665a2c..f676e79df 100644 --- a/src/Magnum/FileCallback.h +++ b/src/Magnum/FileCallback.h @@ -67,7 +67,7 @@ enum class InputFileCallbackPolicy: UnsignedByte { * function is called or another file is opened. * * This can be the case for example when importing mesh data using - * @ref Trade::AbstractImporter::mesh3D() --- all vertex data might be + * @ref Trade::AbstractImporter::mesh() --- all vertex data might be * combined in a single binary file and each mesh occupies only a portion * of it. Note, however, that this might not be the case for all importers * --- see documentation of a particular plugin for concrete info. diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 512794d6b..45c0a15c7 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -40,13 +40,16 @@ #include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/LightData.h" #include "Magnum/Trade/MeshData.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" #include "Magnum/Trade/ObjectData2D.h" #include "Magnum/Trade/ObjectData3D.h" #include "Magnum/Trade/SceneData.h" #include "Magnum/Trade/TextureData.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include "Magnum/Trade/MeshData2D.h" +#include "Magnum/Trade/MeshData3D.h" +#endif + #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT #include "Magnum/Trade/configure.h" #endif @@ -465,32 +468,41 @@ std::string AbstractImporter::meshAttributeName(MeshAttribute name) { std::string AbstractImporter::doMeshAttributeName(UnsignedShort) { return {}; } +#ifdef MAGNUM_BUILD_DEPRECATED UnsignedInt AbstractImporter::mesh2DCount() const { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh2DCount(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH return doMesh2DCount(); + CORRADE_IGNORE_DEPRECATED_POP } UnsignedInt AbstractImporter::doMesh2DCount() const { return 0; } Int AbstractImporter::mesh2DForName(const std::string& name) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh2DForName(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH return doMesh2DForName(name); + CORRADE_IGNORE_DEPRECATED_POP } Int AbstractImporter::doMesh2DForName(const std::string&) { return -1; } std::string AbstractImporter::mesh2DName(const UnsignedInt id) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh2DName(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_ASSERT(id < doMesh2DCount(), "Trade::AbstractImporter::mesh2DName(): index" << id << "out of range for" << doMesh2DCount() << "entries", {}); return doMesh2DName(id); + CORRADE_IGNORE_DEPRECATED_POP } std::string AbstractImporter::doMesh2DName(UnsignedInt) { return {}; } Containers::Optional AbstractImporter::mesh2D(const UnsignedInt id) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh2D(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_ASSERT(id < doMesh2DCount(), "Trade::AbstractImporter::mesh2D(): index" << id << "out of range for" << doMesh2DCount() << "entries", {}); return doMesh2D(id); + CORRADE_IGNORE_DEPRECATED_POP } Containers::Optional AbstractImporter::doMesh2D(UnsignedInt) { @@ -499,35 +511,54 @@ Containers::Optional AbstractImporter::doMesh2D(UnsignedInt) { UnsignedInt AbstractImporter::mesh3DCount() const { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3DCount(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH return doMesh3DCount(); + CORRADE_IGNORE_DEPRECATED_POP } -UnsignedInt AbstractImporter::doMesh3DCount() const { return 0; } +UnsignedInt AbstractImporter::doMesh3DCount() const { + return doMeshCount(); +} Int AbstractImporter::mesh3DForName(const std::string& name) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3DForName(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH return doMesh3DForName(name); + CORRADE_IGNORE_DEPRECATED_POP } -Int AbstractImporter::doMesh3DForName(const std::string&) { return -1; } +Int AbstractImporter::doMesh3DForName(const std::string& name) { + return doMeshForName(name); +} std::string AbstractImporter::mesh3DName(const UnsignedInt id) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3DName(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_ASSERT(id < doMesh3DCount(), "Trade::AbstractImporter::mesh3DName(): index" << id << "out of range for" << doMesh3DCount() << "entries", {}); return doMesh3DName(id); + CORRADE_IGNORE_DEPRECATED_POP } -std::string AbstractImporter::doMesh3DName(UnsignedInt) { return {}; } +std::string AbstractImporter::doMesh3DName(const UnsignedInt id) { + return doMeshName(id); +} Containers::Optional AbstractImporter::mesh3D(const UnsignedInt id) { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3D(): no file opened", {}); + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_ASSERT(id < doMesh3DCount(), "Trade::AbstractImporter::mesh3D(): index" << id << "out of range for" << doMesh3DCount() << "entries", {}); return doMesh3D(id); + CORRADE_IGNORE_DEPRECATED_POP } -Containers::Optional AbstractImporter::doMesh3D(UnsignedInt) { - CORRADE_ASSERT(false, "Trade::AbstractImporter::mesh3D(): not implemented", {}); +Containers::Optional AbstractImporter::doMesh3D(const UnsignedInt id) { + Containers::Optional out = doMesh(id); + CORRADE_IGNORE_DEPRECATED_PUSH + if(out) return MeshData3D{*out}; + CORRADE_IGNORE_DEPRECATED_POP + return Containers::NullOpt; } +#endif UnsignedInt AbstractImporter::materialCount() const { CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::materialCount(): no file opened", {}); diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index bcc337430..29fffef87 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -749,30 +749,34 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi */ std::string meshAttributeName(MeshAttribute name); + #ifdef MAGNUM_BUILD_DEPRECATED /** * @brief Two-dimensional mesh count * * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref meshCount() instead. */ - UnsignedInt mesh2DCount() const; + CORRADE_DEPRECATED("use meshCount() instead") UnsignedInt mesh2DCount() const; /** * @brief Two-dimensional mesh ID for given name * * If no mesh for given name exists, returns @cpp -1 @ce. Expects that * a file is opened. + * @m_deprecated_since_latest Use @ref meshForName() instead. * @see @ref mesh2DName() */ - Int mesh2DForName(const std::string& name); + CORRADE_DEPRECATED("use meshForName() instead") Int mesh2DForName(const std::string& name); /** * @brief Two-dimensional mesh name * @param id Mesh ID, from range [0, @ref mesh2DCount()). * * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref meshName() instead. * @see @ref mesh2DForName() */ - std::string mesh2DName(UnsignedInt id); + CORRADE_DEPRECATED("use meshName() instead") std::string mesh2DName(UnsignedInt id); /** * @brief Two-dimensional mesh @@ -780,29 +784,39 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * * Returns given mesh or @ref Containers::NullOpt if importing failed. * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref mesh() instead. */ - Containers::Optional mesh2D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_PUSH /* Clang doesn't warn, but GCC does */ + CORRADE_DEPRECATED("use mesh() instead") Containers::Optional mesh2D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_POP - /** @brief Three-dimensional mesh count */ - UnsignedInt mesh3DCount() const; + /** + * @brief Three-dimensional mesh count + * + * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref meshCount() instead. + */ + CORRADE_DEPRECATED("use meshCount() instead") UnsignedInt mesh3DCount() const; /** * @brief Three-dimensional mesh ID for given name * * If no mesh for given name exists, returns @cpp -1 @ce. Expects that * a file is opened. + * @m_deprecated_since_latest Use @ref meshForName() instead. * @see @ref mesh3DName() */ - Int mesh3DForName(const std::string& name); + CORRADE_DEPRECATED("use meshForName() instead") Int mesh3DForName(const std::string& name); /** * @brief Three-dimensional mesh name * @param id Mesh ID, from range [0, @ref mesh3DCount()). * * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref meshName() instead. * @see @ref mesh3DForName() */ - std::string mesh3DName(UnsignedInt id); + CORRADE_DEPRECATED("use meshName() instead") std::string mesh3DName(UnsignedInt id); /** * @brief Three-dimensional mesh @@ -810,8 +824,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * * Returns given mesh or @ref Containers::NullOpt if importing failed. * Expects that a file is opened. + * @m_deprecated_since_latest Use @ref meshName() instead. */ - Containers::Optional mesh3D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_PUSH /* Clang doesn't warn, but GCC does */ + CORRADE_DEPRECATED("use mesh() instead") Containers::Optional mesh3D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_POP + #endif /** * @brief Material count @@ -1280,53 +1298,118 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi */ virtual std::string doMeshAttributeName(UnsignedShort name); + #ifdef MAGNUM_BUILD_DEPRECATED /** * @brief Implementation for @ref mesh2DCount() * - * Default implementation returns @cpp 0 @ce. - */ + * Default implementation returns @cpp 0 @ce. There weren't any + * importers in existence known to implement 2D mesh import, so unlike + * @ref doMesh3DCount() this function doesn't delegate to + * @ref doMeshCount(). + * @m_deprecated_since_latest Implement @ref doMeshCount() instead. + */ + /* MSVC warns when overriding such methods and there's no way to + suppress that warning, making the RT build (which treats deprecation + warnings as errors) fail and other builds extremely noisy. So + disabling those on MSVC. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshCount() instead") + #endif virtual UnsignedInt doMesh2DCount() const; /** * @brief Implementation for @ref mesh2DForName() * - * Default implementation returns @cpp -1 @ce. + * Default implementation returns @cpp -1 @ce. There weren't any + * importers in existence known to implement 2D mesh import, so unlike + * @ref doMesh3DForName() this function doesn't delegate to + * @ref doMeshForName(). + * @m_deprecated_since_latest Implement @ref doMeshForName() instead. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshForName() instead") + #endif /* See above */ virtual Int doMesh2DForName(const std::string& name); /** * @brief Implementation for @ref mesh2DName() * - * Default implementation returns empty string. + * Default implementation returns empty string. There weren't any + * importers in existence known to implement 2D mesh import, so unlike + * @ref doMesh3DName() this function doesn't delegate to + * @ref doMeshName(). + * @m_deprecated_since_latest Implement @ref doMeshName() instead. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshName() instead") + #endif /* See above */ virtual std::string doMesh2DName(UnsignedInt id); - /** @brief Implementation for @ref mesh2D() */ + /** + * @brief Implementation for @ref mesh2D() + * + * There weren't any importers in existence known to implement 2D mesh + * import, so unlike @ref doMesh3D() this function doesn't + * delegate to @ref doMesh(). + * @m_deprecated_since_latest Implement @ref doMesh() instead. + */ + CORRADE_IGNORE_DEPRECATED_PUSH /* Clang doesn't warn, but GCC does */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMesh() instead") + #endif /* See above */ virtual Containers::Optional doMesh2D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_POP /** * @brief Implementation for @ref mesh3DCount() * - * Default implementation returns @cpp 0 @ce. + * Default implementation returns @ref doMeshCount() for backwards + * compatibility. + * @m_deprecated_since_latest Implement @ref doMeshCount() instead. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshCount() instead") + #endif /* See above */ virtual UnsignedInt doMesh3DCount() const; /** * @brief Implementation for @ref mesh3DForName() * - * Default implementation returns @cpp -1 @ce. + * Default implementation returns @ref doMeshForName() for backwards + * compatibility. + * @m_deprecated_since_latest Implement @ref doMeshForName() instead. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshForName() instead") + #endif /* See above */ virtual Int doMesh3DForName(const std::string& name); /** * @brief Implementation for @ref mesh3DName() * - * Default implementation returns empty string. + * Default implementation returns @ref doMeshName() for backwards + * compatibility. + * @m_deprecated_since_latest Implement @ref doMeshName() instead. */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMeshName() instead") + #endif /* See above */ virtual std::string doMesh3DName(UnsignedInt id); - /** @brief Implementation for @ref mesh3D() */ + /** + * @brief Implementation for @ref mesh3D() + * + * Default implementation returns @ref doMesh() converted to + * @ref MeshData3D for backwards compatibility. + * @m_deprecated_since_latest Implement @ref doMesh() instead. + */ + CORRADE_IGNORE_DEPRECATED_PUSH /* Clang doesn't warn, but GCC does */ + #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) + CORRADE_DEPRECATED("implement doMesh() instead") + #endif /* See above */ virtual Containers::Optional doMesh3D(UnsignedInt id); + CORRADE_IGNORE_DEPRECATED_POP + #endif /** * @brief Implementation for @ref materialCount() diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index 9dc4256b6..1f3a7c29d 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -39,14 +39,17 @@ #include "Magnum/Trade/ImageData.h" #include "Magnum/Trade/LightData.h" #include "Magnum/Trade/MeshData.h" -#include "Magnum/Trade/MeshData2D.h" -#include "Magnum/Trade/MeshData3D.h" #include "Magnum/Trade/MeshObjectData2D.h" #include "Magnum/Trade/MeshObjectData3D.h" #include "Magnum/Trade/PhongMaterialData.h" #include "Magnum/Trade/SceneData.h" #include "Magnum/Trade/TextureData.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include "Magnum/Trade/MeshData2D.h" +#include "Magnum/Trade/MeshData3D.h" +#endif + #include "configure.h" namespace Magnum { namespace Trade { namespace Test { namespace { @@ -161,6 +164,9 @@ struct AbstractImporterTest: TestSuite::Tester { void object3DOutOfRange(); void mesh(); + #ifdef MAGNUM_BUILD_DEPRECATED + void meshDeprecatedFallback(); + #endif void meshCountNotImplemented(); void meshCountNoFile(); void meshForNameNotImplemented(); @@ -181,6 +187,7 @@ struct AbstractImporterTest: TestSuite::Tester { void meshAttributeNameNotImplemented(); void meshAttributeNameNotCustom(); + #ifdef MAGNUM_BUILD_DEPRECATED void mesh2D(); void mesh2DCountNotImplemented(); void mesh2DCountNoFile(); @@ -204,6 +211,7 @@ struct AbstractImporterTest: TestSuite::Tester { void mesh3DNotImplemented(); void mesh3DNoFile(); void mesh3DOutOfRange(); + #endif void material(); void materialCountNotImplemented(); @@ -405,6 +413,9 @@ AbstractImporterTest::AbstractImporterTest() { &AbstractImporterTest::object3DOutOfRange, &AbstractImporterTest::mesh, + #ifdef MAGNUM_BUILD_DEPRECATED + &AbstractImporterTest::meshDeprecatedFallback, + #endif &AbstractImporterTest::meshCountNotImplemented, &AbstractImporterTest::meshCountNoFile, &AbstractImporterTest::meshForNameNotImplemented, @@ -425,6 +436,7 @@ AbstractImporterTest::AbstractImporterTest() { &AbstractImporterTest::meshAttributeNameNotImplemented, &AbstractImporterTest::meshAttributeNameNotCustom, + #ifdef MAGNUM_BUILD_DEPRECATED &AbstractImporterTest::mesh2D, &AbstractImporterTest::mesh2DCountNotImplemented, &AbstractImporterTest::mesh2DCountNoFile, @@ -448,6 +460,7 @@ AbstractImporterTest::AbstractImporterTest() { &AbstractImporterTest::mesh3DNotImplemented, &AbstractImporterTest::mesh3DNoFile, &AbstractImporterTest::mesh3DOutOfRange, + #endif &AbstractImporterTest::material, &AbstractImporterTest::materialCountNotImplemented, @@ -2169,6 +2182,45 @@ void AbstractImporterTest::mesh() { CORRADE_COMPARE(data->importerState(), &state); } +#ifdef MAGNUM_BUILD_DEPRECATED +void AbstractImporterTest::meshDeprecatedFallback() { + struct: AbstractImporter { + ImporterFeatures doFeatures() const override { return {}; } + bool doIsOpened() const override { return true; } + void doClose() override {} + + UnsignedInt doMeshCount() const override { return 8; } + Int doMeshForName(const std::string& name) override { + if(name == "eighth") return 7; + else return -1; + } + std::string doMeshName(UnsignedInt id) override { + if(id == 7) return "eighth"; + else return {}; + } + Containers::Optional doMesh(UnsignedInt id) override { + if(id == 7) return MeshData{MeshPrimitive::Points, nullptr, {MeshAttributeData{MeshAttribute::Position, VertexFormat::Vector3, nullptr}}, &state}; + else return {}; + } + } importer; + + CORRADE_IGNORE_DEPRECATED_PUSH + /* Nothing done for 2D as there were no known importers for these */ + CORRADE_COMPARE(importer.mesh2DCount(), 0); + CORRADE_COMPARE(importer.mesh2DForName("eighth"), -1); + + /* For 3D it's called through */ + CORRADE_COMPARE(importer.mesh3DCount(), 8); + CORRADE_COMPARE(importer.mesh3DForName("eighth"), 7); + CORRADE_COMPARE(importer.mesh3DName(7), "eighth"); + + auto data = importer.mesh3D(7); + CORRADE_VERIFY(data); + CORRADE_COMPARE(data->importerState(), &state); + CORRADE_IGNORE_DEPRECATED_POP +} +#endif + void AbstractImporterTest::meshCountNotImplemented() { struct: AbstractImporter { ImporterFeatures doFeatures() const override { return {}; } @@ -2470,6 +2522,7 @@ void AbstractImporterTest::meshAttributeNameNotCustom() { "Trade::AbstractImporter::meshAttributeName(): Trade::MeshAttribute::Position is not custom\n"); } +#ifdef MAGNUM_BUILD_DEPRECATED void AbstractImporterTest::mesh2D() { struct: AbstractImporter { ImporterFeatures doFeatures() const override { return {}; } @@ -2485,12 +2538,15 @@ void AbstractImporterTest::mesh2D() { if(id == 7) return "eighth"; else return {}; } + CORRADE_IGNORE_DEPRECATED_PUSH Containers::Optional doMesh2D(UnsignedInt id) override { if(id == 7) return MeshData2D{{}, {}, {{}}, {}, {}, &state}; else return {}; } + CORRADE_IGNORE_DEPRECATED_POP } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh2DCount(), 8); CORRADE_COMPARE(importer.mesh2DForName("eighth"), 7); CORRADE_COMPARE(importer.mesh2DName(7), "eighth"); @@ -2498,6 +2554,7 @@ void AbstractImporterTest::mesh2D() { auto data = importer.mesh2D(7); CORRADE_VERIFY(data); CORRADE_COMPARE(data->importerState(), &state); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh2DCountNotImplemented() { @@ -2507,7 +2564,9 @@ void AbstractImporterTest::mesh2DCountNotImplemented() { void doClose() override {} } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh2DCount(), 0); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh2DCountNoFile() { @@ -2520,7 +2579,9 @@ void AbstractImporterTest::mesh2DCountNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2DCount(); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2DCount(): no file opened\n"); } @@ -2531,7 +2592,9 @@ void AbstractImporterTest::mesh2DForNameNotImplemented() { void doClose() override {} } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh2DForName(""), -1); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh2DForNameNoFile() { @@ -2544,7 +2607,9 @@ void AbstractImporterTest::mesh2DForNameNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2DForName(""); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2DForName(): no file opened\n"); } @@ -2557,7 +2622,9 @@ void AbstractImporterTest::mesh2DNameNotImplemented() { UnsignedInt doMesh2DCount() const override { return 8; } } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh2DName(7), ""); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh2DNameNoFile() { @@ -2570,7 +2637,9 @@ void AbstractImporterTest::mesh2DNameNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2DName(42); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2DName(): no file opened\n"); } @@ -2586,7 +2655,9 @@ void AbstractImporterTest::mesh2DNameOutOfRange() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2DName(8); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2DName(): index 8 out of range for 8 entries\n"); } @@ -2602,7 +2673,9 @@ void AbstractImporterTest::mesh2DNotImplemented() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2D(7); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2D(): not implemented\n"); } @@ -2616,7 +2689,9 @@ void AbstractImporterTest::mesh2DNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2D(42); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2D(): no file opened\n"); } @@ -2632,7 +2707,9 @@ void AbstractImporterTest::mesh2DOutOfRange() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh2D(8); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh2D(): index 8 out of range for 8 entries\n"); } @@ -2651,12 +2728,15 @@ void AbstractImporterTest::mesh3D() { if(id == 7) return "eighth"; else return {}; } + CORRADE_IGNORE_DEPRECATED_PUSH Containers::Optional doMesh3D(UnsignedInt id) override { if(id == 7) return MeshData3D{{}, {}, {{}}, {}, {}, {}, &state}; else return {}; } + CORRADE_IGNORE_DEPRECATED_POP } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh3DCount(), 8); CORRADE_COMPARE(importer.mesh3DForName("eighth"), 7); CORRADE_COMPARE(importer.mesh3DName(7), "eighth"); @@ -2664,6 +2744,7 @@ void AbstractImporterTest::mesh3D() { auto data = importer.mesh3D(7); CORRADE_VERIFY(data); CORRADE_COMPARE(data->importerState(), &state); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh3DCountNotImplemented() { @@ -2673,7 +2754,9 @@ void AbstractImporterTest::mesh3DCountNotImplemented() { void doClose() override {} } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh3DCount(), 0); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh3DCountNoFile() { @@ -2686,7 +2769,9 @@ void AbstractImporterTest::mesh3DCountNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3DCount(); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3DCount(): no file opened\n"); } @@ -2697,7 +2782,9 @@ void AbstractImporterTest::mesh3DForNameNotImplemented() { void doClose() override {} } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh3DForName(""), -1); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh3DForNameNoFile() { @@ -2710,7 +2797,9 @@ void AbstractImporterTest::mesh3DForNameNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3DForName(""); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3DForName(): no file opened\n"); } @@ -2723,7 +2812,9 @@ void AbstractImporterTest::mesh3DNameNotImplemented() { UnsignedInt doMesh3DCount() const override { return 8; } } importer; + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(importer.mesh3DName(7), ""); + CORRADE_IGNORE_DEPRECATED_POP } void AbstractImporterTest::mesh3DNameNoFile() { @@ -2736,7 +2827,9 @@ void AbstractImporterTest::mesh3DNameNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3DName(42); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3DName(): no file opened\n"); } @@ -2752,7 +2845,9 @@ void AbstractImporterTest::mesh3DNameOutOfRange() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3DName(8); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3DName(): index 8 out of range for 8 entries\n"); } @@ -2768,8 +2863,12 @@ void AbstractImporterTest::mesh3DNotImplemented() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3D(7); - CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3D(): not implemented\n"); + CORRADE_IGNORE_DEPRECATED_POP + /* Not mesh3D() because this one delegates into mesh() for backwards + compatibility */ + CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh(): not implemented\n"); } void AbstractImporterTest::mesh3DNoFile() { @@ -2782,7 +2881,9 @@ void AbstractImporterTest::mesh3DNoFile() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3D(42); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3D(): no file opened\n"); } @@ -2798,9 +2899,12 @@ void AbstractImporterTest::mesh3DOutOfRange() { std::ostringstream out; Error redirectError{&out}; + CORRADE_IGNORE_DEPRECATED_PUSH importer.mesh3D(8); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::mesh3D(): index 8 out of range for 8 entries\n"); } +#endif void AbstractImporterTest::material() { struct: AbstractImporter {