This commit is contained in:
Edward R. Gonzalez 2025-05-12 00:55:55 -04:00
parent 3094a51872
commit 81a3465fc4

View File

@ -172,7 +172,7 @@ It will return a result in a composite struct: FileOpResult; which may be expand
typedef struct FileOpResult FileOpResult; typedef struct FileOpResult FileOpResult;
typedef struct Opts__read_file_contents Opts__read_file_contents; typedef struct Opts__read_file_contents Opts__read_file_contents;
void api_file_read_contents(FileOpResult* result, Str8 path, Opts__read_file_contents* opts); void file_read_contents_api(FileOpResult* result, Str8 path, Opts__read_file_contents* opts);
FileOpResult file__read_contents ( Str8 path, Opts__read_file_contents* opts); FileOpResult file__read_contents ( Str8 path, Opts__read_file_contents* opts);
#define file_read_contents(path, ...) file__read_contents(path, & (Opts__read_file_contents){__VA_ARGS__} ) #define file_read_contents(path, ...) file__read_contents(path, & (Opts__read_file_contents){__VA_ARGS__} )
@ -256,7 +256,7 @@ typedef U8 FMem_64KB [ KILOBTYES(64) ];
#define fmem_slice(mem) (SliceByte) { mem, size_of(mem) } #define fmem_slice(mem) (SliceByte) { mem, size_of(mem) }
// We'll be using an intrinsic for copying memory: // We'll be using an intrinsic for copying memory:
void* memory_copy(void* dest, void const* src, USIZE length) void* memory_copy(void* restrict dest, void const* restrict src, USIZE length)
{ {
if (dest == nullptr || src == nullptr || length == 0) { if (dest == nullptr || src == nullptr || length == 0) {
return nullptr; return nullptr;
@ -323,7 +323,7 @@ struct Opts__read_file_contents
B32 zero_backing; B32 zero_backing;
}; };
void api_file_read_contents(FileOpResult* result, Str8 path, Opts__read_file_contents* opts) void file_read_contents_api(FileOpResult* result, Str8 path, Opts__read_file_contents* opts)
{ {
assert(result != nullptr); assert(result != nullptr);
assert(opts != nullptr); assert(opts != nullptr);
@ -399,7 +399,7 @@ void api_file_read_contents(FileOpResult* result, Str8 path, Opts__read_file_con
inline inline
FileOpResult file__read_contents(Str8 path, Opts__read_file_contents* opts) { FileOpResult file__read_contents(Str8 path, Opts__read_file_contents* opts) {
FileOpResult result; FileOpResult result;
api_file_read_contents(& result, path, opts); file_read_contents_api(& result, path, opts);
return result; return result;
} }
@ -430,7 +430,7 @@ returning a WATL_LexInfo for providing user info on how the operation went.
typedef struct WATL_LexInfo WATL_LexInfo; typedef struct WATL_LexInfo WATL_LexInfo;
typedef struct Opts__watl_lex Opts__watl_lex; typedef struct Opts__watl_lex Opts__watl_lex;
void api_watl_lex(WATL_LexInfo* info, Str8 source, Opts__watl_lex* opts); void watl_lex_api(WATL_LexInfo* info, Str8 source, Opts__watl_lex* opts);
WATL_LexInfo watl__lex ( Str8 source, Opts__watl_lex* opts); WATL_LexInfo watl__lex ( Str8 source, Opts__watl_lex* opts);
#define watl_lex(source, ...) watl__lex(source, &(Opts__watl_lex){__VA_ARGS__}) #define watl_lex(source, ...) watl__lex(source, &(Opts__watl_lex){__VA_ARGS__})
@ -552,7 +552,7 @@ struct Opts__watl_lex {
}; };
// We are assuming everything is utf8-ascii. // We are assuming everything is utf8-ascii.
void api_watl_lex(WATL_LexInfo* info, Str8 source, Opts__watl_lex* opts) void watl_lex_api(WATL_LexInfo* info, Str8 source, Opts__watl_lex* opts)
{ {
assert(info != nullptr); assert(info != nullptr);
slice_assert(source); slice_assert(source);
@ -623,7 +623,7 @@ void api_watl_lex(WATL_LexInfo* info, Str8 source, Opts__watl_lex* opts)
inline inline
WATL_LexInfo watl__lex(Str8 source, Opts__watl_lex* opts) { WATL_LexInfo watl__lex(Str8 source, Opts__watl_lex* opts) {
WATL_LexInfo result = {0}; WATL_LexInfo result = {0};
api_watl_lex(& result, source, opts); watl_lex_api(& result, source, opts);
return result; return result;
} }
@ -673,7 +673,7 @@ Next we'll parse these tokens into a rudimentary WATL Abstract Syntax Tree.
typedef struct WATL_ParseInfo WATL_ParseInfo; typedef struct WATL_ParseInfo WATL_ParseInfo;
typedef struct Opts__watl_parse Opts__watl_parse; typedef struct Opts__watl_parse Opts__watl_parse;
void api_watl_parse(WATL_ParseInfo* info, WATL_SliceTok tokens, Opts__watl_parse* opts); void watl_parse_api(WATL_ParseInfo* info, WATL_SliceTok tokens, Opts__watl_parse* opts);
WATL_ParseInfo watl__parse ( WATL_SliceTok tokens, Opts__watl_parse* opts); WATL_ParseInfo watl__parse ( WATL_SliceTok tokens, Opts__watl_parse* opts);
#define watl_parse(tokens, ...) watl__parse(tokens, & (Opts__watl_parse) {__VA_ARGS__}) #define watl_parse(tokens, ...) watl__parse(tokens, & (Opts__watl_parse) {__VA_ARGS__})
@ -682,7 +682,7 @@ For the sake of the exercise, we'll be eliminating the association with the file
*/ */
#pragma region Str8Cache #pragma region Str8Cache
typedef struct Str8Cache Str8Cache; typedef struct Str8Cache Str8Cache;
void api_str8cache_init(Str8Cache* cache, SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table); void str8cache_init_api(Str8Cache* cache, SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table);
Str8Cache str8cache_init ( SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table); Str8Cache str8cache_init ( SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table);
// A cache like this relies on tabling string entires utiliszing an index derived from a hashed ID. // A cache like this relies on tabling string entires utiliszing an index derived from a hashed ID.
@ -728,9 +728,9 @@ struct Str8Cache {
Str8Cache_SliceSlot table; Str8Cache_SliceSlot table;
}; };
Str8Cache str8cache_init(SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table) { Str8Cache cache; api_str8cache_init(& cache, mem_strs, mem_slots, mem_table); return cache; } Str8Cache str8cache_init(SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table) { Str8Cache cache; str8cache_init_api(& cache, mem_strs, mem_slots, mem_table); return cache; }
inline inline
void api_str8cache_init(Str8Cache* cache, SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table) { void str8cache_init_api(Str8Cache* cache, SliceByte mem_strs, SliceByte mem_slots, SliceByte mem_table) {
assert(cache != nullptr); assert(cache != nullptr);
slice_assert(mem_strs); slice_assert(mem_strs);
slice_assert(mem_slots); slice_assert(mem_slots);
@ -881,7 +881,7 @@ struct WATL_ParseInfo {
WATL_SliceLine lines; WATL_SliceLine lines;
}; };
void api_watl_parse(WATL_ParseInfo* info, WATL_SliceTok tokens, Opts__watl_parse* opts) void watl_parse_api(WATL_ParseInfo* info, WATL_SliceTok tokens, Opts__watl_parse* opts)
{ {
assert(info != nullptr); assert(info != nullptr);
slice_assert(tokens); slice_assert(tokens);
@ -926,7 +926,7 @@ void api_watl_parse(WATL_ParseInfo* info, WATL_SliceTok tokens, Opts__watl_parse
#endif DEMO__WATL_PARSE_V1 #endif DEMO__WATL_PARSE_V1
WATL_ParseInfo watl__parse(WATL_SliceTok tokens, Opts__watl_parse* opts) { WATL_ParseInfo info; api_watl_parse(& info, tokens, opts); return info; } WATL_ParseInfo watl__parse(WATL_SliceTok tokens, Opts__watl_parse* opts) { WATL_ParseInfo info; watl_parse_api(& info, tokens, opts); return info; }
#ifdef DEMO__WATL_PARSE_V1 #ifdef DEMO__WATL_PARSE_V1
int main() int main()
@ -966,7 +966,7 @@ We'll be utilizing a new construct called a string generator which be tied to al
typedef struct Str8Gen Str8Gen; typedef struct Str8Gen Str8Gen;
struct Str8Gen { struct Str8Gen {
SliceByte backing; // For V1 the backing buffer is fixed size. SliceByte backing; // For V1 the backing buffer is fixed size.
char* ptr; UTF8* ptr;
SSIZE len; SSIZE len;
}; };
@ -1021,12 +1021,12 @@ Str8 fmt_vtoken_slice(SliceByte buffer, SliceFmtTokEntry tokens, Str8 fmt_templa
slice_assert(tokens); slice_assert(tokens);
slice_assert(fmt_template); slice_assert(fmt_template);
char* cursor_buffer = buffer.ptr; UTF8* cursor_buffer = buffer.ptr;
SSIZE buffer_remaining = buffer.len; SSIZE buffer_remaining = buffer.len;
char curr_code = * fmt_template.ptr; char curr_code = * fmt_template.ptr;
char const* cursor_fmt = fmt_template.ptr; UTF8* cursor_fmt = fmt_template.ptr;
SSIZE left_fmt = fmt_template.len; SSIZE left_fmt = fmt_template.len;
while (left_fmt && buffer_remaining) while (left_fmt && buffer_remaining)
{ {
@ -1044,7 +1044,7 @@ Str8 fmt_vtoken_slice(SliceByte buffer, SliceFmtTokEntry tokens, Str8 fmt_templa
if (curr_code == '<') if (curr_code == '<')
{ {
char const* cursor_potential_token = cursor_fmt + 1; UTF8* cursor_potential_token = cursor_fmt + 1;
SSIZE potential_token_length = 0; SSIZE potential_token_length = 0;
while (* (cursor_potential_token + potential_token_length) != '>') { while (* (cursor_potential_token + potential_token_length) != '>') {