set up settings for enabling/disabling pre-packaged stl/ue type view rules; fill out basic stl ones

This commit is contained in:
Ryan Fleury
2025-05-03 21:01:26 -07:00
parent 6c7568f946
commit 24148dd672
4 changed files with 62 additions and 11 deletions
File diff suppressed because one or more lines are too long
+6
View File
@@ -287,6 +287,12 @@ RD_VocabTable:
{
@default(2) @display_name('Project Tab Width') 'tab_width': @range[1, 32] u64,
//- rjf: visualizers
@display_name('Use Default C++ STL Type Visualizers') @description("Enables the built-in type views for C++ STL types.")
@default(1) use_default_stl_type_views: bool,
@display_name('Use Default Unreal Engine Type Visualizers') @description("Enables the built-in type views for Unreal Engine types.")
@default(1) use_default_ue_type_views: bool,
//- rjf: theme
@no_expand 'theme': string,
@display_name('Project Theme') @description("The project's theme, which describes all colors used throughout the UI, and can override the user's theme.")
+41 -1
View File
@@ -11909,6 +11909,39 @@ rd_frame(void)
}
}
////////////////////////////
//- rjf: construct default immediate-mode configs based on loaded modules
//
if(rd_state->use_default_stl_type_views)
{
local_persist read_only struct
{
String8 pattern;
String8 expr;
}
type_views[] =
{
{ str8_lit_comp("std::vector<?>"), str8_lit_comp("slice(_Mypair._Myval2)") },
{ str8_lit_comp("std::unique_ptr<?>"), str8_lit_comp("_Mypair._Myval2") },
{ str8_lit_comp("std::basic_string<?>"), str8_lit_comp("_Mypair._Myval2._Myres <= 15 ? _Mypair._Myval2._Bx._Buf : array(_Mypair._Myval2._Bx._Ptr, _Mypair._Myval2._Mysize)") },
{ str8_lit_comp("std::basic_string_view<?>"), str8_lit_comp("array(_Mydata, _Mysize)") }
};
for EachElement(idx, type_views)
{
RD_Cfg *immediate_root = rd_immediate_cfg_from_keyf("default_stl_type_vis_%I64x", idx);
RD_Cfg *type_view = rd_cfg_child_from_string_or_alloc(immediate_root, str8_lit("type_view"));
RD_Cfg *type = rd_cfg_child_from_string_or_alloc(type_view, str8_lit("type"));
RD_Cfg *expr = rd_cfg_child_from_string_or_alloc(type_view, str8_lit("expr"));
rd_cfg_new_replace(type, type_views[idx].pattern);
rd_cfg_new_replace(expr, type_views[idx].expr);
rd_cfg_list_push(scratch.arena, &immediate_type_views, type_view);
}
}
if(rd_state->use_default_ue_type_views)
{
// TODO(rjf)
}
////////////////////////////
//- rjf: add auto-hook rules for type views
//
@@ -11966,6 +11999,14 @@ rd_frame(void)
}
e_select_interpret_ctx(interpret_ctx, eval_modules_primary->rdi, rip_voff);
////////////////////////////
//- rjf: evaluate unpacked settings (must be used earlier than this point in the frame,
// but cannot evaluate before this point, so we need to prep for next frame
//
rd_state->alt_menu_bar_enabled = rd_setting_b32_from_name(str8_lit("focus_menu_bar_with_alt"));
rd_state->use_default_stl_type_views = rd_setting_b32_from_name(str8_lit("use_default_stl_type_views"));
rd_state->use_default_ue_type_views = rd_setting_b32_from_name(str8_lit("use_default_ue_type_views"));
////////////////////////////
//- rjf: autosave if needed
//
@@ -11982,7 +12023,6 @@ rd_frame(void)
////////////////////////////
//- rjf: process top-level graphical commands
//
rd_state->alt_menu_bar_enabled = rd_setting_b32_from_name(str8_lit("focus_menu_bar_with_alt"));
if(rd_state->frame_depth == 0)
{
for(;rd_next_cmd(&cmd);) RD_RegsScope()
+14 -9
View File
@@ -84,8 +84,8 @@ enum
RD_EvalSpaceKind_CtrlEntity = E_SpaceKind_FirstUserDefined,
RD_EvalSpaceKind_MetaQuery,
RD_EvalSpaceKind_MetaCfg,
RD_EvalSpaceKind_MetaCmd,
RD_EvalSpaceKind_MetaTheme,
RD_EvalSpaceKind_MetaCmd,
RD_EvalSpaceKind_MetaTheme,
RD_EvalSpaceKind_MetaCtrlEntity,
RD_EvalSpaceKind_MetaUnattachedProcess,
};
@@ -445,8 +445,8 @@ struct RD_WindowState
Rng2F32 last_window_rect;
// rjf: theme (recomputed each frame)
UI_Theme *theme;
Vec4F32 theme_code_colors[RD_CodeColorSlot_COUNT];
UI_Theme *theme;
Vec4F32 theme_code_colors[RD_CodeColorSlot_COUNT];
// rjf: font raster flags (recomputed each frame)
FNT_RasterFlags font_slot_raster_flags[RD_FontSlot_COUNT];
@@ -540,7 +540,6 @@ struct RD_State
Arena *arena;
B32 quit;
B32 quit_after_success;
B32 alt_menu_bar_enabled;
S32 frame_depth;
U64 frame_eval_memread_endt_us;
@@ -552,6 +551,12 @@ struct RD_State
Arena *theme_path_arena;
String8 theme_path;
// rjf: unpacked settings (cached, because they need to be used
// earlier than setting evaluation is legal in a frame)
B32 alt_menu_bar_enabled;
B32 use_default_stl_type_views;
B32 use_default_ue_type_views;
// rjf: serialized config debug string keys
U128 user_cfg_string_key;
U128 project_cfg_string_key;
@@ -961,10 +966,10 @@ internal void rd_set_autocomp_regs_(RD_Regs *regs);
////////////////////////////////
//~ rjf: Colors, Fonts, Config
//- rjf: colors
internal Vec4F32 rd_rgba_from_code_color_slot(RD_CodeColorSlot slot);
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind(TXT_TokenKind kind);
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8 string);
//- rjf: colors
internal Vec4F32 rd_rgba_from_code_color_slot(RD_CodeColorSlot slot);
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind(TXT_TokenKind kind);
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8 string);
//- rjf: fonts
internal FNT_Tag rd_font_from_slot(RD_FontSlot slot);