Browse Source

Using delegating constructors where apropriate.

Because on GCC 4.7 we can.
pull/59/head
Vladimír Vondruš 12 years ago
parent
commit
7f38ccaf63
  1. 4
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 22
      src/Magnum/Platform/AndroidApplication.cpp
  3. 2
      src/Magnum/Platform/AndroidApplication.h
  4. 20
      src/Magnum/Platform/GlutApplication.cpp
  5. 2
      src/Magnum/Platform/GlutApplication.h
  6. 16
      src/Magnum/Platform/NaClApplication.cpp
  7. 18
      src/Magnum/Platform/Sdl2Application.cpp
  8. 1
      src/Magnum/Platform/Sdl2Application.h
  9. 12
      src/Magnum/Platform/WindowlessGlxApplication.cpp
  10. 15
      src/Magnum/Platform/WindowlessNaClApplication.cpp
  11. 14
      src/Magnum/Platform/WindowlessWglApplication.cpp
  12. 18
      src/Magnum/Text/GlyphCache.cpp
  13. 1
      src/Magnum/Text/GlyphCache.h

4
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<Configuration, Display*, VisualID, Window>* contextHandler, const Arguments&, const Configuration& configuration): contextHandler(contextHandler), c(nullptr), flags(Flag::Redraw) {
AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler<Configuration, Display*, VisualID, Window>* contextHandler, const Arguments& arguments, const Configuration& configuration): AbstractXApplication(contextHandler, arguments, nullptr) {
createContext(configuration);
}

22
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) {

2
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;

20
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);
}

2
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});
}

16
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);
}

18
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;

1
src/Magnum/Platform/Sdl2Application.h

@ -397,7 +397,6 @@ class Sdl2Application {
static void staticMainLoop();
#endif
void initialize();
void mainLoop();
#ifndef CORRADE_TARGET_EMSCRIPTEN

12
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({}); }

15
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);
}

14
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({}); }

18
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)

1
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;

Loading…
Cancel
Save