Update readme, fix an issue with stb_image.refactor script (needed newline at eof), some script changes.

This commit is contained in:
2023-03-31 16:17:02 -04:00
parent 6e91555a20
commit 6bc4346652
8 changed files with 101 additions and 53 deletions

View File

@ -30,11 +30,11 @@ The program execution is pretty much outlined quite clearly in `int main()`.
There are constraints for specific variables;
* `Path_Size_Largest` : Longest path size is set to 1 KB of characters.
* `Token_Max_Length` : Set to 1 KB characters as well.
* `Token_Max_Length` : Set to 128 KB.
* `Array_Reserve_Num` : Is set to 4 KB.
* Initial Global arena size : Set to 2 megabytes.
The `Path_Size_Largest` and `Token_Max_Length` are compile-time constraints that the runtime will not have a fallback for, if 1 KB is not enough it will need to be changed for your use case.
The `Path_Size_Largest` and `Token_Max_Length` are compile-time constraints that the runtime will not have a fallback for, if current size is not enough it will need to be changed for your use case.
`Array_Reserve_Num` is used to dictate the assumed amount of tokens will be held in total for any of spec's arrays holding ignores and refactor entries. If any of the array's exceed 4 KB they will grow triggering a resize which will bog down the speed of the refactor. Adjust if you think you can increase or lower for use case.

View File

@ -7,7 +7,7 @@
namespace Spec
{
ct uw Array_Reserve_Num = zpl_kilobytes(4);
ct uw Token_Max_Length = zpl_kilobytes(1);
ct uw Token_Max_Length = 128;
namespace StaticData
{

View File

@ -162,6 +162,11 @@ void parse_options( int num, char** arguments )
}
/*
Refactor will problably have the execution and arg parsing (main and opts)
moved to a separate file.
*/
zpl_arena Refactor_Buffer;
void refactor()
@ -211,21 +216,32 @@ void refactor()
#define pos (IO::Current_Size - left)
#define move_forward( Amount_ ) \
if ( left - Amount_ <= 0 ) \
goto End_Search; \
\
left -= Amount_; \
col += Amount_; \
src += Amount_ \
struct Snapshot
{
char const* Src;
sw Left;
uw Col;
uw Line;
};
#define move_back( Amount_ ) \
left += Amount_; \
col -= Amount_; \
src -= Amount_ \
#define move_forward( Amount_ ) \
if ( left - Amount_ <= 0 ) \
goto End_Search; \
\
line += src[0] == '\n'; \
left -= Amount_; \
col = (col + Amount_) * src[0] != '\n'; \
src += Amount_ \
#define restore( Snapshot_ ) \
src = Snapshot_.Src; \
left = Snapshot_.Left; \
col = Snapshot_.Col; \
line = Snapshot_.Line \
do
{
// Check for comments if ignoring.
if ( Spec::Ignore_Comments && src[0] == '/' && left - 2 > 0 )
{
if ( src[1] == '/' )
@ -259,37 +275,33 @@ void refactor()
{
Spec::Entry* ignore = Spec::Ignore_Includes;
sw ignores_left = zpl_array_count( Spec::Ignore_Includes);
sw rewind = 0;
Snapshot backup = { src, left, col, line };
if ( '#' != src[0] )
break;
move_forward( 1 );
rewind++;
// Ignore whitespace
while ( zpl_char_is_space( src[0] ) )
{
move_forward( 1 );
rewind++;
}
if ( zpl_strncmp( include_sig, src, sizeof(include_sig) - 1 ) != 0 )
{
move_back( rewind );
restore( backup );
break;
}
const u32 sig_size = sizeof(include_sig) - 1;
move_forward( sig_size );
rewind += sig_size;
// Ignore whitespace
while ( zpl_char_is_space( src[0] ) || src[0] == '\"' || src[0] == '<' )
{
move_forward(1);
rewind++;
}
for ( ; ignores_left; ignores_left--, ignore++ )
@ -318,7 +330,7 @@ void refactor()
}
}
move_back( rewind );
restore( backup );
}
while (false);
@ -402,37 +414,33 @@ void refactor()
{
Spec::Entry* include = Spec::Includes;
sw includes_left = zpl_array_count ( Spec::Includes);
sw rewind = 0;
Snapshot backup = { src, left, col, line };
if ( '#' != src[0] )
break;
move_forward( 1 );
rewind++;
// Ignore whitespace
while ( zpl_char_is_space( src[0] ) )
{
move_forward( 1 );
rewind++;
}
if ( zpl_strncmp( include_sig, src, sizeof(include_sig) - 1 ) != 0 )
{
move_back( rewind );
restore( backup );
break;
}
const u32 sig_size = sizeof(include_sig) - 1;
move_forward( sig_size );
rewind += sig_size;
// Ignore whitespace
while ( zpl_char_is_space( src[0] ) || src[0] == '\"' || src[0] == '<' )
{
move_forward( 1 );
rewind++;
}
for ( ; includes_left; includes_left--, include++ )
@ -473,7 +481,7 @@ void refactor()
}
}
move_back( rewind );
restore( backup );
}
while (false);