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) # define hsDeprecated(message)
#endif #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 // 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; } virtual uint8_t GetNumLevels( void ) const { return 1; }
void Colorize() override { } void Colorize() HS_OVERRIDE { }
plMipmap *Clone() const override; plMipmap *Clone() const HS_OVERRIDE;
void CopyFrom(const plMipmap *source) override; void CopyFrom(const plMipmap *source) HS_OVERRIDE;
/// Operations to perform on the text block /// Operations to perform on the text block

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

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

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

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

6
Sources/Tools/plFontConverter/plFontConverter.cpp

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

2
Sources/Tools/plLocalizationEditor/plAddDlgs.cpp

@ -59,7 +59,7 @@ class AlphaNumericValidator : public QValidator
public: public:
AlphaNumericValidator(QObject *parent = nullptr) : QValidator(parent) { } 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) 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 #define _plResBrowser_h
#include <QMainWindow> #include <QMainWindow>
#include "HeadSpin.h"
class plResBrowser : public QMainWindow class plResBrowser : public QMainWindow
{ {
@ -55,8 +56,8 @@ public:
void SetWindowTitle(const QString &title); void SetWindowTitle(const QString &title);
protected: protected:
virtual void dragEnterEvent(QDragEnterEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) HS_OVERRIDE;
virtual void dropEvent(QDropEvent *event) override; void dropEvent(QDropEvent *event) HS_OVERRIDE;
private slots: private slots:
void OpenFile(); void OpenFile();

20
cmake/CompilerChecks.cmake

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

Loading…
Cancel
Save