Browse Source

Add two new compiler feature tests

Michael Hansen 10 years ago
parent
commit
45be91c0e3
  1. 16
      Sources/Plasma/CoreLib/HeadSpin.h
  2. 6
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h
  3. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
  4. 2
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h
  5. 6
      Sources/Tools/plFontConverter/plFontConverter.cpp
  6. 2
      Sources/Tools/plLocalizationEditor/plAddDlgs.cpp
  7. 5
      Sources/Tools/plResBrowser/plResBrowser.h
  8. 20
      cmake/CompilerChecks.cmake
  9. 7
      cmake/check_noexcept.cpp
  10. 26
      cmake/check_override.cpp
  11. 2
      cmake/hsCompilerSpecific.h.cmake

16
Sources/Plasma/CoreLib/HeadSpin.h

@ -130,6 +130,22 @@ typedef int32_t hsError;
# define hsDeprecated(message)
#endif
#ifdef HAVE_OVERRIDE
# define HS_OVERRIDE override
# define HS_FINAL final
#else
# define HS_OVERRIDE
# define HS_FINAL
#endif
#ifdef HAVE_NOEXCEPT
# define HS_NOEXCEPT noexcept
# define HS_NOEXCEPT_IF(cond) noexcept(cond)
#else
# define HS_NOEXCEPT throw()
# define HS_NOEXCEPT_IF(cond)
#endif
//======================================
// Endian swap funcitions
//======================================

6
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h

@ -130,9 +130,9 @@ class plDynamicTextMap : public plMipmap
virtual uint8_t GetNumLevels( void ) const { return 1; }
void Colorize() override { }
plMipmap *Clone() const override;
void CopyFrom(const plMipmap *source) override;
void Colorize() HS_OVERRIDE { }
plMipmap *Clone() const HS_OVERRIDE;
void CopyFrom(const plMipmap *source) HS_OVERRIDE;
/// Operations to perform on the text block

4
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h

@ -237,7 +237,7 @@ private:
int ISendGameMessage(plMessage* msg);
void IDisableNet ();
void ICreateStatusLog() const override;
void ICreateStatusLog() const HS_OVERRIDE;
public:
plNetClientMgr();
@ -265,7 +265,7 @@ public:
void SendApplyAvatarCustomizationsMsg(const plKey msgReceiver, bool netPropagate=true, bool localPropagate=true);
// plLoggable
bool Log(const plString& str) const override;
bool Log(const plString& str) const HS_OVERRIDE;
// setters
void SetIniAuthServer(const char * value) { fIniAuthServer=value;}

2
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h

@ -159,7 +159,7 @@ class plStatusLog : public plLog
~plStatusLog();
bool AddLine(const plString& line) override;
bool AddLine(const plString& line) HS_OVERRIDE;
bool AddLine( const char *line, uint32_t color = kWhite );

6
Sources/Tools/plFontConverter/plFontConverter.cpp

@ -350,12 +350,12 @@ class plMyBDFCallback : public plBDFConvertCallback
public:
plMyBDFCallback(QWidget *parent) : fProgress(parent) { }
virtual void NumChars(uint16_t chars) override
void NumChars(uint16_t chars) HS_OVERRIDE
{
fProgress.SetRange(chars);
}
virtual void CharDone() override
void CharDone() HS_OVERRIDE
{
fPoint++;
fProgress.SetValue(fPoint);
@ -498,7 +498,7 @@ class NumListValidator : public QValidator
public:
NumListValidator(QObject *parent = nullptr) : QValidator(parent) { }
virtual State validate(QString &input, int &pos) const override
State validate(QString &input, int &pos) const HS_OVERRIDE
{
for (int ch = 0; ch < input.size(); ++ch)
{

2
Sources/Tools/plLocalizationEditor/plAddDlgs.cpp

@ -59,7 +59,7 @@ class AlphaNumericValidator : public QValidator
public:
AlphaNumericValidator(QObject *parent = nullptr) : QValidator(parent) { }
virtual State validate(QString &input, int &pos) const override
State validate(QString &input, int &pos) const HS_OVERRIDE
{
for (int ch = 0; ch < input.size(); ++ch)
{

5
Sources/Tools/plResBrowser/plResBrowser.h

@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _plResBrowser_h
#include <QMainWindow>
#include "HeadSpin.h"
class plResBrowser : public QMainWindow
{
@ -55,8 +56,8 @@ public:
void SetWindowTitle(const QString &title);
protected:
virtual void dragEnterEvent(QDragEnterEvent *event) override;
virtual void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) HS_OVERRIDE;
void dropEvent(QDropEvent *event) HS_OVERRIDE;
private slots:
void OpenFile();

20
cmake/CompilerChecks.cmake

@ -40,8 +40,7 @@ endif()
# Check for CPUID headers
try_compile(HAVE_CPUID ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_cpuid.cpp
OUTPUT_VARIABLE OUTPUT)
${PROJECT_SOURCE_DIR}/cmake/check_cpuid.cpp)
if(HAVE_CPUID)
message("CPUID header found -- using hardware math acceleration when available")
else()
@ -51,17 +50,22 @@ endif()
# Look for a supported "deprecated" attribute specifier.
try_compile(HAVE_CXX14_DEPRECATED_ATTR ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_deprecated_attribute.cpp
COMPILE_DEFINITIONS -DTRY_ATTRIBUTE
OUTPUT_VARIABLE OUTPUT)
COMPILE_DEFINITIONS -DTRY_ATTRIBUTE)
try_compile(HAVE_GCC_DEPRECATED_ATTR ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_deprecated_attribute.cpp
COMPILE_DEFINITIONS -DTRY_GCC_ATTR
OUTPUT_VARIABLE OUTPUT)
COMPILE_DEFINITIONS -DTRY_GCC_ATTR)
# Look for C++11 constexpr support
try_compile(HAVE_CONSTEXPR ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp
OUTPUT_VARIABLE OUTPUT)
${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp)
# Look for C++11 override/final specifiers
try_compile(HAVE_OVERRIDE ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_override.cpp)
# Look for C++11 noexcept specifier
try_compile(HAVE_NOEXCEPT ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/check_noexcept.cpp)
configure_file(${PROJECT_SOURCE_DIR}/cmake/hsCompilerSpecific.h.cmake
${PROJECT_BINARY_DIR}/hsCompilerSpecific.h)

7
cmake/check_noexcept.cpp

@ -0,0 +1,7 @@
void doesnt_throw() noexcept { }
int main(int, char **)
{
doesnt_throw();
return 0;
}

26
cmake/check_override.cpp

@ -0,0 +1,26 @@
class Base
{
public:
virtual ~Base() { }
virtual void virtual_function() = 0;
};
class Override : public Base
{
public:
void virtual_function() override { }
};
class Final : public Override
{
public:
void virtual_function() final { }
};
int main(int, char **)
{
Final klass;
klass.virtual_function();
return 0;
}

2
cmake/hsCompilerSpecific.h.cmake

@ -52,5 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#cmakedefine HAVE_GCC_DEPRECATED_ATTR
#cmakedefine HAVE_CONSTEXPR
#cmakedefine HAVE_OVERRIDE
#cmakedefine HAVE_NOEXCEPT
#endif

Loading…
Cancel
Save