further integration work & expanded support; generalized paths for entity reordering in watch views

This commit is contained in:
Ryan Fleury
2024-09-26 14:37:13 -07:00
parent 338fabd9d0
commit 07f978ac41
7 changed files with 331 additions and 51 deletions
@@ -737,7 +737,7 @@ ev2_block_range_list_from_tree(Arena *arena, EV2_BlockTree *block_tree)
EV2_Block *next_child;
Rng1U64 block_relative_range;
};
U64 base_num = 1;
U64 base_num = 0;
BlockTask start_task = {0, block_tree->root, block_tree->root->first, r1u64(0, block_tree->root->row_count)};
for(BlockTask *t = &start_task; t != 0; t = t->next)
{
@@ -792,15 +792,17 @@ internal EV2_BlockRange
ev2_block_range_from_num(EV2_BlockRangeList *block_ranges, U64 num)
{
EV2_BlockRange result = {&ev2_nil_block};
U64 base_num = 1;
U64 base_num = 0;
for(EV2_BlockRangeNode *n = block_ranges->first; n != 0; n = n->next)
{
Rng1U64 global_range = r1u64(base_num, base_num + dim_1u64(n->v.range));
U64 range_size = dim_1u64(n->v.range);
Rng1U64 global_range = r1u64(base_num, base_num + range_size);
if(contains_1u64(global_range, num))
{
result = n->v;
break;
}
base_num += range_size;
}
return result;
}
@@ -813,7 +815,7 @@ ev2_key_from_num(EV2_BlockRangeList *block_ranges, U64 num)
{
key = ev_key_make(ev_hash_from_key(ev_key_root()), 1);
}
U64 base_num = 1;
U64 base_num = 0;
for(EV2_BlockRangeNode *n = block_ranges->first; n != 0; n = n->next)
{
U64 range_size = dim_1u64(n->v.range);
@@ -834,8 +836,8 @@ ev2_key_from_num(EV2_BlockRangeList *block_ranges, U64 num)
internal U64
ev2_num_from_key(EV2_BlockRangeList *block_ranges, EV_Key key)
{
U64 result = 1;
U64 base_num = 1;
U64 result = 0;
U64 base_num = 0;
for(EV2_BlockRangeNode *n = block_ranges->first; n != 0; n = n->next)
{
U64 hash = ev_hash_from_key(n->v.block->key);
+48
View File
@@ -685,6 +685,22 @@ str8_lit_comp("types"),
str8_lit_comp("procedures"),
};
RD_EntityKind rd_collection_entity_kind_table[12] =
{
RD_EntityKind_Watch,
RD_EntityKind_Target,
RD_EntityKind_Breakpoint,
RD_EntityKind_WatchPin,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
RD_EntityKind_Nil,
};
EV_ViewRuleExprExpandInfoHookFunctionType * rd_collection_expr_expand_info_hook_function_table[12] =
{
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_NAME(watches),
@@ -717,6 +733,38 @@ EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_NAME(types),
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_NAME(procedures),
};
EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_id_from_num_hook_function_table[12] =
{
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(watches),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(targets),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(breakpoints),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(watch_pins),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(globals),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(thread_locals),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(types),
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(procedures),
};
EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_num_from_id_hook_function_table[12] =
{
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(watches),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(targets),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(breakpoints),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(watch_pins),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(identity),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(globals),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(thread_locals),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(types),
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(procedures),
};
EV_ViewRuleBlockProdHookFunctionType * rd_collection_block_prod_hook_function_table[12] =
{
EV_VIEW_RULE_BLOCK_PROD_FUNCTION_NAME(watches),
+19
View File
@@ -667,6 +667,22 @@ EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(globals);
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(thread_locals);
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(types);
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(procedures);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watches);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(targets);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(breakpoints);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watch_pins);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(globals);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(thread_locals);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(types);
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(procedures);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watches);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(targets);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(breakpoints);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watch_pins);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(globals);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(thread_locals);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(types);
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(procedures);
EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(watches);
EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(targets);
EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(breakpoints);
@@ -736,8 +752,11 @@ extern String8 rd_binding_version_remap_old_name_table[7];
extern String8 rd_binding_version_remap_new_name_table[7];
extern String8 rd_icon_kind_text_table[69];
extern String8 rd_collection_name_table[12];
extern RD_EntityKind rd_collection_entity_kind_table[12];
extern EV_ViewRuleExprExpandInfoHookFunctionType * rd_collection_expr_expand_info_hook_function_table[12];
extern EV_ViewRuleExprExpandRangeInfoHookFunctionType * rd_collection_expr_expand_range_info_hook_function_table[12];
extern EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_id_from_num_hook_function_table[12];
extern EV_ViewRuleExprExpandIDFromNumHookFunctionType * rd_collection_expr_expand_num_from_id_hook_function_table[12];
extern EV_ViewRuleBlockProdHookFunctionType * rd_collection_block_prod_hook_function_table[12];
extern RD_ViewRuleInfo rd_view_rule_kind_info_table[34];
extern RD_IconKind rd_entity_kind_icon_kind_table[30];
+30 -13
View File
@@ -817,27 +817,29 @@ RD_IconTable:
////////////////////////////////
//~ rjf: Collections
@table(name)
@table(name entity_kind id_space)
RD_CollectionTable:
{
{watches}
{targets}
{breakpoints}
{watch_pins}
{threads}
{modules}
{locals}
{registers}
{globals}
{thread_locals}
{types}
{procedures}
{watches Watch x}
{targets Target x}
{breakpoints Breakpoint x}
{watch_pins WatchPin x}
{threads Nil -}
{modules Nil -}
{locals Nil -}
{registers Nil -}
{globals Nil x}
{thread_locals Nil x}
{types Nil x}
{procedures Nil x}
}
@gen
{
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF($(a.name));`;
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF($(a.name));`;
@expand(RD_CollectionTable a) `$(a.id_space == x -> "EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF("..a.name..");")`;
@expand(RD_CollectionTable a) `$(a.id_space == x -> "EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF("..a.name..");")`;
@expand(RD_CollectionTable a) `EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF($(a.name));`;
}
@@ -846,6 +848,11 @@ RD_CollectionTable:
@expand(RD_CollectionTable a) `str8_lit_comp("$(a.name)")`
}
@data(RD_EntityKind) rd_collection_entity_kind_table:
{
@expand(RD_CollectionTable a) `RD_EntityKind_$(a.entity_kind)`,
}
@data(`EV_ViewRuleExprExpandInfoHookFunctionType *`) rd_collection_expr_expand_info_hook_function_table:
{
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_NAME($(a.name))`
@@ -856,6 +863,16 @@ RD_CollectionTable:
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_NAME($(a.name))`
}
@data(`EV_ViewRuleExprExpandIDFromNumHookFunctionType *`) rd_collection_expr_expand_id_from_num_hook_function_table:
{
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME($(a.id_space == x -> a.name)$(a.id_space != x -> identity))`
}
@data(`EV_ViewRuleExprExpandIDFromNumHookFunctionType *`) rd_collection_expr_expand_num_from_id_hook_function_table:
{
@expand(RD_CollectionTable a) `EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME($(a.id_space == x -> a.name)$(a.id_space != x -> identity))`
}
@data(`EV_ViewRuleBlockProdHookFunctionType *`) rd_collection_block_prod_hook_function_table:
{
@expand(RD_CollectionTable a) `EV_VIEW_RULE_BLOCK_PROD_FUNCTION_NAME($(a.name))`
+60 -2
View File
@@ -7920,14 +7920,23 @@ EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(watches)
return result;
}
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watches) { return rd_ev_view_rule_expr_id_from_num__meta_entities(num, user_data, RD_EntityKind_Watch); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watches) { return rd_ev_view_rule_expr_num_from_id__meta_entities(id, user_data, RD_EntityKind_Watch); }
//- rjf: meta entities
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(targets) { return rd_ev_view_rule_expr_expand_info__meta_entities(arena, view, filter, expr, params, RD_EntityKind_Target); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(targets) { return rd_ev_view_rule_expr_expand_range_info__meta_entities(arena, view, filter, expr, params, idx_range, user_data, RD_EntityKind_Target); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(targets) { return rd_ev_view_rule_expr_id_from_num__meta_entities(num, user_data, RD_EntityKind_Target); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(targets) { return rd_ev_view_rule_expr_num_from_id__meta_entities(id, user_data, RD_EntityKind_Target); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(breakpoints) { return rd_ev_view_rule_expr_expand_info__meta_entities(arena, view, filter, expr, params, RD_EntityKind_Breakpoint); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(breakpoints) { return rd_ev_view_rule_expr_expand_range_info__meta_entities(arena, view, filter, expr, params, idx_range, user_data, RD_EntityKind_Breakpoint); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(breakpoints){ return rd_ev_view_rule_expr_id_from_num__meta_entities(num, user_data, RD_EntityKind_Breakpoint); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(breakpoints){ return rd_ev_view_rule_expr_num_from_id__meta_entities(id, user_data, RD_EntityKind_Breakpoint); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(watch_pins) { return rd_ev_view_rule_expr_expand_info__meta_entities(arena, view, filter, expr, params, RD_EntityKind_WatchPin); }
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(watch_pins) { return rd_ev_view_rule_expr_expand_range_info__meta_entities(arena, view, filter, expr, params, idx_range, user_data, RD_EntityKind_WatchPin); }
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watch_pins) { return rd_ev_view_rule_expr_id_from_num__meta_entities(num, user_data, RD_EntityKind_WatchPin); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watch_pins) { return rd_ev_view_rule_expr_num_from_id__meta_entities(id, user_data, RD_EntityKind_WatchPin); }
//- rjf: meta ctrl entities
@@ -8020,12 +8029,20 @@ EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(registers)
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(globals) {return rd_ev_view_rule_expr_expand_info__debug_info_tables(arena, view, filter, expr, params, RDI_SectionKind_GlobalVariables);}
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(globals) {return rd_ev_view_rule_expr_expand_range_info__debug_info_tables(arena, view, filter, expr, params, idx_range, user_data, RDI_SectionKind_GlobalVariables);}
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(globals) {return rd_ev_view_rule_expr_id_from_num__debug_info_tables(num, user_data, RDI_SectionKind_GlobalVariables); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(globals) {return rd_ev_view_rule_expr_num_from_id__debug_info_tables(id, user_data, RDI_SectionKind_GlobalVariables); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(thread_locals) {return rd_ev_view_rule_expr_expand_info__debug_info_tables(arena, view, filter, expr, params, RDI_SectionKind_ThreadVariables);}
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(thread_locals) {return rd_ev_view_rule_expr_expand_range_info__debug_info_tables(arena, view, filter, expr, params, idx_range, user_data, RDI_SectionKind_ThreadVariables);}
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(thread_locals) {return rd_ev_view_rule_expr_id_from_num__debug_info_tables(num, user_data, RDI_SectionKind_ThreadVariables); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(thread_locals) {return rd_ev_view_rule_expr_num_from_id__debug_info_tables(id, user_data, RDI_SectionKind_ThreadVariables); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(types) {return rd_ev_view_rule_expr_expand_info__debug_info_tables(arena, view, filter, expr, params, RDI_SectionKind_UDTs);}
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(types) {return rd_ev_view_rule_expr_expand_range_info__debug_info_tables(arena, view, filter, expr, params, idx_range, user_data, RDI_SectionKind_UDTs);}
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(types) {return rd_ev_view_rule_expr_id_from_num__debug_info_tables(num, user_data, RDI_SectionKind_UDTs); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(types) {return rd_ev_view_rule_expr_num_from_id__debug_info_tables(id, user_data, RDI_SectionKind_UDTs); }
EV_VIEW_RULE_EXPR_EXPAND_INFO_FUNCTION_DEF(procedures) {return rd_ev_view_rule_expr_expand_info__debug_info_tables(arena, view, filter, expr, params, RDI_SectionKind_Procedures);}
EV_VIEW_RULE_EXPR_EXPAND_RANGE_INFO_FUNCTION_DEF(procedures) {return rd_ev_view_rule_expr_expand_range_info__debug_info_tables(arena, view, filter, expr, params, idx_range, user_data, RDI_SectionKind_Procedures);}
EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_DEF(procedures) {return rd_ev_view_rule_expr_id_from_num__debug_info_tables(num, user_data, RDI_SectionKind_Procedures); }
EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(procedures) {return rd_ev_view_rule_expr_num_from_id__debug_info_tables(id, user_data, RDI_SectionKind_Procedures); }
//- TODO(rjf): OLD VVVVVVVVVVVVVVVVVVVVVVVVVV
@@ -8262,6 +8279,35 @@ rd_ev_view_rule_expr_expand_range_info__meta_entities(Arena *arena, EV_View *vie
return result;
}
internal U64
rd_ev_view_rule_expr_id_from_num__meta_entities(U64 num, void *user_data, RD_EntityKind kind)
{
U64 id = 0;
RD_EntityExpandAccel *accel = (RD_EntityExpandAccel *)user_data;
if(0 < num && num <= accel->entities.count)
{
id = accel->entities.v[num-1]->id;
}
return id;
}
internal U64
rd_ev_view_rule_expr_num_from_id__meta_entities(U64 id, void *user_data, RD_EntityKind kind)
{
RD_Entity *entity = rd_entity_from_id(id);
RD_EntityExpandAccel *accel = (RD_EntityExpandAccel *)user_data;
U64 num = 0;
for(U64 idx = 0; idx < accel->entities.count; idx += 1)
{
if(accel->entities.v[idx]->id == id)
{
num = idx+1;
break;
}
}
return num;
}
internal EV_ExpandInfo
rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, CTRL_EntityKind kind)
{
@@ -8457,6 +8503,18 @@ rd_ev_view_rule_expr_expand_range_info__debug_info_tables(Arena *arena, EV_View
return result;
}
internal U64
rd_ev_view_rule_expr_id_from_num__debug_info_tables(U64 num, void *user_data, RDI_SectionKind section)
{
return num;
}
internal U64
rd_ev_view_rule_expr_num_from_id__debug_info_tables(U64 num, void *user_data, RDI_SectionKind section)
{
return num;
}
internal void
rd_ev_view_rule_block_prod_collection_debug_tables(Arena *arena, RDI_SectionKind target, EV_View *view, String8 filter, EV_Key parent_key, EV_Key key, EV_ExpandNode *expand_node, String8 string, E_Expr *expr, EV_ViewRuleList *view_rules, MD_Node *view_params, S32 depth, struct EV_BlockList *out)
{
@@ -11171,8 +11229,8 @@ rd_frame(void)
info.expr_resolution = EV_VIEW_RULE_EXPR_RESOLUTION_FUNCTION_NAME(identity);
info.expr_expand_info = rd_collection_expr_expand_info_hook_function_table[idx];;
info.expr_expand_range_info = rd_collection_expr_expand_range_info_hook_function_table[idx];
info.expr_expand_id_from_num = EV_VIEW_RULE_EXPR_EXPAND_ID_FROM_NUM_FUNCTION_NAME(identity);
info.expr_expand_num_from_id = EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_NAME(identity);
info.expr_expand_id_from_num = rd_collection_expr_expand_id_from_num_hook_function_table[idx];
info.expr_expand_num_from_id = rd_collection_expr_expand_num_from_id_hook_function_table[idx];
info.block_prod = rd_collection_block_prod_hook_function_table[idx];
ev_view_rule_info_table_push(scratch.arena, view_rule_info_table, &info);
}
+6
View File
@@ -1282,10 +1282,16 @@ internal void rd_window_frame(RD_Window *ws);
internal EV_ExpandInfo rd_ev_view_rule_expr_expand_info__meta_entities(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, RD_EntityKind kind);
internal EV_ExpandRangeInfo rd_ev_view_rule_expr_expand_range_info__meta_entities(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, Rng1U64 idx_range, void *user_data, RD_EntityKind kind);
internal U64 rd_ev_view_rule_expr_id_from_num__meta_entities(U64 num, void *user_data, RD_EntityKind kind);
internal U64 rd_ev_view_rule_expr_num_from_id__meta_entities(U64 num, void *user_data, RD_EntityKind kind);
internal EV_ExpandInfo rd_ev_view_rule_expr_expand_info__meta_ctrl_entities(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, CTRL_EntityKind kind);
internal EV_ExpandRangeInfo rd_ev_view_rule_expr_expand_range_info__meta_ctrl_entities(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, Rng1U64 idx_range, void *user_data, CTRL_EntityKind kind);
internal EV_ExpandInfo rd_ev_view_rule_expr_expand_info__debug_info_tables(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, RDI_SectionKind section);
internal EV_ExpandRangeInfo rd_ev_view_rule_expr_expand_range_info__debug_info_tables(Arena *arena, EV_View *view, String8 filter, E_Expr *expr, MD_Node *params, Rng1U64 idx_range, void *user_data, RDI_SectionKind section);
internal U64 rd_ev_view_rule_expr_id_from_num__debug_info_tables(U64 num, void *user_data, RDI_SectionKind section);
internal U64 rd_ev_view_rule_expr_num_from_id__debug_info_tables(U64 num, void *user_data, RDI_SectionKind section);
internal void rd_ev_view_rule_block_prod_collection_debug_tables(Arena *arena, RDI_SectionKind target, EV_View *view, String8 filter, EV_Key parent_key, EV_Key key, EV_ExpandNode *expand_node, String8 string, E_Expr *expr, EV_ViewRuleList *view_rules, MD_Node *view_params, S32 depth, struct EV_BlockList *out);
internal EV_View *rd_ev_view_from_key(U64 key);
+160 -30
View File
@@ -797,8 +797,8 @@ rd_watch_view_point_from_tbl(EV2_BlockRangeList *block_ranges, Vec2S64 tbl)
{
RD_WatchViewPoint pt = zero_struct;
pt.x = tbl.x;
pt.key = ev2_key_from_num(block_ranges, (U64)tbl.y + 1);
pt.parent_key = ev2_block_range_from_num(block_ranges, (U64)tbl.y + 1).block->key;
pt.key = ev2_key_from_num(block_ranges, (U64)tbl.y);
pt.parent_key = ev2_block_range_from_num(block_ranges, (U64)tbl.y).block->key;
return pt;
}
@@ -807,7 +807,7 @@ rd_tbl_from_watch_view_point(EV2_BlockRangeList *block_ranges, RD_WatchViewPoint
{
Vec2S64 tbl = {0};
tbl.x = pt.x;
tbl.y = (S64)ev2_num_from_key(block_ranges, pt.key) - 1;
tbl.y = (S64)ev2_num_from_key(block_ranges, pt.key);
return tbl;
}
@@ -1688,36 +1688,167 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
if(!ewv->text_editing && evt->flags & UI_EventFlag_Reorder)
{
taken = 1;
EV_Key first_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.min.y);
EV_Key reorder_group_prev_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.min.y - 1);
EV_Key reorder_group_next_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.max.y + 1);
RD_Entity *reorder_group_prev = rd_entity_from_ev_key_and_kind(reorder_group_prev_watch_key, mutable_entity_kind);
RD_Entity *reorder_group_next = rd_entity_from_ev_key_and_kind(reorder_group_next_watch_key, mutable_entity_kind);
RD_Entity *first_watch = rd_entity_from_ev_key_and_kind(first_watch_key, mutable_entity_kind);
RD_Entity *last_watch = first_watch;
if(!rd_entity_is_nil(first_watch))
if(filter.size == 0)
{
for(S64 y = selection_tbl.min.y+1; y <= selection_tbl.max.y; y += 1)
// rjf: determine blocks of each endpoint of the table selection
EV2_Block *selection_endpoint_blocks[2] =
{
EV_Key key = ev2_key_from_num(&block_ranges, y);
RD_Entity *new_last = rd_entity_from_ev_key_and_kind(key, mutable_entity_kind);
if(!rd_entity_is_nil(new_last))
ev2_block_range_from_num(&block_ranges, selection_tbl.min.y).block,
ev2_block_range_from_num(&block_ranges, selection_tbl.max.y).block,
};
// rjf: pick shallowest block within which we can do reordering
U64 selection_depths[2] =
{
ev2_depth_from_block(selection_endpoint_blocks[0]),
ev2_depth_from_block(selection_endpoint_blocks[1]),
};
EV2_Block *selection_block = (selection_depths[1] < selection_depths[0]
? selection_endpoint_blocks[1]
: selection_endpoint_blocks[0]);
// rjf: find selection keys within the block in which we are doing reordering
EV_Key selection_keys_in_block[2] = {0};
{
for EachElement(idx, selection_endpoint_blocks)
{
last_watch = new_last;
EV2_Block *endpoint_block = selection_endpoint_blocks[idx];
if(endpoint_block == selection_block)
{
selection_keys_in_block[idx] = ev2_key_from_num(&block_ranges, selection_tbl.v[idx].y);
}
else
{
for(;endpoint_block->parent != selection_block && endpoint_block != &ev2_nil_block;)
{
endpoint_block = endpoint_block->parent;
}
if(endpoint_block->parent == selection_block)
{
selection_keys_in_block[idx] = endpoint_block->key;
}
}
}
EV_Key fallback_key = {0};
for EachElement(idx, selection_endpoint_blocks)
{
if(!ev_key_match(selection_keys_in_block[idx], ev_key_zero()))
{
fallback_key = selection_keys_in_block[idx];
}
}
for EachElement(idx, selection_endpoint_blocks)
{
if(ev_key_match(selection_keys_in_block[idx], ev_key_zero()))
{
selection_keys_in_block[idx] = fallback_key;
}
}
}
}
if(evt->delta_2s32.y < 0 && !rd_entity_is_nil(first_watch) && !rd_entity_is_nil(reorder_group_prev))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(reorder_group_prev, reorder_group_prev->parent, reorder_group_prev->parent, last_watch);
}
if(evt->delta_2s32.y > 0 && !rd_entity_is_nil(last_watch) && !rd_entity_is_nil(reorder_group_next))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(reorder_group_next, reorder_group_next->parent, reorder_group_next->parent, reorder_group_prev);
// rjf: map selection keys to child numbers
U64 selection_numbers[2] =
{
selection_block->expand_view_rule_info->expr_expand_num_from_id(selection_keys_in_block[0].child_num, selection_block->expand_view_rule_info_user_data),
selection_block->expand_view_rule_info->expr_expand_num_from_id(selection_keys_in_block[1].child_num, selection_block->expand_view_rule_info_user_data),
};
// rjf: determine collection info for the block
RD_EntityKind collection_entity_kind = RD_EntityKind_Nil;
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(scratch.arena, selection_block->expr);
E_Type *type = e_type_from_key(scratch.arena, irtree.type_key);
for EachElement(idx, rd_collection_name_table)
{
if(str8_match(type->name, rd_collection_name_table[idx], 0))
{
collection_entity_kind = rd_collection_entity_kind_table[idx];
break;
}
}
// rjf: map selection endpoints to entities
RD_Entity *first_entity = &d_nil_entity;
RD_Entity *last_entity = &d_nil_entity;
if(collection_entity_kind != RD_EntityKind_Nil)
{
RD_EntityList entities_list = rd_query_cached_entity_list_with_kind(collection_entity_kind);
RD_EntityArray entities = rd_entity_array_from_list(scratch.arena, &entities_list);
if(0 < selection_numbers[0] && selection_numbers[0] <= entities.count &&
0 < selection_numbers[1] && selection_numbers[1] <= entities.count)
{
first_entity = entities.v[Min(selection_numbers[0], selection_numbers[1]) - 1];
last_entity = entities.v[Max(selection_numbers[0], selection_numbers[1]) - 1];
}
}
// rjf: reorder
if(!rd_entity_is_nil(first_entity) && !rd_entity_is_nil(last_entity))
{
RD_Entity *first_entity_prev = &d_nil_entity;
RD_Entity *last_entity_next = &d_nil_entity;
for(RD_Entity *prev = first_entity->prev; !rd_entity_is_nil(prev); prev = prev->prev)
{
if(prev->kind == collection_entity_kind)
{
first_entity_prev = prev;
break;
}
}
for(RD_Entity *next = last_entity->next; !rd_entity_is_nil(next); next = next->next)
{
if(next->kind == collection_entity_kind)
{
last_entity_next = next;
break;
}
}
if(evt->delta_2s32.y < 0 && !rd_entity_is_nil(first_entity) && !rd_entity_is_nil(first_entity_prev))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(first_entity_prev, first_entity_prev->parent, first_entity_prev->parent, last_entity);
}
if(evt->delta_2s32.y > 0 && !rd_entity_is_nil(last_entity) && !rd_entity_is_nil(last_entity_next))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(last_entity_next, last_entity_next->parent, last_entity_next->parent, first_entity_prev);
}
}
#if 0 // TODO(rjf): @blocks
EV_Key first_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.min.y);
EV_Key reorder_group_prev_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.min.y - 1);
EV_Key reorder_group_next_watch_key = ev2_key_from_num(&block_ranges, selection_tbl.max.y + 1);
RD_Entity *reorder_group_prev = rd_entity_from_ev_key_and_kind(reorder_group_prev_watch_key, mutable_entity_kind);
RD_Entity *reorder_group_next = rd_entity_from_ev_key_and_kind(reorder_group_next_watch_key, mutable_entity_kind);
RD_Entity *first_watch = rd_entity_from_ev_key_and_kind(first_watch_key, mutable_entity_kind);
RD_Entity *last_watch = first_watch;
if(!rd_entity_is_nil(first_watch))
{
for(S64 y = selection_tbl.min.y+1; y <= selection_tbl.max.y; y += 1)
{
EV_Key key = ev2_key_from_num(&block_ranges, y);
RD_Entity *new_last = rd_entity_from_ev_key_and_kind(key, mutable_entity_kind);
if(!rd_entity_is_nil(new_last))
{
last_watch = new_last;
}
}
}
if(evt->delta_2s32.y < 0 && !rd_entity_is_nil(first_watch) && !rd_entity_is_nil(reorder_group_prev))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(reorder_group_prev, reorder_group_prev->parent, reorder_group_prev->parent, last_watch);
}
if(evt->delta_2s32.y > 0 && !rd_entity_is_nil(last_watch) && !rd_entity_is_nil(reorder_group_next))
{
state_dirty = 1;
snap_to_cursor = 1;
rd_entity_change_parent(reorder_group_next, reorder_group_next->parent, reorder_group_next->parent, reorder_group_prev);
}
#endif
}
}
@@ -1798,8 +1929,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
ProfScope("build table")
{
U64 global_row_idx = rows.count_before_semantic;
U64 global_row_num = global_row_idx+1;
for(EV2_Row *row = rows.first; row != 0; row = row->next, global_row_idx += 1, global_row_num += 1)
for(EV2_Row *row = rows.first; row != 0; row = row->next, global_row_idx += 1)
{
////////////////////////
//- rjf: unpack row info