2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AuroraMacros.hpp
|
|
|
|
Date: 2021-6-10
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
2021-07-05 13:34:44 +00:00
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
#define AU_NO_COPY(type) type(type&) = delete;
|
|
|
|
#define AU_NO_MOVE(type) type(type&&) = delete;
|
2021-06-27 21:25:29 +00:00
|
|
|
#define AU_NO_COPY_NO_MOVE(type) AU_NO_COPY(type) AU_NO_MOVE(type)
|
|
|
|
|
2021-09-29 10:41:27 +00:00
|
|
|
#if !defined(AU_SHARED_FROM_THIS)
|
|
|
|
#define AU_SHARED_FROM_THIS (std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this()))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(AU_WEAK_FROM_THIS)
|
|
|
|
#define AU_WEAK_FROM_THIS (AuWPtr<std::remove_pointer_t<decltype(this)>>(std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this())))
|
|
|
|
#endif
|
2021-07-05 13:34:44 +00:00
|
|
|
|
2021-09-17 19:26:05 +00:00
|
|
|
#define AU_BRACKET_SCOPE(...) __VA_ARGS__
|
|
|
|
|
|
|
|
#define AU_TEMPLATE_ENABLE_WHEN(...) typename std::enable_if<__VA_ARGS__>::type* = nullptr
|
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
/// @hideinitializer
|
2021-06-27 21:25:29 +00:00
|
|
|
#define AU_STRINGIFY_(in) #in
|
|
|
|
#define AU_STRINGIFY(in) AU_STRINGIFY_(in)
|
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
/// @hideinitializer
|
|
|
|
#define AU_CONCAT_(a, b) a ## b
|
|
|
|
#define AU_CONCAT(a, b) AU_CONCAT_(a, b)
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
/// @hideinitializer
|
|
|
|
#define _AUKCON_STRINGIFY_X(in) AU_STRINGIFY(in)
|
|
|
|
|
|
|
|
#define AU_SHARED_API_EX(vis, name, type, ...) \
|
|
|
|
\
|
|
|
|
vis type *name ## New(__VA_ARGS__); \
|
|
|
|
vis void name ## Release(type *); \
|
|
|
|
static inline void name ## Destroy(type *val) \
|
|
|
|
{ \
|
|
|
|
name ## Release(val); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
struct CppDeleter ## name \
|
|
|
|
{ \
|
|
|
|
void operator()(type *t) \
|
|
|
|
{ \
|
|
|
|
name ## Release(t); \
|
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
\
|
2021-09-06 10:58:08 +00:00
|
|
|
using name ## Unique_t = AURORA_RUNTIME_AU_UNIQUE_PTR<type, CppDeleter ## name>; \
|
2021-06-27 21:25:29 +00:00
|
|
|
template<typename ... T> \
|
|
|
|
name ## Unique_t name ## Unique(T... args) \
|
|
|
|
{ \
|
|
|
|
return name ## Unique_t(name ## New(args...)); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
using name ## Shared_t = std::shared_ptr<type>; \
|
|
|
|
template<typename ... T> \
|
|
|
|
name ## Shared_t name ## Shared(T... args) \
|
|
|
|
{ \
|
|
|
|
return name ## Shared_t(name ## New(args...), name ## Release); \
|
|
|
|
}
|
|
|
|
|
2021-07-02 10:53:44 +00:00
|
|
|
#define AU_SHARED_API(name, type, ...) AU_SHARED_API_EX(, name, type, #__VA_ARGS__)
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
#if defined(AURORA_COMPILER_MSVC)
|
|
|
|
#define AU_NOINLINE __declspec(noinline)
|
|
|
|
#else
|
|
|
|
#define AU_NOINLINE __attribute__((noinline))
|
|
|
|
#endif
|
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
#if defined(AURORA_COMPILER_MSVC)
|
|
|
|
#define AU_INLINE __declspec(__forceinline)
|
|
|
|
#else
|
|
|
|
#define AU_INLINE __attribute__((always_inline))
|
|
|
|
#endif
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
#if defined(AURORA_COMPILER_MSVC)
|
|
|
|
#define AU_NORETURN __declspec(noreturn)
|
2021-09-29 10:41:27 +00:00
|
|
|
#elif (defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC))
|
|
|
|
#define AU_ALLOC __attribute__((noreturn))
|
|
|
|
#elif defined(AU_LANG_CPP)
|
2021-06-27 21:25:29 +00:00
|
|
|
#define AU_NORETURN [[noreturn]]
|
2021-09-29 10:41:27 +00:00
|
|
|
#else
|
|
|
|
#define AU_NORETURN
|
2021-06-27 21:25:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AURORA_PLATFORM_WIN32)
|
|
|
|
#define AU_ALLOC __declspec(allocator)
|
|
|
|
#elif defined(AURORA_COMPILER_CLANG)
|
|
|
|
#define AU_ALLOC __declspec(allocator)
|
2021-09-29 10:41:27 +00:00
|
|
|
#elif defined(AURORA_COMPILER_GCC)
|
2021-06-27 21:25:29 +00:00
|
|
|
#define AU_ALLOC __attribute__((malloc))
|
|
|
|
#else
|
|
|
|
#define AU_ALLOC
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(NO__NEW)
|
|
|
|
#define _new new (std::nothrow)
|
2021-06-30 09:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2021-09-21 01:54:28 +00:00
|
|
|
#define AU_FWD(var) std::forward<decltype(var)>(var)
|
|
|
|
#define AU_ITERATE_ARRAY(index, arry) AuUInt index = 0; index < AuArraySize(arry); index++
|