mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-13 07:52:22 -07:00
progress on sanity_tests.c, adding back md_str8_styllize
Eventually a heavy reduction of base & OS should be provided via libgen or done here to reduce the overall surface area of the library for the user. Base and os were dragged from raddbg and the original metadesk didn't need as many definitions.
This commit is contained in:
+2
-2
@@ -106,11 +106,11 @@ void temp_arena_end(MD_TempArena temp);
|
||||
|
||||
//- rjf: push helper macros
|
||||
|
||||
#ifndef md_push_array_
|
||||
#ifndef md_push_array
|
||||
#define md_push_array__no_zero_aligned(a, T, c, align) (T *)md_arena_push((a), sizeof(T) * (c), (align))
|
||||
#define md_push_array__aligned(a, T, c, align) (T *)md_memory_zero(md_push_array__no_zero_aligned(a, T, c, align), sizeof(T) * (c))
|
||||
#define md_push_array__no_zero(a, T, c) md_push_array__no_zero_aligned(a, T, c, md_max(8, md_align_of(T)))
|
||||
#define md_push_array_(a, T, c) md_push_array__aligned (a, T, c, md_max(8, md_align_of(T)))
|
||||
#define md_push_array(a, T, c) md_push_array__aligned (a, T, c, md_max(8, md_align_of(T)))
|
||||
#endif
|
||||
|
||||
// Inlines
|
||||
|
||||
@@ -85,7 +85,7 @@ md_force_inline MD_CmdLine md_cmd_line_from_string_list__arena(MD_Arena* are
|
||||
|
||||
inline MD_CmdLineOpt* md_cmd_line_opt_from_string(MD_CmdLine *cmd_line, MD_String8 name) { return md_cmd_line_opt_from_slot(md_cmd_line_slot_from_string(cmd_line, name), name); }
|
||||
inline MD_B32 md_cmd_line_has_flag (MD_CmdLine *cmd_line, MD_String8 name) { MD_CmdLineOpt *var = md_cmd_line_opt_from_string(cmd_line, name); return(var != 0); }
|
||||
inline MD_B32 md_cmd_line_has_argument (MD_CmdLine *cmd_line, MD_String8 name) { MD_CmdLineOpt *var = md_cmd_line_opt_from_string(cmd_line, name); return(var != 0 && var->value_strings.md_node_count > 0); }
|
||||
inline MD_B32 md_cmd_line_has_argument (MD_CmdLine *cmd_line, MD_String8 name) { MD_CmdLineOpt *var = md_cmd_line_opt_from_string(cmd_line, name); return(var != 0 && var->value_strings.node_count > 0); }
|
||||
|
||||
inline MD_String8List
|
||||
md_cmd_line_strings(MD_CmdLine *cmd_line, MD_String8 name) {
|
||||
|
||||
@@ -56,7 +56,7 @@ void
|
||||
md_log_scope_begin(void) {
|
||||
if (md_log_active != 0) {
|
||||
MD_U64 pos = md_arena_pos(md_log_active->arena);
|
||||
MD_LogScope* scope = md_push_array_(md_log_active->arena, MD_LogScope, 1);
|
||||
MD_LogScope* scope = md_push_array(md_log_active->arena, MD_LogScope, 1);
|
||||
scope->pos = pos;
|
||||
md_sll_stack_push(md_log_active->top_scope, scope);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ md_log_alloc(MD_AllocatorInfo ainfo, MD_U64 md_arena_block_size) {
|
||||
md_arena_block_size = MD_LOG_DEFAULT_ARENA_BLOCK_SIZE;
|
||||
}
|
||||
MD_Arena* arena = md_arena_alloc(.backing = ainfo, .block_size = md_arena_block_size);
|
||||
MD_Log* log = md_push_array_(arena, MD_Log, 1);
|
||||
MD_Log* log = md_push_array(arena, MD_Log, 1);
|
||||
log->arena = arena;
|
||||
return log;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef md_thousand
|
||||
#define thousand(n) ((n) * 1000)
|
||||
#define md_thousand(n) ((n) * 1000)
|
||||
#endif
|
||||
#ifndef md_million
|
||||
#define md_million(n) ((n) * 1000000)
|
||||
@@ -801,9 +801,9 @@ md_sll__queue_pop_nz(void* nil, void** f, void* f_next, void** l)
|
||||
|
||||
#ifndef md_zero_struct
|
||||
# if MD_LANG_CPP
|
||||
# define md_zero_struct {}
|
||||
# define md_zero_struct() {}
|
||||
# else
|
||||
# define md_zero_struct {0}
|
||||
# define md_zero_struct() {0}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -672,7 +672,7 @@ md_str8_path_list_resolve_dots_in_place(MD_String8List* path, MD_PathStyle style
|
||||
|
||||
eliminate_stack_top:
|
||||
{
|
||||
path->md_node_count -= 1;
|
||||
path->node_count -= 1;
|
||||
path->total_size -= stack->node->string.size;
|
||||
|
||||
md_sll_stack_pop(stack);
|
||||
@@ -1377,7 +1377,7 @@ md_fuzzy_match_find__ainfo(MD_AllocatorInfo ainfo, MD_String8 needle, MD_String8
|
||||
}
|
||||
if (find_pos < haystack.size) {
|
||||
MD_Rng1U64 range = md_r1u64(find_pos, find_pos+needle_n->string.size);
|
||||
MD_FuzzyMatchRangeNode* n = md_push_array_(scratch.arena, MD_FuzzyMatchRangeNode, 1);
|
||||
MD_FuzzyMatchRangeNode* n = md_push_array(scratch.arena, MD_FuzzyMatchRangeNode, 1);
|
||||
n->range = range;
|
||||
md_sll_queue_push(result.first, result.last, n);
|
||||
result.count += 1;
|
||||
|
||||
@@ -616,7 +616,7 @@ void md_str8_list_concat_in_place (MD_String8List* list, MD
|
||||
inline MD_String8Node*
|
||||
md_str8_list_push_node(MD_String8List* list, MD_String8Node* node) {
|
||||
md_sll_queue_push(list->first, list->last, node);
|
||||
list->md_node_count += 1;
|
||||
list->node_count += 1;
|
||||
list->total_size += node->string.size;
|
||||
return(node);
|
||||
}
|
||||
@@ -624,7 +624,7 @@ md_str8_list_push_node(MD_String8List* list, MD_String8Node* node) {
|
||||
inline MD_String8Node*
|
||||
md_str8_list_push_node_set_string(MD_String8List* list, MD_String8Node* node, MD_String8 string) {
|
||||
md_sll_queue_push(list->first, list->last, node);
|
||||
list->md_node_count += 1;
|
||||
list->node_count += 1;
|
||||
list->total_size += string.size;
|
||||
node->string = string;
|
||||
return(node);
|
||||
@@ -633,7 +633,7 @@ md_str8_list_push_node_set_string(MD_String8List* list, MD_String8Node* node, MD
|
||||
inline MD_String8Node*
|
||||
md_str8_list_push_node_front(MD_String8List* list, MD_String8Node* node) {
|
||||
md_sll_queue_push_front(list->first, list->last, node);
|
||||
list->md_node_count += 1;
|
||||
list->node_count += 1;
|
||||
list->total_size += node->string.size;
|
||||
return(node);
|
||||
}
|
||||
@@ -641,7 +641,7 @@ md_str8_list_push_node_front(MD_String8List* list, MD_String8Node* node) {
|
||||
inline MD_String8Node*
|
||||
md_str8_list_push_node_front_set_string(MD_String8List* list, MD_String8Node* node, MD_String8 string) {
|
||||
md_sll_queue_push_front(list->first, list->last, node);
|
||||
list->md_node_count += 1;
|
||||
list->node_count += 1;
|
||||
list->total_size += string.size;
|
||||
node->string = string;
|
||||
return(node);
|
||||
@@ -791,7 +791,7 @@ md_str8_list_from_flags__ainfo(MD_AllocatorInfo ainfo, MD_String8List* list, MD_
|
||||
inline MD_String8Array
|
||||
md_str8_array_from_list__ainfo(MD_AllocatorInfo ainfo, MD_String8List* list) {
|
||||
MD_String8Array array;
|
||||
array.count = list->md_node_count;
|
||||
array.count = list->node_count;
|
||||
array.v = md_alloc_array_no_zero(ainfo, MD_String8, array.count);
|
||||
MD_U64 idx = 0;
|
||||
for(MD_String8Node *n = list->first; n != 0; n = n->next, idx += 1) {
|
||||
@@ -1124,7 +1124,7 @@ MD_API MD_FuzzyMatchRangeList md_fuzzy_match_range_list_copy__ainfo(MD_Allocator
|
||||
#define md_fuzzy_match_range_list_copy(allocator, src) _Generic(allocator, MD_Arena*: md_fuzzy_match_range_list_copy__arena, MD_AllocatorInfo: md_fuzzy_match_range_list_copy__ainfo) md_generic_call(allocator, src)
|
||||
|
||||
md_force_inline MD_FuzzyMatchRangeList md_fuzzy_match_find__arena (MD_Arena *arena, MD_String8 needle, MD_String8 haystack) { return md_fuzzy_match_find__ainfo (md_arena_allocator(arena), needle, haystack); }
|
||||
md_force_inline MD_FuzzyMatchRangeList md_fuzzy_match_range_list_copy__arena(MD_Arena* arena, MD_FuzzyMatchRangeList* src) s{ return md_fuzzy_match_range_list_copy__ainfo(md_arena_allocator(arena), src); }
|
||||
md_force_inline MD_FuzzyMatchRangeList md_fuzzy_match_range_list_copy__arena(MD_Arena* arena, MD_FuzzyMatchRangeList* src) { return md_fuzzy_match_range_list_copy__ainfo(md_arena_allocator(arena), src); }
|
||||
|
||||
////////////////////////////////
|
||||
//~ NOTE(allen): Serialization Helpers
|
||||
@@ -1221,7 +1221,7 @@ md_str8_serial_begin__ainfo(MD_AllocatorInfo ainfo, MD_String8List* srl) {
|
||||
MD_String8Node* node = md_alloc_array(ainfo, MD_String8Node, 1);
|
||||
node->string.str = md_alloc_array_no_zero(ainfo, MD_U8, 0);
|
||||
srl->first = srl->last = node;
|
||||
srl->md_node_count = 1;
|
||||
srl->node_count = 1;
|
||||
srl->total_size = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user