From f0ad33f850b62f01bad3865822ae751e06d84006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 30 Aug 2022 18:51:21 +0200 Subject: [PATCH] Audio,ShaderTools,Text,Trade: packed debug printing for all Feature enums. --- src/Magnum/Audio/AbstractImporter.cpp | 11 ++++--- .../Audio/Test/AbstractImporterTest.cpp | 20 ++++++++++++- src/Magnum/ShaderTools/AbstractConverter.cpp | 11 ++++--- .../Test/AbstractConverterTest.cpp | 18 +++++++++++ src/Magnum/Text/AbstractFont.cpp | 11 ++++--- src/Magnum/Text/AbstractFontConverter.cpp | 11 ++++--- .../Text/Test/AbstractFontConverterTest.cpp | 20 ++++++++++++- src/Magnum/Text/Test/AbstractFontTest.cpp | 20 ++++++++++++- src/Magnum/Trade/AbstractImageConverter.cpp | 13 ++++---- src/Magnum/Trade/AbstractImporter.cpp | 11 ++++--- src/Magnum/Trade/AbstractSceneConverter.cpp | 11 ++++--- .../Trade/Test/AbstractImageConverterTest.cpp | 30 +++++++++++++++++++ .../Trade/Test/AbstractImporterTest.cpp | 18 +++++++++++ .../Trade/Test/AbstractSceneConverterTest.cpp | 18 +++++++++++ 14 files changed, 191 insertions(+), 32 deletions(-) diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index 040c9c2cb..ab7ffd87a 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -145,21 +145,24 @@ Containers::Array AbstractImporter::data() { } Debug& operator<<(Debug& debug, const ImporterFeature value) { - debug << "Audio::ImporterFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "Audio::ImporterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case ImporterFeature::v: return debug << "::" #v; + #define _c(v) case ImporterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(OpenData) #undef _c /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const ImporterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Audio::ImporterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Audio::ImporterFeatures{}", { ImporterFeature::OpenData}); } diff --git a/src/Magnum/Audio/Test/AbstractImporterTest.cpp b/src/Magnum/Audio/Test/AbstractImporterTest.cpp index 5767bc7bf..c40300f00 100644 --- a/src/Magnum/Audio/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Audio/Test/AbstractImporterTest.cpp @@ -67,7 +67,9 @@ struct AbstractImporterTest: TestSuite::Tester { void dataCustomDeleter(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); }; AbstractImporterTest::AbstractImporterTest() { @@ -92,7 +94,9 @@ AbstractImporterTest::AbstractImporterTest() { &AbstractImporterTest::dataCustomDeleter, &AbstractImporterTest::debugFeature, - &AbstractImporterTest::debugFeatures}); + &AbstractImporterTest::debugFeaturePacked, + &AbstractImporterTest::debugFeatures, + &AbstractImporterTest::debugFeaturesPacked}); } void AbstractImporterTest::construct() { @@ -388,6 +392,13 @@ void AbstractImporterTest::debugFeature() { CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData Audio::ImporterFeature(0xf0)\n"); } +void AbstractImporterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::OpenData; + CORRADE_COMPARE(out.str(), "OpenData 0xf0 Audio::ImporterFeature::OpenData\n"); +} + void AbstractImporterTest::debugFeatures() { std::ostringstream out; @@ -395,6 +406,13 @@ void AbstractImporterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Audio::ImporterFeature::OpenData|Audio::ImporterFeature(0xf0) Audio::ImporterFeatures{}\n"); } +void AbstractImporterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (ImporterFeature::OpenData|ImporterFeature(0xf0)) << Debug::packed << ImporterFeatures{} << ImporterFeature::OpenData; + CORRADE_COMPARE(out.str(), "OpenData|0xf0 {} Audio::ImporterFeature::OpenData\n"); +} + }}}} CORRADE_TEST_MAIN(Magnum::Audio::Test::AbstractImporterTest) diff --git a/src/Magnum/ShaderTools/AbstractConverter.cpp b/src/Magnum/ShaderTools/AbstractConverter.cpp index 4d3a9596e..dec8ac9fd 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.cpp +++ b/src/Magnum/ShaderTools/AbstractConverter.cpp @@ -733,11 +733,14 @@ Containers::Optional> AbstractConverter::doLinkFilesToDa } Debug& operator<<(Debug& debug, const ConverterFeature value) { - debug << "ShaderTools::ConverterFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "ShaderTools::ConverterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case ConverterFeature::v: return debug << "::" #v; + #define _c(v) case ConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(ValidateData) _c(ValidateFile) _c(ConvertData) @@ -752,11 +755,11 @@ Debug& operator<<(Debug& debug, const ConverterFeature value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const ConverterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "ShaderTools::ConverterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "ShaderTools::ConverterFeatures{}", { ConverterFeature::ValidateData, /* Implied by ValidateData, has to be after */ ConverterFeature::ValidateFile, diff --git a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp index 1ce7185ac..949e917e2 100644 --- a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp +++ b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp @@ -189,7 +189,9 @@ struct AbstractConverterTest: TestSuite::Tester { void setInputFileCallbackLinkFilesToDataAsDataFailed(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); void debugFeaturesSupersets(); void debugFlag(); void debugFlags(); @@ -339,7 +341,9 @@ AbstractConverterTest::AbstractConverterTest() { &AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsDataFailed, &AbstractConverterTest::debugFeature, + &AbstractConverterTest::debugFeaturePacked, &AbstractConverterTest::debugFeatures, + &AbstractConverterTest::debugFeaturesPacked, &AbstractConverterTest::debugFeaturesSupersets, &AbstractConverterTest::debugFlag, &AbstractConverterTest::debugFlags, @@ -3533,6 +3537,13 @@ void AbstractConverterTest::debugFeature() { CORRADE_COMPARE(out.str(), "ShaderTools::ConverterFeature::ConvertData ShaderTools::ConverterFeature(0xf0)\n"); } +void AbstractConverterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << ConverterFeature::ConvertData << Debug::packed << ConverterFeature(0xf0) << ConverterFeature::ValidateFile; + CORRADE_COMPARE(out.str(), "ConvertData 0xf0 ShaderTools::ConverterFeature::ValidateFile\n"); +} + void AbstractConverterTest::debugFeatures() { std::ostringstream out; @@ -3540,6 +3551,13 @@ void AbstractConverterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "ShaderTools::ConverterFeature::ValidateData|ShaderTools::ConverterFeature::ConvertFile ShaderTools::ConverterFeatures{}\n"); } +void AbstractConverterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (ConverterFeature::ValidateData|ConverterFeature::ConvertFile) << Debug::packed << ConverterFeatures{} << ConverterFeature::InputFileCallback; + CORRADE_COMPARE(out.str(), "ValidateData|ConvertFile {} ShaderTools::ConverterFeature::InputFileCallback\n"); +} + void AbstractConverterTest::debugFeaturesSupersets() { /* ValidateData is a superset of ValidateFile, so only one should be printed */ diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index b88755173..a926aed6e 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -283,11 +283,14 @@ Containers::Pointer AbstractFont::layout(const AbstractGlyphCa } Debug& operator<<(Debug& debug, const FontFeature value) { - debug << "Text::FontFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "Text::FontFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case FontFeature::v: return debug << "::" #v; + #define _c(v) case FontFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(OpenData) _c(FileCallback) _c(PreparedGlyphCache) @@ -295,11 +298,11 @@ Debug& operator<<(Debug& debug, const FontFeature value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const FontFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Text::FontFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontFeatures{}", { FontFeature::OpenData, FontFeature::FileCallback, FontFeature::PreparedGlyphCache}); diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 02058ee2c..89a8f30ce 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -263,11 +263,14 @@ Containers::Pointer AbstractFontConverter::doImportGlyphCach } Debug& operator<<(Debug& debug, const FontConverterFeature value) { - debug << "Text::FontConverterFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "Text::FontConverterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case FontConverterFeature::v: return debug << "::" #v; + #define _c(v) case FontConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(ExportFont) _c(ExportGlyphCache) _c(ImportGlyphCache) @@ -277,11 +280,11 @@ Debug& operator<<(Debug& debug, const FontConverterFeature value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(Containers::enumCastUnderlyingType(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(Containers::enumCastUnderlyingType(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const FontConverterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Text::FontConverterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Text::FontConverterFeatures{}", { FontConverterFeature::ExportFont, FontConverterFeature::ExportGlyphCache, FontConverterFeature::ImportGlyphCache, diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index a30d36da4..4e7cff7a7 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -95,7 +95,9 @@ struct AbstractFontConverterTest: TestSuite::Tester { void importGlyphCacheFromFileAsSingleDataNotFound(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); }; AbstractFontConverterTest::AbstractFontConverterTest() { @@ -149,7 +151,9 @@ AbstractFontConverterTest::AbstractFontConverterTest() { &AbstractFontConverterTest::importGlyphCacheFromFileAsSingleDataNotFound, &AbstractFontConverterTest::debugFeature, - &AbstractFontConverterTest::debugFeatures}); + &AbstractFontConverterTest::debugFeaturePacked, + &AbstractFontConverterTest::debugFeatures, + &AbstractFontConverterTest::debugFeaturesPacked}); /* Create testing dir */ Utility::Path::make(TEXT_TEST_OUTPUT_DIR); @@ -1019,6 +1023,13 @@ void AbstractFontConverterTest::debugFeature() { CORRADE_COMPARE(out.str(), "Text::FontConverterFeature::ExportFont Text::FontConverterFeature(0xf0)\n"); } +void AbstractFontConverterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << FontConverterFeature::ExportFont << Debug::packed << FontConverterFeature(0xf0) << FontConverterFeature::ImportGlyphCache; + CORRADE_COMPARE(out.str(), "ExportFont 0xf0 Text::FontConverterFeature::ImportGlyphCache\n"); +} + void AbstractFontConverterTest::debugFeatures() { std::ostringstream out; @@ -1026,6 +1037,13 @@ void AbstractFontConverterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Text::FontConverterFeature::ExportFont|Text::FontConverterFeature::ImportGlyphCache Text::FontConverterFeatures{}\n"); } +void AbstractFontConverterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (FontConverterFeature::ExportFont|FontConverterFeature::ImportGlyphCache) << Debug::packed << FontConverterFeatures{} << FontConverterFeature::ExportGlyphCache; + CORRADE_COMPARE(out.str(), "ExportFont|ImportGlyphCache {} Text::FontConverterFeature::ExportGlyphCache\n"); +} + }}}} CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontConverterTest) diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index f0df222a6..e11f2dd55 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -95,7 +95,9 @@ struct AbstractFontTest: TestSuite::Tester { void createGlyphCacheNoFont(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); }; AbstractFontTest::AbstractFontTest() { @@ -150,7 +152,9 @@ AbstractFontTest::AbstractFontTest() { &AbstractFontTest::createGlyphCacheNoFont, &AbstractFontTest::debugFeature, - &AbstractFontTest::debugFeatures}); + &AbstractFontTest::debugFeaturePacked, + &AbstractFontTest::debugFeatures, + &AbstractFontTest::debugFeaturesPacked}); } void AbstractFontTest::construct() { @@ -1154,6 +1158,13 @@ void AbstractFontTest::debugFeature() { CORRADE_COMPARE(out.str(), "Text::FontFeature::OpenData Text::FontFeature(0xf0)\n"); } +void AbstractFontTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << FontFeature::OpenData << Debug::packed << FontFeature(0xf0) << FontFeature::FileCallback; + CORRADE_COMPARE(out.str(), "OpenData 0xf0 Text::FontFeature::FileCallback\n"); +} + void AbstractFontTest::debugFeatures() { std::ostringstream out; @@ -1161,6 +1172,13 @@ void AbstractFontTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Text::FontFeature::OpenData|Text::FontFeature::PreparedGlyphCache Text::FontFeatures{}\n"); } +void AbstractFontTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (FontFeature::OpenData|FontFeature::PreparedGlyphCache) << Debug::packed << FontFeatures{} << FontFeature::FileCallback; + CORRADE_COMPARE(out.str(), "OpenData|PreparedGlyphCache {} Text::FontFeature::FileCallback\n"); +} + }}}} CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest) diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 56068481c..fc7bba2c0 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -1278,18 +1278,21 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView= Debug::Flag::Packed; + #ifdef MAGNUM_BUILD_DEPRECATED /* If printing a deprecated flag combination, make it look like the enum set */ if((value & ImageConverterFeature::Levels) && (value & ~ImageConverterFeature::Levels)) - return debug << (value & ~ImageConverterFeature::Levels) << Debug::nospace << "|Trade::ImageConverterFeature::Levels"; + return debug << (value & ~ImageConverterFeature::Levels) << Debug::nospace << (packed ? "|Levels" : "|Trade::ImageConverterFeature::Levels"); #endif - debug << "Trade::ImageConverterFeature" << Debug::nospace; + if(!packed) + debug << "Trade::ImageConverterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case ImageConverterFeature::v: return debug << "::" #v; + #define _c(v) case ImageConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(Convert1D) _c(Convert2D) _c(Convert3D) @@ -1333,11 +1336,11 @@ Debug& operator<<(Debug& debug, const ImageConverterFeature value) { #endif } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const ImageConverterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Trade::ImageConverterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImageConverterFeatures{}", { ImageConverterFeature::Convert1D, ImageConverterFeature::Convert2D, ImageConverterFeature::Convert3D, diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index f5d012d3c..f363ae97c 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -1598,11 +1598,14 @@ const void* AbstractImporter::importerState() const { const void* AbstractImporter::doImporterState() const { return nullptr; } Debug& operator<<(Debug& debug, const ImporterFeature value) { - debug << "Trade::ImporterFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "Trade::ImporterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case ImporterFeature::v: return debug << "::" #v; + #define _c(v) case ImporterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(OpenData) _c(OpenState) _c(FileCallback) @@ -1610,11 +1613,11 @@ Debug& operator<<(Debug& debug, const ImporterFeature value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const ImporterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Trade::ImporterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::ImporterFeatures{}", { ImporterFeature::OpenData, ImporterFeature::OpenState, ImporterFeature::FileCallback}); diff --git a/src/Magnum/Trade/AbstractSceneConverter.cpp b/src/Magnum/Trade/AbstractSceneConverter.cpp index d0c676c28..9b40f8009 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.cpp +++ b/src/Magnum/Trade/AbstractSceneConverter.cpp @@ -1187,11 +1187,14 @@ Containers::Optional AbstractSceneConverter::add(const Containers:: } Debug& operator<<(Debug& debug, const SceneConverterFeature value) { - debug << "Trade::SceneConverterFeature" << Debug::nospace; + const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; + + if(!packed) + debug << "Trade::SceneConverterFeature" << Debug::nospace; switch(value) { /* LCOV_EXCL_START */ - #define _c(v) case SceneConverterFeature::v: return debug << "::" #v; + #define _c(v) case SceneConverterFeature::v: return debug << (packed ? "" : "::") << Debug::nospace << #v; _c(ConvertMesh) _c(ConvertMeshInPlace) _c(ConvertMeshToData) @@ -1220,11 +1223,11 @@ Debug& operator<<(Debug& debug, const SceneConverterFeature value) { /* LCOV_EXCL_STOP */ } - return debug << "(" << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << ")"; + return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << (packed ? "" : ")"); } Debug& operator<<(Debug& debug, const SceneConverterFeatures value) { - return Containers::enumSetDebugOutput(debug, value, "Trade::SceneConverterFeatures{}", { + return Containers::enumSetDebugOutput(debug, value, debug.immediateFlags() >= Debug::Flag::Packed ? "{}" : "Trade::SceneConverterFeatures{}", { SceneConverterFeature::ConvertMesh, SceneConverterFeature::ConvertMeshInPlace, SceneConverterFeature::ConvertMeshToData, diff --git a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp index 6b7b07739..078ee968f 100644 --- a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp @@ -296,10 +296,13 @@ struct AbstractImageConverterTest: TestSuite::Tester { void convertCompressed3DToFileThroughLevels(); void debugFeature(); + void debugFeaturePacked(); #ifdef MAGNUM_BUILD_DEPRECATED void debugFeatureDeprecated(); + void debugFeatureDeprecatedPacked(); #endif void debugFeatures(); + void debugFeaturesPacked(); void debugFeaturesSupersets(); void debugFlag(); void debugFlags(); @@ -535,10 +538,13 @@ AbstractImageConverterTest::AbstractImageConverterTest() { &AbstractImageConverterTest::convertCompressed3DToFileThroughLevels, &AbstractImageConverterTest::debugFeature, + &AbstractImageConverterTest::debugFeaturePacked, #ifdef MAGNUM_BUILD_DEPRECATED &AbstractImageConverterTest::debugFeatureDeprecated, + &AbstractImageConverterTest::debugFeatureDeprecatedPacked, #endif &AbstractImageConverterTest::debugFeatures, + &AbstractImageConverterTest::debugFeaturesPacked, &AbstractImageConverterTest::debugFeaturesSupersets, &AbstractImageConverterTest::debugFlag, &AbstractImageConverterTest::debugFlags}); @@ -4515,6 +4521,13 @@ void AbstractImageConverterTest::debugFeature() { CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressed2D Trade::ImageConverterFeature(0xdeadbeef)\n"); } +void AbstractImageConverterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressed2D << Debug::packed << ImageConverterFeature(0xdeadbeef) << ImageConverterFeature::Convert3D; + CORRADE_COMPARE(out.str(), "ConvertCompressed2D 0xdeadbeef Trade::ImageConverterFeature::Convert3D\n"); +} + #ifdef MAGNUM_BUILD_DEPRECATED void AbstractImageConverterTest::debugFeatureDeprecated() { std::ostringstream out; @@ -4524,6 +4537,16 @@ void AbstractImageConverterTest::debugFeatureDeprecated() { CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::ConvertCompressed1DToData|Trade::ImageConverterFeature::Levels Trade::ImageConverterFeature::Convert3DToFile|Trade::ImageConverterFeature::Levels\n"); } + +void AbstractImageConverterTest::debugFeatureDeprecatedPacked() { + std::ostringstream out; + + CORRADE_IGNORE_DEPRECATED_PUSH + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << ImageConverterFeature::ConvertCompressedLevels1DToData << Debug::packed << ImageConverterFeature::ConvertLevels3DToFile << ImageConverterFeature::Convert1D; + CORRADE_IGNORE_DEPRECATED_POP + CORRADE_COMPARE(out.str(), "ConvertCompressed1DToData|Levels Convert3DToFile|Levels Trade::ImageConverterFeature::Convert1D\n"); +} #endif void AbstractImageConverterTest::debugFeatures() { @@ -4533,6 +4556,13 @@ void AbstractImageConverterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Trade::ImageConverterFeature::Convert2DToData|Trade::ImageConverterFeature::ConvertCompressed2DToFile Trade::ImageConverterFeatures{}\n"); } +void AbstractImageConverterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (ImageConverterFeature::Convert2DToData|ImageConverterFeature::ConvertCompressed2DToFile) << Debug::packed << ImageConverterFeatures{} << ImageConverterFeature::Convert1D; + CORRADE_COMPARE(out.str(), "Convert2DToData|ConvertCompressed2DToFile {} Trade::ImageConverterFeature::Convert1D\n"); +} + void AbstractImageConverterTest::debugFeaturesSupersets() { /* Convert*DToData is a superset of Convert*DToFile, so only one should be printed */ diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index c8464df4f..23dd7fc25 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -373,7 +373,9 @@ struct AbstractImporterTest: TestSuite::Tester { void importerStateNoFile(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); void debugFlag(); void debugFlags(); }; @@ -699,7 +701,9 @@ AbstractImporterTest::AbstractImporterTest() { &AbstractImporterTest::importerStateNoFile, &AbstractImporterTest::debugFeature, + &AbstractImporterTest::debugFeaturePacked, &AbstractImporterTest::debugFeatures, + &AbstractImporterTest::debugFeaturesPacked, &AbstractImporterTest::debugFlag, &AbstractImporterTest::debugFlags}); } @@ -7695,6 +7699,13 @@ void AbstractImporterTest::debugFeature() { CORRADE_COMPARE(out.str(), "Trade::ImporterFeature::OpenData Trade::ImporterFeature(0xf0)\n"); } +void AbstractImporterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << ImporterFeature::OpenData << Debug::packed << ImporterFeature(0xf0) << ImporterFeature::FileCallback; + CORRADE_COMPARE(out.str(), "OpenData 0xf0 Trade::ImporterFeature::FileCallback\n"); +} + void AbstractImporterTest::debugFeatures() { std::ostringstream out; @@ -7702,6 +7713,13 @@ void AbstractImporterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Trade::ImporterFeature::OpenData|Trade::ImporterFeature::OpenState Trade::ImporterFeatures{}\n"); } +void AbstractImporterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (ImporterFeature::OpenData|ImporterFeature::OpenState) << Debug::packed << ImporterFeatures{} << ImporterFeature::FileCallback; + CORRADE_COMPARE(out.str(), "OpenData|OpenState {} Trade::ImporterFeature::FileCallback\n"); +} + void AbstractImporterTest::debugFlag() { std::ostringstream out; diff --git a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp index 4b171c762..1398f24e0 100644 --- a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp @@ -275,7 +275,9 @@ struct AbstractSceneConverterTest: TestSuite::Tester { void addImage3DThroughLevels(); void debugFeature(); + void debugFeaturePacked(); void debugFeatures(); + void debugFeaturesPacked(); void debugFeaturesSupersets(); void debugFlag(); void debugFlags(); @@ -488,7 +490,9 @@ AbstractSceneConverterTest::AbstractSceneConverterTest() { &AbstractSceneConverterTest::addImage3DThroughLevels, &AbstractSceneConverterTest::debugFeature, + &AbstractSceneConverterTest::debugFeaturePacked, &AbstractSceneConverterTest::debugFeatures, + &AbstractSceneConverterTest::debugFeaturesPacked, &AbstractSceneConverterTest::debugFeaturesSupersets, &AbstractSceneConverterTest::debugFlag, &AbstractSceneConverterTest::debugFlags}); @@ -5358,6 +5362,13 @@ void AbstractSceneConverterTest::debugFeature() { CORRADE_COMPARE(out.str(), "Trade::SceneConverterFeature::ConvertMeshInPlace Trade::SceneConverterFeature(0xdeaddead)\n"); } +void AbstractSceneConverterTest::debugFeaturePacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << SceneConverterFeature::ConvertMeshInPlace << Debug::packed << SceneConverterFeature(0xdeaddead) << SceneConverterFeature::AddCameras; + CORRADE_COMPARE(out.str(), "ConvertMeshInPlace 0xdeaddead Trade::SceneConverterFeature::AddCameras\n"); +} + void AbstractSceneConverterTest::debugFeatures() { std::ostringstream out; @@ -5365,6 +5376,13 @@ void AbstractSceneConverterTest::debugFeatures() { CORRADE_COMPARE(out.str(), "Trade::SceneConverterFeature::ConvertMesh|Trade::SceneConverterFeature::ConvertMeshToFile Trade::SceneConverterFeatures{}\n"); } +void AbstractSceneConverterTest::debugFeaturesPacked() { + std::ostringstream out; + /* Last is not packed, ones before should not make any flags persistent */ + Debug{&out} << Debug::packed << (SceneConverterFeature::ConvertMesh|SceneConverterFeature::ConvertMeshToFile) << Debug::packed << SceneConverterFeatures{} << SceneConverterFeature::AddLights; + CORRADE_COMPARE(out.str(), "ConvertMesh|ConvertMeshToFile {} Trade::SceneConverterFeature::AddLights\n"); +} + void AbstractSceneConverterTest::debugFeaturesSupersets() { /* ConvertMeshToData is a superset of ConvertMeshToFile, so only one should be printed */