Looking into what the library's convention for enums will be.

Most likely will just reduce them to C-enums with underlying type.
Otherwise there has to be a mechanism to drop the defs down to them anyways, and eliminate the namespace wraps.
This commit is contained in:
2024-12-01 05:30:37 -05:00
parent e5acac1d18
commit ed0c0422ad
15 changed files with 195 additions and 128 deletions

View File

@ -205,4 +205,14 @@
# define foreach(Type, entry_id, iterable) for ( Type entry_id : iterable )
#endif
#if GENC_COMPILERC
# if __STDC_VERSION__ >= 202311L
# define enum_underlying(type) : type
# else
# define enum_underlying(type)
# endif
#else
# define enum_underlying(type) : type
#endif
#pragma endregion Macros

View File

@ -76,13 +76,18 @@
/* Platform compiler */
#if defined( _MSC_VER )
# define GEN_COMPILER_MSVC 1
# define GEN_COMPILER_CLANG 0
# define GEN_COMPILER_MSVC 1
# define GEN_COMPILER_GCC 0
#elif defined( __GNUC__ )
# define GEN_COMPILER_GCC 1
# define GEN_COMPILER_CLANG 0
# define GEN_COMPILER_MSVC 0
# define GEN_COMPILER_GCC 1
#elif defined( __clang__ )
# define GEN_COMPILER_CLANG 1
#elif defined( __MINGW32__ )
# define GEN_COMPILER_MINGW 1
# define GEN_COMPILER_MSVC 0
# define GEN_COMPILER_GCC 1
#else
# error Unknown compiler
#endif
@ -122,11 +127,23 @@
#pragma endregion Mandatory Includes
#if GEN_DONT_USE_NAMESPACE || GEN_COMPILER_C
# define GEN_NS
# define GEN_NS_BEGIN
# define GEN_NS_END
#if GEN_DONT_USE_NAMESPACE
# if GEN_COMPILER_C
# define GEN_NS_ENUM_BEGIN
# define GEN_NS_ENUM_END
# define GEN_NS
# define GEN_NS_BEGIN
# define GEN_NS_END
# else
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
# define GEN_NS_ENUM_END }
# define GEN_NS ::
# define GEN_NS_BEGIN
# define GEN_NS_END
# endif
#else
# define GEN_NS_ENUM_BEGIN namespace gen_internal_enums {
# define GEN_NS_ENUM_END }
# define GEN_NS gen::
# define GEN_NS_BEGIN namespace gen {
# define GEN_NS_END }

View File

@ -85,7 +85,7 @@ struct String
forceinline operator bool() { return Data != nullptr; }
forceinline operator char*() { return Data; }
forceinline operator char const*() const { return Data; }
forceinline operator StrC() const { return { length(* this), Data }; }
forceinline operator StrC() const { return { GEN_NS length(* this), Data }; }
String const& operator=(String const& other) const {
if (this == &other)
@ -101,7 +101,7 @@ struct String
forceinline char const& operator[](ssize index) const { return Data[index]; }
forceinline char* begin() const { return Data; }
forceinline char* end() const { return Data + length(* this); }
forceinline char* end() const { return Data + GEN_NS length(* this); }
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
#pragma region Member Mapping