tiny.filigree.FallbackWorkspace
Defined in tiny.filigree.
API (17)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/filigree/src/fallback/workspace.zig:15
zig
pub const Workspace = struct { phase: alloc_phase.capacity.Phase, capacity: capacity_mod.Capacity, bytes: []align(capacity_mod.storage_alignment) u8, scalars: std.ArrayList(model.Scalar), clusters: std.ArrayList(model.SourceCluster), ranges: std.ArrayList(model.SegmentRange), pub const Limits: type = capacity_mod.Limits; pub const Capacity: type = capacity_mod.Capacity; pub const Exhaustion: type = model.Exhaustion; pub const InitError = std.mem.Allocator.Error || capacity_mod.DeriveError; pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "filigree.fallback_workspace", .kind = .phase_static, .limit_source = .caller, .storage = .{ .covered = &.{ .{ .id = "decoded_fallback_scalars", .lifetime = .steady, .detail = "decoded scalar descriptors used for face coverage", }, .{ .id = "grapheme_safe_fallback_clusters", .lifetime = .steady, .detail = "grapheme and joining-cluster descriptors", }, .{ .id = "fallback_face_segment_ranges", .lifetime = .steady, .detail = "script and selected-face segment descriptors", }, }, .excluded = &.{ "caller-owned source units and fallback candidates", "shape engine, shape output, and script-run storage", "caller-owned reported face segments", }, }, .capacity = .{ .inputs = &.{ alloc_phase.capacity.bindInput(Limits, "max_source_units", "max_source_units"), }, .type_selectors = &.{ alloc_phase.capacity.bindType(model.Scalar, "scalar"), alloc_phase.capacity.bindType(model.SourceCluster, "sourcecluster"), alloc_phase.capacity.bindType(model.SegmentRange, "segmentrange"), }, .nodes = &.{ .{ .input = 0 }, .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 0 } } }, .{ .alignment = .{ .node = 1, .alignment = .{ .concrete_type = 1 } } }, .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 1 } } }, .{ .add = .{ .left = 2, .right = 3 } }, .{ .alignment = .{ .node = 4, .alignment = .{ .concrete_type = 2 } } }, .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 2 } } }, .{ .add = .{ .left = 5, .right = 6 } }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .exact, .expression = 7, }}, }, .overload = .{ .kind = .reject_before_mutation, .detail = "a max-plus-one source rejects before prior scalar, cluster, or face-range state changes", }, .risks = .{ .transitive = .{ .status = .witnessed, .detail = "fallback collection and segmentation use only activated typed regions", }, .foreign = .{ .status = .excluded, .detail = "workspace collection and segmentation cross no operating-system or foreign callback boundary", }, }, .obligations = &.{ .{ .key = "filigree_fallback_workspace_capacity", .role = .capacity_model }, .{ .key = "filigree_fallback_workspace_acquisition", .role = .custom }, .{ .key = "filigree_fallback_workspace_oom", .role = .custom }, .{ .key = "filigree_fallback_workspace_boundaries", .role = .overload }, .{ .key = "filigree_fallback_workspace_reuse", .role = .overload }, .{ .key = "filigree_fallback_workspace_sealed_transitive_risk", .role = .transitive_risk }, .{ .key = "filigree_fallback_workspace_sealed_foreign_risk", .role = .foreign_risk }, .{ .key = "filigree_fallback_workspace_root", .role = .custom }, }, }, .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 fn init(allocator: std.mem.Allocator, limits: Limits) InitError!Workspace { const capacity = try Capacity.derive(limits); const bytes = try allocator.alignedAlloc( u8, .fromByteUnits(capacity_mod.storage_alignment), capacity.storage_bytes, ); return .{ .phase = .initialization, .capacity = capacity, .bytes = bytes, .scalars = .initBuffer(typedSlice(model.Scalar, bytes, capacity.scalar_offset, limits.max_source_units)), .clusters = .initBuffer(typedSlice(model.SourceCluster, bytes, capacity.cluster_offset, limits.max_source_units)), .ranges = .initBuffer(typedSlice(model.SegmentRange, bytes, capacity.range_offset, limits.max_source_units)), }; } pub fn activate(self: *Workspace) void { std.debug.assert(self.phase == .initialization); self.assertStorage(); self.phase = .steady; } pub fn deinit(self: *Workspace, allocator: std.mem.Allocator) void { std.debug.assert(self.phase != .teardown); self.assertStorage(); self.phase = .teardown; allocator.free(self.bytes); self.bytes = &.{}; self.scalars = .empty; self.clusters = .empty; self.ranges = .empty; } pub fn begin(self: *Workspace, source_units: usize) Exhaustion!void { std.debug.assert(self.phase == .steady); if (source_units > self.capacity.limits.max_source_units) { return error.SourceUnitCapacityExceeded; } self.reset(); } pub fn reset(self: *Workspace) void { std.debug.assert(self.phase == .steady); self.scalars.clearRetainingCapacity(); self.clusters.clearRetainingCapacity(); self.ranges.clearRetainingCapacity(); } pub fn status(self: *const Workspace) Status { return .{ .phase = self.phase, .storage_bytes = self.capacity.storage_bytes, .max_source_units = self.capacity.limits.max_source_units, .scalar_count = self.scalars.items.len, .cluster_count = self.clusters.items.len, .range_count = self.ranges.items.len, }; } fn assertStorage(self: *const Workspace) void { std.debug.assert(self.bytes.len == self.capacity.storage_bytes); std.debug.assert(self.scalars.capacity == self.capacity.limits.max_source_units); std.debug.assert(self.clusters.capacity == self.capacity.limits.max_source_units); std.debug.assert(self.ranges.capacity == self.capacity.limits.max_source_units); std.debug.assert(self.scalars.items.len <= self.scalars.capacity); std.debug.assert(self.clusters.items.len <= self.clusters.capacity); std.debug.assert(self.ranges.items.len <= self.ranges.capacity); }};Source: lib/filigree/src/root.zig:44
zig
pub const FallbackWorkspace = fallback.Workspace;Also reachable as
Audit
| Definitions | 9 |
|---|---|
| Public names | 18 |
| Members | 6 |
| Version | 26.7.0 |
| Revision | daab053ee433 |