Sha256: f6cbc1f4c0261c15fc33725ccea0bcb671184d10da2c04435a67fb7bd5729757

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

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

#pragma once

#ifdef __BIG_ENDIAN__
# define GOSU_IS_BIG_ENDIAN
# define IDENTITY_FUN big_to_native
# define IDENTITY_FUN2 native_to_big
# define CONV_FUN little_to_native
# define CONV_FUN2 native_to_little
#else
# define GOSU_IS_LITTLE_ENDIAN
# define IDENTITY_FUN little_to_native
# define IDENTITY_FUN2 native_to_little
# define CONV_FUN big_to_native
# define CONV_FUN2 native_to_big
#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) || defined(_WIN64)
# 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
#   define GOSU_IS_OPENGLES
#  endif
# endif
#endif

#ifndef GOSU_DEPRECATED
# if defined(GOSU_IS_WIN)
#  define GOSU_DEPRECATED __declspec(deprecated)
# else
#  define GOSU_DEPRECATED __attribute__((__deprecated__))
# endif
#endif

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gosu-1.2.0 include/Gosu/Platform.hpp
gosu-1.1.1.1 include/Gosu/Platform.hpp
gosu-1.1.0 include/Gosu/Platform.hpp
gosu-1.1.0.pre2 include/Gosu/Platform.hpp
gosu-1.1.0.pre1 include/Gosu/Platform.hpp
gosu-1.0.0 include/Gosu/Platform.hpp
gosu-1.0.0.pre2 include/Gosu/Platform.hpp
gosu-1.0.0.pre1 include/Gosu/Platform.hpp
gosu-0.15.2 Gosu/Platform.hpp
gosu-0.15.1 Gosu/Platform.hpp
gosu-0.15.0 Gosu/Platform.hpp
gosu-0.14.6.pre1 Gosu/Platform.hpp
gosu-0.14.5 Gosu/Platform.hpp
gosu-0.14.4 Gosu/Platform.hpp
gosu-0.14.4.pre2 Gosu/Platform.hpp
gosu-0.14.3.pre1 Gosu/Platform.hpp
gosu-0.14.3 Gosu/Platform.hpp
gosu-0.14.0 Gosu/Platform.hpp
gosu-0.14.0.pre2 Gosu/Platform.hpp
gosu-0.13.3 Gosu/Platform.hpp