Sha256: f641c24fa77aedf96732197351cbbb0ab758775e8459740892bc1618c3034f18

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

//! \file Platform.hpp
//! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.

#ifndef GOSU_PLATFORM_HPP
#define GOSU_PLATFORM_HPP

#ifdef __BIG_ENDIAN__
#define IDENTITY_FUN bigToNative
#define IDENTITY_FUN2 nativeToBig
#define CONV_FUN littleToNative
#define CONV_FUN2 nativeToLittle
#else
#define IDENTITY_FUN littleToNative
#define IDENTITY_FUN2 nativeToLittle
#define CONV_FUN bigToNative
#define CONV_FUN2 nativeToBig
#endif

#include <algorithm>

namespace Gosu
{
    template<typename T> T IDENTITY_FUN(T t) { return t; }
    template<typename T> T IDENTITY_FUN2(T t) { return t; }
    
    template<typename T>
    T CONV_FUN(T t)
    {
        char* begin = reinterpret_cast<char*>(&t);
        std::reverse(begin, begin + sizeof t);
        return t;
    }

    template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
}

#undef IDENTITY_FUN
#undef IDENTITY_FUN2
#undef CONV_FUN
#undef CONV_FUN2

#if defined(_MSC_VER)
#define GOSU_NORETURN __declspec(noreturn)
#elif defined(__GNUC__)
#define GOSU_NORETURN __attribute__ ((noreturn))
#endif

#if defined(WIN32)
# define GOSU_IS_WIN
#else
# define GOSU_IS_UNIX
# if defined(__linux) || defined(__FreeBSD__)
#  define GOSU_IS_X
# else
#  define GOSU_IS_MAC
#  include <TargetConditionals.h>
#  if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#   define GOSU_IS_IPHONE
#  endif
# endif
#endif

#endif

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gosu-0.7.12 Gosu/Platform.hpp
gosu-0.7.13.3 Gosu/Platform.hpp
gosu-0.7.13.2 Gosu/Platform.hpp
gosu-0.7.13 Gosu/Platform.hpp