Replace override and noexcept with macros

master
Piotr Dziwinski 2015-04-27 15:59:23 +02:00
parent f52650edb5
commit 3dce58c0fa
12 changed files with 134 additions and 116 deletions

View File

@ -120,18 +120,36 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
message(STATUS "Detected GCC version 4.7+")
set(CXX11_FLAGS "-std=gnu++11")
add_definitions(-DOVERRIDE=override)
elseif (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
message(STATUS "Detected GCC version 4.6+")
set(CXX11_FLAGS "-std=c++0x -Doverride=")
set(CXX11_FLAGS "-std=c++0x")
add_definitions(-DOVERRIDE=)
else()
message(FATAL_ERROR "${PROJECT_NAME} requires GCC 4.6 or greater.")
endif()
set(NORMAL_CXX_FLAGS "-Wall -Wold-style-cast")
set(RELEASE_CXX_FLAGS "-O2")
set(DEBUG_CXX_FLAGS "-g -O0")
set(TEST_CXX_FLAGS "-pthread")
add_definitions(-DNOEXCEPT=noexcept)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Detected Clang compiler")
set(CXX11_FLAGS "-std=c++11")
set(NORMAL_CXX_FLAGS "-Wall -Wold-style-cast")
set(RELEASE_CXX_FLAGS "-O2")
set(DEBUG_CXX_FLAGS "-g -O0")
set(TEST_CXX_FLAGS "-pthread")
add_definitions(-DNOEXCEPT=noexcept)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
message(STATUS "Detected MSVC compiler")
set(CXX11_FLAGS "")
set(NORMAL_CXX_FLAGS "")
set(RELEASE_CXX_FLAGS "")
set(DEBUG_CXX_FLAGS "")
set(TEST_CXX_FLAGS "")
add_definitions(-DNOEXCEPT=)
add_definitions(-DOVERRIDE=override)
else()
message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.")
endif()
@ -142,14 +160,14 @@ endif()
# The flags are used throughout src/ and test/ subdirs
# Special flags for boost
set(Boost_FLAGS "-DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS")
add_definitions(-DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS)
set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast ${CXX11_FLAGS} ${Boost_FLAGS}")
set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NORMAL_CXX_FLAGS} ${CXX11_FLAGS}")
set(COLOBOT_CXX_FLAGS_RELEASE "${RELEASE_CXX_FLAGS}")
set(COLOBOT_CXX_FLAGS_DEBUG "${DEBUG_CXX_FLAGS}")
# Flags for gtest
set(COLOBOT_GTEST_CXX_FLAGS "-pthread")
set(COLOBOT_GTEST_CXX_FLAGS "${TEST_CXX_FLAGS}")
# Asserts can be enabled/disabled regardless of build type
@ -179,7 +197,7 @@ option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
# Build OpenAL sound support
option(OPENAL_SOUND "Build OpenAL sound support" ON)
# Change to false in case static boost libraries are not available
# This is useful in case you want to use static boost libraries
option(BOOST_STATIC "Link with static boost libraries" OFF)
# This is useful on Windows, if linking against standard GLEW dll fails

View File

@ -40,15 +40,15 @@ struct SystemTimeStamp
class CSystemUtilsLinux : public CSystemUtils
{
public:
virtual void Init() override;
virtual void Init() OVERRIDE;
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) OVERRIDE;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) OVERRIDE;
virtual long long GetTimeStampExactResolution() OVERRIDE;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) OVERRIDE;
virtual std::string GetSaveDir() override;
virtual std::string GetSaveDir() OVERRIDE;
private:
bool m_zenityAvailable;

View File

@ -28,11 +28,11 @@
class CSystemUtilsMacOSX : public CSystemUtilsOther
{
public:
virtual void Init() override;
virtual void Init() OVERRIDE;
virtual std::string GetDataPath() override;
virtual std::string GetLangPath() override;
virtual std::string GetSaveDir() override;
virtual std::string GetDataPath() OVERRIDE;
virtual std::string GetLangPath() OVERRIDE;
virtual std::string GetSaveDir() OVERRIDE;
private:
std::string m_ASPath;
std::string m_dataPath;

View File

@ -43,10 +43,10 @@ class CSystemUtilsOther : public CSystemUtils
{
public:
virtual void Init() {};
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) OVERRIDE;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
virtual long long int GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) OVERRIDE;
virtual long long int GetTimeStampExactResolution() OVERRIDE;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) OVERRIDE;
};

View File

@ -38,15 +38,15 @@ struct SystemTimeStamp
class CSystemUtilsWindows : public CSystemUtils
{
public:
virtual void Init() override;
virtual void Init() OVERRIDE;
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) OVERRIDE;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) OVERRIDE;
virtual long long GetTimeStampExactResolution() OVERRIDE;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) OVERRIDE;
virtual std::string GetSaveDir() override;
virtual std::string GetSaveDir() OVERRIDE;
public:
static std::string UTF8_Encode(const std::wstring &wstr);

View File

@ -106,84 +106,84 @@ public:
CGLDevice(const GLDeviceConfig &config);
virtual ~CGLDevice();
virtual void DebugHook() override;
virtual void DebugLights() override;
virtual void DebugHook() OVERRIDE;
virtual void DebugLights() OVERRIDE;
virtual bool Create() override;
virtual void Destroy() override;
virtual bool Create() OVERRIDE;
virtual void Destroy() OVERRIDE;
void ConfigChanged(const GLDeviceConfig &newConfig);
void SetUseVbo(bool useVbo);
void SetVertexBufferType(VertexBufferType type);
virtual void BeginScene() override;
virtual void EndScene() override;
virtual void BeginScene() OVERRIDE;
virtual void EndScene() OVERRIDE;
virtual void Clear() override;
virtual void Clear() OVERRIDE;
virtual void SetTransform(TransformType type, const Math::Matrix &matrix) override;
virtual void SetTransform(TransformType type, const Math::Matrix &matrix) OVERRIDE;
virtual void SetMaterial(const Material &material) override;
virtual void SetMaterial(const Material &material) OVERRIDE;
virtual int GetMaxLightCount() override;
virtual void SetLight(int index, const Light &light) override;
virtual void SetLightEnabled(int index, bool enabled) override;
virtual int GetMaxLightCount() OVERRIDE;
virtual void SetLight(int index, const Light &light) OVERRIDE;
virtual void SetLightEnabled(int index, bool enabled) OVERRIDE;
virtual Texture CreateTexture(CImage *image, const TextureCreateParams &params) override;
virtual Texture CreateTexture(ImageData *data, const TextureCreateParams &params) override;
virtual void DestroyTexture(const Texture &texture) override;
virtual void DestroyAllTextures() override;
virtual Texture CreateTexture(CImage *image, const TextureCreateParams &params) OVERRIDE;
virtual Texture CreateTexture(ImageData *data, const TextureCreateParams &params) OVERRIDE;
virtual void DestroyTexture(const Texture &texture) OVERRIDE;
virtual void DestroyAllTextures() OVERRIDE;
virtual int GetMaxTextureStageCount() override;
virtual void SetTexture(int index, const Texture &texture) override;
virtual void SetTexture(int index, unsigned int textureId) override;
virtual void SetTextureEnabled(int index, bool enabled) override;
virtual int GetMaxTextureStageCount() OVERRIDE;
virtual void SetTexture(int index, const Texture &texture) OVERRIDE;
virtual void SetTexture(int index, unsigned int textureId) OVERRIDE;
virtual void SetTextureEnabled(int index, bool enabled) OVERRIDE;
virtual void SetTextureStageParams(int index, const TextureStageParams &params) override;
virtual void SetTextureStageParams(int index, const TextureStageParams &params) OVERRIDE;
virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) OVERRIDE;
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) OVERRIDE;
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) override;
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) OVERRIDE;
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) OVERRIDE;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
virtual void DrawStaticBuffer(unsigned int bufferId) override;
virtual void DestroyStaticBuffer(unsigned int bufferId) override;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) OVERRIDE;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) OVERRIDE;
virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) OVERRIDE;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) OVERRIDE;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) OVERRIDE;
virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) OVERRIDE;
virtual void DrawStaticBuffer(unsigned int bufferId) OVERRIDE;
virtual void DestroyStaticBuffer(unsigned int bufferId) OVERRIDE;
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius) override;
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius) OVERRIDE;
virtual void SetRenderState(RenderState state, bool enabled) override;
virtual void SetRenderState(RenderState state, bool enabled) OVERRIDE;
virtual void SetDepthTestFunc(CompFunc func) override;
virtual void SetDepthTestFunc(CompFunc func) OVERRIDE;
virtual void SetDepthBias(float factor) override;
virtual void SetDepthBias(float factor) OVERRIDE;
virtual void SetAlphaTestFunc(CompFunc func, float refValue) override;
virtual void SetAlphaTestFunc(CompFunc func, float refValue) OVERRIDE;
virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) override;
virtual void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) OVERRIDE;
virtual void SetClearColor(const Color &color) override;
virtual void SetClearColor(const Color &color) OVERRIDE;
virtual void SetGlobalAmbient(const Color &color) override;
virtual void SetGlobalAmbient(const Color &color) OVERRIDE;
virtual void SetFogParams(FogMode mode, const Color &color, float start, float end, float density) override;
virtual void SetFogParams(FogMode mode, const Color &color, float start, float end, float density) OVERRIDE;
virtual void SetCullMode(CullMode mode) override;
virtual void SetCullMode(CullMode mode) OVERRIDE;
virtual void SetShadeModel(ShadeModel model) override;
virtual void SetShadeModel(ShadeModel model) OVERRIDE;
virtual void SetFillMode(FillMode mode) override;
virtual void SetFillMode(FillMode mode) OVERRIDE;
virtual void* GetFrameBufferPixels() const override;
virtual void* GetFrameBufferPixels() const OVERRIDE;
private:
//! Updates internal modelview matrix

View File

@ -41,7 +41,7 @@ public:
private:
// Overriden to avoid warning about hiding virtual function
virtual void Start(int param) override;
virtual void Start(int param) OVERRIDE;
protected:
float m_force;

View File

@ -24,22 +24,22 @@
#include <boost/lexical_cast.hpp>
CLevelParserException::CLevelParserException(std::string message) noexcept
CLevelParserException::CLevelParserException(std::string message) NOEXCEPT
{
m_message = message;
}
const char* CLevelParserException::what() const noexcept
const char* CLevelParserException::what() const NOEXCEPT
{
return m_message.c_str();
}
CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) noexcept
CLevelParserExceptionMissingParam::CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) NOEXCEPT
: CLevelParserException("Missing required param "+thisParam->GetName()+" (in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
{
}
CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) noexcept
CLevelParserExceptionBadParam::CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) NOEXCEPT
: CLevelParserException("Unable to parse '"+thisParam->GetValue()+"' as "+requestedType+" (param '"+thisParam->GetName()+"' in "+thisParam->GetLine()->GetLevel()->GetFilename()+":"+boost::lexical_cast<std::string>(thisParam->GetLine()->GetLineNumber())+")")
{
}

View File

@ -32,9 +32,9 @@ class CLevelParserParam;
class CLevelParserException : public std::exception
{
public:
CLevelParserException(std::string message) noexcept;
virtual ~CLevelParserException() noexcept {}
const char* what() const noexcept;
CLevelParserException(std::string message) NOEXCEPT;
virtual ~CLevelParserException() NOEXCEPT {}
const char* what() const NOEXCEPT;
protected:
std::string m_message;
@ -43,13 +43,13 @@ protected:
class CLevelParserExceptionMissingParam : public CLevelParserException
{
public:
CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) noexcept;
virtual ~CLevelParserExceptionMissingParam() noexcept {}
CLevelParserExceptionMissingParam(CLevelParserParam* thisParam) NOEXCEPT;
virtual ~CLevelParserExceptionMissingParam() NOEXCEPT {}
};
class CLevelParserExceptionBadParam : public CLevelParserException
{
public:
CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) noexcept;
virtual ~CLevelParserExceptionBadParam() noexcept {}
CLevelParserExceptionBadParam(CLevelParserParam* thisParam, std::string requestedType) NOEXCEPT;
virtual ~CLevelParserExceptionBadParam() NOEXCEPT {}
};

View File

@ -50,40 +50,40 @@ public:
ALSound();
~ALSound();
bool Create() override;
bool Cache(Sound, const std::string &) override;
bool CacheMusic(const std::string &) override;
bool IsCached(Sound) override;
bool IsCachedMusic(const std::string &) override;
bool Create() OVERRIDE;
bool Cache(Sound, const std::string &) OVERRIDE;
bool CacheMusic(const std::string &) OVERRIDE;
bool IsCached(Sound) OVERRIDE;
bool IsCachedMusic(const std::string &) OVERRIDE;
bool GetEnable() override;
bool GetEnable() OVERRIDE;
void SetAudioVolume(int volume) override;
int GetAudioVolume() override;
void SetMusicVolume(int volume) override;
int GetMusicVolume() override;
void SetAudioVolume(int volume) OVERRIDE;
int GetAudioVolume() OVERRIDE;
void SetMusicVolume(int volume) OVERRIDE;
int GetMusicVolume() OVERRIDE;
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) override;
void FrameMove(float rTime) override;
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) OVERRIDE;
void FrameMove(float rTime) OVERRIDE;
int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) override;
int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) override;
bool FlushEnvelope(int channel) override;
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override;
bool Position(int channel, const Math::Vector &pos) override;
bool Frequency(int channel, float frequency) override;
bool Stop(int channel) override;
bool StopAll() override;
bool MuteAll(bool bMute) override;
int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) OVERRIDE;
int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) OVERRIDE;
bool FlushEnvelope(int channel) OVERRIDE;
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) OVERRIDE;
bool Position(int channel, const Math::Vector &pos) OVERRIDE;
bool Frequency(int channel, float frequency) OVERRIDE;
bool Stop(int channel) OVERRIDE;
bool StopAll() OVERRIDE;
bool MuteAll(bool bMute) OVERRIDE;
bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f) override;
bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f) override;
bool RestartMusic() override;
void SuspendMusic() override;
void StopMusic(float fadeTime=2.0f) override;
bool IsPlayingMusic() override;
bool PlayPauseMusic(const std::string &filename, bool repeat) override;
void StopPauseMusic() override;
bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f) OVERRIDE;
bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f) OVERRIDE;
bool RestartMusic() OVERRIDE;
void SuspendMusic() OVERRIDE;
void StopMusic(float fadeTime=2.0f) OVERRIDE;
bool IsPlayingMusic() OVERRIDE;
bool PlayPauseMusic(const std::string &filename, bool repeat) OVERRIDE;
void StopPauseMusic() OVERRIDE;
private:
void CleanUp();

View File

@ -97,7 +97,7 @@ class CList : public CControl
private:
// Overridden to avoid warning about hiding the virtual function
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override;
virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) OVERRIDE;
protected:
CButton* m_button[LISTMAXDISPLAY];

View File

@ -85,7 +85,7 @@ public:
EventType GetEventTypeFull();
EventType GetEventTypeClose();
virtual void SetName(std::string name, bool tooltip = true) override;
virtual void SetName(std::string name, bool tooltip = true) OVERRIDE;
void SetTrashEvent(bool bTrash);
bool GetTrashEvent();