Adding pragma regions to all dependency components

This commit is contained in:
Edward R. Gonzalez 2023-07-25 23:00:57 -04:00
parent a11117c97c
commit 8232e79aac
23 changed files with 98 additions and 16 deletions

View File

@ -1,3 +1,5 @@
#pragma region Basic Types
#define GEN_U8_MIN 0u
#define GEN_U8_MAX 0xffu
#define GEN_I8_MIN ( -0x7f - 1 )
@ -114,3 +116,5 @@ static_assert( sizeof( f64 ) == 8, "sizeof(f64) != 8" );
typedef s8 b8;
typedef s16 b16;
typedef s32 b32;
#pragma region Basic Types

View File

@ -1,3 +1,5 @@
#pragma region Containers
template<class Type>
struct Array
{
@ -530,9 +532,4 @@ protected:
}
};
#pragma region Hashing
u32 crc32( void const* data, sw len );
u64 crc64( void const* data, sw len );
#pragma endregion Hashing
#pragma endregion Containers

View File

@ -1,3 +1,5 @@
#pragma endregion Debug
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... )
{
_printf_err( "%s:(%d): Assert Failure: ", file, line );
@ -35,3 +37,5 @@ s32 assert_crash( char const* condition )
exit( code );
}
#endif
#pragma endregion Debug

View File

@ -1,3 +1,5 @@
#pragma endregion Debug
#if defined( _MSC_VER )
# if _MSC_VER < 1300
# define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */
@ -30,3 +32,5 @@
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... );
s32 assert_crash( char const* condition );
void process_exit( u32 code );
#pragma endregion Debug

View File

@ -1,3 +1,5 @@
#pragma region File Handling
#if defined( GEN_SYSTEM_WINDOWS ) || defined( GEN_SYSTEM_CYGWIN )
internal wchar_t* _alloc_utf8_to_ucs2( AllocatorInfo a, char const* text, sw* w_len_ )
@ -630,3 +632,5 @@ internal GEN_FILE_CLOSE_PROC( _memory_file_close )
}
FileOperations const memory_file_operations = { _memory_file_read, _memory_file_write, _memory_file_seek, _memory_file_close };
#pragma endregion File Handling

View File

@ -1,3 +1,4 @@
#pragma region File Handling
typedef u32 FileMode;
@ -367,3 +368,5 @@ b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw siz
u8* file_stream_buf( FileInfo* file, sw* size );
extern FileOperations const memory_file_operations;
#pragma endregion File Handling

View File

@ -1,3 +1,5 @@
#pragma region Hashing
global u32 const _crc32_table[ 256 ] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd,
0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
@ -79,3 +81,5 @@ u64 crc64( void const* data, sw len )
result = ( result >> 8 ) ^ ( _crc64_table[ ( result ^ *c ) & 0xff ] );
return result;
}
#pragma region Hashing

View File

@ -0,0 +1,6 @@
#pragma region Hashing
u32 crc32( void const* data, sw len );
u64 crc64( void const* data, sw len );
#pragma endregion Hashing

View File

@ -1,3 +1,5 @@
#pragma region Macros and Includes
# include <stdio.h>
// NOTE: Ensure we use standard methods for these calls if we use GEN_PICO
# if ! defined( GEN_PICO_CUSTOM_ROUTINES )
@ -74,3 +76,5 @@
# include <timezoneapi.h>
#endif
#endif
#pragma endregion Macros and Includes

View File

@ -1,3 +1,5 @@
#pragma region Macros
#define zpl_cast( Type ) ( Type )
// Keywords
@ -98,3 +100,5 @@ void swap( Type& a, Type& b )
a = b;
b = tmp;
}
#pragma endregion Macros

View File

@ -1,3 +1,5 @@
#pragma region Memory
void* mem_copy( void* dest, void const* source, sw n )
{
if ( dest == NULL )
@ -383,3 +385,5 @@ void Pool::clear()
FreeList = PhysicalStart;
}
#pragma endregion Memory

View File

@ -1,3 +1,5 @@
#pragma region Memory
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
@ -480,3 +482,5 @@ struct Pool
return { allocator_proc, this };
}
};
#pragma endregion Memory

View File

@ -1,4 +1,5 @@
#pragma region ADT
#define _adt_fprintf( s_, fmt_, ... ) \
do \
{ \
@ -780,9 +781,11 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
}
#undef _adt_fprintf
#pragma endregion ADT
#pragma region CSV
#ifdef GEN_CSV_DEBUG
# define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
#else
@ -1062,4 +1065,5 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
file_close( &tmp );
return output;
}
#pragma endregion CSV

View File

@ -1,4 +1,5 @@
#pragma region ADT
enum ADT_Type : u32
{
EADT_TYPE_UNINITIALISED, /* node was not initialised, this is a programming error! */
@ -380,9 +381,11 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
* @return
*/
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
#pragma endregion ADT
#pragma region CSV
enum CSV_Error : u32
{
ECSV_Error__NONE,
@ -418,4 +421,5 @@ GEN_IMPL_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj )
{
return csv_write_string_delimiter( a, obj, ',' );
}
#pragma endregion CSV

View File

@ -1,3 +1,5 @@
#pragma region Printing
enum
{
GEN_FMT_MINUS = bit( 0 ),
@ -558,3 +560,5 @@ sw str_fmt_out_err( char const* fmt, ... )
va_end( va );
return res;
}
#pragma endregion Printing

View File

@ -1,3 +1,5 @@
#pragma region Printing
struct FileInfo;
#ifndef GEN_PRINTF_MAXLEN
@ -54,3 +56,5 @@ sw fatal(char const* fmt, ...)
return -1;
#endif
}
#pragma endregion Printing

View File

@ -1,3 +1,5 @@
#pragma region String
String String::fmt( AllocatorInfo allocator, char* buf, sw buf_size, char const* fmt, ... )
{
va_list va;
@ -33,3 +35,5 @@ bool String::append_fmt( char const* fmt, ... )
return append( buf, res );
}
#pragma endregion String

View File

@ -1,3 +1,5 @@
#pragma region String
// Constant string with length.
struct StrC
{
@ -219,7 +221,7 @@ struct String
sw avail_space() const
{
Header const&
header = * rcast( Header const*, Data - sizeof( Header ));
header = * rcast( Header const*, Data - sizeof( Header ));
return header.Capacity - header.Length;
}
@ -227,7 +229,7 @@ struct String
sw capacity() const
{
Header const&
header = * rcast( Header const*, Data - sizeof( Header ));
header = * rcast( Header const*, Data - sizeof( Header ));
return header.Capacity;
}
@ -260,7 +262,7 @@ struct String
sw length() const
{
Header const&
header = * rcast( Header const*, Data - sizeof( Header ));
header = * rcast( Header const*, Data - sizeof( Header ));
return header.Length;
}
@ -303,7 +305,7 @@ struct String
char* end()
{
Header const&
header = * rcast( Header const*, Data - sizeof( Header ));
header = * rcast( Header const*, Data - sizeof( Header ));
return Data + header.Length;
}
@ -370,3 +372,4 @@ struct String_POD
};
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
#pragma endregion String

View File

@ -1,4 +1,7 @@
internal sw _scan_zpl_i64( const char* text, s32 base, s64* value )
#pragma region String Ops
internal
sw _scan_zpl_i64( const char* text, s32 base, s64* value )
{
const char* text_begin = text;
s64 result = 0;
@ -202,3 +205,5 @@ f64 str_to_f64( const char* str, char** end_ptr )
return result;
}
#pragma endregion String Ops

View File

@ -1,3 +1,5 @@
#pragma region String Ops
GEN_DEF_INLINE const char* char_first_occurence( const char* str, char c );
constexpr auto str_find = &char_first_occurence;
@ -256,3 +258,5 @@ GEN_IMPL_INLINE void str_to_upper( char* str )
str++;
}
}
#pragma endregion String Ops

View File

@ -1,3 +1,5 @@
#pragma region Timing
#ifdef GEN_BENCHMARK
#if defined( GEN_COMPILER_MSVC ) && ! defined( __clang__ )
u64 read_cpu_time_stamp_counter( void )
@ -156,3 +158,5 @@
return ( f64 )( time_rel_ms() * 1e-3 );
}
#endif
#pragma endregion Timing

View File

@ -1,3 +1,5 @@
#pragma region Timing
#ifdef GEN_BENCHMARK
//! Return CPU timestamp.
u64 read_cpu_time_stamp_counter( void );
@ -8,3 +10,5 @@ f64 time_rel( void );
//! Return relative time since the application start.
u64 time_rel_ms( void );
#endif
#pragma endregion Timing

View File

@ -46,6 +46,7 @@ int gen_main()
Code string_ops = scan_file( "dependencies/gen.string_ops.hpp" );
Code printing = scan_file( "dependencies/gen.printing.hpp" );
Code containers = scan_file( "dependencies/gen.containers.hpp" );
Core hashing = scan_file( "dependencies/gen.hashing.hpp" );
Code string = scan_file( "dependencies/gen.string.hpp" );
Code file_handling = scan_file( "dependencies/gen.file_handling.hpp" );
Code parsing = scan_file( "dependencies/gen.parsing.hpp" );
@ -54,9 +55,8 @@ int gen_main()
Builder
deps_header;
deps_header.open("gen/gen_dep.hpp");
deps_header.print_fmt("// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n");
deps_header.print_fmt("// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)\n\n");
deps_header.print_fmt("#pragma once\n\n");
deps_header.print( push_ignores );
deps_header.print( header_start );
deps_header.print( nspace_macro );
deps_header.print_fmt( "GEN_NS_BEGIN\n\n");
@ -67,12 +67,12 @@ int gen_main()
deps_header.print( string_ops );
deps_header.print( printing );
deps_header.print( containers );
deps_header.print( hashing );
deps_header.print( string );
deps_header.print( file_handling );
deps_header.print( parsing );
deps_header.print( timing );
deps_header.print_fmt( "GEN_NS_END\n\n");
deps_header.print( pop_ignores );
deps_header.write();
}