Scripting updates, some refactors..

Made a package release script.

Did refactors based on some design considerations
Still need to make some major decisions...
This commit is contained in:
2023-08-09 18:47:59 -04:00
parent 5aff89262b
commit aa928ff446
46 changed files with 371 additions and 312 deletions

View File

@ -34,7 +34,7 @@ s32 assert_crash( char const* condition );
void process_exit( u32 code );
#if Build_Debug
#define fatal( fmt, ... ) \
#define GEN_FATAL( fmt, ... ) \
do \
{ \
local_persist thread_local \
@ -46,7 +46,7 @@ void process_exit( u32 code );
while (0)
#else
# define fatal( fmt, ... ) \
# define GEN_FATAL( fmt, ... ) \
do \
{ \
str_fmt_out_err( fmt, __VA_ARGS__ ); \

View File

@ -100,25 +100,6 @@
#define GEN_DEF_INLINE static
#define GEN_IMPL_INLINE static inline
#ifdef GEN_COMPILER_MSVC
# define forceinline __forceinline
# define neverinline __declspec( noinline )
#elif defined(GEN_COMPILER_GCC)
# define forceinline inline __attribute__((__always_inline__))
# define neverinline __attribute__( ( __noinline__ ) )
#elif defined(GEN_COMPILER_CLANG)
#if __has_attribute(__always_inline__)
# define forceinline inline __attribute__((__always_inline__))
# define neverinline __attribute__( ( __noinline__ ) )
#else
# define forceinline
# define neverinline
#endif
#else
# define forceinline
# define neverinline
#endif
#pragma endregion Platform Detection
#pragma region Mandatory Includes

View File

@ -8,6 +8,25 @@
#define internal static // Internal linkage
#define local_persist static // Local Persisting variables
#ifdef GEN_COMPILER_MSVC
# define forceinline __forceinline
# define neverinline __declspec( noinline )
#elif defined(GEN_COMPILER_GCC)
# define forceinline inline __attribute__((__always_inline__))
# define neverinline __attribute__( ( __noinline__ ) )
#elif defined(GEN_COMPILER_CLANG)
#if __has_attribute(__always_inline__)
# define forceinline inline __attribute__((__always_inline__))
# define neverinline __attribute__( ( __noinline__ ) )
#else
# define forceinline
# define neverinline
#endif
#else
# define forceinline
# define neverinline
#endif
// Bits
#define bit( Value ) ( 1 << Value )
@ -125,6 +144,12 @@
#define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
#define size_of( x ) ( sw )( sizeof( x ) )
#if defined( _MSC_VER ) || defined( GEN_COMPILER_TINYC )
# define offset_of( Type, element ) ( ( GEN_NS( gen_sw ) ) & ( ( ( Type* )0 )->element ) )
#else
# define offset_of( Type, element ) __builtin_offsetof( Type, element )
#endif
template< class Type >
void swap( Type& a, Type& b )
{

View File

@ -221,7 +221,7 @@ void* Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw a
if ( arena->TotalUsed + total_size > (sw) arena->TotalSize )
{
// zpl__printf_err("%s", "Arena out of memory\n");
fatal("Arena out of memory! (Possibly could not fit for the largest size Arena!!)");
GEN_FATAL("Arena out of memory! (Possibly could not fit for the largest size Arena!!)");
return nullptr;
}

View File

@ -1,4 +1,4 @@
#pragma region String
#pragma region Strings
// Constant string with length.
struct StrC
@ -12,18 +12,14 @@ struct StrC
}
};
#define txt_StrC( text ) StrC { sizeof( text ) - 1, text }
#define cast_to_strc( str ) * rcast( StrC*, str - sizeof(sw) )
#define txt( text ) StrC { sizeof( text ) - 1, text }
StrC to_StrC( char const* str )
StrC to_str( char const* str )
{
return { str_len( str ), str };
}
sw StrC_len( char const* str )
{
return (sw) ( str - 1 );
}
// Dynamic String
// This is directly based off the ZPL string api.
// They used a header pattern
@ -33,8 +29,8 @@ struct String
struct Header
{
AllocatorInfo Allocator;
sw Length;
sw Capacity;
sw Length;
};
static
@ -92,7 +88,7 @@ struct String
return { nullptr };
Header&
header = * rcast(Header*, allocation);
header = * rcast(Header*, allocation);
header = { allocator, length, length };
String result = { rcast( char*, allocation) + header_size };
@ -332,11 +328,7 @@ struct String
operator StrC() const
{
return
{
length(),
Data
};
return { length(), Data };
}
// Used with cached strings
@ -363,19 +355,21 @@ struct String
return Data[ index ];
}
char* Data = nullptr;
char* Data;
};
struct String_POD
{
char* Data;
operator String()
{
return * rcast(String*, this);
}
};
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
#pragma endregion String
// Implements basic string interning. Data structure is based off the ZPL Hashtable.
using StringTable = HashTable<String const>;
// Represents strings cached with the string table.
// Should never be modified, if changed string is desired, cache_string( str ) another.
using StringCached = String const;
#pragma endregion Strings