diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index 544fc0b34..1acb1126d 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -35,7 +35,7 @@ AbstractImporter::AbstractImporter() = default; AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): PluginManager::AbstractPlugin(manager, std::move(plugin)) {} -bool AbstractImporter::openData(Containers::ArrayReference data) { +bool AbstractImporter::openData(Containers::ArrayReference data) { CORRADE_ASSERT(features() & Feature::OpenData, "Audio::AbstractImporter::openData(): feature not supported", nullptr); @@ -44,7 +44,7 @@ bool AbstractImporter::openData(Containers::ArrayReference return isOpened(); } -void AbstractImporter::doOpenData(Containers::ArrayReference) { +void AbstractImporter::doOpenData(Containers::ArrayReference) { CORRADE_ASSERT(false, "Audio::AbstractImporter::openData(): feature advertised but not implemented", ); } @@ -83,7 +83,7 @@ UnsignedInt AbstractImporter::frequency() const { return doFrequency(); } -Containers::Array AbstractImporter::data() { +Containers::Array AbstractImporter::data() { CORRADE_ASSERT(isOpened(), "Audio::AbstractImporter::data(): no file opened", nullptr); return doData(); } diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 0dd932808..7ecc338c4 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -103,7 +103,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin * `true` on success, `false` otherwise. * @see @ref features(), @ref openFile() */ - bool openData(Containers::ArrayReference data); + bool openData(Containers::ArrayReference data); /** * @brief Open file @@ -126,7 +126,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin UnsignedInt frequency() const; /** @brief Sample data */ - Containers::Array data(); + Containers::Array data(); /*@}*/ @@ -142,7 +142,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin virtual bool doIsOpened() const = 0; /** @brief Implementation for @ref openData() */ - virtual void doOpenData(Containers::ArrayReference data); + virtual void doOpenData(Containers::ArrayReference data); /** * @brief Implementation for @ref openFile() @@ -162,7 +162,7 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin virtual UnsignedInt doFrequency() const = 0; /** @brief Implementation for @ref data() */ - virtual Containers::Array doData() = 0; + virtual Containers::Array doData() = 0; }; }} diff --git a/src/Magnum/Audio/Test/AbstractImporterTest.cpp b/src/Magnum/Audio/Test/AbstractImporterTest.cpp index f1665c383..0e8af085d 100644 --- a/src/Magnum/Audio/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Audio/Test/AbstractImporterTest.cpp @@ -53,13 +53,13 @@ void AbstractImporterTest::openFile() { bool doIsOpened() const override { return opened; } void doClose() override {} - void doOpenData(Containers::ArrayReference data) override { - opened = (data.size() == 1 && data[0] == 0xa5); + void doOpenData(Containers::ArrayReference data) override { + opened = (data.size() == 1 && data[0] == '\xa5'); } Buffer::Format doFormat() const override { return {}; } UnsignedInt doFrequency() const override { return {}; } - Corrade::Containers::Array doData() override { return nullptr; } + Corrade::Containers::Array doData() override { return nullptr; } bool opened; }; diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 5f4fa436c..bcbff3195 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -951,7 +951,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @requires_gl Buffer data queries are not available in OpenGL ES. * Use @ref Magnum::Buffer::map() "map()" instead. */ - template Containers::Array data(); + template Containers::Array data(); /** * @brief Buffer subdata @@ -969,7 +969,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @requires_gl Buffer data queries are not available in OpenGL ES. * Use @ref Magnum::Buffer::map() "map()" instead. */ - template Containers::Array subData(GLintptr offset, GLsizeiptr size); + template Containers::Array subData(GLintptr offset, GLsizeiptr size); #endif /** diff --git a/src/Magnum/Image.cpp b/src/Magnum/Image.cpp index ab94f8f58..adecf4b47 100644 --- a/src/Magnum/Image.cpp +++ b/src/Magnum/Image.cpp @@ -32,7 +32,7 @@ template void Image::setData(ColorFormat for _format = format; _type = type; _size = size; - _data = reinterpret_cast(data); + _data = reinterpret_cast(data); } #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 7f7eade84..a9800a75d 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -54,7 +54,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - explicit Image(ColorFormat format, ColorType type, const VectorTypeFor& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit Image(ColorFormat format, ColorType type, const VectorTypeFor& size, void* data): AbstractImage{format, type}, _size{size}, _data{reinterpret_cast(data)} {} /** * @brief Constructor @@ -64,7 +64,7 @@ template class Image: public AbstractImage { * Dimensions are set to zero and data pointer to `nullptr`, call * @ref setData() to fill the image with data. */ - /*implicit*/ Image(ColorFormat format, ColorType type): AbstractImage(format, type), _data(nullptr) {} + /*implicit*/ Image(ColorFormat format, ColorType type): AbstractImage(format, type), _data{} {} /** @brief Copying is not allowed */ Image(const Image&) = delete; @@ -113,12 +113,12 @@ template class Image: public AbstractImage { * * @see @ref release() */ - template T* data() { + template T* data() { return reinterpret_cast(_data); } /** @overload */ - template const T* data() const { + template const T* data() const { return reinterpret_cast(_data); } @@ -142,11 +142,11 @@ template class Image: public AbstractImage { * to default. Deleting the returned array is then user responsibility. * @see @ref setData() */ - unsigned char* release(); + char* release(); private: Math::Vector _size; - unsigned char* _data; + char* _data; }; /** @brief One-dimensional image */ @@ -180,9 +180,9 @@ const return ImageReference(AbstractImage::format(), AbstractImage::type(), _size, _data); } -template inline unsigned char* Image::release() { +template inline char* Image::release() { /** @todo I need `std::exchange` NOW. */ - unsigned char* const data = _data; + char* const data = _data; _size = {}; _data = nullptr; return data; diff --git a/src/Magnum/ImageReference.h b/src/Magnum/ImageReference.h index b896eff16..1fac76b59 100644 --- a/src/Magnum/ImageReference.h +++ b/src/Magnum/ImageReference.h @@ -61,7 +61,7 @@ template class ImageReference: public AbstractImage { * @param size Image size * @param data Image data */ - constexpr explicit ImageReference(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + constexpr explicit ImageReference(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -83,10 +83,10 @@ template class ImageReference: public AbstractImage { } /** @brief Pointer to raw data */ - constexpr const unsigned char* data() const { return _data; } + constexpr const char* data() const { return _data; } /** @overload */ - template const T* data() const { + template const T* data() const { return reinterpret_cast(_data); } @@ -99,12 +99,12 @@ template class ImageReference: public AbstractImage { * destruction. */ void setData(const void* data) { - _data = reinterpret_cast(data); + _data = reinterpret_cast(data); } private: Math::Vector _size; - const unsigned char* _data; + const char* _data; }; /** @brief One-dimensional image wrapper */ diff --git a/src/Magnum/Test/BufferImageGLTest.cpp b/src/Magnum/Test/BufferImageGLTest.cpp index e982d1c57..e688d5cce 100644 --- a/src/Magnum/Test/BufferImageGLTest.cpp +++ b/src/Magnum/Test/BufferImageGLTest.cpp @@ -50,11 +50,11 @@ BufferImageTest::BufferImageTest() { } void BufferImageTest::construct() { - const unsigned char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0, 'c', 0, 0, 0 }; + const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0, 'c', 0, 0, 0 }; BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data, BufferUsage::StaticDraw); #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); + const auto imageData = a.buffer().data(); #endif MAGNUM_VERIFY_NO_ERROR(); @@ -65,8 +65,8 @@ void BufferImageTest::construct() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), - std::vector(data, data + 12), + CORRADE_COMPARE_AS(std::vector(imageData.begin(), imageData.end()), + std::vector(data, data + 12), TestSuite::Compare::Container); #endif } @@ -77,7 +77,7 @@ void BufferImageTest::constructCopy() { } void BufferImageTest::constructMove() { - const unsigned char data[4] = { 'a', 'b', 'c', 'd' }; + const char data[4] = { 'a', 'b', 'c', 'd' }; BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw); const Int id = a.buffer().id(); @@ -112,10 +112,10 @@ void BufferImageTest::constructMove() { } void BufferImageTest::setData() { - const unsigned char data[4] = { 'a', 'b', 'c', 'd' }; + const char data[4] = { 'a', 'b', 'c', 'd' }; BufferImage2D a(ColorFormat::Red, ColorType::UnsignedByte, {4, 1}, data, BufferUsage::StaticDraw); - const unsigned short data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 }; + const UnsignedShort data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 }; a.setData(ColorFormat::RGBA, ColorType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw); #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/ImageReferenceTest.cpp b/src/Magnum/Test/ImageReferenceTest.cpp index 6ec60ac03..841617559 100644 --- a/src/Magnum/Test/ImageReferenceTest.cpp +++ b/src/Magnum/Test/ImageReferenceTest.cpp @@ -43,7 +43,7 @@ ImageReferenceTest::ImageReferenceTest() { } void ImageReferenceTest::construct() { - const unsigned char data[3] = {}; + const char data[3] = {}; ImageReference2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); CORRADE_COMPARE(a.format(), ColorFormat::Red); @@ -53,15 +53,15 @@ void ImageReferenceTest::construct() { } void ImageReferenceTest::setData() { - const unsigned char data[3] = {}; + const char data[3] = {}; ImageReference2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - const unsigned char data2[8] = {}; + const char data2[8] = {}; a.setData(data2); CORRADE_COMPARE(a.format(), ColorFormat::Red); CORRADE_COMPARE(a.type(), ColorType::UnsignedByte); CORRADE_COMPARE(a.size(), Vector2i(1, 3)); - CORRADE_COMPARE(a.data(), reinterpret_cast(data2)); + CORRADE_COMPARE(a.data(), data2); } }} diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index b08275c76..c6c6e1aa1 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -53,7 +53,7 @@ ImageTest::ImageTest() { } void ImageTest::construct() { - auto data = new unsigned char[3]; + auto data = new char[3]; Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); CORRADE_COMPARE(a.format(), ColorFormat::Red); @@ -68,7 +68,7 @@ void ImageTest::constructCopy() { } void ImageTest::constructMove() { - auto data = new unsigned char[3]; + auto data = new char[3]; Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); Image2D b(std::move(a)); @@ -80,7 +80,7 @@ void ImageTest::constructMove() { CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); - auto data2 = new unsigned char[3]; + auto data2 = new char[12*4*2]; Image2D c(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 6}, data2); c = std::move(b); @@ -94,19 +94,19 @@ void ImageTest::constructMove() { } void ImageTest::setData() { - auto data = new unsigned char[3]; + auto data = new char[3]; Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); - auto data2 = new unsigned short[2*4]; + auto data2 = new char[2*4]; a.setData(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 1}, data2); CORRADE_COMPARE(a.format(), ColorFormat::RGBA); CORRADE_COMPARE(a.type(), ColorType::UnsignedShort); CORRADE_COMPARE(a.size(), Vector2i(2, 1)); - CORRADE_COMPARE(a.data(), reinterpret_cast(data2)); + CORRADE_COMPARE(a.data(), data2); } void ImageTest::toReference() { - auto data = new unsigned char[3]; + auto data = new char[3]; const Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); ImageReference2D b = a; @@ -126,9 +126,9 @@ void ImageTest::toReference() { } void ImageTest::release() { - unsigned char data[] = {'c', 'a', 'f', 'e'}; + char data[] = {'c', 'a', 'f', 'e'}; Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data); - const unsigned char* const pointer = a.release(); + const char* const pointer = a.release(); CORRADE_COMPARE(pointer, data); CORRADE_COMPARE(a.data(), nullptr); diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 7b7f48d81..e817d4a7e 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -38,7 +38,7 @@ AbstractFont::AbstractFont(): _size(0.0f) {} AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)), _size(0.0f), _lineHeight(0.0f) {} -bool AbstractFont::openData(const std::vector>>& data, const Float size) { +bool AbstractFont::openData(const std::vector>>& data, const Float size) { CORRADE_ASSERT(features() & Feature::OpenData, "Text::AbstractFont::openData(): feature not supported", false); CORRADE_ASSERT(!data.empty(), @@ -50,7 +50,7 @@ bool AbstractFont::openData(const std::vector AbstractFont::doOpenData(const std::vector>>& data, const Float size) { +std::pair AbstractFont::doOpenData(const std::vector>>& data, const Float size) { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFont::openData(): feature advertised but not implemented", {}); CORRADE_ASSERT(data.size() == 1, @@ -60,7 +60,7 @@ std::pair AbstractFont::doOpenData(const std::vector data, const Float size) { +bool AbstractFont::openSingleData(const Containers::ArrayReference data, const Float size) { CORRADE_ASSERT(features() & Feature::OpenData, "Text::AbstractFont::openSingleData(): feature not supported", false); CORRADE_ASSERT(!(features() & Feature::MultiFile), @@ -72,7 +72,7 @@ bool AbstractFont::openSingleData(const Containers::ArrayReference AbstractFont::doOpenSingleData(Containers::ArrayReference, Float) { +std::pair AbstractFont::doOpenSingleData(Containers::ArrayReference, Float) { CORRADE_ASSERT(false, "Text::AbstractFont::openSingleData(): feature advertised but not implemented", {}); } diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index abbf650e1..b7354078a 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -125,7 +125,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * file. Available only if @ref Feature::OpenData is supported. Returns * `true` on success, `false` otherwise. */ - bool openData(const std::vector>>& data, Float size); + bool openData(const std::vector>>& data, Float size); /** * @brief Open font from single data @@ -137,7 +137,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * plugin doesn't have @ref Feature::MultiFile. Returns `true` on * success, `false` otherwise. */ - bool openSingleData(Containers::ArrayReference data, Float size); + bool openSingleData(Containers::ArrayReference data, Float size); /** * @brief Open font from file @@ -243,7 +243,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * zeros otherwise. If the plugin doesn't have @ref Feature::MultiFile, * default implementation calls @ref doOpenSingleData(). */ - virtual std::pair doOpenData(const std::vector>>& data, Float size); + virtual std::pair doOpenData(const std::vector>>& data, Float size); /** * @brief Implementation for @ref openSingleData() @@ -251,7 +251,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * Return size and line height of opened font on successful opening, * zeros otherwise. */ - virtual std::pair doOpenSingleData(Containers::ArrayReference data, Float size); + virtual std::pair doOpenSingleData(Containers::ArrayReference data, Float size); /** * @brief Implementation for @ref openFile() diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index b5b19bbea..1718e575d 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -39,7 +39,7 @@ AbstractFontConverter::AbstractFontConverter() = default; AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, std::string plugin): PluginManager::AbstractPlugin(manager, std::move(plugin)) {} -std::vector>> AbstractFontConverter::exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const { +std::vector>> AbstractFontConverter::exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const { CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData), "Text::AbstractFontConverter::exportFontToData(): feature not supported", {}); @@ -47,20 +47,20 @@ std::vector>> AbstractFo } #ifndef __MINGW32__ -std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const +std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const #else -std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const +std::vector>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const #endif { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {}); - std::vector>> out; + std::vector>> out; out.emplace_back(filename, std::move(doExportFontToSingleData(font, cache, characters))); return std::move(out); } -Containers::Array AbstractFontConverter::exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const { +Containers::Array AbstractFontConverter::exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const { CORRADE_ASSERT(features() >= (Feature::ExportFont|Feature::ConvertData), "Text::AbstractFontConverter::exportFontToSingleData(): feature not supported", nullptr); CORRADE_ASSERT(!(features() & Feature::MultiFile), @@ -70,9 +70,9 @@ Containers::Array AbstractFontConverter::exportFontToSingleData(A } #ifndef __MINGW32__ -Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const +Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const #else -Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const +Containers::Array AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const #endif { CORRADE_ASSERT(false, @@ -105,23 +105,23 @@ bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& c return true; } -std::vector>> AbstractFontConverter::exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { +std::vector>> AbstractFontConverter::exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData), "Text::AbstractFontConverter::exportGlyphCacheToData(): feature not supported", {}); return doExportGlyphCacheToData(cache, filename); } -std::vector>> AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { +std::vector>> AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", {}); - std::vector>> out; + std::vector>> out; out.emplace_back(filename, std::move(doExportGlyphCacheToSingleData(cache))); return std::move(out); } -Containers::Array AbstractFontConverter::exportGlyphCacheToSingleData(GlyphCache& cache) const { +Containers::Array AbstractFontConverter::exportGlyphCacheToSingleData(GlyphCache& cache) const { CORRADE_ASSERT(features() >= (Feature::ExportGlyphCache|Feature::ConvertData), "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature not supported", nullptr); CORRADE_ASSERT(!(features() & Feature::MultiFile), @@ -130,7 +130,7 @@ Containers::Array AbstractFontConverter::exportGlyphCacheToSingle return doExportGlyphCacheToSingleData(cache); } -Containers::Array AbstractFontConverter::doExportGlyphCacheToSingleData(GlyphCache&) const { +Containers::Array AbstractFontConverter::doExportGlyphCacheToSingleData(GlyphCache&) const { CORRADE_ASSERT(false, "Text::AbstractFontConverter::exportGlyphCacheToSingleData(): feature advertised but not implemented", nullptr); } @@ -156,7 +156,7 @@ bool AbstractFontConverter::doExportGlyphCacheToFile(GlyphCache& cache, const st return true; } -std::unique_ptr AbstractFontConverter::importGlyphCacheFromData(const std::vector>>& data) const { +std::unique_ptr AbstractFontConverter::importGlyphCacheFromData(const std::vector>>& data) const { CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported", nullptr); CORRADE_ASSERT(!data.empty(), @@ -165,7 +165,7 @@ std::unique_ptr AbstractFontConverter::importGlyphCacheFromData(cons return doImportGlyphCacheFromData(data); } -std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromData(const std::vector>>& data) const { +std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromData(const std::vector>>& data) const { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented", nullptr); CORRADE_ASSERT(data.size() == 1, @@ -174,7 +174,7 @@ std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromData(co return doImportGlyphCacheFromSingleData(data[0].second); } -std::unique_ptr AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayReference data) const { +std::unique_ptr AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayReference data) const { CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported", nullptr); CORRADE_ASSERT(!(features() & Feature::MultiFile), @@ -183,7 +183,7 @@ std::unique_ptr AbstractFontConverter::importGlyphCacheFromSingleDat return doImportGlyphCacheFromSingleData(data); } -std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromSingleData(Containers::ArrayReference) const { +std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromSingleData(Containers::ArrayReference) const { CORRADE_ASSERT(false, "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented", nullptr); } diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index 3dda571d7..5d0741ff9 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -149,7 +149,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref exportFontToFile(), * @ref exportGlyphCacheToData() */ - std::vector>> exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const; + std::vector>> exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const; /** * @brief Export font to single raw data @@ -161,7 +161,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref exportFontToFile(), * @ref exportGlyphCacheToSingleData() */ - Containers::Array exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const; + Containers::Array exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const; /** * @brief Export font to file @@ -193,7 +193,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref exportGlyphCacheToFile(), * @ref exportFontToData() */ - std::vector>> exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const; + std::vector>> exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const; /** * @brief Export glyph cache to single raw data @@ -205,7 +205,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref exportGlyphCacheToFile(), * @ref importGlyphCacheFromSingleData() */ - Containers::Array exportGlyphCacheToSingleData(GlyphCache& cache) const; + Containers::Array exportGlyphCacheToSingleData(GlyphCache& cache) const; /** * @brief Export glyph cache to file @@ -232,7 +232,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref importGlyphCacheFromFile(), * @ref exportGlyphCacheToData() */ - std::unique_ptr importGlyphCacheFromData(const std::vector>>& data) const; + std::unique_ptr importGlyphCacheFromData(const std::vector>>& data) const; /** * @brief Import glyph cache from single raw data @@ -244,7 +244,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @see @ref features(), @ref importGlyphCacheFromFile(), * @ref exportFontToSingleData() */ - std::unique_ptr importGlyphCacheFromSingleData(Containers::ArrayReference data) const; + std::unique_ptr importGlyphCacheFromSingleData(Containers::ArrayReference data) const; /** * @brief Import glyph cache from file @@ -277,9 +277,9 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * for more information. */ #ifndef __MINGW32__ - virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; + virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; #else - virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const; + virtual std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const; #endif /** @@ -290,9 +290,9 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * for more information. */ #ifndef __MINGW32__ - virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const; + virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const; #else - virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector& characters) const; + virtual Containers::Array doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector& characters) const; #endif /** @@ -317,10 +317,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * If the plugin doesn't have @ref Feature::MultiFile, default * implementation calls @ref doExportGlyphCacheToSingleData(). */ - virtual std::vector>> doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const; + virtual std::vector>> doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const; /** @brief Implementation for @ref exportGlyphCacheToSingleData() */ - virtual Containers::Array doExportGlyphCacheToSingleData(GlyphCache& cache) const; + virtual Containers::Array doExportGlyphCacheToSingleData(GlyphCache& cache) const; /** * @brief Implementation for @ref exportGlyphCacheToFile() @@ -337,10 +337,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * If the plugin doesn't have @ref Feature::MultiFile, default * implementation calls @ref doImportGlyphCacheFromSingleData(). */ - virtual std::unique_ptr doImportGlyphCacheFromData(const std::vector>>& data) const; + virtual std::unique_ptr doImportGlyphCacheFromData(const std::vector>>& data) const; /** @brief Implementation for @ref importGlyphCacheFromSingleData() */ - virtual std::unique_ptr doImportGlyphCacheFromSingleData(Containers::ArrayReference data) const; + virtual std::unique_ptr doImportGlyphCacheFromSingleData(Containers::ArrayReference data) const; /** * @brief Implementation for @ref importGlyphCacheFromFile() diff --git a/src/Magnum/Text/Renderer.cpp b/src/Magnum/Text/Renderer.cpp index b06192e85..62816ed6e 100644 --- a/src/Magnum/Text/Renderer.cpp +++ b/src/Magnum/Text/Renderer.cpp @@ -172,23 +172,23 @@ std::tuple, Range2D> renderVerticesInternal(AbstractFont& fo return std::make_tuple(std::move(vertices), rectangle); } -std::pair, Mesh::IndexType> renderIndicesInternal(const UnsignedInt glyphCount) { +std::pair, Mesh::IndexType> renderIndicesInternal(const UnsignedInt glyphCount) { const UnsignedInt vertexCount = glyphCount*4; const UnsignedInt indexCount = glyphCount*6; - Containers::Array indices; + Containers::Array indices; Mesh::IndexType indexType; if(vertexCount <= 256) { indexType = Mesh::IndexType::UnsignedByte; - indices = Containers::Array(indexCount*sizeof(UnsignedByte)); + indices = Containers::Array(indexCount*sizeof(UnsignedByte)); createIndices(indices, glyphCount); } else if(vertexCount <= 65536) { indexType = Mesh::IndexType::UnsignedShort; - indices = Containers::Array(indexCount*sizeof(UnsignedShort)); + indices = Containers::Array(indexCount*sizeof(UnsignedShort)); createIndices(indices, glyphCount); } else { indexType = Mesh::IndexType::UnsignedInt; - indices = Containers::Array(indexCount*sizeof(UnsignedInt)); + indices = Containers::Array(indexCount*sizeof(UnsignedInt)); createIndices(indices, glyphCount); } @@ -206,7 +206,7 @@ std::tuple renderInternal(AbstractFont& font, const GlyphCache& c const UnsignedInt indexCount = glyphCount*6; /* Render indices and upload them */ - Containers::Array indices; + Containers::Array indices; Mesh::IndexType indexType; std::tie(indices, indexType) = renderIndicesInternal(glyphCount); indexBuffer.setData(indices, usage); @@ -345,7 +345,7 @@ void AbstractRenderer::reserve(const uint32_t glyphCount, const BufferUsage vert _mesh.setCount(0); /* Render indices */ - Containers::Array indexData; + Containers::Array indexData; Mesh::IndexType indexType; std::tie(indexData, indexType) = renderIndicesInternal(glyphCount); @@ -358,7 +358,7 @@ void AbstractRenderer::reserve(const uint32_t glyphCount, const BufferUsage vert .setIndexBuffer(_indexBuffer, 0, indexType, 0, vertexCount); /* Prefill index buffer */ - unsigned char* const indices = static_cast(bufferMapImplementation(_indexBuffer, indexData.size())); + char* const indices = static_cast(bufferMapImplementation(_indexBuffer, indexData.size())); CORRADE_INTERNAL_ASSERT(indices); /** @todo Emscripten: it can be done without this copying altogether */ std::copy(indexData.begin(), indexData.end(), indices); diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index 6bf54ee0b..1886865bb 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "Magnum/Text/AbstractFontConverter.h" @@ -65,7 +66,7 @@ AbstractFontConverterTest::AbstractFontConverterTest() { namespace { /* *static_cast(nullptr) makes Clang Analyzer grumpy */ - unsigned char nullData; + char nullData; AbstractFont& nullFont = *reinterpret_cast(nullData); GlyphCache& nullGlyphCache = *reinterpret_cast(nullData); } @@ -83,9 +84,9 @@ void AbstractFontConverterTest::convertGlyphs() { Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } #ifndef __MINGW32__ - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override #else - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector& characters) const override + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector& characters) const override #endif { this->characters = characters; @@ -120,13 +121,13 @@ void AbstractFontConverterTest::exportFontToSingleData() { Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } #ifndef __MINGW32__ - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override #else - Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const override + Containers::Array doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector&) const override #endif { - Containers::Array data(1); - data[0] = 0xee; + Containers::Array data(1); + data[0] = '\xee'; return std::move(data); } }; @@ -137,7 +138,7 @@ void AbstractFontConverterTest::exportFontToSingleData() { CORRADE_COMPARE(ret.size(), 1); CORRADE_COMPARE(ret[0].first, "font.out"); CORRADE_COMPARE(ret[0].second.size(), 1); - CORRADE_COMPARE(ret[0].second[0], 0xee); + CORRADE_COMPARE(ret[0].second[0], '\xee'); } void AbstractFontConverterTest::exportFontToFile() { @@ -146,22 +147,17 @@ void AbstractFontConverterTest::exportFontToFile() { Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; } #ifndef __MINGW32__ - std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override + std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override #else - std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector&) const override + std::vector>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector&) const override #endif { - Containers::Array file(1); - file[0] = 0xf0; - - Containers::Array data(2); - data[0] = 0xfe; - data[1] = 0xed; - - std::vector>> out; - out.emplace_back(filename, std::move(file)); - out.emplace_back(filename + ".data", std::move(data)); - return std::move(out); + /* Why the hell GCC 4.9 fails to do proper move so I need to + work around that this ugly way?! */ + std::vector>> ret; + ret.emplace_back(filename, Containers::Array::from('\xf0')); + ret.emplace_back(filename + ".data", Containers::Array::from('\xfe', '\xed')); + return ret; } }; @@ -184,10 +180,8 @@ void AbstractFontConverterTest::exportGlyphCacheToSingleData() { private: Features doFeatures() const override { return Feature::ConvertData|Feature::ExportGlyphCache; } - Containers::Array doExportGlyphCacheToSingleData(GlyphCache&) const override { - Containers::Array data(1); - data[0] = 0xee; - return std::move(data); + Containers::Array doExportGlyphCacheToSingleData(GlyphCache&) const override { + return Containers::Array::from('\xee'); } }; @@ -196,8 +190,7 @@ void AbstractFontConverterTest::exportGlyphCacheToSingleData() { auto ret = exporter.exportGlyphCacheToData(nullGlyphCache, "font.out"); CORRADE_COMPARE(ret.size(), 1); CORRADE_COMPARE(ret[0].first, "font.out"); - CORRADE_COMPARE(ret[0].second.size(), 1); - CORRADE_COMPARE(ret[0].second[0], 0xee); + CORRADE_COMPARE_AS(ret[0].second, Containers::Array::from('\xee'), TestSuite::Compare::Container); } void AbstractFontConverterTest::exportGlyphCacheToFile() { @@ -205,18 +198,13 @@ void AbstractFontConverterTest::exportGlyphCacheToFile() { private: Features doFeatures() const override { return Feature::ConvertData|Feature::ExportGlyphCache|Feature::MultiFile; } - std::vector>> doExportGlyphCacheToData(GlyphCache&, const std::string& filename) const override { - Containers::Array file(1); - file[0] = 0xf0; - - Containers::Array data(2); - data[0] = 0xfe; - data[1] = 0xed; - - std::vector>> out; - out.emplace_back(filename, std::move(file)); - out.emplace_back(filename + ".data", std::move(data)); - return std::move(out); + std::vector>> doExportGlyphCacheToData(GlyphCache&, const std::string& filename) const override { + /* Why the hell GCC 4.9 fails to do proper move so I need to + work around that this ugly way?! */ + std::vector>> ret; + ret.emplace_back(filename, Containers::Array::from('\xf0')); + ret.emplace_back(filename + ".data", Containers::Array::from('\xfe', '\xed')); + return ret; } }; @@ -240,8 +228,8 @@ class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter { private: Features doFeatures() const override { return Feature::ConvertData|Feature::ImportGlyphCache; } - std::unique_ptr doImportGlyphCacheFromSingleData(const Containers::ArrayReference data) const override { - if(data.size() == 1 && data[0] == 0xa5) + std::unique_ptr doImportGlyphCacheFromSingleData(const Containers::ArrayReference data) const override { + if(data.size() == 1 && data[0] == '\xa5') return std::unique_ptr(reinterpret_cast(0xdeadbeef)); return nullptr; } @@ -252,7 +240,7 @@ class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter { void AbstractFontConverterTest::importGlyphCacheFromSingleData() { /* doImportFromData() should call doImportFromSingleData() */ SingleGlyphCacheDataImporter importer; - const unsigned char data[] = {0xa5}; + const char data[] = {'\xa5'}; std::unique_ptr cache = importer.importGlyphCacheFromData({{{}, data}}); CORRADE_COMPARE(cache.get(), reinterpret_cast(0xdeadbeef)); diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index 1a3b45ddc..d4b780950 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -56,8 +56,8 @@ class SingleDataFont: public Text::AbstractFont { bool doIsOpened() const override { return opened; } void doClose() override {} - std::pair doOpenSingleData(const Containers::ArrayReference data, Float) override { - opened = (data.size() == 1 && data[0] == 0xa5); + std::pair doOpenSingleData(const Containers::ArrayReference data, Float) override { + opened = (data.size() == 1 && data[0] == '\xa5'); return {}; } @@ -77,7 +77,7 @@ class SingleDataFont: public Text::AbstractFont { void AbstractFontTest::openSingleData() { /* doOpenData() should call doOpenSingleData() */ SingleDataFont font; - const unsigned char data[] = {0xa5}; + const char data[] = {'\xa5'}; CORRADE_VERIFY(!font.isOpened()); font.openData({{{}, data}}, 3.0f); CORRADE_VERIFY(font.isOpened()); diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index cd12f93df..bede62c5d 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -82,7 +82,7 @@ class TestFont: public Text::AbstractFont { }; /* *static_cast(nullptr) makes Clang Analyzer grumpy */ -unsigned char glyphCacheData; +char glyphCacheData; GlyphCache& nullGlyphCache = *reinterpret_cast(&glyphCacheData); } diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 1ce5d092b..fac848f00 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -46,14 +46,14 @@ Image2D* AbstractImageConverter::doExportToImage(const ImageReference2D&) const CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToImage(): feature advertised but not implemented", nullptr); } -Containers::Array AbstractImageConverter::exportToData(const ImageReference2D& image) const { +Containers::Array AbstractImageConverter::exportToData(const ImageReference2D& image) const { CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToData(): feature not supported", nullptr); return doExportToData(image); } -Containers::Array AbstractImageConverter::doExportToData(const ImageReference2D&) const { +Containers::Array AbstractImageConverter::doExportToData(const ImageReference2D&) const { CORRADE_ASSERT(false, "Trade::AbstractImageConverter::exportToData(): feature advertised but not implemented", nullptr); } diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 48e347a52..cc0913f11 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -107,7 +107,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin * data on success, zero-sized array otherwise. * @see @ref features(), @ref exportToImage(), @ref exportToFile() */ - Containers::Array exportToData(const ImageReference2D& image) const; + Containers::Array exportToData(const ImageReference2D& image) const; /** * @brief Export image to file @@ -129,7 +129,7 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin virtual Image2D* doExportToImage(const ImageReference2D& image) const; /** @brief Implementation of @ref exportToData() */ - virtual Containers::Array doExportToData(const ImageReference2D& image) const; + virtual Containers::Array doExportToData(const ImageReference2D& image) const; /** * @brief Implementation of @ref exportToFile() diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index af4bb4947..fabc0902f 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -49,7 +49,7 @@ AbstractImporter::AbstractImporter(PluginManager::Manager& man AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): PluginManager::AbstractManagingPlugin(manager, std::move(plugin)) {} -bool AbstractImporter::openData(Containers::ArrayReference data) { +bool AbstractImporter::openData(Containers::ArrayReference data) { CORRADE_ASSERT(features() & Feature::OpenData, "Trade::AbstractImporter::openData(): feature not supported", nullptr); @@ -58,7 +58,7 @@ bool AbstractImporter::openData(Containers::ArrayReference return isOpened(); } -void AbstractImporter::doOpenData(Containers::ArrayReference) { +void AbstractImporter::doOpenData(Containers::ArrayReference) { CORRADE_ASSERT(false, "Trade::AbstractImporter::openData(): feature advertised but not implemented", ); } diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 0cdb5e8ce..f5172d863 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -116,7 +116,7 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlug * `true` on success, `false` otherwise. * @see @ref features(), @ref openFile() */ - bool openData(Containers::ArrayReference data); + bool openData(Containers::ArrayReference data); /** * @brief Open file @@ -483,7 +483,7 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlug virtual bool doIsOpened() const = 0; /** @brief Implementation for @ref openData() */ - virtual void doOpenData(Containers::ArrayReference data); + virtual void doOpenData(Containers::ArrayReference data); /** * @brief Implementation for @ref openFile() diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 86c16e1f7..ddca34e5b 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -54,7 +54,7 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - explicit ImageData(ColorFormat format, ColorType type, const VectorTypeFor& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {} + explicit ImageData(ColorFormat format, ColorType type, const VectorTypeFor& size, void* data): AbstractImage{format, type}, _size{size}, _data{reinterpret_cast(data)} {} /** @brief Copying is not allowed */ ImageData(const ImageData&) = delete; @@ -97,12 +97,12 @@ template class ImageData: public AbstractImage { * * @see @ref release() */ - template T* data() { + template T* data() { return reinterpret_cast(_data); } /** @overload */ - template const T* data() const { + template const T* data() const { return reinterpret_cast(_data); } @@ -113,11 +113,11 @@ template class ImageData: public AbstractImage { * to default. Deleting the returned array is then user responsibility. * @see @ref data() */ - unsigned char* release(); + char* release(); private: Math::Vector _size; - unsigned char* _data; + char* _data; }; /** @brief One-dimensional image */ @@ -151,9 +151,9 @@ const return ImageReference(AbstractImage::format(), AbstractImage::type(), _size, _data); } -template inline unsigned char* ImageData::release() { +template inline char* ImageData::release() { /** @todo I need `std::exchange` NOW. */ - unsigned char* const data = _data; + char* const data = _data; _size = {}; _data = nullptr; return data; diff --git a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp index 2514d7222..45d6f40dc 100644 --- a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp @@ -52,11 +52,8 @@ void AbstractImageConverterTest::exportToFile() { private: Features doFeatures() const override { return Feature::ConvertData; } - Containers::Array doExportToData(const ImageReference2D& image) const override { - Containers::Array out(2); - out[0] = static_cast(image.size().x()); - out[1] = static_cast(image.size().y()); - return out; + Containers::Array doExportToData(const ImageReference2D& image) const override { + return Containers::Array::from(char(image.size().x()), char(image.size().y())); }; }; diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index e8bcfae76..06f2a6b58 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -54,8 +54,8 @@ void AbstractImporterTest::openFile() { bool doIsOpened() const override { return opened; } void doClose() override {} - void doOpenData(Containers::ArrayReference data) override { - opened = (data.size() == 1 && data[0] == 0xa5); + void doOpenData(Containers::ArrayReference data) override { + opened = (data.size() == 1 && data[0] == '\xa5'); } bool opened; diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index 3e89daa5b..6d0f1a02c 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -52,7 +52,7 @@ ImageDataTest::ImageDataTest() { } void ImageDataTest::construct() { - auto data = new unsigned char[3]; + auto data = new char[3]; Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); CORRADE_COMPARE(a.format(), ColorFormat::Red); @@ -67,7 +67,7 @@ void ImageDataTest::constructCopy() { } void ImageDataTest::constructMove() { - auto data = new unsigned char[3]; + auto data = new char[3]; Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); Trade::ImageData2D b(std::move(a)); @@ -79,7 +79,7 @@ void ImageDataTest::constructMove() { CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); - auto data2 = new unsigned char[3]; + auto data2 = new char[3]; Trade::ImageData2D c(ColorFormat::RGBA, ColorType::UnsignedShort, {2, 6}, data2); c = std::move(b); @@ -93,7 +93,7 @@ void ImageDataTest::constructMove() { } void ImageDataTest::toReference() { - auto data = new unsigned char[3]; + auto data = new char[3]; const Trade::ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 3}, data); ImageReference2D b = a; @@ -113,9 +113,9 @@ void ImageDataTest::toReference() { } void ImageDataTest::release() { - unsigned char data[] = {'b', 'e', 'e', 'r'}; + char data[] = {'b', 'e', 'e', 'r'}; ImageData2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data); - const unsigned char* const pointer = a.release(); + const char* const pointer = a.release(); CORRADE_COMPARE(pointer, data); CORRADE_COMPARE(a.data(), nullptr); diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp index f6e7c7422..6578b7ccb 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp @@ -68,7 +68,7 @@ auto MagnumFont::doFeatures() const -> Features { return Feature::OpenData|Featu bool MagnumFont::doIsOpened() const { return _opened; } -std::pair MagnumFont::doOpenData(const std::vector>>& data, const Float) { +std::pair MagnumFont::doOpenData(const std::vector>>& data, const Float) { /* We need just the configuration file and image file */ if(data.size() != 2) { Error() << "Text::MagnumFont::openData(): wanted two files, got" << data.size(); @@ -76,7 +76,7 @@ std::pair MagnumFont::doOpenData(const std::vector(data[0].second.begin()), data[0].second.size()}); + std::istringstream in({data[0].second.begin(), data[0].second.size()}); Utility::Configuration conf(in, Utility::Configuration::Flag::SkipComments); if(!conf.isValid() || conf.isEmpty()) { Error() << "Text::MagnumFont::openData(): cannot open file" << data[0].first; diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.h b/src/MagnumPlugins/MagnumFont/MagnumFont.h index 0ae4bd918..4ff51174c 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.h +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.h @@ -120,7 +120,7 @@ class MagnumFont: public AbstractFont { bool doIsOpened() const override; - std::pair doOpenData(const std::vector>>& data, Float) override; + std::pair doOpenData(const std::vector>>& data, Float) override; std::pair doOpenFile(const std::string& filename, Float) override; diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp index 6783873a5..43d7956ca 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -46,9 +46,9 @@ auto MagnumFontConverter::doFeatures() const -> Features { } #ifndef __MINGW32__ -std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const +std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const #else -std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const +std::vector>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const #endif { Utility::Configuration configuration; @@ -100,7 +100,7 @@ std::vector>> MagnumFont std::ostringstream confOut; configuration.save(confOut); std::string confStr = confOut.str(); - Containers::Array confData{confStr.size()}; + Containers::Array confData{confStr.size()}; std::copy(confStr.begin(), confStr.end(), confData.begin()); /* Save cache image */ @@ -108,7 +108,7 @@ std::vector>> MagnumFont cache.texture().image(0, image); auto tgaData = Trade::TgaImageConverter().exportToData(image); - std::vector>> out; + std::vector>> out; out.emplace_back(filename + ".conf", std::move(confData)); out.emplace_back(filename + ".tga", std::move(tgaData)); return std::move(out); diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h index 5e7c0ec89..f82583770 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h @@ -61,9 +61,9 @@ class MagnumFontConverter: public Text::AbstractFontConverter { private: Features doFeatures() const override; #ifndef __MINGW32__ - std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; + std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; #else - std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const override; + std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector& characters) const override; #endif }; diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp index 397cae56c..bc8b5134e 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp @@ -132,10 +132,10 @@ void ObjImporter::doOpenFile(const std::string& filename) { parseMeshNames(); } -void ObjImporter::doOpenData(Containers::ArrayReference data) { +void ObjImporter::doOpenData(Containers::ArrayReference data) { /* Open file in *text* mode (to avoid \r handling) */ _file.reset(new File); - _file->in.reset(new std::istringstream{{reinterpret_cast(data.begin()), data.size()}}); + _file->in.reset(new std::istringstream{{data.begin(), data.size()}}); parseMeshNames(); } diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.h b/src/MagnumPlugins/ObjImporter/ObjImporter.h index 6c5b90269..28fe640d6 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.h +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.h @@ -67,7 +67,7 @@ class ObjImporter: public AbstractImporter { Features doFeatures() const override; bool doIsOpened() const override; - void doOpenData(Containers::ArrayReference data) override; + void doOpenData(Containers::ArrayReference data) override; void doOpenFile(const std::string& filename) override; void doClose() override; diff --git a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp index d6ef66d09..4ba6bbd56 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp +++ b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp @@ -107,8 +107,8 @@ void TgaImageConverterTest::data() { CORRADE_COMPARE(converted->format(), ColorFormat::RGB); #endif CORRADE_COMPARE(converted->type(), ColorType::UnsignedByte); - CORRADE_COMPARE(std::string(reinterpret_cast(converted->data()), 2*3*3), - std::string(reinterpret_cast(original.data()), 2*3*3)); + CORRADE_COMPARE((std::string{converted->data(), 2*3*3}), + (std::string{original.data(), 2*3*3})); } }}} diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index b4fa7e37e..24c8b7c48 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -48,7 +48,7 @@ TgaImageConverter::TgaImageConverter(PluginManager::AbstractManager& manager, st auto TgaImageConverter::doFeatures() const -> Features { return Feature::ConvertData; } -Containers::Array TgaImageConverter::doExportToData(const ImageReference2D& image) const { +Containers::Array TgaImageConverter::doExportToData(const ImageReference2D& image) const { #ifndef MAGNUM_TARGET_GLES if(image.format() != ColorFormat::BGR && image.format() != ColorFormat::BGRA && @@ -70,7 +70,7 @@ Containers::Array TgaImageConverter::doExportToData(const ImageRe /* Initialize data buffer */ const auto pixelSize = UnsignedByte(image.pixelSize()); - auto data = Containers::Array::zeroInitialized(sizeof(TgaHeader) + pixelSize*image.size().product()); + auto data = Containers::Array::zeroInitialized(sizeof(TgaHeader) + pixelSize*image.size().product()); /* Fill header */ auto header = reinterpret_cast(data.begin()); diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index 31e27371c..b9b9aeb82 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -67,7 +67,7 @@ class MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractIm private: Features MAGNUM_TRADE_TGAIMAGECONVERTER_LOCAL doFeatures() const override; - Containers::Array MAGNUM_TRADE_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageReference2D& image) const override; + Containers::Array MAGNUM_TRADE_TGAIMAGECONVERTER_LOCAL doExportToData(const ImageReference2D& image) const override; }; }} diff --git a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp index 0a0b73dff..b84293b80 100644 --- a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp @@ -82,7 +82,7 @@ void TgaImporterTest::openNonexistent() { void TgaImporterTest::openShort() { TgaImporter importer; - const unsigned char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; @@ -93,7 +93,7 @@ void TgaImporterTest::openShort() { void TgaImporterTest::paletted() { TgaImporter importer; - const unsigned char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; @@ -104,7 +104,7 @@ void TgaImporterTest::paletted() { void TgaImporterTest::compressed() { TgaImporter importer; - const unsigned char data[] = { 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + const char data[] = { 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; @@ -115,7 +115,7 @@ void TgaImporterTest::compressed() { void TgaImporterTest::colorBits16() { TgaImporter importer; - const unsigned char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; + const char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; @@ -126,14 +126,14 @@ void TgaImporterTest::colorBits16() { void TgaImporterTest::colorBits24() { TgaImporter importer; - const unsigned char data[] = { + const char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 24, 0, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8 }; #ifndef MAGNUM_TARGET_GLES - const char* pixels = reinterpret_cast(data) + 18; + const char* pixels = data + 18; #else const char pixels[] = { 3, 2, 1, 4, 3, 2, @@ -152,19 +152,20 @@ void TgaImporterTest::colorBits24() { #endif CORRADE_COMPARE(image->size(), Vector2i(2, 3)); CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); - CORRADE_COMPARE(std::string(reinterpret_cast(image->data()), 2*3*3), std::string(pixels, 2*3*3)); + CORRADE_COMPARE((std::string{image->data(), 2*3*3}), + (std::string{pixels, 2*3*3})); } void TgaImporterTest::colorBits32() { TgaImporter importer; - const unsigned char data[] = { + const char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 32, 0, 1, 2, 3, 1, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5, 6, 1, 5, 6, 7, 1, 6, 7, 8, 1 }; #ifndef MAGNUM_TARGET_GLES - const char* pixels = reinterpret_cast(data) + 18; + const char* pixels = data + 18; #else const char pixels[] = { 3, 2, 1, 1, 4, 3, 2, 1, @@ -183,12 +184,13 @@ void TgaImporterTest::colorBits32() { #endif CORRADE_COMPARE(image->size(), Vector2i(2, 3)); CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); - CORRADE_COMPARE(std::string(reinterpret_cast(image->data()), 2*3*3), std::string(pixels, 2*3*3)); + CORRADE_COMPARE((std::string{image->data(), 2*3*3}), + (std::string{pixels, 2*3*3})); } void TgaImporterTest::grayscaleBits8() { TgaImporter importer; - const unsigned char data[] = { + const char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 8, 0, 1, 2, 3, 4, @@ -205,13 +207,13 @@ void TgaImporterTest::grayscaleBits8() { #endif CORRADE_COMPARE(image->size(), Vector2i(2, 3)); CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); - CORRADE_COMPARE(std::string(reinterpret_cast(image->data()), 2*3), - std::string(reinterpret_cast(data) + 18, 2*3)); + CORRADE_COMPARE((std::string{image->data(), 2*3}), + (std::string{data + 18, 2*3})); } void TgaImporterTest::grayscaleBits16() { TgaImporter importer; - const unsigned char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; + const char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 }; CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; @@ -222,7 +224,7 @@ void TgaImporterTest::grayscaleBits16() { void TgaImporterTest::file() { TgaImporter importer; - const unsigned char data[] = { + const char data[] = { 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 8, 0, 1, 2, 3, 4, @@ -239,8 +241,8 @@ void TgaImporterTest::file() { #endif CORRADE_COMPARE(image->size(), Vector2i(2, 3)); CORRADE_COMPARE(image->type(), ColorType::UnsignedByte); - CORRADE_COMPARE(std::string(reinterpret_cast(image->data()), 2*3), - std::string(reinterpret_cast(data) + 18, 2*3)); + CORRADE_COMPARE((std::string{image->data(), 2*3}), + (std::string{data + 18, 2*3})); } }}} diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index a94fa050f..eccf0cc1f 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -57,8 +57,8 @@ auto TgaImporter::doFeatures() const -> Features { return Feature::OpenData; } bool TgaImporter::doIsOpened() const { return in; } -void TgaImporter::doOpenData(const Containers::ArrayReference data) { - in = new std::istringstream(std::string(reinterpret_cast(data.begin()), data.size())); +void TgaImporter::doOpenData(const Containers::ArrayReference data) { + in = new std::istringstream{{data, data.size()}}; } void TgaImporter::doOpenFile(const std::string& filename) { diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.h b/src/MagnumPlugins/TgaImporter/TgaImporter.h index 9f67fd8bc..2a98ffe95 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.h +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.h @@ -78,7 +78,7 @@ class MAGNUM_TRADE_TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter { private: Features MAGNUM_TRADE_TGAIMPORTER_LOCAL doFeatures() const override; bool MAGNUM_TRADE_TGAIMPORTER_LOCAL doIsOpened() const override; - void MAGNUM_TRADE_TGAIMPORTER_LOCAL doOpenData(Containers::ArrayReference data) override; + void MAGNUM_TRADE_TGAIMPORTER_LOCAL doOpenData(Containers::ArrayReference data) override; void MAGNUM_TRADE_TGAIMPORTER_LOCAL doOpenFile(const std::string& filename) override; void MAGNUM_TRADE_TGAIMPORTER_LOCAL doClose() override; UnsignedInt MAGNUM_TRADE_TGAIMPORTER_LOCAL doImage2DCount() const override; diff --git a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp index b8c20b4c5..c19f55134 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp +++ b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp @@ -60,7 +60,7 @@ void WavImporterTest::wrongSize() { Error::setOutput(&out); WavImporter importer; - CORRADE_VERIFY(!importer.openData(Containers::Array(43))); + CORRADE_VERIFY(!importer.openData(Containers::Array(43))); CORRADE_COMPARE(out.str(), "Audio::WavImporter::openData(): the file is too short: 43 bytes\n"); } @@ -97,12 +97,12 @@ void WavImporterTest::mono16() { CORRADE_COMPARE(importer.format(), Buffer::Format::Mono16); CORRADE_COMPARE(importer.frequency(), 44000); - Containers::Array data = importer.data(); + Containers::Array data = importer.data(); CORRADE_COMPARE(data.size(), 4); - CORRADE_COMPARE(data[0], 0x1d); - CORRADE_COMPARE(data[1], 0x10); - CORRADE_COMPARE(data[2], 0x71); - CORRADE_COMPARE(data[3], 0xC5); + CORRADE_COMPARE(data[0], '\x1d'); + CORRADE_COMPARE(data[1], '\x10'); + CORRADE_COMPARE(data[2], '\x71'); + CORRADE_COMPARE(data[3], '\xc5'); } void WavImporterTest::stereo8() { @@ -111,12 +111,12 @@ void WavImporterTest::stereo8() { CORRADE_COMPARE(importer.format(), Buffer::Format::Stereo8); CORRADE_COMPARE(importer.frequency(), 96000); - Containers::Array data = importer.data(); + Containers::Array data = importer.data(); CORRADE_COMPARE(data.size(), 4); - CORRADE_COMPARE(data[0], 0xde); - CORRADE_COMPARE(data[1], 0xfe); - CORRADE_COMPARE(data[2], 0xca); - CORRADE_COMPARE(data[3], 0x7e); + CORRADE_COMPARE(data[0], '\xde'); + CORRADE_COMPARE(data[1], '\xfe'); + CORRADE_COMPARE(data[2], '\xca'); + CORRADE_COMPARE(data[3], '\x7e'); } }}} diff --git a/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp b/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp index de306e4f4..7b0328995 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp +++ b/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp @@ -43,7 +43,7 @@ auto WavImporter::doFeatures() const -> Features { return Feature::OpenData; } bool WavImporter::doIsOpened() const { return _data; } -void WavImporter::doOpenData(Containers::ArrayReference data) { +void WavImporter::doOpenData(Containers::ArrayReference data) { /* Check file size */ if(data.size() < sizeof(WavHeader)) { Error() << "Audio::WavImporter::openData(): the file is too short:" << data.size() << "bytes"; @@ -111,7 +111,7 @@ void WavImporter::doOpenData(Containers::ArrayReference dat CORRADE_INTERNAL_ASSERT(!Utility::Endianness::isBigEndian()); /* Copy the data */ - _data = Containers::Array(header.subChunk2Size); + _data = Containers::Array(header.subChunk2Size); std::copy(data.begin()+sizeof(WavHeader), data.end(), _data.begin()); return; } @@ -122,8 +122,8 @@ Buffer::Format WavImporter::doFormat() const { return _format; } UnsignedInt WavImporter::doFrequency() const { return _frequency; } -Containers::Array WavImporter::doData() { - Containers::Array copy(_data.size()); +Containers::Array WavImporter::doData() { + Containers::Array copy(_data.size()); std::copy(_data.begin(), _data.end(), copy.begin()); return copy; } diff --git a/src/MagnumPlugins/WavAudioImporter/WavImporter.h b/src/MagnumPlugins/WavAudioImporter/WavImporter.h index 0d5da1327..f8fb6ec9c 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavImporter.h +++ b/src/MagnumPlugins/WavAudioImporter/WavImporter.h @@ -62,14 +62,14 @@ class WavImporter: public AbstractImporter { private: Features doFeatures() const override; bool doIsOpened() const override; - void doOpenData(Containers::ArrayReference data) override; + void doOpenData(Containers::ArrayReference data) override; void doClose() override; Buffer::Format doFormat() const override; UnsignedInt doFrequency() const override; - Containers::Array doData() override; + Containers::Array doData() override; - Containers::Array _data; + Containers::Array _data; Buffer::Format _format; UnsignedInt _frequency; };