move rest of cfg-related stuff into frontend

This commit is contained in:
Ryan Fleury
2024-09-13 14:51:07 -07:00
parent 793ad8fe1e
commit 48ae9b6973
13 changed files with 309 additions and 315 deletions
-23
View File
@@ -1,29 +1,6 @@
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Config Sources
@table(string, name, load_cmd, write_cmd, apply_cmd)
D_CfgSrcTable:
{
{"user" User OpenUser WriteUserData ApplyUserData }
{"project" Project OpenProject WriteProjectData ApplyProjectData }
{"command_line" CommandLine Null Null Null }
{"transient" Transient Null Null Null }
}
@enum D_CfgSrc:
{
@expand(D_CfgSrcTable a) `$(a.name)`,
COUNT,
}
@data(String8) d_cfg_src_string_table:
{
@expand(D_CfgSrcTable a) `str8_lit_comp("$(a.string)")`,
}
////////////////////////////////
//~ rjf: Built-In Command Tables
+1 -115
View File
@@ -46,48 +46,6 @@ d_hash_from_string__case_insensitive(String8 string)
return d_hash_from_seed_string__case_insensitive(5381, string);
}
////////////////////////////////
//~ rjf: Handles
internal D_Handle
d_handle_zero(void)
{
D_Handle result = {0};
return result;
}
internal B32
d_handle_match(D_Handle a, D_Handle b)
{
return (a.u64[0] == b.u64[0] && a.u64[1] == b.u64[1]);
}
internal void
d_handle_list_push_node(D_HandleList *list, D_HandleNode *node)
{
DLLPushBack(list->first, list->last, node);
list->count += 1;
}
internal void
d_handle_list_push(Arena *arena, D_HandleList *list, D_Handle handle)
{
D_HandleNode *n = push_array(arena, D_HandleNode, 1);
n->handle = handle;
d_handle_list_push_node(list, n);
}
internal D_HandleList
d_handle_list_copy(Arena *arena, D_HandleList list)
{
D_HandleList result = {0};
for(D_HandleNode *n = list.first; n != 0; n = n->next)
{
d_handle_list_push(arena, &result, n->handle);
}
return result;
}
////////////////////////////////
//~ rjf: Breakpoints
@@ -180,78 +138,6 @@ d_possible_path_overrides_from_maps_path(Arena *arena, D_PathMapArray *path_maps
return result;
}
////////////////////////////////
//~ rjf: Config Type Functions
internal void
d_cfg_table_push_unparsed_string(Arena *arena, D_CfgTable *table, String8 string, D_CfgSrc source)
{
if(table->slot_count == 0)
{
table->slot_count = 64;
table->slots = push_array(arena, D_CfgSlot, table->slot_count);
}
MD_TokenizeResult tokenize = md_tokenize_from_text(arena, string);
MD_ParseResult parse = md_parse_from_text_tokens(arena, str8_lit(""), string, tokenize.tokens);
for(MD_EachNode(tln, parse.root->first)) if(tln->string.size != 0)
{
// rjf: map string -> hash*slot
String8 string = str8(tln->string.str, tln->string.size);
U64 hash = d_hash_from_string__case_insensitive(string);
U64 slot_idx = hash % table->slot_count;
D_CfgSlot *slot = &table->slots[slot_idx];
// rjf: find existing value for this string
D_CfgVal *val = 0;
for(D_CfgVal *v = slot->first; v != 0; v = v->hash_next)
{
if(str8_match(v->string, string, StringMatchFlag_CaseInsensitive))
{
val = v;
break;
}
}
// rjf: create new value if needed
if(val == 0)
{
val = push_array(arena, D_CfgVal, 1);
val->string = push_str8_copy(arena, string);
val->insertion_stamp = table->insertion_stamp_counter;
SLLStackPush_N(slot->first, val, hash_next);
SLLQueuePush_N(table->first_val, table->last_val, val, linear_next);
table->insertion_stamp_counter += 1;
}
// rjf: create new node within this value
D_CfgTree *tree = push_array(arena, D_CfgTree, 1);
SLLQueuePush_NZ(&d_nil_cfg_tree, val->first, val->last, tree, next);
tree->source = source;
tree->root = md_tree_copy(arena, tln);
}
}
internal D_CfgVal *
d_cfg_val_from_string(D_CfgTable *table, String8 string)
{
D_CfgVal *result = &d_nil_cfg_val;
if(table->slot_count != 0)
{
U64 hash = d_hash_from_string__case_insensitive(string);
U64 slot_idx = hash % table->slot_count;
D_CfgSlot *slot = &table->slots[slot_idx];
for(D_CfgVal *val = slot->first; val != 0; val = val->hash_next)
{
if(str8_match(val->string, string, StringMatchFlag_CaseInsensitive))
{
result = val;
break;
}
}
}
return result;
}
////////////////////////////////
//~ rjf: Debug Info Extraction Type Pure Functions
@@ -271,7 +157,7 @@ d_line_list_copy(Arena *arena, D_LineList *list)
}
////////////////////////////////
//~ rjf: Command Type Pure Functions
//~ rjf: Command Type Functions
//- rjf: command parameters
+1 -82
View File
@@ -98,31 +98,6 @@ struct D_EventList
U64 count;
};
////////////////////////////////
//~ rjf: Handles
typedef struct D_Handle D_Handle;
struct D_Handle
{
U64 u64[2];
};
typedef struct D_HandleNode D_HandleNode;
struct D_HandleNode
{
D_HandleNode *next;
D_HandleNode *prev;
D_Handle handle;
};
typedef struct D_HandleList D_HandleList;
struct D_HandleList
{
D_HandleNode *first;
D_HandleNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Line Info Types
@@ -175,44 +150,6 @@ D_RunKind;
#include "dbg_engine/generated/dbg_engine.meta.h"
////////////////////////////////
//~ rjf: Config Types
typedef struct D_CfgTree D_CfgTree;
struct D_CfgTree
{
D_CfgTree *next;
D_CfgSrc source;
MD_Node *root;
};
typedef struct D_CfgVal D_CfgVal;
struct D_CfgVal
{
D_CfgVal *hash_next;
D_CfgVal *linear_next;
D_CfgTree *first;
D_CfgTree *last;
U64 insertion_stamp;
String8 string;
};
typedef struct D_CfgSlot D_CfgSlot;
struct D_CfgSlot
{
D_CfgVal *first;
};
typedef struct D_CfgTable D_CfgTable;
struct D_CfgTable
{
U64 slot_count;
D_CfgSlot *slots;
U64 insertion_stamp_counter;
D_CfgVal *first_val;
D_CfgVal *last_val;
};
////////////////////////////////
//~ rjf: View Rules
@@ -471,9 +408,6 @@ struct D_State
//~ rjf: Globals
read_only global D_ViewRuleSpec d_nil_core_view_rule_spec = {0};
read_only global D_CfgTree d_nil_cfg_tree = {&d_nil_cfg_tree, D_CfgSrc_User, &md_nil_node};
read_only global D_CfgVal d_nil_cfg_val = {&d_nil_cfg_val, &d_nil_cfg_val, &d_nil_cfg_tree, &d_nil_cfg_tree};
global D_State *d_state = 0;
////////////////////////////////
@@ -484,15 +418,6 @@ internal U64 d_hash_from_string(String8 string);
internal U64 d_hash_from_seed_string__case_insensitive(U64 seed, String8 string);
internal U64 d_hash_from_string__case_insensitive(String8 string);
////////////////////////////////
//~ rjf: Handle Type Pure Functions
internal D_Handle d_handle_zero(void);
internal B32 d_handle_match(D_Handle a, D_Handle b);
internal void d_handle_list_push_node(D_HandleList *list, D_HandleNode *node);
internal void d_handle_list_push(Arena *arena, D_HandleList *list, D_Handle handle);
internal D_HandleList d_handle_list_copy(Arena *arena, D_HandleList list);
////////////////////////////////
//~ rjf: Breakpoints
@@ -503,19 +428,13 @@ internal D_BreakpointArray d_breakpoint_array_copy(Arena *arena, D_BreakpointArr
internal String8List d_possible_path_overrides_from_maps_path(Arena *arena, D_PathMapArray *path_maps, String8 file_path);
////////////////////////////////
//~ rjf: Config Type Pure Functions
internal void d_cfg_table_push_unparsed_string(Arena *arena, D_CfgTable *table, String8 string, D_CfgSrc source);
internal D_CfgVal *d_cfg_val_from_string(D_CfgTable *table, String8 string);
////////////////////////////////
//~ rjf: Debug Info Extraction Type Pure Functions
internal D_LineList d_line_list_copy(Arena *arena, D_LineList *list);
////////////////////////////////
//~ rjf: Command Type Pure Functions
//~ rjf: Command Type Functions
//- rjf: command parameters
internal D_CmdParams d_cmd_params_copy(Arena *arena, D_CmdParams *src);
@@ -4,14 +4,6 @@
//- GENERATED CODE
C_LINKAGE_BEGIN
String8 d_cfg_src_string_table[4] =
{
str8_lit_comp("user"),
str8_lit_comp("project"),
str8_lit_comp("command_line"),
str8_lit_comp("transient"),
};
D_ViewRuleSpecInfo d_core_view_rule_spec_info_table[21] =
{
{str8_lit_comp("default"), str8_lit_comp("Default"), str8_lit_comp(""), str8_lit_comp(""), (D_ViewRuleSpecInfoFlag_Inherited*0)|(D_ViewRuleSpecInfoFlag_Expandable*0)|(D_ViewRuleSpecInfoFlag_ExprResolution*0)|(D_ViewRuleSpecInfoFlag_VizBlockProd*1), },
@@ -6,15 +6,6 @@
#ifndef DBG_ENGINE_META_H
#define DBG_ENGINE_META_H
typedef enum D_CfgSrc
{
D_CfgSrc_User,
D_CfgSrc_Project,
D_CfgSrc_CommandLine,
D_CfgSrc_Transient,
D_CfgSrc_COUNT,
} D_CfgSrc;
typedef enum D_CmdKind
{
D_CmdKind_Null,
@@ -101,9 +92,4 @@ struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =
{&DEV_scratch_mouse_draw, str8_lit_comp("scratch_mouse_draw")},
{&DEV_updating_indicator, str8_lit_comp("updating_indicator")},
};
C_LINKAGE_BEGIN
extern String8 d_cfg_src_string_table[4];
C_LINKAGE_END
#endif // DBG_ENGINE_META_H