From 7f38ccaf63972eb05cd99142f1c0608dc6a12127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 24 May 2014 16:01:23 +0200 Subject: [PATCH] Using delegating constructors where apropriate. Because on GCC 4.7 we can. --- src/Magnum/Platform/AbstractXApplication.cpp | 4 +--- src/Magnum/Platform/AndroidApplication.cpp | 22 +++++-------------- src/Magnum/Platform/AndroidApplication.h | 2 -- src/Magnum/Platform/GlutApplication.cpp | 20 +++++------------ src/Magnum/Platform/GlutApplication.h | 2 -- src/Magnum/Platform/NaClApplication.cpp | 16 +++++--------- src/Magnum/Platform/Sdl2Application.cpp | 18 ++++----------- src/Magnum/Platform/Sdl2Application.h | 1 - .../Platform/WindowlessGlxApplication.cpp | 12 ++++------ .../Platform/WindowlessNaClApplication.cpp | 15 +++++-------- .../Platform/WindowlessWglApplication.cpp | 14 +++++------- src/Magnum/Text/GlyphCache.cpp | 18 ++++----------- src/Magnum/Text/GlyphCache.h | 1 - 13 files changed, 39 insertions(+), 106 deletions(-) diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index 4a06752b2..8d8bfd018 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -37,9 +37,7 @@ namespace Magnum { namespace Platform { -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ - -AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments&, const Configuration& configuration): contextHandler(contextHandler), c(nullptr), flags(Flag::Redraw) { +AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration): AbstractXApplication(contextHandler, arguments, nullptr) { createContext(configuration); } diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index 436b02da1..e9ede0982 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -34,22 +34,17 @@ namespace Magnum { namespace Platform { -/** @todo Delegating constructors when support for GCC 4.6 can be dropped */ +#ifndef DOXYGEN_GENERATING_OUTPUT +AndroidApplication::AndroidApplication(const Arguments& arguments): AndroidApplication{arguments, Configuration{}} {} +#endif -AndroidApplication::AndroidApplication(const Arguments& arguments, const Configuration& configuration): _state(arguments) { - initialize(); +AndroidApplication::AndroidApplication(const Arguments& arguments, const Configuration& configuration): AndroidApplication{arguments, nullptr} { createContext(configuration); } -#ifndef DOXYGEN_GENERATING_OUTPUT -AndroidApplication::AndroidApplication(const Arguments& arguments): _state(arguments) { - initialize(); - createContext(); -} -#endif - AndroidApplication::AndroidApplication(const Arguments& arguments, std::nullptr_t): _state(arguments) { - initialize(); + /* Redirect debug output to Android log */ + _logOutput.reset(new LogOutput); } AndroidApplication::~AndroidApplication() { @@ -77,11 +72,6 @@ AndroidApplication::LogOutput::LogOutput(): Error::setOutput(&errorStream); } -void AndroidApplication::initialize() { - /* Redirect debug output to Android log */ - _logOutput.reset(new LogOutput); -} - void AndroidApplication::createContext() { createContext({}); } void AndroidApplication::createContext(const Configuration& configuration) { diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index d7aebb9d7..2d887d1e9 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -299,8 +299,6 @@ class AndroidApplication { static void commandEvent(android_app* state, std::int32_t cmd); static std::int32_t inputEvent(android_app* state, AInputEvent* event); - void initialize(); - android_app* const _state; Flags _flags; diff --git a/src/Magnum/Platform/GlutApplication.cpp b/src/Magnum/Platform/GlutApplication.cpp index 8009451b4..a576d8ab2 100644 --- a/src/Magnum/Platform/GlutApplication.cpp +++ b/src/Magnum/Platform/GlutApplication.cpp @@ -35,30 +35,20 @@ namespace Magnum { namespace Platform { GlutApplication* GlutApplication::instance = nullptr; -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ - -GlutApplication::GlutApplication(const Arguments& arguments, const Configuration& configuration): c(nullptr) { - initialize(arguments.argc, arguments.argv); - createContext(configuration); -} - #ifndef DOXYGEN_GENERATING_OUTPUT -GlutApplication::GlutApplication(const Arguments& arguments): c(nullptr) { - initialize(arguments.argc, arguments.argv); - createContext(); -} +GlutApplication::GlutApplication(const Arguments& arguments): GlutApplication{arguments, Configuration{}} {} #endif -GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t): c(nullptr) { - initialize(arguments.argc, arguments.argv); +GlutApplication::GlutApplication(const Arguments& arguments, const Configuration& configuration): GlutApplication{arguments, nullptr} { + createContext(configuration); } -void GlutApplication::initialize(int& argc, char** argv) { +GlutApplication::GlutApplication(const Arguments& arguments, std::nullptr_t): c(nullptr) { /* Save global instance */ instance = this; /* Init GLUT */ - glutInit(&argc, argv); + glutInit(&arguments.argc, arguments.argv); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); } diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index e537e47d3..68aa18ffc 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -247,8 +247,6 @@ class GlutApplication { /*@}*/ private: - void initialize(int& argc, char** argv); - static void staticViewportEvent(int x, int y) { instance->viewportEvent({x, y}); } diff --git a/src/Magnum/Platform/NaClApplication.cpp b/src/Magnum/Platform/NaClApplication.cpp index b0f4daa8c..a0a7db690 100644 --- a/src/Magnum/Platform/NaClApplication.cpp +++ b/src/Magnum/Platform/NaClApplication.cpp @@ -58,21 +58,15 @@ NaClApplication::ConsoleDebugOutput::ConsoleDebugOutput(pp::Instance* instance): Error::setOutput(&errorOutput); } -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ +#ifndef DOXYGEN_GENERATING_OUTPUT +NaClApplication::NaClApplication(const Arguments& arguments): NaClApplication{arguments, Configuration{}} {} +#endif -NaClApplication::NaClApplication(const Arguments& arguments, const Configuration& configuration): Instance(arguments), Graphics3DClient(this), MouseLock(this), graphics(nullptr), fullscreen(nullptr), c(nullptr) { - debugOutput = new ConsoleDebugOutput(this); +NaClApplication::NaClApplication(const Arguments& arguments, const Configuration& configuration): NaClApplication{arguments, nullptr} { createContext(configuration); } -#ifndef DOXYGEN_GENERATING_OUTPUT -NaClApplication::NaClApplication(const Arguments& arguments): Instance(arguments), Graphics3DClient(this), MouseLock(this), c(nullptr) { - debugOutput = new ConsoleDebugOutput(this); - createContext(); -} -#endif - -NaClApplication::NaClApplication(const Arguments& arguments, std::nullptr_t): Instance(arguments), Graphics3DClient(this), MouseLock(this), c(nullptr) { +NaClApplication::NaClApplication(const Arguments& arguments, std::nullptr_t): Instance(arguments), Graphics3DClient(this), MouseLock(this), graphics(nullptr), fullscreen(nullptr), c(nullptr) { debugOutput = new ConsoleDebugOutput(this); } diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 9d9af050b..7b7f91256 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -62,25 +62,15 @@ void Sdl2Application::staticMainLoop() { } #endif -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ - -Sdl2Application::Sdl2Application(const Arguments&, const Configuration& configuration): context(nullptr), flags(Flag::Redraw) { - initialize(); - createContext(configuration); -} - #ifndef DOXYGEN_GENERATING_OUTPUT -Sdl2Application::Sdl2Application(const Arguments&): context(nullptr), flags(Flag::Redraw) { - initialize(); - createContext(); -} +Sdl2Application::Sdl2Application(const Arguments& arguments): Sdl2Application{arguments, Configuration{}} {} #endif -Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t): context(nullptr), flags(Flag::Redraw) { - initialize(); +Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration): Sdl2Application{arguments, nullptr} { + createContext(configuration); } -void Sdl2Application::initialize() { +Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t): context(nullptr), flags(Flag::Redraw) { #ifdef CORRADE_TARGET_EMSCRIPTEN CORRADE_ASSERT(!instance, "Platform::Sdl2Application::Sdl2Application(): the instance is already created", ); instance = this; diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index da2067807..b4a12743e 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -397,7 +397,6 @@ class Sdl2Application { static void staticMainLoop(); #endif - void initialize(); void mainLoop(); #ifndef CORRADE_TARGET_EMSCRIPTEN diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index c172de214..3d0943d30 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -34,18 +34,14 @@ namespace Magnum { namespace Platform { -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ +#ifndef DOXYGEN_GENERATING_OUTPUT +WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments): WindowlessGlxApplication{arguments, Configuration{}} {} +#endif -WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&, const Configuration& configuration): c(nullptr) { +WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments, const Configuration& configuration): WindowlessGlxApplication{arguments, nullptr} { createContext(configuration); } -#ifndef DOXYGEN_GENERATING_OUTPUT -WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&): c(nullptr) { - createContext(); -} -#endif - WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&, std::nullptr_t): c(nullptr) {} void WindowlessGlxApplication::createContext() { createContext({}); } diff --git a/src/Magnum/Platform/WindowlessNaClApplication.cpp b/src/Magnum/Platform/WindowlessNaClApplication.cpp index f9a893765..d2a28d95d 100644 --- a/src/Magnum/Platform/WindowlessNaClApplication.cpp +++ b/src/Magnum/Platform/WindowlessNaClApplication.cpp @@ -50,20 +50,15 @@ WindowlessNaClApplication::ConsoleDebugOutput::ConsoleDebugOutput(pp::Instance* Error::setOutput(&errorOutput); } -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ +#ifndef DOXYGEN_GENERATING_OUTPUT +WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments): WindowlessNaClApplication{arguments, Configuration{}} {} +#endif -WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments, const Configuration& configuration): Instance(arguments), Graphics3DClient(this), graphics(nullptr), c(nullptr) { - debugOutput = new ConsoleDebugOutput(this); +WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments, const Configuration& configuration): +WindowlessNaClApplication{arguments, nullptr} { createContext(configuration); } -#ifndef DOXYGEN_GENERATING_OUTPUT -WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments): Instance(arguments), Graphics3DClient(this), c(nullptr) { - debugOutput = new ConsoleDebugOutput(this); - createContext(); -} -#endif - WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments, std::nullptr_t): Instance(arguments), Graphics3DClient(this), graphics(nullptr), c(nullptr) { debugOutput = new ConsoleDebugOutput(this); } diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index 4ef4ef02c..0a3eeb742 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -33,8 +33,6 @@ namespace Magnum { namespace Platform { -/** @todo Delegating constructor when support for GCC 4.6 is dropped */ - #ifndef DOXYGEN_GENERATING_OUTPUT int WindowlessWglApplication::create(LRESULT(CALLBACK windowProcedure)(HWND, UINT, WPARAM, LPARAM)) { const WNDCLASS wc{ @@ -58,16 +56,14 @@ int WindowlessWglApplication::create(LRESULT(CALLBACK windowProcedure)(HWND, UIN } #endif -WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, const Configuration& configuration): _window(arguments.window), _c(nullptr) { - createContext(configuration); -} - #ifndef DOXYGEN_GENERATING_OUTPUT -WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments): _window(arguments.window), _c(nullptr) { - createContext(); -} +WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments): WindowlessWglApplication{arguments, Configuration{}} {} #endif +WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, const Configuration& configuration): WindowlessWglApplication{arguments, nullptr} { + createContext(configuration); +} + WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, std::nullptr_t): _window(arguments.window), _c(nullptr) {} void WindowlessWglApplication::createContext() { createContext({}); } diff --git a/src/Magnum/Text/GlyphCache.cpp b/src/Magnum/Text/GlyphCache.cpp index 65fe27ad0..5568dc1f9 100644 --- a/src/Magnum/Text/GlyphCache.cpp +++ b/src/Magnum/Text/GlyphCache.cpp @@ -33,27 +33,15 @@ namespace Magnum { namespace Text { -/** @todo Do this using delegating constructors when support for GCC 4.6 is dropped */ +GlyphCache::GlyphCache(const TextureFormat internalFormat, const Vector2i& size, const Vector2i& padding): GlyphCache{internalFormat, size, size, padding} {} GlyphCache::GlyphCache(const TextureFormat internalFormat, const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding): _size(originalSize), _padding(padding) { initialize(internalFormat, size); } -GlyphCache::GlyphCache(const TextureFormat internalFormat, const Vector2i& size, const Vector2i& padding): _size(size), _padding(padding) { - initialize(internalFormat, size); -} +GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): GlyphCache{size, size, padding} {} GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding): _size(originalSize), _padding(padding) { - initialize(size); -} - -GlyphCache::GlyphCache(const Vector2i& size, const Vector2i& padding): _size(size), _padding(padding) { - initialize(size); -} - -GlyphCache::~GlyphCache() = default; - -void GlyphCache::initialize(const Vector2i& size) { #ifndef MAGNUM_TARGET_GLES MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg); #endif @@ -69,6 +57,8 @@ void GlyphCache::initialize(const Vector2i& size) { initialize(internalFormat, size); } +GlyphCache::~GlyphCache() = default; + void GlyphCache::initialize(const TextureFormat internalFormat, const Vector2i& size) { /* Initialize texture */ _texture.setWrapping(Sampler::Wrapping::ClampToEdge) diff --git a/src/Magnum/Text/GlyphCache.h b/src/Magnum/Text/GlyphCache.h index 2f33ecaa5..df1923c05 100644 --- a/src/Magnum/Text/GlyphCache.h +++ b/src/Magnum/Text/GlyphCache.h @@ -188,7 +188,6 @@ class MAGNUM_TEXT_EXPORT GlyphCache { virtual void setImage(const Vector2i& offset, const ImageReference2D& image); private: - void MAGNUM_LOCAL initialize(const Vector2i& size); void MAGNUM_LOCAL initialize(TextureFormat internalFormat, const Vector2i& size); Vector2i _size, _padding;