Browse Source

Remove old std::u32string-related MinGW workarounds.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
d7a922bfb5
  1. 7
      src/Magnum/Text/AbstractFont.cpp
  2. 7
      src/Magnum/Text/AbstractFont.h
  3. 29
      src/Magnum/Text/AbstractFontConverter.cpp
  4. 26
      src/Magnum/Text/AbstractFontConverter.h
  5. 38
      src/Magnum/Text/Test/AbstractFontConverterTest.cpp
  6. 7
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp
  7. 4
      src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h

7
src/Magnum/Text/AbstractFont.cpp

@ -127,12 +127,7 @@ void AbstractFont::fillGlyphCache(GlyphCache& cache, const std::string& characte
doFillGlyphCache(cache, Utility::Unicode::utf32(characters)); doFillGlyphCache(cache, Utility::Unicode::utf32(characters));
} }
#ifndef __MINGW32__ void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&) {
void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&)
#else
void AbstractFont::doFillGlyphCache(GlyphCache&, const std::vector<char32_t>&)
#endif
{
CORRADE_ASSERT(false, "Text::AbstractFont::fillGlyphCache(): feature advertised but not implemented", ); CORRADE_ASSERT(false, "Text::AbstractFont::fillGlyphCache(): feature advertised but not implemented", );
} }

7
src/Magnum/Text/AbstractFont.h

@ -277,15 +277,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* *
* The string is converted from UTF-8 to UTF-32, unique characters are * The string is converted from UTF-8 to UTF-32, unique characters are
* *not* removed. * *not* removed.
* @note On MinGW uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/ */
#ifndef __MINGW32__
virtual void doFillGlyphCache(GlyphCache& cache, const std::u32string& characters); virtual void doFillGlyphCache(GlyphCache& cache, const std::u32string& characters);
#else
virtual void doFillGlyphCache(GlyphCache& cache, const std::vector<char32_t>& characters);
#endif
/** @brief Implementation for @ref createGlyphCache() */ /** @brief Implementation for @ref createGlyphCache() */
virtual std::unique_ptr<GlyphCache> doCreateGlyphCache(); virtual std::unique_ptr<GlyphCache> doCreateGlyphCache();

29
src/Magnum/Text/AbstractFontConverter.cpp

@ -37,18 +37,10 @@ namespace Magnum { namespace Text {
namespace { namespace {
#ifndef __MINGW32__
std::u32string uniqueUnicode(const std::string& characters) std::u32string uniqueUnicode(const std::string& characters)
#else
std::vector<char32_t> uniqueUnicode(const std::string& characters)
#endif
{ {
/* Convert UTF-8 to UTF-32 */ /* Convert UTF-8 to UTF-32 */
#ifndef __MINGW32__
std::u32string result = Utility::Unicode::utf32(characters); std::u32string result = Utility::Unicode::utf32(characters);
#else
std::vector<char32_t> result = Utility::Unicode::utf32(characters);
#endif
/* Remove duplicate glyphs */ /* Remove duplicate glyphs */
std::sort(result.begin(), result.end()); std::sort(result.begin(), result.end());
@ -70,12 +62,7 @@ std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConvert
return doExportFontToData(font, cache, filename, uniqueUnicode(characters)); return doExportFontToData(font, cache, filename, uniqueUnicode(characters));
} }
#ifndef __MINGW32__ std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif
{
CORRADE_ASSERT(!(features() & Feature::MultiFile), CORRADE_ASSERT(!(features() & Feature::MultiFile),
"Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {}); "Text::AbstractFontConverter::exportFontToData(): feature advertised but not implemented", {});
@ -93,12 +80,7 @@ Containers::Array<char> AbstractFontConverter::exportFontToSingleData(AbstractFo
return doExportFontToSingleData(font, cache, uniqueUnicode(characters)); return doExportFontToSingleData(font, cache, uniqueUnicode(characters));
} }
#ifndef __MINGW32__ Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const {
Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const
#else
Containers::Array<char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const
#endif
{
CORRADE_ASSERT(false, CORRADE_ASSERT(false,
"Text::AbstractFontConverter::exportFontToSingleData(): feature advertised but not implemented", nullptr); "Text::AbstractFontConverter::exportFontToSingleData(): feature advertised but not implemented", nullptr);
return nullptr; return nullptr;
@ -111,12 +93,7 @@ bool AbstractFontConverter::exportFontToFile(AbstractFont& font, GlyphCache& cac
return doExportFontToFile(font, cache, filename, uniqueUnicode(characters)); return doExportFontToFile(font, cache, filename, uniqueUnicode(characters));
} }
#ifndef __MINGW32__ bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif
{
CORRADE_ASSERT(features() & Feature::ConvertData, CORRADE_ASSERT(features() & Feature::ConvertData,
"Text::AbstractFontConverter::exportFontToFile(): not implemented", false); "Text::AbstractFontConverter::exportFontToFile(): not implemented", false);

26
src/Magnum/Text/AbstractFontConverter.h

@ -272,28 +272,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* *
* If the plugin doesn't have @ref Feature::MultiFile, default * If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doExportFontToSingleData(). * implementation calls @ref doExportFontToSingleData().
* @note On MinGW uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/ */
#ifndef __MINGW32__
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
#else
virtual std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const;
#endif
/** /** @brief Implementation for @ref exportFontToSingleData() */
* @brief Implementation for @ref exportFontToSingleData()
*
* @note On MinGW uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef __MINGW32__
virtual Containers::Array<char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const; virtual Containers::Array<char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const;
#else
virtual Containers::Array<char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector<char32_t>& characters) const;
#endif
/** /**
* @brief Implementation for @ref exportFontToFile() * @brief Implementation for @ref exportFontToFile()
@ -301,15 +284,8 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* If @ref Feature::ConvertData is supported, default implementation * If @ref Feature::ConvertData is supported, default implementation
* calls @ref doExportFontToData() and saves the result to given * calls @ref doExportFontToData() and saves the result to given
* file(s). * file(s).
* @note On MinGW uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/ */
#ifndef __MINGW32__
virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const; virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
#else
virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const;
#endif
/** /**
* @brief Implementation for @ref exportGlyphCacheToData() * @brief Implementation for @ref exportGlyphCacheToData()

38
src/Magnum/Text/Test/AbstractFontConverterTest.cpp

@ -74,45 +74,23 @@ namespace {
void AbstractFontConverterTest::convertGlyphs() { void AbstractFontConverterTest::convertGlyphs() {
class GlyphExporter: public AbstractFontConverter { class GlyphExporter: public AbstractFontConverter {
public: public:
#ifndef __MINGW32__
GlyphExporter(std::u32string& characters): characters(characters) {} GlyphExporter(std::u32string& characters): characters(characters) {}
#else
GlyphExporter(std::vector<char32_t>& characters): characters(characters) {}
#endif
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; }
#ifndef __MINGW32__ Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override {
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override
#else
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>& characters) const override
#endif
{
this->characters = characters; this->characters = characters;
return nullptr; return nullptr;
} }
#ifndef __MINGW32__
std::u32string& characters; std::u32string& characters;
#else
std::vector<char32_t>& characters;
#endif
}; };
#ifndef __MINGW32__
std::u32string characters; std::u32string characters;
#else
std::vector<char32_t> characters;
#endif
GlyphExporter exporter(characters); GlyphExporter exporter(characters);
exporter.exportFontToSingleData(nullFont, nullGlyphCache, "abC01a0 "); exporter.exportFontToSingleData(nullFont, nullGlyphCache, "abC01a0 ");
#ifndef __MINGW32__
CORRADE_COMPARE(characters, U" 01Cab"); CORRADE_COMPARE(characters, U" 01Cab");
#else
CORRADE_COMPARE(characters, (std::vector<char32_t>{
U' ', U'0', U'1', U'C', U'a', U'b'}));
#endif
} }
void AbstractFontConverterTest::exportFontToSingleData() { void AbstractFontConverterTest::exportFontToSingleData() {
@ -120,12 +98,7 @@ void AbstractFontConverterTest::exportFontToSingleData() {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; } Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; }
#ifndef __MINGW32__ Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override {
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override
#else
Containers::Array<char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const override
#endif
{
Containers::Array<char> data(1); Containers::Array<char> data(1);
data[0] = '\xee'; data[0] = '\xee';
return data; return data;
@ -146,12 +119,7 @@ void AbstractFontConverterTest::exportFontToFile() {
private: private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; } Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; }
#ifndef __MINGW32__ std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override {
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override
#else
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector<char32_t>&) const override
#endif
{
/* Why the hell GCC 4.9 fails to do proper move so I need to /* Why the hell GCC 4.9 fails to do proper move so I need to
work around that this ugly way?! */ work around that this ugly way?! */
std::vector<std::pair<std::string, Containers::Array<char>>> ret; std::vector<std::pair<std::string, Containers::Array<char>>> ret;

7
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -45,12 +45,7 @@ auto MagnumFontConverter::doFeatures() const -> Features {
return Feature::ExportFont|Feature::ConvertData|Feature::MultiFile; return Feature::ExportFont|Feature::ConvertData|Feature::MultiFile;
} }
#ifndef __MINGW32__ std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const {
std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
#endif
{
Utility::Configuration configuration; Utility::Configuration configuration;
configuration.setValue("version", 1); configuration.setValue("version", 1);

4
src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h

@ -60,11 +60,7 @@ class MagnumFontConverter: public Text::AbstractFontConverter {
private: private:
Features doFeatures() const override; Features doFeatures() const override;
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override;
#else
std::vector<std::pair<std::string, Containers::Array<char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const override;
#endif
}; };
}} }}

Loading…
Cancel
Save