update gencpp to latest

This commit is contained in:
Edward R. Gonzalez 2024-10-27 21:44:34 -04:00
parent 208cc67a7f
commit feea8361b5
10 changed files with 11166 additions and 11269 deletions

View File

@ -1,3 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppCodeStyle/OverridingFunctionStyle/@EntryValue">Override</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/DotNetCliExePath/@EntryValue">C:\projects\Unreal\Surgo\UE\Engine\Binaries\ThirdParty\DotNet\8.0.300\win-x64\dotnet.exe</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1114112</s:Int64>
<s:Boolean x:Key="/Default/Environment/Hierarchy/Build/BuildTool/RecentDotNetCliExePaths/=C_003A_005Cprojects_005CUnreal_005CSurgo_005CUE_005CEngine_005CBinaries_005CThirdParty_005CDotNet_005C8_002E0_002E300_005Cwin_002Dx64_005Cdotnet_002Eexe/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gasa/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -28,8 +28,8 @@ public class GasaEditor : ModuleRules
PrivateDependencyModuleNames.Add("Gasa");
bWarningsAsErrors = false;
ShadowVariableWarningLevel = UnrealBuildTool.WarningLevel.Warning;
UndefinedIdentifierWarningLevel = UnrealBuildTool.WarningLevel.Warning;
ShadowVariableWarningLevel = UnrealBuildTool.WarningLevel.Off;
UndefinedIdentifierWarningLevel = UnrealBuildTool.WarningLevel.Off;
// gencpp related defines
PublicDefinitions.Add("Build_Debug=1");

View File

@ -1,22 +1,22 @@
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#pragma clang diagnostic ignored "-Wswitch"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wvarargs"
#pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-const-variable"
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wcomment"
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunused-variable"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
# pragma GCC diagnostic ignored "-Wcomment"
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include "gen.builder.hpp"
@ -27,10 +27,10 @@ Builder Builder::open( char const* path )
{
Builder result;
FileError error = file_open_mode( &result.File, EFileMode_WRITE, path );
FileError error = file_open_mode( & result.File, EFileMode_WRITE, path );
if ( error != EFileError_NONE )
{
log_failure( "gen::File::open - Could not open file: %s", path );
log_failure( "gen::File::open - Could not open file: %s", path);
return result;
}
@ -47,16 +47,16 @@ void Builder::pad_lines( s32 num )
void Builder::print( Code code )
{
String str = code->to_string();
// const sw len = str.length();
String str = code->to_string();
// const ssize len = str.length();
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
Buffer.append( str );
}
void Builder::print_fmt( char const* fmt, ... )
{
sw res;
char buf[GEN_PRINTF_MAXLEN] = { 0 };
ssize res;
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
va_list va;
va_start( va, fmt );
@ -69,22 +69,22 @@ void Builder::print_fmt( char const* fmt, ... )
void Builder::write()
{
b32 result = file_write( &File, Buffer, Buffer.length() );
b32 result = file_write( & File, Buffer, Buffer.length() );
if ( result == false )
log_failure( "gen::File::write - Failed to write to file: %s\n", file_name( &File ) );
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & File ) );
log_fmt( "Generated: %s\n", File.filename );
file_close( &File );
file_close( & File );
Buffer.free();
}
GEN_NS_END
#ifdef __clang__
#pragma clang diagnostic pop
# pragma clang diagnostic pop
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#endif

View File

@ -1,22 +1,22 @@
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#pragma clang diagnostic ignored "-Wswitch"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wvarargs"
#pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-const-variable"
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wcomment"
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunused-variable"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
# pragma GCC diagnostic ignored "-Wcomment"
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#pragma once
@ -43,9 +43,9 @@ struct Builder
GEN_NS_END
#ifdef __clang__
#pragma clang diagnostic pop
# pragma clang diagnostic pop
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
// This file was generated automatially by gencpp's unreal.cpp (See: https://github.com/Ed94/gencpp)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#pragma clang diagnostic ignored "-Wswitch"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wvarargs"
#pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-const-variable"
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wcomment"
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunused-variable"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
# pragma GCC diagnostic ignored "-Wcomment"
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include "gen.scanner.hpp"
@ -57,7 +57,7 @@ u8 adt_destroy_branch( ADT_Node* node )
GEN_ASSERT_NOT_NULL( node );
if ( ( node->type == EADT_TYPE_OBJECT || node->type == EADT_TYPE_ARRAY ) && node->nodes )
{
for ( sw i = 0; i < scast( sw, node->nodes.num() ); ++i )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); ++i )
{
adt_destroy_branch( node->nodes + i );
}
@ -87,9 +87,9 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
return NULL;
}
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); i++ )
{
if ( ! str_compare( node->nodes[i].name, name ) )
if ( ! str_compare( node->nodes[ i ].name, name ) )
{
return ( node->nodes + i );
}
@ -97,7 +97,7 @@ ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search )
if ( deep_search )
{
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); i++ )
{
ADT_Node* res = adt_find( node->nodes + i, name, deep_search );
@ -115,35 +115,35 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
{
case EADT_TYPE_MULTISTRING :
case EADT_TYPE_STRING :
{
if ( node->string && ! str_compare( node->string, value ) )
{
return node;
if ( node->string && ! str_compare( node->string, value ) )
{
return node;
}
}
}
break;
break;
case EADT_TYPE_INTEGER :
case EADT_TYPE_REAL :
{
char back[4096] = { 0 };
FileInfo tmp;
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
file_stream_open( &tmp, heap(), (u8*)back, size_of( back ), EFileStream_WRITABLE );
adt_print_number( &tmp, node );
sw fsize = 0;
u8* buf = file_stream_buf( &tmp, &fsize );
if ( ! str_compare( (char const*)buf, value ) )
{
file_close( &tmp );
return node;
}
char back[ 4096 ] = { 0 };
FileInfo tmp;
file_close( &tmp );
}
break;
/* allocate a file descriptor for a memory-mapped number to string conversion, input source buffer is not cloned, however. */
file_stream_open( &tmp, heap(), ( u8* )back, size_of( back ), EFileStream_WRITABLE );
adt_print_number( &tmp, node );
ssize fsize = 0;
u8* buf = file_stream_buf( &tmp, &fsize );
if ( ! str_compare( ( char const* )buf, value ) )
{
file_close( &tmp );
return node;
}
file_close( &tmp );
}
break;
default :
break; /* node doesn't support value based lookup */
}
@ -153,11 +153,11 @@ internal ADT_Node* _adt_get_value( ADT_Node* node, char const* value )
internal ADT_Node* _adt_get_field( ADT_Node* node, char* name, char* value )
{
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); i++ )
{
if ( ! str_compare( node->nodes[i].name, name ) )
if ( ! str_compare( node->nodes[ i ].name, name ) )
{
ADT_Node* child = &node->nodes[i];
ADT_Node* child = &node->nodes[ i ];
if ( _adt_get_value( child, value ) )
{
return node; /* this object does contain a field of a specified value! */
@ -191,19 +191,19 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
str_fmt_out( "uri: %s\n", uri );
#endif
char * p = (char*)uri, *b = p, *e = p;
char * p = ( char* )uri, *b = p, *e = p;
ADT_Node* found_node = NULL;
b = p;
p = e = (char*)str_skip( p, '/' );
char* buf = str_fmt_buf( "%.*s", (int)( e - b ), b );
b = p;
p = e = ( char* )str_skip( p, '/' );
char* buf = str_fmt_buf( "%.*s", ( int )( e - b ), b );
/* handle field value lookup */
if ( *b == '[' )
{
char *l_p = buf + 1, *l_b = l_p, *l_e = l_p, *l_b2 = l_p, *l_e2 = l_p;
l_e = (char*)str_skip( l_p, '=' );
l_e2 = (char*)str_skip( l_p, ']' );
l_e = ( char* )str_skip( l_p, '=' );
l_e2 = ( char* )str_skip( l_p, ']' );
if ( ( ! *l_e && node->type != EADT_TYPE_ARRAY ) || ! *l_e2 )
{
@ -228,9 +228,9 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
/* run a value comparison against any child that is an object node */
else if ( node->type == EADT_TYPE_ARRAY )
{
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); i++ )
{
ADT_Node* child = &node->nodes[i];
ADT_Node* child = &node->nodes[ i ];
if ( child->type != EADT_TYPE_OBJECT )
{
continue;
@ -246,9 +246,9 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
/* [value] */
else
{
for ( sw i = 0; i < scast( sw, node->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, node->nodes.num()); i++ )
{
ADT_Node* child = &node->nodes[i];
ADT_Node* child = &node->nodes[ i ];
if ( _adt_get_value( child, l_b2 ) )
{
found_node = child;
@ -277,10 +277,10 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
/* handle array index lookup */
else
{
sw idx = (sw)str_to_i64( buf, NULL, 10 );
if ( idx >= 0 && idx < scast( sw, node->nodes.num() ) )
ssize idx = ( ssize )str_to_i64( buf, NULL, 10 );
if ( idx >= 0 && idx < scast(ssize, node->nodes.num()) )
{
found_node = &node->nodes[idx];
found_node = &node->nodes[ idx ];
/* go deeper if uri continues */
if ( *e )
@ -293,7 +293,7 @@ ADT_Node* adt_query( ADT_Node* node, char const* uri )
return found_node;
}
ADT_Node* adt_alloc_at( ADT_Node* parent, sw index )
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index )
{
if ( ! parent || ( parent->type != EADT_TYPE_OBJECT && parent->type != EADT_TYPE_ARRAY ) )
{
@ -303,7 +303,7 @@ ADT_Node* adt_alloc_at( ADT_Node* parent, sw index )
if ( ! parent->nodes )
return NULL;
if ( index < 0 || index > scast( sw, parent->nodes.num() ) )
if ( index < 0 || index > scast(ssize, parent->nodes.num()) )
return NULL;
ADT_Node o = { 0 };
@ -358,7 +358,7 @@ b8 adt_set_int( ADT_Node* obj, char const* name, s64 value )
return true;
}
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, sw index )
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index )
{
GEN_ASSERT_NOT_NULL( node );
GEN_ASSERT_NOT_NULL( new_parent );
@ -385,15 +385,15 @@ void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node )
{
GEN_ASSERT_NOT_NULL( node );
GEN_ASSERT_NOT_NULL( other_node );
ADT_Node* parent = node->parent;
ADT_Node* other_parent = other_node->parent;
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
sw index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
ADT_Node temp = parent->nodes[index];
temp.parent = other_parent;
other_parent->nodes[index2].parent = parent;
parent->nodes[index] = other_parent->nodes[index2];
other_parent->nodes[index2] = temp;
ADT_Node* parent = node->parent;
ADT_Node* other_parent = other_node->parent;
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
ssize index2 = ( pointer_diff( other_parent->nodes, other_node ) / size_of( ADT_Node ) );
ADT_Node temp = parent->nodes[ index ];
temp.parent = other_parent;
other_parent->nodes[ index2 ].parent = parent;
parent->nodes[ index ] = other_parent->nodes[ index2 ];
other_parent->nodes[ index2 ] = temp;
}
void adt_remove_node( ADT_Node* node )
@ -401,7 +401,7 @@ void adt_remove_node( ADT_Node* node )
GEN_ASSERT_NOT_NULL( node );
GEN_ASSERT_NOT_NULL( node->parent );
ADT_Node* parent = node->parent;
sw index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
ssize index = ( pointer_diff( parent->nodes, node ) / size_of( ADT_Node ) );
parent->nodes.remove_at( index );
}
@ -487,14 +487,14 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
GEN_ASSERT_NOT_NULL( base_str );
char *p = base_str, *e = p;
s32 base = 0;
s32 base2 = 0;
u8 base2_offset = 0;
s8 exp = 0, orig_exp = 0;
u8 neg_zero = 0;
u8 lead_digit = 0;
ADT_Type node_type = EADT_TYPE_UNINITIALISED;
u8 node_props = 0;
s32 base = 0;
s32 base2 = 0;
u8 base2_offset = 0;
s8 exp = 0, orig_exp = 0;
u8 neg_zero = 0;
u8 lead_digit = 0;
ADT_Type node_type = EADT_TYPE_UNINITIALISED;
u8 node_props = 0;
/* skip false positives and special cases */
if ( ! ! str_find( "eE", *p ) || ( ! ! str_find( ".+-", *p ) && ! char_is_hex_digit( *( p + 1 ) ) && *( p + 1 ) != '.' ) )
@ -502,28 +502,28 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
return ++base_str;
}
node_type = EADT_TYPE_INTEGER;
neg_zero = false;
node_type = EADT_TYPE_INTEGER;
neg_zero = false;
sw ib = 0;
char buf[48] = { 0 };
ssize ib = 0;
char buf[ 48 ] = { 0 };
if ( *e == '+' )
++e;
else if ( *e == '-' )
{
buf[ib++] = *e++;
buf[ ib++ ] = *e++;
}
if ( *e == '.' )
{
node_type = EADT_TYPE_REAL;
node_props = EADT_PROPS_IS_PARSED_REAL;
lead_digit = false;
buf[ib++] = '0';
node_type = EADT_TYPE_REAL;
node_props = EADT_PROPS_IS_PARSED_REAL;
lead_digit = false;
buf[ ib++ ] = '0';
do
{
buf[ib++] = *e;
buf[ ib++ ] = *e;
} while ( char_is_digit( *++e ) );
}
else
@ -541,7 +541,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
while ( char_is_hex_digit( *e ) || char_to_lower( *e ) == 'x' )
{
buf[ib++] = *e++;
buf[ ib++ ] = *e++;
}
if ( *e == '.' )
@ -552,13 +552,13 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
do
{
buf[ib++] = *e;
buf[ ib++ ] = *e;
++step;
} while ( char_is_digit( *++e ) );
if ( step < 2 )
{
buf[ib++] = '0';
buf[ ib++ ] = '0';
}
}
}
@ -569,9 +569,9 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
return ++base_str;
}
f32 eb = 10;
char expbuf[6] = { 0 };
sw expi = 0;
f32 eb = 10;
char expbuf[ 6 ] = { 0 };
ssize expi = 0;
if ( *e && ! ! str_find( "eE", *e ) )
{
@ -588,11 +588,11 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
}
while ( char_is_digit( *e ) )
{
expbuf[expi++] = *e++;
expbuf[ expi++ ] = *e++;
}
}
orig_exp = exp = (u8)str_to_i64( expbuf, NULL, 10 );
orig_exp = exp = ( u8 )str_to_i64( expbuf, NULL, 10 );
}
if ( node_type == EADT_TYPE_INTEGER )
@ -600,14 +600,14 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
node->integer = str_to_i64( buf, 0, 0 );
#ifndef GEN_PARSER_DISABLE_ANALYSIS
/* special case: negative zero */
if ( node->integer == 0 && buf[0] == '-' )
if ( node->integer == 0 && buf[ 0 ] == '-' )
{
neg_zero = true;
}
#endif
while ( orig_exp-- > 0 )
{
node->integer *= (s64)eb;
node->integer *= ( s64 )eb;
}
}
else
@ -616,15 +616,15 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
#ifndef GEN_PARSER_DISABLE_ANALYSIS
char *q = buf, *base_string = q, *base_string2 = q;
base_string = zpl_cast( char* ) str_skip( base_string, '.' );
base_string = ccast( char*, str_skip( base_string, '.' ));
*base_string = '\0';
base_string2 = base_string + 1;
char* base_string_off = base_string2;
while ( *base_string_off++ == '0' )
base2_offset++;
base = (s32)str_to_i64( q, 0, 0 );
base2 = (s32)str_to_i64( base_string2, 0, 0 );
base = ( s32 )str_to_i64( q, 0, 0 );
base2 = ( s32 )str_to_i64( base_string2, 0, 0 );
if ( exp )
{
exp = exp * ( ! ( eb == 10.0f ) ? -1 : 1 );
@ -632,7 +632,7 @@ char* adt_parse_number( ADT_Node* node, char* base_str )
}
/* special case: negative zero */
if ( base == 0 && buf[0] == '-' )
if ( base == 0 && buf[ 0 ] == '-' )
{
neg_zero = true;
}
@ -683,67 +683,67 @@ ADT_Error adt_print_number( FileInfo* file, ADT_Node* node )
switch ( node->type )
{
case EADT_TYPE_INTEGER :
{
if ( node->props == EADT_PROPS_IS_HEX )
{
_adt_fprintf( file, "0x%llx", (long long)node->integer );
if ( node->props == EADT_PROPS_IS_HEX )
{
_adt_fprintf( file, "0x%llx", ( long long )node->integer );
}
else
{
_adt_fprintf( file, "%lld", ( long long )node->integer );
}
}
else
{
_adt_fprintf( file, "%lld", (long long)node->integer );
}
}
break;
break;
case EADT_TYPE_REAL :
{
if ( node->props == EADT_PROPS_NAN )
{
_adt_fprintf( file, "NaN" );
}
else if ( node->props == EADT_PROPS_NAN_NEG )
{
_adt_fprintf( file, "-NaN" );
}
else if ( node->props == EADT_PROPS_INFINITY )
{
_adt_fprintf( file, "Infinity" );
}
else if ( node->props == EADT_PROPS_INFINITY_NEG )
{
_adt_fprintf( file, "-Infinity" );
}
else if ( node->props == EADT_PROPS_TRUE )
{
_adt_fprintf( file, "true" );
}
else if ( node->props == EADT_PROPS_FALSE )
{
_adt_fprintf( file, "false" );
}
else if ( node->props == EADT_PROPS_NULL )
{
_adt_fprintf( file, "null" );
if ( node->props == EADT_PROPS_NAN )
{
_adt_fprintf( file, "NaN" );
}
else if ( node->props == EADT_PROPS_NAN_NEG )
{
_adt_fprintf( file, "-NaN" );
}
else if ( node->props == EADT_PROPS_INFINITY )
{
_adt_fprintf( file, "Infinity" );
}
else if ( node->props == EADT_PROPS_INFINITY_NEG )
{
_adt_fprintf( file, "-Infinity" );
}
else if ( node->props == EADT_PROPS_TRUE )
{
_adt_fprintf( file, "true" );
}
else if ( node->props == EADT_PROPS_FALSE )
{
_adt_fprintf( file, "false" );
}
else if ( node->props == EADT_PROPS_NULL )
{
_adt_fprintf( file, "null" );
#ifndef GEN_PARSER_DISABLE_ANALYSIS
}
else if ( node->props == EADT_PROPS_IS_EXP )
{
_adt_fprintf( file, "%lld.%0*d%llde%lld", (long long)node->base, node->base2_offset, 0, (long long)node->base2, (long long)node->exp );
}
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
{
if ( ! node->lead_digit )
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, (long long)node->base2 );
else
_adt_fprintf( file, "%lld.%0*d%lld", (long long int)node->base2_offset, 0, (int)node->base, (long long)node->base2 );
}
else if ( node->props == EADT_PROPS_IS_EXP )
{
_adt_fprintf( file, "%lld.%0*d%llde%lld", ( long long )node->base, node->base2_offset, 0, ( long long )node->base2, ( long long )node->exp );
}
else if ( node->props == EADT_PROPS_IS_PARSED_REAL )
{
if ( ! node->lead_digit )
_adt_fprintf( file, ".%0*d%lld", node->base2_offset, 0, ( long long )node->base2 );
else
_adt_fprintf( file, "%lld.%0*d%lld", ( long long int )node->base2_offset, 0, ( int )node->base, ( long long )node->base2 );
#endif
}
else
{
_adt_fprintf( file, "%f", node->real );
}
}
else
{
_adt_fprintf( file, "%f", node->real );
}
}
break;
break;
}
return EADT_ERROR_NONE;
@ -791,7 +791,7 @@ ADT_Error adt_str_to_number( ADT_Node* node )
return EADT_ERROR_INVALID_TYPE;
}
adt_parse_number( node, (char*)node->string );
adt_parse_number( node, ( char* )node->string );
return EADT_ERROR_NONE;
}
@ -807,7 +807,7 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
return EADT_ERROR_INVALID_TYPE;
}
adt_parse_number_strict( node, (char*)node->string );
adt_parse_number_strict( node, ( char* )node->string );
return EADT_ERROR_NONE;
}
@ -819,9 +819,9 @@ ADT_Error adt_str_to_number_strict( ADT_Node* node )
#pragma region CSV
#ifdef GEN_CSV_DEBUG
#define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
# define GEN_CSV_ASSERT( msg ) GEN_PANIC( msg )
#else
#define GEN_CSV_ASSERT( msg )
# define GEN_CSV_ASSERT( msg )
#endif
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim )
@ -837,13 +837,13 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
char* beginChar;
char* endChar;
sw columnIndex = 0;
sw totalColumnIndex = 0;
ssize columnIndex = 0;
ssize totalColumnIndex = 0;
do
{
char delimiter = 0;
currentChar = zpl_cast( char* ) str_trim( currentChar, false );
currentChar = ccast( char*, str_trim( currentChar, false ));
if ( *currentChar == 0 )
break;
@ -851,23 +851,23 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
ADT_Node rowItem = { 0 };
rowItem.type = EADT_TYPE_STRING;
#ifndef GEN_PARSER_DISABLE_ANALYSIS
#ifndef GEN_PARSER_DISABLE_ANALYSIS
rowItem.name_style = EADT_NAME_STYLE_NO_QUOTES;
#endif
#endif
/* handle string literals */
if ( *currentChar == '"' )
{
currentChar += 1;
beginChar = currentChar;
endChar = currentChar;
rowItem.string = beginChar;
#ifndef GEN_PARSER_DISABLE_ANALYSIS
currentChar += 1;
beginChar = currentChar;
endChar = currentChar;
rowItem.string = beginChar;
#ifndef GEN_PARSER_DISABLE_ANALYSIS
rowItem.name_style = EADT_NAME_STYLE_DOUBLE_QUOTE;
#endif
#endif
do
{
endChar = zpl_cast( char* ) str_skip( endChar, '"' );
endChar = ccast( char*, str_skip( endChar, '"' ));
if ( *endChar && *( endChar + 1 ) == '"' )
{
@ -875,7 +875,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
}
else
break;
} while ( *endChar );
}
while ( *endChar );
if ( *endChar == 0 )
{
@ -885,8 +886,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
}
*endChar = 0;
currentChar = zpl_cast( char* ) str_trim( endChar + 1, true );
delimiter = *currentChar;
currentChar = ccast( char*, str_trim( endChar + 1, true ));
delimiter = * currentChar;
/* unescape escaped quotes (so that unescaped text escapes :) */
{
@ -898,12 +899,13 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
mem_move( escapedChar, escapedChar + 1, str_len( escapedChar ) );
}
escapedChar++;
} while ( *escapedChar );
}
while ( *escapedChar );
}
}
else if ( *currentChar == delim )
{
delimiter = *currentChar;
delimiter = * currentChar;
rowItem.string = "";
}
else if ( *currentChar )
@ -916,19 +918,20 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
do
{
endChar++;
} while ( *endChar && *endChar != delim && *endChar != '\n' );
}
while ( * endChar && * endChar != delim && * endChar != '\n' );
if ( *endChar )
if ( * endChar )
{
currentChar = zpl_cast( char* ) str_trim( endChar, true );
currentChar = ccast( char*, str_trim( endChar, true ));
while ( char_is_space( *( endChar - 1 ) ) )
{
endChar--;
}
delimiter = *currentChar;
*endChar = 0;
delimiter = * currentChar;
* endChar = 0;
}
else
{
@ -941,35 +944,35 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
char* num_p = beginChar;
// We only consider hexadecimal values if they start with 0x
if ( str_len( num_p ) > 2 && num_p[0] == '0' && ( num_p[1] == 'x' || num_p[1] == 'X' ) )
if ( str_len(num_p) > 2 && num_p[0] == '0' && (num_p[1] == 'x' || num_p[1] == 'X') )
{
num_p += 2; // skip '0x' prefix
num_p += 2; // skip '0x' prefix
do
{
if ( ! char_is_hex_digit( *num_p ) )
if (!char_is_hex_digit(*num_p))
{
skip_number = true;
break;
}
} while ( *num_p++ );
} while (*num_p++);
}
else
{
skip_number = true;
}
if ( ! skip_number )
if (!skip_number)
{
adt_str_to_number( &rowItem );
adt_str_to_number(&rowItem);
}
}
if ( columnIndex >= scast( sw, root->nodes.num() ) )
if ( columnIndex >= scast(ssize, root->nodes.num()) )
{
adt_append_arr( root, NULL );
}
root->nodes[columnIndex].nodes.append( rowItem );
root->nodes[ columnIndex ].nodes.append( rowItem );
if ( delimiter == delim )
{
@ -994,7 +997,8 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
if ( delimiter != 0 )
currentChar++;
}
} while ( *currentChar );
}
while ( *currentChar );
if ( root->nodes.num() == 0 )
{
@ -1006,7 +1010,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
/* consider first row as a header. */
if ( has_header )
{
for ( sw i = 0; i < scast( sw, root->nodes.num() ); i++ )
for ( ssize i = 0; i < scast(ssize, root->nodes.num()); i++ )
{
CSV_Object* col = root->nodes + i;
CSV_Object* hdr = col->nodes;
@ -1028,36 +1032,36 @@ void _csv_write_record( FileInfo* file, CSV_Object* node )
switch ( node->type )
{
case EADT_TYPE_STRING :
{
#ifndef GEN_PARSER_DISABLE_ANALYSIS
switch ( node->name_style )
{
case EADT_NAME_STYLE_DOUBLE_QUOTE :
{
str_fmt_file( file, "\"" );
adt_print_string( file, node, "\"", "\"" );
str_fmt_file( file, "\"" );
}
break;
case EADT_NAME_STYLE_NO_QUOTES :
{
#endif
str_fmt_file( file, "%s", node->string );
#ifndef GEN_PARSER_DISABLE_ANALYSIS
}
break;
}
switch ( node->name_style )
{
case EADT_NAME_STYLE_DOUBLE_QUOTE :
{
str_fmt_file( file, "\"" );
adt_print_string( file, node, "\"", "\"" );
str_fmt_file( file, "\"" );
}
break;
case EADT_NAME_STYLE_NO_QUOTES :
{
#endif
}
break;
str_fmt_file( file, "%s", node->string );
#ifndef GEN_PARSER_DISABLE_ANALYSIS
}
break;
}
#endif
}
break;
case EADT_TYPE_REAL :
case EADT_TYPE_INTEGER :
{
adt_print_number( file, node );
}
break;
{
adt_print_number( file, node );
}
break;
}
}
@ -1074,21 +1078,21 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
GEN_ASSERT_NOT_NULL( file );
GEN_ASSERT_NOT_NULL( obj );
GEN_ASSERT( obj->nodes );
sw cols = obj->nodes.num();
ssize cols = obj->nodes.num();
if ( cols == 0 )
return;
sw rows = obj->nodes[0].nodes.num();
ssize rows = obj->nodes[ 0 ].nodes.num();
if ( rows == 0 )
return;
b32 has_headers = obj->nodes[0].name != NULL;
b32 has_headers = obj->nodes[ 0 ].name != NULL;
if ( has_headers )
{
for ( sw i = 0; i < cols; i++ )
for ( ssize i = 0; i < cols; i++ )
{
_csv_write_header( file, &obj->nodes[i] );
_csv_write_header( file, &obj->nodes[ i ] );
if ( i + 1 != cols )
{
str_fmt_file( file, "%c", delimiter );
@ -1097,11 +1101,11 @@ void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delimiter )
str_fmt_file( file, "\n" );
}
for ( sw r = 0; r < rows; r++ )
for ( ssize r = 0; r < rows; r++ )
{
for ( sw i = 0; i < cols; i++ )
for ( ssize i = 0; i < cols; i++ )
{
_csv_write_record( file, &obj->nodes[i].nodes[r] );
_csv_write_record( file, &obj->nodes[ i ].nodes[ r ] );
if ( i + 1 != cols )
{
str_fmt_file( file, "%c", delimiter );
@ -1116,9 +1120,10 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
FileInfo tmp;
file_stream_new( &tmp, a );
csv_write_delimiter( &tmp, obj, delimiter );
sw fsize;
ssize fsize;
u8* buf = file_stream_buf( &tmp, &fsize );
String output = String::make_length( a, (char*)buf, fsize );
String output = String::make_length( a, ( char* )buf, fsize );
file_close( &tmp );
return output;
}
@ -1128,9 +1133,9 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi
GEN_NS_END
#ifdef __clang__
#pragma clang diagnostic pop
# pragma clang diagnostic pop
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#endif

View File

@ -3,22 +3,22 @@
#pragma once
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
#pragma clang diagnostic ignored "-Wswitch"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wvarargs"
#pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-const-variable"
# pragma clang diagnostic ignored "-Wunused-but-set-variable"
# pragma clang diagnostic ignored "-Wswitch"
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wcomment"
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunused-variable"
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
# pragma GCC diagnostic ignored "-Wcomment"
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include "gen.hpp"
@ -92,7 +92,7 @@ struct ADT_Node
/* properties */
ADT_Type type : 4;
u8 props : 4;
u8 props : 4;
#ifndef GEN_PARSER_DISABLE_ANALYSIS
u8 cfg_mode : 1;
u8 name_style : 2;
@ -130,283 +130,283 @@ struct ADT_Node
};
/* ADT NODE LIMITS
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
* real number limits decimal position to 128 places.
* real number exponent is limited to 64 digits.
*/
* delimiter and assignment segment width is limited to 128 whitespace symbols each.
* real number limits decimal position to 128 places.
* real number exponent is limited to 64 digits.
*/
/**
* @brief Initialise an ADT object or array
*
* @param node
* @param backing Memory allocator used for descendants
* @param name Node's name
* @param is_array
* @return error code
*/
* @brief Initialise an ADT object or array
*
* @param node
* @param backing Memory allocator used for descendants
* @param name Node's name
* @param is_array
* @return error code
*/
u8 adt_make_branch( ADT_Node* node, AllocatorInfo backing, char const* name, b32 is_array );
/**
* @brief Destroy an ADT branch and its descendants
*
* @param node
* @return error code
*/
* @brief Destroy an ADT branch and its descendants
*
* @param node
* @return error code
*/
u8 adt_destroy_branch( ADT_Node* node );
/**
* @brief Initialise an ADT leaf
*
* @param node
* @param name Node's name
* @param type Node's type (use zpl_adt_make_branch for container nodes)
* @return error code
*/
* @brief Initialise an ADT leaf
*
* @param node
* @param name Node's name
* @param type Node's type (use zpl_adt_make_branch for container nodes)
* @return error code
*/
u8 adt_make_leaf( ADT_Node* node, char const* name, ADT_Type type );
/**
* @brief Fetch a node using provided URI string.
*
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
* to retrieve the data:
*
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
* - "arr/3" retrieves the 4th element in "arr"
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
*
* @param node ADT node
* @param uri Locator string as described above
* @return zpl_adt_node*
*
* @see code/apps/examples/json_get.c
*/
* @brief Fetch a node using provided URI string.
*
* This method uses a basic syntax to fetch a node from the ADT. The following features are available
* to retrieve the data:
*
* - "a/b/c" navigates through objects "a" and "b" to get to "c"
* - "arr/[foo=123]/bar" iterates over "arr" to find any object with param "foo" that matches the value "123", then gets its field called "bar"
* - "arr/3" retrieves the 4th element in "arr"
* - "arr/[apple]" retrieves the first element of value "apple" in "arr"
*
* @param node ADT node
* @param uri Locator string as described above
* @return zpl_adt_node*
*
* @see code/apps/examples/json_get.c
*/
ADT_Node* adt_query( ADT_Node* node, char const* uri );
/**
* @brief Find a field node within an object by the given name.
*
* @param node
* @param name
* @param deep_search Perform search recursively
* @return zpl_adt_node * node
*/
* @brief Find a field node within an object by the given name.
*
* @param node
* @param name
* @param deep_search Perform search recursively
* @return zpl_adt_node * node
*/
ADT_Node* adt_find( ADT_Node* node, char const* name, b32 deep_search );
/**
* @brief Allocate an unitialised node within a container at a specified index.
*
* @param parent
* @param index
* @return zpl_adt_node * node
*/
ADT_Node* adt_alloc_at( ADT_Node* parent, sw index );
* @brief Allocate an unitialised node within a container at a specified index.
*
* @param parent
* @param index
* @return zpl_adt_node * node
*/
ADT_Node* adt_alloc_at( ADT_Node* parent, ssize index );
/**
* @brief Allocate an unitialised node within a container.
*
* @param parent
* @return zpl_adt_node * node
*/
* @brief Allocate an unitialised node within a container.
*
* @param parent
* @return zpl_adt_node * node
*/
ADT_Node* adt_alloc( ADT_Node* parent );
/**
* @brief Move an existing node to a new container at a specified index.
*
* @param node
* @param new_parent
* @param index
* @return zpl_adt_node * node
*/
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, sw index );
* @brief Move an existing node to a new container at a specified index.
*
* @param node
* @param new_parent
* @param index
* @return zpl_adt_node * node
*/
ADT_Node* adt_move_node_at( ADT_Node* node, ADT_Node* new_parent, ssize index );
/**
* @brief Move an existing node to a new container.
*
* @param node
* @param new_parent
* @return zpl_adt_node * node
*/
* @brief Move an existing node to a new container.
*
* @param node
* @param new_parent
* @return zpl_adt_node * node
*/
ADT_Node* adt_move_node( ADT_Node* node, ADT_Node* new_parent );
/**
* @brief Swap two nodes.
*
* @param node
* @param other_node
* @return
*/
* @brief Swap two nodes.
*
* @param node
* @param other_node
* @return
*/
void adt_swap_nodes( ADT_Node* node, ADT_Node* other_node );
/**
* @brief Remove node from container.
*
* @param node
* @return
*/
* @brief Remove node from container.
*
* @param node
* @return
*/
void adt_remove_node( ADT_Node* node );
/**
* @brief Initialise a node as an object
*
* @param obj
* @param name
* @param backing
* @return
*/
* @brief Initialise a node as an object
*
* @param obj
* @param name
* @param backing
* @return
*/
b8 adt_set_obj( ADT_Node* obj, char const* name, AllocatorInfo backing );
/**
* @brief Initialise a node as an array
*
* @param obj
* @param name
* @param backing
* @return
*/
* @brief Initialise a node as an array
*
* @param obj
* @param name
* @param backing
* @return
*/
b8 adt_set_arr( ADT_Node* obj, char const* name, AllocatorInfo backing );
/**
* @brief Initialise a node as a string
*
* @param obj
* @param name
* @param value
* @return
*/
* @brief Initialise a node as a string
*
* @param obj
* @param name
* @param value
* @return
*/
b8 adt_set_str( ADT_Node* obj, char const* name, char const* value );
/**
* @brief Initialise a node as a float
*
* @param obj
* @param name
* @param value
* @return
*/
* @brief Initialise a node as a float
*
* @param obj
* @param name
* @param value
* @return
*/
b8 adt_set_flt( ADT_Node* obj, char const* name, f64 value );
/**
* @brief Initialise a node as a signed integer
*
* @param obj
* @param name
* @param value
* @return
*/
* @brief Initialise a node as a signed integer
*
* @param obj
* @param name
* @param value
* @return
*/
b8 adt_set_int( ADT_Node* obj, char const* name, s64 value );
/**
* @brief Append a new node to a container as an object
*
* @param parent
* @param name
* @return*
*/
* @brief Append a new node to a container as an object
*
* @param parent
* @param name
* @return*
*/
ADT_Node* adt_append_obj( ADT_Node* parent, char const* name );
/**
* @brief Append a new node to a container as an array
*
* @param parent
* @param name
* @return*
*/
* @brief Append a new node to a container as an array
*
* @param parent
* @param name
* @return*
*/
ADT_Node* adt_append_arr( ADT_Node* parent, char const* name );
/**
* @brief Append a new node to a container as a string
*
* @param parent
* @param name
* @param value
* @return*
*/
* @brief Append a new node to a container as a string
*
* @param parent
* @param name
* @param value
* @return*
*/
ADT_Node* adt_append_str( ADT_Node* parent, char const* name, char const* value );
/**
* @brief Append a new node to a container as a float
*
* @param parent
* @param name
* @param value
* @return*
*/
* @brief Append a new node to a container as a float
*
* @param parent
* @param name
* @param value
* @return*
*/
ADT_Node* adt_append_flt( ADT_Node* parent, char const* name, f64 value );
/**
* @brief Append a new node to a container as a signed integer
*
* @param parent
* @param name
* @param value
* @return*
*/
* @brief Append a new node to a container as a signed integer
*
* @param parent
* @param name
* @param value
* @return*
*/
ADT_Node* adt_append_int( ADT_Node* parent, char const* name, s64 value );
/* parser helpers */
/**
* @brief Parses a text and stores the result into an unitialised node.
*
* @param node
* @param base
* @return*
*/
* @brief Parses a text and stores the result into an unitialised node.
*
* @param node
* @param base
* @return*
*/
char* adt_parse_number( ADT_Node* node, char* base );
/**
* @brief Parses a text and stores the result into an unitialised node.
* This function expects the entire input to be a number.
*
* @param node
* @param base
* @return*
*/
* @brief Parses a text and stores the result into an unitialised node.
* This function expects the entire input to be a number.
*
* @param node
* @param base
* @return*
*/
char* adt_parse_number_strict( ADT_Node* node, char* base_str );
/**
* @brief Parses and converts an existing string node into a number.
*
* @param node
* @return
*/
* @brief Parses and converts an existing string node into a number.
*
* @param node
* @return
*/
ADT_Error adt_str_to_number( ADT_Node* node );
/**
* @brief Parses and converts an existing string node into a number.
* This function expects the entire input to be a number.
*
* @param node
* @return
*/
* @brief Parses and converts an existing string node into a number.
* This function expects the entire input to be a number.
*
* @param node
* @return
*/
ADT_Error adt_str_to_number_strict( ADT_Node* node );
/**
* @brief Prints a number into a file stream.
*
* The provided file handle can also be a memory mapped stream.
*
* @see zpl_file_stream_new
* @param file
* @param node
* @return
*/
* @brief Prints a number into a file stream.
*
* The provided file handle can also be a memory mapped stream.
*
* @see zpl_file_stream_new
* @param file
* @param node
* @return
*/
ADT_Error adt_print_number( FileInfo* file, ADT_Node* node );
/**
* @brief Prints a string into a file stream.
*
* The provided file handle can also be a memory mapped stream.
*
* @see zpl_file_stream_new
* @param file
* @param node
* @param escaped_chars
* @param escape_symbol
* @return
*/
* @brief Prints a string into a file stream.
*
* The provided file handle can also be a memory mapped stream.
*
* @see zpl_file_stream_new
* @param file
* @param node
* @param escaped_chars
* @param escape_symbol
* @return
*/
ADT_Error adt_print_string( FileInfo* file, ADT_Node* node, char const* escaped_chars, char const* escape_symbol );
#pragma endregion ADT
@ -423,28 +423,31 @@ enum CSV_Error : u32
typedef ADT_Node CSV_Object;
GEN_DEF_INLINE u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
void csv_free( CSV_Object* obj );
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header );
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim );
void csv_free( CSV_Object* obj );
GEN_DEF_INLINE void csv_write( FileInfo* file, CSV_Object* obj );
GEN_DEF_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj );
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
void csv_write( FileInfo* file, CSV_Object* obj );
String csv_write_string( AllocatorInfo a, CSV_Object* obj );
void csv_write_delimiter( FileInfo* file, CSV_Object* obj, char delim );
String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delim );
/* inline */
GEN_IMPL_INLINE u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
inline
u8 csv_parse( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header )
{
return csv_parse_delimiter( root, text, allocator, has_header, ',' );
}
GEN_IMPL_INLINE void csv_write( FileInfo* file, CSV_Object* obj )
inline
void csv_write( FileInfo* file, CSV_Object* obj )
{
csv_write_delimiter( file, obj, ',' );
}
GEN_IMPL_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj )
inline
String csv_write_string( AllocatorInfo a, CSV_Object* obj )
{
return csv_write_string_delimiter( a, obj, ',' );
}
@ -454,41 +457,37 @@ GEN_IMPL_INLINE String csv_write_string( AllocatorInfo a, CSV_Object* obj )
// This is a simple file reader that reads the entire file into memory.
// It has an extra option to skip the first few lines for undesired includes.
// This is done so that includes can be kept in dependency and component files so that intellisense works.
inline Code scan_file( char const* path )
inline
Code scan_file( char const* path )
{
FileInfo file;
FileError error = file_open_mode( &file, EFileMode_READ, path );
FileError error = file_open_mode( & file, EFileMode_READ, path );
if ( error != EFileError_NONE )
{
GEN_FATAL( "scan_file: Could not open: %s", path );
}
sw fsize = file_size( &file );
ssize fsize = file_size( & file );
if ( fsize <= 0 )
{
GEN_FATAL( "scan_file: %s is empty", path );
GEN_FATAL("scan_file: %s is empty", path );
}
String str = String::make_reserve( GlobalAllocator, fsize );
file_read( &file, str, fsize );
str.get_header().Length = fsize;
file_read( & file, str, fsize );
str.get_header().Length = fsize;
// Skip GEN_INTELLISENSE_DIRECTIVES preprocessor blocks
// Its designed so that the directive should be the first thing in the file.
// Anything that comes before it will also be omitted.
{
#define current ( *scanner )
#define matched 0
#define move_fwd() \
do \
{ \
++scanner; \
--left; \
} while ( 0 )
const StrC directive_start = txt( "ifdef" );
const StrC directive_end = txt( "endif" );
const StrC def_intellisense = txt( "GEN_INTELLISENSE_DIRECTIVES" );
#define current (*scanner)
#define matched 0
#define move_fwd() do { ++ scanner; -- left; } while (0)
const StrC directive_start = txt( "ifdef" );
const StrC directive_end = txt( "endif" );
const StrC def_intellisense = txt("GEN_INTELLISENSE_DIRECTIVES" );
bool found_directive = false;
char const* scanner = str.Data;
@ -514,10 +513,10 @@ inline Code scan_file( char const* path )
if ( left && str_compare( scanner, def_intellisense.Ptr, def_intellisense.Len ) == matched )
{
scanner += def_intellisense.Len;
left -= def_intellisense.Len;
scanner += def_intellisense.Len;
left -= def_intellisense.Len;
found_directive = true;
found_directive = true;
}
}
@ -546,7 +545,7 @@ inline Code scan_file( char const* path )
move_fwd();
// sptr skip_size = fsize - left;
if ( ( scanner + 2 ) >= ( str.Data + fsize ) )
if ( (scanner + 2) >= ( str.Data + fsize ) )
{
mem_move( str, scanner, left );
str.get_header().Length = left;
@ -558,16 +557,17 @@ inline Code scan_file( char const* path )
break;
}
}
move_fwd();
}
#undef move_fwd
#undef matched
#undef current
#undef move_fwd
#undef matched
#undef current
}
file_close( &file );
file_close( & file );
return untyped_str( str );
}
@ -612,9 +612,9 @@ CodeFile scan_file( char const* path )
GEN_NS_END
#ifdef __clang__
#pragma clang diagnostic pop
# pragma clang diagnostic pop
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#endif