You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
Mono: Cleanup
This commit is contained in:
@@ -31,39 +31,57 @@
|
||||
#ifndef UTIL_MACROS_H
|
||||
#define UTIL_MACROS_H
|
||||
|
||||
#define _GD_VARNAME_CONCAT_B(m_ignore, m_name) m_name
|
||||
#define _GD_VARNAME_CONCAT_A(m_a, m_b, m_c) _GD_VARNAME_CONCAT_B(hello there, m_a##m_b##m_c)
|
||||
#define _GD_VARNAME_CONCAT(m_a, m_b, m_c) _GD_VARNAME_CONCAT_A(m_a, m_b, m_c)
|
||||
#define GD_UNIQUE_NAME(m_name) _GD_VARNAME_CONCAT(m_name, _, __COUNTER__)
|
||||
#ifndef __has_cpp_attribute
|
||||
#define __has_cpp_attribute(attr_token) 0
|
||||
#endif
|
||||
|
||||
// noreturn
|
||||
#define _GD_VARNAME_CONCAT_B_(m_ignore, m_name) m_name
|
||||
#define _GD_VARNAME_CONCAT_A_(m_a, m_b, m_c) _GD_VARNAME_CONCAT_B_(hello there, m_a##m_b##m_c)
|
||||
#define _GD_VARNAME_CONCAT_(m_a, m_b, m_c) _GD_VARNAME_CONCAT_A_(m_a, m_b, m_c)
|
||||
#define GD_UNIQUE_NAME(m_name) _GD_VARNAME_CONCAT_(m_name, _, __COUNTER__)
|
||||
|
||||
#if __cpp_static_assert
|
||||
// static assert
|
||||
// TODO: Get rid of this macro once we upgrade to C++11
|
||||
|
||||
#ifdef __cpp_static_assert
|
||||
#define GD_STATIC_ASSERT(m_cond) static_assert((m_cond), "Condition '" #m_cond "' failed")
|
||||
#else
|
||||
#define GD_STATIC_ASSERT(m_cond) typedef int GD_UNIQUE_NAME(godot_static_assert)[((m_cond) ? 1 : -1)]
|
||||
#endif
|
||||
|
||||
#undef _NO_RETURN_
|
||||
// final
|
||||
// TODO: Get rid of this macro once we upgrade to C++11
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _NO_RETURN_ __attribute__((noreturn))
|
||||
#elif _MSC_VER
|
||||
#define _NO_RETURN_ __declspec(noreturn)
|
||||
#if (__cplusplus >= 201103L)
|
||||
#define GD_FINAL final
|
||||
#else
|
||||
#error Platform or compiler not supported
|
||||
#define GD_FINAL
|
||||
#endif
|
||||
|
||||
// noreturn
|
||||
// TODO: Get rid of this macro once we upgrade to C++11
|
||||
|
||||
#if __has_cpp_attribute(deprecated)
|
||||
#define GD_NORETURN [[noreturn]]
|
||||
#elif defined(__GNUC__)
|
||||
#define GD_NORETURN __attribute__((noreturn))
|
||||
#elif defined(_MSC_VER)
|
||||
#define GD_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define GD_NORETURN
|
||||
#pragma message "Macro GD_NORETURN will have no effect"
|
||||
#endif
|
||||
|
||||
// unreachable
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define _UNREACHABLE_() __assume(0)
|
||||
#define GD_UNREACHABLE() __assume(0)
|
||||
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
|
||||
#define _UNREACHABLE_() __builtin_unreachable()
|
||||
#define GD_UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
#define _UNREACHABLE_() \
|
||||
CRASH_NOW(); \
|
||||
do { \
|
||||
#define GD_UNREACHABLE() \
|
||||
CRASH_NOW(); \
|
||||
do { \
|
||||
} while (true);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user