diff --git a/.vscode/settings.json b/.vscode/settings.json index b2b244d..0465b58 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,8 @@ "tuple": "cpp", "xmemory": "cpp", "algorithm": "cpp", - "limits": "cpp" + "limits": "cpp", + "concepts": "cpp" }, "C_Cpp.intelliSenseEngineFallback": "disabled", "mesonbuild.configureOnOpen": true, diff --git a/project/gen.cpp b/project/gen.cpp index 1d9735d..14a3b5e 100644 --- a/project/gen.cpp +++ b/project/gen.cpp @@ -1458,52 +1458,6 @@ namespace gen return &_std_files[ std ]; } - // void file_connect_handle( FileInfo* file, void* handle ) - // { - // GEN_ASSERT_NOT_NULL( file ); - // GEN_ASSERT_NOT_NULL( handle ); - - // if ( file->is_temp ) - // return; - - // zero_item( file ); - - // file->fd.p = handle; - // file->ops = default_file_operations; - // } - - // FileError file_truncate( FileInfo* f, s64 size ) - // { - // FileError err = EFileError_NONE; - // s64 prev_offset = file_tell( f ); - // file_seek( f, size ); - // if ( ! SetEndOfFile( f ) ) - // err = EFileError_TRUNCATION_FAILURE; - // file_seek( f, prev_offset ); - // return err; - // } - - // b32 fs_exists( char const* name ) - // { - // WIN32_FIND_DATAW data; - // wchar_t* w_text; - // void* handle; - // b32 found = false; - // AllocatorInfo a = heap_allocator(); - - // w_text = _alloc_utf8_to_ucs2( a, name, NULL ); - // if ( w_text == NULL ) - // { - // return false; - // } - // handle = FindFirstFileW( w_text, &data ); - // free( a, w_text ); - // found = handle != INVALID_HANDLE_VALUE; - // if ( found ) - // FindClose( handle ); - // return found; - // } - #else // POSIX FileInfo* file_get_standard( FileStandardType std ) @@ -1522,20 +1476,6 @@ namespace gen return &_std_files[ std ]; } - // FileError file_truncate( FileInfo* f, s64 size ) - // { - // FileError err = EFileError_NONE; - // int i = ftruncate( f->fd.i, size ); - // if ( i != 0 ) - // err = EFileError_TRUNCATION_FAILURE; - // return err; - // } - - // b32 fs_exists( char const* name ) - // { - // return access( name, F_OK ) != -1; - // } - #endif FileError file_close( FileInfo* f ) @@ -3042,7 +2982,7 @@ namespace gen # define local_persist local_persist # define def_constant_spec( Type_, ... ) \ - spec_##Type_ = def_specifiers( macro_num_args(__VA_ARGS__), __VA_ARGS__); \ + spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \ spec_##Type_.set_global(); def_constant_spec( const, ESpecifier::Const ); @@ -3296,7 +3236,7 @@ namespace gen switch ( op ) { - # define specs( ... ) macro_num_args( __VA_ARGS__ ), __VA_ARGS__ + # define specs( ... ) num_args( __VA_ARGS__ ), __VA_ARGS__ case Assign: check_params(); diff --git a/project/gen.hpp b/project/gen.hpp index 64ffc2c..6109703 100644 --- a/project/gen.hpp +++ b/project/gen.hpp @@ -23,7 +23,6 @@ # pragma clang diagnostic ignored "-Wunused-function" #endif - #pragma region Platform Detection /* Platform architecture */ @@ -105,151 +104,39 @@ # define GEN_COMPILER_CLANG 1 #elif defined( __MINGW32__ ) # define GEN_COMPILER_MINGW 1 -#elif defined( __TINYC__ ) -# define GEN_COMPILER_TINYC 1 -#else # error Unknown compiler #endif -#if defined( GEN_HAS_ATTRIBUTE ) -# undef GEN_HAS_ATTRIBUTE -#endif #if defined( __has_attribute ) # define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute ) #else # define GEN_HAS_ATTRIBUTE( attribute ) ( 0 ) #endif -#ifndef GEN_DEF_INLINE -# if defined( GEN_STATIC ) -# define GEN_DEF_INLINE -# define GEN_IMPL_INLINE -# else -# define GEN_DEF_INLINE static -# define GEN_IMPL_INLINE static inline -# endif -#endif - -#if defined( GEN_ALWAYS_INLINE ) -# undef GEN_ALWAYS_INLINE -#endif +#define GEN_DEF_INLINE static +#define GEN_IMPL_INLINE static inline #ifdef GEN_COMPILER_MSVC # define forceinline __forceinline -#elif defined(GEN_COMPILER_GCC) -# define forceinline inline __attribute__((__always_inline__)) -#elif defined(GEN_COMPILER_CLANG) -#if __has_attribute(__always_inline__) -# define forceinline inline __attribute__((__always_inline__)) -#else -# define forceinline inline -#endif -#else -# define forceinline inline -#endif - -#ifdef GEN_COMPILER_MSVC # define neverinline __declspec( noinline ) #elif defined(GEN_COMPILER_GCC) -# define forceinline inline __attribute__( ( __noinline__ ) ) +# define forceinline inline __attribute__((__always_inline__)) +# define neverinline __attribute__( ( __noinline__ ) ) #elif defined(GEN_COMPILER_CLANG) #if __has_attribute(__always_inline__) -# define forceinline inline __attribute__( ( __noinline__ ) ) +# define forceinline inline __attribute__((__always_inline__)) +# define neverinline __attribute__( ( __noinline__ ) ) #else -# define forceinline inline +# define forceinline +# define neverinline #endif #else -# define forceinline inline +# define forceinline +# define neverinline #endif #pragma endregion Platform Detection -#ifndef zpl_cast -# define zpl_cast( Type ) ( Type ) -#endif - -// num_args macro -#if defined(__GNUC__) || defined(__clang__) - // Supports 0-10 arguments - #define macro_num_args_impl( _0, \ - _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ - _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ - N, ... \ - ) N - // _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ - // _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ - // _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, - - // ## deletes preceding comma if _VA_ARGS__ is empty (GCC, Clang) - #define macro_num_args(...) \ - macro_num_args_impl(_, ## __VA_ARGS__, \ - 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, \ - 0 \ - ) - // 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ - // 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, \ - // 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, -#else - // Supports 1-10 arguments - #define macro_num_args_impl( \ - _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ - _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ - N, ... \ - ) N - - #define macro_num_args(...) \ - macro_num_args_impl( __VA_ARGS__, \ - 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 \ - ) -#endif - -// Bits - -#define bit( Value_ ) ( 1 << Value_ ) -#define bitfield_is_equal( Type_, Field_, Mask_ ) ( (Type_(Mask_) & Type_(Field_)) == Type_(Mask_) ) - -// Casting -#define ccast( Type_, Value_ ) * const_cast< Type_* >( & (Value_) ) - -#define rcast( Type_, Value_ ) reinterpret_cast< Type_ >( Value_ ) -#define scast( Type_, Value_ ) static_cast< Type_ >( Value_ ) -#define pcast( Type_, Value_ ) ( * (Type_*)( & (Value_) ) ) - -// Keywords - -#define global static // Global variables -#define internal static // Internal linkage -#define local_persist static // Local Persisting variables - -#define stringize_va( ... ) #__VA_ARGS__ -#define stringize( ... ) stringize_va( __VA_ARGS__ ) - -#define do_once() \ -do \ -{ \ - static \ - bool Done = false; \ - if ( Done ) \ - return; \ - Done = true; \ -} \ -while(0) - -#define do_once_start \ -do \ -{ \ - static \ - bool Done = false; \ - if ( Done ) \ - break; \ - Done = true; - -#define do_once_end \ -} \ -while(0); - #pragma region Mandatory Includes # include # include @@ -261,75 +148,144 @@ while(0); namespace gen { - #ifndef count_of - # define count_of( x ) ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) ) + #define zpl_cast( Type ) ( Type ) + + // Keywords + + #define global static // Global variables + #define internal static // Internal linkage + #define local_persist static // Local Persisting variables + + // Bits + + #define bit( Value_ ) ( 1 << Value_ ) + #define bitfield_is_equal( Type_, Field_, Mask_ ) ( (Type_(Mask_) & Type_(Field_)) == Type_(Mask_) ) + + // Casting + #define ccast( Type_, Value_ ) * const_cast< Type_* >( & (Value_) ) + #define pcast( Type_, Value_ ) ( * (Type_*)( & (Value_) ) ) + #define rcast( Type_, Value_ ) reinterpret_cast< Type_ >( Value_ ) + #define scast( Type_, Value_ ) static_cast< Type_ >( Value_ ) + + // Num Arguments (Varadics) + #if defined(__GNUC__) || defined(__clang__) + // Supports 0-10 arguments + #define num_args_impl( _0, \ + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + N, ... \ + ) N + // _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ + // _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ + // _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, + + // ## deletes preceding comma if _VA_ARGS__ is empty (GCC, Clang) + #define num_args(...) \ + num_args_impl(_, ## __VA_ARGS__, \ + 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, \ + 0 \ + ) + // 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ + // 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, \ + // 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, + #else + // Supports 1-10 arguments + #define num_args_impl( \ + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + N, ... \ + ) N + + #define num_args(...) \ + num_args_impl( __VA_ARGS__, \ + 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 \ + ) #endif - #ifndef is_between - # define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) ) - #endif + // Stringizing + #define stringize_va( ... ) #__VA_ARGS__ + #define stringize( ... ) stringize_va( __VA_ARGS__ ) - #ifndef min - # define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) - #endif + // Function do once - #ifndef size_of - # define size_of( x ) ( sw )( sizeof( x ) ) - #endif + #define do_once() \ + do \ + { \ + static \ + bool Done = false; \ + if ( Done ) \ + return; \ + Done = true; \ + } \ + while(0) - #ifndef swap - # define swap( Type, a, b ) \ - do \ - { \ - Type tmp = ( a ); \ - ( a ) = ( b ); \ - ( b ) = tmp; \ - } while ( 0 ) - #endif + #define do_once_start \ + do \ + { \ + static \ + bool Done = false; \ + if ( Done ) \ + break; \ + Done = true; + + #define do_once_end \ + } \ + while(0); + + #define count_of( x ) ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) ) + #define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) ) + #define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) + #define size_of( x ) ( sw )( sizeof( x ) ) + #define swap( Type, a, b ) \ + do \ + { \ + Type tmp = ( a ); \ + ( a ) = ( b ); \ + ( b ) = tmp; \ + } while ( 0 ) #pragma region Basic Types - #ifndef GEN_U8_MIN - # define GEN_U8_MIN 0u - # define GEN_U8_MAX 0xffu - # define GEN_I8_MIN ( -0x7f - 1 ) - # define GEN_I8_MAX 0x7f + #define GEN_U8_MIN 0u + #define GEN_U8_MAX 0xffu + #define GEN_I8_MIN ( -0x7f - 1 ) + #define GEN_I8_MAX 0x7f - # define GEN_U16_MIN 0u - # define GEN_U16_MAX 0xffffu - # define GEN_I16_MIN ( -0x7fff - 1 ) - # define GEN_I16_MAX 0x7fff + #define GEN_U16_MIN 0u + #define GEN_U16_MAX 0xffffu + #define GEN_I16_MIN ( -0x7fff - 1 ) + #define GEN_I16_MAX 0x7fff - # define GEN_U32_MIN 0u - # define GEN_U32_MAX 0xffffffffu - # define GEN_I32_MIN ( -0x7fffffff - 1 ) - # define GEN_I32_MAX 0x7fffffff + #define GEN_U32_MIN 0u + #define GEN_U32_MAX 0xffffffffu + #define GEN_I32_MIN ( -0x7fffffff - 1 ) + #define GEN_I32_MAX 0x7fffffff - # define GEN_U64_MIN 0ull - # define GEN_U64_MAX 0xffffffffffffffffull - # define GEN_I64_MIN ( -0x7fffffffffffffffll - 1 ) - # define GEN_I64_MAX 0x7fffffffffffffffll + #define GEN_U64_MIN 0ull + #define GEN_U64_MAX 0xffffffffffffffffull + #define GEN_I64_MIN ( -0x7fffffffffffffffll - 1 ) + #define GEN_I64_MAX 0x7fffffffffffffffll - # if defined( GEN_ARCH_32_BIT ) - # define GEN_USIZE_MIN GEN_U32_MIN - # define GEN_USIZE_MAX GEN_U32_MAX - # define GEN_ISIZE_MIN GEN_S32_MIN - # define GEN_ISIZE_MAX GEN_S32_MAX - # elif defined( GEN_ARCH_64_BIT ) - # define GEN_USIZE_MIN GEN_U64_MIN - # define GEN_USIZE_MAX GEN_U64_MAX - # define GEN_ISIZE_MIN GEN_I64_MIN - # define GEN_ISIZE_MAX GEN_I64_MAX - # else - # error Unknown architecture size. This library only supports 32 bit and 64 bit architectures. - # endif - - # define GEN_F32_MIN 1.17549435e-38f - # define GEN_F32_MAX 3.40282347e+38f - - # define GEN_F64_MIN 2.2250738585072014e-308 - # define GEN_F64_MAX 1.7976931348623157e+308 + #if defined( GEN_ARCH_32_BIT ) + # define GEN_USIZE_MIN GEN_U32_MIN + # define GEN_USIZE_MAX GEN_U32_MAX + # define GEN_ISIZE_MIN GEN_S32_MIN + # define GEN_ISIZE_MAX GEN_S32_MAX + #elif defined( GEN_ARCH_64_BIT ) + # define GEN_USIZE_MIN GEN_U64_MIN + # define GEN_USIZE_MAX GEN_U64_MAX + # define GEN_ISIZE_MIN GEN_I64_MIN + # define GEN_ISIZE_MAX GEN_I64_MAX + #else + # error Unknown architecture size. This library only supports 32 bit and 64 bit architectures. #endif + #define GEN_F32_MIN 1.17549435e-38f + #define GEN_F32_MAX 3.40282347e+38f + #define GEN_F64_MIN 2.2250738585072014e-308 + #define GEN_F64_MAX 1.7976931348623157e+308 + #if defined( GEN_COMPILER_MSVC ) # if _MSC_VER < 1300 typedef unsigned char u8; @@ -410,47 +366,34 @@ namespace gen #pragma endregion Basic Types #pragma region Debug - constexpr - char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED"; - - #ifndef GEN_DEBUG_TRAP - # if defined( _MSC_VER ) - # if _MSC_VER < 1300 - # define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */ - # else - # define GEN_DEBUG_TRAP() __debugbreak() - # endif - # elif defined( GEN_COMPILER_TINYC ) - # define GEN_DEBUG_TRAP() process_exit( 1 ) + #if defined( _MSC_VER ) + # if _MSC_VER < 1300 + # define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */ # else - # define GEN_DEBUG_TRAP() __builtin_trap() + # define GEN_DEBUG_TRAP() __debugbreak() # endif + #elif defined( GEN_COMPILER_TINYC ) + # define GEN_DEBUG_TRAP() process_exit( 1 ) + #else + # define GEN_DEBUG_TRAP() __builtin_trap() #endif - #ifndef GEN_ASSERT - # define GEN_ASSERT( cond ) GEN_ASSERT_MSG( cond, NULL ) - #endif + #define GEN_ASSERT( cond ) GEN_ASSERT_MSG( cond, NULL ) - #ifndef GEN_ASSERT_MSG - # define GEN_ASSERT_MSG( cond, msg, ... ) \ - do \ - { \ - if ( ! ( cond ) ) \ - { \ - assert_handler( #cond, __FILE__, zpl_cast( s64 ) __LINE__, msg, ##__VA_ARGS__ ); \ - GEN_DEBUG_TRAP(); \ - } \ - } while ( 0 ) - #endif + #define GEN_ASSERT_MSG( cond, msg, ... ) \ + do \ + { \ + if ( ! ( cond ) ) \ + { \ + assert_handler( #cond, __FILE__, zpl_cast( s64 ) __LINE__, msg, ##__VA_ARGS__ ); \ + GEN_DEBUG_TRAP(); \ + } \ + } while ( 0 ) - #ifndef GEN_ASSERT_NOT_NULL - # define GEN_ASSERT_NOT_NULL( ptr ) GEN_ASSERT_MSG( ( ptr ) != NULL, #ptr " must not be NULL" ) - #endif + #define GEN_ASSERT_NOT_NULL( ptr ) GEN_ASSERT_MSG( ( ptr ) != NULL, #ptr " must not be NULL" ) // NOTE: Things that shouldn't happen with a message! - #ifndef GEN_PANIC - # define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ ) - #endif + #define GEN_PANIC( msg, ... ) GEN_ASSERT_MSG( 0, msg, ##__VA_ARGS__ ) void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... ); s32 assert_crash( char const* condition ); @@ -458,12 +401,10 @@ namespace gen #pragma endregion Debug #pragma region Memory - #ifndef kilobytes - # define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) ) - # define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) ) - # define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) ) - # define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) ) - #endif + #define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) ) + #define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) ) + #define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) ) + #define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) ) #define GEN__ONES ( zpl_cast( uw ) - 1 / GEN_U8_MAX ) #define GEN__HIGHS ( GEN__ONES * ( GEN_U8_MAX / 2 + 1 ) ) @@ -497,13 +438,11 @@ namespace gen //! @param size The size to clear up with. GEN_DEF_INLINE void zero_size( void* ptr, sw size ); - #ifndef zero_item //! Clears up an item. - # define zero_item( t ) zero_size( ( t ), size_of( *( t ) ) ) // NOTE: Pass pointer of struct + #define zero_item( t ) zero_size( ( t ), size_of( *( t ) ) ) // NOTE: Pass pointer of struct //! Clears up an array. - # define zero_array( a, count ) zero_size( ( a ), size_of( *( a ) ) * count ) - #endif + #define zero_array( a, count ) zero_size( ( a ), size_of( *( a ) ) * count ) enum AllocType : u8 { @@ -555,13 +494,11 @@ namespace gen //! Resize an allocated memory with specified alignment. GEN_DEF_INLINE void* resize_align( AllocatorInfo a, void* ptr, sw old_size, sw new_size, sw alignment ); - #ifndef alloc_item //! Allocate memory for an item. - # define alloc_item( allocator_, Type ) ( Type* )alloc( allocator_, size_of( Type ) ) + #define alloc_item( allocator_, Type ) ( Type* )alloc( allocator_, size_of( Type ) ) //! Allocate memory for an array of items. - # define alloc_array( allocator_, Type, count ) ( Type* )alloc( allocator_, size_of( Type ) * ( count ) ) - #endif + #define alloc_array( allocator_, Type, count ) ( Type* )alloc( allocator_, size_of( Type ) * ( count ) ) /* heap memory analysis tools */ /* define GEN_HEAP_ANALYSIS to enable this feature */ @@ -582,13 +519,11 @@ namespace gen //! The heap allocator backed by operating system's memory manager. constexpr AllocatorInfo heap( void ) { return { heap_allocator_proc, nullptr }; } - #ifndef malloc //! Helper to allocate memory using heap allocator. - # define malloc( sz ) alloc( heap(), sz ) + #define malloc( sz ) alloc( heap(), sz ) //! Helper to free memory allocated by heap allocator. - # define mfree( ptr ) free( heap(), ptr ) - #endif + #define mfree( ptr ) free( heap(), ptr ) GEN_IMPL_INLINE b32 is_power_of_two( sw x ) { @@ -1159,9 +1094,6 @@ namespace gen #pragma endregion String Ops #pragma region Containers - #pragma push_macro("template") - #undef template - template struct Array { @@ -1620,8 +1552,6 @@ namespace gen return 0.75f * Hashes.num() < Entries.num(); } }; - - #pragma pop_macro("template") #pragma endregion Containers #pragma region Hashing @@ -2262,6 +2192,9 @@ namespace gen void cleanup(); } + constexpr + char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED"; + inline sw log_fmt(char const* fmt, ...) { @@ -3213,10 +3146,10 @@ namespace gen // Same as name just used to indicate intention of literal for code instead of names. # define code( ... ) { sizeof(stringize(__VA_ARGS__)) - 1, stringize( __VA_ARGS__ ) } -# define args( ... ) macro_num_args( __VA_ARGS__ ), __VA_ARGS__ +# define args( ... ) num_args( __VA_ARGS__ ), __VA_ARGS__ // Takes a format string (char const*) and a list of tokens (StrC) and returns a StrC of the formatted string. -# define token_fmt( ... ) token_fmt_impl( (macro_num_args( __VA_ARGS__ ) + 1) / 2, __VA_ARGS__ ) +# define token_fmt( ... ) token_fmt_impl( (num_args( __VA_ARGS__ ) + 1) / 2, __VA_ARGS__ ) #pragma endregion Macros #pragma region Constants diff --git a/project/gen.undef.macros.hpp b/project/gen.undef.macros.hpp index f896661..073d511 100644 --- a/project/gen.undef.macros.hpp +++ b/project/gen.undef.macros.hpp @@ -2,6 +2,55 @@ // This undefines the macros used by the gen library but are not necessary for the user. // TODO : This is incomplete until all dependencies are brough in from ZPL into bloat. +#undef GEN_ARCH_64_BIT +#undef GEN_ARCH_32_BIT + +#undef GEN_SYSTEM_ANDROID +#undef GEN_SYSTEM_CYGWIN +#undef GEN_SYSTEM_EMSCRIPTEN +#undef GEN_SYSTEM_FREEBSD +#undef GEN_SYSTEM_IOS +#undef GEN_SYSTEM_LINUX +#undef GEN_SYSTEM_MACOS +#undef GEN_SYSTEM_OPENBSD +#undef GEN_SYSTEM_OSX +#undef GEN_SYSTEM_UNIX +#undef GEN_SYSTEM_WINDOWS + +#undef GEN_COMPILER_CLANG +#undef GEN_COMPILER_GCC +#undef GEN_COMPILER_MINGW +#undef GEN_COMPILER_MSVC + +#undef forceinline +#undef neverinline + +#undef zpl_cast + +#undef global +#undef internal +#undef local_persist + +#undef kilobytes +#undef megabytes +#undef gigabytes +#undef terabytes + +#undef zero_item +#undef zero_array + +#undef alloc_item +#undef alloc_array + +#undef malloc +#undef mfree + +#undef count_of +#undef is_between +#undef min +#undef size_of +#undef swap + #undef bit #undef bitfield_is_equal #undef ccast @@ -11,11 +60,18 @@ #undef do_once #undef do_once_start #undef do_once_end +#undef num_args +#undef num_args_impl +#undef stringize +#undef stringize +#undef stringize_va +#undef txt_StrC -#undef kilobytes -#undef megabytes -#undef gigabytes -#undef terabytes +#undef __ +#undef args +#undef gen_main +#undef gen_time +#undef token_fmt // gen_time #endif diff --git a/scripts/gencpp.refactor b/scripts/gencpp.refactor index 2a0aba4..3a6deb2 100644 --- a/scripts/gencpp.refactor +++ b/scripts/gencpp.refactor @@ -18,95 +18,240 @@ // Precedence (highest to lowest): // word, namespace, regex -// Basic Types +// Gen Macro namespace +// namespace GEN_ new_namespace_ +// ---------- ZPL Macros + +// word GEN_ARCH_64_BIT new_name +// word GEN_ARCH_32_BIT new_name + +// word GEN_SYSTEM_ANDROID new_name +// word GEN_SYSTEM_CYGWIN new_name +// word GEN_SYSTEM_EMSCRIPTEN new_name +// word GEN_SYSTEM_FREEBSD new_name +// word GEN_SYSTEM_IOS new_name +// word GEN_SYSTEM_LINUX new_name +// word GEN_SYSTEM_MACOS new_name +// word GEN_SYSTEM_OPENBSD new_name +// word GEN_SYSTEM_OSX new_name +// word GEN_SYSTEM_UNIX new_name +// word GEN_SYSTEM_WINDOWS new_name + +// word GEN_COMPILER_CLANG new_name +// word GEN_COMPILER_GCC new_name +// word GEN_COMPILER_MINGW new_name +// word GEN_COMPILER_MSVC new_name + +// word forceinline new_name +// word neverinline new_name + +// word zpl_cast new_name + +// word global new_name +// word internal new_name +// word local_persist new_name + +// word GEN_DEBUG_TRAP new_name +// word GEN_ASSERT new_name +// word GEN_ASSERT_MSG new_name +// word GEN_ASSERT_NOT_NULL new_name +// word GEN_PANIC new_name + +// word zero_item new_name +// word zero_array new_name + +// word alloc_item new_name +// word alloc_array new_name + +// word malloc new_name +// word mfree new_name + +// word count_of new_name +// word is_between new_name +// word min new_name +// word size_of new_name +// word swap new_name + +// ---------- ZPL Types + +// word b8 new_name +// word b16 new_name // word b32 new_name // word s8 new_name +// word s16 new_name +// word s32 new_name // word s64 new_name // word u8 new_name +// word u16 new_name // word u32 new_name // word u64 new_name // word uw new_name // word sw new_name // word sptr new_name // word uptr new_name - -// ZPL Derived +// word f32 new_name +// word f64 new_name // namespace EAllocator_ new_namespace_ // namespace EFileMode_ new_namespace_ // namespace EFileError_ new_namespace_ -// word Arena new_name -// word AllocatorInfo new_name -// word ArrayHeader new_name -// word FileInfo new_name -// word FileError new_name -// word Pool new_name +// word AllocatorInfo new_name +// word AllocatorProc new_name +// word AllocFlag new_name +// word AllocType new_name +// word ArrayHeader new_name +// word DirEntry new_name +// word DirInfo new_name +// word DirType new_name +// word FileDescriptor new_name +// word FileError new_name +// word FileInfo new_name +// word FileTime new_name +// word FileModeFlag new_name +// word FileOperations new_name +// word FileStandardType new_name +// word SeekWhenceType new_name +// ---------- ZPL Data + +// word default_file_operations new_name + +// ---------- ZPL Procedures + +// word align_forward new_name +// word align_fordward_i64 new_name +// word alloc new_name +// word alloc_align new_name +// word assert_handler new_name +// word assert_crash new_name +// word char_first_occurence new_name +// word char_is_alpha new_name +// word char_is_alphanumeric new_name +// word char_is_digit new_name +// word char_is_hex_digit new_name +// word char_is_space new_name +// word char_to_lower new_name +// word char_to_upper new_name +// word crc32 new_name +// word default_resize_align new_name +// word digit_to_int new_name +// word file_close new_name +// word file_get_standard new_name +// word file_name new_name +// word file_open new_name +// word file_open_mode new_name +// word file_seek new_name +// word file_tell new_name +// word file_write new_name +// word file_write_at new_name +// word file_write_at_check new_name +// word free new_name +// word free_all new_name +// word heap new_name +// word heap_allocator_proc new_name +// word heap_stats_check new_name +// word heap_stats_alloc_count new_name +// word heap_stats_init new_name +// word heap_stats_used_memory new_name +// word hex_digit_to_int new_name +// word i64_to_str new_name +// word is_power_of_two new_name +// word mem_copy new_name +// word mem_move new_name +// word mem_set new_name +// word pointer_add new_name +// word mem_copy new_name +// word mem_find new_name +// word mem_move new_name +// word mem_set new_name +// word resize new_name +// word resize_align new_name +// word process_exit new_name +// word str_compare new_name +// word str_copy new_name +// word str_copy_nulpad new_name +// word str_fmt_buf new_name +// word str_fmt_buf_va new_name +// word str_fmt_file_va new_name +// word str_fmt_out_va new_name +// word str_fmt_out_err new_name +// word str_fmt_out_err_va new_name +// word str_fmt_va new_name +// word str_len new_name +// word str_reverse new_name +// word str_to_i64 new_name +// word str_to_lower new_name +// word str_to_upper new_name +// word u64_to_str new_name +// word zero_size new_name + +// ---------- gencpp Macros + +// word bit new_name +// word bitfield_is_equal new_name + +// word ccast new_name +// word pcast new_name +// word rcast new_name +// word scast new_name + +// word do_once new_name +// word do_once_start new_name +// word do_once_end new_name +// word num_args new_name +// word num_args_impl new_name +// word stringize new_name +// word stringize_va new_name +// word txt_StrC new_name + +// ------------ gencpp common + +// word Arena new_name // word Array new_name // word HashTable new_name +// word Pool new_name +// word StrC new_name +// word String new_name -// word alloc new_name -// word alloc_align new_name -// word assert_crash new_name -// word char_first_occurence new_name -// word char_is_alpha new_name -// word char_is_alphanumeric new_name -// word char_is_digit new_name -// word char_is_hex_digit new_name -// word char_is_space new_name -// word crc32 new_name -// word free_all new_name -// word mem_copy new_name -// word mem_move new_name -// word mem_set new_name -// word process_exit new_name -// word str_compare new_name -// word str_copy new_name -// word str_fmt_buf new_name -// word str_fmt_va new_name -// word str_fmt_out_va new_name -// word str_fmt_out_err_va new_name -// word str_len new_name +// word log_fmt new_name +// word fatal new_name +// word to_str new_name +// word to_StrC new_name +// word to_type new_name -// generic API - -// word to_str new_name -// word to_type new_name - -// gencpp Types & Constants +// ------------ gencpp Types & Constants // word LogFailType new_name // word log_failure new_name +// word AccessSpec new_name // word ECode new_name -// word EnumT new_name // word EnumClass new_name // word EnumRegular new_name -// word UsingT new_name +// word EnumT new_name +// word EOperator new_name +// word ESpecifier new_name +// word OperatorT new_name +// word ModuleFlag new_name +// word SpecifierT new_name +// word StringCached new_name +// word StringTable new_name // word UsingRegular new_name // word UsingNamespace new_name -// word EOperator new_name -// word OperatorT new_name -// word ESpecifier new_name -// word SpecifierT new_name -// word AccessSpec new_name -// word ModuleFlag new_name - -// word API_Export new_name -// word API_Import new_name -// word Keyword new_name +// word UsingT new_name // gencpp Data -// word StringTable new_name -// word StringCached new_name +// word API_Export new_name +// word API_Import new_name // word AST_POD_Size new_name // word AST new_name // word AST_POD new_name // word Code new_name // word Code_POD new_name +// word Keyword new_name // word NoCode new_name // gencpp API @@ -153,27 +298,17 @@ // word def_using_namespace new_name // word def_variable new_name -// word def_class_body new_name +// word def_body new_name // word def_class_body new_name // word def_enum_body new_name -// word def_enum_body new_name -// word def_export_body new_name // word def_export_body new_name // word def_extern_link_body new_name -// word def_extern_link_body new_name -// word def_function_body new_name // word def_function_body new_name // word def_global_body new_name -// word def_global_body new_name -// word def_namespace_body new_name // word def_namespace_body new_name // word def_params new_name -// word def_params new_name -// word def_specifiers new_name // word def_specifiers new_name // word def_struct_body new_name -// word def_struct_body new_name -// word def_union_body new_name // word def_union_body new_name // parse constructor namespace @@ -203,8 +338,8 @@ // untyped constructor individual +// word token_fmt_impl new_name // word token_fmt_va new_name -// word token_fmt new_name // word untyped_str new_name // word untyped_fmt new_name // word untyped_token_fmt new_name @@ -217,11 +352,14 @@ // gencpp macros +// word gen_main new_name +// word gen_time new_name + // word __ new_name // word code new_name // word name new_name -// word txt new_name -// word txt_to_StrC new_name +// word args new_name +// word token_fmt new_name // Type AST namespace // namespace t_ new_namespace_