[*] Clean up and expand AuroraMacros.hpp
This commit is contained in:
parent
fab9856adb
commit
8a9d9b67e8
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
#define AU_BRACKET_SCOPE(...) __VA_ARGS__
|
#define AU_BRACKET_SCOPE(...) __VA_ARGS__
|
||||||
|
|
||||||
|
#if !defined(AU_TEMPLATE_ENABLE_WHEN)
|
||||||
#define AU_TEMPLATE_ENABLE_WHEN(...) typename std::enable_if<__VA_ARGS__>::type* = nullptr
|
#define AU_TEMPLATE_ENABLE_WHEN(...) typename std::enable_if<__VA_ARGS__>::type* = nullptr
|
||||||
|
#endif
|
||||||
|
|
||||||
/// @hideinitializer
|
/// @hideinitializer
|
||||||
#define AU_STRINGIFY_(in) #in
|
#define AU_STRINGIFY_(in) #in
|
||||||
@ -34,6 +36,7 @@
|
|||||||
/// @hideinitializer
|
/// @hideinitializer
|
||||||
#define _AUKCON_STRINGIFY_X(in) AU_STRINGIFY(in)
|
#define _AUKCON_STRINGIFY_X(in) AU_STRINGIFY(in)
|
||||||
|
|
||||||
|
#if !defined(AU_SHARED_API_EX)
|
||||||
#define AU_SHARED_API_EX(vis, name, type, ...) \
|
#define AU_SHARED_API_EX(vis, name, type, ...) \
|
||||||
\
|
\
|
||||||
vis type *name ## New(__VA_ARGS__); \
|
vis type *name ## New(__VA_ARGS__); \
|
||||||
@ -64,21 +67,29 @@ name ## Shared_t name ## Shared(T... args) \
|
|||||||
{ \
|
{ \
|
||||||
return name ## Shared_t(name ## New(args...), name ## Release); \
|
return name ## Shared_t(name ## New(args...), name ## Release); \
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_SHARED_API)
|
||||||
#define AU_SHARED_API(name, type, ...) AU_SHARED_API_EX(, name, type, #__VA_ARGS__)
|
#define AU_SHARED_API(name, type, ...) AU_SHARED_API_EX(, name, type, #__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_NOINLINE)
|
||||||
#if defined(AURORA_COMPILER_MSVC)
|
#if defined(AURORA_COMPILER_MSVC)
|
||||||
#define AU_NOINLINE __declspec(noinline)
|
#define AU_NOINLINE __declspec(noinline)
|
||||||
#else
|
#else
|
||||||
#define AU_NOINLINE __attribute__((noinline))
|
#define AU_NOINLINE __attribute__((noinline))
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_INLINE)
|
||||||
#if defined(AURORA_COMPILER_MSVC)
|
#if defined(AURORA_COMPILER_MSVC)
|
||||||
#define AU_INLINE __declspec(__forceinline)
|
#define AU_INLINE __declspec(__forceinline)
|
||||||
#else
|
#else
|
||||||
#define AU_INLINE __attribute__((always_inline))
|
#define AU_INLINE __attribute__((always_inline))
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_NORETURN)
|
||||||
#if defined(AURORA_COMPILER_MSVC)
|
#if defined(AURORA_COMPILER_MSVC)
|
||||||
#define AU_NORETURN __declspec(noreturn)
|
#define AU_NORETURN __declspec(noreturn)
|
||||||
#elif (defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC))
|
#elif (defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC))
|
||||||
@ -88,7 +99,9 @@ name ## Shared_t name ## Shared(T... args) \
|
|||||||
#else
|
#else
|
||||||
#define AU_NORETURN
|
#define AU_NORETURN
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_ALLOC)
|
||||||
#if defined(AURORA_PLATFORM_WIN32)
|
#if defined(AURORA_PLATFORM_WIN32)
|
||||||
#define AU_ALLOC __declspec(allocator)
|
#define AU_ALLOC __declspec(allocator)
|
||||||
#elif defined(AURORA_COMPILER_CLANG)
|
#elif defined(AURORA_COMPILER_CLANG)
|
||||||
@ -98,20 +111,49 @@ name ## Shared_t name ## Shared(T... args) \
|
|||||||
#else
|
#else
|
||||||
#define AU_ALLOC
|
#define AU_ALLOC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(NO__NEW)
|
|
||||||
#define _new new (std::nothrow)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(NO__NEW)
|
||||||
|
#if !defined(_new)
|
||||||
|
#define _new new (std::nothrow)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_FWD)
|
||||||
#define AU_FWD(var) std::forward<decltype(var)>(var)
|
#define AU_FWD(var) std::forward<decltype(var)>(var)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define AU_ITERATE_ARRAY(index, arry) AuUInt index = 0; index < AuArraySize(arry); index++
|
#define AU_ITERATE_ARRAY(index, arry) AuUInt index = 0; index < AuArraySize(arry); index++
|
||||||
|
#define AU_ITERATE_N(index, n) AuUInt index = 0; index < n; index++
|
||||||
|
#define AU_ITERATE_N_TO_X(index, n, x) AuUInt index = n; index < x; index++
|
||||||
|
#define AU_ITERATE_BACKWARDS(index, lastIdx) AuUInt index = lastIdx; index <= 0; index--
|
||||||
|
|
||||||
|
#define AU_ITR_ARRAY AU_ITERATE_ARRAY
|
||||||
|
#define AU_ITR_N AU_ITERATE_N
|
||||||
|
#define AU_ITR_N_TO_X AU_ITERATE_N_TO_X
|
||||||
|
#define AU_ITR_BACKWARDS AU_ITERATE_BACKWARDS
|
||||||
|
|
||||||
#define AU_STRIP_BRACKETS_IMPL(X) X
|
#define AU_STRIP_BRACKETS_IMPL(X) X
|
||||||
#define AU_STRIP_BRACKETS(X) AU_STRIP_BRACKETS_IMPL(AU_BRACKET_SCOPE X)
|
|
||||||
|
|
||||||
|
#if !defined(AU_STRIP_BRACKETS)
|
||||||
|
#define AU_STRIP_BRACKETS(X) AU_STRIP_BRACKETS_IMPL(AU_BRACKET_SCOPE X)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_STRIP)
|
||||||
|
#define AU_STRIP AU_STRIP_BRACKETS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_EMIT_FIRST)
|
||||||
#define AU_EMIT_FIRST(a, b)a
|
#define AU_EMIT_FIRST(a, b)a
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_EMIT_SECOND)
|
||||||
#define AU_EMIT_SECOND(a, b)b
|
#define AU_EMIT_SECOND(a, b)b
|
||||||
#define AU_EMIT_BOTH(a, b) a b
|
#endif
|
||||||
|
|
||||||
|
#if !defined(AU_EMIT_BOTH)
|
||||||
|
#define AU_EMIT_BOTH(a, b)a, a
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(AuBindThis)
|
#if !defined(AuBindThis)
|
||||||
#define AuBindThis(method, ...) std::bind(method, this, ## __VA_ARGS__)
|
#define AuBindThis(method, ...) std::bind(method, this, ## __VA_ARGS__)
|
||||||
@ -124,3 +166,13 @@ name ## Shared_t name ## Shared(T... args) \
|
|||||||
#if !defined(AuWeakFromThis)
|
#if !defined(AuWeakFromThis)
|
||||||
#define AuWeakFromThis() AU_SHARED_FROM_THIS
|
#define AuWeakFromThis() AU_SHARED_FROM_THIS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define AU_DEFINE_CTOR_ONE(thisType, pairTypeName) \
|
||||||
|
inline thisType(AU_EMIT_FIRST pairTypeName && AU_EMIT_SECOND pairTypeName) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName) {} \
|
||||||
|
inline thisType(const AU_EMIT_FIRST pairTypeName & AU_EMIT_SECOND pairTypeName) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName) {}
|
||||||
|
|
||||||
|
#define AU_DEFINE_CTOR_TWO(thisType, pairTypeName, pairTypeName2) \
|
||||||
|
inline thisType(AU_EMIT_FIRST pairTypeName && AU_EMIT_SECOND pairTypeName, AU_EMIT_FIRST pairTypeName2 && AU_EMIT_SECOND pairTypeName2) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName), AU_EMIT_SECOND pairTypeName2 (AU_EMIT_SECOND pairTypeName2) {} \
|
||||||
|
inline thisType(const AU_EMIT_FIRST pairTypeName & AU_EMIT_SECOND pairTypeName, AU_EMIT_FIRST pairTypeName2 && AU_EMIT_SECOND pairTypeName2) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName), AU_EMIT_SECOND pairTypeName2 (AU_EMIT_SECOND pairTypeName2) {} \
|
||||||
|
inline thisType(AU_EMIT_FIRST pairTypeName && AU_EMIT_SECOND pairTypeName, const AU_EMIT_FIRST pairTypeName2 & AU_EMIT_SECOND pairTypeName2) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName), AU_EMIT_SECOND pairTypeName2 (AU_EMIT_SECOND pairTypeName2) {} \
|
||||||
|
inline thisType(const AU_EMIT_FIRST pairTypeName & AU_EMIT_SECOND pairTypeName, const AU_EMIT_FIRST pairTypeName2 & AU_EMIT_SECOND pairTypeName2) : AU_EMIT_SECOND pairTypeName (AU_EMIT_SECOND pairTypeName), AU_EMIT_SECOND pairTypeName2 (AU_EMIT_SECOND pairTypeName2) {}
|
Loading…
Reference in New Issue
Block a user