From 818c5a916074e074ebc778174f9ff01dd230ccd7 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 28 Aug 2024 15:34:46 -0700 Subject: [PATCH] eliminate dependence on 'command parameter slots' --- src/dbg_engine/dbg_engine.mdesk | 2 +- src/dbg_engine/dbg_engine_core.c | 6 ++---- src/dbg_engine/generated/dbg_engine.meta.c | 2 +- src/dbg_gfx/dbg_gfx_core.c | 18 +++++++++--------- src/dbg_gfx/dbg_gfx_core.h | 1 + 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/dbg_engine/dbg_engine.mdesk b/src/dbg_engine/dbg_engine.mdesk index 1ebed937..ffa3e5d4 100644 --- a/src/dbg_engine/dbg_engine.mdesk +++ b/src/dbg_engine/dbg_engine.mdesk @@ -123,7 +123,7 @@ D_CoreCmdTable: // | | | | {Exit 1 1 Null Nil 0 0 0 0 0 0 X "exit" "Exit" "Exits the debugger." "quit,close,abort" } //- rjf: command runner - {RunCommand 1 1 CmdSpec Nil 0 0 0 0 0 0 Null "run_command" "Run Command" "Runs a command from the command palette." "help,cmd" } + {RunCommand 1 1 CmdSpec Nil 0 0 0 0 0 1 Null "run_command" "Run Command" "Runs a command from the command palette." "help,cmd" } //- rjf: notifications {Error 0 1 Null Nil 0 0 0 0 0 0 Null "error" "Error" "Notifies of an error." "" } diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index db904fba..b0efbcc1 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -6831,12 +6831,10 @@ d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt) case D_CmdKind_RunCommand: { D_CmdSpec *spec = params.cmd_spec; - if(spec != cmd->spec) + if(spec != cmd->spec && !d_cmd_spec_is_nil(spec)) { d_cmd_spec_counter_inc(spec); - if(!(spec->info.query.flags & D_CmdQueryFlag_Required) && - (spec->info.query.slot == D_CmdParamSlot_Null || - d_cmd_params_has_slot(¶ms, spec->info.query.slot))) + if(!(spec->info.query.flags & D_CmdQueryFlag_Required)) { d_cmd_list_push(arena, cmds, ¶ms, spec); } diff --git a/src/dbg_engine/generated/dbg_engine.meta.c b/src/dbg_engine/generated/dbg_engine.meta.c index 99cfceb6..a8a5d3e2 100644 --- a/src/dbg_engine/generated/dbg_engine.meta.c +++ b/src/dbg_engine/generated/dbg_engine.meta.c @@ -260,7 +260,7 @@ D_CmdSpecInfo d_core_cmd_kind_spec_info_table[221] = { { str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), (D_CmdSpecFlag_ListInUI*0)|(D_CmdSpecFlag_ListInIPCDocs*0), {D_CmdParamSlot_Null, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("exit"), str8_lit_comp("Exits the debugger."), str8_lit_comp("quit,close,abort"), str8_lit_comp("Exit"), (D_CmdSpecFlag_ListInUI*1)|(D_CmdSpecFlag_ListInIPCDocs*1), {D_CmdParamSlot_Null, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*0)}, DF_IconKind_X}, -{ str8_lit_comp("run_command"), str8_lit_comp("Runs a command from the command palette."), str8_lit_comp("help,cmd"), str8_lit_comp("Run Command"), (D_CmdSpecFlag_ListInUI*1)|(D_CmdSpecFlag_ListInIPCDocs*1), {D_CmdParamSlot_CmdSpec, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, +{ str8_lit_comp("run_command"), str8_lit_comp("Runs a command from the command palette."), str8_lit_comp("help,cmd"), str8_lit_comp("Run Command"), (D_CmdSpecFlag_ListInUI*1)|(D_CmdSpecFlag_ListInIPCDocs*1), {D_CmdParamSlot_CmdSpec, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*1)}, DF_IconKind_Null}, { str8_lit_comp("error"), str8_lit_comp("Notifies of an error."), str8_lit_comp(""), str8_lit_comp("Error"), (D_CmdSpecFlag_ListInUI*0)|(D_CmdSpecFlag_ListInIPCDocs*1), {D_CmdParamSlot_Null, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("os_event"), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("OS Event"), (D_CmdSpecFlag_ListInUI*0)|(D_CmdSpecFlag_ListInIPCDocs*0), {D_CmdParamSlot_Null, D_EntityKind_Nil, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("launch_and_run"), str8_lit_comp("Starts debugging a new instance of a target, then runs."), str8_lit_comp("launch,start,run,target"), str8_lit_comp("Launch and Run"), (D_CmdSpecFlag_ListInUI*1)|(D_CmdSpecFlag_ListInIPCDocs*1), {D_CmdParamSlot_EntityList, D_EntityKind_Target, (D_CmdQueryFlag_AllowFiles*0)|(D_CmdQueryFlag_AllowFolders*0)|(D_CmdQueryFlag_CodeInput*0)|(D_CmdQueryFlag_KeepOldInput*0)|(D_CmdQueryFlag_SelectOldInput*0)|(D_CmdQueryFlag_Required*1)}, DF_IconKind_Play}, diff --git a/src/dbg_gfx/dbg_gfx_core.c b/src/dbg_gfx/dbg_gfx_core.c index 404dda9e..202ff430 100644 --- a/src/dbg_gfx/dbg_gfx_core.c +++ b/src/dbg_gfx/dbg_gfx_core.c @@ -1365,18 +1365,17 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, D_CmdList *cmds) D_CmdSpec *spec = params.cmd_spec; // rjf: command simply executes - just no-op in this layer - if(!(spec->info.query.flags & D_CmdQueryFlag_Required) && - !d_cmd_spec_is_nil(spec) && - (spec->info.query.slot == D_CmdParamSlot_Null || d_cmd_params_has_slot(¶ms, spec->info.query.slot))) + if(!d_cmd_spec_is_nil(spec) && !(spec->info.query.flags & D_CmdQueryFlag_Required)) { } - // rjf: command is missing arguments -> prep query + // rjf: command has required query -> prep query else { arena_clear(ws->query_cmd_arena); ws->query_cmd_spec = d_cmd_spec_is_nil(spec) ? cmd->spec : spec; ws->query_cmd_params = df_cmd_params_copy(ws->query_cmd_arena, ¶ms); + MemoryZeroArray(ws->query_cmd_params_mask); ws->query_view_selected = 1; } }break; @@ -3384,22 +3383,22 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, D_CmdList *cmds) //- rjf: query completion case D_CmdKind_CompleteQuery: { + D_CmdParamSlot slot = ws->query_cmd_spec->info.query.slot; + // rjf: compound command parameters - if(ws->query_cmd_spec->info.query.slot != D_CmdParamSlot_Null && - d_cmd_params_has_slot(¶ms, ws->query_cmd_spec->info.query.slot)) + if(slot != D_CmdParamSlot_Null && !(ws->query_cmd_params_mask[slot/64] & (1ull<<(slot%64)))) { D_CmdParams params_copy = df_cmd_params_copy(ws->query_cmd_arena, ¶ms); Rng1U64 offset_range_in_params = d_cmd_param_slot_range_table[ws->query_cmd_spec->info.query.slot]; MemoryCopy((U8 *)(&ws->query_cmd_params) + offset_range_in_params.min, (U8 *)(¶ms_copy) + offset_range_in_params.min, dim_1u64(offset_range_in_params)); - d_cmd_params_mark_slot(&ws->query_cmd_params, ws->query_cmd_spec->info.query.slot); + ws->query_cmd_params_mask[slot/64] |= (1ull<<(slot%64)); } // rjf: determine if command is ready to run B32 command_ready = 1; - if(ws->query_cmd_spec->info.query.slot != D_CmdParamSlot_Null && - !d_cmd_params_has_slot(&ws->query_cmd_params, ws->query_cmd_spec->info.query.slot)) + if(slot != D_CmdParamSlot_Null && !(ws->query_cmd_params_mask[slot/64] & (1ull<<(slot%64)))) { command_ready = 0; } @@ -3422,6 +3421,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, D_CmdList *cmds) arena_clear(ws->query_cmd_arena); ws->query_cmd_spec = &d_nil_cmd_spec; MemoryZeroStruct(&ws->query_cmd_params); + MemoryZeroArray(ws->query_cmd_params_mask); for(DF_View *v = ws->query_view_stack_top, *next = 0; !df_view_is_nil(v); v = next) { next = v->order_next; diff --git a/src/dbg_gfx/dbg_gfx_core.h b/src/dbg_gfx/dbg_gfx_core.h index 75837464..ecac8253 100644 --- a/src/dbg_gfx/dbg_gfx_core.h +++ b/src/dbg_gfx/dbg_gfx_core.h @@ -632,6 +632,7 @@ struct DF_Window // rjf: query view stack Arena *query_cmd_arena; D_CmdSpec *query_cmd_spec; + U64 query_cmd_params_mask[(D_CmdParamSlot_COUNT + 63) / 64]; D_CmdParams query_cmd_params; DF_View *query_view_stack_top; B32 query_view_selected;