// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)

////////////////////////////////
//~ rjf: Built-In Command Tables

@table(name                      ui_vis   ipc_docs_vis   text_pt_vis      text_rng_vis     q_expr                       q_slot       q_view  q_ent_kind  q_ctrl_ent_kind  q_allow_files q_allow_folders  q_keep_oi   q_select_oi  q_is_code  q_floating  q_required                        canonical_icon        string                        display_name                                  desc                                                                                                               search_tags                      ctx_filter)
//    /                          |        |              |                |                |                            |             \___                                                                                       _________________________________/                        |                     |                             |                                             |                                                                                                                  |                                |
//   /                           |        |              |                |                |                            |                 \                                                                                     /                                                          |                     |                             |                                             |                                                                                                                  |                                |
D_CmdTable:     //               |        |              |                |                |                            |                  |                                                                                   |                                                           |                     |                             |                                             |                                                                                                                  |                                |
{
  //- rjf: low-level target control operations
  {LaunchAndRun                   1        1              0                0                "query:targets"              Cfg                null              Target         Null                    0  0  0  0  0  1  1                                                           Play                  "launch_and_run"              "Launch and Run"                              "Starts debugging a new instance of a target, then runs."                                                          "launch,start,run,target"        ""                                                                                            }
  {LaunchAndStepInto              1        1              0                0                "query:targets"              Cfg                null              Target         Null                    0  0  0  0  0  1  1                                                           PlayStepForward       "launch_and_step_into"        "Launch and Step Into"                        "Starts debugging a new instance of a target, then stops at the program's entry point."                            "launch,start,entry,point"       ""                                                                                            }
  {Kill                           1        1              0                0                "query:processes"            Process            null              Nil            Process                 0  0  0  0  0  1  1                                                           X                     "kill"                        "Kill"                                        "Kills the specified existing attached process(es)."                                                               "stop,kill"                      ""                                                                                            }
  {KillAll                        1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Stop                  "kill_all"                    "Kill All"                                    "Kills all attached processes."                                                                                    "stop,kill,all"                  ""                                                                                            }
  {Detach                         1        1              0                0                "query:processes"            Process            null              Nil            Process                 0  0  0  0  0  1  1                                                           Null                  "detach"                      "Detach"                                      "Detaches the specified attached process(es)."                                                                     "detach"                         ""                                                                                            }
  {Continue                       1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Play                  "continue"                    "Continue"                                    "Continues executing all attached processes."                                                                      ""                               ""                                                                                            }
  {StepIntoInst                   1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepInto              "step_into_inst"              "Step Into (Assembly)"                        "Performs a step that goes into calls, at the instruction level."                                                  "single,step,thread"             ""                                                                                            }
  {StepOverInst                   1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepOver              "step_over_inst"              "Step Over (Assembly)"                        "Performs a step that skips calls, at the instruction level."                                                      "single,step,thread"             ""                                                                                            }
  {StepIntoLine                   1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepInto              "step_into_line"              "Step Into (Line)"                            "Performs a step that goes into calls, at the source code line level."                                             "step,thread"                    ""                                                                                            }
  {StepOverLine                   1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepOver              "step_over_line"              "Step Over (Line)"                            "Performs a step that skips calls, at the source code line level."                                                 "step,thread"                    ""                                                                                            }
  {StepOut                        1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepOut               "step_out"                    "Step Out"                                    "Runs to the end of the current function and exits it."                                                            ""                               ""                                                                                            }
  {Halt                           1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Pause                 "halt"                        "Halt"                                        "Halts all attached processes."                                                                                    "pause"                          ""                                                                                            }
  {SoftHaltRefresh                0        0              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Refresh               "soft_halt_refresh"           "Soft Halt Refresh"                           "Interrupts all attached processes to collect data, and then resumes them."                                        ""                               ""                                                                                            }
  {SetThreadIP                    0        1              0                0                ""                           Vaddr              null              Nil            Null                    0  0  0  0  1  1  1                                                           Null                  "set_thread_ip"               "Set Thread IP"                               "Sets the specified thread's instruction pointer at the specified address."                                        ""                               ""                                                                                            }
  
  //- rjf: high-level composite target control operations
  {RunToLine                      1        1              1                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Play                  "run_to_line"                 "Run To Line"                                 "Runs until a particular source line is hit."                                                                      ""                               "$text_pt,"                                                                                   }
  {Run                            1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Play                  "run"                         "Run"                                         "Runs all targets after starting them if they have not been started yet."                                          "play"                           ""                                                                                            }
  {Restart                        1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Redo                  "restart"                     "Restart"                                     "Kills all attached processes, then launches all active targets."                                                  "restart,retry"                  ""                                                                                            }
  {StepInto                       1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepInto              "step_into"                   "Step Into"                                   "Steps once, possibly into function calls, for either source lines or instructions (whichever is selected)."       ""                               ""                                                                                            }
  {StepOver                       1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           StepOver              "step_over"                   "Step Over"                                   "Steps once, always over function calls, for either source lines or instructions."                                 ""                               ""                                                                                            }
  
  //- rjf: debug control context management operations
  {FreezeThread                   1        1              0                0                "query:threads"              Thread             null              Nil            Thread                  0  0  0  0  0  1  1                                                           Locked                "freeze_thread"               "Freeze Thread"                               "Freezes the passed thread."                                                                                       "callstack,unwind"               ""                                                                                            }
  {ThawThread                     1        1              0                0                "query:threads"              Thread             null              Nil            Thread                  0  0  0  0  0  1  1                                                           Unlocked              "thaw_thread"                 "Thaw Thread"                                 "Thaws the passed thread."                                                                                         ""                               ""                                                                                            }
  {FreezeProcess                  1        1              0                0                "query:processes"            Process            null              Nil            Process                 0  0  0  0  0  1  1                                                           Locked                "freeze_process"              "Freeze Process"                              "Freezes the passed process."                                                                                      ""                               ""                                                                                            }
  {ThawProcess                    1        1              0                0                "query:processes"            Process            null              Nil            Process                 0  0  0  0  0  1  1                                                           Unlocked              "thaw_process"                "Thaw Process"                                "Thaws the passed process."                                                                                        ""                               ""                                                                                            }
  {FreezeMachine                  0        1              0                0                "query:machines"             Machine            null              Nil            Machine                 0  0  0  0  0  1  1                                                           Locked                "freeze_machine"              "Freeze Machine"                              "Freezes the passed machine."                                                                                      ""                               ""                                                                                            }
  {ThawMachine                    0        1              0                0                "query:machines"             Machine            null              Nil            Machine                 0  0  0  0  0  1  1                                                           Unlocked              "thaw_machine"                "Thaw Machine"                                "Thaws the passed machine."                                                                                        ""                               ""                                                                                            }
  {FreezeLocalMachine             1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Machine               "freeze_local_machine"        "Freeze Local Machine"                        "Freezes the local machine."                                                                                       ""                               ""                                                                                            }
  {ThawLocalMachine               1        1              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Machine               "thaw_local_machine"          "Thaw Local Machine"                          "Thaws the local machine."                                                                                         ""                               ""                                                                                            }
  {FreezeEntity                   0        0              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Unlocked              "freeze_entity"               "Freeze Entity"                               "Freezes an entity."                                                                                               ""                               ""                                                                                            }
  {ThawEntity                     0        0              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Locked                "thaw_entity"                 "Thaw Entity"                                 "Thaws an entity."                                                                                                 ""                               ""                                                                                            }
  
  //- rjf: entity decoration
  {SetEntityColor                 0        0              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Null                  "set_entity_color"            "Set Entity Color"                            "Sets the passed entity's color."                                                                                  ""                               ""                                                                                            }
  {SetEntityName                  0        0              0                0                ""                           Null               null              Nil            Null                    0  0  0  0  0  0  0                                                           Null                  "set_entity_name"             "Set Entity Name"                             "Sets the passed entity's name."                                                                                   ""                               ""                                                                                            }
  
  //- rjf: attaching
  {Attach                         1        1              0                0                "query:unattached_processes" PID                null              Nil            Null                    0  0  0  0  0  1  1                                                           Null                  "attach"                      "Attach"                                      "Attaches to a process that is already running on the local machine."                                              ""                               ""                                                                                            }
}

@enum D_CmdKind:
{
  Null,
  @expand(D_CmdTable, a) `$(a.name)`,
  COUNT,
}

////////////////////////////////
//~ rjf: Developer Toggles

@table(name)
D_DevToggleTable:
{
  {always_refresh}
  {simulate_lag}
  {draw_ui_text_pos}
  {draw_ui_focus_debug}
  {draw_ui_box_heatmap}
  {eval_compiler_tooltips}
  {eval_watch_key_tooltips}
  {cmd_context_tooltips}
  {updating_indicator}
}

@gen
{
  @expand(D_DevToggleTable a) `global B32 DEV_$(a.name) = 0;`
}

@gen
{
  `struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =`;
  `{`;
    @expand(D_DevToggleTable a) `{&DEV_$(a.name), str8_lit_comp("$(a.name)")},`
      `};`;
}
