From 0c497abba67f5606a1f992a741ec702284a6e976 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Sun, 14 Jan 2024 06:40:41 -0800 Subject: [PATCH] only supply config defaults when doing user config application --- src/df/gfx/df_gfx.c | 9 +++++--- src/raddbg/raddbg.h | 2 +- src/scratch/ryan_scratch.c | 43 ++++++++++++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index a7ad144f..e701cfb7 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -11534,7 +11534,10 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) } //- rjf: apply keybindings - df_clear_bindings(); + if(src == DF_CfgSrc_User) + { + df_clear_bindings(); + } DF_CfgVal *keybindings = df_cfg_val_from_string(table, str8_lit("keybindings")); for(DF_CfgNode *keybinding_set = keybindings->first; keybinding_set != &df_g_nil_cfg_node; @@ -11649,7 +11652,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) } //- rjf: if config opened 0 windows, we need to do some sensible default - if(windows->first == &df_g_nil_cfg_node) + if(src == DF_CfgSrc_User && windows->first == &df_g_nil_cfg_node) { OS_Handle preferred_monitor = os_primary_monitor(); Vec2F32 monitor_dim = os_dim_from_monitor(preferred_monitor); @@ -11660,7 +11663,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) } //- rjf: if config bound 0 keys, we need to do some sensible default - if(df_gfx_state->key_map_total_count == 0) + if(src == DF_CfgSrc_User && df_gfx_state->key_map_total_count == 0) { for(U64 idx = 0; idx < ArrayCount(df_g_default_binding_table); idx += 1) { diff --git a/src/raddbg/raddbg.h b/src/raddbg/raddbg.h index b3878621..88de5606 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -422,7 +422,7 @@ #define RADDBG_VERSION_MAJOR 0 #define RADDBG_VERSION_MINOR 9 -#define RADDBG_VERSION_PATCH 1 +#define RADDBG_VERSION_PATCH 3 #define RADDBG_VERSION_STRING_LITERAL Stringify(RADDBG_VERSION_MAJOR) "." Stringify(RADDBG_VERSION_MINOR) "." Stringify(RADDBG_VERSION_PATCH) #if defined(NDEBUG) # define RADDBG_TITLE_STRING_LITERAL "The RAD Debugger (" RADDBG_VERSION_STRING_LITERAL " ALPHA) - " __DATE__ "" diff --git a/src/scratch/ryan_scratch.c b/src/scratch/ryan_scratch.c index b5a71af8..142e4219 100644 --- a/src/scratch/ryan_scratch.c +++ b/src/scratch/ryan_scratch.c @@ -1,14 +1,49 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) -#include +// build with: +// cl /Zi /nologo look_at_raddbg.c + +#include +#include +#include "raddbg_format/raddbg_format.h" +#include "raddbg_format/raddbg_format_parse.h" +#include "raddbg_format/raddbg_format.c" +#include "raddbg_format/raddbg_format_parse.c" + +typedef struct Foo Foo; +struct Foo +{ + int x; + int y; + int z; +}; int main(int argument_count, char **arguments) { - int *arr = malloc(sizeof(int)*1000); - for(int i = 0; i < 1001; i += 1) + Foo foo = {123, 456, 789}; + HANDLE file = CreateFileA(arguments[1], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + DWORD size_hi32 = 0; + DWORD size_lo32 = GetFileSize(file, &size_hi32); + HANDLE map = CreateFileMappingA(file, 0, PAGE_READONLY, 0, 0, 0); + uint64_t data_size = (size_lo32 | ((uint64_t)size_hi32 << 32)); + uint8_t *data = (uint8_t *)MapViewOfFile(map, FILE_MAP_READ, 0, 0, data_size); + RADDBG_Parsed rdbg = {0}; + RADDBG_ParseStatus parse_status = raddbg_parse(data, data_size, &rdbg); + uint64_t foo_count = 0; + for(uint64_t idx = 0; idx < rdbg.type_node_count; idx += 1) { - arr[i] = i; + RADDBG_TypeNode *type_node = &rdbg.type_nodes[idx]; + if(RADDBG_TypeKind_FirstUserDefined <= type_node->kind && type_node->kind <= RADDBG_TypeKind_LastUserDefined) + { + uint64_t name_size = 0; + uint8_t *name = raddbg_string_from_idx(&rdbg, type_node->user_defined.name_string_idx, &name_size); + if(name_size == 3 && name[0] == 'f' && name[1] == 'o' && name[2] == 'o') + { + foo_count += 1; + } + } } + printf("%s -> %I64u foos\n", arguments[1], foo_count); return 0; }