Doing some heavy refactors on the container interfaces

Trying to set up their use to be more ideomatic to the core containers
This commit is contained in:
2024-05-31 17:58:18 -04:00
parent 3db403017e
commit f415eada0d
20 changed files with 133 additions and 98 deletions

View File

@ -133,7 +133,7 @@ ui_startup :: proc( ui : ^ UI_State, cache_allocator : Allocator /* , cache_rese
ui^ = {}
for & cache in ui.caches {
box_cache, allocation_error := hamp_zpl_init( UI_Box, cache_allocator, UI_Built_Boxes_Array_Size )
box_cache, allocation_error := make( HMapZPL(UI_Box), UI_Built_Boxes_Array_Size, cache_allocator )
verify( allocation_error == AllocatorError.None, "Failed to allocate box cache" )
cache = box_cache
}
@ -141,7 +141,7 @@ ui_startup :: proc( ui : ^ UI_State, cache_allocator : Allocator /* , cache_rese
ui.prev_cache = (& ui.caches[0])
allocation_error : AllocatorError
ui.render_queue, allocation_error = array_init_reserve( UI_RenderBoxInfo, cache_allocator, UI_Built_Boxes_Array_Size, fixed_cap = true )
ui.render_queue, allocation_error = make( Array(UI_RenderBoxInfo), UI_Built_Boxes_Array_Size, cache_allocator, fixed_cap = true )
verify( allocation_error == AllocatorError.None, "Failed to allocate render queue" )
log("ui_startup completed")

View File

@ -14,15 +14,15 @@ UI_FloatingBuilder :: #type proc( captures : rawptr ) -> (became_active : b32)
UI_FloatingManager :: struct {
using links : DLL_NodeFL(UI_Floating),
build_queue : Array(UI_Floating),
tracked : HMapChainedPtr(UI_Floating),
tracked : HMapChained(UI_Floating),
}
ui_floating_startup :: proc( self : ^UI_FloatingManager, allocator : Allocator, build_queue_cap, tracked_cap : u64, dbg_name : string = "" ) -> AllocatorError
ui_floating_startup :: proc( self : ^UI_FloatingManager, build_queue_cap, tracked_cap : u64, allocator := context.allocator, dbg_name : string = "" ) -> AllocatorError
{
error : AllocatorError
queue_dbg_name := str_intern(str_fmt("%s: build_queue", dbg_name))
self.build_queue, error = array_init_reserve( UI_Floating, allocator, build_queue_cap, dbg_name = queue_dbg_name.str )
self.build_queue, error = make( Array(UI_Floating), build_queue_cap, dbg_name = queue_dbg_name.str, allocator = allocator )
if error != AllocatorError.None
{
ensure(false, "Failed to allocate the build_queue")
@ -30,7 +30,7 @@ ui_floating_startup :: proc( self : ^UI_FloatingManager, allocator : Allocator,
}
tracked_dbg_name := str_intern(str_fmt("%s: tracked", dbg_name))
self.tracked, error = hmap_chained_init(UI_Floating, uint(tracked_cap), allocator, dbg_name = tracked_dbg_name.str )
self.tracked, error = make( HMapChained(UI_Floating), uint(tracked_cap), allocator, dbg_name = tracked_dbg_name.str )
if error != AllocatorError.None
{
ensure(false, "Failed to allocate tracking table")

View File

@ -189,7 +189,7 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
// index := 0
widgets : Array(UI_Widget)
// widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 8 )
widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 4 * Kilobyte )
widgets, alloc_error = make( Array(UI_Widget), 4 * Kilobyte )
widgets_ptr := & widgets
label_id := 0