[+] Added AUE_NOCPPSTL configuration macro. Scriptability will and kernel drivers shouldn't (but probably will) depend no a nostl assumption

This commit is contained in:
Reece Wilson 2021-11-19 14:38:03 +00:00
parent ce9d53f779
commit 0fcca45387

View File

@ -13,31 +13,33 @@
#if defined(AUE_OUT_OF_ECOSYSTEM) #if defined(AUE_OUT_OF_ECOSYSTEM)
#include <unordered_map> #if !defined(AUE_NOCPPSTL)
#include <string> #include <unordered_map>
#include <functional> #include <string>
#include <functional>
#if !defined(AU_AuHashMap) #if !defined(AU_AuHashMap)
#define AU_AuHashMap #define AU_AuHashMap
template<typename T, typename Z> template<typename T, typename Z>
using AuHashMap = std::unordered_map<T, Z>; using AuHashMap = std::unordered_map<T, Z>;
#endif #endif
#if !defined(AU_AuString) #if !defined(AU_AuString)
#define AU_AuString #define AU_AuString
using AuString = std::string; using AuString = std::string;
#endif #endif
#if !defined(AU_UInt) #if !defined(AU_AuConsumer)
#define AU_UInt #define AU_AuConsumer
using AuUInt = size_t; template<typename ... T>
#endif using AuConsumer = std::function<void(T...)>;
#endif
#endif
#if !defined(AU_Consumer) #if !defined(AU_AuUInt)
#define AU_Consumer #define AU_AuUInt
template<typename ... T> using AuUInt = size_t;
using AuConsumer = std::function<void(T...)>; #endif
#endif
#endif #endif
@ -90,4 +92,21 @@ using AuConsumer = std::function<void(T...)>;
static const name k ## name ## MaxLegal = static_cast<name>(k ## name ## Count - 1); \ static const name k ## name ## MaxLegal = static_cast<name>(k ## name ## Count - 1); \
static const name k ## name ## MinLegal = static_cast<name>(0); static const name k ## name ## MinLegal = static_cast<name>(0);
#define AUE_ITERATE(name, index) name index = static_cast<name>(0); static_cast<AuUInt>(index) < static_cast<AuUInt>(name::kEnumCount); index = static_cast<name>(static_cast<AuUInt>(index) + 1) #define AUE_ITERATE(name, index) name index = static_cast<name>(0); static_cast<AuUInt>(index) < static_cast<AuUInt>(name::kEnumCount); index = static_cast<name>(static_cast<AuUInt>(index) + 1)
///////////////////////////////////////////////////////////////////////////////////////////
// Limited support for when there is no STL or STL-like library available
///////////////////////////////////////////////////////////////////////////////////////////
#if defined(AUE_NOCPPSTL)
#undef AUE_DEFINE
#define AUE_DEFINE(name, vals) enum class name { AU_FOR_EACH(AUE_EMIT_ARRAY, AUE_STRIP_BRACKETS(vals)) kEnumCount }; \
static inline const char * k ## name ## ToString[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH(AUE_EMIT_A, AUE_STRIP_BRACKETS(vals)) }; \
static inline const name k ## name ## Values[static_cast<AuUInt>(name::kEnumCount)] = { AU_FOR_EACH_THAT(AUE_EMIT_D, name, AUE_STRIP_BRACKETS(vals)) }; \
static inline const char * name ## ToString(name val) { static const char * invalid = "kEnumCount"; if (static_cast<AuUInt>(val) >= static_cast<AuUInt>(name::kEnumCount)) return invalid; return k ## name ## ToString[static_cast<AuUInt>(val)]; } \
static inline bool name ## IsValid(name val) { return static_cast<AuUInt>(val) < static_cast<AuUInt>(name::kEnumCount); } \
static const AuUInt k ## name ## Count = static_cast<AuUInt>(name::kEnumCount); \
static const name k ## name ## Invalid = name::kEnumCount; \
static const name k ## name ## MaxLegal = static_cast<name>(k ## name ## Count - 1); \
static const name k ## name ## MinLegal = static_cast<name>(0);
#endif