mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Adding pragma regions to all dependency components
This commit is contained in:
parent
a11117c97c
commit
8232e79aac
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Basic Types
|
||||||
|
|
||||||
#define GEN_U8_MIN 0u
|
#define GEN_U8_MIN 0u
|
||||||
#define GEN_U8_MAX 0xffu
|
#define GEN_U8_MAX 0xffu
|
||||||
#define GEN_I8_MIN ( -0x7f - 1 )
|
#define GEN_I8_MIN ( -0x7f - 1 )
|
||||||
@ -114,3 +116,5 @@ static_assert( sizeof( f64 ) == 8, "sizeof(f64) != 8" );
|
|||||||
typedef s8 b8;
|
typedef s8 b8;
|
||||||
typedef s16 b16;
|
typedef s16 b16;
|
||||||
typedef s32 b32;
|
typedef s32 b32;
|
||||||
|
|
||||||
|
#pragma region Basic Types
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Containers
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
struct Array
|
struct Array
|
||||||
{
|
{
|
||||||
@ -530,9 +532,4 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma region Hashing
|
#pragma endregion Containers
|
||||||
|
|
||||||
u32 crc32( void const* data, sw len );
|
|
||||||
u64 crc64( void const* data, sw len );
|
|
||||||
|
|
||||||
#pragma endregion Hashing
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma endregion Debug
|
||||||
|
|
||||||
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... )
|
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... )
|
||||||
{
|
{
|
||||||
_printf_err( "%s:(%d): Assert Failure: ", file, line );
|
_printf_err( "%s:(%d): Assert Failure: ", file, line );
|
||||||
@ -35,3 +37,5 @@ s32 assert_crash( char const* condition )
|
|||||||
exit( code );
|
exit( code );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion Debug
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma endregion Debug
|
||||||
|
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
# if _MSC_VER < 1300
|
# if _MSC_VER < 1300
|
||||||
# define GEN_DEBUG_TRAP() __asm int 3 /* Trap to debugger! */
|
# 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, ... );
|
void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... );
|
||||||
s32 assert_crash( char const* condition );
|
s32 assert_crash( char const* condition );
|
||||||
void process_exit( u32 code );
|
void process_exit( u32 code );
|
||||||
|
|
||||||
|
#pragma endregion Debug
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region File Handling
|
||||||
|
|
||||||
#if defined( GEN_SYSTEM_WINDOWS ) || defined( GEN_SYSTEM_CYGWIN )
|
#if defined( GEN_SYSTEM_WINDOWS ) || defined( GEN_SYSTEM_CYGWIN )
|
||||||
|
|
||||||
internal wchar_t* _alloc_utf8_to_ucs2( AllocatorInfo a, char const* text, sw* w_len_ )
|
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 };
|
FileOperations const memory_file_operations = { _memory_file_read, _memory_file_write, _memory_file_seek, _memory_file_close };
|
||||||
|
|
||||||
|
#pragma endregion File Handling
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#pragma region File Handling
|
||||||
|
|
||||||
typedef u32 FileMode;
|
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 );
|
u8* file_stream_buf( FileInfo* file, sw* size );
|
||||||
|
|
||||||
extern FileOperations const memory_file_operations;
|
extern FileOperations const memory_file_operations;
|
||||||
|
|
||||||
|
#pragma endregion File Handling
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Hashing
|
||||||
|
|
||||||
global u32 const _crc32_table[ 256 ] = {
|
global u32 const _crc32_table[ 256 ] = {
|
||||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd,
|
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,
|
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 ] );
|
result = ( result >> 8 ) ^ ( _crc64_table[ ( result ^ *c ) & 0xff ] );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Hashing
|
||||||
|
6
project/dependencies/gen.hashing.hpp
Normal file
6
project/dependencies/gen.hashing.hpp
Normal 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
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Macros and Includes
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
// NOTE: Ensure we use standard methods for these calls if we use GEN_PICO
|
// NOTE: Ensure we use standard methods for these calls if we use GEN_PICO
|
||||||
# if ! defined( GEN_PICO_CUSTOM_ROUTINES )
|
# if ! defined( GEN_PICO_CUSTOM_ROUTINES )
|
||||||
@ -74,3 +76,5 @@
|
|||||||
# include <timezoneapi.h>
|
# include <timezoneapi.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion Macros and Includes
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Macros
|
||||||
|
|
||||||
#define zpl_cast( Type ) ( Type )
|
#define zpl_cast( Type ) ( Type )
|
||||||
|
|
||||||
// Keywords
|
// Keywords
|
||||||
@ -98,3 +100,5 @@ void swap( Type& a, Type& b )
|
|||||||
a = b;
|
a = b;
|
||||||
b = tmp;
|
b = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion Macros
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Memory
|
||||||
|
|
||||||
void* mem_copy( void* dest, void const* source, sw n )
|
void* mem_copy( void* dest, void const* source, sw n )
|
||||||
{
|
{
|
||||||
if ( dest == NULL )
|
if ( dest == NULL )
|
||||||
@ -383,3 +385,5 @@ void Pool::clear()
|
|||||||
|
|
||||||
FreeList = PhysicalStart;
|
FreeList = PhysicalStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion Memory
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Memory
|
||||||
|
|
||||||
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
||||||
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
||||||
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
||||||
@ -480,3 +482,5 @@ struct Pool
|
|||||||
return { allocator_proc, this };
|
return { allocator_proc, this };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma endregion Memory
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma region ADT
|
#pragma region ADT
|
||||||
|
|
||||||
#define _adt_fprintf( s_, fmt_, ... ) \
|
#define _adt_fprintf( s_, fmt_, ... ) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
@ -780,9 +781,11 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef _adt_fprintf
|
#undef _adt_fprintf
|
||||||
|
|
||||||
#pragma endregion ADT
|
#pragma endregion ADT
|
||||||
|
|
||||||
#pragma region CSV
|
#pragma region CSV
|
||||||
|
|
||||||
#ifdef GEN_CSV_DEBUG
|
#ifdef GEN_CSV_DEBUG
|
||||||
# define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
|
# define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
|
||||||
#else
|
#else
|
||||||
@ -1062,4 +1065,5 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
|
|||||||
file_close( &tmp );
|
file_close( &tmp );
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion CSV
|
#pragma endregion CSV
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma region ADT
|
#pragma region ADT
|
||||||
|
|
||||||
enum ADT_Type : u32
|
enum ADT_Type : u32
|
||||||
{
|
{
|
||||||
EADT_TYPE_UNINITIALISED, /* node was not initialised, this is a programming error! */
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
|
||||||
|
|
||||||
#pragma endregion ADT
|
#pragma endregion ADT
|
||||||
|
|
||||||
#pragma region CSV
|
#pragma region CSV
|
||||||
|
|
||||||
enum CSV_Error : u32
|
enum CSV_Error : u32
|
||||||
{
|
{
|
||||||
ECSV_Error__NONE,
|
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, ',' );
|
return csv_write_string_delimiter( a, obj, ',' );
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion CSV
|
#pragma endregion CSV
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Printing
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
GEN_FMT_MINUS = bit( 0 ),
|
GEN_FMT_MINUS = bit( 0 ),
|
||||||
@ -558,3 +560,5 @@ sw str_fmt_out_err( char const* fmt, ... )
|
|||||||
va_end( va );
|
va_end( va );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion Printing
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Printing
|
||||||
|
|
||||||
struct FileInfo;
|
struct FileInfo;
|
||||||
|
|
||||||
#ifndef GEN_PRINTF_MAXLEN
|
#ifndef GEN_PRINTF_MAXLEN
|
||||||
@ -54,3 +56,5 @@ sw fatal(char const* fmt, ...)
|
|||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion Printing
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region String
|
||||||
|
|
||||||
String String::fmt( AllocatorInfo allocator, char* buf, sw buf_size, char const* fmt, ... )
|
String String::fmt( AllocatorInfo allocator, char* buf, sw buf_size, char const* fmt, ... )
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -33,3 +35,5 @@ bool String::append_fmt( char const* fmt, ... )
|
|||||||
|
|
||||||
return append( buf, res );
|
return append( buf, res );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion String
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region String
|
||||||
|
|
||||||
// Constant string with length.
|
// Constant string with length.
|
||||||
struct StrC
|
struct StrC
|
||||||
{
|
{
|
||||||
@ -219,7 +221,7 @@ struct String
|
|||||||
sw avail_space() const
|
sw avail_space() const
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
header = * rcast( Header const*, Data - sizeof( Header ));
|
header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
return header.Capacity - header.Length;
|
return header.Capacity - header.Length;
|
||||||
}
|
}
|
||||||
@ -227,7 +229,7 @@ struct String
|
|||||||
sw capacity() const
|
sw capacity() const
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
header = * rcast( Header const*, Data - sizeof( Header ));
|
header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
return header.Capacity;
|
return header.Capacity;
|
||||||
}
|
}
|
||||||
@ -260,7 +262,7 @@ struct String
|
|||||||
sw length() const
|
sw length() const
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
header = * rcast( Header const*, Data - sizeof( Header ));
|
header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
return header.Length;
|
return header.Length;
|
||||||
}
|
}
|
||||||
@ -303,7 +305,7 @@ struct String
|
|||||||
char* end()
|
char* end()
|
||||||
{
|
{
|
||||||
Header const&
|
Header const&
|
||||||
header = * rcast( Header const*, Data - sizeof( Header ));
|
header = * rcast( Header const*, Data - sizeof( Header ));
|
||||||
|
|
||||||
return Data + header.Length;
|
return Data + header.Length;
|
||||||
}
|
}
|
||||||
@ -370,3 +372,4 @@ struct String_POD
|
|||||||
};
|
};
|
||||||
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
|
static_assert( sizeof( String_POD ) == sizeof( String ), "String is not a POD" );
|
||||||
|
|
||||||
|
#pragma endregion String
|
@ -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;
|
const char* text_begin = text;
|
||||||
s64 result = 0;
|
s64 result = 0;
|
||||||
@ -202,3 +205,5 @@ f64 str_to_f64( const char* str, char** end_ptr )
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion String Ops
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region String Ops
|
||||||
|
|
||||||
GEN_DEF_INLINE const char* char_first_occurence( const char* str, char c );
|
GEN_DEF_INLINE const char* char_first_occurence( const char* str, char c );
|
||||||
constexpr auto str_find = &char_first_occurence;
|
constexpr auto str_find = &char_first_occurence;
|
||||||
|
|
||||||
@ -256,3 +258,5 @@ GEN_IMPL_INLINE void str_to_upper( char* str )
|
|||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion String Ops
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Timing
|
||||||
|
|
||||||
#ifdef GEN_BENCHMARK
|
#ifdef GEN_BENCHMARK
|
||||||
#if defined( GEN_COMPILER_MSVC ) && ! defined( __clang__ )
|
#if defined( GEN_COMPILER_MSVC ) && ! defined( __clang__ )
|
||||||
u64 read_cpu_time_stamp_counter( void )
|
u64 read_cpu_time_stamp_counter( void )
|
||||||
@ -156,3 +158,5 @@
|
|||||||
return ( f64 )( time_rel_ms() * 1e-3 );
|
return ( f64 )( time_rel_ms() * 1e-3 );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion Timing
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma region Timing
|
||||||
|
|
||||||
#ifdef GEN_BENCHMARK
|
#ifdef GEN_BENCHMARK
|
||||||
//! Return CPU timestamp.
|
//! Return CPU timestamp.
|
||||||
u64 read_cpu_time_stamp_counter( void );
|
u64 read_cpu_time_stamp_counter( void );
|
||||||
@ -8,3 +10,5 @@ f64 time_rel( void );
|
|||||||
//! Return relative time since the application start.
|
//! Return relative time since the application start.
|
||||||
u64 time_rel_ms( void );
|
u64 time_rel_ms( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion Timing
|
||||||
|
@ -46,6 +46,7 @@ int gen_main()
|
|||||||
Code string_ops = scan_file( "dependencies/gen.string_ops.hpp" );
|
Code string_ops = scan_file( "dependencies/gen.string_ops.hpp" );
|
||||||
Code printing = scan_file( "dependencies/gen.printing.hpp" );
|
Code printing = scan_file( "dependencies/gen.printing.hpp" );
|
||||||
Code containers = scan_file( "dependencies/gen.containers.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 string = scan_file( "dependencies/gen.string.hpp" );
|
||||||
Code file_handling = scan_file( "dependencies/gen.file_handling.hpp" );
|
Code file_handling = scan_file( "dependencies/gen.file_handling.hpp" );
|
||||||
Code parsing = scan_file( "dependencies/gen.parsing.hpp" );
|
Code parsing = scan_file( "dependencies/gen.parsing.hpp" );
|
||||||
@ -54,9 +55,8 @@ int gen_main()
|
|||||||
Builder
|
Builder
|
||||||
deps_header;
|
deps_header;
|
||||||
deps_header.open("gen/gen_dep.hpp");
|
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_fmt("#pragma once\n\n");
|
||||||
deps_header.print( push_ignores );
|
|
||||||
deps_header.print( header_start );
|
deps_header.print( header_start );
|
||||||
deps_header.print( nspace_macro );
|
deps_header.print( nspace_macro );
|
||||||
deps_header.print_fmt( "GEN_NS_BEGIN\n\n");
|
deps_header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
@ -67,12 +67,12 @@ int gen_main()
|
|||||||
deps_header.print( string_ops );
|
deps_header.print( string_ops );
|
||||||
deps_header.print( printing );
|
deps_header.print( printing );
|
||||||
deps_header.print( containers );
|
deps_header.print( containers );
|
||||||
|
deps_header.print( hashing );
|
||||||
deps_header.print( string );
|
deps_header.print( string );
|
||||||
deps_header.print( file_handling );
|
deps_header.print( file_handling );
|
||||||
deps_header.print( parsing );
|
deps_header.print( parsing );
|
||||||
deps_header.print( timing );
|
deps_header.print( timing );
|
||||||
deps_header.print_fmt( "GEN_NS_END\n\n");
|
deps_header.print_fmt( "GEN_NS_END\n\n");
|
||||||
deps_header.print( pop_ignores );
|
|
||||||
deps_header.write();
|
deps_header.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user