mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-10 03:21:37 -07:00
kill old row/cell building code, fix incorrect use of view ui rule hooks in all cells
This commit is contained in:
@@ -4223,7 +4223,7 @@ rd_view_ui(Rng2F32 rect)
|
||||
UI_Tag(cell_tag)
|
||||
{
|
||||
//- rjf: cell has hook? -> build ui by calling hook
|
||||
if(cell_info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
if(cell->kind == RD_WatchCellKind_ViewUI && cell_info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
{
|
||||
RD_Cfg *root = rd_immediate_cfg_from_keyf("view_%I64x_%I64x", rd_regs()->view, row_hash);
|
||||
RD_Cfg *view = rd_view_from_eval(root, cell->eval);
|
||||
|
||||
@@ -1752,311 +1752,6 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
result.fstrs = fstrs;
|
||||
}break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//- rjf: fill basics/defaults
|
||||
result.view_ui_rule = &rd_nil_view_ui_rule;
|
||||
result.flags = cell->flags;
|
||||
result.cfg = &rd_nil_cfg;
|
||||
result.entity = &ctrl_entity_nil;
|
||||
|
||||
//- rjf: do per-kind fills
|
||||
switch(cell->kind)
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
//- rjf: expression cells -> if no string attached to row itself, form one from the
|
||||
// expression tree.
|
||||
case RD_WatchCellKind_Expr:
|
||||
{
|
||||
if(row_info->expr_is_editable)
|
||||
{
|
||||
result.flags |= RD_WatchCellFlag_CanEdit;
|
||||
}
|
||||
result.eval = (!e_type_key_match(cell->eval.irtree.type_key, e_type_key_zero()) ? cell->eval : row->eval);
|
||||
result.string = row->string;
|
||||
if(result.string.size == 0)
|
||||
{
|
||||
E_Expr *notable_expr = row->eval.expr;
|
||||
for(B32 good = 0; !good;)
|
||||
{
|
||||
switch(notable_expr->kind)
|
||||
{
|
||||
default:{good = 1;}break;
|
||||
case E_ExprKind_Address:
|
||||
case E_ExprKind_Deref:
|
||||
case E_ExprKind_Cast:
|
||||
{
|
||||
notable_expr = notable_expr->last;
|
||||
}break;
|
||||
case E_ExprKind_Ref:
|
||||
{
|
||||
notable_expr = notable_expr->ref;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
switch(notable_expr->kind)
|
||||
{
|
||||
default:
|
||||
{
|
||||
result.string = e_string_from_expr(arena, notable_expr);
|
||||
}break;
|
||||
case E_ExprKind_ArrayIndex:
|
||||
{
|
||||
result.string = push_str8f(arena, "[%S]", e_string_from_expr(arena, notable_expr->last));
|
||||
}break;
|
||||
case E_ExprKind_MemberAccess:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_Member member = e_type_member_from_key_name__cached(result.eval.irtree.type_key, notable_expr->last->string);
|
||||
String8 member_name = member.name;
|
||||
if(member_name.size == 0)
|
||||
{
|
||||
member_name = notable_expr->last->string;
|
||||
}
|
||||
if(member.inheritance_key_chain.count != 0)
|
||||
{
|
||||
String8List strings = {0};
|
||||
for(E_TypeKeyNode *n = member.inheritance_key_chain.first; n != 0; n = n->next)
|
||||
{
|
||||
String8 base_class_name = e_type_string_from_key(scratch.arena, n->v);
|
||||
str8_list_push(scratch.arena, &strings, base_class_name);
|
||||
}
|
||||
result.inheritance_tooltip = str8_list_join(arena, &strings, &(StringJoin){.sep = str8_lit_comp("::")});
|
||||
}
|
||||
B32 is_non_code = 0;
|
||||
String8 string = push_str8f(arena, ".%S", member_name);
|
||||
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
|
||||
result.eval.space.kind == E_SpaceKind_File ||
|
||||
result.eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
String8 fancy_name = rd_display_from_code_name(member_name);
|
||||
if(fancy_name.size != 0)
|
||||
{
|
||||
string = fancy_name;
|
||||
is_non_code = 1;
|
||||
}
|
||||
}
|
||||
result.flags |= (!!is_non_code * RD_WatchCellFlag_IsNonCode);
|
||||
result.string = string;
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: evaluation cells -> wrap expression if needed, evaluate, & stringize
|
||||
case RD_WatchCellKind_Eval:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: use cell's wrap string to wrap row's expression
|
||||
String8 wrap_string = cell->string;
|
||||
E_Expr *root_expr = row->eval.expr;
|
||||
if(wrap_string.size != 0)
|
||||
{
|
||||
E_Expr *wrap_expr = e_parse_expr_from_text(scratch.arena, wrap_string).expr;
|
||||
root_expr = wrap_expr;
|
||||
typedef struct Task Task;
|
||||
struct Task
|
||||
{
|
||||
Task *next;
|
||||
E_Expr *parent;
|
||||
E_Expr *expr;
|
||||
};
|
||||
Task start_task = {0, &e_expr_nil, wrap_expr};
|
||||
Task *first_task = &start_task;
|
||||
Task *last_task = first_task;
|
||||
for(Task *t = first_task; t != 0; t = t->next)
|
||||
{
|
||||
if(t->expr->kind == E_ExprKind_LeafIdentifier && str8_match(t->expr->string, str8_lit("$expr"), 0))
|
||||
{
|
||||
E_Expr *original_expr_ref = e_expr_ref(scratch.arena, row->eval.expr);
|
||||
if(t->parent != &e_expr_nil)
|
||||
{
|
||||
e_expr_insert_child(t->parent, t->expr, original_expr_ref);
|
||||
e_expr_remove_child(t->parent, t->expr);
|
||||
}
|
||||
else
|
||||
{
|
||||
root_expr = original_expr_ref;
|
||||
}
|
||||
}
|
||||
else for(E_Expr *child = t->expr->first; child != &e_expr_nil; child = child->next)
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
task->parent = t->expr;
|
||||
task->expr = child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: evaluate wrapped expression
|
||||
result.eval = (!e_type_key_match(cell->eval.irtree.type_key, e_type_key_zero()) ? cell->eval : e_eval_from_expr(arena, root_expr));
|
||||
|
||||
//- rjf: determine string generation parameters based on evaluation
|
||||
EV_StringParams string_params = {string_flags, 10};
|
||||
{
|
||||
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity)
|
||||
{
|
||||
string_params.flags |= EV_StringFlag_DisableStringQuotes|EV_StringFlag_DisableAddresses;
|
||||
}
|
||||
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(result.eval.space)->kind == CTRL_EntityKind_Module)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
if(result.eval.space.kind == RD_EvalSpaceKind_CtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(result.eval.space)->kind == CTRL_EntityKind_Thread)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: generate strings/flags based on that expression & fill
|
||||
result.string = rd_value_string_from_eval(arena, rd_view_query_input(), &string_params, font, font_size, max_size_px, result.eval);
|
||||
result.flags |= !!(ev_type_key_is_editable(result.eval.irtree.type_key) && result.eval.irtree.mode == E_Mode_Offset) * RD_WatchCellFlag_CanEdit;
|
||||
E_Type *type = e_type_from_key__cached(result.eval.irtree.type_key);
|
||||
if(type->flags & (E_TypeFlag_IsPlainText|E_TypeFlag_IsPathText))
|
||||
{
|
||||
result.flags |= RD_WatchCellFlag_IsNonCode;
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
|
||||
//- rjf: tag cells -> look up attached tag
|
||||
case RD_WatchCellKind_Tag:
|
||||
{
|
||||
EV_View *ev_view = rd_view_eval_view();
|
||||
result.string = ev_view_rule_from_key(ev_view, row->key);
|
||||
result.flags |= RD_WatchCellFlag_CanEdit;
|
||||
}break;
|
||||
|
||||
//- rjf: view ui cells
|
||||
case RD_WatchCellKind_ViewUI:
|
||||
{
|
||||
result.eval = (cell->eval.irtree.mode != E_Mode_Null ? cell->eval : row->eval);
|
||||
result.view_ui_rule = row_info->view_ui_rule;
|
||||
}break;
|
||||
}
|
||||
|
||||
//- rjf: adjust style based on evaluation
|
||||
switch(cell->kind)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_WatchCellKind_Expr:
|
||||
{
|
||||
if(result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
|
||||
result.eval.value.u64 == 0)
|
||||
{
|
||||
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(result.eval.space);
|
||||
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]);
|
||||
if(e_type_key_match(cfg_type, result.eval.irtree.type_key))
|
||||
{
|
||||
result.entity = entity;
|
||||
}
|
||||
}
|
||||
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
|
||||
result.eval.value.u64 == 0)
|
||||
{
|
||||
RD_Cfg *cfg = rd_cfg_from_eval_space(result.eval.space);
|
||||
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, cfg->string);
|
||||
if(e_type_key_match(cfg_type, result.eval.irtree.type_key))
|
||||
{
|
||||
result.cfg = cfg;
|
||||
result.fstrs = rd_title_fstrs_from_cfg(arena, cfg);
|
||||
}
|
||||
}
|
||||
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCmd)
|
||||
{
|
||||
result.cmd_name = e_string_from_id(result.eval.value.u64);
|
||||
}
|
||||
else if(result.eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
E_Type *type = e_type_from_key__cached(result.eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Set)
|
||||
{
|
||||
String8 file_path = e_string_from_id(result.eval.value.u64);
|
||||
result.fstrs = rd_title_fstrs_from_file_path(arena, file_path);
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case RD_WatchCellKind_Eval:
|
||||
{
|
||||
if(result.eval.msgs.max_kind != E_MsgKind_Null)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
result.flags |= RD_WatchCellFlag_IsErrored|RD_WatchCellFlag_IsNonCode;
|
||||
String8List error_strings = {0};
|
||||
for(E_Msg *msg = result.eval.msgs.first; msg != 0; msg = msg->next)
|
||||
{
|
||||
str8_list_push(scratch.arena, &error_strings, msg->text);
|
||||
if(msg->next)
|
||||
{
|
||||
str8_list_pushf(scratch.arena, &error_strings, " ");
|
||||
}
|
||||
}
|
||||
result.string = str8_list_join(arena, &error_strings, 0);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
|
||||
result.eval.value.u64 == 0)
|
||||
{
|
||||
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(result.eval.space);
|
||||
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]);
|
||||
if(e_type_key_match(cfg_type, result.eval.irtree.type_key))
|
||||
{
|
||||
result.fstrs = rd_title_fstrs_from_ctrl_entity(arena, entity, 1);
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
result.entity = entity;
|
||||
}
|
||||
}
|
||||
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCfg &&
|
||||
result.eval.value.u64 == 0)
|
||||
{
|
||||
RD_Cfg *cfg = rd_cfg_from_eval_space(result.eval.space);
|
||||
E_TypeKey cfg_type = e_string2typekey_map_lookup(rd_state->meta_name2type_map, cfg->string);
|
||||
if(e_type_key_match(cfg_type, result.eval.irtree.type_key))
|
||||
{
|
||||
result.fstrs = rd_title_fstrs_from_cfg(arena, cfg);
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
result.cfg = cfg;
|
||||
}
|
||||
}
|
||||
else if(result.eval.space.kind == RD_EvalSpaceKind_MetaCmd)
|
||||
{
|
||||
String8 cmd_name = e_string_from_id(result.eval.value.u64);
|
||||
if(cell->px != 0) UI_TagF("weak")
|
||||
{
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Icons), rd_raster_flags_from_slot(RD_FontSlot_Icons), ui_color_from_name(str8_lit("text")), ui_top_font_size()};
|
||||
dr_fstrs_push_new(arena, &result.fstrs, ¶ms, rd_icon_kind_text_table[rd_icon_kind_from_code_name(cmd_name)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.fstrs = rd_title_fstrs_from_code_name(arena, cmd_name);
|
||||
}
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
result.cmd_name = cmd_name;
|
||||
}
|
||||
else if(result.eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
E_Type *type = e_type_from_key__cached(result.eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Set)
|
||||
{
|
||||
String8 file_path = e_string_from_id(result.eval.value.u64);
|
||||
result.fstrs = rd_title_fstrs_from_file_path(arena, file_path);
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
#endif
|
||||
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user