Skip to documentation
SLOP

tiny.gui.FrameStorage

Reference tiny.gui FrameStorage

Defined in frame.

API (19)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callsframeFrameStorage
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/gui/src/frame.zig:192

zig
pub const FrameStorage = struct {    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "gui.frame_storage",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "root_frame_slots_at_the_admitted_root_quota",                        .lifetime = .steady,                        .detail = "root frame slots at the admitted root quota",                    },                    .{                        .id = "widget_frame_slots_at_the_surveyed_shell_and_solved_node_count",                        .lifetime = .steady,                        .detail = "widget frame slots at the surveyed shell and solved node count",                    },                    .{                        .id = "flex_node_spans_at_the_surveyed_child_count",                        .lifetime = .steady,                        .detail = "flex node spans at the surveyed child count",                    },                    .{                        .id = "layout_node_state_spans_at_the_surveyed_shell_node_count",                        .lifetime = .steady,                        .detail = "layout node-state spans at the surveyed shell node count",                    },                    .{                        .id = "layout_child_index_result_metric_and_line_spans",                        .lifetime = .steady,                        .detail = "layout child-index, result, metric, and line spans",                    },                },                .excluded = &.{                    "the caller-owned UiSurfaceTree, solved spans, and strings",                    "resolver callbacks and any storage they touch",                    "sdfii semantics byte ownership and root-id ordering scratch",                    "paint command, atlas, and executor storage",                    "epoch replacement allocation and release outside one admitted demand epoch",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "roots", "roots"),                    alloc_phase.capacity.bindInput(Limits, "nodes", "nodes"),                    alloc_phase.capacity.bindInput(Limits, "children", "children"),                    alloc_phase.capacity.bindInput(Limits, "layout_nodes", "layout_nodes"),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(RootFrame, "root"),                    alloc_phase.capacity.bindType(WidgetFrame, "widget"),                    alloc_phase.capacity.bindType(flex_layout.NodeState, "state"),                    alloc_phase.capacity.bindType(flex_layout.Node, "node"),                    alloc_phase.capacity.bindType(flex_layout.LayoutResult, "result"),                    alloc_phase.capacity.bindType(flex_layout.ChildIndex, "index"),                    alloc_phase.capacity.bindType(flex_layout.ChildMetrics, "metric"),                    alloc_phase.capacity.bindType(flex_layout.Line, "line"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 0 } } },                    .{ .input = 1 },                    .{ .constant = 1 },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 1 } } },                    .{ .product = .{ .left = 2, .right = 4 } },                    .{ .input = 3 },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 2 } } },                    .{ .product = .{ .left = 6, .right = 7 } },                    .{ .input = 2 },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 3 } } },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 4 } } },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 5 } } },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 6 } } },                    .{ .scale = .{ .node = 3, .coefficient = .{ .size_of_concrete_type = 7 } } },                    .{ .add = .{ .left = 10, .right = 11 } },                    .{ .add = .{ .left = 15, .right = 12 } },                    .{ .add = .{ .left = 16, .right = 13 } },                    .{ .add = .{ .left = 17, .right = 14 } },                    .{ .product = .{ .left = 9, .right = 18 } },                    .{ .add = .{ .left = 1, .right = 5 } },                    .{ .add = .{ .left = 20, .right = 8 } },                    .{ .add = .{ .left = 21, .right = 19 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 22,                }},            },            .overload = .{                .kind = .reject_before_seal,                .detail = "surveyFrameRoot rejects invalid or over-deep shell and solved trees before acquisition; demand past the admitted epoch re-derives storage at the new high water before building; carve past admitted capacity is a capacity-model bug caught by assertion",            },            .risks = .{                .transitive = .{                    .status = .open,                    .detail = "the build crosses layout, widget query, and model helpers without a machine-checked call-graph closure certificate",                },                .foreign = .{                    .status = .open,                    .detail = "resolver callbacks (text measurement, scroll, selection) run host code outside the claim during builds",                },            },            .obligations = &.{                .{ .key = "gui_frame_capacity", .role = .capacity_model },                .{ .key = "gui_frame_acquisition", .role = .custom },                .{ .key = "gui_frame_survey", .role = .overload },                .{ .key = "gui_frame_highwater", .role = .overload },                .{ .key = "gui_frame_steady_transitive_risk", .role = .transitive_risk },                .{ .key = "gui_frame_steady_foreign_risk", .role = .foreign_risk },                .{ .key = "gui_frame_oom", .role = .custom },                .{ .key = "gui_frame_session", .role = .custom },                .{ .key = "gui_frame_session_steady", .role = .transitive_risk },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },        },    };    pub const Limits = struct {        nodes: usize,        layout_nodes: usize,        children: usize,        roots: usize,    };    pub const Capacity = struct {        roots: usize,        widgets: usize,        flex_nodes: usize,        layout_results: usize,        layout_metrics: usize,        layout_lines: usize,        layout_states: usize,        layout_child_indices: usize,        total_bytes: usize,        pub fn derive(limits: Limits) error{CapacityOverflow}!Capacity {            if (limits.roots == 0) return error.CapacityOverflow;            if (limits.nodes == 0) return error.CapacityOverflow;            if (limits.layout_nodes == 0 or limits.layout_nodes > limits.nodes) return error.CapacityOverflow;            const root_bytes = std.math.mul(                usize,                limits.roots,                @sizeOf(RootFrame),            ) catch return error.CapacityOverflow;            const widget_bytes = std.math.mul(                usize,                limits.nodes,                @sizeOf(WidgetFrame),            ) catch return error.CapacityOverflow;            const state_bytes = std.math.mul(                usize,                limits.layout_nodes,                @sizeOf(flex_layout.NodeState),            ) catch return error.CapacityOverflow;            const per_child = @sizeOf(flex_layout.Node) +                @sizeOf(flex_layout.LayoutResult) +                @sizeOf(flex_layout.ChildIndex) +                @sizeOf(flex_layout.ChildMetrics) +                @sizeOf(flex_layout.Line);            const child_bytes = std.math.mul(                usize,                limits.children,                per_child,            ) catch return error.CapacityOverflow;            const frame_bytes = std.math.add(                usize,                root_bytes,                widget_bytes,            ) catch return error.CapacityOverflow;            const owned_node_bytes = std.math.add(                usize,                frame_bytes,                state_bytes,            ) catch return error.CapacityOverflow;            const total_bytes = std.math.add(                usize,                owned_node_bytes,                child_bytes,            ) catch return error.CapacityOverflow;            return .{                .roots = limits.roots,                .widgets = limits.nodes,                .flex_nodes = limits.children,                .layout_results = limits.children,                .layout_metrics = limits.children,                .layout_lines = limits.children,                .layout_states = limits.layout_nodes,                .layout_child_indices = limits.children,                .total_bytes = total_bytes,            };        }    };    phase: alloc_phase.capacity.Phase,    capacity: Capacity,    limits: Limits,    roots: []RootFrame,    roots_used: usize,    widgets: []WidgetFrame,    widgets_used: usize,    flex_nodes: []flex_layout.Node,    flex_used: usize,    layout_scratch: flex_layout.Scratch,    pub fn init(allocator: Allocator, limits: Limits) !FrameStorage {        const capacity = try Capacity.derive(limits);        const roots = try allocator.alloc(RootFrame, capacity.roots);        errdefer allocator.free(roots);        const widgets = try allocator.alloc(WidgetFrame, capacity.widgets);        errdefer allocator.free(widgets);        const flex_nodes = try allocator.alloc(flex_layout.Node, capacity.flex_nodes);        errdefer allocator.free(flex_nodes);        const results = try allocator.alloc(flex_layout.LayoutResult, capacity.layout_results);        errdefer allocator.free(results);        const metrics = try allocator.alloc(flex_layout.ChildMetrics, capacity.layout_metrics);        errdefer allocator.free(metrics);        const lines = try allocator.alloc(flex_layout.Line, capacity.layout_lines);        errdefer allocator.free(lines);        const states = try allocator.alloc(flex_layout.NodeState, capacity.layout_states);        errdefer allocator.free(states);        const child_indices = try allocator.alloc(            flex_layout.ChildIndex,            capacity.layout_child_indices,        );        return .{            .phase = .initialization,            .capacity = capacity,            .limits = limits,            .roots = roots,            .roots_used = 0,            .widgets = widgets,            .widgets_used = 0,            .flex_nodes = flex_nodes,            .flex_used = 0,            .layout_scratch = .{                .results = results,                .metrics = metrics,                .lines = lines,                .states = states,                .child_indices = child_indices,            },        };    }    pub fn activate(self: *FrameStorage) void {        std.debug.assert(self.phase == .initialization);        self.assertStorage();        self.phase = .steady;    }    pub fn deinit(self: *FrameStorage, allocator: Allocator) void {        std.debug.assert(self.phase != .teardown);        self.assertStorage();        self.phase = .teardown;        allocator.free(self.roots);        allocator.free(self.widgets);        allocator.free(self.flex_nodes);        allocator.free(self.layout_scratch.results);        allocator.free(self.layout_scratch.metrics);        allocator.free(self.layout_scratch.lines);        allocator.free(self.layout_scratch.states);        allocator.free(self.layout_scratch.child_indices);    }    pub fn admits(self: *const FrameStorage, facts: SurfaceFacts, roots: usize) bool {        std.debug.assert(self.phase == .steady);        if (facts.nodes > self.capacity.widgets) return false;        if (facts.layout_nodes > self.capacity.layout_states) return false;        if (facts.children > self.capacity.flex_nodes) return false;        return roots <= self.capacity.roots;    }    pub fn reset(self: *FrameStorage) void {        std.debug.assert(self.phase == .steady);        self.roots_used = 0;        self.widgets_used = 0;        self.flex_used = 0;        self.layout_scratch.reset();    }    fn carveFlexNodes(self: *FrameStorage, count: usize) []flex_layout.Node {        std.debug.assert(self.flex_used + count <= self.flex_nodes.len);        const span = self.flex_nodes[self.flex_used..][0..count];        self.flex_used += count;        return span;    }    fn assertStorage(self: *const FrameStorage) void {        const expected = Capacity.derive(self.limits) catch unreachable;        std.debug.assert(std.meta.eql(expected, self.capacity));        std.debug.assert(self.roots.len == self.capacity.roots);        std.debug.assert(self.widgets.len == self.capacity.widgets);        std.debug.assert(self.flex_nodes.len == self.capacity.flex_nodes);        std.debug.assert(self.layout_scratch.results.len == self.capacity.layout_results);        std.debug.assert(self.layout_scratch.metrics.len == self.capacity.layout_metrics);        std.debug.assert(self.layout_scratch.lines.len == self.capacity.layout_lines);        std.debug.assert(self.layout_scratch.states.len == self.capacity.layout_states);        std.debug.assert(            self.layout_scratch.child_indices.len == self.capacity.layout_child_indices,        );    }};

Source: lib/gui/src/root.zig:18

zig
pub const FrameStorage = @import("frame.zig").FrameStorage;
Called byCallsNo direct callsprivate sourcelib.gui.src.frame.FrameStorageassertStorageFrameStorageinittest sourcelib.gui.src.frametest: FrameStorage capacity matches a...FrameStorage.Capacityderive
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsframe.Sessionbeginprivate sourcelib.gui.src.frame.WorkspaceensureStoragetest sourcelib.gui.src.frametest: FrameStorage acquires the exact...private sourcelib.gui.src.frame.FrameStorageassertStorageFrameStorageactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.gui.src.frametest: FrameStorage acquires the exact...FrameStorageadmits
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.gui.src.frametest: FrameStorage acquires the exact...private sourcelib.gui.src.frame.FrameStorageassertStorageFrameStoragedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsframe.Sessionbeginprivate sourcelib.gui.src.frame.WorkspaceensureStoragetest sourcelib.gui.src.frametest: FrameStorage acquires the exact...FrameStorage.CapacityderiveFrameStorageinit
Static calls · unresolved targets: 0 · external targets: 2.

Audit

Definitions10
Public names20
Members23
Version26.7.0
Revisiondaab053ee433