2022-07-30 12:24:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
2022-10-09 14:04:10 -04:00
|
|
|
#include "cplatform.h"
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
namespace geode {
|
|
|
|
class PlatformID {
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
Unknown = -1,
|
|
|
|
Windows,
|
|
|
|
MacOS,
|
|
|
|
iOS,
|
|
|
|
Android,
|
|
|
|
Linux,
|
|
|
|
};
|
|
|
|
|
|
|
|
using Type = decltype(Unknown);
|
|
|
|
|
|
|
|
Type m_value;
|
|
|
|
|
|
|
|
PlatformID(Type t) { m_value = t; }
|
|
|
|
PlatformID& operator=(Type t) { m_value = t; return *this; }
|
|
|
|
bool operator==(int other) const { return m_value == other; }
|
|
|
|
bool operator==(PlatformID const& other) const { return m_value == other.m_value; }
|
|
|
|
bool operator<(PlatformID const& other) const { return m_value < other.m_value; }
|
|
|
|
bool operator>(PlatformID const& other) const { return m_value > other.m_value; }
|
2022-09-01 05:46:37 -04:00
|
|
|
operator int() const { return m_value; }
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
template<class T>
|
2022-09-01 16:36:26 -04:00
|
|
|
static PlatformID from(T t) {
|
2022-07-30 12:24:03 -04:00
|
|
|
return static_cast<Type>(t);
|
|
|
|
}
|
2022-09-01 16:36:26 -04:00
|
|
|
template<class T>
|
|
|
|
T to() const {
|
|
|
|
return static_cast<T>(m_value);
|
|
|
|
}
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
static constexpr const char* toString(Type lp) {
|
|
|
|
switch (lp) {
|
|
|
|
case Unknown: return "Unknown";
|
|
|
|
case Windows: return "Windows";
|
|
|
|
case MacOS: return "MacOS";
|
|
|
|
case iOS: return "iOS";
|
|
|
|
case Android: return "Android";
|
|
|
|
case Linux: return "Linux";
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return "Undefined";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template<>
|
|
|
|
struct hash<geode::PlatformID> {
|
|
|
|
inline std::size_t operator()(geode::PlatformID const& id) const {
|
|
|
|
return std::hash<geode::PlatformID::Type>()(id.m_value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-10-05 16:31:25 -04:00
|
|
|
#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__)
|
2022-10-06 14:02:32 -04:00
|
|
|
#define GEODE_PRETTY_FUNCTION std::string(__FUNCSIG__)
|
2022-10-05 16:31:25 -04:00
|
|
|
#else
|
2022-10-06 14:02:32 -04:00
|
|
|
#define GEODE_PRETTY_FUNCTION std::string(__PRETTY_FUNCTION__)
|
2022-10-05 16:31:25 -04:00
|
|
|
#endif
|
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
// Windows
|
2022-10-09 14:04:10 -04:00
|
|
|
#ifdef GEODE_IS_WINDOWS
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
#define GEODE_PLATFORM_TARGET PlatformID::Windows
|
|
|
|
#define GEODE_HIDDEN
|
2022-10-13 04:31:23 -04:00
|
|
|
#define GEODE_INLINE __forceinline
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_VIRTUAL_CONSTEXPR
|
|
|
|
#define GEODE_NOINLINE __declspec(noinline)
|
|
|
|
|
|
|
|
#ifdef GEODE_EXPORTING
|
|
|
|
#define GEODE_DLL __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define GEODE_DLL __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GEODE_API extern "C" __declspec(dllexport)
|
|
|
|
#define GEODE_EXPORT __declspec(dllexport)
|
|
|
|
|
|
|
|
#include "windows.hpp"
|
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#elif defined(GEODE_IS_MACOS)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#define GEODE_PLATFORM_TARGET PlatformID::MacOS
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
|
2022-10-13 07:08:48 -04:00
|
|
|
#define GEODE_INLINE inline __attribute__((always_inline))
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_VIRTUAL_CONSTEXPR constexpr
|
|
|
|
#define GEODE_NOINLINE __attribute__((noinline))
|
|
|
|
|
|
|
|
#ifdef GEODE_EXPORTING
|
|
|
|
#define GEODE_DLL __attribute__((visibility("default")))
|
|
|
|
#else
|
2022-10-09 14:04:10 -04:00
|
|
|
#define GEODE_DLL
|
2022-07-30 12:24:03 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GEODE_API extern "C" __attribute__((visibility("default")))
|
|
|
|
#define GEODE_EXPORT __attribute__((visibility("default")))
|
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#include "macos.hpp"
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#elif defined(GEODE_IS_IOS)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#define GEODE_PLATFORM_TARGET PlatformID::iOS
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
|
2022-10-13 07:08:48 -04:00
|
|
|
#define GEODE_INLINE inline __attribute__((always_inline))
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_VIRTUAL_CONSTEXPR constexpr
|
|
|
|
#define GEODE_NOINLINE __attribute__((noinline))
|
|
|
|
|
|
|
|
#ifdef GEODE_EXPORTING
|
2022-10-09 14:04:10 -04:00
|
|
|
#define GEODE_DLL __attribute__((visibility("default")))
|
2022-07-30 12:24:03 -04:00
|
|
|
#else
|
2022-10-09 14:04:10 -04:00
|
|
|
#define GEODE_DLL
|
2022-07-30 12:24:03 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GEODE_API extern "C" __attribute__((visibility("default")))
|
|
|
|
#define GEODE_EXPORT __attribute__((visibility("default")))
|
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#include "ios.hpp"
|
|
|
|
|
|
|
|
#elif defined(GEODE_IS_ANDROID)
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
#define GEODE_PLATFORM_TARGET PlatformID::Android
|
|
|
|
#define GEODE_HIDDEN __attribute__((visibility("hidden")))
|
2022-10-13 07:08:48 -04:00
|
|
|
#define GEODE_INLINE inline __attribute__((always_inline))
|
2022-07-30 12:24:03 -04:00
|
|
|
#define GEODE_VIRTUAL_CONSTEXPR constexpr
|
|
|
|
#define GEODE_NOINLINE __attribute__((noinline))
|
|
|
|
|
|
|
|
#ifdef GEODE_EXPORTING
|
|
|
|
#define GEODE_DLL __attribute__((visibility("default")))
|
|
|
|
#else
|
|
|
|
#define GEODE_DLL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GEODE_API extern "C" __attribute__((visibility("default")))
|
|
|
|
#define GEODE_EXPORT __attribute__((visibility("default")))
|
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#include "android.hpp"
|
2022-07-30 12:24:03 -04:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2022-10-09 14:04:10 -04:00
|
|
|
#error "Unsupported Platform!"
|
|
|
|
|
2022-07-30 12:24:03 -04:00
|
|
|
#endif
|